/* X-RAY 7: quiet, dense internal tool. One accent; color only where it means something.
   Motion is interaction-driven (hover, reveal-once, one-shot effects) and off with reduced motion or Settings → Animations. */

:root, [data-theme="dark"] {
    color-scheme: dark;
    --bg: #0F1216; --panel: #15191F; --well: #1A1F26; --well-2: #20262E;
    --border: #232931; --border-2: #2F3741;
    --text: #E6E9EE; --text-2: #9AA3AF; --text-3: #6B7480;
    --accent: #5B9BFF; --accent-soft: rgba(91,155,255,.12);
    --up: #3FB950; --amber: #D9A23A; --down: #F0605D; --btc: #E8962E;
    --shadow: 0 10px 30px rgba(0,0,0,.35);
}
[data-theme="light"] {
    color-scheme: light;
    --bg: #F5F6F8; --panel: #FFFFFF; --well: #F7F8FA; --well-2: #EEF0F3;
    --border: #E3E6EA; --border-2: #D0D5DC;
    --text: #1B1F24; --text-2: #5F6B7A; --text-3: #8C96A3;
    --accent: #2563EB; --accent-soft: rgba(37,99,235,.08);
    --up: #1A7F37; --amber: #9A6700; --down: #CF222E; --btc: #C26A00;
    --shadow: 0 10px 30px rgba(20,30,50,.12);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scrollbar-gutter: stable; }
body { font: 400 14px/1.45 Inter, system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: .01em; }
h2 { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.muted { color: var(--text-3); font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 10px; border: 2px solid var(--bg); }
main { max-width: 1240px; margin: 0 auto; padding: 18px 24px 48px; }

/* ── Top bar with the central search ───────────────────────────────── */
.topbar { position: sticky; top: 0; z-index: 40; display: grid; grid-template-columns: 1fr minmax(320px, 640px) 1fr; align-items: center; gap: 16px;
    height: 60px; padding: 0 24px; background: var(--bg); border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; align-items: center; color: var(--text); text-decoration: none; }
/* The logo is a shape filled with the text color, so it reads in both themes */
.brand-mark { display: block; height: 17px; aspect-ratio: 1070 / 258; background: currentColor;
    -webkit-mask: url(assets/xray-logo.svg) center / contain no-repeat; mask: url(assets/xray-logo.svg) center / contain no-repeat; }
.top-actions { justify-self: end; display: flex; gap: 4px; }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; background: none; border: 0; border-radius: 6px; color: var(--text-2); cursor: pointer; transition: background .12s, color .12s; }
.icon-btn:hover { background: var(--well-2); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

.search { position: relative; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 12px;
    background: var(--panel); border: 1px solid var(--border-2); border-radius: 10px; transition: border-color .12s, box-shadow .12s; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-ico { width: 16px; height: 16px; color: var(--text-3); flex-shrink: 0; }
.search input { flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: none; }
.search input::placeholder { color: var(--text-3); }
.search kbd { font: 500 11px Inter; color: var(--text-3); border: 1px solid var(--border-2); border-radius: 4px; padding: 1px 5px; }
.chips { display: flex; gap: 4px; flex-shrink: 0; }
.chip { font-size: 11px; font-weight: 500; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 2px 6px; white-space: nowrap; }
.suggest { position: absolute; top: calc(100% + 6px); left: 0; right: 0; list-style: none; background: var(--panel); border: 1px solid var(--border-2);
    border-radius: 10px; padding: 4px; box-shadow: var(--shadow); max-height: 420px; overflow: auto; animation: drop .12s ease-out; }
.suggest li { display: grid; grid-template-columns: 22px 64px 1fr auto; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; cursor: pointer; }
.suggest li .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.suggest li.sel, .suggest li:hover { background: var(--well-2); }
.sg-meta { font-size: 11px; color: var(--text-3); }
@keyframes drop { from { opacity: 0; transform: translateY(-4px); } }

/* ── Controls ──────────────────────────────────────────────────────── */
.btn { height: 32px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--border-2);
    border-radius: 6px; font-weight: 500; cursor: pointer; transition: background .12s; white-space: nowrap; }
.btn:hover { background: var(--well-2); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: 6px; overflow: hidden; }
.seg button { height: 28px; padding: 0 12px; background: var(--panel); border: 0; border-right: 1px solid var(--border-2); font-size: 12px; color: var(--text-2); cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--well-2); color: var(--text); font-weight: 600; }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.q { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border-2); background: none; color: var(--text-3); font-size: 11px; font-weight: 600;
    line-height: 1; cursor: pointer; display: inline-grid; place-items: center; flex-shrink: 0; transition: color .12s, border-color .12s; }
