/* Open Sans (variabel, latin) — zelfde lettertype als de Vermogentracker,
   self-hosted zodat er geen extern CDN nodig is */
@font-face {
  font-family: "Open Sans";
  font-style: normal;
  font-weight: 300 800;
  font-stretch: 100%;
  font-display: swap;
  src: url("/static/opensans-var.woff2") format("woff2");
}

/* ---- thema-tokens: donker is de default, html[data-theme=light] is dag ---- */
:root {
  --bg: #101014;
  --bg-accent: rgba(144, 133, 233, 0.05);
  --surface: #191920;
  --surface-2: #22222b;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --text: #e8e8ea;
  --muted: #9a9aa6;
  --accent: #9085e9;
  --accent-ink: #ffffff;
  --ok: #199e70;
  --bad: #e66767;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --nav-bg: rgba(16, 16, 20, 0.85);
}

html[data-theme="light"] {
  --bg: #f3f3f6;
  --bg-accent: rgba(74, 58, 167, 0.04);
  --surface: #ffffff;
  --surface-2: #eeeef3;
  --border: rgba(20, 20, 40, 0.08);
  --border-strong: rgba(20, 20, 40, 0.16);
  --text: #26262c;
  --muted: #63636e;
  --accent: #4a3aa7;
  --accent-ink: #ffffff;
  --ok: #147a57;
  --bad: #c93c3c;
  --shadow: 0 10px 30px rgba(30, 30, 60, 0.08);
  --nav-bg: rgba(243, 243, 246, 0.85);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1100px 500px at 20% -10%, var(--bg-accent), transparent 60%), var(--bg);
  color: var(--text);
  font: 15px/1.55 "Open Sans", -apple-system, "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
}

/* ---- navigatie ---- */
nav {
  display: flex; align-items: center; justify-content: space-between; gap: 0.8rem;
  padding: 0.65rem clamp(0.8rem, 3vw, 1.4rem);
  /* PWA op iOS: onder de statusbalk/notch uit blijven */
  padding-top: calc(0.65rem + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
  background: var(--nav-bg);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text); text-decoration: none; letter-spacing: 0.02em; white-space: nowrap; }
.brand span { color: var(--accent); }
nav .links { display: flex; align-items: center; gap: 0.25rem; }
nav .links > a { color: var(--muted); text-decoration: none; font-size: 0.92rem; padding: 0.4rem 0.7rem; border-radius: 9px; }
nav .links > a:hover { color: var(--text); background: var(--surface-2); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px;
  color: var(--muted); background: none; border: none; cursor: pointer; text-decoration: none;
  padding: 0;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu[open] > summary { color: var(--text); background: var(--surface-2); }
details.menu .dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 190px; padding: 0.4rem;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 12px; box-shadow: var(--shadow); z-index: 30;
}
details.menu .dropdown a {
  display: block; padding: 0.5rem 0.7rem; border-radius: 8px;
  color: var(--text); text-decoration: none; font-size: 0.92rem; white-space: nowrap;
}
details.menu .dropdown a:hover { background: var(--surface-2); }
details.menu .dropdown .hintje { padding: 0.15rem 0.7rem 0.35rem; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; }

/* ---- layout ---- */
main {
  max-width: 1080px; margin: 0 auto;
  padding: 1.3rem clamp(0.8rem, 3vw, 1.4rem) calc(4rem + env(safe-area-inset-bottom, 0px));
}

h1 { font-size: 1.35rem; margin: 0.3rem 0 1rem; letter-spacing: -0.01em; }
h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); margin: 0 0 0.75rem; font-weight: 700; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.05rem 1.2rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

