:root {
  --bg: #f5f6f3;
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --border: #dde2db;
  --text: #1c2420;
  --muted: #5f6b65;
  --accent: #2f7a70;
  --accent-ink: #ffffff;
  --accent-soft: #e2efec;
  --pos: #23784a;
  --pos-soft: #e3f2e8;
  --neg: #b23a34;
  --neg-soft: #f8e6e4;
  --neu: #8a938e;
  --neu-soft: #eceeec;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 4px 16px rgba(20, 30, 25, .04);
  --font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --surface: #1a1f1d;
    --surface-2: #222826;
    --border: #2e3633;
    --text: #e7ece9;
    --muted: #9aa69f;
    --accent: #6fbfb2;
    --accent-ink: #0e1513;
    --accent-soft: #1f3330;
    --pos: #5cc58a;
    --pos-soft: #1b3326;
    --neg: #ee7b72;
    --neg-soft: #3a2220;
    --neu: #7d8782;
    --neu-soft: #262c2a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0; letter-spacing: -.01em; font-weight: 650; }
h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 .8rem; font-weight: 600; }
p { margin: .3rem 0; }
.mono { font-family: var(--mono); font-feature-settings: "tnum"; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.pre { white-space: pre-wrap; }

/* ---------- header */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .45rem; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 22px; height: 22px; color: var(--accent); }
.nav { display: flex; gap: .2rem; margin-left: auto; }
.nav a { color: var(--muted); padding: .35rem .6rem; border-radius: 999px; font-size: .92rem; font-weight: 500; }
.nav a:hover { text-decoration: none; color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.logout { margin: 0; }
button.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; padding: .35rem 0; }
button.link:hover { color: var(--text); }

.wrap { max-width: 980px; margin: 0 auto; padding: 1.2rem 16px 4rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin: .4rem 0 1.2rem; }
.sub { margin: .15rem 0 0; }
.back { display: inline-block; margin-bottom: .4rem; color: var(--muted); }
.intro { max-width: 60ch; margin-bottom: 1rem; }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 44px; padding: .55rem 1rem;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; font-size: .95rem; cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--neg); }
.btn.danger:hover { border-color: var(--neg); }
.btn.small { min-height: 36px; padding: .35rem .8rem; font-size: .88rem; }
.btn.wide { width: 100%; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } .btn { transition: none; } }

/* ---------- cards */
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.card, .panel, .center-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card { padding: 1rem 1rem .8rem; display: flex; flex-direction: column; gap: .7rem; }
.card.alert { border-color: color-mix(in srgb, var(--neg) 45%, var(--border)); }
.card-head { display: flex; justify-content: space-between; gap: .6rem; color: var(--text); }
.card-head:hover { text-decoration: none; }
.card-head:hover .ticker { color: var(--accent); }
.ticker { font-size: 1.15rem; font-weight: 600; }
.name { font-size: .88rem; }
.price-col { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; }
.price { font-size: 1.05rem; }
.price.big { font-size: 1.4rem; }
.badge { font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; padding: .15rem .5rem; border-radius: 999px; }
.badge.neg { background: var(--neg-soft); color: var(--neg); }

