:root {
  color-scheme: light;
  --page: #f5f7f5;
  --surface: #ffffff;
  --surface-alt: #eef2ef;
  --sidebar: #202825;
  --sidebar-hover: #2b3732;
  --sidebar-text: #edf3ef;
  --sidebar-muted: #9caaa3;
  --text: #18201d;
  --muted: #68746e;
  --border: #d7ddd9;
  --border-strong: #bac5bf;
  --emerald: #187a57;
  --emerald-strong: #105e43;
  --emerald-soft: #e4f1eb;
  --amber: #b76a28;
  --amber-soft: #f5eadf;
  --danger: #b9473e;
  --shadow: 0 12px 34px rgba(24, 32, 29, .06);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #111714;
  --surface: #18201d;
  --surface-alt: #202a25;
  --sidebar: #0b110e;
  --sidebar-hover: #18241e;
  --sidebar-text: #edf3ef;
  --sidebar-muted: #8fa098;
  --text: #edf2ef;
  --muted: #a0aea7;
  --border: #35423b;
  --border-strong: #506159;
  --emerald: #50b98a;
  --emerald-strong: #75cda5;
  --emerald-soft: #203c30;
  --amber: #e29a55;
  --amber-soft: #3d2f21;
  --danger: #e0746b;
  --shadow: 0 12px 34px rgba(0, 0, 0, .18);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --page: #111714;
    --surface: #18201d;
    --surface-alt: #202a25;
    --sidebar: #0b110e;
    --sidebar-hover: #18241e;
    --sidebar-text: #edf3ef;
    --sidebar-muted: #8fa098;
    --text: #edf2ef;
    --muted: #a0aea7;
    --border: #35423b;
    --border-strong: #506159;
    --emerald: #50b98a;
    --emerald-strong: #75cda5;
    --emerald-soft: #203c30;
    --amber: #e29a55;
    --amber-soft: #3d2f21;
    --danger: #e0746b;
    --shadow: 0 12px 34px rgba(0, 0, 0, .18);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--text); background: var(--page); font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
[hidden] { display: none !important; }

.app-layout { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 16px 18px; color: var(--sidebar-text); background: var(--sidebar); }
.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; font-size: 16px; font-weight: 800; letter-spacing: -.35px; }
.brand-mark { width: 31px; height: 31px; display: inline-grid; place-items: center; color: white; background: var(--emerald); font: 800 18px/1 Georgia, serif; }
.sidebar-nav { display: grid; gap: 3px; margin-top: 31px; }
.nav-label { margin: 0 10px 8px; color: var(--sidebar-muted); font-size: 10px; font-weight: 800; letter-spacing: 1.25px; }
.game-filter, .sidebar-nav a { width: 100%; min-height: 40px; display: flex; align-items: center; justify-content: space-between; padding: 0 11px; border: 0; color: var(--sidebar-muted); background: transparent; text-decoration: none; text-align: left; cursor: pointer; font-size: 12px; font-weight: 650; }
.game-filter:hover, .sidebar-nav a:hover { color: var(--sidebar-text); background: var(--sidebar-hover); }
.game-filter.active { color: white; background: var(--emerald); }
.game-filter i { font-style: normal; font-size: 17px; }
.analysis-nav { margin-top: 25px; }
.storage-status { margin-top: auto; padding: 14px 12px; border: 1px solid rgba(255,255,255,.12); display: grid; gap: 3px; }
.storage-status span, .storage-status small { color: var(--sidebar-muted); font-size: 10px; }
.storage-status strong { margin: 2px 0; font-size: 18px; }