.weeknav { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.weeknav h1 { margin: 0; }
.weeknav .spacer { flex: 1; }

/* ---- statistiektegels ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.7rem; margin-bottom: 1rem; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 0.7rem 0.95rem; box-shadow: var(--shadow);
}
.stat .v { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat .l { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; margin-top: 0.1rem; }

/* ---- knoppen & formulieren ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 10px; padding: 0.42rem 0.85rem;
  text-decoration: none; font-size: 0.9rem; font-family: inherit; cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }

.switcher { display: inline-flex; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; padding: 3px; gap: 2px; }
.switcher .btn { border: none; background: none; padding: 0.3rem 0.8rem; border-radius: 8px; color: var(--muted); }
.switcher .btn:hover { color: var(--text); }
.switcher .btn.actief { background: var(--accent); color: var(--accent-ink); }

form.stacked label { display: block; margin: 0.7rem 0 0.25rem; color: var(--muted); font-size: 0.85rem; }
input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 10px; padding: 0.5rem 0.7rem;
  font: inherit;
}
input[type=file] { color: var(--muted); font: inherit; }
textarea { min-height: 4.5rem; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }

.auth-card { max-width: 380px; margin: 12vh auto 0; }
.error { color: var(--bad); margin: 0.6rem 0; }
.success { color: var(--ok); margin: 0.6rem 0; }
.hint { color: var(--muted); font-size: 0.85rem; }

/* ---- tabellen ---- */
table.habits { width: 100%; border-collapse: collapse; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
table.habits th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
table.habits th, table.habits td { padding: 0.42rem 0.45rem; text-align: center; border-bottom: 1px solid var(--border); }
table.habits tr:last-child td { border-bottom: none; }
table.habits tbody tr:hover, table.habits tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
table.habits td:first-child, table.habits th:first-child { text-align: left; white-space: nowrap; }
table.habits .pct { font-weight: 700; white-space: nowrap; }
.pctbar { display: inline-block; vertical-align: middle; width: 44px; height: 6px; border-radius: 3px; background: var(--surface-2); margin-right: 0.45rem; overflow: hidden; }
.pctbar i { display: block; height: 100%; width: var(--p, 0%); border-radius: 3px; background: var(--accent); }
.v-ok { color: var(--ok); } .v-bad { color: var(--bad); } .v-none { color: var(--muted); opacity: 0.5; }

/* ---- microdoelen ---- */
.microdoel-nu { font-size: 1.02rem; padding: 0.85rem 1.1rem; border-left: 3px solid var(--accent); }
.microdoel-strip { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.4rem; }
.microdoel-strip .wk {
  width: 3.4rem; text-align: center; border-radius: 10px; padding: 0.3rem 0 0.35rem;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 0.72rem;
  color: var(--muted); text-decoration: none; transition: transform 0.08s ease;
}
.microdoel-strip a.wk:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--text); }
.microdoel-strip .wk .m { font-size: 1rem; display: block; line-height: 1.2; }
.microdoel-strip .ja { border-color: color-mix(in srgb, var(--ok) 55%, transparent); background: color-mix(in srgb, var(--ok) 12%, var(--surface-2)); }
.microdoel-strip .ja .m { color: var(--ok); }
.microdoel-strip .nee { border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: color-mix(in srgb, var(--bad) 10%, var(--surface-2)); }
.microdoel-strip .nee .m { color: var(--bad); }

/* ---- doelen ---- */
.filterbalk { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-bottom: 1rem; }
.filterbalk .chip { padding: 0.3rem 0.75rem; font-size: 0.85rem; border-radius: 999px; }
.filterbalk .chip.actief { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.doellijst { display: grid; gap: 0.35rem; }
.doel {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0.65rem; border-radius: 10px;
  color: var(--text); text-decoration: none; border: 1px solid transparent;
}
.doel:hover { background: var(--surface-2); border-color: var(--border); }
.doel .d-status { width: 1.2rem; text-align: center; }
.doel.status-done .d-status { color: var(--ok); }
.doel.status-doing .d-status { color: var(--accent); }
.doel.status-todo .d-status { color: var(--muted); }
.doel.status-done .d-naam { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.doel .d-naam { flex: 1; }
.doel .d-due { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }

canvas { max-width: 100%; }
.chart-wrap { position: relative; height: 250px; }
.chart-wrap.small { height: 185px; }

.qr { background: #ffffff; padding: 1rem; border-radius: 12px; display: inline-block; }

/* ---- mobiel ---- */
@media (max-width: 680px) {
  body { font-size: 14px; }
  nav { padding: 0.45rem 0.55rem calc(0.45rem); gap: 0.4rem;
        padding-top: calc(0.45rem + env(safe-area-inset-top, 0px)); }
  .brand { font-size: 0.95rem; }
  nav .links { gap: 0; min-width: 0; }
  nav .links > a { padding: 0.32rem 0.42rem; font-size: 0.85rem; }
  .icon-btn { width: 30px; height: 30px; }
  .icon-btn svg { width: 16px; height: 16px; }
  main { padding: 0.9rem 0.75rem 3rem; }
  h1 { font-size: 1.15rem; }
  .weeknav { gap: 0.45rem; }
  .weeknav .btn { padding: 0.35rem 0.6rem; }
  .switcher { order: 5; width: 100%; justify-content: stretch; }
  .switcher .btn { flex: 1; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 0.5rem; }
  .stat { padding: 0.55rem 0.7rem; }
  .stat .v { font-size: 1.2rem; }
  .card { padding: 0.85rem 0.9rem; border-radius: 14px; }
  .chart-wrap { height: 215px; }
  .chart-wrap.small { height: 165px; }
  table.habits { font-size: 0.82rem; }
  .pctbar { width: 30px; }
}
