/* Dark theme: palette and background pattern from aki-dev-sync (src/assets/main.css); layout after the owner's UX reference. */
:root {
  color-scheme: dark;
  --bg: #0a0f16;
  --surface: rgba(255, 255, 255, 0.03);
  --surface-solid: #111821;
  --surface-muted: rgba(255, 255, 255, 0.05);
  --surface-highlight: rgba(0, 210, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-card: rgba(0, 210, 255, 0.15);
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --accent: #00d2ff;
  --accent-strong: #0088ff;
  --up: #10b981;
  --up-soft: rgba(16, 185, 129, 0.12);
  --down: #ef4444;
  --down-soft: rgba(239, 68, 68, 0.14);
  --gold: #f5b301;
  --gold-soft: rgba(245, 179, 1, 0.1);
  --on-accent: #04121c;
  --radius-control: 4px;
  --radius-card: 8px;
  --control-h: 32px;
  --topbar-h: 60px;
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.35);
  --topbar-bg: rgba(10, 15, 22, 0.85);
  --page-pattern: radial-gradient(ellipse at 50% -20%, rgba(0, 136, 255, 0.15) 0%, transparent 70%), url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.02' fill-rule='evenodd'%3E%3Ccircle cx='3' cy='3' r='1'/%3E%3Ccircle cx='13' cy='13' r='1'/%3E%3C/g%3E%3C/svg%3E");
}

/* Light theme: the owner's original UX reference palette. */
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-solid: #ffffff;
  --surface-muted: #f6f8fa;
  --surface-highlight: #f0f7ff;
  --border: #e3e8ee;
  --border-card: #e3e8ee;
  --text: #1f2933;
  --text-muted: #6b7280;
  --accent: #0088ff;
  --accent-strong: #0066cc;
  --up: #059669;
  --up-soft: #ecfdf5;
  --down: #dc2626;
  --down-soft: #fee2e2;
  --gold: #b8860b;
  --gold-soft: #fdf6e3;
  --on-accent: #ffffff;
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.08);
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --page-pattern: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--text); background-color: var(--bg); background-image: var(--page-pattern); background-attachment: fixed; min-height: 100vh; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 4px; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--text-muted); }
.up { color: var(--up); }
.down { color: var(--down); }

.topbar { position: sticky; top: 0; z-index: 5; min-height: var(--topbar-h); display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 28px; background: var(--topbar-bg); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border-card); }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand img { width: 32px; height: 32px; }
.brand__name { font-size: 16px; font-weight: 800; letter-spacing: 0.04em; }
.brand__name b { color: var(--accent); }
.brand__tag { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.topbar__right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.live { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.live.is-on { color: var(--up); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 12px; border: 1px solid currentColor; border-radius: 999px; font-weight: 600; font-size: 13px; text-transform: uppercase; white-space: nowrap; }
.pill--UPTREND { color: var(--up); }
.pill--DOWNTREND { color: var(--down); }
.pill--sample { color: var(--up); background: var(--up-soft); }
.pill--locked { color: var(--gold); background: var(--gold-soft); cursor: pointer; }
.pill--full { color: var(--accent); }

.btn { height: var(--control-h); padding: 0 14px; border-radius: var(--radius-control); border: 1px solid transparent; cursor: pointer; font-weight: 600; background: none; }
.btn--primary { background: linear-gradient(90deg, var(--accent), var(--accent-strong)); color: var(--on-accent); }
.btn--gold { background: var(--gold); color: var(--on-accent); text-transform: uppercase; height: 44px; }
.btn--outline { border-color: var(--border); background: var(--surface); }
.btn--ghost { color: var(--text-muted); }

.page { padding: 20px 28px; }
.card { background: var(--surface); border: 1px solid var(--border-card); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 20px; }

.summary { display: grid; grid-template-columns: 1.6fr repeat(4, 1fr); gap: 12px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface-muted); }
.summary__value { font-size: 22px; font-weight: 700; }
.eyebrow { font-size: 13px; color: var(--text-muted); text-transform: uppercase; }
.tier { text-align: left; border: 1px solid transparent; border-radius: var(--radius-card); padding: 6px 10px; background: none; cursor: pointer; }
.tier:hover { background: var(--surface-highlight); }
.tier.is-active { border-color: var(--accent); background: var(--surface-highlight); }
.tier__count { font-size: 18px; font-weight: 700; }
.tier:nth-of-type(3) .tier__count { color: var(--gold); }
.tier:nth-of-type(4) .tier__count, .tier:nth-of-type(5) .tier__count { color: var(--up); }

.filters { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; margin: 16px 0; font-size: 14px; }
.filters select { height: var(--control-h); border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface-solid); padding: 0 8px; }

