/* =====================================================================
   Easycard Tool · design system
   Tokens first (light + dark), then base, layout (sidebar shell), components.
   ===================================================================== */

:root {
  /* EasyCard brand palette (from the brand sheet):
     navy #203E78 · sky #56A8FC · light blue #ABD1FD · orange #FD9B3B · cream #FEEDD3 · light gray #E3E5F4 */
  --navy: #203E78;
  --navy-2: #2A4C8E;
  --sky: #56A8FC;
  --sky-light: #ABD1FD;
  --orange: #FD9B3B;
  --cream: #FEEDD3;
  --gray-brand: #E3E5F4;

  /* roles */
  --primary: #1F6FD1;          /* links, focus, selected (sky darkened for text contrast) */
  --primary-hover: #1A5DB0;
  --primary-soft: #EAF3FF;
  --primary-ink: #1B4E9B;
  --on-primary: #FFFFFF;
  --cta: #FD9B3B;              /* main actions: brand orange with navy text */
  --cta-hover: #F48A22;
  --on-cta: #1A2F5C;

  /* surfaces */
  --bg: #F4F6FB;
  --surface: #FFFFFF;
  --surface-2: #F1F3FA;
  --surface-3: #E3E5F4;
  --sidebar: #203E78;
  --sidebar-text: #DCE6F8;
  --sidebar-muted: #9FB3DA;
  --sidebar-hover: rgba(255, 255, 255, .08);
  --sidebar-active: rgba(255, 255, 255, .14);
  --border: #E3E5F4;
  --border-strong: #C9CFE6;

  /* text */
  --text: #16244A;
  --text-2: #4A5878;
  --text-3: #6B7794;

  /* meaning */
  --cheaper: #A84F06;          /* a competitor is cheaper than us (orange, dark enough for text) */
  --cheaper-bg: #FEEDD3;
  --cheaper-line: #FDBB75;
  --good: #15803D;             /* we are cheapest / equal */
  --good-bg: #E9F8EE;
  --warn: #B45309;             /* needs review */
  --warn-bg: #FEF4DF;
  --bad: #B42318;              /* errors */
  --bad-bg: #FDECEC;
  --star: #D97706;
  --star-bg: #FFF8E6;

  /* shape */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 20px rgba(15, 23, 42, .06);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, .22);
  --ring: 0 0 0 3px rgba(86, 168, 252, .45);

  /* spacing (4px grid) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;

  /* type */
  --font: "IBM Plex Sans Thai", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 15px; --fs-lg: 17px; --fs-xl: 20px; --fs-2xl: 26px; --fs-3xl: 30px;

  --sidebar-w: 256px;
  --topbar-h: 64px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --primary: #56A8FC;
  --primary-hover: #7DBCFD;
  --primary-soft: rgba(86, 168, 252, .16);
  --primary-ink: #ABD1FD;
  --on-primary: #0B1730;
  --cta: #FD9B3B;
  --cta-hover: #FEAD5C;
  --on-cta: #16244A;

  --bg: #0B1530;
  --surface: #12204A;
  --surface-2: #182A57;
  --surface-3: #203566;
  --sidebar: #0A1430;
  --sidebar-text: #DCE6F8;
  --sidebar-muted: #8FA3CC;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --sidebar-active: rgba(86, 168, 252, .18);
  --border: #23366A;
  --border-strong: #33498A;

  --text: #E8EEFA;
  --text-2: #AFBDDB;
  --text-3: #8899BF;

  --cheaper: #FDB66A;
  --cheaper-bg: rgba(253, 155, 59, .16);
  --cheaper-line: rgba(253, 155, 59, .55);
  --good: #6EE7A0;
  --good-bg: rgba(34, 197, 94, .14);
  --warn: #FCD34D;
  --warn-bg: rgba(245, 158, 11, .16);
  --bad: #FCA5A5;
  --bad-bg: rgba(239, 68, 68, .16);
  --star: #FBBF24;
  --star-bg: rgba(251, 191, 36, .14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .55);
  --ring: 0 0 0 3px rgba(96, 165, 250, .45);
  color-scheme: dark;
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 var(--fs-md)/1.6 var(--font); -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.3; letter-spacing: -.01em; }
h1 { font-size: var(--fs-2xl); font-weight: 700; }
h2 { font-size: var(--fs-lg); font-weight: 600; }
h3 { font-size: var(--fs-md); font-weight: 600; }
b, strong { font-weight: 600; }
p { margin: 0; }
code { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: .92em; }
::selection { background: var(--primary-soft); }
.muted { color: var(--text-2); }
.small { font-size: var(--fs-sm); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

/* icons */
.ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.ic.sm { width: 16px; height: 16px; }
.ic.filled { fill: currentColor; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------------------------------------------------------------- app shell: sidebar + content */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--s4);
  background: var(--sidebar); border-right: 1px solid var(--border); padding: var(--s4) var(--s3); z-index: 40;
}
.side-brand { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s2) var(--s3); color: #fff; }
.side-brand:hover { text-decoration: none; }
.logo { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #FFB25E, var(--orange)); color: var(--navy); box-shadow: 0 6px 16px rgba(253, 155, 59, .35); }
.logo.logo-img { background: #fff; box-shadow: none; overflow: hidden; }
.logo.logo-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.side-group + .side-group { margin-top: var(--s3); }
.brand-logo { height: 34px; width: auto; display: block; }
.brand-text { display: grid; line-height: 1.25; min-width: 0; }
.brand-text b { font-size: var(--fs-md); }
.brand-text small { color: var(--sidebar-muted); font-size: var(--fs-xs); }
.side-nav { display: grid; gap: 2px; }
.side-label { font-size: var(--fs-xs); font-weight: 600; color: var(--sidebar-muted); text-transform: uppercase; letter-spacing: .06em; padding: var(--s2) var(--s3) var(--s1); }
.side-nav a {
  display: flex; align-items: center; gap: var(--s3); min-height: 44px; padding: 0 var(--s3);
  border-radius: var(--r-sm); color: var(--sidebar-text); font-weight: 500; position: relative;
}
.side-nav a:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.side-nav a.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.side-nav a.active::before { content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 4px; border-radius: 0 4px 4px 0; background: var(--orange); }
.side-nav a.active .ic { color: var(--orange); }
.side-mascot { margin: auto var(--s2) 0; border-radius: var(--r-md); background: rgba(255, 255, 255, .06); padding: var(--s3); display: flex; gap: var(--s3); align-items: center; color: var(--sidebar-text); font-size: var(--fs-xs); }
.side-mascot img { width: 56px; height: 56px; object-fit: contain; flex: none; }
.side-foot { margin-top: auto; display: grid; gap: var(--s2); border-top: 1px solid rgba(255, 255, 255, .12); padding-top: var(--s3); }
.side-mascot + .side-foot { margin-top: var(--s3); }
@media (max-height: 640px) { .side-mascot { display: none; } }
.side-user { display: flex; align-items: center; gap: var(--s3); padding: var(--s2); border-radius: var(--r-sm); color: #fff; }
.side-user:hover, .side-user.active { background: var(--sidebar-hover); text-decoration: none; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--orange); color: var(--navy); font-weight: 700; }
.who { display: grid; min-width: 0; line-height: 1.3; }
.who small { color: var(--sidebar-muted); font-size: var(--fs-xs); }
.side-actions { display: flex; gap: var(--s1); flex-wrap: wrap; }
.side-actions .btn.ghost { flex: 1; justify-content: flex-start; color: var(--sidebar-text); }
.side-actions .btn.ghost:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar :focus-visible { box-shadow: 0 0 0 3px rgba(253, 155, 59, .6); }

.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s6); background: var(--bg); border-bottom: 1px solid var(--border);
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }
.btn.hamburger { display: none; }
.backdrop { position: fixed; inset: 0; background: rgba(2, 6, 23, .5); z-index: 35; }

