/* EnjoyGames portal. One stylesheet, no framework. Tokens first, then layout, then parts. */
:root {
  --ink: #0d1726;
  --ink-2: #16233a;
  --ink-3: #22324d;
  --ink-text: #c9d3e3;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e7ee;
  --border-strong: #cfd7e2;
  --text: #132034;
  --muted: #5d6d82;
  --faint: #8a97a8;
  --primary: #0d7d57;
  --primary-hover: #0a6a49;
  --primary-soft: #e3f4ec;
  --gold: #d9a93d;
  --danger: #c4303c;
  --danger-soft: #fbe9eb;
  --warn: #9a6200;
  --warn-soft: #fdf1dc;
  --info: #2459c4;
  --info-soft: #e6eefc;
  --num-red: #c4303c;
  --num-black: #1b2331;
  --num-green: #0e8a5f;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 20px 48px rgba(13, 23, 38, .22);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --sidebar: 236px;
  --tabbar: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--info); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0; }
.num, .credits { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 24px; text-align: center; }

/* ---- Brand ---- */
/* The logo is brand/logo/logo-horizontal-on-dark.svg (copied by brand/tools/build.mjs). */
.brand { display: inline-flex; align-items: center; }
a.brand { text-decoration: none; border-radius: 6px; }
.brand-logo { display: block; height: 30px; width: auto; }
.brand-lg .brand-logo { height: 42px; }
.boot { min-height: 100vh; display: grid; place-items: center; background: var(--ink); }