.app-shell { min-width: 0; }
.topbar { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 11px 30px; border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar-title { display: grid; gap: 3px; }
.topbar-title strong { font-size: 14px; }
.topbar-title span { color: var(--muted); font-size: 10px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.theme-switch { display: inline-flex; border: 1px solid var(--border); background: var(--surface-alt); }
.theme-switch button { min-height: 34px; padding: 0 9px; border: 0; border-right: 1px solid var(--border); color: var(--muted); background: transparent; cursor: pointer; font-size: 10px; font-weight: 700; }
.theme-switch button:last-child { border-right: 0; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button.active { color: var(--emerald-strong); background: var(--surface); box-shadow: inset 0 -2px var(--emerald); }
.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; padding: 0 15px; border: 1px solid var(--border-strong); color: var(--text); background: var(--surface); cursor: pointer; text-decoration: none; font-size: 11px; font-weight: 750; }
.button:hover:not(:disabled) { border-color: var(--emerald); color: var(--emerald-strong); }
.button:disabled { opacity: .65; cursor: wait; }
.button.primary { border-color: var(--emerald); color: white; background: var(--emerald); }
.button-icon { margin-right: 6px; font-size: 16px; }
.is-loading .button-icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.dashboard-main { width: min(1240px, calc(100% - 52px)); margin: 0 auto; padding: 42px 0 64px; }
.game-section { scroll-margin-top: 20px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 23px; }
.eyebrow, .card-label { margin: 0 0 7px; color: var(--emerald-strong); font-size: 9px; font-weight: 850; letter-spacing: 1.15px; text-transform: uppercase; }
.section-heading h1 { margin-bottom: 8px; font-size: clamp(29px, 3.4vw, 43px); line-height: 1; letter-spacing: -1.8px; }
.section-description { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.text-link, .quick-stat-head a { color: var(--emerald-strong); font-size: 10px; font-weight: 750; text-decoration: none; white-space: nowrap; }
.text-link:hover, .quick-stat-head a:hover { text-decoration: underline; }

.summary-grid { display: grid; grid-template-columns: 1.7fr repeat(3, 1fr); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.summary-grid > article { min-height: 134px; padding: 19px; border-right: 1px solid var(--border); }
.summary-grid > article:last-child { border-right: 0; }
.summary-latest { background: var(--sidebar); color: var(--sidebar-text); }
.summary-latest .card-label { color: var(--sidebar-muted); }
.latest-meta { display: flex; justify-content: space-between; margin: 13px 0 17px; color: var(--sidebar-muted); font-size: 10px; }
.summary-stat { display: flex; flex-direction: column; justify-content: center; }
.summary-stat span { color: var(--muted); font-size: 10px; }
.summary-stat strong { margin: 8px 0 5px; font-size: clamp(19px, 2vw, 28px); letter-spacing: -1px; }
.summary-stat small { color: var(--muted); font-size: 9px; }
.balls, .prediction-balls, .mini-balls, .history-balls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ball { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 1px solid var(--border-strong); border-radius: 50%; color: var(--text); background: var(--surface); font-size: 11px; font-weight: 850; }
.summary-latest .ball { border-color: rgba(255,255,255,.25); color: white; background: rgba(255,255,255,.08); }
.ball.special { border-color: var(--amber); color: white; background: var(--amber); }
.plus { color: var(--muted); }
.no-results, .muted { color: var(--muted); font-size: 11px; line-height: 1.5; }

.model-section { margin-top: 18px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.model-section, .frequency-card, .history-card { scroll-margin-top: 20px; }
.model-heading { display: flex; align-items: start; justify-content: space-between; gap: 25px; padding: 20px; border-bottom: 1px solid var(--border); }
.model-heading h3 { margin-bottom: 6px; font-size: 18px; letter-spacing: -.5px; }
.model-heading p { max-width: 760px; margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.model-status { flex: 0 0 auto; min-width: 125px; padding: 9px 11px; display: grid; gap: 2px; border-left: 3px solid var(--emerald); background: var(--emerald-soft); text-align: right; }
.model-status strong { color: var(--emerald-strong); font-size: 11px; }
.model-status span { color: var(--muted); font-size: 9px; }
.prediction-list { display: grid; }
.prediction-group-heading { min-height: 49px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 10px 20px; border-bottom: 1px solid var(--border); background: var(--surface-alt); }
.prediction-group-heading > div { display: grid; gap: 2px; }
.prediction-group-heading strong { font-size: 11px; }
.prediction-group-heading small, .prediction-group-heading > span { color: var(--muted); font-size: 8px; }
.prediction-group-heading > span { padding: 4px 7px; border: 1px solid var(--border-strong); font-weight: 750; letter-spacing: .4px; text-transform: uppercase; }
.hybrid-heading { border-top: 3px solid var(--emerald); background: var(--emerald-soft); }
.prediction-row { min-width: 0; display: grid; grid-template-columns: 62px minmax(210px, 1.1fr) minmax(255px, .9fr) minmax(200px, 1fr) 72px; align-items: center; gap: 15px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.prediction-row:last-child { border-bottom: 0; }
.prediction-row:hover { background: var(--surface-alt); }
.hybrid-row { background: color-mix(in srgb, var(--emerald-soft) 35%, var(--surface)); }
.hybrid-row:hover { background: var(--emerald-soft); }
.prediction-rank { display: grid; gap: 2px; }
.prediction-rank small { color: var(--muted); font-size: 8px; letter-spacing: .8px; }
.prediction-rank strong { font-size: 12px; }
.prediction-rank .prediction-parents { color: var(--emerald-strong); font-size: 7px; letter-spacing: 0; white-space: nowrap; }
.prediction-balls .ball { width: 31px; height: 31px; color: white; border-color: var(--emerald-strong); background: var(--emerald-strong); font-size: 10px; }
.prediction-balls .ball.special { border-color: var(--amber); background: var(--amber); }
.hybrid-row .prediction-balls .ball:not(.special) { color: var(--emerald-strong); background: var(--surface); }
.score-components { display: grid; gap: 4px; }
.score-row { display: grid; grid-template-columns: 48px 1fr 26px; align-items: center; gap: 6px; color: var(--muted); font-size: 8px; }
.score-row i { height: 3px; display: block; background: var(--surface-alt); }
.score-row i b { width: var(--score); height: 100%; display: block; background: var(--emerald); }
.score-row > strong { color: var(--text); font-size: 8px; text-align: right; }
.prediction-meta { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 11px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.prediction-meta strong { color: var(--text); }
.model-score { display: grid; text-align: right; }
.model-score strong { color: var(--emerald-strong); font-size: 21px; letter-spacing: -.8px; }
.model-score small { color: var(--muted); font-size: 8px; }
.model-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; padding: 15px 20px; border-top: 1px solid var(--border); background: var(--emerald-soft); }
.model-foot p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.55; }
.model-foot strong { color: var(--text); }

.quick-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.card { min-width: 0; padding: 18px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.quick-stat-head, .card-title-row { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.quick-stat-head small { color: var(--muted); font-size: 9px; }
.suggestion-balls { min-height: 54px; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.metric-ball { width: 52px; min-height: 48px; display: grid; place-items: center; padding: 5px; border: 1px solid var(--border); background: var(--surface-alt); }
.metric-ball span { font-size: 13px; font-weight: 850; }
.metric-ball small { color: var(--muted); font-size: 8px; }
.metric-ball.cold { border-bottom: 3px solid var(--emerald); }
.metric-ball.gap, .metric-ball.special-metric { border-bottom: 3px solid var(--amber); background: var(--amber-soft); }
.card-footnote { margin: 12px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.analysis-strip { display: grid; grid-template-columns: 1fr 1fr 1.15fr; border: 1px solid var(--border); border-top: 0; background: var(--surface); }
.analysis-note { min-height: 92px; display: grid; align-content: center; gap: 5px; padding: 14px 18px; border-right: 1px solid var(--border); }
.analysis-note:last-child { border-right: 0; }
.analysis-note > span { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; }
.analysis-note strong { font-size: 12px; }
.analysis-note small { color: var(--muted); font-size: 9px; line-height: 1.4; }
.balance-note { background: var(--amber-soft); }
.mini-balls .ball { width: 23px; height: 23px; font-size: 8px; }
.mini-balls .plus { font-size: 11px; }

.details-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(290px, .75fr); gap: 14px; margin-top: 14px; }
.card-title-row h2 { margin: 0; font-size: 18px; letter-spacing: -.5px; }
.expected { padding: 5px 7px; color: var(--emerald-strong); background: var(--emerald-soft); white-space: nowrap; font-size: 9px; font-weight: 750; }
.table-wrap { overflow-x: auto; margin-top: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 10px; }
th { padding: 8px 6px; border-bottom: 1px solid var(--border-strong); color: var(--muted); font-size: 8px; letter-spacing: .7px; text-align: left; text-transform: uppercase; }
td { padding: 8px 6px; border-bottom: 1px solid var(--border); }
.count-cell { display: flex; align-items: center; gap: 7px; }
.count-cell i { width: var(--bar); max-width: 65px; height: 3px; display: block; background: var(--emerald); }
.history-list { display: grid; }
.history-row { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--border); }
.history-row > div:first-child { display: grid; gap: 2px; font-size: 9px; white-space: nowrap; }
.history-row span { color: var(--muted); font-size: 8px; }
.history-balls { justify-content: flex-end; gap: 3px; }
.history-balls .ball { width: 20px; height: 20px; font-size: 7px; }
.history-balls .plus { font-size: 10px; }
.special-summary { margin-bottom: 17px; padding-bottom: 15px; border-bottom: 1px solid var(--border); }
.empty-panel { margin-bottom: 20px; padding: 16px; display: grid; gap: 3px; border: 1px dashed var(--border-strong); color: var(--muted); background: var(--surface); font-size: 11px; }
footer { padding: 27px; color: var(--muted); font-size: 9px; text-align: center; }

/* Trang giải thích dùng cùng hệ màu Data Desk. */
.shell { width: min(1120px, calc(100% - 40px)); margin: 0 auto; }
.shell > .topbar { padding-left: 0; padding-right: 0; }
.shell .brand { color: var(--text); }
.brand-muted { color: var(--emerald); }
.topnav { display: flex; margin-left: auto; }
.topnav a { padding: 9px 11px; color: var(--muted); text-decoration: none; font-size: 10px; font-weight: 700; }
.topnav a.active { color: var(--emerald-strong); border-bottom: 2px solid var(--emerald); }
.guide-page { padding: 56px 0 30px; }
.guide-hero { max-width: 850px; padding-bottom: 37px; }
.guide-hero h1 { margin-bottom: 17px; font-size: clamp(34px, 5vw, 58px); line-height: 1.02; letter-spacing: -2.8px; }
.guide-hero h1 em { color: var(--emerald-strong); font-family: Georgia, serif; font-weight: 500; }
.hero-text { max-width: 700px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.notice { display: flex; gap: 11px; padding: 15px; border: 1px solid var(--emerald); background: var(--emerald-soft); color: var(--text); font-size: 11px; line-height: 1.55; }
.notice p { margin: 0; }
.notice-dot { flex: 0 0 auto; width: 7px; height: 7px; margin-top: 5px; background: var(--emerald); }
.guide-section { padding: 45px 0; border-bottom: 1px solid var(--border); }
.guide-heading { margin-bottom: 19px; }
.guide-heading h2 { margin: 0; font-size: 25px; letter-spacing: -.9px; }
.term-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.term-card, .example-card { padding: 18px; border: 1px solid var(--border); background: var(--surface); }
.term-card h3, .example-card h3 { margin-bottom: 7px; font-size: 14px; }
.term-card p, .example-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.term-card strong { color: var(--text); }
.example-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; }
.example-card.emphasis { border-color: var(--emerald); background: var(--emerald-soft); }
.example-tag { display: block; margin-bottom: 18px; color: var(--emerald-strong); font-size: 8px; font-weight: 850; letter-spacing: .9px; }
.guide-table-wrap { border: 1px solid var(--border); }
.guide-table th { background: var(--surface-alt); }
.guide-table td { color: var(--muted); }
.guide-caption { margin: 12px 0 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.guide-steps { border-bottom: 0; }
.guide-steps ol { display: grid; gap: 10px; padding-left: 19px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.guide-steps strong { color: var(--text); }

@media (max-width: 1100px) {
  .prediction-row { grid-template-columns: 54px minmax(190px, 1fr) minmax(210px, .9fr) 68px; }
  .prediction-meta { display: none; }
  .summary-grid { grid-template-columns: 1.5fr repeat(3, 1fr); }
}
@media (max-width: 860px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 13px 18px; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 13px; }
  .sidebar-nav { display: flex; margin: 0; overflow-x: auto; }
  .nav-label, .analysis-nav, .storage-status { display: none; }
  .game-filter { width: auto; min-width: max-content; }
  .game-filter i { display: none; }
  .topbar { padding: 10px 18px; }
  .dashboard-main { width: min(100% - 30px, 1240px); padding-top: 30px; }
  .summary-grid { grid-template-columns: 1.4fr 1fr; }
  .summary-grid > article:nth-child(2) { border-right: 0; }
  .summary-grid > article:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .prediction-row { grid-template-columns: 55px 1fr 70px; }
  .score-components { grid-column: 2 / -1; }
  .quick-stats, .details-grid, .model-foot, .term-grid { grid-template-columns: 1fr; }
  .analysis-strip { grid-template-columns: 1fr; }
  .analysis-note { border-right: 0; border-bottom: 1px solid var(--border); }
  .analysis-note:last-child { border-bottom: 0; }
  .example-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .sidebar { grid-template-columns: 1fr; }
  .sidebar .brand { display: none; }
  .topbar-title span { display: none; }
  .theme-switch button span { display: none; }
  .theme-switch button { min-width: 31px; padding: 0 7px; }
  .button { padding: 0 10px; }
  .section-heading { display: grid; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-latest { grid-column: 1 / -1; }
  .summary-grid > article { min-height: 108px; }
  .summary-grid > article:first-child { border-right: 0; }
  .summary-grid > article:nth-child(2) { border-right: 1px solid var(--border); }
  .summary-grid > article:nth-child(3) { border-right: 0; }
  .summary-grid > article:last-child { grid-column: 1 / -1; border-top: 1px solid var(--border); }
  .model-heading { display: grid; }
  .model-status { width: 100%; text-align: left; }
  .prediction-row { grid-template-columns: 46px 1fr 60px; padding: 13px; gap: 9px; }
  .prediction-balls { gap: 4px; }
  .prediction-balls .ball { width: 27px; height: 27px; }
  .score-components { grid-column: 1 / -1; }
  .shell { width: min(100% - 26px, 1120px); }
  .shell .topbar { flex-wrap: wrap; }
  .topnav { order: 3; width: 100%; justify-content: center; }
  .guide-page { padding-top: 38px; }
  .guide-table { min-width: 650px; }
}