.q:hover { color: var(--accent); border-color: var(--accent); }

/* ── Home ──────────────────────────────────────────────────────────── */
.view { animation: fade .16s ease-out; }
@keyframes fade { from { opacity: 0; } }
.home-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.quick-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.qtab { font: inherit; font-size: 12.5px; font-weight: 500; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border-2); background: var(--panel); color: var(--text-2); cursor: pointer; }
.qtab:hover { color: var(--text); border-color: var(--text-3); }
.qtab.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.scan-slot { margin-left: auto; }
.tile-score.up50 { color: var(--btc); background: color-mix(in srgb, var(--btc) 12%, transparent); }
.sec { margin-bottom: 22px; }
.sec-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.tile { display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 10px; text-align: left; background: var(--panel); border: 1px solid var(--border);
    border-radius: 8px; cursor: pointer; transition: border-color .12s, transform .12s, background .12s; min-width: 0; }
.tile:hover { border-color: var(--border-2); background: var(--well); transform: translateY(-1px); }
.tile.in { animation: rise .22s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.tile-text { display: grid; min-width: 0; flex: 1; }
.tile-text b { font-size: 13px; }
.tile-text small { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-score { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; padding: 1px 6px; border-radius: 4px; }
.tile-score.good { color: var(--up); background: color-mix(in srgb, var(--up) 12%, transparent); }
.tile-score.mid { color: var(--amber); background: color-mix(in srgb, var(--amber) 12%, transparent); }
.tile-score.bad { color: var(--down); background: color-mix(in srgb, var(--down) 12%, transparent); }
.logo { width: 28px; height: 28px; border-radius: 6px; object-fit: contain; background: #fff; flex-shrink: 0; }
.logo-sm { width: 20px; height: 20px; border-radius: 4px; }
.logo-lg { width: 44px; height: 44px; border-radius: 10px; }
.logo-mono, .logo-btc { display: grid; place-items: center; background: var(--well-2); color: var(--text-2); font-weight: 700; font-size: 11px; }
.logo-btc { background: var(--btc); color: #fff; font-size: 16px; }
.logo-lg.logo-btc { font-size: 24px; } .logo-sm.logo-btc { font-size: 12px; }
.empty { padding: 60px 0; text-align: center; color: var(--text-3); }

.web { position: relative; height: calc(100vh - 60px - 18px - 44px - 24px); min-height: 480px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); overflow: hidden; }
.web canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.web-tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--border-2); border-radius: 6px; padding: 6px 9px; font-size: 12px; box-shadow: var(--shadow); max-width: 260px; }
.web-ctrl { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 10px; align-items: center; }

/* ── Report ────────────────────────────────────────────────────────── */
.report-top { margin-bottom: 12px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; animation: fade .2s ease-out; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 12px; align-items: start; }
.grid-2 > * > .panel:last-child, .grid-2 > .panel { margin-bottom: 12px; }

.summary { display: grid; grid-template-columns: 1fr auto auto auto; gap: 28px; align-items: center; }
.sum-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sum-px { text-align: right; }
.sum-px .big { font-size: 22px; font-weight: 600; }
.sum-px > div:last-child { font-size: 12px; }
.sum-score { display: grid; grid-template-columns: auto 1fr; gap: 0 12px; align-items: center; min-width: 230px; }
.score-num { font-size: 34px; font-weight: 700; line-height: 1; }
.sum-score.has-upside { grid-template-columns: auto auto 1fr; }
.upside { display: flex; flex-direction: column; align-items: center; padding: 2px 12px; border-left: 1px solid var(--border-2); }
.upside-val { font-size: 26px; font-weight: 700; line-height: 1; color: var(--amber); }
.upside.tone-hot .upside-val { color: var(--down); }
.upside .pct { font-size: 15px; margin-left: 1px; }
.upside small { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-3); margin-top: 3px; text-transform: uppercase; letter-spacing: .04em; }
.action-why { grid-column: 1 / -1; margin: 8px 0 0; font-size: 12.5px; color: var(--text-2); max-width: 520px; line-height: 1.45; }
.odds-line { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 6px; font-size: 12.5px; color: var(--text-2); }
.odds-line b { color: var(--text); font-variant-numeric: tabular-nums; }
.risky-btn { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border-2); background: transparent; color: var(--text-2); cursor: pointer; }
.risky-btn[aria-pressed="true"] { background: var(--down); border-color: var(--down); color: #fff; }
.score-word { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.score-bar { grid-column: 1 / -1; height: 4px; margin-top: 8px; background: var(--well-2); border-radius: 2px; overflow: hidden; }
.score-bar i { display: block; height: 100%; background: currentColor; transition: width .4s ease-out; }
.tone-good { color: var(--up); } .tone-mid { color: var(--amber); } .tone-bad { color: var(--down); } .tone-none { color: var(--text-3); }
.sum-score .score-word, .sum-score .muted { color: var(--text); } .sum-score .muted { color: var(--text-3); }
.sum-actions { display: flex; flex-direction: column; gap: 6px; }

.chart-box { position: relative; height: 380px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 3px; margin-right: 6px; vertical-align: middle; border-radius: 2px; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 20px; }
.kv-grid.strip { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); grid-template-columns: repeat(4, 1fr); }
.kv { display: grid; gap: 1px; }
.kv > span { font-size: 12px; color: var(--text-3); }
.kv b { font-weight: 600; }
.kv small { font-size: 12px; color: var(--text-3); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-3); padding: 0 8px 6px 0; }
td { padding: 8px 8px 8px 0; border-top: 1px solid var(--border); vertical-align: middle; }
td.num, th.num { text-align: right; }
.sig-table tr.sig-row { cursor: pointer; }
.sig-table tr.sig-row:hover td { background: var(--well); }
.sig-table td:first-child { padding-left: 6px; }
.sig-name { font-weight: 500; white-space: nowrap; }
.sig-name small { color: var(--text-3); font-weight: 400; margin-left: 4px; }
.sig-table td.num { font-weight: 600; white-space: nowrap; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px; }
.sig-pts { width: 120px; text-align: right; white-space: nowrap; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.sig-pts .bar { display: inline-block; width: 48px; height: 4px; margin-right: 8px; vertical-align: middle; background: var(--well-2); border-radius: 2px; overflow: hidden; }
.sig-pts .bar i { display: block; height: 100%; background: currentColor; }
.sig-q { width: 26px; text-align: right; }
tr.sig-group td { padding: 14px 6px 4px; font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
tr.sig-detail td { display: none; border-top: 0; padding: 0 8px 10px 6px; font-size: 12px; color: var(--text-2); }
tr.sig-row.open + tr.sig-detail td { display: table-cell; animation: fade .15s ease-out; }
.tp tr[title] { cursor: help; }
.tp small { color: var(--text-3); }
.tp th:first-child, .tp td:first-child { padding-left: 12px; }       /* room for the highlight's accent edge */
.tp th:last-child, .tp td:last-child { padding-right: 12px; }
.tp.entry tr.best td { background: var(--accent-soft); color: var(--text); }
.tp.entry tr.best td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.tp .best-tag { color: var(--accent); margin-left: 4px; font-size: 11px; }
.tp td.nowrap, .tp.entry td.num { white-space: nowrap; }
.entry-note { font-size: 12px; margin: 8px 0 0; }
.load-warn { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 12px; border-radius: 10px; font-size: 13px;
    background: color-mix(in srgb, var(--amber) 12%, var(--panel)); border: 1px solid color-mix(in srgb, var(--amber) 45%, var(--border)); color: var(--text); }
.load-warn .ico { color: var(--amber); width: 18px; height: 18px; } .load-warn span { flex: 1; } .load-warn button { flex-shrink: 0; }
td.didnt-load { color: var(--amber); font-weight: 500; }

/* Ambient background, shared by the sign-in screen and the app (js/ambient.js draws the rippling dot field on a canvas).
   Here: two soft glows that drift. It sits behind everything and panels stay opaque, so it only shows in the gaps. Settings → Animations (html.no-fx) or the OS reduce-motion setting stops it. */
.ambient { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.ambient i, .ambient canvas { position: absolute; display: block; }
.ambient canvas { inset: 0; }
.amb-glow { inset: -25%;
    background: radial-gradient(38% 32% at 28% 22%, color-mix(in srgb, var(--accent) 15%, transparent), transparent 70%),
                radial-gradient(34% 30% at 76% 78%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%);
    animation: amb-drift 46s ease-in-out infinite alternate; will-change: transform; }
@keyframes amb-drift { from { transform: translate3d(-4%, -3%, 0) scale(1); } to { transform: translate3d(4%, 3%, 0) scale(1.1); } }

/* Browser version: until the session check finishes, only the sign-in card (and the backdrop) may show */
html.auth-pending body > :not(.login):not(.ambient) { display: none; }   /* out of the layout, so phones don't zoom out to fit it */

/* Browser version: sign-in screen */
/* The sign-in layer is see-through: the shared ambient background shows behind the card, plus a glow from above */
.login { position: fixed; inset: 0; display: grid; place-items: center; z-index: 80; padding: 16px; overflow: auto;
    background: radial-gradient(900px 520px at 50% -8%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 65%); }
.login-card { position: relative; overflow: hidden; width: min(400px, 100%); display: flex; flex-direction: column; gap: 12px; padding: 34px 30px 22px;
    text-align: center; border-radius: 16px; border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
    background: color-mix(in srgb, var(--panel) 88%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 8%, transparent), 0 24px 70px color-mix(in srgb, var(--accent) 18%, transparent), var(--shadow);
    animation: rise .45s cubic-bezier(.2, .8, .2, 1) both; }
.login-head { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 8px; }
.login-head .brand-mark { height: 42px; color: var(--text); }
.login-intro, .login-msg { text-wrap: balance; }
.login-intro { font-size: 13px; color: var(--text-3); margin-bottom: 2px; }
.login-card input { height: 42px; padding: 0 14px; background: var(--bg); border: 1px solid var(--border-2); border-radius: 10px; outline: none; text-align: left; transition: border-color .15s, box-shadow .15s; }
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card .btn { height: 42px; justify-content: center; border-radius: 10px; font-weight: 600; }
.login-msg { font-size: 12.5px; }
.login-msg:empty { display: none; }
.login-foot { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-3); letter-spacing: .03em; }
.link-btn { background: none; border: 0; color: var(--accent); font-size: 12.5px; cursor: pointer; padding: 2px; align-self: center; }
.link-btn:hover { text-decoration: underline; }
.load-warn.key-note { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.load-warn.key-note .ico { color: var(--accent); }
.scen-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.scen-cell { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 8px; background: var(--well); border-top: 3px solid currentColor; }
.scen-cell.up { color: var(--up); } .scen-cell.down { color: var(--down); }
.scen-cell b { font-size: 20px; color: var(--text); } .scen-cell small { font-size: 12px; } .scen-cell .muted { color: var(--text-3); }
.scen-note { font-size: 12px; margin-top: 8px; }
.amt-in { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; color: var(--text-3); }
.amt-in input { width: 90px; height: 28px; padding: 0 8px; background: var(--bg); border: 1px solid var(--border-2); border-radius: 6px; outline: none; }
.sources { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.loading .ld-title { font-weight: 600; margin-bottom: 8px; }
.ld-steps { list-style: none; display: flex; gap: 18px; color: var(--text-3); font-size: 12px; }
.ld-steps li::before { content: '○ '; }
.error { color: var(--down); }

/* ── Explain panel ─────────────────────────────────────────────────── */
.explain { position: fixed; top: 60px; right: 0; bottom: 0; width: min(440px, 100vw); z-index: 30; background: var(--panel); border-left: 1px solid var(--border-2);
    box-shadow: var(--shadow); display: flex; flex-direction: column; transform: translateX(100%); transition: transform .18s ease-out; }
.explain.open { transform: none; }
.explain header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.explain h3 { font-size: 15px; }
.ex-body { padding: 14px 16px 24px; overflow: auto; font-size: 13px; line-height: 1.55; color: var(--text-2); }
.ex-body p, .ex-body ul { margin-bottom: 10px; } .ex-body ul { padding-left: 18px; }
.ex-body h4 { font-size: 12px; font-weight: 600; color: var(--text); margin: 16px 0 6px; }
.ex-body b, .ex-body em { color: var(--text); }
.ex-table { margin: 4px 0 8px; font-size: 12px; }
.ex-table td { padding: 6px 8px 6px 0; color: var(--text-2); }
.ex-table tr.hit td { color: var(--text); font-weight: 600; background: var(--accent-soft); }
.ex-table tr.hit td:first-child { box-shadow: inset 2px 0 0 var(--accent); padding-left: 6px; }
.ex-table tr.off td { color: var(--text-3); }
.ex-table tfoot td { color: var(--text); font-weight: 600; }
.ex-math { font-size: 15px; color: var(--text); text-align: center; padding: 8px; background: var(--well); border-radius: 6px; font-variant-numeric: tabular-nums; }
.ex-note { font-size: 12px; color: var(--text-3); }

/* ── Top nav ───────────────────────────────────────────────────────── */
.top-left { display: flex; align-items: center; gap: 20px; }
.top-nav { display: flex; gap: 2px; }
.top-nav a { padding: 6px 10px; border-radius: 6px; color: var(--text-2); text-decoration: none; font-weight: 500; transition: background .12s, color .12s; }
.top-nav a:hover { background: var(--well-2); color: var(--text); }
.top-nav a.on { color: var(--text); background: var(--well-2); }

/* ── Portfolio ─────────────────────────────────────────────────────── */
.pf-empty { text-align: center; padding: 48px 20px; display: grid; gap: 12px; justify-items: center; }
.pf-empty h2 { font-size: 16px; }
.pf-sum { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 24px; align-items: start; }
.pf-sum .big { font-size: 22px; font-weight: 600; margin: 2px 0; }
.pf-sum > div > div:first-child { display: flex; align-items: center; gap: 6px; }
.pf-sum .up, .pf-sum .down { font-size: 12px; } .pf-sum .big.up, .pf-sum .big.down { font-size: 22px; }
.pf-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.pf-chart { height: 300px; }
.tbl-wrap { overflow-x: auto; }
.pf-table tbody tr { cursor: pointer; }
.pf-table tbody tr:hover td { background: var(--well); }
.pf-table td { white-space: nowrap; }
.pf-table small { font-size: 11px; }
.pf-stock { display: inline-flex; align-items: center; gap: 8px; }
.then-now { white-space: nowrap; }
.then-now .arrow { color: var(--text-3); margin: 0 6px; }
.tile-score.rebuilt { background: none; outline: 1px dashed currentColor; outline-offset: -1px; }
.th-q { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
#pfStatus { margin-left: auto; margin-right: 12px; }
.pf-trades summary { cursor: pointer; list-style: none; }
.pf-trades summary::-webkit-details-marker { display: none; }
.pf-trades summary h2::before { content: '▸'; color: var(--text-3); margin-right: 2px; transition: transform .12s; display: inline-block; }
.pf-trades[open] summary h2::before { transform: rotate(90deg); }
.pf-trades[open] summary { margin-bottom: 10px; }
.sub-head { font-size: 12px; font-weight: 600; color: var(--text-2); margin: 16px 0 8px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg-wide { display: grid; grid-template-columns: 1fr 1fr; }
.seg-wide button { height: 32px; font-size: 13px; }
#tradeType button[data-type="buy"].on { color: var(--up); }
#tradeType button[data-type="sell"].on { color: var(--down); }
dialog input[type=text], dialog input[type=number], dialog input[type=date], dialog input:not([type]) {
    height: 32px; padding: 0 10px; background: var(--bg); border: 1px solid var(--border-2); border-radius: 6px; outline: none; color: var(--text); }
dialog input:focus { border-color: var(--accent); }
#tradeDlg { width: min(480px, 94vw); }
#tradeDlg .error { font-size: 13px; min-height: 1em; }
@media (max-width: 980px) { .pf-sum { grid-template-columns: 1fr 1fr; } .pf-actions { grid-column: 1 / -1; flex-direction: row; } .top-nav a { padding: 6px 6px; } }

/* ── Settings dialog ───────────────────────────────────────────────── */
dialog { margin: auto; border: 1px solid var(--border-2); border-radius: 12px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); width: min(420px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { display: grid; gap: 12px; padding: 18px; }
dialog h3 { font-size: 15px; }
dialog label { display: grid; gap: 4px; font-size: 12px; color: var(--text-2); }
dialog label.check { display: flex; gap: 6px; align-items: center; }
dialog input[type=password] { height: 32px; padding: 0 10px; background: var(--bg); border: 1px solid var(--border-2); border-radius: 6px; outline: none; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Tablets and narrow windows */
@media (max-width: 980px) {
    .topbar { grid-template-columns: auto 1fr auto; }
    .search kbd { display: none; }
    .grid-2 { grid-template-columns: 1fr; }
    .summary { grid-template-columns: 1fr auto; }
    .sum-score { grid-column: 1 / -1; }
    .sum-actions { flex-direction: row; grid-column: 1 / -1; }
    .kv-grid.strip { grid-template-columns: 1fr 1fr; }
}
/* ── Phones (≤720px): one column, nothing wider than the screen, tables scroll sideways inside their panel ── */
@media (max-width: 720px) {
    main { padding: 12px 12px 40px; }
    /* Top bar: logo, nav and buttons on one row; search full width below */
    .topbar { grid-template-columns: 1fr auto; grid-template-rows: auto auto; height: auto; gap: 8px 10px; padding: 8px 12px 10px; }
    .top-left { gap: 10px; min-width: 0; }
    .top-nav a { padding: 6px 7px; font-size: 13px; }
    .brand-mark { height: 15px; }
    .search { grid-column: 1 / -1; grid-row: 2; height: 38px; }
    .search kbd { display: none; }
    .top-actions { gap: 0; }
    .risky-btn { padding: 5px 8px; }
    .explain { top: 0; width: 100vw; z-index: 50; }
    /* Home: suggested tabs scroll sideways in one row; Scan all gets its own full-width row */
    .quick-tabs { flex-wrap: nowrap; overflow-x: auto; margin: 0 -12px 10px; padding: 2px 12px 4px; scrollbar-width: none; }
    .quick-tabs::-webkit-scrollbar { display: none; }
    .qtab { flex-shrink: 0; }
    .home-bar { flex-wrap: wrap; gap: 8px; }
    .scan-slot { margin-left: 0; width: 100%; }
    .scan-btn { width: 100%; justify-content: center; }
    .tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .web { height: 70vh; min-height: 380px; }
    /* Report */
    .panel { padding: 12px; min-width: 0; }
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .summary { grid-template-columns: 1fr auto; gap: 12px; }
    .sum-id { gap: 10px; } .sum-id h1 { font-size: 19px; } .sum-id .muted { font-size: 11.5px; }
    .sum-px .big { font-size: 19px; }
    .sum-score { grid-column: 1 / -1; min-width: 0; }
    .score-num { font-size: 30px; }
    .sum-actions { grid-column: 1 / -1; flex-direction: row; }
    .sum-actions .btn { flex: 1; justify-content: center; }
    .action-why { max-width: none; }
    .chart-box { height: 260px; }
    .kv-grid { grid-template-columns: 1fr 1fr; gap: 10px 14px; }
    .kv-grid.strip { grid-template-columns: 1fr 1fr; }
    .scen-grid { grid-template-columns: 1fr 1fr; }
    .scen-cell b { font-size: 17px; }
    .panel-head .row-gap { flex-wrap: wrap; }
    /* Wide tables keep their columns and scroll sideways inside the panel instead of widening the page */
    .tp, .pf-table, .ex-table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
    .sig-table .sig-pts .bar { display: none; }
    .sig-table td { padding-left: 4px; padding-right: 4px; }
    .sig-name { white-space: normal; }
    .sig-pts { width: auto; }
    .panel-head { flex-wrap: wrap; gap: 4px 10px; }
    /* Portfolio */
    .pf-sum { grid-template-columns: 1fr 1fr; gap: 14px; }
    .pf-actions { grid-column: 1 / -1; flex-direction: row; }
    .pf-actions .btn { flex: 1; justify-content: center; }
    .pf-chart { height: 220px; }
    /* Toasts span the bottom of the screen */
    #toasts { left: 12px; right: 12px; bottom: 12px; }
    .toast { max-width: none; }
}
@media (max-width: 380px) {
    .risky-btn span { display: none; }              /* icon only on the narrowest phones */
    .top-nav a { padding: 6px 5px; }
}

/* ── Fun, one-shot motion (fx.js). Each plays once per action; nothing idles. ───────────── */
.ico { width: 15px; height: 15px; flex-shrink: 0; vertical-align: -3px; }

/* Report opens: X-ray beam sweeps the summary, panels rise in, the instruction pops */
.summary { position: relative; overflow: hidden; }
.summary.xray-sweep::after { content: ''; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(100deg, transparent 0 35%, color-mix(in srgb, var(--accent) 22%, transparent) 48%, color-mix(in srgb, var(--accent) 45%, transparent) 50%, color-mix(in srgb, var(--accent) 22%, transparent) 52%, transparent 65% 100%);
    transform: translateX(-100%); animation: sweep 1s cubic-bezier(.4, 0, .2, 1) .1s both; }
@keyframes sweep { to { transform: translateX(100%); } }
.panel.rise-in { animation: rise .35s cubic-bezier(.2, .8, .2, 1) both; }
.score-word.pop { animation: pop .5s cubic-bezier(.3, 1.6, .5, 1) .35s both; transform-origin: left center; }
@keyframes pop { from { opacity: 0; transform: scale(.7); } }
.bar i { transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.score-bar i { transition: width .9s cubic-bezier(.2, .8, .2, 1); }

/* Loading: the X-ray scanner */
.loading.scanner { position: relative; overflow: hidden; min-height: 260px; }
.scan-beam { position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; pointer-events: none;
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 18%, transparent), transparent);
    border-right: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); animation: beam 1.5s ease-in-out infinite; }
@keyframes beam { to { left: 100%; } }
.scanner .ld-title { display: flex; align-items: center; gap: 8px; color: var(--accent); }
.sk { display: block; background: var(--well-2); border-radius: 6px; }
.sk-row { display: flex; align-items: center; gap: 14px; margin: 16px 0 12px; }
.sk-logo { width: 44px; height: 44px; border-radius: 10px; } .sk-line { height: 14px; flex: 1; max-width: 260px; } .sk-num { width: 70px; height: 34px; margin-left: auto; }
.sk-chart { height: 120px; margin-bottom: 12px; }
.scanner .ld-steps li::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: 1px; animation: blink 1.2s ease-in-out infinite; }
.scanner .ld-steps li:nth-child(2)::before { animation-delay: .2s; } .scanner .ld-steps li:nth-child(3)::before { animation-delay: .4s; }
@keyframes blink { 50% { opacity: .25; } }

/* Tiles and tabs: a little lift under the pointer */
.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 16px color-mix(in srgb, var(--text) 8%, transparent); }
.tile:hover .tile-score.up50 { animation: launch .45s cubic-bezier(.3, 1.5, .5, 1); }
@keyframes launch { 40% { transform: translateY(-3px) rotate(-4deg); } }
.qtab { display: inline-flex; align-items: center; gap: 6px; transition: background .15s, border-color .15s, color .15s, transform .15s; }
.qtab:hover { transform: translateY(-1px); }
.qtab:active { transform: scale(.96); }
.qtab .ico { width: 14px; height: 14px; }
.qtab[data-tab="moonshot"]:hover .ico { animation: launch .45s cubic-bezier(.3, 1.5, .5, 1); }

/* Scan button fills up as it goes */
.scan-btn { position: relative; overflow: hidden; display: inline-flex; align-items: center; gap: 6px; }
.scan-btn::before { content: ''; position: absolute; inset: 0; width: calc(var(--p, 0) * 100%); background: var(--accent-soft); transition: width .4s ease-out; z-index: 0; }
.scan-btn > * { position: relative; z-index: 1; }

/* Risky mode: the button ignites; reports get a warm edge */
.risky-btn { display: inline-flex; align-items: center; gap: 5px; transition: background .2s, border-color .2s, color .2s, transform .15s; }
.risky-btn .ico { width: 14px; height: 14px; }
.risky-btn.ignite { animation: ignite .6s cubic-bezier(.3, 1.6, .5, 1); }
.risky-btn.ignite .ico { animation: flicker .6s ease-out; }
@keyframes ignite { 30% { transform: scale(1.12); box-shadow: 0 0 0 6px color-mix(in srgb, var(--down) 25%, transparent); } }
@keyframes flicker { 25% { transform: scale(1.4) rotate(-8deg); } 55% { transform: scale(.9) rotate(6deg); } }
html.risky .summary { border-color: color-mix(in srgb, var(--down) 45%, var(--border)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--down) 15%, transparent), 0 8px 28px color-mix(in srgb, var(--down) 10%, transparent); }

/* Toasts */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; max-width: 380px; padding: 10px 14px; border-radius: 10px; background: var(--panel); border: 1px solid var(--border-2);
    box-shadow: var(--shadow); font-size: 13px; animation: toast-in .35s cubic-bezier(.2, 1.3, .4, 1) both; }
.toast.out { animation: toast-out .25s ease-in both; }
.toast-ico { color: var(--accent); display: inline-flex; } .toast.good .toast-ico { color: var(--up); } .toast.hot .toast-ico { color: var(--down); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 70; }

/* Animations off: the OS setting or Settings → Animations */
html.no-fx *, html.no-fx *::before, html.no-fx *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