/* ---- Auth screens (login, set password, 2FA) ---- */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(13, 125, 87, .35), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(217, 169, 61, .18), transparent 60%),
    var(--ink);
}
.auth-card { width: 100%; max-width: 420px; }
.auth-card .brand { margin: 0 auto 22px; display: flex; justify-content: center; }
.auth-panel { background: var(--surface); border-radius: 16px; padding: 28px; box-shadow: var(--shadow-lg); }
.auth-panel h1 { font-size: 20px; margin-bottom: 4px; }
.auth-panel .lead { color: var(--muted); margin-bottom: 20px; }
.auth-foot { text-align: center; color: #8ea0ba; font-size: 12px; margin-top: 18px; }
.auth-panel.wide { max-width: 560px; }
.auth-panel .checkbox { margin: 18px 0 14px; }
.auth-panel p.small { margin: 4px 0 14px; }
.card-body > p { margin-top: 10px; }
.auth-card.wide { max-width: 560px; }

/* ---- Shell ---- */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--ink); color: var(--ink-text);
  display: flex; flex-direction: column; padding: 18px 12px; z-index: 20;
}
.sidebar .brand { padding: 4px 10px 18px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px;
  color: var(--ink-text); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a.active { background: var(--ink-3); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav svg { width: 20px; height: 20px; flex: none; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--ink-3); padding: 14px 10px 0; font-size: 13px; }
.who { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--ink-3); color: #fff; font-weight: 700; font-size: 14px; text-transform: uppercase;
}
.who-name { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-role { color: #8ea0ba; font-size: 12px; text-transform: capitalize; }
.sidebar-foot .btn-link { color: var(--ink-text); margin-top: 10px; }

.topbar { display: none; }
.main { margin-left: var(--sidebar); padding: 28px 32px 48px; max-width: 1320px; }
.tabbar { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--text); }

/* ---- Cards, grids ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-body { padding: 16px 20px; }
.stack > * + * { margin-top: 16px; }
.grid > * + * { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
/* One account: balance and history on the left, the account card (with its actions) on the
   right; on phones the account card comes between the two. */
.account-split {
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; grid-template-rows: auto 1fr; gap: 16px;
  grid-template-areas: "main side" "hist side"; align-items: start;
}
.a-main { grid-area: main; }
.a-side { grid-area: side; }
.a-hist { grid-area: hist; }

.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi .hint { color: var(--muted); font-size: 13px; }

.balance-card {
  background: linear-gradient(135deg, var(--ink) 0%, var(--ink-3) 100%); color: #fff; border: 0;
  padding: 22px 24px; position: relative; overflow: hidden;
}
.balance-card::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%;
  border: 18px solid rgba(217, 169, 61, .18);
}
.balance-card .label { color: #9fb0c8; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.balance-card .value { font-size: 38px; font-weight: 750; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.balance-card .value small { font-size: 15px; font-weight: 600; color: var(--gold); margin-left: 6px; }
.balance-card .meta { color: #9fb0c8; font-size: 13px; margin-top: 6px; position: relative; z-index: 1; }
.balance-card .actions { margin-top: 16px; display: flex; gap: 8px; flex-wrap: wrap; position: relative; z-index: 1; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); border-color: #b9c4d3; }
.btn:focus-visible, .nav a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .chip:focus-visible, .seg button:focus-visible, .punch-grid button:focus-visible, .row-link:focus-visible {
  outline: 3px solid rgba(13, 125, 87, .35); outline-offset: 1px;
}
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #a92733; border-color: #a92733; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(19, 32, 52, .06); border-color: transparent; }
.btn-light { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .2); color: #fff; }
.btn-light:hover { background: rgba(255, 255, 255, .2); border-color: rgba(255, 255, 255, .3); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn-gold:hover { background: #c99a30; border-color: #c99a30; }
.btn-block { width: 100%; }
.btn-sm { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn-link { background: none; border: 0; padding: 0; color: var(--info); font-weight: 600; cursor: pointer; font-size: 14px; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid currentColor; border-color: rgba(255,255,255,.9) rgba(255,255,255,.9) transparent transparent;
  animation: spin .7s linear infinite;
}
.btn:not(.btn-primary):not(.btn-danger).busy::after { border-color: var(--muted) var(--muted) transparent transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Forms ---- */
.field { display: block; margin-bottom: 14px; }
.field > span, .label-row { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field .help { display: block; font-size: 12.5px; color: var(--muted); margin-top: 6px; font-weight: 400; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 9px;
  background: var(--surface); font-size: 15px;
}
.input:focus { border-color: var(--primary); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-amount { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.input-code { font-family: var(--mono); font-size: 24px; letter-spacing: .3em; text-align: center; }
.amount-echo { font-size: 13px; color: var(--muted); margin-top: 6px; min-height: 18px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: end; }
form h3 { margin: 6px 0 10px; }
.form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
.checkbox { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary); }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 64px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.rules { list-style: none; padding: 10px 12px; margin: 0 0 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; font-size: 13px; }
.rules li { display: flex; gap: 8px; align-items: center; color: var(--muted); padding: 2px 0; }
.rules li::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; }
.rules li.ok { color: var(--primary); }
.rules li.ok::before { border-color: var(--primary); background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='white' stroke-width='2.2'/%3E%3C/svg%3E") center/12px no-repeat; }
.rules li.bad { color: var(--danger); }
.rules li.bad::before { border-color: var(--danger); }

/* ---- Alerts, badges ---- */
.alert { padding: 11px 14px; border-radius: 9px; font-size: 14px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: #8d1f29; border-color: #f2c5ca; }
.alert-warn { background: var(--warn-soft); color: #6f4700; border-color: #f2d8a6; }
.alert-info { background: var(--info-soft); color: #1b438f; border-color: #c9d8f6; }
.alert-ok { background: var(--primary-soft); color: #075438; border-color: #bfe4d2; }
.alert strong { font-weight: 700; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px;
  font-weight: 650; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge-ok { background: var(--primary-soft); color: var(--primary); border-color: #bfe4d2; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: #f2c5ca; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: #f2d8a6; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: #c9d8f6; }
.badge-dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.role { text-transform: capitalize; }
.role-contractor { background: #efe9fb; color: #5b3aa8; border-color: #dccff5; }
.role-agent { background: var(--info-soft); color: var(--info); border-color: #c9d8f6; }
.role-player { background: #e8f6f1; color: #0b6d4a; border-color: #c4e7d9; }

/* ---- Lists and tables ---- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--border); }
.list > li:first-child { border-top: 0; }
.row-link {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px; text-decoration: none; color: inherit; width: 100%;
  background: none; border: 0; text-align: left; cursor: pointer;
}
.row-link:hover { background: var(--surface-2); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-end { text-align: right; flex: none; }
.row-end .credits { font-weight: 700; }
.chev { color: var(--faint); width: 18px; height: 18px; flex: none; }
.tree-toggle {
  width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; flex: none; color: var(--muted);
}
.tree-toggle svg { width: 14px; height: 14px; transition: transform .15s; }
.tree-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.tree-spacer { width: 28px; flex: none; }
.indent-1 { padding-left: 44px; }
.indent-2 { padding-left: 68px; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.r, table.data th.r { text-align: right; }
.amount-in { color: var(--primary); font-weight: 700; }
.amount-out { color: var(--danger); font-weight: 700; }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 36px; height: 36px; color: var(--faint); display: block; margin: 0 auto 10px; }
.load-more { padding: 12px; text-align: center; border-top: 1px solid var(--border); }

/* ---- Toolbar, chips, segmented ---- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.toolbar .input { min-height: 40px; }
.toolbar > select.input { width: auto; min-width: 220px; }
.search { flex: 1 1 240px; position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--faint); }
.search .input { padding-left: 38px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted);
}
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 7px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg button.danger[aria-pressed="true"] { background: var(--warn-soft); color: var(--warn); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--text); border-color: var(--primary); }

/* ---- Roulette numbers ---- */
.n {
  display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 50%;
  color: #fff; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums;
}
.n-red { background: var(--num-red); }
.n-black { background: var(--num-black); }
.n-green { background: var(--num-green); }
.n-lg { min-width: 44px; height: 44px; font-size: 18px; }
.results { display: flex; gap: 6px; flex-wrap: wrap; }
.punch-grid { display: grid; grid-template-columns: repeat(13, minmax(0, 44px)); gap: 6px; margin-top: 10px; }
.punch-grid button {
  aspect-ratio: 1; border: 2px solid transparent; border-radius: 8px; color: #fff; font-weight: 700; cursor: pointer; font-size: 13px;
  font-variant-numeric: tabular-nums; min-height: 32px;
}
.punch-grid button.zero { grid-row: span 1; }
.punch-grid button[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.punch-grid button:hover { filter: brightness(1.12); }

/* ---- Live dashboard ---- */
.live-dot { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.live-dot::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--faint); }
.live-dot.on { color: var(--primary); }
.live-dot.on::before { background: #16b47c; box-shadow: 0 0 0 0 rgba(22, 180, 124, .6); animation: pulse 1.8s infinite; }
.live-dot.off { color: var(--danger); }
.live-dot.off::before { background: var(--danger); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(22, 180, 124, .55); } 70% { box-shadow: 0 0 0 8px rgba(22, 180, 124, 0); } 100% { box-shadow: 0 0 0 0 rgba(22, 180, 124, 0); } }
.table-live { display: flex; flex-direction: column; }
.table-live .card-head h2 { display: flex; align-items: center; gap: 8px; }
.phase { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.phase-name { font-weight: 700; font-size: 15px; }
.phase-betting { color: var(--primary); }
.phase-closed { color: var(--warn); }
.phase-spinning { color: var(--info); }
.countdown { font-size: 28px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.02em; min-width: 54px; }
.progress { flex: 1 1 120px; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.progress > div { height: 100%; background: var(--primary); transition: width .4s linear; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.stats > div { padding: 12px 20px; }
.stats > div + div { border-left: 1px solid var(--border); }
.stats .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.stats .value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bets { max-height: 260px; overflow-y: auto; }
.bets table.data td, .bets table.data th { padding: 7px 14px; }
.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: #fff7d6; } to { background: transparent; } }
.players { display: flex; flex-wrap: wrap; gap: 6px; }
.table-live .results, .table-live .players { margin: 6px 0 12px; }
a.badge { text-decoration: none; }
a.badge:hover { border-color: var(--border-strong); color: var(--text); }

/* ---- Modal, toast ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(9, 15, 26, .55); display: grid; place-items: center; z-index: 100;
  padding: 16px; animation: fade .12s ease-out;
}
.modal {
  width: 100%; max-width: 480px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 32px); overflow: auto; animation: rise .16s ease-out;
}
.modal-wide { max-width: 640px; }
.modal-head { padding: 20px 22px 0; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.modal-head p { color: var(--muted); margin-top: 4px; font-size: 14px; }
.modal-body { padding: 16px 22px; }
.modal-foot { padding: 0 22px 20px; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.close-x { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 6px; }
.close-x svg { width: 20px; height: 20px; display: block; }
.summary { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 4px 14px; }
.summary div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: 14px; }
.summary div + div { border-top: 1px dashed var(--border-strong); }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }
.secret-box {
  font-family: var(--mono); font-size: 22px; font-weight: 700; letter-spacing: .06em; text-align: center;
  padding: 16px; background: var(--ink); color: #fff; border-radius: 10px; word-break: break-all; user-select: all;
}
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; font-family: var(--mono); font-size: 15px; font-weight: 600; }
.codes span { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px; text-align: center; user-select: all; }
.qr { display: grid; place-items: center; padding: 12px; background: #fff; border: 1px solid var(--border); border-radius: 12px; width: 220px; height: 220px; margin: 0 auto; }
.qr svg { width: 196px; height: 196px; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps > li { counter-increment: step; position: relative; padding-left: 38px; margin-bottom: 18px; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); color: #fff; font-weight: 700; font-size: 13px; display: grid; place-items: center;
}
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 14px;
  display: flex; gap: 10px; align-items: flex-start; animation: rise .16s ease-out;
}
.toast.ok { border-left: 4px solid #16b47c; }
.toast.error { border-left: 4px solid #ef5a66; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-weight: 550; min-width: 0; overflow-wrap: anywhere; }
.details { font-size: 13px; color: var(--muted); }
.details b { color: var(--text); font-weight: 600; }
.kv { display: inline-block; margin-right: 10px; }

.skeleton { background: linear-gradient(90deg, #eef1f5, #f7f9fb, #eef1f5); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; height: 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ---- Tablet ---- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .account-split { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "main" "side" "hist"; }
}

/* ---- Phone ---- */
@media (max-width: 860px) {
  body { font-size: 15px; }
  .sidebar { display: none; }
  .topbar {
    display: flex; position: sticky; top: 0; z-index: 30; align-items: center; justify-content: space-between; gap: 10px;
    background: var(--ink); color: #fff; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  }
  .topbar .brand-logo { height: 26px; }
  .topbar-right { display: flex; align-items: center; gap: 8px; }
  .topbar-balance { font-weight: 700; font-size: 14px; background: var(--ink-3); padding: 5px 10px; border-radius: 999px; font-variant-numeric: tabular-nums; }
  .topbar .avatar { width: 32px; height: 32px; border: 0; cursor: pointer; text-decoration: none; }
  .main { margin-left: 0; padding: 18px 16px calc(var(--tabbar) + 28px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface);
    border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(13, 23, 38, .06);
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: var(--tabbar);
    color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600;
  }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a.active { color: var(--primary); }
  h1 { font-size: 20px; }
  .page-head { margin-bottom: 14px; align-items: flex-start; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .value { font-size: 20px; }
  .card-head, .card-body, .toolbar { padding-left: 16px; padding-right: 16px; }
  .row-link { padding: 12px 16px; }
  .indent-1 { padding-left: 34px; }
  .indent-2 { padding-left: 52px; }
  .form-row, .form-row-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .balance-card .value { font-size: 32px; }
  .balance-card .actions .btn { flex: 1; }
  .stats > div { padding: 10px 14px; }
  .phase { padding: 12px 16px; }
  .punch-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { max-width: none; border-radius: 18px 18px 0 0; max-height: 92vh; padding-bottom: env(safe-area-inset-bottom); }
  .modal-foot .btn { flex: 1; }
  .toasts { left: 16px; right: 16px; bottom: calc(var(--tabbar) + 12px); max-width: none; }

  /* Data tables become stacked cards. */
  table.data.stack-sm thead { display: none; }
  table.data.stack-sm, table.data.stack-sm tbody, table.data.stack-sm tr, table.data.stack-sm td { display: block; width: 100%; }
  table.data.stack-sm tr { padding: 10px 16px; border-bottom: 1px solid var(--border); }
  table.data.stack-sm tr:last-child { border-bottom: 0; }
  table.data.stack-sm td { border: 0; padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.data.stack-sm td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 600; text-align: left; flex: none; }
  table.data.stack-sm td.r { text-align: right; }
  table.data.stack-sm td.lead { font-weight: 650; font-size: 15px; }
  table.data.stack-sm td.lead::before { display: none; }
  table.data.stack-sm td.lead { justify-content: flex-start; text-align: left; }

  /* Credit history: two short lines per movement. */
  table.data.history tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 1px; }
  table.data.history td { display: block; padding: 0; text-align: left; }
  table.data.history td::before { display: none; }
  table.data.history td:nth-child(1) { grid-column: 1; grid-row: 1; }
  table.data.history td:nth-child(4) { grid-column: 2; grid-row: 1; text-align: right; }
  table.data.history td:nth-child(2) { grid-column: 1; grid-row: 2; color: var(--muted); font-size: 13px; }
  table.data.history td:nth-child(5) { grid-column: 2; grid-row: 2; text-align: right; color: var(--muted); font-size: 13px; }
  table.data.history td:nth-child(3) { grid-column: 1 / -1; grid-row: 3; color: var(--faint); font-size: 12.5px; }
  table.data.history td:nth-child(5)::before { display: inline; content: "Balance "; font-weight: 400; font-size: inherit; color: inherit; }
}

@media (max-width: 380px) {
  .form-row, .form-row-3 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