.table-wrap { border: 1px solid var(--border); border-radius: var(--radius-card); overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; }
.grid th { background: var(--surface-muted); font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; text-align: left; }
.grid th, .grid td { padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tr.is-open { cursor: pointer; }
.grid tr.is-open:hover, .grid tr.is-selected { background: var(--surface-highlight); }
.symbol { color: var(--accent); font-weight: 700; }
.blur { filter: blur(5px); user-select: none; color: var(--text-muted); }
.flash-up { animation: flash-up 0.9s; }
.flash-down { animation: flash-down 0.9s; }
@keyframes flash-up { from { background: var(--up-soft); } }
@keyframes flash-down { from { background: var(--down-soft); } }

.cta { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 20px; padding: 18px 22px; border: 1px dashed var(--gold); border-radius: var(--radius-card); background: linear-gradient(90deg, var(--surface-highlight), var(--gold-soft)); }
.cta__title { color: var(--gold); font-weight: 700; font-size: 18px; text-transform: uppercase; }

.drawer { z-index: 4; position: fixed; inset: var(--topbar-h) 0 0 auto; width: min(820px, 100vw); overflow-y: auto; background: var(--surface-solid); border-left: 1px solid var(--border-card); box-shadow: var(--shadow-card); padding: 22px; }
.drawer__close { position: absolute; top: 12px; right: 12px; }
.drawer h2 { margin: 0; font-size: 20px; }
.drawer h3 { margin: 18px 0 6px; font-size: 13px; color: var(--accent); text-transform: uppercase; }
.drawer dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 14px; }
.drawer dt { color: var(--text-muted); }
.drawer dd { margin: 0; text-align: right; }
.overview { max-height: 320px; overflow: auto; font-size: 14px; line-height: 1.6; color: var(--text-muted); white-space: pre-line; }
.summary__zone { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
#trendText { text-transform: uppercase; }

/* Symbol detail (public/detail.js) */
.sd-head { display: flex; justify-content: space-between; gap: 16px; padding-right: 36px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.sd-head h2 { font-size: 20px; }
.sd-sub { margin: 4px 0 8px; color: var(--text-muted); font-size: 14px; }
.sd-tier { text-transform: none; font-size: 12px; }
.sd-price { text-align: right; white-space: nowrap; }
.sd-price__value { font-size: 28px; font-weight: 800; line-height: 1.1; }
.seg { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-muted); }
.seg--tabs { margin: 14px 0; flex-wrap: wrap; }
.seg__item { border: 0; background: none; padding: 5px 14px; border-radius: 999px; cursor: pointer; color: var(--text-muted); font-size: 14px; }
.seg__item.is-active { background: linear-gradient(90deg, var(--accent), var(--accent-strong)); color: var(--on-accent); font-weight: 600; }
.sd-body { display: grid; gap: 12px; }
.sd-grid { display: grid; grid-template-columns: minmax(220px, 0.9fr) 1.6fr; gap: 12px; align-items: start; }
.sd-stack { display: grid; gap: 12px; }
.sd-card { border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface-muted); padding: 14px; min-width: 0; }
.drawer .sd-card h3 { margin: 0 0 10px; }
.sd-card__head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.drawer .sd-card__head h3 { margin: 0; }
.sd-card__head .seg__item { padding: 3px 10px; font-size: 12px; }
.drawer .sd-list { margin: 0 0 6px; column-gap: 0; }
.drawer .sd-list dt, .drawer .sd-list dd { padding: 6px 0; border-bottom: 1px solid var(--border); }
.drawer .sd-list dd { padding-left: 12px; font-weight: 600; }
.sd-strong { font-size: 18px; }
.range { margin: 12px 0; font-size: 13px; }
.range__track { position: relative; height: 6px; margin: 8px 0 4px; border-radius: 3px; background: linear-gradient(90deg, var(--down), var(--gold), var(--up)); }
.range__dot { position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--bg); box-shadow: 0 0 0 1px var(--text-muted); transform: translate(-50%, -50%); }
.range__ends { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.drawer svg.sd-line, .drawer svg.sd-bars { display: block; width: 100%; height: 180px; }
.drawer svg.sd-bars { height: 110px; }
.drawer svg.sd-bars--tall { height: 170px; }
.sd-line__stroke { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
.sd-line--up .sd-line__stroke { stroke: var(--up); }
.sd-line--down .sd-line__stroke { stroke: var(--down); }
.sd-line__area { opacity: 0.12; }
.sd-line--up .sd-line__area { fill: var(--up); }
.sd-line--down .sd-line__area { fill: var(--down); }
.sd-axis { stroke: var(--border); vector-effect: non-scaling-stroke; }
.sd-bar--up { fill: var(--up); }
.sd-bar--down { fill: var(--down); }
.sd-bar--revenue { fill: var(--accent-strong); }
.sd-bars__labels { display: flex; justify-content: space-around; font-size: 11px; margin-top: 4px; }
.sd-legend { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; }
.sd-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 8px; }
.sd-key--revenue { background: var(--accent-strong); }
.sd-key--up { background: var(--up); }
.sd-caption { font-size: 12px; margin: 8px 0 4px; }
.sd-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.sd-table th, .sd-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.sd-table th:first-child, .sd-table td:first-child { text-align: left; white-space: normal; }
.sd-table th { color: var(--text-muted); font-weight: 600; }
.sd-group td { padding-top: 12px; color: var(--accent); font-weight: 600; text-transform: uppercase; font-size: 12px; }
.sd-card .sd-table { margin-top: 0; }
.sd-card:has(.sd-table) { overflow-x: auto; }
.meter { margin: 10px 0; font-size: 14px; }
.meter__label { display: flex; justify-content: space-between; }
.meter__track { height: 8px; margin-top: 4px; border-radius: 4px; background: var(--border); overflow: hidden; }
.meter__track span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); }
@media (max-width: 760px) {
  .sd-grid { grid-template-columns: 1fr; }
  .sd-head { flex-direction: column; }
  .sd-price { text-align: left; }
}