main { width: 100%; max-width: 1280px; margin: 0 auto; padding: var(--s6) var(--s6) var(--s10); }

@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(84vw, 300px); transform: translateX(-102%);
    transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  body.menu-open .sidebar { transform: none; }
  body.menu-open { overflow: hidden; }
  .btn.hamburger { display: inline-flex; }
  .topbar { padding: 0 var(--s3); }
  main { padding: var(--s4) var(--s4) var(--s8); }
}
@media (max-width: 560px) {
  .topbar { height: auto; min-height: var(--topbar-h); flex-wrap: wrap; padding: var(--s2) var(--s3); row-gap: var(--s2); }
  .topbar-actions { width: 100%; margin-left: 0; }
  .topbar-actions .interval { flex: 1; }
  .topbar-actions .interval select { width: 100%; }
  #startBtn span { display: inline; }
  h1 { font-size: var(--fs-xl); }
  .kpis { gap: var(--s3); }
  .kpi { flex-direction: column; align-items: flex-start; gap: var(--s2); padding: var(--s3) var(--s4); }
  .kpi .kpi-ic { width: 36px; height: 36px; }
  .kpi .value { font-size: var(--fs-2xl); }
  .card { padding: var(--s4); }
  .table-wrap { margin: 0 calc(-1 * var(--s4)); padding: 0 var(--s4); }
}

