/* ============================================================
   ds.css — DS Payment design system "Dark Glass"
   3 ธีม: data-theme="dark" (ดำ, ค่าเริ่มต้น) | "light" (ขาว) | "red" (แดง)
   ทุกสีอยู่ในตัวแปร — component ห้ามใช้ hex ตรงๆ
   ============================================================ */

/* ---------- Tokens ---------- */
:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070A12;
  --glow-1: rgba(64, 84, 190, .30);
  --glow-2: rgba(30, 120, 125, .24);
  --shell: #0C1222;
  --surface: #111A30;
  --surface-2: #0B1121;
  --raised: #16213D;
  --border: #1F2B47;
  --border-strong: #2C3B60;
  --text: #E8EDF8;
  --text-2: #B9C4DB;
  --muted: #93A1BF;
  --accent: #5FE3D5;
  --accent-ink: #05211E;
  --accent-soft: rgba(95, 227, 213, .12);
  --accent-line: #2F6B6A;
  --accent-2: #B3A8FA;
  --accent-2-soft: rgba(139, 124, 246, .18);
  --ok: #6EE7A8;
  --warn: #F5C46B;
  --danger: #FF8A9A;
  --ok-soft: rgba(110, 231, 168, .12);
  --warn-soft: rgba(245, 196, 107, .14);
  --danger-soft: rgba(255, 138, 154, .14);
  --track-off: #34405E;
  --track-on: #2BB5A7;
  --knob: #F4F7FD;
  --chart-1: #5FE3D5;
  --chart-2: #8B7CF6;
  --hero-from: #16234A;
  --hero-to: #101A33;
  --hero-border: #273763;
  --overlay: rgba(3, 6, 14, .72);
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, .65);
  --focus: #9AF0E7;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #E7ECF4;
  --glow-1: rgba(120, 140, 255, .28);
  --glow-2: rgba(70, 200, 190, .24);
  --shell: #F7F9FC;
  --surface: #FFFFFF;
  --surface-2: #F0F3F9;
  --raised: #FFFFFF;
  --border: #DCE2EC;
  --border-strong: #C3CCDB;
  --text: #0E1526;
  --text-2: #36425A;
  --muted: #55617A;
  --accent: #0A7068;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(10, 112, 104, .10);
  --accent-line: #8CCFC8;
  --accent-2: #5B47D6;
  --accent-2-soft: rgba(91, 71, 214, .10);
  --ok: #157A4A;
  --warn: #8A5A00;
  --danger: #B8233A;
  --ok-soft: rgba(21, 122, 74, .10);
  --warn-soft: rgba(176, 120, 0, .12);
  --danger-soft: rgba(184, 35, 58, .10);
  --track-off: #B7C1D2;
  --track-on: #0A7068;
  --knob: #FFFFFF;
  --chart-1: #0A7068;
  --chart-2: #8B7CF6;
  --hero-from: #FFFFFF;
  --hero-to: #EAF1FB;
  --hero-border: #C9D6EA;
  --overlay: rgba(14, 21, 38, .45);
  --shadow: 0 24px 60px -28px rgba(20, 30, 60, .35);
  --focus: #0A7068;
}
html[data-theme="red"] {
  color-scheme: dark;
  --bg: #0C0608;
  --glow-1: rgba(200, 30, 60, .32);
  --glow-2: rgba(255, 120, 80, .14);
  --shell: #130A0D;
  --surface: #1B0E12;
  --surface-2: #12090C;
  --raised: #241217;
  --border: #36181F;
  --border-strong: #4E222C;
  --text: #F7EBEE;
  --text-2: #DCC2C8;
  --muted: #BC9AA2;
  --accent: #FF5C6C;
  --accent-ink: #2A0509;
  --accent-soft: rgba(255, 92, 108, .14);
  --accent-line: #7A2A35;
  --accent-2: #FFB36B;
  --accent-2-soft: rgba(255, 179, 107, .14);
  --ok: #6EE7A8;
  --warn: #FFC46B;
  --danger: #FF9AA6;
  --ok-soft: rgba(110, 231, 168, .12);
  --warn-soft: rgba(255, 196, 107, .14);
  --danger-soft: rgba(255, 154, 166, .14);
  --track-off: #4A2A32;
  --track-on: #E0475A;
  --knob: #FFF5F6;
  --chart-1: #FF5C6C;
  --chart-2: #FFB36B;
  --hero-from: #3A1119;
  --hero-to: #1D0D12;
  --hero-border: #5A2230;
  --overlay: rgba(10, 2, 4, .74);
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, .7);
  --focus: #FFB3BB;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.ds {
  margin: 0; min-height: 100vh;
  font-family: 'Plus Jakarta Sans', 'Noto Sans Thai', system-ui, sans-serif;
  font-size: 16px; line-height: 1.5; color: var(--text);
  background:
    radial-gradient(620px 480px at 0% 0%, var(--glow-1), transparent 70%),
    radial-gradient(640px 520px at 100% 100%, var(--glow-2), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  overflow-x: hidden;
}
:where(.ds) a { color: var(--accent); }
.ds h1, .ds h2, .ds h3 { margin: 0; line-height: 1.25; }
.ds :where(a, button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 3px solid var(--focus); outline-offset: 2px;
}
.hidden { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link:focus { position: fixed !important; left: 12px; top: 12px; width: auto; height: auto; clip: auto; padding: 10px 16px; z-index: 1000; background: var(--surface); color: var(--text); border-radius: 12px; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .danger { color: var(--danger); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.ico { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- App shell ---------- */
.shell { max-width: 1600px; margin: 0 auto; padding: 20px; }
.shell-frame {
  min-height: calc(100vh - 40px); border-radius: 26px; background: var(--shell);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  display: grid; grid-template-columns: 248px minmax(0, 1fr); grid-template-rows: 72px minmax(0, 1fr);
  overflow: hidden;
}
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 0 20px; border-bottom: 1px solid var(--border); min-width: 0; }
.brand { display: flex; align-items: center; gap: 12px; width: 212px; flex-shrink: 0; text-decoration: none; color: var(--text); }
.brand-mark { width: 34px; height: 34px; border-radius: 50%; background: conic-gradient(var(--accent) 0 72%, var(--track-off) 72% 100%); display: grid; place-items: center; flex-shrink: 0; }
.brand-mark::after { content: ""; width: 22px; height: 22px; border-radius: 50%; background: var(--shell); }
.brand-name { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.badge-admin { font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--accent-2-soft); color: var(--accent-2); font-weight: 600; }
.topbar-spacer { flex: 1; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-2); color: var(--accent-ink); font-weight: 700; text-decoration: none; flex-shrink: 0; overflow: hidden; }
html[data-theme="light"] .avatar { color: #FFFFFF; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.sidebar { padding: 20px 16px; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 14px; border-radius: 14px;
  color: var(--text-2); text-decoration: none; border: 1px solid transparent; font-size: 15px;
  transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--text); border-color: var(--accent-line); font-weight: 600; }
.nav a[aria-current="page"] .ico { color: var(--accent); }
.side-card { padding: 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.side-card h2 { font-size: 14px; font-weight: 600; }
.kv { display: flex; justify-content: space-between; gap: 10px; }
.kv > :first-child { color: var(--muted); }
.side-foot { margin-top: auto; }
.content { padding: 20px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }

.bottom-nav { display: none; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.card { border-radius: 22px; padding: 20px 22px; background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.card-head h2 { font-size: 18px; font-weight: 700; }
.card-hero { background: linear-gradient(150deg, var(--hero-from), var(--hero-to)); border-color: var(--hero-border); }
.inset { padding: 12px 14px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); }
.big-num { font-size: 42px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 22px; font-weight: 700; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; display: inline-block; }

.ring { --p: 0; width: 96px; height: 96px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: conic-gradient(var(--ring-color, var(--accent)) calc(var(--p) * 1%), var(--track-off) 0); }
.ring-inner { width: 74px; height: 74px; border-radius: 50%; background: var(--hero-to); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; }
.ring-inner b { font-size: 20px; }
.ring-inner span { font-size: 12px; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 14px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .15s ease, background-color .18s ease, border-color .18s ease, opacity .18s ease;
}
.btn:hover { border-color: var(--accent-line); }
.btn:active { transform: scale(.98); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.06); border-color: var(--accent); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn-block { width: 100%; }
.icon-btn { width: 44px; height: 44px; padding: 0; position: relative; }
.icon-btn .pip { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.btn.is-loading { pointer-events: none; opacity: .75; }

.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 600; border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.chip-accent { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.chip-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.chip-warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.chip-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.chip-admin { background: var(--accent-2-soft); border-color: transparent; color: var(--accent-2); }
.live .dot { color: var(--accent); }

.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button { min-height: 38px; padding: 0 14px; border-radius: 9px; border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 14px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---------- Switch (button role="switch") ---------- */
.switch { width: 56px; height: 44px; padding: 0; border: 0; background: transparent; cursor: pointer; display: inline-flex; align-items: center; flex-shrink: 0; }
.switch .track { width: 48px; height: 26px; border-radius: 13px; background: var(--track-off); position: relative; transition: background-color .2s ease; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--knob); transition: transform .2s ease; }
.switch[aria-checked="true"] .track { background: var(--track-on); }
.switch[aria-checked="true"] .track::after { transform: translateX(22px); }
.setting-row { display: flex; align-items: center; gap: 12px; }
.setting-row .t { font-weight: 600; }
.setting-row .h { font-size: 13px; color: var(--muted); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label-text { font-size: 14px; font-weight: 600; color: var(--text-2); }
.input, .select, .textarea, .ds input[type="text"].input, .ds input[type="password"].input {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 16px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.input::placeholder { color: var(--muted); opacity: .85; }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); outline: none; }
.input-lg { font-size: 22px; font-weight: 700; }
.help { font-size: 13px; color: var(--muted); }
.field-error { font-size: 13px; color: var(--danger); display: flex; gap: 6px; align-items: flex-start; }
.input[aria-invalid="true"] { border-color: var(--danger); }
.search { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); min-width: 0; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 15px; }
.search input:focus { outline: none; }
.search:focus-within { border-color: var(--accent); }
.alert { padding: 12px 16px; border-radius: 14px; font-size: 14px; border: 1px solid; display: flex; gap: 10px; align-items: flex-start; }
.alert-ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.alert-err { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.alert-warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.alert-info { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }

/* ---------- Table / lists ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }
.ref-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ref-src { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--accent); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-src .ico { width: 14px; height: 14px; }
.ref-id { font-weight: 600; word-break: break-all; }
.status { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); }
.pager { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pager a, .pager button { min-width: 44px; min-height: 44px; display: inline-grid; place-items: center; padding: 0 12px; border-radius: 12px; border: 1px solid var(--border); background: transparent; color: var(--text-2); font: inherit; text-decoration: none; cursor: pointer; }
.pager [aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.pager [disabled] { opacity: .45; cursor: not-allowed; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }

/* ---------- Charts ---------- */
.bars { display: flex; align-items: flex-end; gap: 14px; height: 170px; }
.bars .bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.bars .bar i { display: block; width: 22px; max-width: 100%; border-radius: 11px; background: var(--chart-2); }
.bars .bar.today i { background: var(--chart-1); }
.bars .bar.today { color: var(--text); font-weight: 600; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-box { position: relative; height: 240px; }
.progress { height: 6px; border-radius: 3px; background: var(--track-off); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* ---------- Theme picker ---------- */
.theme-picker { display: inline-flex; gap: 4px; padding: 3px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.theme-picker button { width: 44px; height: 38px; border-radius: 10px; border: 1px solid transparent; background: transparent; cursor: pointer; display: grid; place-items: center; padding: 0; }
.theme-picker button[aria-pressed="true"] { border-color: var(--accent); background: var(--surface); }
.swatch { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(128, 128, 128, .6); }
.swatch-dark { background: linear-gradient(135deg, #0C1222 50%, #5FE3D5 50%); }
.swatch-light { background: linear-gradient(135deg, #FFFFFF 50%, #0A7068 50%); }
.swatch-red { background: linear-gradient(135deg, #1B0E12 50%, #FF5C6C 50%); }

/* ---------- Modal / toast ---------- */
.modal { position: fixed; inset: 0; z-index: 100; background: var(--overlay); backdrop-filter: blur(6px); display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px; overflow-y: auto; }
.modal-card { width: 100%; max-width: 520px; margin: auto; border-radius: 24px; padding: 26px; background: var(--shell); border: 1px solid var(--border-strong); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; animation: pop .2s ease-out; }
.modal-card.sm { max-width: 440px; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 200; max-width: min(360px, calc(100vw - 40px)); padding: 14px 18px; border-radius: 16px; background: var(--raised); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-size: 15px; font-weight: 600; transform: translateY(16px); opacity: 0; transition: transform .25s ease, opacity .2s ease; pointer-events: none; }
.toast.show { transform: none; opacity: 1; }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.success { border-color: var(--accent-line); }
.secret-box { padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px dashed var(--border-strong); word-break: break-all; font-size: 14px; user-select: all; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-brand { padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; border-right: 1px solid var(--border); background: linear-gradient(160deg, var(--hero-from), transparent 70%); }
.auth-brand .lead { font-size: 40px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; max-width: 520px; }
.auth-brand .lead em { font-style: normal; color: var(--accent); }
.auth-feats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 560px; }
.auth-feat { padding: 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: var(--text-2); }
.auth-feat b { display: block; color: var(--text); font-size: 15px; }
.auth-feat .ico { color: var(--accent); margin-top: 2px; }
.auth-main { padding: 32px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; }
.auth-top { width: 100%; max-width: 440px; display: flex; justify-content: flex-end; }
.auth-card { width: 100%; max-width: 440px; border-radius: 26px; padding: 32px; background: var(--shell); border: 1px solid var(--border); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 18px; }
.auth-card h1 { font-size: 28px; font-weight: 700; }
.oauth { display: flex; flex-direction: column; gap: 10px; }
.btn-oauth { justify-content: flex-start; gap: 12px; background: var(--surface); font-weight: 600; }
.btn-oauth svg { width: 20px; height: 20px; }
.divider { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.hp-field { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Plans ---------- */
.plans { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.plan { position: relative; }
.plan.featured { background: linear-gradient(160deg, var(--hero-from), var(--hero-to)); border-color: var(--accent-line); }
.plan .price { font-size: 40px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.plan .price small { font-size: 15px; font-weight: 500; color: var(--muted); }
.plan ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 15px; color: var(--text-2); }
.plan li { display: flex; gap: 8px; align-items: flex-start; }
.plan li .ico { color: var(--accent); margin-top: 3px; width: 16px; height: 16px; }
.plan .cta { margin-top: auto; }
.qr-frame { width: 232px; height: 232px; margin: 0 auto; padding: 12px; border-radius: 18px; background: #FFFFFF; }
.qr-frame img { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid .span-2 { grid-column: 1 / -1; }
  .plans { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar .search { display: none; }
}
@media (max-width: 900px) {
  .shell { padding: 0; }
  .shell-frame { border-radius: 0; border: 0; min-height: 100vh; grid-template-columns: minmax(0, 1fr); grid-template-rows: 64px minmax(0, 1fr); padding-bottom: 76px; }
  .sidebar { display: none; }
  .brand { width: auto; }
  .brand-sub, .topbar .hide-sm { display: none; }
  .topbar { padding: 0 12px; gap: 8px; }
  .content { padding: 16px 14px; }
  .grid, .grid-2, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; padding: 6px 8px 14px;
    background: var(--shell); border-top: 1px solid var(--border);
  }
  .bottom-nav a { flex: 1; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; color: var(--text-2); text-decoration: none; }
  .bottom-nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }
  .bottom-nav .ico { width: 22px; height: 22px; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-brand { display: none; }
  .auth-card { padding: 24px 20px; }
  .plans { grid-template-columns: minmax(0, 1fr); }
  .big-num { font-size: 34px; }
  .toast { left: 16px; right: 16px; bottom: 88px; max-width: none; }
  .theme-picker button { width: 40px; }
}
@media (max-width: 380px) {
  .theme-picker button { width: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media (pointer: coarse) {
  .seg button { min-height: 44px; }
}
