:root {
  color-scheme: light;
  --bg: #f4f3f0;
  --surface: #fcfcfb;
  --border: #e4e2dc;
  --grid: #ecebe7;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #75746f;
  --accent: #2a78d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #006300;
  --bad: #c42f2f;
  --good-bg: #e6f2e6;
  --bad-bg: #fbeaea;
  --warn-bg: #fff4dc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --border: #2c2c2a;
    --grid: #262624;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --text-3: #9a998f;
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --good: #3cc23c;
    --bad: #e66767;
    --good-bg: #16301a;
    --bad-bg: #3a1c1c;
    --warn-bg: #3a2f14;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums;
}
.wrap { max-width: 1040px; margin: 0 auto; padding: 24px 16px 48px; }

header.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
header.top h1 { font-size: 22px; line-height: 1.2; margin: 0 0 2px; letter-spacing: -.01em; }
.meta { color: var(--text-3); font-size: 13px; }
.actions { display: flex; gap: 8px; flex-shrink: 0; }
.actions form { margin: 0; }

button, .btn {
  font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 7px 12px; cursor: pointer; line-height: 1.2;
}
button:hover { border-color: var(--text-3); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button[disabled] { opacity: .55; cursor: default; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card h2 { font-size: 15px; margin: 0; font-weight: 600; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

.hero { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: 0; padding: 0; }
.stat { padding: 18px 20px; border-left: 1px solid var(--border); min-width: 0; }
.stat:first-child { border-left: 0; }
.stat .label { color: var(--text-2); font-size: 13px; margin-bottom: 4px; }
.stat .value { font-size: 24px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.stat.main .value { font-size: 32px; }
.stat .sub { font-size: 13px; color: var(--text-3); margin-top: 2px; }

.delta { font-weight: 600; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.pill { display: inline-block; font-size: 13px; font-weight: 600; padding: 2px 8px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }
.pill.up { background: var(--good-bg); color: var(--good); }
.pill.down { background: var(--bad-bg); color: var(--bad); }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 6px 11px; font-size: 13px; background: transparent; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--surface); }

.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.sw.s1 { background: var(--series-1); }
.sw.s2 { background: var(--series-2); }

.chart { position: relative; height: 300px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .axis text { fill: var(--text-3); font-size: 11px; }
.chart .l1 { stroke: var(--series-1); }
.chart .l2 { stroke: var(--series-2); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--series-1); opacity: .08; }
.chart .endlabel { font-size: 12px; fill: var(--text-2); font-weight: 600; }
.chart .xhair { stroke: var(--text-3); stroke-width: 1; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .dot.d1 { fill: var(--series-1); }
.chart .dot.d2 { fill: var(--series-2); }
.tip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,.12);
  min-width: 170px; transform: translateY(-50%);
}
.tip .d { color: var(--text-3); margin-bottom: 4px; }
.tip .r { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.tip .r .k { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.tip hr { border: 0; border-top: 1px solid var(--border); margin: 5px 0; }
.empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-3); }

.tbl-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
thead th { font-size: 12px; font-weight: 500; color: var(--text-3); border-bottom: 1px solid var(--border); }
tbody td { border-bottom: 1px solid var(--grid); }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { border-top: 1px solid var(--border); font-weight: 600; }
.coin { font-weight: 600; }
.muted { color: var(--text-3); }

.note { font-size: 13px; color: var(--text-2); }
.note p { margin: 0 0 6px; }
.warn { background: var(--warn-bg); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 16px; }
.error { background: var(--bad-bg); color: var(--text); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; }
.loading { color: var(--text-3); padding: 40px 0; text-align: center; }
[hidden] { display: none !important; }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; padding: 28px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login p { color: var(--text-2); margin: 0 0 18px; font-size: 14px; }
.login label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.login input {
  width: 100%; font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); margin-bottom: 14px;
}
.login button { width: 100%; background: var(--text); color: var(--surface); border-color: var(--text); padding: 10px; font-weight: 600; }
.login .msg { font-size: 13px; color: var(--bad); margin: -4px 0 12px; }
.login .msg.ok { color: var(--good); }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr 1fr; }
  .stat.main { grid-column: 1 / -1; }
  .stat:nth-child(2) { border-left: 0; }
  .stat:nth-child(n+2) { border-top: 1px solid var(--border); }
  .stat:nth-child(4) { grid-column: 1 / -1; border-left: 0; }
  .stat .value { font-size: 20px; }
  .stat.main .value { font-size: 28px; }
  .chart { height: 240px; }
  header.top { flex-direction: column; }
}
@media (max-width: 600px) {
  table.coins th:nth-child(2), table.coins td:nth-child(2), table.coins th:nth-child(3), table.coins td:nth-child(3), table.coins th:nth-child(4), table.coins td:nth-child(4) { display: none; }
  td .muted { display: block; font-size: 12px; }
}