/* ---------------------------------------------------------------- buttons & inputs */
.btn {
  height: 44px; padding: 0 var(--s4); border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: 600 14px/1 var(--font);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--cta); border-color: var(--cta); color: var(--on-cta); }
.btn.primary:hover { background: var(--cta-hover); border-color: var(--cta-hover); }
.btn.cta { background: var(--cta); border-color: var(--cta); color: var(--on-cta); box-shadow: 0 4px 14px rgba(253, 155, 59, .35); }
.btn.cta:hover { background: var(--cta-hover); border-color: var(--cta-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.icon-only { width: 44px; padding: 0; }
.btn.sm { height: 36px; padding: 0 var(--s3); font-size: var(--fs-sm); }
.btn[disabled] { opacity: .5; cursor: not-allowed; box-shadow: none; }

select, input[type=number], input[type=text], input[type=search], input[type=password] {
  height: 44px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--text);
  font: 15px var(--font); padding: 0 var(--s3); min-width: 0; transition: border-color .15s, box-shadow .15s;
}
select:hover, input:hover { border-color: var(--text-3); }
select:focus-visible, input:focus-visible { border-color: var(--primary); box-shadow: var(--ring); }
select.sm, input.sm { height: 38px; font-size: 14px; }
select[disabled] { opacity: .6; }
::placeholder { color: var(--text-3); }
label.check { display: flex; align-items: center; gap: var(--s3); min-height: 44px; cursor: pointer; }
label.check input { width: 20px; height: 20px; accent-color: var(--primary); }

/* ---------------------------------------------------------------- status pill */
.pill { display: inline-flex; align-items: center; gap: var(--s2); height: 36px; padding: 0 var(--s3); border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 600; background: var(--good-bg); color: var(--good); white-space: nowrap; }
.pill.running { background: var(--primary-soft); color: var(--primary-ink); }

/* ---------------------------------------------------------------- page layout pieces */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s5); }
.page-head .muted { margin-top: var(--s1); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-sm); padding: var(--s5); }
.grid { display: grid; gap: var(--s4); }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: var(--s5); }
.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); margin-bottom: var(--s6); }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .two { grid-template-columns: minmax(0, 1fr); } }
.section { margin-bottom: var(--s5); }
.section > h2 { margin-bottom: var(--s1); }
.section > p { margin: 0 0 var(--s4); }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s3); flex-wrap: wrap; }

/* KPI tiles */
.kpi { display: flex; gap: var(--s4); align-items: center; padding: var(--s4) var(--s5); }
.kpi .kpi-ic { width: 44px; height: 44px; border-radius: var(--r-md); display: grid; place-items: center; flex: none; }
.kpi .value { font-size: var(--fs-3xl); font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.kpi .label { font-size: var(--fs-sm); color: var(--text-2); margin-top: 2px; }
.kpi.alert { border-color: var(--cheaper-line); background: linear-gradient(0deg, var(--cheaper-bg), var(--cheaper-bg)), var(--surface); }
.kpi.alert .value { color: var(--cheaper); }
.tone-blue { background: var(--primary-soft); color: var(--primary-ink); }
.tone-orange { background: var(--cheaper-bg); color: var(--cheaper); }
.tone-green { background: var(--good-bg); color: var(--good); }
.tone-amber { background: var(--star-bg); color: var(--star); }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--border); min-width: 0; }
.list li:last-child { border-bottom: 0; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; line-height: 1.7; }
.b-orange { background: var(--cheaper-bg); color: var(--cheaper); }
.b-green { background: var(--good-bg); color: var(--good); }
.b-grey { background: var(--surface-2); color: var(--text-2); }
.b-blue { background: var(--primary-soft); color: var(--primary-ink); }
.b-red { background: var(--bad-bg); color: var(--bad); }
.b-amber { background: var(--warn-bg); color: var(--warn); }
a.badge:hover { text-decoration: none; filter: brightness(.97); }

