:root {
  --bg0: #07090f;
  --bg1: #0d1220;
  --bg2: #141b2d;
  --bg3: #1c253b;
  --line: rgba(255, 214, 120, 0.12);
  --gold: #f0c14b;
  --gold2: #ffd978;
  --amber: #ff9f43;
  --cyan: #4fd1c5;
  --violet: #a78bfa;
  --rose: #fb7185;
  --green: #34d399;
  --text: #e8edf7;
  --muted: #8b95ad;
  --danger: #f87171;
  --ok: #4ade80;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(240, 193, 75, 0.12), transparent 50%),
    radial-gradient(900px 500px at 90% 0%, rgba(79, 209, 197, 0.08), transparent 45%),
    radial-gradient(800px 500px at 50% 100%, rgba(167, 139, 250, 0.08), transparent 50%),
    var(--bg0);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--cyan); }

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  background: rgba(7, 9, 15, 0.88);
  border-bottom: 1px solid var(--line);
  padding: 18px 20px 14px;
}
.header-brand-bar {
  max-width: 1440px;
  margin: 0 auto 14px;
  text-align: center;
}
.site-brand {
  margin: 0;
  font-size: clamp(2rem, 6.5vw, 3.4rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.15;
  color: var(--gold2);
  text-shadow:
    0 0 28px rgba(240, 193, 75, 0.4),
    0 2px 0 rgba(0, 0, 0, 0.35);
  background: linear-gradient(180deg, #ffe9a8 0%, var(--gold2) 45%, #c9891a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
@supports not (background-clip: text) {
  .site-brand {
    color: var(--gold2);
    -webkit-text-fill-color: unset;
  }
}
.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: left;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #f0c14b, #c9891a);
  color: #1a1200;
  font-weight: 800;
  box-shadow: 0 0 24px rgba(240, 193, 75, 0.35);
  flex-shrink: 0;
}
.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
.brand p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}
.header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.pill {
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  white-space: nowrap;
}
.pill strong { color: var(--gold2); font-weight: 700; }
.pill.live { border-color: rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.08); }
.pill.live strong { color: var(--green); }

