@import url("/static/css/fonts.css");

/* ============================================================================
   ZZP Boekhouding, presentatielaag
   Aesthetiek: financieel instrument. Warm papier, near-black inkt, een enkele
   bronzen accent, mono cijfers (grootboek-gevoel), haarlijnen, fijne korrel.
   Strak en zakelijk. Geen marketing-flair.
   ========================================================================== */

:root {
  --paper:        #f2efe7;
  --paper-2:      #ece8de;
  --surface:      #fbfaf6;
  --surface-2:    #ffffff;

  --ink:          #15171c;
  --ink-2:        #383c44;
  --ink-soft:     #5d626c;
  --muted:        #6a6e77;   /* AA-contrast (>=4.5:1) op papier/kaart voor labels/kopjes */
  --faint:        #9a9da4;

  --hair:         #e4ded1;
  --hair-strong:  #d6cfbe;

  --accent:       #1b2330;   /* ink-navy: knoppen, donkere vlakken */
  --accent-2:     #2a3445;
  --bronze:       #9a6b1f;   /* enige warme accent: actief, focus, highlight */
  --bronze-soft:  #efe5d2;

  --pos:          #2f6b4f;
  --pos-bg:       #e6efe7;
  --neg:          #a23a2e;
  --neg-bg:       #f5e6e1;

  --shadow-sm:    0 1px 2px rgba(24,20,10,.05);
  --shadow:       0 1px 2px rgba(24,20,10,.05), 0 18px 44px -24px rgba(24,20,10,.22);
  --shadow-pop:   0 8px 30px -10px rgba(24,20,10,.28);

  --r:            10px;
  --r-lg:         14px;

  --font-display: "Bricolage Grotesque", "Hanken Grotesk", sans-serif;
  --font-ui:      "Hanken Grotesk", -apple-system, "Segoe UI", sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, "DejaVu Sans Mono", monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Fijne korrel over de hele pagina (SVG-noise, geen externe asset) */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: .035; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
body > * { position: relative; z-index: 1; }

h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 600; letter-spacing: -.012em; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

::selection { background: var(--bronze-soft); color: var(--accent-ink, var(--ink)); }
:focus-visible { outline: 2px solid var(--bronze); outline-offset: 2px; border-radius: 4px; }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Iconen: stroke-set, consistente maat */
.ic { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.7;
  fill: none; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.ic-sm { width: 15px; height: 15px; }
.ic-lg { width: 22px; height: 22px; }

/* ── Merkmark ─────────────────────────────────────────────────────────────── */
.brand-mark {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: 10px; background: var(--accent); color: #f4f1ea;
  font-family: var(--font-display); font-weight: 700; font-size: 14px;
  letter-spacing: .02em; box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}
.brand-mark .ic { stroke: #e9c98a; }

/* ============================================================================
   LOGIN
   ========================================================================== */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card {
  position: relative; width: 380px; max-width: 94vw; background: var(--surface);
  border: 1px solid var(--hair); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 38px 34px 32px;
}
.login-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: linear-gradient(90deg, var(--accent) 0 62%, var(--bronze) 62% 100%);
}
.brand { display: grid; justify-items: center; gap: 12px; margin-bottom: 26px; text-align: center; }
.brand .brand-mark { width: 46px; height: 46px; font-size: 17px; border-radius: 12px; }
.brand h1 { font-size: 21px; letter-spacing: .14em; text-transform: uppercase; }
.brand p { margin: 0; color: var(--muted); font-size: 12.5px; letter-spacing: .04em; }

.auth-form { display: flex; flex-direction: column; gap: 15px; }
.auth-form label, .field-label {
  display: flex; flex-direction: column; gap: 6px; font-size: 11px;
  text-transform: uppercase; letter-spacing: .09em; color: var(--ink-soft); font-weight: 600;
}
.auth-form input, .form input, .form select, .form textarea {
  font: inherit; font-family: var(--font-ui); padding: 11px 13px; border: 1px solid var(--hair-strong);
  border-radius: 9px; background: var(--surface-2); color: var(--ink);
  text-transform: none; letter-spacing: 0; font-weight: 500; transition: border-color .18s, box-shadow .18s;
}
#totp { font-family: var(--font-mono); letter-spacing: .5em; text-align: center; font-size: 18px; }
.auth-form input:focus, .form input:focus, .form select:focus, .form textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(27,35,48,.10);
}
.qr { display: block; width: 176px; height: 176px; margin: 8px auto 2px; border-radius: 10px;
  border: 1px solid var(--hair); padding: 8px; background: #fff; }
.btn-primary {
  font: inherit; font-family: var(--font-ui); font-weight: 600; letter-spacing: .01em;
  padding: 12px 16px; border: 1px solid var(--accent); border-radius: 9px;
  background: var(--accent); color: #f4f1ea; cursor: pointer; margin-top: 4px;
  transition: filter .18s, transform .06s; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary:hover { filter: brightness(1.14); }
.btn-primary:active { transform: translateY(1px); }
.fout { margin: 16px 0 0; color: var(--neg); font-size: 13px; text-align: center; font-weight: 500; }

/* ============================================================================
   APP-CHROME: sticky topbar + sticky tabs
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 26px; background: rgba(251,250,246,.82); backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--hair);
}
.topbar .left { display: flex; align-items: center; gap: 13px; }
.topbar h1 { font-family: var(--font-display); font-size: 15px; letter-spacing: .15em; text-transform: uppercase; font-weight: 600; }
.topbar h1 .sub { color: var(--muted); font-weight: 500; letter-spacing: .04em; }
.topbar .right { display: flex; align-items: center; gap: 12px; }
.yr { position: relative; display: inline-flex; align-items: center; }
.topbar select {
  font: inherit; font-family: var(--font-mono); font-weight: 500; padding: 7px 30px 7px 12px;
  border: 1px solid var(--hair-strong); border-radius: 8px; background: var(--surface-2); color: var(--ink);
  appearance: none; cursor: pointer;
}
.yr::after { content: ""; position: absolute; right: 11px; width: 7px; height: 7px;
  border-right: 1.6px solid var(--ink-soft); border-bottom: 1.6px solid var(--ink-soft);
  transform: rotate(45deg) translateY(-2px); pointer-events: none; }
.link-btn { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border: 1px solid var(--hair-strong);
  border-radius: 8px; background: none; color: var(--ink-soft); cursor: pointer; font: inherit; font-weight: 500;
  transition: color .18s, border-color .18s, background .18s; }
.link-btn:hover { color: var(--ink); border-color: var(--ink-soft); background: var(--surface-2); }

.tabs {
  position: sticky; top: 63px; z-index: 25;
  display: flex; gap: 2px; padding: 0 22px; background: rgba(242,239,231,.86); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--hair); overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 13px 15px 12px; border: none; background: none;
  font: inherit; font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .18s; }
.tab .ic { width: 16px; height: 16px; opacity: .85; }
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--ink); border-bottom-color: var(--bronze); font-weight: 600; }
.tab.active .ic { color: var(--bronze); opacity: 1; }

main.wrap { padding: 28px 26px 56px; max-width: 1200px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; animation: panelIn .32s cubic-bezier(.16,1,.3,1) both; }
@keyframes panelIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── KPI's ───────────────────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(192px, 1fr)); gap: 14px; }
.kpi { position: relative; background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r);
  padding: 15px 17px 16px; box-shadow: var(--shadow-sm); overflow: hidden;
  opacity: 0; transform: translateY(10px); animation: kpiIn .5s cubic-bezier(.16,1,.3,1) forwards;
  animation-delay: calc(var(--i, 0) * 55ms); transition: transform .2s, box-shadow .2s, border-color .2s; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--hair-strong); }
@keyframes kpiIn { to { opacity: 1; transform: none; } }
.kpi::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 3px;
  background: var(--hair-strong); }
.kpi.pos::before { background: var(--pos); }
.kpi.neg::before { background: var(--neg); }
.kpi.accent::before { background: var(--bronze); }
.kpi .label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.kpi .value { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 25px;
  font-weight: 600; letter-spacing: -.02em; margin-top: 7px; line-height: 1.05; color: var(--ink); }
.kpi.pos .value { color: var(--pos); }
.kpi.neg .value { color: var(--neg); }
.kpi .sub { font-size: 11.5px; color: var(--ink-soft); margin-top: 4px; letter-spacing: .01em; }

/* ── Kaarten / grids ─────────────────────────────────────────────────────── */
.cards-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
@media (max-width: 860px) { .cards-2 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r-lg);
  padding: 18px 20px; box-shadow: var(--shadow-sm); }
.card h3 { display: flex; align-items: center; gap: 8px; font-family: var(--font-ui); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .09em; color: var(--ink-soft); font-weight: 600; margin-bottom: 14px; }
.card h3 .ic { width: 15px; height: 15px; color: var(--muted); }
.chart-box { position: relative; height: 264px; }
.chart-box canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-head h2 { display: flex; align-items: center; gap: 10px; font-size: 19px; letter-spacing: -.01em; }
.section-head h2 .ic { width: 20px; height: 20px; color: var(--bronze); }

/* ── Tabellen ────────────────────────────────────────────────────────────── */
table.data { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--hair);
  border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
table.data thead th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 600; padding: 11px 16px; background: var(--paper-2); border-bottom: 1px solid var(--hair); }
table.data td { padding: 12px 16px; border-bottom: 1px solid var(--hair); vertical-align: middle; }
table.data tbody tr { transition: background .14s; }
table.data tbody tr:hover { background: rgba(154,107,31,.045); }
table.data tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.card table.data { border: none; box-shadow: none; border-radius: 0; margin: -2px 0; }
.card table.data thead th { background: transparent; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; border: 1px solid transparent; }
.badge.hoog { background: var(--pos-bg); color: var(--pos); border-color: rgba(47,107,79,.18); }
.badge.laag { background: var(--bronze-soft); color: #7a540e; border-color: rgba(154,107,31,.28); }
.badge.grijs { background: #ece9e1; color: var(--ink-soft); border-color: var(--hair-strong); }
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ── Knoppen ─────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 7px; font: inherit; font-family: var(--font-ui);
  font-size: 13px; font-weight: 500; padding: 8px 13px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--hair-strong); background: var(--surface-2); color: var(--ink);
  transition: background .16s, border-color .16s, color .16s, transform .06s; }
.btn .ic { width: 15px; height: 15px; }
.btn:hover { background: var(--paper-2); border-color: var(--ink-soft); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #f4f1ea; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.14); background: var(--accent); }
.btn.danger { color: var(--neg); border-color: #e3c9c4; background: var(--surface-2); }
.btn.danger:hover { background: var(--neg-bg); border-color: var(--neg); }
.btn.ghost { border-color: transparent; background: none; color: var(--accent); padding: 8px 8px; }
.btn.ghost:hover { background: var(--paper-2); color: var(--accent); }
.row-actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

/* ── Formulieren ─────────────────────────────────────────────────────────── */
.form { display: grid; gap: 14px; max-width: 660px; }
.form > label, .form .field-label { gap: 6px; }
.form .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.regel-rij { display: grid; grid-template-columns: 1fr 76px 108px 116px 34px; gap: 9px; align-items: center; }
.regel-rij input, .regel-rij select { padding: 9px 10px; }
.regel-rij input[type=number], .b-incl, .b-btw { font-family: var(--font-mono); }
#factuur-form-wrap.card { border-style: dashed; border-color: var(--hair-strong); background: var(--surface-2); }

/* ── Bon-kaarten ─────────────────────────────────────────────────────────── */
.bon { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r-lg);
  padding: 17px 19px; box-shadow: var(--shadow-sm); margin-bottom: 14px; }
.bon-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.bon-head strong { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.bon-velden { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 11px; margin: 14px 0; }
.veld label, .veld .field-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  display: block; margin-bottom: 4px; font-weight: 600; }
.veld input, .veld select { width: 100%; padding: 8px 10px; border: 1px solid var(--hair-strong); border-radius: 7px;
  font: inherit; font-family: var(--font-ui); background: var(--surface-2); }
.veld input:focus, .veld select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(27,35,48,.09); }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 60; display: inline-flex; align-items: center; gap: 9px;
  background: var(--accent); color: #f4f1ea; padding: 12px 17px; border-radius: 10px; box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(10px) scale(.98); transition: opacity .22s, transform .22s; font-weight: 500; }
.toast::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #7fb89a; }
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--neg); }
.toast.err::before { background: #f0c0b8; }

/* ── Lege staten ─────────────────────────────────────────────────────────── */
.empty { display: grid; justify-items: center; gap: 8px; color: var(--muted); padding: 30px 20px; text-align: center; }
.empty .ic { width: 26px; height: 26px; color: var(--faint); stroke-width: 1.5; }
.empty.small { padding: 18px; }

/* ── Responsief ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .topbar { padding: 11px 16px; }
  main.wrap { padding: 20px 16px 48px; }
  .regel-rij { grid-template-columns: 1fr 1fr; }
  .tabs { top: 59px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important;
    transition-duration: .01ms !important; }
}