/* filters & chips */
.filters { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; margin: var(--s1) 0 var(--s4); }
.chip { height: 38px; padding: 0 var(--s4); border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface);
  font: 600 14px var(--font); color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { border-color: var(--border-strong); color: var(--text); text-decoration: none; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
:root[data-theme="dark"] .chip.on { background: var(--sky); border-color: var(--sky); color: #0B1730; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pack-chip { display: inline-flex; gap: 6px; align-items: baseline; padding: 4px 10px; border-radius: var(--r-pill); background: var(--surface-2); font-size: var(--fs-sm); color: var(--text-2); }
.pack-chip b { color: var(--text); }
.pack-chip.equal { background: var(--good-bg); color: var(--good); }

/* ---------------------------------------------------------------- games & tables */
.games { display: grid; gap: var(--s4); grid-template-columns: minmax(0, 1fr); }
.game-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.thumb, .game-head img { display: block; width: 44px; height: 44px; min-width: 44px; max-width: 44px; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex: none; }
.game-head .grow { flex: 1; min-width: 0; }
.game-card.has-cheaper { border-left: 4px solid var(--cheaper); }
/* skip layout/paint of off-screen game cards */
.game-card, .best-game { content-visibility: auto; contain-intrinsic-size: auto 420px; }
.best-game { contain-intrinsic-size: auto 160px; }
.empty-art { width: 140px; height: auto; margin: 0 auto var(--s3); display: block; }
.page-banner { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5);
  background: linear-gradient(120deg, var(--surface) 55%, var(--primary-soft)); overflow: hidden; padding-block: var(--s3); }
.page-banner p { margin: var(--s1) 0 0; max-width: 560px; }
.page-banner img { width: 110px; height: auto; flex: none; margin-bottom: calc(-1 * var(--s3)); }
@media (max-width: 520px) { .page-banner img { width: 76px; } }
.star-btn { width: 40px; height: 40px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text-3); display: grid; place-items: center; cursor: pointer; flex: none; }
.star-btn:hover { color: var(--star); }
.star-btn.on { color: var(--star); border-color: var(--star); background: var(--star-bg); }

.table-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--s5)); padding: 0 var(--s5); }
table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 620px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; background: var(--surface); position: sticky; top: 0; }
td:first-child { white-space: normal; min-width: 160px; max-width: 320px; }
tbody tr:hover td { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
th.ours, td.ours { background: color-mix(in srgb, var(--primary-soft) 55%, transparent); }
td.ours { font-weight: 700; }
tr.row-cheaper td:first-child { box-shadow: inset 3px 0 0 var(--cheaper); }
td.cheaper { color: var(--cheaper); font-weight: 700; }
td.cheaper .cell { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; background: var(--cheaper-bg); }
td.dim { color: var(--text-3); }
td.review { text-decoration: underline dotted; text-underline-offset: 4px; color: var(--warn); }
.gap { color: var(--cheaper); font-weight: 700; }

/* top gaps panel on the dashboard */
.top-gaps { margin-bottom: var(--s6); border-color: var(--cheaper-line); }
.top-gaps .gap-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s3); }
.gap-item { display: flex; gap: var(--s3); align-items: center; padding: var(--s3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); min-width: 0; }
.gap-item:hover { border-color: var(--cheaper-line); text-decoration: none; }
.gap-item .meta { min-width: 0; flex: 1; }
.gap-item .meta b { display: block; color: var(--text); }
.gap-item .meta span { color: var(--text-2); font-size: var(--fs-sm); }
.gap-amount { text-align: right; flex: none; }
.gap-amount b { display: block; color: var(--cheaper); font-size: var(--fs-lg); }
.gap-amount small { color: var(--text-3); font-size: var(--fs-xs); }

/* summary page */
.best-game { padding: var(--s3) 0; border-bottom: 1px solid var(--border); }
.best-game:last-child { border-bottom: 0; }
.best-game .head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s2); }