/* ---------------------------------------------------------------- navigatie */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-in { max-width: 1040px; margin: 0 auto; padding: 0 16px; height: 56px; display: flex; align-items: center; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand img { border-radius: 6px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: var(--text-2); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 14px; }
.nav a:hover { color: var(--text); background: var(--bg); }
.nav a[aria-current="page"] { color: var(--text); background: var(--bg); font-weight: 600; }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; white-space: nowrap; }
.who form { margin: 0; }
button.link { border: 0; background: none; padding: 4px 0; color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; }
button.link:hover { color: var(--text); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 20px; }
.page-head h1 { font-size: 22px; line-height: 1.2; margin: 0 0 2px; letter-spacing: -.01em; }
.wrap.narrow { max-width: 680px; }

/* ---------------------------------------------------------------- formulieren */
.card > h2 { margin-bottom: 12px; }
.card > p { margin: 0 0 12px; }
.form { display: grid; gap: 12px; }
.field { display: grid; gap: 5px; }
.field span { font-size: 13px; color: var(--text-2); }
.field em { font-style: normal; color: var(--text-3); }
input[type=text], input[type=password] {
  width: 100%; font: inherit; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.form-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.form.inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.form.inline .field { width: 280px; max-width: 100%; }
.form.inline .notice { flex-basis: 100%; }
.card > p.muted { font-size: 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; padding-bottom: 9px; }
button.primary, .btn.primary { background: var(--text); color: var(--surface); border-color: var(--text); font-weight: 600; }
button.primary:hover { opacity: .9; }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; font-weight: 600; }
button.danger-link { border: 0; background: none; color: var(--bad); padding: 7px 4px; text-decoration: underline; text-underline-offset: 3px; }
button.armed { outline: 2px solid var(--bad); outline-offset: 1px; }
.btn { display: inline-block; text-decoration: none; }
.notice { font-size: 14px; border-radius: 10px; padding: 9px 12px; background: var(--bg); }
.notice.ok { background: var(--good-bg); color: var(--good); }
.notice.error { background: var(--bad-bg); color: var(--bad); }
.status-line { font-size: 14px; color: var(--text-2); margin-bottom: 12px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--text-2); border: 1px solid var(--border); margin-left: 6px; vertical-align: 1px; }
.status-line .badge, td .badge:first-child { margin-left: 0; }
.badge.ok { background: var(--good-bg); color: var(--good); border-color: transparent; }
details.howto { background: var(--bg); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px; }
details.howto summary { cursor: pointer; font-weight: 600; }
details.howto ol { padding-left: 20px; margin: 10px 0 8px; }
details.howto li { margin-bottom: 4px; }
details.howto p { margin: 0; font-size: 13px; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.empty-state { text-align: center; padding: 36px 24px; }
.empty-state p { color: var(--text-2); max-width: 460px; margin: 8px auto 18px; }
.empty-state .btn { padding: 9px 16px; border-radius: 10px; }

/* ---------------------------------------------------------------- beheer */
table.users td, table.users th { text-align: left; }
table.users td:last-child, table.users th:last-child { text-align: right; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
table.users td:last-child { width: 1%; }
.row-actions button { font-size: 13px; padding: 5px 9px; }
.row-actions a { font-size: 13px; color: var(--text-2); }
.secret-box { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; background: var(--warn-bg); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px; }
.secret-box .label { font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
.secret-box code { font-size: 22px; font-weight: 700; letter-spacing: .04em; user-select: all; }
.secret-box p { margin: 6px 0 0; font-size: 13px; max-width: 620px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (max-width: 760px) {
  .topbar-in { gap: 12px; }
  .brand span, .who .muted { display: none; }
  .form.inline .field { width: 100%; }
  .row-actions { flex-wrap: wrap; }
  table.users td:last-child { width: auto; }
  .check { padding-bottom: 0; }
}
@media (max-width: 480px) {
  .brand { font-size: 0; gap: 0; }
  .nav a { padding: 6px 8px; }
}
@media (max-width: 600px) {
  table.users thead { display: none; }
  table.users, table.users tbody, table.users tr, table.users td { display: block; width: auto !important; }
  table.users tr { padding: 12px 0; border-bottom: 1px solid var(--grid); }
  table.users tr:last-child { border-bottom: 0; }
  table.users td { border: 0; padding: 2px 0; text-align: left !important; white-space: normal; }
  table.users td:nth-child(2), table.users td:nth-child(4) { display: inline-block; margin-right: 10px; font-size: 13px; color: var(--text-2); }
  table.users td:nth-child(3) { display: inline-block; margin-right: 10px; }
  .row-actions { justify-content: flex-start; flex-wrap: wrap; margin-top: 8px; }
}

/* ---------------------------------------------------------------- analyse */
.head-actions { display: flex; gap: 8px; flex-shrink: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-2 > .card { margin-bottom: 0; min-width: 0; }
.small { font-size: 13px; }
p.small { margin: 0 0 12px; }
.insights { margin: 0; padding-left: 18px; font-size: 14px; }
.insights li { margin-bottom: 8px; line-height: 1.45; }
.insights li::marker { color: var(--text-3); }
.ledger { margin: 0; font-size: 14px; }
.ledger-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; }
.ledger-row dt { color: var(--text-2); }
.ledger-row dd { margin: 0; white-space: nowrap; font-weight: 500; }
.ledger-row.total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 9px; font-weight: 700; }
.ledger-row.total dt { color: var(--text); }
.ledger-row.total dd { font-weight: 700; }
.ledger-sub { font-size: 12px; color: var(--text-3); margin-top: 12px; text-transform: uppercase; letter-spacing: .04em; }
.ledger-row.sub { padding-left: 12px; }
.ledger-row.muted-row dt, .ledger-row.muted-row dd { color: var(--text-3); font-weight: 400; }
td.strong { font-weight: 700; }
td .badge { margin-left: 8px; }
.barcol { width: 26%; min-width: 140px; }
.dbar { display: grid; grid-template-columns: 1fr 1fr; height: 12px; align-items: center; }
.dbar .neg { display: flex; justify-content: flex-end; border-right: 1px solid var(--text-3); height: 100%; align-items: center; }
.dbar .pos { display: flex; justify-content: flex-start; height: 100%; align-items: center; }
.dbar i { display: block; height: 10px; }
.dbar .neg i { background: var(--bad); border-radius: 3px 0 0 3px; }
.dbar .pos i { background: var(--good); border-radius: 0 3px 3px 0; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 4px 0 12px; }
.compare > div { background: var(--bg); border-radius: 10px; padding: 12px 14px; }
.compare .label { font-size: 13px; color: var(--text-2); }
.compare .value { font-size: 22px; font-weight: 700; }
details#sales-details summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details#sales-details summary::-webkit-details-marker { display: none; }
details#sales-details summary::before { content: "▸"; color: var(--text-3); transition: transform .15s; }
details#sales-details[open] summary::before { transform: rotate(90deg); }
details#sales-details summary h2 { display: inline; margin: 0; }
details#sales-details[open] summary { margin-bottom: 12px; }
table.plain th, table.plain td { padding: 8px; }

@media (max-width: 760px) {
  .grid-2 { grid-template-columns: 1fr; }
  .page-head { flex-wrap: wrap; }
  table.coins-a th:nth-child(2), table.coins-a td:nth-child(2), table.coins-a th:nth-child(3), table.coins-a td:nth-child(3),
  table.coins-a th:nth-child(5), table.coins-a td:nth-child(5), table.hold th:nth-child(3), table.hold td:nth-child(3) { display: none; }
  .barcol { display: none; }
  table.years th:nth-child(3), table.years td:nth-child(3), table.years th:nth-child(4), table.years td:nth-child(4), table.years th:nth-child(5), table.years td:nth-child(5), table.years th:nth-child(7), table.years td:nth-child(7) { display: none; }
  table.plain th, table.plain td { padding: 8px 4px; }
  table.sales th:nth-child(3), table.sales td:nth-child(3), table.sales th:nth-child(5), table.sales td:nth-child(5) { display: none; }
}

/* ---------------------------------------------------------------- voortgang */
.progress-card { padding: 22px 24px; }
.progress-top { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; margin-bottom: 10px; }
.progress-top .pct { font-weight: 700; font-variant-numeric: tabular-nums; }
.progress { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .5s ease; }
.progress-foot { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--text-3); margin-top: 10px; }
.progress-foot span:last-child { white-space: nowrap; }