.dialog { color: var(--text); background: var(--surface-solid); border: 1px solid var(--border-card); border-radius: var(--radius-card); padding: 22px; width: min(480px, 92vw); box-shadow: var(--shadow-card); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog label { display: block; margin: 12px 0; font-size: 14px; }
.dialog input { display: block; width: 100%; height: 38px; margin-top: 4px; padding: 0 10px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-control); }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--text-muted); border-bottom: 2px solid transparent; }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.error { color: var(--down); min-height: 1.5em; margin: 0; font-size: 14px; }
code { background: var(--surface-muted); padding: 2px 6px; border-radius: var(--radius-control); }

@media (max-width: 900px) {
  .summary { grid-template-columns: 1fr 1fr; }
  .page, .topbar { padding-inline: 14px; }
}

a { color: var(--accent); }
.btn--link { display: inline-flex; align-items: center; text-decoration: none; color: var(--text); }
.gold { color: var(--gold); }
.notice { padding: 8px 12px; border: 1px solid var(--gold); border-radius: var(--radius-control); background: var(--gold-soft); color: var(--gold); font-size: 14px; }
.dialog .check { display: flex; gap: 8px; align-items: flex-start; }
.dialog .check input { width: auto; height: auto; margin-top: 4px; }
.auth-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.auth-row label { margin: 0; }
.link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: 14px; }
.link:hover { text-decoration: underline; }
.dialog h4 { margin: 16px 0 4px; font-size: 13px; color: var(--accent); text-transform: uppercase; }
.dialog details { margin-top: 14px; }
.dialog summary { cursor: pointer; color: var(--accent); }
.devices { margin: 4px 0 8px; padding-left: 18px; font-size: 13px; }
.footer { margin-top: 18px; font-size: 13px; text-align: center; }
.terms article { max-width: 820px; margin: 0 auto; line-height: 1.65; }
.terms h1 { margin-top: 0; }
.terms h2 { margin: 24px 0 8px; font-size: 17px; color: var(--accent); }
/* Text is replaced by a solid bar instead of blurred: blur on short strings can be reversed from a recording. */
.privacy .pii { color: transparent !important; background: var(--text-muted) !important; border-radius: 3px; text-shadow: none; user-select: none; pointer-events: none; }
.privacy input.pii, .privacy textarea.pii { -webkit-text-fill-color: transparent; caret-color: transparent; }
.privacy .pii * { visibility: hidden; }
.btn.is-active { color: var(--gold); border-color: var(--gold); }
#accountButton { display: inline-flex; align-items: center; gap: 8px; }
.plan-badge { padding: 1px 7px; border: 1px solid currentColor; border-radius: 999px; color: var(--text-muted); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; }
.plan-badge--vip { color: var(--gold); background: var(--gold-soft); }
.plan-badge--admin { color: var(--accent); }
.privacy .pii-block > * { display: none; }
.privacy .pii-block::before { content: '🎥 Chế độ quay màn hình: chi tiết mã VIP đang ẩn.'; color: var(--text-muted); }

/* Detail sheet: slides in from the right, a click anywhere outside closes it (closeDrawer in public/app.js). */
.drawer--sheet { overflow: hidden; padding: 0; visibility: hidden; transform: translateX(104%); transition: transform 0.34s cubic-bezier(0.22, 0.8, 0.24, 1), visibility 0s linear 0.34s; }
.drawer--sheet.is-open { visibility: visible; transform: none; transition: transform 0.34s cubic-bezier(0.22, 0.8, 0.24, 1), visibility 0s; }
.drawer--sheet #detail { height: 100%; overflow-y: auto; padding: 22px; overscroll-behavior: contain; }
.drawer--sheet .drawer__close { z-index: 2; display: grid; place-items: center; width: 36px; height: 36px; padding: 0 0 2px; line-height: 1; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-solid); font-size: 18px; }
/* Long titles (emails) would run under the close button. */
.drawer--sheet #detail > h2:first-child { padding-right: 44px; overflow-wrap: anywhere; }
.promo-strip { margin: 0 0 12px; padding: 8px 12px; border: 1px solid var(--up); border-radius: var(--radius-control); background: var(--up-soft); color: var(--up); font-size: 14px; font-weight: 600; }
.drawer--sheet .drawer__close:hover { color: var(--text); border-color: var(--accent); }
.scrim { position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 3; background: rgba(0, 0, 0, 0.35); opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
.scrim.is-on { opacity: 1; }
@keyframes sd-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes sd-reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes sd-grow { from { transform: scaleX(0); } }
@keyframes sd-rise { from { transform: scaleY(0); } }
@keyframes sd-shimmer { to { background-position: -200% 0; } }
#detail > *, .sd-body > * { animation: sd-in 0.3s ease both; }
#detail > :nth-child(2), .sd-body > :nth-child(2) { animation-delay: 0.05s; }
#detail > :nth-child(3), .sd-body > :nth-child(3) { animation-delay: 0.1s; }
.sd-line { animation: sd-reveal 0.7s ease-out both; }
.sd-bars rect { transform-box: fill-box; transform-origin: center bottom; animation: sd-rise 0.45s ease-out both; }
.sd-bars rect.sd-bar--down { transform-origin: center top; }
.meter__track span { transform-origin: left; animation: sd-grow 0.6s ease-out both; }
.range__dot { transition: left 0.4s ease; }
.seg__item { transition: background-color 0.2s, color 0.2s; }
.sd-price__value { display: inline-block; padding: 0 4px; border-radius: 4px; }
.sd-skeleton { display: grid; gap: 12px; }
.sd-skeleton span { display: block; height: 18px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-muted) 25%, var(--surface-highlight) 50%, var(--surface-muted) 75%); background-size: 200% 100%; animation: sd-shimmer 1.2s linear infinite; }
.sd-skeleton span:nth-child(1) { width: 55%; height: 26px; }
.sd-skeleton span:nth-child(4) { height: 180px; }
.btn--primary.btn--link { color: var(--on-accent); margin-bottom: 8px; }
@media (prefers-reduced-motion: reduce) {
  .drawer--sheet, .drawer--sheet *, .scrim { animation: none !important; transition: none !important; }
}

