:root {
  /* Yours Car Rental, as in the accounting app: red #e1423e, ink #131313, greys, Manrope */
  color-scheme: light;
  --page: #f5f5f5; --surface: #ffffff; --ink: #131313; --ink2: #606161; --muted: #8a8a89;
  --grid: #efefee; --axis: #e3e3e2; --border: #e3e3e2; --line: #e3e3e2;
  --brand: #e1423e; --brand-soft: #fdeceb; --primary: #131313; --on-primary: #ffffff; --header: #131313;
  --s1: #2a78d6; --s2: #606161; --s3: #198754; --s4: #9a6200; --im: #0e7490; --newrate: #c27c00;
  --neutral: #f5f5f5; --div-cool: #2a78d6; --div-warm: #e1423e;
  --good: #198754; --good-text: #198754; --ok-soft: #e3f4ea; --warn: #9a6200; --warn-soft: #fff4d6; --crit: #b4231f; --danger-soft: #fde8e7;
  --band: rgba(96,97,97,0.16); --q: rgba(96,97,97,0.36);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0f0f0f; --surface: #1a1a1a; --ink: #f0efec; --ink2: #a3a3a0; --muted: #7d7d7a;
    --grid: #242423; --axis: #2d2d2c; --border: #2d2d2c; --line: #2d2d2c;
    --brand: #ee5a56; --brand-soft: #3a1817; --primary: #f0efec; --on-primary: #131313; --header: #0a0a0a;
    --s1: #3987e5; --s2: #a3a3a0; --s3: #5fd69a; --s4: #f5c451; --im: #67e8f9; --newrate: #f5c451;
    --neutral: #242423; --div-cool: #3987e5; --div-warm: #ee5a56;
    --good: #5fd69a; --good-text: #5fd69a; --ok-soft: #10291c; --warn: #f5c451; --warn-soft: #33270b; --crit: #ff8a85; --danger-soft: #3a1414;
    --band: rgba(163,163,160,0.16); --q: rgba(163,163,160,0.40);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0f0f0f; --surface: #1a1a1a; --ink: #f0efec; --ink2: #a3a3a0; --muted: #7d7d7a;
  --grid: #242423; --axis: #2d2d2c; --border: #2d2d2c; --line: #2d2d2c;
  --brand: #ee5a56; --brand-soft: #3a1817; --primary: #f0efec; --on-primary: #131313; --header: #0a0a0a;
  --s1: #3987e5; --s2: #a3a3a0; --s3: #5fd69a; --s4: #f5c451; --im: #67e8f9; --newrate: #f5c451;
  --neutral: #242423; --div-cool: #3987e5; --div-warm: #ee5a56;
  --good: #5fd69a; --good-text: #5fd69a; --ok-soft: #10291c; --warn: #f5c451; --warn-soft: #33270b; --crit: #ff8a85; --danger-soft: #3a1414;
  --band: rgba(163,163,160,0.16); --q: rgba(163,163,160,0.40);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.45 Manrope, system-ui, -apple-system, "Segoe UI", sans-serif; }
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 650; font-size: 16px; }
nav { display: flex; flex-wrap: wrap; gap: 2px; }
nav button { border: 0; background: none; color: var(--ink2); padding: 6px 10px; border-radius: 6px; cursor: pointer; font: inherit; }
nav button:hover { background: var(--neutral); }
nav button.on { color: var(--ink); background: var(--neutral); font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: end; padding: 10px 16px; border-bottom: 1px solid var(--border); }
label { display: inline-flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--ink2); }
.row label, label:has(input[type=checkbox]) { flex-direction: row; align-items: center; gap: 6px; }
select, input { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; min-width: 7em; }
input[type=checkbox] { min-width: 0; }
main { padding: 16px; max-width: 1400px; margin: 0 auto; }
.tab { display: none; } .tab.on { display: block; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; min-width: 0; }
.card h3 { margin: 0 0 2px; font-size: 15px; }
.sub { color: var(--ink2); font-size: 12px; margin: 0 0 10px; white-space: pre-wrap; }
.muted { color: var(--muted); font-weight: 400; font-size: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 0 16px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.tile .k { font-size: 12px; color: var(--ink2); }
.tile .v { font-size: 26px; font-weight: 600; margin-top: 2px; }
.tile .d { font-size: 12px; color: var(--ink2); }
.up { color: var(--good-text); } .down { color: var(--crit); }
.chartbox { position: relative; height: 260px; } .chartbox.tall { height: 360px; }
.scrollx { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; font-size: 13px; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--ink2); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: var(--surface); }
td.n, th.n { text-align: right; }
td.why { white-space: normal; min-width: 260px; color: var(--ink2); font-size: 12px; }
table.heat td.c { text-align: center; color: #0b0b0b; border: 2px solid var(--surface); border-radius: 4px; min-width: 76px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--neutral); }
.pill.raise::before { content: "▲ "; color: var(--good-text); } .pill.lower::before { content: "▼ "; color: var(--crit); } .pill.hold::before { content: "■ "; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 10px; }
.btn { display: inline-block; font: inherit; border: 1px solid var(--border); background: var(--neutral); color: var(--ink); border-radius: 6px; padding: 5px 12px; cursor: pointer; text-decoration: none; }
.btn.sm { padding: 1px 8px; font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.stack label { width: 100%; } .stack input:not([type=file]), .stack select { width: 100%; max-width: 420px; }
.empty { color: var(--muted); padding: 20px 0; }
.tip { position: fixed; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.12); z-index: 10; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink2); margin: 4px 0 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 18px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }
.spread { justify-content: space-between; align-items: flex-start; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--ink2); padding: 4px 12px; font: inherit; cursor: pointer; }
.seg button.on { background: var(--neutral); color: var(--ink); font-weight: 600; }
.btn.primary { background: var(--s1); color: #fff; border-color: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
.filebtn { flex-direction: row; font-size: 14px; color: var(--ink); }
.bar { height: 8px; background: var(--neutral); border-radius: 4px; overflow: hidden; margin: 6px 0 10px; }
.bar > div { height: 100%; background: var(--s1); width: 0; transition: width .4s; }
.log { background: var(--page); border: 1px solid var(--border); border-radius: 6px; padding: 8px; font-size: 12px; max-height: 220px; overflow: auto; margin: 0; white-space: pre-wrap; }
.locpick { display: flex; flex-wrap: wrap; gap: 4px 14px; max-width: 100%; }
.locpick .ctry { width: 100%; font-size: 12px; font-weight: 600; color: var(--ink2); margin-top: 6px; }
.locpick label { flex-direction: row; align-items: center; gap: 4px; font-size: 13px; color: var(--ink); }
.tallscroll { max-height: 520px; overflow: auto; }
td input { min-width: 0; width: 6em; padding: 2px 4px; }
.status-ok { color: var(--good-text); } .status-aborted, .status-failed { color: var(--crit); } .status-running { color: var(--s1); } .status-stopped { color: var(--muted); }
.tag { display: inline-block; padding: 0 6px; border-radius: 8px; font-size: 11px; background: var(--neutral); color: var(--ink2); }
.tag.own { background: var(--s1); color: #fff; }
@media (max-width: 520px) { main { padding: 12px 16px; } .row input { max-width: 100%; } }
.chartbox.xtall { height: 600px; }
#tab-market .chartbox:not(.xtall) { height: 340px; }
#tab-market .tile .v { font-size: 28px; }
table.matrix { font-size: 14px; }
table.matrix td, table.matrix th { padding: 6px 10px; }
.chip { font-size: 13px; padding: 4px 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--ink2); border-radius: 12px; padding: 2px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.chip.on { color: #fff; border-color: transparent; }
.chip .p { opacity: .75; margin-left: 4px; }
table.matrix td.n { min-width: 54px; }
table.matrix tr.mine td { font-weight: 600; border-bottom: 2px solid var(--axis); }
table.matrix td.cheaper { background: rgba(227, 73, 72, .18); }
table.matrix td.dearer { background: rgba(12, 163, 12, .12); }
table.matrix td.best { font-weight: 700; outline: 1px solid var(--ink2); outline-offset: -2px; }
table.matrix th.n { text-align: right; }
table.matrix td.vname { position: sticky; left: 0; background: var(--surface); }
body.loading main { opacity: .45; transition: opacity .15s; pointer-events: none; }
body.loading .filters::after { content: "updating…"; color: var(--s1); font-size: 12px; align-self: center; }
.mk-more { margin-top: 10px; } .mk-more summary { cursor: pointer; color: var(--ink2); font-size: 13px; }
#mk-legend i.candle { width: 8px; height: 16px; border-radius: 2px; }
table.matrix thead { position: sticky; top: 0; z-index: 2; }
table.matrix thead th { background: var(--surface); position: static; }
table.matrix thead th.vname { position: sticky; left: 0; z-index: 3; }
table.matrix thead tr.mine th { font-weight: 600; color: var(--ink); }
table.matrix thead tr:last-child th { border-bottom: 2px solid var(--axis); }
table.matrix tr.inline-own td { font-weight: 700; background: color-mix(in srgb, var(--oc) 16%, var(--surface)); }
table.matrix tr.inline-own td.vname { box-shadow: inset 4px 0 var(--oc); background: color-mix(in srgb, var(--oc) 16%, var(--surface)); }
table.matrix td.vname { white-space: nowrap; }
/* sticky header block: separate borders, or collapsed borders scroll away and leave gaps */
table.matrix { border-collapse: separate; border-spacing: 0; }
table.matrix thead th { border-bottom: 1px solid var(--grid); }
table.matrix thead tr:last-child th { border-bottom: 2px solid var(--axis); }
table.matrix tfoot { position: sticky; bottom: 0; z-index: 2; }
table.matrix tfoot td { background: color-mix(in srgb, var(--s3) 18%, var(--surface)); font-weight: 700; border-top: 2px solid var(--s3); }
table.matrix tfoot td.vname { position: sticky; left: 0; z-index: 3; box-shadow: inset 4px 0 var(--s3); }
table.matrix tfoot .rk { display: block; font-size: 11px; font-weight: 500; color: var(--ink2); }
table.matrix tr.inline-own .rk { display: block; font-size: 11px; font-weight: 500; color: var(--ink2); }
/* market chart hover panel */
.mk-tip { position: absolute; z-index: 20; pointer-events: none; opacity: 0; transition: opacity .12s; min-width: 300px; max-width: 420px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25);
  padding: 10px 12px; font-size: 12.5px; }
.mk-tip .tt-title { font-weight: 800; font-size: 14px; margin-bottom: 6px; }
.mk-tip .tt-sum { display: grid; grid-template-columns: 44px 70px 74px 1fr; gap: 6px; align-items: center; padding: 4px 8px; margin-bottom: 3px;
  border-radius: 6px; background: color-mix(in srgb, var(--c) 18%, transparent); border-left: 4px solid var(--c); font-variant-numeric: tabular-nums; }
.mk-tip .tt-sum b { color: var(--c); }
.mk-tip .tt-sub { color: var(--ink2); margin: 6px 0 4px; }
.mk-tip table.tt-list { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.mk-tip .tt-list td { padding: 2px 6px; border-bottom: none; white-space: nowrap; }
.mk-tip .tt-list td:nth-child(1) { color: var(--muted); width: 24px; text-align: right; }
.mk-tip .tt-list td:nth-child(2) { text-align: right; width: 64px; }
.mk-tip .tt-list tr.cheaper td { background: rgba(227, 73, 72, .16); }
.mk-tip .tt-list tr.dearer td { background: rgba(12, 163, 12, .11); }
.mk-tip .tt-list tr.own td { font-weight: 800; background: color-mix(in srgb, var(--c) 22%, transparent); }
.mk-tip .tt-list tr.own td:first-child { box-shadow: inset 3px 0 var(--c); }
.mk-tip .tt-list td.tag { color: var(--c); font-weight: 800; text-align: right; }

/* ---------- app shell and components, as in the accounting app ---------- */
body { font: 14px/1.5 Manrope, ui-sans-serif, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
.top { background: var(--header); color: #fff; border-bottom: 0; padding: 0; position: sticky; top: 0; z-index: 10; display: block; }
.top-inner { max-width: 1400px; margin: 0 auto; padding: 0 16px; min-height: 56px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; margin-right: 12px; font-weight: 600; font-size: 14px; color: #fff; text-decoration: none; }
.brand img { height: 36px; width: auto; display: block; }
.brand .app { border-left: 1px solid rgba(255,255,255,.2); padding-left: 12px; white-space: nowrap; }
.top .asof { margin-left: auto; font-size: 12px; color: rgba(255,255,255,.6); }
nav { gap: 0; }
nav button { color: rgba(255,255,255,.65); background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  padding: 17px 9px 15px; font: 600 13.5px Manrope, sans-serif; white-space: nowrap; }
nav button:hover { color: #fff; background: none; }
nav button.on { color: #fff; border-bottom-color: #e1423e; background: none; font-weight: 600; box-shadow: none; }
.filters { max-width: 1400px; margin: 0 auto; border-bottom: 0; padding: 16px 16px 0; }
main { max-width: 1400px; padding: 16px 16px 32px; }
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 20px; }
.pagehead h1 { margin: 0; font-size: 20px; font-weight: 600; }
.pagehead p { margin: 2px 0 0; font-size: 14px; color: var(--ink2); }
.card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 16px; margin-bottom: 16px; }
.card h3 { font-size: 15px; font-weight: 600; margin: 0 0 2px; }
.cardhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.cardhead a, a.more { color: var(--brand); font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.cardhead a:hover, a.more:hover { text-decoration: underline; }
.sub { color: var(--ink2); }
.tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
@media (max-width: 1000px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 16px; }
.tile .k { font-size: 12px; font-weight: 500; color: var(--ink2); }
.tile .v { margin-top: 4px; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.tile .d { margin-top: 2px; font-size: 12px; color: var(--ink2); }
.tile.danger .v { color: var(--crit); }
.up { color: var(--good-text); } .down { color: var(--crit); }
th { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink2); border-bottom: 1px solid var(--line); padding: 8px 12px; }
td { border-bottom: 1px solid var(--line); padding: 8px 12px; }
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 6px 12px; font: 500 14px Manrope, sans-serif; }
.btn:hover { background: var(--page); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: var(--brand); color: #fff; }
select, input { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--surface); font-family: Manrope, sans-serif; }
input:focus, select:focus { outline: none; border-color: var(--ink); }
label { font-size: 12px; font-weight: 500; color: var(--ink2); }
.seg { border-radius: 8px; border: 1px solid var(--line); }
.seg button { font-weight: 600; }
.seg button.on { background: var(--primary); color: var(--on-primary); }
.pill { border-radius: 999px; font-weight: 500; }
.tag { border-radius: 999px; }
a { color: var(--brand); }
@media (max-width: 1100px) { nav button { padding: 12px 8px; } }
.top-inner { padding: 6px 16px; }
@media (max-width: 1100px) { .top .asof { display: none; } }
.vs-h { margin: 14px 0 6px; font-size: 13px; font-weight: 700; padding-left: 8px; border-left: 4px solid var(--oc); }
table.matrix.vs tr.inline-own td { font-weight: 700; }

/* ---------- login */
body.locked > *:not(#login):not(script) { visibility: hidden; }
#login { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; background: var(--page); padding: 16px; }
#login[hidden] { display: none; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: grid; gap: 12px; }
.login-card h2 { margin: 0; font-size: 20px; }
.login-card .sub { margin: 0 0 4px; color: var(--ink2); }
.login-card label { display: grid; gap: 4px; font-size: 13px; color: var(--ink2); }
.login-card input { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.login-card .btn { justify-content: center; margin-top: 4px; }
.login-logo { height: 28px; width: auto; justify-self: start; }
.login-msg { margin: 0; min-height: 1.2em; font-size: 13px; color: var(--brand); }
#whoami { margin-left: 16px; display: flex; align-items: center; gap: 8px; font-size: 12px; color: #bdbdbd; white-space: nowrap; }
#whoami .linkbtn { background: none; border: 0; color: #fff; font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }
