/* Tickolio — racing green, brass, and figures that line up. */

:root {
  --green: #0f3b2d;
  --green-2: #17513e;
  --green-3: #21684f;
  --on-green: #e8f0eb;
  --on-green-muted: #a9c2b5;
  --paper: #f2f5f1;
  --surface: #ffffff;
  --ink: #18241f;
  --muted: #56665e;
  --line: #d6ddd7;
  --line-strong: #b9c4bc;
  --brass: #d3a43a;
  --brass-deep: #b98a22;
  --up: #12784a;
  --down: #b5382c;
  --up-on-green: #82e4b3;
  --down-on-green: #ffa696;
  --focus: #2a6df4;
  --on-brass: #18241f;
  --brass-hover: #ddb24d;
  --emph: #0f3b2d;
  --tint: #eef3ef;
  --tint-2: #f7f9f7;
  --tint-3: #f4f7f4;
  --section-alt: #e7ede8;
  --code-bg: #e6ebe6;
  --track: #e3e9e4;
  --quiet-hover: #e7ece7;
  --good-bg: #e4efe7;
  --good-line: #c3dcc9;
  --bad-bg: #fbecea;
  --bad-line: #efc5bf;
  --bad-ink: #7d2219;
  --danger-line: #e0b3ad;
  --flash-up: #d7f2e3;
  --flash-down: #f8dcd8;
  --spark-fill: rgba(33, 104, 79, 0.08);
  --shadow-strong: rgba(0, 20, 12, 0.5);
  color-scheme: light;

  --serif: "Young Serif", Georgia, "Times New Roman", serif;
  --sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.5625rem;
  --step-3: 2rem;
  --step-4: 2.75rem;
  --step-5: 3.5rem;

  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
  --wrap: 1120px;
}