/* Mobile (≤640px; checked on iPhone 16 Plus 430pt and Meizu Lucky 08 ~393dp): rows become cards, the detail sheet rises from the bottom, safe areas respected. */
@media (max-width: 640px) {
  :root { --topbar-h: 56px; --control-h: 40px; }
  body { -webkit-text-size-adjust: 100%; background-attachment: scroll; }
  .topbar { gap: 8px; padding: calc(8px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); }
  .brand { gap: 8px; min-width: 0; }
  .brand img { width: 28px; height: 28px; }
  .brand__name { font-size: 15px; }
  .brand__tag, #trendBadge { display: none; }
  .topbar__right { gap: 6px; flex-wrap: nowrap; min-width: 0; }
  .topbar .btn { height: 36px; padding: 0 10px; white-space: nowrap; }
  /* Icon-only on phones: the emoji leads the label, the full text stays in the title tooltip. */
  #privacyToggle { min-width: 36px; padding: 0 8px; }
  #privacyToggle .btn__label { display: none; }
  #accountButton .pii { display: none; }
  #adminLink { min-width: 36px; padding: 0 8px; justify-content: center; font-size: 0; }
  #adminLink::before { content: '⚙'; font-size: 17px; }
  .live { font-size: 0; }
  .live::before { content: '●'; font-size: 14px; }
  .page { padding: 12px max(12px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .card { padding: 0; border: 0; background: none; box-shadow: none; }
  .summary { grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; border-radius: 16px; }
  .summary__trend { grid-column: 1 / -1; }
  .summary__value { font-size: 20px; }
  .tier { min-height: 48px; padding: 8px 10px; border-radius: 12px; }
  .tier .eyebrow { font-size: 11px; }
  .tier__count { font-size: 15px; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
  .filters > span { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
  .filters > span label { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; }
  .filters input[type='checkbox'] { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
  .filters > label { display: grid; gap: 4px; font-size: 12px; color: var(--text-muted); }
  .filters > label:last-child { grid-column: 1 / -1; }
  /* 16px keeps iOS Safari from zooming the page when a control takes focus. */
  .filters select { width: 100%; height: 44px; font-size: 16px; color: var(--text); border-radius: 12px; }

  .table-wrap { border: 0; overflow: visible; }
  .grid, .grid tbody { display: block; }
  .grid thead { display: none; }
  .grid tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; margin-bottom: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-muted); }
  .grid td, .grid tbody tr:last-child td { padding: 0; border: 0; white-space: normal; font-size: 14px; }
  .grid td::before { content: attr(data-label); display: block; margin-bottom: 2px; color: var(--text-muted); font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
  .grid td:nth-child(1) { align-self: center; font-size: 19px; }
  .grid td:nth-child(2), .grid td:nth-child(7) { grid-column: span 2; }
  .grid td:nth-child(8) { grid-column: 1 / -1; }
  .grid td:nth-child(1)::before, .grid td:nth-child(8)::before { display: none; }
  .grid td:nth-child(8) .pill { justify-content: center; width: 100%; min-height: 34px; font-size: 12px; }
  .grid tr.is-open { transition: transform 0.15s ease; }
  .grid tr.is-open:active { transform: scale(0.985); }
  .grid tr.is-selected { border-color: var(--accent); }
  .muted#status { font-size: 13px; }

  .cta { flex-direction: column; align-items: stretch; padding: 14px; border-radius: 16px; }
  .cta__title { font-size: 15px; }
  .cta .btn { width: 100%; border-radius: 12px; }

  .drawer { inset: auto 0 0 0; width: 100%; height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top) - 8px); border: 0; border-top: 1px solid var(--border-card); border-radius: 22px 22px 0 0; }
  .drawer--sheet { transform: translateY(104%); }
  .drawer--sheet.is-open { transform: none; }
  .drawer--sheet::before { content: ''; position: absolute; z-index: 2; top: 8px; left: 50%; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: var(--text-muted); opacity: 0.45; }
  .drawer--sheet #detail { padding: 28px 16px calc(24px + env(safe-area-inset-bottom)); }
  .drawer--sheet .drawer__close { top: 14px; right: 12px; width: 36px; height: 36px; }
  .scrim { inset: 0; }
  .sd-head { padding-right: 44px; }
  .sd-price__value { font-size: 24px; }
  .seg--tabs { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .seg--tabs::-webkit-scrollbar { display: none; }
  .seg__item { min-height: 36px; white-space: nowrap; }
  .sd-card { border-radius: 14px; }

  .dialog { width: calc(100vw - 24px); max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; padding: 18px; border-radius: 20px; }
  .dialog input { height: 44px; font-size: 16px; border-radius: 12px; }
  .dialog__actions { flex-wrap: wrap; }
  .dialog__actions .btn { flex: 1 1 auto; height: 44px; border-radius: 12px; }
  .tab { min-height: 44px; }
  .footer { padding-bottom: env(safe-area-inset-bottom); }
}

/* Liquid Glass on phones: translucent layers with blur, saturation and a lit top edge over a soft colour field.
   Android gets a lighter blur (cost on mid-range GPUs); iOS WebKit, matched by -webkit-touch-callout, gets the full effect. */
@media (max-width: 640px) {
  :root { --glass: rgba(17, 24, 33, 0.62); --glass-strong: rgba(14, 20, 28, 0.78); --glass-edge: rgba(255, 255, 255, 0.12); --glass-shine: inset 0 1px 0 rgba(255, 255, 255, 0.16); --glass-blur: blur(14px) saturate(140%); }
  :root[data-theme='light'] { --glass: rgba(255, 255, 255, 0.66); --glass-strong: rgba(255, 255, 255, 0.82); --glass-edge: rgba(255, 255, 255, 0.75); --glass-shine: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 1px 3px rgba(15, 23, 42, 0.08); }
  body::before { content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(45% 28% at 12% 8%, rgba(0, 136, 255, 0.3), transparent 70%), radial-gradient(40% 26% at 92% 34%, rgba(0, 210, 255, 0.18), transparent 70%), radial-gradient(50% 30% at 25% 88%, rgba(245, 179, 1, 0.12), transparent 70%); }
  :root[data-theme='light'] body::before { opacity: 0.55; }
  .topbar, .drawer--sheet, .dialog { background: var(--glass-strong); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border-color: var(--glass-edge); }
  .topbar { border-bottom: 1px solid var(--glass-edge); box-shadow: var(--glass-shine); }
  .drawer--sheet, .dialog { box-shadow: var(--glass-shine), 0 -12px 40px rgba(0, 0, 0, 0.35); }
  .summary, .grid tr, .cta, .filters select { background: var(--glass); border-color: var(--glass-edge); box-shadow: var(--glass-shine); }
  .cta { border: 1px dashed var(--gold); }
  .drawer--sheet .sd-card { background: var(--glass); border-color: var(--glass-edge); box-shadow: var(--glass-shine); }
  .dialog::backdrop { background: rgba(0, 0, 0, 0.45); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
}
@supports (-webkit-touch-callout: none) {
  @media (max-width: 640px) {
    :root { --glass: rgba(28, 36, 48, 0.34); --glass-strong: rgba(20, 28, 40, 0.5); --glass-edge: rgba(255, 255, 255, 0.16); --glass-shine: inset 0 1px 0 rgba(255, 255, 255, 0.28), inset 0 -1px 0 rgba(255, 255, 255, 0.05), 0 8px 24px rgba(0, 0, 0, 0.25); --glass-blur: blur(28px) saturate(190%); }
    :root[data-theme='light'] { --glass: rgba(255, 255, 255, 0.42); --glass-strong: rgba(255, 255, 255, 0.6); --glass-edge: rgba(255, 255, 255, 0.85); --glass-shine: inset 0 1px 0 rgba(255, 255, 255, 1), 0 8px 24px rgba(15, 23, 42, 0.1); }
    .summary, .grid tr, .cta { -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); }
    .summary, .grid tr { border-radius: 22px; }
    .tier { border-radius: 16px; }
    .tier.is-active { background: rgba(255, 255, 255, 0.1); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3); }
    .topbar .btn, .seg, .drawer--sheet .drawer__close { border-color: var(--glass-edge); border-radius: 999px; background: rgba(255, 255, 255, 0.08); box-shadow: var(--glass-shine); }
    .btn--primary, .btn--gold, .cta .btn, .dialog__actions .btn, .filters select, .dialog input { border-radius: 999px; }
    .dialog { border-radius: 30px; }
    .drawer--sheet { border-radius: 30px 30px 0 0; }
  }
}
@media (max-width: 640px) and (prefers-reduced-transparency: reduce) {
  .topbar, .drawer--sheet, .dialog, .summary, .grid tr, .cta { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface-solid); }
  body::before { display: none; }
}