/* ---------------------------------------------------------------- states */
.empty { text-align: center; padding: var(--s10) var(--s4); color: var(--text-2); }
.empty .ic { width: 40px; height: 40px; color: var(--text-3); margin-bottom: var(--s2); }
.empty b { display: block; color: var(--text); font-size: var(--fs-lg); margin-bottom: var(--s1); }
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-sm); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.sk-line { height: 12px; margin: 10px 0; }
.sk-card { height: 180px; border-radius: var(--r-md); }
.notice { display: flex; gap: var(--s3); align-items: flex-start; margin-bottom: var(--s5); border-left: 4px solid var(--primary); }
.notice .kpi-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.notice .grow { flex: 1; min-width: 0; }
.error-card { border-left: 4px solid var(--bad); }

/* ---------------------------------------------------------------- modal (alerts) */
.modal { position: fixed; inset: 0; background: rgba(2, 6, 23, .55); display: grid; place-items: center; padding: var(--s4); z-index: 60; }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: 85vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s5) var(--s5) var(--s2); }
.modal-head .ic-wrap { width: 44px; height: 44px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--cheaper-bg); color: var(--cheaper); }
.modal-card.strong { outline: 3px solid var(--cta); }
.modal-card.strong .modal-head .ic-wrap { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.modal-list { overflow-y: auto; padding: 0 var(--s5); }
.modal-foot { padding: var(--s3) var(--s5) var(--s5); display: flex; justify-content: flex-end; gap: var(--s2); flex-wrap: wrap; }
.alert-item { display: flex; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--border); }
.alert-item.starred { background: var(--star-bg); margin: 0 calc(-1 * var(--s5)); padding: var(--s3) var(--s5); }

/* ---------------------------------------------------------------- forms & settings */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s3) var(--s5); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.editor { background: var(--surface-2); border-radius: var(--r-md); padding: var(--s4); display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-error { margin: 0; padding: var(--s2) var(--s3); border-radius: var(--r-sm); background: var(--bad-bg); color: var(--bad); font-size: 14px; }

/* game-matching editor */
.editor2 { background: var(--surface-2); border-radius: var(--r-md); padding: var(--s4); display: grid; gap: var(--s3); white-space: normal; }
.editor-title { font-size: var(--fs-md); }
.pickers { display: grid; gap: var(--s3); grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 960px) { .pickers { grid-template-columns: minmax(0, 1fr); } }
.picker { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s3); display: grid; gap: var(--s2); align-content: start; min-width: 0; }
.picker-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; }
.picker-current { display: grid; gap: 4px; padding: var(--s2) var(--s3); border-radius: var(--r-sm); background: var(--surface-2); }
.picker-current .badge { white-space: normal; text-align: left; }
.sel-name { font-weight: 700; word-break: break-word; }
.picker-search { width: 100%; }
.picker-list { display: grid; gap: 2px; max-height: 260px; overflow-y: auto; }
.pick { display: flex; align-items: center; gap: var(--s2); width: 100%; min-height: 40px; padding: 6px var(--s2); border: 0; border-radius: var(--r-sm);
  background: transparent; font: 14px var(--font); color: var(--text); text-align: left; cursor: pointer; }