/* Dark mode: follows the device unless the visitor picks light or dark (theme.js sets data-theme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --green: #0a2a1f;
    --green-2: #123d2f;
    --green-3: #7ccfa5;
    --paper: #0e1714;
    --surface: #15211c;
    --ink: #e3ebe6;
    --muted: #9aada3;
    --line: #26362f;
    --line-strong: #3b4f46;
    --up: #52d697;
    --down: #ff9282;
    --focus: #79a6ff;
    --emph: #7ccfa5;
    --tint: #1b2a24;
    --tint-2: #18261f;
    --tint-3: #1a2822;
    --section-alt: #111c18;
    --code-bg: #22322b;
    --track: #2a3b33;
    --quiet-hover: #1f2e28;
    --good-bg: #15301f;
    --good-line: #2b5a3c;
    --bad-bg: #3a1a17;
    --bad-line: #6b2e27;
    --bad-ink: #ffb8ad;
    --danger-line: #6b2e27;
    --flash-up: rgba(82, 214, 151, 0.22);
    --flash-down: rgba(255, 146, 130, 0.22);
    --spark-fill: rgba(124, 207, 165, 0.10);
    --shadow-strong: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
}
}
:root[data-theme="dark"] {
  --green: #0a2a1f;
  --green-2: #123d2f;
  --green-3: #7ccfa5;
  --paper: #0e1714;
  --surface: #15211c;
  --ink: #e3ebe6;
  --muted: #9aada3;
  --line: #26362f;
  --line-strong: #3b4f46;
  --up: #52d697;
  --down: #ff9282;
  --focus: #79a6ff;
  --emph: #7ccfa5;
  --tint: #1b2a24;
  --tint-2: #18261f;
  --tint-3: #1a2822;
  --section-alt: #111c18;
  --code-bg: #22322b;
  --track: #2a3b33;
  --quiet-hover: #1f2e28;
  --good-bg: #15301f;
  --good-line: #2b5a3c;
  --bad-bg: #3a1a17;
  --bad-line: #6b2e27;
  --bad-ink: #ffb8ad;
  --danger-line: #6b2e27;
  --flash-up: rgba(82, 214, 151, 0.22);
  --flash-down: rgba(255, 146, 130, 0.22);
  --spark-fill: rgba(124, 207, 165, 0.10);
  --shadow-strong: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  font-feature-settings: "tnum" 1, "lnum" 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img, svg { display: block; max-width: 100%; }
a { color: var(--green-3); text-underline-offset: 0.18em; }
a:hover { color: var(--green); }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: 1.15; margin: 0 0 0.5em; letter-spacing: -0.005em; }
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); }
p { margin: 0 0 1em; }
code { font-size: 0.9em; background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 32px; } }
.narrow { max-width: 640px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
.inline { display: inline; margin: 0; }
.num { text-align: right; }

/* ---- Buttons and forms ------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  font: 600 var(--step-0)/1 var(--sans);
  padding: 0.85em 1.35em;
  border-radius: var(--radius-s);
  border: 1px solid var(--brass-deep);
  background: var(--brass);
  color: var(--on-brass);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--brass-hover); color: var(--on-brass); }
.btn-small { padding: 0.55em 0.95em; font-size: var(--step--1); }
.btn-wide { width: 100%; }
.btn-quiet { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-quiet:hover { background: var(--quiet-hover); }
.btn-danger { background: transparent; border-color: var(--danger-line); color: var(--down); }
.btn-danger:hover { background: var(--bad-bg); color: var(--down); }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 0.18em; }

.form { display: grid; gap: 0.35rem; }
.form label { font-weight: 500; font-size: var(--step--1); margin-top: 0.65rem; }
.form .btn { margin-top: 1.25rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], select {
  font: inherit;
  width: 100%;
  padding: 0.7em 0.8em;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--ink);
}
input:focus-visible, select:focus-visible { outline-offset: 0; }
.hint { color: var(--muted); font-size: var(--step--1); margin: 0; }
.form-error { background: var(--bad-bg); color: var(--bad-ink); border-left: 3px solid var(--down); padding: 0.6em 0.8em; border-radius: 0 var(--radius-s) var(--radius-s) 0; font-size: var(--step--1); }

/* ---- Top bar ---------------------------------------------------------- */
.lock-band { background: var(--brass); color: var(--on-brass); font-size: var(--step--1); text-align: center; padding: 0.45em 16px; }
.lock-band a { color: var(--on-brass); font-weight: 600; }
.topbar { background: var(--green); color: var(--on-green); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 64px; flex-wrap: wrap; }
.wordmark { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--on-green); text-decoration: none; font-family: var(--serif); font-size: 1.45rem; }
.wordmark:hover { color: #fff; }
.logo-mark { width: 26px; height: 26px; color: var(--brass); }
.topnav { display: flex; align-items: center; gap: 1.25rem; font-size: var(--step--1); flex-wrap: wrap; }
.topnav a, .topnav .linkish { color: var(--on-green); text-decoration: none; }
.topnav a:hover, .topnav .linkish:hover { color: #fff; text-decoration: underline; }
.topnav a[aria-current="page"] { text-decoration: underline; text-decoration-color: var(--brass); text-decoration-thickness: 2px; }
.topnav .btn { color: var(--on-brass); text-decoration: none; }

.flashes { padding-top: 1rem; }
.flash { padding: 0.7em 1em; border-radius: var(--radius-s); background: var(--good-bg); border: 1px solid var(--good-line); margin: 0 0 0.5rem; }
.flash-bad { background: var(--bad-bg); border-color: var(--bad-line); }

/* ---- Landing ---------------------------------------------------------- */
.hero { background: var(--green); color: var(--on-green); padding: 3rem 0 4rem; overflow: hidden; }
.hero-in { display: grid; gap: 2.5rem; align-items: center; }
@media (min-width: 900px) {
  .hero { padding: 4.5rem 0 5.5rem; }
  .hero-in { grid-template-columns: 1fr 1.05fr; gap: 4rem; }
}
.hero h1 { font-size: clamp(2.25rem, 5.2vw, var(--step-5)); max-width: 13ch; color: #fff; }
.hero .lede { font-size: var(--step-1); color: var(--on-green-muted); max-width: 34ch; }
.hero-actions { margin-top: 1.75rem; }

.demo { margin: 0; }
.demo figcaption { font-size: var(--step--1); color: var(--on-green-muted); margin-top: 0.75rem; }
.demo-card {
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-l);
  padding: 1.5rem 1.5rem 1rem;
  box-shadow: 0 1px 0 rgba(255,255,255,0.08) inset, 0 24px 48px -24px var(--shadow-strong);
}
.demo-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.demo-label { margin: 0; font-size: var(--step--1); color: var(--muted); }
.demo-live { margin: 0; font-size: var(--step--1); color: var(--up); display: inline-flex; align-items: center; gap: 0.45em; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.demo-total {
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(2.4rem, 7vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0.35rem 0 0.2rem;
  white-space: nowrap;
}
.digit { display: inline-block; transition: color 0.9s ease; }
.digit.tick-up { color: var(--up); transition: none; }
.digit.tick-down { color: var(--down); transition: none; }
.demo-change { margin: 0 0 0.75rem; font-weight: 500; }
.up { color: var(--up); }
.down { color: var(--down); }
.demo-spark { width: 100%; height: 64px; margin-bottom: 0.75rem; }
.spark-line { fill: none; stroke: var(--green-3); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark-fill { fill: var(--spark-fill); stroke: none; }

.demo-rows { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
.demo-rows th { text-align: left; font-weight: 500; color: var(--muted); padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.demo-rows th.num { text-align: right; }
.demo-rows td { padding: 0.5rem 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.demo-rows tr:last-child td { border-bottom: 0; }
.demo-rows .h-name { font-weight: 500; display: block; }
.demo-rows .h-meta { color: var(--muted); font-size: 0.8rem; }
.demo-rows input { width: 5.5rem; padding: 0.35em 0.5em; text-align: right; font-size: var(--step--1); }

.section { padding: 4rem 0; }
.section-alt { background: var(--section-alt); }
.section h2 { max-width: 22ch; }
.steps { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: 2rem; counter-reset: step; }
@media (min-width: 800px) { .steps { grid-template-columns: repeat(3, 1fr); gap: 2.5rem; } }
.steps li { counter-increment: step; border-top: 2px solid var(--emph); padding-top: 1rem; }
.steps li::before { content: counter(step); font-family: var(--serif); font-size: var(--step-2); color: var(--brass-deep); display: block; margin-bottom: 0.4rem; line-height: 1; }
.steps p { color: var(--muted); max-width: 36ch; }

.two-col { display: grid; gap: 2rem; }
@media (min-width: 900px) { .two-col { grid-template-columns: 0.8fr 1.2fr; gap: 4rem; align-items: start; } }
.two-col p { max-width: 42ch; color: var(--muted); }
.freq { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius-m); overflow: hidden; border: 1px solid var(--line); }
.freq th, .freq td { padding: 0.85rem 1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.freq thead th { font-size: var(--step--1); color: var(--muted); font-weight: 500; background: var(--tint-2); }
.freq tbody th { font-weight: 500; width: 42%; }
.freq tbody tr:last-child th, .freq tbody tr:last-child td { border-bottom: 0; }

.closing { max-width: 720px; }
.closing p { color: var(--muted); max-width: 52ch; }

/* ---- Auth -------------------------------------------------------------- */
.auth { padding: 3rem 16px 4rem; display: flex; justify-content: center; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 2rem 1.5rem; }
@media (min-width: 520px) { .auth-card { padding: 2.25rem 2.25rem; } }
.auth-card h1 { font-size: var(--step-3); }
.auth-card .lede { color: var(--muted); }
.auth-alt { margin: 1.25rem 0 0; font-size: var(--step--1); color: var(--muted); }

/* ---- Footer ----------------------------------------------------------- */
.footer { border-top: 1px solid var(--line); padding: 1.5rem 0; font-size: var(--step--1); color: var(--muted); }
.footer-in { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 2rem; }
.footer p { margin: 0; max-width: 70ch; }

/* ---- Installer ---------------------------------------------------------- */
.install { padding-top: 3rem; padding-bottom: 3rem; }
.checklist { list-style: none; padding: 0; }
.checklist li { padding: 0.5rem 0 0.5rem 1.75rem; position: relative; border-bottom: 1px solid var(--line); }
.checklist li::before { position: absolute; left: 0; font-weight: 600; }
.checklist li.good::before { content: "✓"; color: var(--up); }
.checklist li.bad::before { content: "!"; color: var(--down); }

/* ---- Dashboard -------------------------------------------------------- */
.dash { padding-top: 2rem; padding-bottom: 4rem; }
.summary { display: grid; gap: 1.5rem; padding-bottom: 1.75rem; border-bottom: 1px solid var(--line); }
@media (min-width: 900px) { .summary { grid-template-columns: 1.1fr 1fr; align-items: end; gap: 3rem; } }
.summary-label { color: var(--muted); font-size: var(--step--1); margin: 0; }
.total {
  font-weight: 500;
  font-size: clamp(2.6rem, 8vw, 4.25rem);
  line-height: 1;
  letter-spacing: -0.035em;
  margin: 0.35rem 0 0.75rem;
  white-space: nowrap;
}
.figures { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; margin: 0; }
.figures div { margin: 0; }
.figures dt { color: var(--muted); font-size: var(--step--1); }
.figures dd { margin: 0; font-weight: 500; font-size: var(--step-1); }
.chart-box { min-width: 0; }
.chart { width: 100%; height: 120px; }
.chart .spark-line { stroke-width: 2.25; }
.chart-note { display: flex; justify-content: space-between; gap: 1rem; font-size: var(--step--1); color: var(--muted); margin: 0.4rem 0 0; flex-wrap: wrap; }
.status { display: inline-flex; align-items: center; gap: 0.45em; }
.status .pulse { color: var(--up); }
.status.is-error .pulse { color: var(--down); animation: none; }

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: 2rem 0 0.75rem; flex-wrap: wrap; }
.section-head h2 { font-size: var(--step-2); margin: 0; }
.muted-note { color: var(--muted); font-size: var(--step-0) !important; font-weight: 400 !important; }
.optional { color: var(--muted); font-weight: 400; }

/* Pots: each card is a filter button for the holdings table. */
.pots { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.75rem; }
@media (max-width: 699px) {
  .pots { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 72%; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 0.4rem; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
  .pot-card { scroll-snap-align: start; }
}
.pot-card {
  display: grid; gap: 0.1rem; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  padding: 0.9rem 1rem 1rem; position: relative;
}
.pot-card:hover { border-color: var(--line-strong); }
.pot-card[aria-pressed="true"] { border-color: var(--emph); box-shadow: inset 0 0 0 1px var(--emph); }
.pot-name { font-family: var(--serif); font-size: var(--step-1); line-height: 1.2; }
.pot-type { color: var(--muted); font-size: 0.8125rem; margin-bottom: 0.45rem; }
.pot-value { font-weight: 600; font-size: var(--step-1); letter-spacing: -0.01em; }
.pot-change { font-size: var(--step--1); }
.pot-share { display: block; height: 4px; background: var(--track); border-radius: 2px; margin-top: 0.6rem; overflow: hidden; }
.pot-share span { display: block; height: 100%; background: var(--brass); }

.holdings tr.pot-row th, .holdings tr.pot-row td { background: var(--tint); border-bottom: 1px solid var(--line); padding-top: 0.65rem; padding-bottom: 0.65rem; }
.pot-row-name { font-family: var(--serif); font-size: var(--step-1); font-weight: 400; margin-right: 0.6rem; }
.pot-row-type { color: var(--muted); font-size: 0.8125rem; font-weight: 400; }
.pot-row-value { font-weight: 600; }
.pot-empty td { color: var(--muted); font-size: var(--step--1); }
.pot-order { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }
.pot-order .hint { margin-right: auto; }
.new-pot-fields { background: var(--tint-3); border-radius: var(--radius-s); padding: 0.25rem 0.75rem 0.75rem; margin-top: 0.5rem; }
.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.holdings { width: 100%; border-collapse: collapse; min-width: 760px; }
.holdings th, .holdings td { padding: 0.8rem 1rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.holdings thead th { font-weight: 500; font-size: var(--step--1); color: var(--muted); background: var(--tint-2); white-space: nowrap; }
.holdings th.num, .holdings td.num { text-align: right; white-space: nowrap; }
.holdings tbody tr:last-child td { border-bottom: 0; }
.holdings tfoot td { font-weight: 600; border-top: 1px solid var(--line-strong); border-bottom: 0; }
.h-name { font-weight: 500; }
.h-meta { display: block; color: var(--muted); font-size: 0.8125rem; }
.h-closed { display: block; color: var(--muted); font-size: 0.8125rem; }
.flat { color: var(--muted); }
.row-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }
.row-actions button { font-size: var(--step--1); }
.cell-flash-up { animation: flash-up 1.2s ease-out; }
.cell-flash-down { animation: flash-down 1.2s ease-out; }
@keyframes flash-up { from { background: var(--flash-up); } to { background: transparent; } }
@keyframes flash-down { from { background: var(--flash-down); } to { background: transparent; } }

@media (max-width: 699px) {
  .table-scroll { overflow: visible; }
  .holdings { min-width: 0; }
  .holdings thead { display: none; }
  .holdings tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "name value" "units today" "price gain" "act act";
    gap: 0.2rem 1rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--line);
  }
  .holdings tbody tr:last-child { border-bottom: 0; }
  .holdings tbody td { padding: 0; border: 0; font-size: var(--step--1); }
  .holdings td.c-name { grid-area: name; font-size: var(--step-0); }
  .holdings td.c-value { grid-area: value; font-size: var(--step-0); font-weight: 600; }
  .holdings td.c-units { grid-area: units; text-align: left; }
  .holdings td.c-price { grid-area: price; text-align: left; }
  .holdings td.c-today { grid-area: today; }
  .holdings td.c-gain { grid-area: gain; }
  .holdings td.c-act { grid-area: act; text-align: left; padding-top: 0.4rem; }
  .holdings td[data-label]::before { content: attr(data-label) " "; color: var(--muted); }
  .holdings tbody tr.pot-row { grid-template-areas: "name value" "name gain" "name act"; background: var(--tint); }
  .holdings tr.pot-row th { grid-area: name; background: none; padding: 0; border: 0; }
  .holdings tr.pot-row td { background: none; padding: 0; border: 0; }
  .holdings tr.pot-row td:nth-of-type(1) { grid-area: value; }
  .holdings tr.pot-row td:nth-of-type(2) { grid-area: gain; }
  .holdings tr.pot-row td:nth-of-type(3) { grid-area: act; }
  .holdings tr.pot-row .pot-row-type { display: block; }
  .holdings tbody tr.pot-empty { display: block; }
  .holdings td.c-gain:empty, .holdings td.c-today:empty { display: none; }
}

.empty { background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius-m); padding: 2.5rem 1.5rem; text-align: center; }
.empty h2 { font-size: var(--step-2); }
.empty p { color: var(--muted); max-width: 46ch; margin: 0 auto 1.25rem; }

/* Dialog */
dialog {
  border: 0; border-radius: var(--radius-l); padding: 0; width: min(560px, calc(100vw - 32px));
  color: var(--ink); background: var(--surface); box-shadow: 0 30px 60px -20px var(--shadow-strong);
}
dialog::backdrop { background: rgba(10, 30, 22, 0.55); }
.dlg { padding: 1.5rem; }
@media (min-width: 520px) { .dlg { padding: 1.75rem 2rem; } }
.dlg h2 { font-size: var(--step-2); }
.dlg-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; flex-wrap: wrap; }
.results { list-style: none; margin: 0.5rem 0 0; padding: 0; max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-s); }
.results:empty { display: none; }
.results li + li { border-top: 1px solid var(--line); }
.results button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 0.65rem 0.8rem; font: inherit; cursor: pointer; color: inherit; }
.results button:hover, .results button:focus-visible { background: var(--tint); }
.results .r-sym { font-weight: 600; }
.results .r-meta { color: var(--muted); font-size: 0.8125rem; display: block; }
.results .r-none { padding: 0.65rem 0.8rem; color: var(--muted); }
.picked { background: var(--tint); border-radius: var(--radius-s); padding: 0.7rem 0.9rem; margin-top: 0.5rem; display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.picked p { margin: 0; }
.field-row { display: grid; gap: 0.35rem 1rem; }
@media (min-width: 520px) { .field-row { grid-template-columns: 1fr 1fr; } }
.field-row > div { display: grid; gap: 0.35rem; }

/* ---- Theme toggle ------------------------------------------------------ */
.theme-toggle { background: none; border: 1px solid rgba(232, 240, 235, 0.25); color: var(--on-green); width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer; padding: 0; }
.theme-toggle:hover { border-color: var(--on-green); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle[aria-pressed="true"] .icon-sun { display: block; }
.theme-toggle[aria-pressed="true"] .icon-moon { display: none; }

/* ---- Adding and editing holdings -------------------------------------- */
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line-strong); border-radius: var(--radius-s); overflow: hidden; margin-bottom: 1.25rem; }
.seg-opt { position: relative; text-align: center; cursor: pointer; font-weight: 500; font-size: var(--step--1); }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt span { display: block; padding: 0.65rem 0.5rem; }
.seg-opt + .seg-opt span { border-left: 1px solid var(--line-strong); }
.seg-opt input:checked + span { background: var(--emph); color: var(--surface); }
.seg-opt input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }

.more-btn { display: inline-flex; align-items: center; gap: 0.4rem; background: none; border: 0; padding: 0.35rem 0; margin-top: 0.75rem; font: 500 var(--step--1)/1.3 var(--sans); color: var(--green-3); cursor: pointer; text-decoration: underline; text-underline-offset: 0.18em; }
.more-btn::before { content: "+"; display: inline-grid; place-items: center; width: 1.15rem; height: 1.15rem; border: 1px solid currentColor; border-radius: 50%; font-size: 0.85rem; line-height: 1; text-decoration: none; }
.more-btn[aria-expanded="true"]::before { content: "−"; }
.lots-box { background: var(--tint-3); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 0.85rem; margin-top: 0.5rem; }
.lots-box .hint { margin-bottom: 0.6rem; }
.lots { display: grid; gap: 0.6rem; margin-bottom: 0.75rem; }
.lot { display: grid; grid-template-columns: 6.5rem 9.5rem 1fr 1fr 1fr 2rem; gap: 0.5rem; align-items: end; padding-bottom: 0.6rem; border-bottom: 1px solid var(--line); }
.lot-field { display: grid; gap: 0.2rem; min-width: 0; }
.lot-field label { font-size: 0.75rem; font-weight: 500; color: var(--muted); }
.lot-field input, .lot-field select { padding: 0.45em 0.5em; font-size: var(--step--1); }
.lot-remove { background: none; border: 1px solid var(--line-strong); border-radius: var(--radius-s); color: var(--muted); height: 2.1rem; cursor: pointer; font-size: 1.1rem; line-height: 1; }
.lot-remove:hover { color: var(--down); border-color: var(--danger-line); }
@media (max-width: 599px) {
  .lot { grid-template-columns: 1fr 1fr; }
  .lot-remove { grid-column: 2; justify-self: end; width: 2.4rem; }
}
.lots-sum { margin: 0.6rem 0 0; font-size: var(--step--1); font-weight: 500; }
.derived { background: var(--tint); border-radius: var(--radius-s); padding: 0.7rem 0.9rem; margin: 0.75rem 0 0; font-size: var(--step--1); }
.paid-in { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 0.4rem 0.9rem 0.9rem; margin: 1rem 0 0; min-width: 0; }
.paid-in legend { font-weight: 500; font-size: var(--step--1); padding: 0 0.3rem; }
@media (min-width: 520px) { .field-row.three { grid-template-columns: 1fr 1fr 1fr; } }
.sub { font-family: var(--sans); font-size: var(--step--1); font-weight: 600; margin: 1rem 0 0.5rem; }
.history { width: 100%; border-collapse: collapse; font-size: var(--step--1); margin-bottom: 0.25rem; }
.history th, .history td { padding: 0.45rem 0.4rem; border-bottom: 1px solid var(--line); text-align: left; }
.history th { color: var(--muted); font-weight: 500; }
.history .num { text-align: right; white-space: nowrap; }
.valuations { list-style: none; margin: 0; padding: 0; font-size: var(--step--1); }
.valuations li { display: flex; justify-content: space-between; padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
dialog { max-height: calc(100vh - 32px); overflow-y: auto; }
@media (min-width: 720px) { dialog#add-dialog, dialog#edit-dialog { width: min(720px, calc(100vw - 32px)); } }

/* ---- Account and admin -------------------------------------------------- */
.page { padding-top: 2rem; padding-bottom: 4rem; }
.page h1 { font-size: var(--step-3); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1.5rem; margin-bottom: 1.5rem; max-width: 640px; }
.panel h2 { font-size: var(--step-1); }
.panel-wide { max-width: none; }
.plain-table { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
.plain-table th, .plain-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); text-align: left; }
.plain-table th { color: var(--muted); font-weight: 500; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
.toggle-row:last-child { border-bottom: 0; }
.toggle-row p { margin: 0; }
.toggle-row .state { font-weight: 600; }
.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 400 !important; font-size: var(--step-0) !important; margin-top: 0.9rem !important; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--emph); }
.new-account { background: var(--good-bg); border: 1px solid var(--good-line); border-radius: var(--radius-s); padding: 1rem; margin-bottom: 1.25rem; }
.new-account .plain-table { margin: 0.5rem 0; }
.secret { font-size: 1rem; user-select: all; }
.test-out { background: var(--tint-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 0.75rem; font-size: var(--step--1); white-space: pre-wrap; overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
