/* Console layout: top bar, icon sidebar, one view at a time, a key drawer and dialogs. */
body { background: var(--subtle); }

/* Sign in */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left, 0px)); background: var(--subtle); }
.login-card { width: 100%; max-width: 400px; padding: 32px; display: grid; gap: 22px; box-shadow: var(--shadow-md); }
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-card form { display: grid; gap: 14px; }
.login-card .fine { font-size: 12px; color: var(--muted); }
.demo-code { font: 12.5px var(--mono); background: var(--warn-soft); color: var(--warn); border: 1px solid #fde3a7; padding: 8px 10px; border-radius: 8px; }
.form-error { color: var(--red-ink); font-size: 13px; min-height: 0; }
.form-error:empty { display: none; }

/* Top bar */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg); }
.topbar-in { display: flex; align-items: center; gap: 16px; height: 56px; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }
.crumb-sep { color: var(--line-strong); font-size: 18px; font-weight: 300; margin: 0 -4px; }
.crumb { font-size: 14px; font-weight: 500; color: var(--ink); }
.top-links { display: flex; gap: 2px; margin-right: 4px; }
.top-links a { color: var(--muted); text-decoration: none; font-size: 13.5px; padding: 6px 10px; border-radius: 6px; }
.top-links a:hover { color: var(--ink); background: var(--hover); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.balance-pill { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 13px; color: var(--ink); text-decoration: none; background: var(--subtle); }
.balance-pill:hover { background: var(--hover); }
.balance-pill.low { border-color: #f5c2c3; background: var(--red-soft); color: var(--red-ink); }
.balance-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.balance-pill.on i { background: #22c55e; animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(34 197 94 / 50%); } 100% { box-shadow: 0 0 0 7px rgb(34 197 94 / 0%); } }
.avatar.static { cursor: default; flex: none; display: grid; place-items: center; }
.avatar { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line-strong); background: linear-gradient(135deg, #fff, var(--hover)); font: 600 13px var(--font); color: var(--ink); cursor: pointer; text-transform: uppercase; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: 42px; width: 260px; padding: 6px; box-shadow: var(--shadow-md); z-index: 25; }
.menu-head { display: flex; gap: 10px; align-items: center; padding: 10px 10px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); min-width: 0; }
.menu-head > div:last-child { min-width: 0; display: grid; }
.menu-head strong { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-head span { font-size: 12px; color: var(--muted); }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 7px 10px; border-radius: 6px; border: 0; background: none; font: 13.5px var(--font); color: var(--ink); text-decoration: none; cursor: pointer; }
.menu-pop svg { width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--hover); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* Shell */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100dvh - 56px); }
.side { border-right: 1px solid var(--line); background: var(--bg); padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(56px + env(safe-area-inset-top, 0px)); height: calc(100dvh - 56px); }
.side a { display: flex; align-items: center; gap: 10px; color: var(--ink-2); text-decoration: none; font-size: 13.5px; padding: 7px 10px; border-radius: 7px; white-space: nowrap; flex: none; }
.side a:hover { background: var(--hover); }
.side a[aria-current="page"] { background: var(--hover); color: var(--ink); font-weight: 500; }
.side svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); }
.side a[aria-current="page"] svg { color: var(--ink); }
.side-sep { height: 1px; background: var(--line); margin: 10px 4px; }
.main { padding: 28px max(24px, env(safe-area-inset-right, 0px)) 64px 32px; min-width: 0; width: 100%; max-width: 1240px; margin-inline: auto; }
.view { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
/* Grid and flex children default to their content's width; let wide tables scroll inside their card instead of widening the page. */
.view > *, .card, .credits-top > *, .grid-2 > *, .grid-3 > * { min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.page-head h1 { font-size: 22px; margin-bottom: 4px; }
.banner { margin-bottom: 20px; padding: 10px 14px; border-radius: 10px; font-size: 13.5px; background: var(--warn-soft); color: var(--warn); border: 1px solid #fde3a7; }
.banner.ok { background: var(--ok-soft); color: var(--ok); border-color: #c6ecd3; }

.grid-3 { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* Stats */
.stat { padding: 20px 22px; min-width: 0; }
.stat-big { font-size: 34px; font-weight: 500; letter-spacing: -0.03em; line-height: 1.15; margin-top: 6px; }
.stat-mid { font-size: 20px; font-weight: 500; letter-spacing: -0.02em; margin-top: 6px; }
.meter { height: 6px; border-radius: 3px; background: var(--hover); margin: 16px 0 10px; overflow: hidden; }
.meter b { display: block; height: 100%; background: var(--ink); border-radius: 3px; transition: width .6s ease; }
.meter.low b { background: var(--red); }
.kv { display: grid; grid-template-columns: auto auto; justify-content: space-between; gap: 5px 16px; margin: 12px 0 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
/* Live update cue: a brief soft highlight, not a color change that reads as an error. */
.flash { animation: flash 1s ease; border-radius: 4px; }
@keyframes flash { 0% { background: var(--hover); box-shadow: 0 0 0 4px var(--hover); } 100% { background: transparent; box-shadow: 0 0 0 4px transparent; } }

/* Credits */
.credits-top { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
.balance-card { display: grid; }
.balance-main { padding: 22px 24px 20px; }
.balance-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.balance-facts > div { padding: 16px 24px; display: grid; gap: 2px; }
.balance-facts > div + div { border-left: 1px solid var(--line); }
.balance-facts strong { font-size: 18px; font-weight: 500; letter-spacing: -0.02em; }
.balance-facts small { color: var(--muted); font-size: 12px; }
.today-card { padding: 22px 24px; }
.today-head { display: flex; justify-content: space-between; align-items: center; }
.tx-amount { color: var(--ok); }

/* Plan */
.plan-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 22px; flex-wrap: wrap; }
.plan-info { display: flex; align-items: center; gap: 16px; min-width: 0; }
.plan-mark { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--ink); flex: none; }
.plan-mark::before { content: ""; width: 18px; height: 3px; border-radius: 2px; background: var(--red); }
.plan-info h2 { font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.plan-info p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.plan-card.start { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 28px; border-color: var(--ink); box-shadow: var(--shadow-md); }
.plan-card.start h2 { font-size: 20px; letter-spacing: -0.02em; }
.plan-card.start .price { font: 500 30px var(--mono); letter-spacing: -0.03em; margin-top: 10px; }
.plan-card.start .price small { font: 400 13px var(--font); color: var(--muted); margin-left: 6px; }
.plan-list { display: flex; gap: 8px 20px; flex-wrap: wrap; margin: 14px 0 0; padding: 0; list-style: none; font-size: 13px; color: var(--ink-2); }
.plan-list li { padding-left: 20px; position: relative; }
.plan-list li::before { content: ""; position: absolute; left: 0; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--ok-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M4 7.2l2 2 4-4.4' fill='none' stroke='%2315803d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat; }
.plan-cta { display: grid; gap: 8px; justify-items: end; align-self: end; }
.plan-cta small { color: var(--muted); font-size: 12px; }
@media (max-width: 760px) { .plan-card.start { grid-template-columns: minmax(0, 1fr); } .plan-cta { justify-items: start; } }

/* Redeem */
.redeem-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 20px; align-items: center; padding: 18px 22px; }
.redeem-card h2 { font-size: 14px; margin-bottom: 2px; }
.redeem-row { display: flex; gap: 8px; }
.redeem-row input { font-family: var(--mono); font-size: 13px; text-transform: uppercase; }
@media (max-width: 760px) { .redeem-card { grid-template-columns: minmax(0, 1fr); } .redeem-row { flex-direction: column; } }

/* Add credits dialog */
.plan-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.plan-opt { position: relative; display: grid; gap: 4px; align-content: start; padding: 16px; border: 1px solid var(--line-strong); border-radius: 10px; cursor: pointer; font-size: 12.5px; color: var(--muted); transition: border-color .12s, box-shadow .12s; }
.plan-opt input { position: absolute; opacity: 0; pointer-events: none; }
.plan-opt b { font-size: 13px; font-weight: 600; color: var(--ink); }
.plan-opt strong { font: 500 22px var(--mono); letter-spacing: -0.03em; color: var(--ink); }
.plan-opt strong small { font: 400 12px var(--font); color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.plan-opt em { position: absolute; top: -9px; right: 10px; font-style: normal; font-size: 11px; font-weight: 500; padding: 1px 8px; border-radius: 999px; background: var(--ink); color: #fff; }
.plan-opt em.soft { background: var(--subtle); color: var(--ink-2); border: 1px solid var(--line-strong); }
.plan-opt:hover { border-color: var(--faint); }
.plan-opt:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.plan-opt:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.plan-opt .btn { margin-top: 10px; width: 100%; }
.plan-card.start .plan-options { margin-top: 18px; }
.plan-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.amount-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.amount-opt { position: relative; display: grid; gap: 2px; padding: 16px; border: 1px solid var(--line-strong); border-radius: 10px; cursor: pointer; font-size: 12.5px; color: var(--muted); transition: border-color .12s, box-shadow .12s; }
.amount-opt input { position: absolute; opacity: 0; pointer-events: none; }
.amount-opt strong { font-size: 22px; font-weight: 500; color: var(--ink); }
.amount-opt em { position: absolute; top: -9px; right: 10px; font-style: normal; font-size: 11px; font-weight: 500; padding: 1px 8px; border-radius: 999px; background: var(--ink); color: #fff; }
.amount-opt:hover { border-color: var(--faint); }
.amount-opt:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.amount-opt:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.secure { display: flex; align-items: center; gap: 6px; }

/* Keys */
.keys-table tbody tr { cursor: pointer; }
.keys-table tbody tr:hover td { background: var(--subtle); }
.keys-table tr.revoked td { color: var(--faint); }
.k-name strong { display: block; font-weight: 500; color: var(--ink); }
.k-name code { font-size: 12px; color: var(--muted); }
.k-spend { min-width: 140px; }
.k-spend .mini { height: 4px; border-radius: 2px; background: var(--hover); margin-top: 6px; overflow: hidden; }
.k-spend .mini b { display: block; height: 100%; background: var(--ink); }
.k-spend .mini.full b { background: var(--red); }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-weight: 500; margin-bottom: 4px; }
.connect { display: grid; gap: 14px; }
.model-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.model-card { display: flex; flex-direction: column; gap: 14px; padding: 20px 22px; min-width: 0; }
.model-head { display: grid; gap: 10px; }
.model-head > div:first-child { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.model-head h2 { font-size: 16px; letter-spacing: -0.01em; }
.model-desc { color: var(--muted); font-size: 13.5px; }
.caps { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.caps li { font-size: 12px; color: var(--ink-2); padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--subtle); }
.model-prices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.model-prices div { padding: 10px 12px; border-left: 1px solid var(--line); min-width: 0; }
.model-prices div:first-child { border-left: 0; }
.model-prices dt { font-size: 12px; color: var(--muted); }
.model-prices dd { margin: 2px 0 0; font: 500 15px var(--mono); }
.model-usage { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.model-notes { padding: 20px 22px; margin-top: 16px; }
.model-notes h2 { font-size: 15px; }
.model-notes ul { margin: 10px 0 16px; padding-left: 18px; display: grid; gap: 6px; color: var(--ink-2); font-size: 13.5px; }
.model-notes code { font-size: 12px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 5px; background: var(--subtle); }
.copyline { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; padding: 6px 6px 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--subtle); min-width: 0; }
.copyline code { overflow-x: auto; white-space: nowrap; font-size: 12.5px; }
.models-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.models-list code { padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--subtle); font-size: 12px; }
.checklist { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.checklist li { position: relative; padding-left: 24px; color: var(--ink-2); font-size: 13.5px; }
.checklist li::before { content: ""; position: absolute; left: 0; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--ok-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M4 7.2l2 2 4-4.4' fill='none' stroke='%2315803d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat; }

/* Activity */
.head-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.summary-strip > div { padding: 18px 22px; display: grid; gap: 2px; min-width: 0; }
.summary-strip > div + div { border-left: 1px solid var(--line); }
.summary-strip strong { font-size: 22px; font-weight: 500; letter-spacing: -0.02em; }
.summary-strip small { color: var(--muted); font-size: 12px; }
.breakdown { padding: 6px 20px 14px; display: grid; }
.bd-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: center; }
.bd-row:last-child { border-bottom: 0; }
.bd-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.bd-name small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.bd-val { text-align: right; font-family: var(--mono); font-size: 13px; }
.bd-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--hover); overflow: hidden; }
.bd-bar b { display: block; height: 100%; border-radius: 3px; background: #3f3f46; }
.bd-meta { grid-column: 1 / -1; display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.req-table td.when { white-space: nowrap; }
.req-table td.when span { display: block; font-size: 12px; color: var(--muted); }
.key-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--subtle); font-size: 12.5px; }
.key-chip::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--ink-2); }
.model-cell strong { display: block; font-weight: 500; font-size: 13px; }
.model-cell code { font-size: 11.5px; color: var(--muted); }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); box-shadow: var(--shadow-sm); }
.seg button { border: 0; background: none; padding: 5px 12px; font: 500 13px var(--font); color: var(--muted); cursor: pointer; border-radius: 6px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* Charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 240px; overflow: visible; }
.chart.small svg { height: 150px; }
.chart .axis { fill: var(--faint); font: 11px var(--font); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .grid.base { stroke: var(--line-strong); stroke-dasharray: none; }
.chart .bar { fill: #3f3f46; transition: fill .1s; }
.chart .bar.today { fill: var(--red); }
.chart .hit { fill: transparent; }
.chart .col { fill: var(--hover); opacity: 0; }
.chart .col.active { opacity: 1; }
.chart .bar.active { fill: var(--ink); }
.chart .bar.today.active { fill: var(--red-ink); }
.tip { position: absolute; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; min-width: 190px; white-space: nowrap; box-shadow: var(--shadow-md); z-index: 5; }
.tip b { display: block; margin-bottom: 6px; font-weight: 500; }
.tip div { display: flex; justify-content: space-between; gap: 18px; color: var(--muted); line-height: 1.7; }
.tip div span:last-child { color: var(--ink); font-family: var(--mono); font-size: 12px; }

tr.new td { animation: rowin 1.6s ease; }
@keyframes rowin { 0% { background: var(--red-soft); } 100% { background: transparent; } }

/* Drawer */
.drawer { position: fixed; inset: 0; z-index: 40; }
.drawer-scrim { position: absolute; inset: 0; background: rgb(16 16 20 / 28%); animation: fade .15s ease; }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(600px, 100%); background: var(--bg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .18s ease; padding-top: env(safe-area-inset-top, 0px); padding-right: env(safe-area-inset-right, 0px); }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 17px; margin-bottom: 2px; }
.drawer-body { padding: 20px 24px 32px; overflow-y: auto; display: grid; gap: 18px; align-content: start; }
.d-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.d-stats div { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.d-stats strong { display: block; font-size: 17px; font-weight: 500; margin-top: 2px; }
.d-title { font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.d-table { border: 1px solid var(--line); border-radius: 10px; }
.d-table table { table-layout: fixed; }
.d-table th:first-child, .d-table td:first-child { width: 52%; }
.d-model { white-space: normal; }
.d-model strong { display: block; font-weight: 500; }
.d-model code { font-size: 11.5px; color: var(--muted); }
.d-chart { border: 1px solid var(--line); border-radius: 10px; padding: 14px 10px 6px; }
.d-settings { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px 16px; margin: 0; font-size: 13.5px; }
.d-settings dt { color: var(--muted); }
.d-settings dd { margin: 0; overflow-wrap: anywhere; }
.d-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 6px; border-top: 1px solid var(--line); padding-top: 18px; }

/* Dialogs */
.modal { border: 0; padding: 0; border-radius: 14px; box-shadow: var(--shadow-lg); width: min(520px, calc(100% - 32px)); color: var(--ink); }
.modal::backdrop { background: rgb(16 16 20 / 35%); }
.modal-in { display: grid; }
.modal-head { padding: 20px 24px 0; }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 16px 24px 4px; display: grid; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 20px 24px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.secret { display: flex; gap: 8px; align-items: center; padding: 8px 8px 8px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--subtle); }
.secret code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font-size: 13px; }

/* Toasts */
.toasts { position: fixed; right: max(20px, env(safe-area-inset-right, 0px)); bottom: max(20px, env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow-lg); animation: slide .18s ease; }
.toast.err { background: var(--red-ink); }

@media (max-width: 960px) {
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-strip > div:nth-child(3) { border-left: 0; }
  .summary-strip > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .credits-top { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; }
  .side-sep, .top-links, .crumb-sep, .crumb, #top-add { display: none; }
  .main { padding: 20px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px)); }
  .page-head { align-items: stretch; }
  .page-head > .btn, .page-head .head-controls { width: 100%; }
  .page-head .head-controls .seg { flex: 1; }
  .page-head .head-controls .seg button { flex: 1; }
  .plan-card.start { padding: 22px 20px; }
  .plan-card.start .btn-lg { width: 100%; }
  .plan-list { display: grid; gap: 8px; }
  .plan-card { flex-direction: column; align-items: stretch; }
  .plan-card > .btn { width: 100%; }
  .balance-main, .today-card, .stat { padding: 18px 20px; }
  .card-head { flex-wrap: wrap; padding: 14px 16px; }
  .card-body { padding: 16px; }
  .stat-big { font-size: 30px; }
  .newkey, .redeem-row { flex-direction: column; }
  .amount-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .model-grid { grid-template-columns: minmax(0, 1fr); }
  .model-prices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .model-prices div:nth-child(3) { border-left: 0; }
  .model-prices div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .plan-options { grid-template-columns: minmax(0, 1fr); }
  .plan-actions { display: grid; }
  .plan-actions .btn { width: 100%; }
  .topbar-in { gap: 10px; }
  .balance-pill { padding: 0 10px; }
  .drawer-head, .drawer-body { padding-left: 18px; padding-right: 18px; }
  .balance-facts { grid-template-columns: minmax(0, 1fr); }
  .balance-facts > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .field-row, .d-stats { grid-template-columns: minmax(0, 1fr); }

}
.plan-opt.static { cursor: default; }
.plan-opt.static:hover { border-color: var(--line-strong); }