.pick:hover { background: var(--surface-2); }
.pick.on { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }
.pick .grow { flex: 1; min-width: 0; }
.pick .radio { width: 20px; height: 20px; border-radius: 999px; border: 2px solid var(--border-strong); display: grid; place-items: center; flex: none; }
.pick.on .radio { border-color: var(--primary); background: var(--primary); color: #fff; }
.pick.on .radio .ic { width: 12px; height: 12px; }
.picker:focus-within .pick.active, .combo:focus-within .pick.active { box-shadow: inset 0 0 0 2px var(--primary); }
.pick-group { padding: 6px var(--s2) 2px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.tab-choices { display: flex; flex-wrap: wrap; gap: var(--s2); }
.editor-foot { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.editor-foot .grow { flex: 1; }

/* searchable dropdown */
.combo { position: relative; }
.combo-input { width: 100%; padding-right: 34px; }
.combo-caret { position: absolute; right: 10px; top: 0; height: 38px; display: grid; place-items: center; color: var(--text-3); pointer-events: none; }
.combo-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow); max-height: 280px; overflow-y: auto; padding: 4px; display: grid; gap: 2px; }
.table-wrap .combo-list { position: static; margin-top: 4px; }
/* matching / users tables: let long names wrap so the action buttons stay in view */
#games td, #users td, #packTables td { white-space: normal; }
#games td:last-child, #users td:last-child { white-space: nowrap; width: 1%; }

/* phones: matching + users tables become stacked cards */
@media (max-width: 700px) {
  #games table, #users table { min-width: 0; }
  #games thead, #users thead { display: none; }
  #games tr, #games td, #users tr, #users td { display: block; }
  #games tr:not(.edit-row), #users tr { padding: var(--s3) 0; border-bottom: 1px solid var(--border); }
  #games td, #users td { border: 0; padding: 3px 0; white-space: normal; max-width: none; min-width: 0; }
  #games td[data-label]::before, #users td[data-label]::before { content: attr(data-label) " · "; font-weight: 600; color: var(--text-3); }
  #games .table-wrap, #users .table-wrap { margin: 0; padding: 0; }
  tbody tr:hover td { background: transparent; }
}

/* ---------------------------------------------------------------- login / setup */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: var(--s4);
  background: radial-gradient(1200px 600px at 10% -10%, var(--primary-soft), transparent 60%), radial-gradient(900px 500px at 110% 110%, var(--cheaper-bg), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; display: grid; gap: var(--s4); padding: var(--s8) var(--s6); box-shadow: var(--shadow); border-radius: var(--r-lg); }
.auth-card .field input { width: 100%; }
.auth-card h1 { font-size: var(--fs-xl); }
.brand { display: flex; align-items: center; gap: var(--s3); font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }

/* split login / setup: brand panel + form */
.auth-split { max-width: none; padding: 0; min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--bg); }
.auth-hero {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; gap: var(--s8);
  padding: var(--s10); color: #fff;
  background: radial-gradient(700px 400px at 0% 0%, rgba(171, 209, 253, .28), transparent 60%),
              radial-gradient(600px 500px at 100% 100%, rgba(253, 155, 59, .45), transparent 60%),
              linear-gradient(150deg, #17305F, var(--navy) 50%, #2F63B8);
}
.auth-hero::after { content: ""; position: absolute; inset: auto -80px -120px auto; width: 360px; height: 360px; border-radius: 50%;
  border: 48px solid rgba(255, 255, 255, .07); }
.hero-brand { display: flex; align-items: center; gap: var(--s3); position: relative; z-index: 1; }
.hero-brand .logo { box-shadow: none; }
.hero-brand b { display: block; font-size: var(--fs-lg); }
.hero-brand small { opacity: .8; }
.hero-copy { position: relative; z-index: 1; max-width: 460px; }
.hero-copy h2 { font-size: 34px; line-height: 1.25; font-weight: 700; margin-bottom: var(--s3); }
.hero-copy p { font-size: var(--fs-lg); opacity: .9; }
.hero-mascot { position: relative; z-index: 1; width: clamp(160px, 22vw, 240px); height: auto; align-self: center;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .25)); }
@media (max-height: 720px) { .hero-mascot { display: none; } }
.hero-points { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); position: relative; z-index: 1; }
.hero-points li { display: flex; align-items: center; gap: var(--s3); opacity: .95; }
.hero-points .dot { width: 8px; height: 8px; border-radius: 50%; background: #FDBA74; box-shadow: 0 0 0 4px rgba(253, 186, 116, .25); }
.auth-panel { display: grid; place-items: center; padding: var(--s8) var(--s5); }
.auth-panel .auth-card { background: var(--surface); border: 1px solid var(--border); max-width: 420px; }
.auth-mobile-brand { display: none; }
.btn-block { width: 100%; height: 48px; font-size: var(--fs-md); }
.center { text-align: center; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-right: 48px; }
.pw-toggle { position: absolute; right: 4px; top: 4px; width: 36px; height: 36px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-3); display: grid; place-items: center; cursor: pointer; }
.pw-toggle:hover { background: var(--surface-2); color: var(--text); }
@media (max-width: 860px) {
  .auth-split { grid-template-columns: minmax(0, 1fr); }
  .auth-hero { display: none; }
  .auth-mobile-brand { display: flex; }
  .auth-panel { align-items: start; padding: var(--s8) var(--s4); background:
    radial-gradient(800px 400px at 0% -10%, var(--primary-soft), transparent 60%), var(--bg); }
}

/* ---------------------------------------------------------------- toast */
.toast { position: fixed; left: 50%; bottom: var(--s5); transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: var(--s3) var(--s4); border-radius: var(--r-sm); font-size: 14px; z-index: 70; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); }

/* misc */
.share-link { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