dl.position { margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; padding: .6rem .7rem; background: var(--surface-2); border-radius: var(--radius-sm); }
dl.position dt { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
dl.position dd { margin: 0; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
dl.position.wide { grid-template-columns: repeat(4, 1fr); margin-bottom: 1rem; }
@media (max-width: 560px) { dl.position.wide { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 360px) { dl.position { grid-template-columns: 1fr 1fr; } }

.advice p { margin: .3rem 0 0; font-size: .92rem; }
.pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: .1rem .55rem; border-radius: 999px; }
.pill.pos { background: var(--pos-soft); color: var(--pos); }
.pill.neg { background: var(--neg-soft); color: var(--neg); }
.pill.neu { background: var(--neu-soft); color: var(--muted); }

/* ---------- events */
.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.event { display: grid; grid-template-columns: 14px 1fr; gap: .6rem; padding: .55rem 0; border-top: 1px solid var(--border); }
.events.compact .event:first-child { border-top: 0; }
.event .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: .4rem; background: var(--neu); }
.event.dir-pos .dot { background: var(--pos); }
.event.dir-neg .dot { background: var(--neg); }
.event-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; font-size: .78rem; color: var(--muted); }
.tag { background: var(--surface-2); padding: .05rem .45rem; border-radius: 6px; }
.strength { display: inline-flex; align-items: center; gap: .35rem; }
.bar { display: inline-block; width: 38px; height: 4px; border-radius: 2px; background: var(--neu-soft); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--neu); }
.event.dir-pos .bar span { background: var(--pos); }
.event.dir-neg .bar span { background: var(--neg); }
.event-title { font-size: .92rem; line-height: 1.4; overflow-wrap: anywhere; }
.event-title a { color: var(--text); }
.event.dir-neg .event-title { color: var(--neg); }
.event.dir-neg .event-title a { color: var(--neg); }
.event.dir-pos .event-title a, .event.dir-pos .event-title { color: var(--text); }
.event-detail { font-size: .84rem; color: var(--muted); margin: .25rem 0 0; overflow-wrap: anywhere; }
.timeline .event:first-child { border-top: 0; }

/* ---------- panels and forms */
.panel { padding: 1rem; margin-bottom: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.actions form { margin: 0; }
.job { margin: .7rem 0 0; padding: .5rem .7rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.job.fout { background: var(--neg-soft); color: var(--neg); }
.job.klaar { background: var(--accent-soft); }

.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .6rem; margin-bottom: .2rem; scrollbar-width: none; }
.chips a { flex: none; padding: .3rem .8rem; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: .85rem; }
.chips a:hover { text-decoration: none; color: var(--text); }
.chips a[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.advice-list { list-style: none; margin: 0; padding: 0; }
.advice-list li { padding: .7rem 0; border-top: 1px solid var(--border); }
.advice-list li:first-child { border-top: 0; padding-top: 0; }
details summary { cursor: pointer; color: var(--accent); }

.form { display: flex; flex-direction: column; gap: .8rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
@media (max-width: 480px) { .grid2 { grid-template-columns: 1fr; } }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .82rem; color: var(--muted); font-weight: 500; }
input, textarea {
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .6rem .7rem; width: 100%;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, .btn:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.form .btn { align-self: flex-start; }
.row-actions { display: flex; gap: .6rem; }

.watch-list { list-style: none; margin: 0; padding: 0; }
.watch-list > li { border-top: 1px solid var(--border); }
.watch-list > li:first-child { border-top: 0; }
.watch-list summary { display: flex; align-items: baseline; gap: .7rem; padding: .75rem 0; color: var(--text); list-style: none; }
.watch-list summary::-webkit-details-marker { display: none; }
.watch-list summary .right { margin-left: auto; color: var(--muted); }
.watch-list details[open] { padding-bottom: 1rem; }
.remove { margin-top: .8rem; }

/* ---------- tables */
.table-scroll { overflow-x: auto; margin: 0 -1rem; padding: 0 1rem; }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th { text-align: left; font-weight: 600; font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: .4rem .5rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: .55rem .5rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data .num { text-align: right; }
.stat-row { display: flex; gap: 14px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; display: flex; flex-direction: column; }
.stat-num { font-size: 1.5rem; font-weight: 500; }

/* ---------- misc */
.center-card { max-width: 420px; margin: 12vh auto 0; padding: 2rem 1.5rem; text-align: center; display: flex; flex-direction: column; gap: .8rem; }
.center-card h1 { font-size: 1.5rem; }
.notice { padding: .7rem .9rem; border-radius: var(--radius-sm); background: var(--neg-soft); color: var(--neg); font-size: .9rem; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: .8rem; }

@media (max-width: 520px) {
  .top { gap: .6rem; }
  .brand { font-size: 0; gap: 0; }
  .brand-mark { width: 24px; height: 24px; }
  .nav { margin-left: 0; }
  .nav a { padding: .35rem .5rem; font-size: .88rem; }
  .logout { margin-left: auto; }
  h1 { font-size: 1.35rem; }
}