/* Language toggle */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg2);
}
.lang-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.lang-btn:hover {
  color: var(--text);
}
.lang-btn.active {
  background: linear-gradient(145deg, rgba(240, 193, 75, 0.95), rgba(201, 137, 26, 0.95));
  color: #1a1200;
  box-shadow: 0 0 14px rgba(240, 193, 75, 0.25);
}

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px 16px 60px;
  display: grid;
  gap: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 1100px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.card {
  background: linear-gradient(180deg, rgba(28, 37, 59, 0.55), rgba(13, 18, 32, 0.9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-hd {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px 8px;
  border-bottom: 1px solid transparent;
}
.card-hd h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}
.card-hd .sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}
.card-bd { padding: 12px 16px 16px; }

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.tab {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  cursor: pointer;
}
.tab.active {
  color: #1a1200;
  background: linear-gradient(145deg, var(--gold2), var(--gold));
  border-color: transparent;
  font-weight: 700;
}

.btn {
  border: 1px solid var(--line);
  background: var(--bg3);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: 0.15s ease;
}
.btn:hover { border-color: rgba(240, 193, 75, 0.35); color: var(--gold2); }
.btn.primary {
  background: linear-gradient(145deg, #f0c14b, #d4a017);
  color: #1a1200;
  border: none;
  font-weight: 700;
}
.btn.primary:hover { filter: brightness(1.05); color: #1a1200; }
.btn.ghost { background: transparent; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.signal-list { display: grid; gap: 10px; }
.signal {
  border: 1px solid var(--line);
  background: rgba(7, 9, 15, 0.45);
  border-radius: 12px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px 12px;
  align-items: start;
}
.signal .badge {
  min-width: 54px;
  text-align: center;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.badge.bull { background: rgba(52, 211, 153, 0.15); color: var(--green); border: 1px solid rgba(52, 211, 153, 0.3); }
.badge.bear { background: rgba(248, 113, 113, 0.12); color: var(--danger); border: 1px solid rgba(248, 113, 113, 0.28); }
.badge.neut { background: rgba(167, 139, 250, 0.12); color: var(--violet); border: 1px solid rgba(167, 139, 250, 0.28); }
.badge.info { background: rgba(79, 209, 197, 0.12); color: var(--cyan); border: 1px solid rgba(79, 209, 197, 0.28); }
.signal h3 { margin: 0; font-size: 0.92rem; }
.signal p { margin: 4px 0 0; color: var(--muted); font-size: 0.8rem; }
.signal .strength {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--gold2);
  white-space: nowrap;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
.stat {
  background: rgba(7, 9, 15, 0.4);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.stat .lbl { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }
.stat .val { font-size: 1.25rem; font-weight: 750; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .hint { color: var(--muted); font-size: 0.72rem; margin-top: 2px; }

.ball-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 8px;
}
@media (max-width: 700px) {
  .ball-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}
.ball {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  background: var(--bg2);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  user-select: none;
  min-height: 46px;
}
.ball:hover { transform: translateY(-2px); }
.ball .n {
  font-weight: 800;
  font-size: 0.92rem;
  line-height: 1;
}
.ball .s {
  font-size: 0.58rem;
  color: var(--muted);
  margin-top: 2px;
  font-family: var(--mono);
}
.ball.selected {
  box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(240, 193, 75, 0.35);
  border-color: transparent;
}
.ball.hot { background: linear-gradient(160deg, rgba(248, 113, 113, 0.35), rgba(240, 193, 75, 0.2)); }
.ball.warm { background: linear-gradient(160deg, rgba(240, 193, 75, 0.28), rgba(255, 159, 67, 0.12)); }
.ball.neutral { background: var(--bg2); }
.ball.cool { background: linear-gradient(160deg, rgba(79, 209, 197, 0.18), rgba(20, 27, 45, 0.6)); }
.ball.cold { background: linear-gradient(160deg, rgba(96, 165, 250, 0.2), rgba(20, 27, 45, 0.75)); }
.ball.overdue::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 0 8px var(--violet);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.75rem;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch {
  width: 12px; height: 12px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.15);
}
.swatch.hot { background: #f87171; }
.swatch.warm { background: #f0c14b; }
.swatch.cool { background: #4fd1c5; }
.swatch.cold { background: #60a5fa; }
.swatch.overdue { background: #a78bfa; }

.table-wrap { overflow: auto; max-height: 420px; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
th, td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  text-align: left;
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  background: #12192b;
  color: var(--muted);
  font-weight: 600;
  z-index: 1;
}
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
tr:hover td { background: rgba(240, 193, 75, 0.04); }
.bar {
  height: 6px;
  border-radius: 99px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
  min-width: 70px;
}
.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
}

.pick-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 48px;
}
.pick-ball {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: linear-gradient(145deg, #f0c14b, #c9891a);
  color: #1a1200;
  box-shadow: 0 6px 16px rgba(240, 193, 75, 0.25);
}
.pick-ball.empty {
  background: transparent;
  border: 1px dashed rgba(255,255,255,0.18);
  color: var(--muted);
  box-shadow: none;
  font-weight: 500;
  font-size: 0.75rem;
}

.ticket {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(7, 9, 15, 0.35);
  margin-bottom: 10px;
}
.ticket-hd {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.ticket-hd h4 { margin: 0; font-size: 0.88rem; }
.ticket-hd .score {
  font-family: var(--mono);
  color: var(--gold2);
  font-size: 0.82rem;
}
.ticket-nums {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ticket-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.chart-bars {
  display: grid;
  gap: 6px;
}
.chart-row {
  display: grid;
  grid-template-columns: 70px 1fr 48px;
  gap: 8px;
  align-items: center;
  font-size: 0.78rem;
}
.chart-row .label { color: var(--muted); }
.chart-row .pct { font-family: var(--mono); text-align: right; color: var(--gold2); }
.hbar {
  height: 10px;
  border-radius: 99px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}
.hbar > i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #4fd1c5, #f0c14b);
}

.slider-row {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}
.weight-item {
  display: grid;
  grid-template-columns: 120px 1fr 42px;
  gap: 10px;
  align-items: center;
  font-size: 0.8rem;
}
.weight-item input[type="range"] { width: 100%; accent-color: var(--gold); }
.weight-item .wval { font-family: var(--mono); color: var(--muted); text-align: right; }

.note {
  color: var(--muted);
  font-size: 0.78rem;
  border-left: 3px solid rgba(240, 193, 75, 0.4);
  padding: 8px 12px;
  background: rgba(240, 193, 75, 0.05);
  border-radius: 0 10px 10px 0;
  margin: 0 0 12px;
}

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.gold { color: var(--gold2); }
.green { color: var(--green); }
.rose { color: var(--rose); }

.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 8px 16px 24px;
}

/* Live data refresh */
.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn-refresh .refresh-icon {
  display: inline-block;
  font-size: 1.05rem;
  line-height: 1;
  transition: transform 0.3s ease;
}
.btn-refresh.is-refreshing .refresh-icon {
  animation: spin-refresh 0.8s linear infinite;
}
.btn-refresh:disabled {
  opacity: 0.65;
  cursor: wait;
}
@keyframes spin-refresh {
  to { transform: rotate(360deg); }
}
.refresh-status {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 20px 10px;
  font-size: 0.78rem;
  color: var(--muted);
}
.refresh-status[data-kind="ok"] { color: var(--green); }
.refresh-status[data-kind="err"] { color: var(--danger); }
.refresh-status[data-kind="info"] { color: var(--cyan); }

.loading {
  min-height: 50vh;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.spark {
  display: inline-flex;
  gap: 3px;
  align-items: flex-end;
  height: 18px;
}
.spark i {
  width: 3px;
  background: var(--gold);
  border-radius: 2px;
  opacity: 0.75;
  display: block;
}

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  place-items: center;
  z-index: 100;
  padding: 16px;
}
.modal-backdrop.open { display: grid; }
.modal {
  width: min(720px, 100%);
  max-height: 85vh;
  overflow: auto;
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.modal h3 { margin-top: 0; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  border: 1px solid var(--line);
  color: var(--muted);
}
.tag.ok { color: var(--green); border-color: rgba(52,211,153,0.3); }
.tag.warn { color: var(--amber); border-color: rgba(255,159,67,0.3); }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

/* ── Password gate ─────────────────────────────────────────── */
html.gate-locked body > *:not(#gate-overlay) {
  display: none !important;
}
#gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(900px 500px at 20% 0%, rgba(240, 193, 75, 0.14), transparent 50%),
    radial-gradient(700px 400px at 90% 100%, rgba(79, 209, 197, 0.1), transparent 45%),
    var(--bg0);
}
.gate-card {
  width: min(380px, 100%);
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
  text-align: center;
}
.gate-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #f0c14b, #c9891a);
  color: #1a1200;
  font-weight: 800;
  font-size: 1.2rem;
  box-shadow: 0 0 24px rgba(240, 193, 75, 0.35);
}
.gate-card h1 {
  margin: 0 0 6px;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
}
.gate-sub {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
}
.gate-label {
  display: block;
  text-align: left;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.gate-input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg0);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--mono);
  outline: none;
  margin-bottom: 10px;
}
.gate-input:focus {
  border-color: rgba(240, 193, 75, 0.45);
  box-shadow: 0 0 0 3px rgba(240, 193, 75, 0.12);
}
.gate-error {
  margin: 0 0 10px;
  color: var(--danger);
  font-size: 0.85rem;
}
.gate-submit {
  width: 100%;
  margin-top: 4px;
  padding: 11px 14px;
}
#gate-overlay.gate-shake .gate-card {
  animation: gate-shake 0.35s ease;
}
@keyframes gate-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
