@font-face {
  font-family: 'Geist';
  src: url('https://cdn.jsdelivr.net/npm/geist@1.3.0/dist/fonts/geist-sans/Geist-Variable.woff2') format('woff2');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: 'Geist Mono';
  src: url('https://cdn.jsdelivr.net/npm/geist@1.3.0/dist/fonts/geist-mono/GeistMono-Variable.woff2') format('woff2');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

/* ── shadcn/ui Zinc · Light (default) ───────────────────── */
  :root {
    --background: #ffffff;
    --foreground: #09090b;
    --card: #ffffff;
    --muted: #f4f4f5;
    --muted-foreground: #71717a;
    --border: #e4e4e7;
    --input: #e4e4e7;
    --primary: #09090b;
    --primary-foreground: #fafafa;
    --accent: #f4f4f5;
    --accent-foreground: #09090b;
    --destructive: #ef4444;
    --destructive-foreground: #fafafa;
    --ring: #09090b;
    --result-active: #18181b;
    --result-active-foreground: #fafafa;
    --radius: 0.5rem;

    /* Legacy aliases */
    --bg:      var(--background);
    --panel:   var(--card);
    --panel2:  var(--muted);
    --line:    var(--border);
    --ink:     var(--foreground);
    --dim:     var(--muted-foreground);
    --signal:  #09090b;
    --signal2: #18181b;
    --eigen:   #16a34a;
    --bedrijf: #ea580c;
    --bad:     var(--destructive);
    --soft:    var(--accent);
    --warn:    #fefce8;
    --shadow:  0 1px 3px 0 rgb(0 0 0 / .08), 0 1px 2px -1px rgb(0 0 0 / .05);
    --disp:    'Geist', ui-sans-serif, system-ui, -apple-system, sans-serif;
    --mono:    'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    /* ── Design tokens ─────────────────────────────────── */
    /* Typography scale */
    --text-xs:   11px;
    --text-sm:   12px;
    --text-base: 14px;
    --text-md:   15px;
    --text-lg:   18px;
    --text-xl:   24px;

    /* Spacing scale */
    --sp-1: 4px;  --sp-2: 8px;   --sp-3: 12px;
    --sp-4: 16px; --sp-5: 20px;  --sp-6: 24px;  --sp-8: 32px;

    /* Shadows — layered, Stripe-style */
    --shadow-xs:   0 1px 2px 0 rgb(0 0 0 / .05);
    --shadow-sm:   0 1px 3px 0 rgb(0 0 0 / .08), 0 1px 2px -1px rgb(0 0 0 / .05);
    --shadow-md:   0 4px 6px -1px rgb(0 0 0 / .07), 0 2px 4px -2px rgb(0 0 0 / .05);
    --shadow-card: 0 0 0 1px var(--border), 0 2px 8px -2px rgb(0 0 0 / .08);

    /* Easing curves (Emil Kowalski) */
    --ease-out:    cubic-bezier(0.23, 1, 0.32, 1);
    --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  }

  /* ── shadcn/ui Zinc · Dark ───────────────────────────────── */
  html.dark {
    --background: #09090b;
    --foreground: #fafafa;
    --card: #09090b;
    --muted: #18181b;
    --muted-foreground: #71717a;
    --border: #27272a;
    --input: #27272a;
    --primary: #fafafa;
    --primary-foreground: #09090b;
    --accent: #27272a;
    --accent-foreground: #fafafa;
    --destructive: #ef4444;
    --destructive-foreground: #fafafa;
    --ring: #fafafa;
    --result-active: #27272a;
    --result-active-foreground: #fafafa;

    /* Legacy aliases */
    --bg:      var(--background);
    --panel:   var(--card);
    --panel2:  var(--muted);
    --line:    var(--border);
    --ink:     var(--foreground);
    --dim:     var(--muted-foreground);
    --signal:  #fafafa;
    --signal2: #e4e4e7;
    --eigen:   #4ade80;
    --bedrijf: #fb923c;
    --bad:     var(--destructive);
    --soft:    var(--accent);
    --warn:    #422006;
    --shadow:  0 1px 3px 0 rgb(0 0 0 / .3), 0 1px 2px -1px rgb(0 0 0 / .2);
  }

  *, *::before, *::after { box-sizing: border-box; }

  body {
    margin: 0;
    background: var(--background);
    color: var(--foreground);
    font-family: var(--disp);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* ── Layout ─────────────────────────────────────────────── */
  .wrap {
    max-width: 1440px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    min-height: 100vh;
    align-items: start;
  }

  header.bar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 20px;
    height: 56px;
    border-bottom: 1px solid var(--border);
    background: var(--background);
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 40;
  }

  /* ── Logo ───────────────────────────────────────────────── */
  .logo {
    font-family: var(--disp);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.02em;
    color: var(--foreground);
    line-height: 1;
  }
  .logo span { color: var(--muted-foreground); font-weight: 400; }

  .tag {
    color: var(--muted-foreground);
    font-size: 12px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
  }
  .env-badge {
    display: none;
    padding: 4px 8px;
    border: 1px solid var(--warning);
    border-radius: 999px;
    background: color-mix(in oklch, var(--warning) 14%, var(--card));
    color: color-mix(in oklch, var(--warning) 64%, var(--foreground));
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
  }
  .env-badge.show { display: inline-flex; }

  /* ── Sidebar ─────────────────────────────────────────────── */
  nav.nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--background);
    border-right: 1px solid var(--border);
    border-radius: 0;
    padding: 12px 10px 24px;
    box-shadow: none;
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
  }

  .nav-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
  }
  .nav-title { font-weight: 600; font-size: 13px; color: var(--foreground); }
  .nav-group-label {
    padding: 8px 10px 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--muted-foreground);
    user-select: none;
  }
  .nav-icon { font-size: 14px; width: 16px; text-align: center; flex-shrink: 0; }

  /* Collapsed: verberg group labels en tekst */
  body.menu-collapsed .nav-group-label { display: none; }
  body.menu-collapsed nav.nav button span:not(.nav-icon) { display: none; }
  body.menu-collapsed nav.nav button { justify-content: center; padding: 8px; }
  .nav-toggle { padding: 4px 8px !important; font-size: 12px !important; height: 28px; }

  nav.nav button {
    background: transparent;
    border: 1px solid transparent;
    color: var(--muted-foreground);
    padding: 7px 10px;
    border-radius: calc(var(--radius) - 2px);
    font-family: var(--disp);
    font-weight: 500;
    cursor: pointer;
    font-size: 13px;
    text-align: left;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.1s, color 0.1s;
  }
  nav.nav button.active {
    background: var(--accent);
    color: var(--accent-foreground);
    font-weight: 600;
    border-color: transparent;
  }
  nav.nav button:not(.active):hover {
    background: var(--accent);
    color: var(--accent-foreground);
  }

  body.menu-collapsed .wrap { grid-template-columns: 56px minmax(0, 1fr); }
  body.menu-collapsed .nav-title { display: none; }

  /* ── Views ───────────────────────────────────────────────── */
  .view { display: none; }
  .view.on { display: block; }
  main.app-main {
    min-width: 0;
    padding: 28px 28px 80px;
  }

  /* ── Card / Section ──────────────────────────────────────── */
  section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-xs);
  }

  .head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--background);
  }
  .head .n {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    background: var(--secondary);
    color: var(--secondary-foreground);
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: 11px;
    font-family: var(--disp);
    border: 1px solid var(--border);
    flex-shrink: 0;
  }
  .head h2 {
    margin: 0;
    font-family: var(--disp);
    font-weight: 600;
    font-size: 15px;
    color: var(--foreground);
    letter-spacing: -0.01em;
  }
  .head .sub { color: var(--muted-foreground); font-size: 12px; margin-left: auto; }
  .body { padding: 18px; }

  /* ── Form labels ─────────────────────────────────────────── */
  label {
    display: block;
    color: var(--foreground);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    text-transform: none;
    letter-spacing: 0;
  }

  /* ── Inputs & Selects ────────────────────────────────────── */
  input, select {
    width: 100%;
    background: var(--background);
    border: 1px solid var(--input);
    color: var(--foreground);
    font-family: var(--disp);
    font-size: 14px;
    padding: 0 10px;
    height: 36px;
    border-radius: calc(var(--radius) - 2px);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  input:focus, select:focus {
    border-color: var(--ring);
    box-shadow: 0 0 0 2px hsl(240 5% 64.9% / 0.25);
  }
  input::placeholder { color: var(--muted-foreground); }
  input[type="date"], input[type="month"] { font-family: var(--disp); }

  /* ── Grid ────────────────────────────────────────────────── */
  .grid { display: grid; grid-template-columns: 130px 1fr 1.3fr 1.4fr 90px auto; gap: 12px; align-items: end; }

  /* ── Buttons ─────────────────────────────────────────────── */
  button {
    font-family: var(--disp);
    font-weight: 500;
    cursor: pointer;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    padding: 0 14px;
    font-size: 13px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 150ms ease-out, color 150ms ease-out, border-color 150ms ease-out, opacity 150ms ease-out, transform 120ms ease-out;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* Primary */
  .btn {
    background: var(--primary);
    color: var(--primary-foreground);
    border: 1px solid var(--primary);
  }
  .btn:hover { background: hsl(240 5.9% 18%); border-color: hsl(240 5.9% 18%); }
  .btn:active { transform: scale(0.97); }
  .btn:disabled {
    background: var(--muted);
    color: var(--muted-foreground);
    border-color: var(--border);
    cursor: not-allowed;
    pointer-events: none;
  }

  /* Outline / Ghost */
  .ghost {
    background: var(--background);
    color: var(--foreground);
    border: 1px solid var(--border);
  }
  .ghost:hover { background: var(--accent); color: var(--accent-foreground); }
  .ghost:active { transform: scale(0.97); }

  @media (hover: hover) and (pointer: fine) {
    .btn:hover, .ghost:hover { }
  }

  /* ── Table ───────────────────────────────────────────────── */
  table { width: 100%; border-collapse: collapse; font-size: 13px; }
  th {
    text-align: left;
    color: var(--muted-foreground);
    font-weight: 500;
    font-size: 12px;
    text-transform: none;
    letter-spacing: 0;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--muted);
  }
  td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--foreground);
  }
  tr:last-child td { border-bottom: none; }
  tr:hover td { background: var(--muted); }
  td input { padding: 0 8px; font-size: 13px; height: 32px; }

  /* ── Badge / Pill ────────────────────────────────────────── */
  .pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid transparent;
  }
  .pill.e {
    background: hsl(142.1 76.2% 36.3% / 0.1);
    color: hsl(142.1 76.2% 28%);
    border-color: hsl(142.1 76.2% 36.3% / 0.25);
  }
  .pill.b {
    background: hsl(217.2 91.2% 59.8% / 0.12);
    color: hsl(217.2 91.2% 42%);
    border-color: hsl(217.2 91.2% 59.8% / 0.28);
  }
  [data-theme="dark"] .pill.b { color: hsl(213 93.9% 67.8%); }

  /* ── Delete icon ─────────────────────────────────────────── */
  .x { color: var(--muted-foreground); cursor: pointer; font-weight: 400; font-size: 16px; }
  .x:hover { color: var(--destructive); }

  /* ── Toolbar ─────────────────────────────────────────────── */
  .toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
  .toolbar .spacer { flex: 1; }

  /* ── Empty state ─────────────────────────────────────────── */
  .empty { color: var(--muted-foreground); text-align: center; padding: 40px; font-style: normal; font-size: 13px; }

  /* ── Drop zone ───────────────────────────────────────────── */
  .drop {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    color: var(--muted-foreground);
    background: var(--muted);
    transition: border-color 150ms ease-out, background 150ms ease-out, color 150ms ease-out;
    cursor: pointer;
  }
  .drop.hot { border-color: var(--ring); color: var(--foreground); background: var(--accent); }
  .drop strong { color: var(--foreground); font-weight: 600; }

  /* ── Status / Alert ──────────────────────────────────────── */
  .status {
    margin-top: 14px;
    font-size: 12px;
    white-space: pre-line;
    border: 1px solid var(--border);
    padding: 12px 14px;
    background: var(--muted);
    border-radius: var(--radius);
    display: none;
    font-family: var(--mono);
    line-height: 1.6;
    color: var(--foreground);
  }
  .status.show { display: block; }

  /* ── Legend / help text ──────────────────────────────────── */
  .legend { color: var(--muted-foreground); font-size: 12px; margin-top: 10px; line-height: 1.6; }
  .num { color: var(--foreground); font-weight: 600; }

  /* ── Scroll ──────────────────────────────────────────────── */
  .scroll { max-height: 340px; overflow: auto; border-radius: var(--radius); border: 1px solid var(--border); }
  .scroll table { border-radius: 0; }
  .scroll th:first-child { border-radius: var(--radius) 0 0 0; }
  .scroll th:last-child  { border-radius: 0 var(--radius) 0 0; }

  /* ── Add row ─────────────────────────────────────────────── */
  .addrow { display: flex; gap: 10px; align-items: end; margin-bottom: 16px; flex-wrap: wrap; }
  .addrow > div { flex: 1; min-width: 120px; }

  /* ── Month accordion ─────────────────────────────────────── */
  .month {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    overflow: hidden;
    background: var(--card);
  }
  .month-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    cursor: pointer;
    background: var(--background);
    user-select: none;
    transition: background var(--duration-fast) var(--ease-out);
  }
  .month-head:hover { background: var(--muted); }
  .caret { color: var(--muted-foreground); width: 12px; font-size: 10px; flex-shrink: 0; }
  .month-name { font-family: var(--disp); font-weight: 600; font-size: 14px; color: var(--foreground); text-transform: none; }
  .month-meta { color: var(--muted-foreground); font-size: 12px; }
  .month-exp {
    margin-left: auto;
    color: var(--muted-foreground);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 500;
    background: var(--background);
    height: auto;
    cursor: pointer;
  }
  .month-exp:hover { background: var(--accent); color: var(--foreground); }
  .month-body { padding: 8px 10px 10px; background: var(--muted); }

  /* ── Week accordion ──────────────────────────────────────── */
  .week { border: 1px solid var(--border); border-radius: calc(var(--radius) - 2px); margin: 6px 0; overflow: hidden; background: var(--card); }
  .week-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; user-select: none; background: var(--background); transition: background var(--duration-fast) var(--ease-out); }
  .week-head:hover { background: var(--muted); }
  .week-name { font-weight: 600; font-size: 13px; color: var(--foreground); }
  .week-meta { color: var(--muted-foreground); font-size: 12px; margin-left: auto; }
  .week-body { padding: 0 12px 8px; background: var(--background); }

  /* ── Day toggle ──────────────────────────────────────────── */
  .day-head {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    margin: 6px 0 0;
    padding: 8px;
    border-top: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    transition: background var(--duration-fast) var(--ease-out);
  }
  .day-head:hover { background: var(--muted); }
  .day-name { font-weight: 500; font-size: 13px; color: var(--foreground); }
  .day-meta { color: var(--muted-foreground); font-size: 12px; margin-left: auto; }

  /* ── Page header ─────────────────────────────────────────── */
  .page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
  }
  .page-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--foreground);
    margin: 0 0 4px;
    line-height: 1.1;
  }
  .page-sub {
    font-size: 13px;
    color: var(--muted-foreground);
    margin: 0;
  }

  /* ── Display board ───────────────────────────────────────── */
  .board-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
  .board-title { font-family: var(--disp); font-weight: 700; font-size: 22px; letter-spacing: -0.02em; color: var(--foreground); }
  .board-title span { color: var(--muted-foreground); font-weight: 300; }
  .board { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }

  .card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    position: relative;
    overflow: hidden;
    box-shadow: none;
  }
  .card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--foreground);
    border-radius: 0 2px 2px 0;
  }
  .card.eig::before { background: hsl(142.1 70.6% 45.3%); }
  .card .who { font-family: var(--disp); font-weight: 700; font-size: 18px; letter-spacing: -0.02em; margin-bottom: 12px; color: var(--foreground); padding-left: 8px; }
  .card .row { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 0; border-top: 1px solid var(--border); }
  .card .k { color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.08em; font-size: 10px; font-weight: 500; }
  .card .v { font-size: 14px; font-weight: 500; text-align: right; color: var(--foreground); }
  .card .stops { color: var(--foreground); font-size: 28px; font-family: var(--disp); font-weight: 700; }
  .card .route { font-size: 13px; color: var(--muted-foreground); text-align: right; max-width: 65%; }

  /* ── Lock / Auth overlay ─────────────────────────────────── */
  .lock-screen {
    position: fixed; inset: 0;
    background: hsl(0 0% 100% / 0.92);
    backdrop-filter: blur(4px);
    z-index: 60;
    display: none;
    align-items: center;
    justify-content: center;
  }
  .lock-screen.on { display: flex; }
  html.dark .lock-screen {
    background: hsl(0 0% 4% / 0.92);
  }
  #auth-overlay {
    background: hsl(0 0% 100% / 0.92);
    backdrop-filter: blur(4px);
  }
  html.dark #auth-overlay {
    background: hsl(0 0% 4% / 0.92);
    backdrop-filter: blur(4px);
  }

  /* ── Privacy mode — blur sensitive financial values ─────── */
  .pv { transition: none; }
  body.privacy-mode span.pv { font-size: 0; user-select: none; pointer-events: none; cursor: not-allowed; white-space: nowrap; }
  body.privacy-mode span.pv::before { content: '***'; font-size: 14px; color: inherit; }
  body.privacy-mode input.pv-field { color: transparent; background: repeating-linear-gradient(90deg,var(--muted-foreground) 0 6px,transparent 6px 9px) center/auto 2px no-repeat; }

  /* ── Display mode overrides ──────────────────────────────── */
  body.display-mode nav.nav,
  body.display-mode #view-admin,
  body.display-mode #view-beheer,
  body.display-mode #view-uren,
  body.display-mode #view-kosten,
  body.display-mode #view-dashboard,
  body.display-mode #view-maand,
  body.display-mode #logout-btn,
  body.display-mode #lock-btn,
  body.display-mode #save-btn,
  body.display-mode .board-controls { display: none !important; }
  body.display-mode .wrap { max-width: none; }

  /* ── Responsive ──────────────────────────────────────────── */
  @media (max-width: 820px) {
    .grid { grid-template-columns: 1fr; }
    .wrap { display: block; }
    nav.nav {
      position: fixed;
      left: 0;
      right: 0;
      bottom: 0;
      z-index: 45;
      height: calc(68px + env(safe-area-inset-bottom));
      border-right: none;
      border-top: 1px solid var(--border);
      border-bottom: none;
      padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
      flex-direction: row;
      flex-wrap: nowrap;
      gap: 2px;
      overflow-x: auto;
      overflow-y: hidden;
      background: color-mix(in srgb, var(--background) 94%, transparent);
      backdrop-filter: blur(12px);
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
    }
    nav.nav::-webkit-scrollbar { display: none; }
    .nav-head { display: none; }
    .nav-group-label { display: none; }
    nav.nav button,
    body.menu-collapsed nav.nav button {
      width: 76px;
      min-width: 76px;
      height: 54px;
      padding: 5px 4px;
      justify-content: center;
      flex-direction: column;
      gap: 2px;
      font-size: 10px;
      text-align: center;
    }
    nav.nav button .nav-icon { width: auto; font-size: 17px; line-height: 1; }
    main.app-main { padding: 16px 12px calc(92px + env(safe-area-inset-bottom)); }
    body.menu-collapsed .wrap { display: block; }
    body.menu-collapsed nav.nav button span:not(.nav-icon) { display: inline; }
  }
  /* ── Dashboard ──────────────────────────────────────── */
  .dash-kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 20px;
  }
  @media (max-width: 900px) {
    .dash-kpi-grid { grid-template-columns: repeat(3, 1fr); }
  }
  @media (max-width: 600px) {
    .dash-kpi-grid { grid-template-columns: repeat(2, 1fr); }
  }

  .dash-kpi-card {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--shadow-card);
  }
  .dash-kpi-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted-foreground);
  }
  .dash-kpi-value {
    font-family: var(--mono);
    font-size: 36px;
    font-weight: 700;
    color: var(--foreground);
    line-height: 1.1;
  }
  .dash-kpi-value.muted {
    font-size: 28px;
    color: var(--muted-foreground);
  }
  .dash-kpi-trend {
    font-size: 12px;
    color: var(--muted-foreground);
  }
  .dash-kpi-trend.up   { color: #16a34a; }
  .dash-kpi-trend.down { color: var(--destructive); }

  .dash-two-col {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 16px;
  }
  @media (max-width: 820px) {
    .dash-two-col { grid-template-columns: 1fr; }
  }

  .dash-panel {
    background: var(--surface-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 0;
    box-shadow: var(--shadow-sm);
  }
  .dash-panel-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted-foreground);
    padding: 12px 16px 8px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-table-head);
  }
  .dash-panel-body {
    padding: 12px 16px;
  }

  /* Top-5 driver progress bar */
  .dash-driver-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
  }
  .dash-driver-bar:last-child { border-bottom: none; }
  .dash-driver-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dash-driver-stops { font-family: var(--mono); font-size: 13px; font-weight: 600; width: 44px; text-align: right; flex-shrink: 0; }
  .dash-driver-pct-wrap { width: 80px; flex-shrink: 0; }
  .dash-driver-pct-track { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
  .dash-driver-pct-fill  { height: 6px; border-radius: var(--radius-xs); background: var(--foreground); transition: width var(--duration-base) var(--ease-out); }

  /* Week trend bars */
  .dash-week-chart { display: flex; align-items: flex-end; gap: 4px; height: 108px; }
  .dash-week-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
  .dash-week-bar-fill { width: 100%; border-radius: var(--radius-xs) var(--radius-xs) 0 0; min-height: 2px; transition: height var(--duration-base) var(--ease-out); }
  .dash-week-label { font-size: 10px; color: var(--muted-foreground); }
  .dash-week-label.today { color: var(--foreground); font-weight: 600; }
  .dash-week-count { font-size: 10px; color: var(--muted-foreground); font-family: var(--mono); min-height: 13px; }

  /* Claims block */
  .dash-claims-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 4px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
  }
  .dash-claims-row:last-child { border-bottom: none; }
  .dash-claims-key { color: var(--muted-foreground); font-size: 12px; }
  .dash-claims-val { font-family: var(--mono); font-weight: 600; }
/* ── Maandverwerking tabs ── */
.maand-tabs{display:flex;gap:0;border-bottom:1px solid var(--border);padding:0 24px;margin-bottom:0;}
.maand-tab{background:none;border:none;border-bottom:2px solid transparent;padding:10px 16px;font-size:13px;font-weight:500;color:var(--muted-foreground);cursor:pointer;margin-bottom:-1px;}
.maand-tab.active{border-bottom-color:var(--brand);color:var(--brand);}
.maand-pane{padding:0;}
/* ── Resultaten month list ── */
.res-month-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  cursor: pointer;
  background: var(--card);
  box-shadow: var(--shadow-xs);
  transition: box-shadow 150ms ease-out, border-color 150ms ease-out;
}
.res-month-row:hover {
  border-color: hsl(240 5.9% 65%);
  box-shadow: var(--shadow-sm);
}
.res-month-label {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--foreground);
  letter-spacing: -0.01em;
}
.res-month-meta {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  margin-top: 3px;
  letter-spacing: 0.01em;
}
.res-month-total {
  font-family: var(--mono);
  font-size: var(--text-md);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--foreground);
  margin-right: 4px;
}
.res-month-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.res-month-chevron {
  color: var(--muted-foreground);
  font-size: 12px;
  margin-left: 2px;
}

/* ── Resultaten detail panel ── */
.res-detail-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px 0;
}
.res-detail-title {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--foreground);
  margin: 0;
}
.res-person-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  margin: 16px 0 0;
}
.res-ptab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 9px 16px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted-foreground);
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 150ms ease-out, border-color 150ms ease-out;
}
.res-ptab:hover { color: var(--foreground); }
.res-ptab.active {
  border-bottom-color: var(--foreground);
  color: var(--foreground);
  font-weight: 600;
}

/* Split layout */
.res-list-detail {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 14px 24px 24px;
  overflow: hidden;
  min-height: 360px;
  box-shadow: var(--shadow-xs);
}
.res-left-list {
  width: 40%;
  border-right: 1px solid var(--border);
  padding: 10px 8px;
  overflow-y: auto;
  background: var(--muted);
}
.res-right-panel {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  background: var(--card);
}

/* Person rows in left list */
.res-person-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 2px;
  cursor: pointer;
  font-size: var(--text-sm);
  transition: background 120ms ease-out;
}
.res-person-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: inherit;
}
.res-person-amount {
  font-family: var(--mono);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.res-person-row:hover { background: var(--border); }
.res-person-row.selected {
  background: var(--result-active);
  color: var(--result-active-foreground);
}
.res-person-spec {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--foreground);
}
.res-person-row.selected .res-person-spec {
  background: transparent;
  border-color: hsl(0 0% 100% / 0.3);
  color: var(--result-active-foreground);
}

/* Right panel: person name header */
.res-person-header {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.res-person-header-name {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--foreground);
  margin: 0 0 2px;
}
.res-person-header-role {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

/* Key-value breakdown */
.res-kv {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0;
  font-size: var(--text-sm);
}
.res-kv span:nth-child(odd) {
  color: var(--muted-foreground);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  padding: 5px 0 5px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}
.res-kv span:nth-child(even) {
  font-family: var(--mono);
  font-size: var(--text-sm);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding: 5px 0 5px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.res-kv span:nth-last-child(-n+2) { border-bottom: none; }

/* Net total */
.res-net-total {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--result-active);
  color: var(--result-active-foreground);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

/* Spec button */
.res-spec-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--foreground);
  padding: 3px 8px;
  border-radius: 5px;
  font-size: var(--text-xs);
  height: auto;
  transition: background 120ms ease-out, color 120ms ease-out;
}
.res-spec-btn:hover { background: var(--muted); color: var(--foreground); }

/* Claims section */
.res-claim-row {
  display: grid;
  grid-template-columns: auto minmax(180px,1fr) minmax(100px,1fr) auto auto;
  align-items: center;
  gap: 4px 10px;
  margin-top: 5px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.res-claim-code { font-family: var(--mono); color: var(--foreground); overflow-wrap: anywhere; word-break: break-word; }
.res-claim-remove {
  background: transparent;
  border: 1px solid var(--destructive);
  color: var(--destructive);
  padding: 4px 9px;
  height: auto;
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  transition: background 120ms ease-out, color 120ms ease-out;
}
.res-claim-remove:hover { background: var(--destructive); color: var(--destructive-foreground); }
.res-claims-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.res-claims-help { color: var(--muted-foreground); font-size: var(--text-xs); font-weight: 400; text-transform: none; letter-spacing: 0; }
.res-claim-search { margin: 8px 0 4px; height: 32px; font-family: var(--mono); font-size: var(--text-sm); }
.res-claim-row.search-match { background: var(--accent); border-radius: 4px; padding-left: 6px; padding-right: 6px; }
@media (max-width: 600px) {
  body { overflow-x: hidden; }
  header.bar {
    min-height: 52px;
    height: auto;
    padding: 8px 12px;
    flex-wrap: nowrap;
  }
  header.bar .logo { font-size: 14px; white-space: nowrap; }
  .header-actions {
    min-width: 0;
    overflow-x: auto;
    justify-content: flex-end;
    scrollbar-width: none;
  }
  .header-actions::-webkit-scrollbar { display: none; }
  #clock, #sync-status { display: none; }
  .header-actions button { height: 34px; padding: 0 10px; }
  #theme-btn { min-width: 36px; justify-content: center; }
  .page-header { margin-bottom: 16px; }
  .page-title { font-size: 21px; }
  section { margin-bottom: 12px; }
  .head { padding: 12px; flex-wrap: wrap; }
  .head .sub {
    width: 100%;
    margin-left: 32px;
    line-height: 1.4;
  }
  .body { padding: 12px; overflow-x: auto; }
  .grid { gap: 10px; }
  .grid > div:last-child .btn,
  .addrow .btn { width: 100%; justify-content: center; }
  .addrow { gap: 10px; }
  .addrow > div,
  .addrow > div[style] { flex: 1 1 100% !important; min-width: 0 !important; }
  .toolbar { align-items: stretch; gap: 10px; }
  .toolbar > div,
  .toolbar > div[style] { width: 100%; min-width: 0 !important; }
  .toolbar .spacer { display: none; }
  .toolbar > button { flex: 1 1 auto; justify-content: center; }
  .drop { padding: 24px 14px; }
  #maand-pane-verwerken .body > div[style*="display:flex"] { flex-wrap: wrap; }
  #maand-pane-verwerken .body > div[style*="display:flex"] > input,
  #maand-pane-verwerken .body > div[style*="display:flex"] > button { width: 100% !important; }
  .month-head, .week-head, .day-head { align-items: flex-start; flex-wrap: wrap; }
  .month-meta, .week-meta, .day-meta {
    width: calc(100% - 22px);
    margin-left: 22px;
    line-height: 1.35;
  }
  .month-exp { position: absolute; right: 18px; }
  .month-head { position: relative; padding-right: 64px; }
  .month-body { padding: 6px; }
  .week-body { padding: 0 6px 6px; overflow-x: auto; }
  .week-body table { min-width: 760px; }
  .body > table, .scroll table { min-width: 560px; }
  .scroll { max-width: 100%; }
  .dash-kpi-grid { gap: 8px; }
  .dash-kpi-card { padding: 12px; }
  .dash-kpi-value { font-size: 28px; }
  .dash-log-row { grid-template-columns: 42px minmax(90px, 1fr) minmax(80px, 1fr) 34px; }
  .board { grid-template-columns: 1fr; }
  .board-controls { width: 100%; flex-wrap: wrap; }
  .board-controls input, .board-controls button { width: 100% !important; justify-content: center; }
  .maand-tabs, .res-person-tabs { padding: 0 12px; overflow-x: auto; }
  .res-month-row { margin: 0 12px 8px; gap: 10px; }
  .res-month-actions { flex-wrap: wrap; justify-content: flex-end; }
  .res-detail-header { padding: 14px 12px 0; flex-wrap: wrap; }
  .res-list-detail { margin: 12px; min-height: 0; flex-direction: column; }
  .res-left-list { width: 100%; max-height: 220px; border-right: none; border-bottom: 1px solid var(--border); }
  .res-right-panel { width: 100%; }
  .res-claim-row { grid-template-columns: 1fr auto; gap: 4px 8px; }
  .res-claim-code { grid-column: 1 / -1; }
  .res-claims-head { align-items: flex-start; flex-direction: column; }
}

/* ─────────────────────────────────────────────────────────────
   shadcn/ui redesign layer
   Preset: https://ui.shadcn.com/create?preset=b1aJBiRvM
   Decoded: luma + zinc + blue charts + lucide + inter + medium radius.
   Source blocks: dashboard-01, sidebar-07, login-03.
   This layer maps the current static DOM to shadcn component primitives
   without changing IDs, inline handlers, state, sync or calculation logic.
   ───────────────────────────────────────────────────────────── */

@font-face {
  font-family: 'Inter';
  src: url('https://cdn.jsdelivr.net/npm/@fontsource-variable/inter/files/inter-latin-wght-normal.woff2') format('woff2');
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --background: oklch(1 0 0);
  --foreground: oklch(0.141 0.005 285.823);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.141 0.005 285.823);
  --popover: oklch(1 0 0);
  --popover-foreground: oklch(0.141 0.005 285.823);
  --primary: oklch(0.21 0.006 285.885);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.967 0.001 286.375);
  --secondary-foreground: oklch(0.21 0.006 285.885);
  --muted: oklch(0.967 0.001 286.375);
  --muted-foreground: oklch(0.442 0.017 285.786);
  --accent: oklch(0.967 0.001 286.375);
  --accent-foreground: oklch(0.21 0.006 285.885);
  --destructive: oklch(0.577 0.245 27.325);
  --destructive-foreground: oklch(0.985 0 0);
  --border: oklch(0.92 0.004 286.32);
  --input: oklch(0.92 0.004 286.32);
  --ring: oklch(0.552 0.016 285.938);
  --chart-1: oklch(0.623 0.214 259.815);
  --chart-2: oklch(0.546 0.245 262.881);
  --chart-3: oklch(0.488 0.243 264.376);
  --chart-4: oklch(0.424 0.199 265.638);
  --chart-5: oklch(0.379 0.146 265.522);
  --brand: oklch(0.48 0.18 264);
  --brand-foreground: oklch(0.985 0 0);
  --warning: oklch(0.72 0.16 70);
  --warning-foreground: oklch(0.99 0 0);
  --sidebar: oklch(0.985 0 0);
  --sidebar-foreground: oklch(0.141 0.005 285.823);
  --sidebar-primary: var(--primary);
  --sidebar-primary-foreground: var(--primary-foreground);
  --sidebar-accent: var(--accent);
  --sidebar-accent-foreground: var(--accent-foreground);
  --sidebar-border: var(--border);
  --sidebar-ring: var(--ring);
  --radius: 0.625rem;
  --header-height: 3.5rem;
  --sidebar-width: 16rem;

  --font-size-2xs: .6875rem;
  --font-size-xs: .75rem;
  --font-size-sm: .8125rem;
  --font-size-base: .875rem;
  --font-size-md: .9375rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.375rem;
  --font-size-2xl: 2rem;
  --line-tight: 1.2;
  --line-ui: 1.43;
  --line-body: 1.55;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-strong: 650;

  --space-0: 0;
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;

  --radius-xs: calc(var(--radius) - 4px);
  --radius-sm: calc(var(--radius) - 3px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);
  --radius-pill: 999px;

  --duration-fast: 120ms;
  --duration-base: 180ms;
  --duration-slow: 240ms;
  --ease-standard: cubic-bezier(.2, 0, 0, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  --surface-app: oklch(0.974 0.002 286.4);
  --surface-card: linear-gradient(180deg, oklch(1 0 0) 0%, oklch(0.992 0.001 286.4) 100%);
  --surface-card-subtle: linear-gradient(180deg, oklch(0.995 0.001 286.4) 0%, oklch(0.972 0.002 286.4) 100%);
  --surface-panel: color-mix(in oklch, var(--card) 96%, transparent);
  --surface-control: oklch(1 0 0);
  --surface-control-hover: color-mix(in oklch, var(--accent) 72%, var(--card));
  --surface-sidebar: linear-gradient(180deg, oklch(1 0 0) 0%, oklch(0.982 0.002 286.4) 100%);
  --surface-selected: var(--background);
  --surface-table-head: color-mix(in oklch, var(--muted) 84%, var(--card));
  --border-subtle: color-mix(in oklch, var(--border) 72%, transparent);
  --border-strong: color-mix(in oklch, var(--border) 84%, var(--foreground));

  --bg: var(--background);
  --panel: var(--card);
  --panel2: var(--muted);
  --line: var(--border);
  --ink: var(--foreground);
  --dim: var(--muted-foreground);
  --signal: var(--primary);
  --signal2: var(--chart-2);
  --eigen: oklch(0.627 0.194 149.214);
  --bedrijf: var(--chart-1);
  --bad: var(--destructive);
  --soft: var(--accent);
  --warn: oklch(0.973 0.071 103.193);
  --shadow: 0 1px 2px 0 rgb(9 9 11 / .04);
  --shadow-xs: 0 1px 2px 0 rgb(9 9 11 / .04);
  --shadow-sm: 0 2px 5px -3px rgb(9 9 11 / .12);
  --shadow-md: 0 8px 18px -14px rgb(9 9 11 / .28);
  --shadow-card: 0 1px 2px 0 rgb(9 9 11 / .04);
  --shadow-control: 0 1px 2px 0 rgb(9 9 11 / .03);
  --shadow-focus: 0 0 0 3px color-mix(in oklch, var(--ring) 20%, transparent);
  --disp: 'Inter', 'Geist', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

html.dark {
  color-scheme: dark;
  --background: oklch(0.141 0.005 285.823);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.21 0.006 285.885);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.21 0.006 285.885);
  --popover-foreground: oklch(0.985 0 0);
  --primary: oklch(0.92 0.004 286.32);
  --primary-foreground: oklch(0.21 0.006 285.885);
  --secondary: oklch(0.274 0.006 286.033);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.274 0.006 286.033);
  --muted-foreground: oklch(0.705 0.015 286.067);
  --accent: oklch(0.274 0.006 286.033);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --destructive-foreground: oklch(0.985 0 0);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.552 0.016 285.938);
  --brand: oklch(0.60 0.17 264);
  --brand-foreground: oklch(0.985 0 0);
  --warning: oklch(0.78 0.15 70);
  --warning-foreground: oklch(0.21 0.04 70);
  --sidebar: oklch(0.21 0.006 285.885);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-primary: var(--primary);
  --sidebar-primary-foreground: var(--primary-foreground);
  --sidebar-accent: oklch(0.274 0.006 286.033);
  --sidebar-accent-foreground: oklch(0.985 0 0);
  --sidebar-border: var(--border);
  --sidebar-ring: var(--ring);
  --surface-app: oklch(0.141 0.005 285.823);
  --surface-card: linear-gradient(180deg, oklch(0.224 0.006 286.033) 0%, oklch(0.192 0.006 285.885) 100%);
  --surface-card-subtle: linear-gradient(180deg, oklch(0.24 0.006 286.033) 0%, oklch(0.176 0.006 285.885) 100%);
  --surface-panel: color-mix(in oklch, var(--card) 90%, transparent);
  --surface-control: oklch(0.21 0.006 285.885);
  --surface-control-hover: color-mix(in oklch, var(--accent) 82%, var(--card));
  --surface-sidebar: linear-gradient(180deg, oklch(0.21 0.006 285.885) 0%, oklch(0.164 0.006 285.823) 100%);
  --surface-selected: oklch(0.274 0.006 286.033);
  --surface-table-head: color-mix(in oklch, var(--muted) 78%, var(--card));
  --border-subtle: color-mix(in oklch, var(--border) 74%, transparent);
  --border-strong: color-mix(in oklch, var(--border) 70%, var(--foreground));
  --shadow: 0 1px 2px 0 rgb(0 0 0 / .28);
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / .24);
  --shadow-sm: 0 2px 5px -3px rgb(0 0 0 / .48);
  --shadow-md: 0 10px 20px -14px rgb(0 0 0 / .7);
  --shadow-card: 0 1px 2px 0 rgb(0 0 0 / .28);
  --shadow-control: 0 1px 2px 0 rgb(0 0 0 / .24);
  --shadow-focus: 0 0 0 3px color-mix(in oklch, var(--ring) 28%, transparent);
}

body {
  background: var(--surface-app);
  color: var(--foreground);
  font-family: var(--disp);
  font-size: var(--font-size-base);
  line-height: var(--line-body);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; }
textarea {
  background: var(--surface-control);
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  color: var(--foreground);
  min-height: 2.25rem;
  padding: var(--space-2) var(--space-3);
  outline: none;
  transition: border-color var(--duration-base) var(--ease-out), box-shadow var(--duration-base) var(--ease-out);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: var(--shadow-focus);
}

.wrap {
  max-width: none;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  background: var(--surface-app);
}

header.bar {
  height: var(--header-height);
  min-height: var(--header-height);
  padding: 0 var(--space-4);
  background: var(--surface-panel);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-base);
  font-weight: var(--weight-strong);
  letter-spacing: -0.015em;
}
.logo::before {
  content: "";
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-md);
  background: var(--primary);
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--primary-foreground) 14%, transparent);
}
.tag {
  color: var(--muted-foreground);
  font-size: var(--font-size-xs);
}
.env-badge,
#maand-result-badge {
  align-items: center;
  border: 1px solid var(--border);
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-radius: var(--radius-md);
  font-size: var(--font-size-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0;
  padding: .125rem var(--space-2);
}
.env-badge.show { display: inline-flex; }

nav.nav {
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  background: var(--surface-sidebar);
  color: var(--sidebar-foreground);
  border-right: 1px solid var(--sidebar-border);
  padding: var(--space-3);
  gap: .125rem;
}
.nav-head {
  min-height: 2.5rem;
  padding: 0 var(--space-1) var(--space-3);
  border-bottom: 1px solid var(--sidebar-border);
}
.nav-title {
  color: var(--sidebar-foreground);
  font-size: var(--font-size-base);
  font-weight: var(--weight-strong);
}
.nav-group-label {
  padding: .875rem .625rem .375rem;
  color: var(--muted-foreground);
  font-size: var(--font-size-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: .02em;
  text-transform: none;
}
.nav-icon {
  width: 1rem;
  height: 1rem;
  display: inline-grid;
  place-items: center;
  color: inherit;
}
.nav-icon svg {
  width: 1rem;
  height: 1rem;
  stroke-width: 2;
}
nav.nav button {
  height: 2rem;
  border-radius: var(--radius-md);
  color: var(--muted-foreground);
  font-size: var(--font-size-base);
  font-weight: var(--weight-medium);
  padding: 0 .625rem;
  gap: .625rem;
  border: 1px solid transparent;
  transition: background-color var(--duration-base) var(--ease-out), color var(--duration-base) var(--ease-out);
}
nav.nav button.active,
nav.nav button:not(.active):hover {
  background: var(--sidebar-accent);
  color: var(--sidebar-accent-foreground);
}
nav.nav button.active {
  font-weight: var(--weight-semibold);
}
body.menu-collapsed .wrap { grid-template-columns: 4rem minmax(0, 1fr); }
body.menu-collapsed nav.nav { padding-inline: .5rem; }
body.menu-collapsed nav.nav button { height: 2.25rem; }

main.app-main {
  padding: var(--space-4);
  background: var(--surface-app);
}
.view.on {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.page-header {
  min-height: 3.25rem;
  align-items: center;
  margin: 0;
  padding: var(--space-1) var(--space-1) var(--space-2);
}
.page-title {
  font-size: var(--font-size-xl);
  font-weight: var(--weight-strong);
  line-height: var(--line-tight);
  letter-spacing: -0.025em;
  text-wrap: balance;
}
.page-sub {
  color: var(--muted-foreground);
  font-size: var(--font-size-base);
  text-wrap: pretty;
}

section,
.dash-panel,
.dash-kpi-card,
.res-month-row,
.res-list-detail,
.month,
.week,
.card {
  background: var(--surface-card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
section {
  margin: 0;
  overflow: hidden;
}
.head,
.dash-panel-title {
  min-height: 3.25rem;
  padding: var(--space-4) var(--space-5);
  background: color-mix(in oklch, var(--card) 72%, transparent);
  border-bottom: 1px solid var(--border);
}
.head .n {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-xs);
  background: var(--secondary);
  color: var(--secondary-foreground);
  border: 1px solid var(--border);
  font-size: var(--font-size-xs);
}
.head h2 {
  color: var(--card-foreground);
  font-size: var(--font-size-md);
  font-weight: var(--weight-strong);
  line-height: var(--line-tight);
}
.head .sub {
  color: var(--muted-foreground);
  font-size: var(--font-size-sm);
}
.body {
  padding: var(--space-5);
}

label {
  color: var(--foreground);
  font-size: var(--font-size-sm);
  font-weight: var(--weight-medium);
  line-height: 1.25rem;
  margin-bottom: .375rem;
}
input,
select {
  height: 2.25rem;
  background: var(--surface-control);
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  color: var(--foreground);
  font-size: var(--font-size-base);
  padding: 0 var(--space-3);
  box-shadow: var(--shadow-control);
}
input::placeholder,
textarea::placeholder {
  color: color-mix(in oklch, var(--muted-foreground) 82%, var(--foreground));
}
input[readonly] {
  background: var(--muted);
  color: var(--muted-foreground);
}

button {
  height: 2.25rem;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: var(--weight-medium);
  padding: 0 .875rem;
}
.btn {
  background: var(--brand);
  color: var(--brand-foreground);
  border: 1px solid var(--brand);
}
.btn:hover {
  background: color-mix(in oklch, var(--brand) 90%, var(--foreground));
  border-color: color-mix(in oklch, var(--brand) 90%, var(--foreground));
}
.btn:disabled {
  opacity: .5;
  background: var(--brand);
  color: var(--brand-foreground);
  border-color: var(--brand);
}
.ghost {
  background: var(--surface-control);
  color: var(--foreground);
  border: 1px solid var(--border);
}
.ghost:hover {
  background: var(--surface-control-hover);
  color: var(--accent-foreground);
}
.btn:active,
.ghost:active {
  transform: none;
}

.grid {
  grid-template-columns: minmax(8rem, .8fr) minmax(10rem, 1fr) minmax(12rem, 1.1fr) minmax(12rem, 1.1fr) minmax(6rem, .7fr) auto auto;
  gap: .875rem;
}
.toolbar,
.addrow {
  gap: var(--space-3);
}

.scroll {
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  border: 1px solid var(--border);
}
table {
  font-size: var(--font-size-sm);
}
th {
  height: 2.5rem;
  color: var(--muted-foreground);
  background: var(--surface-table-head);
  font-size: var(--font-size-xs);
  font-weight: var(--weight-medium);
  padding: .625rem var(--space-3);
}
td {
  padding: .625rem var(--space-3);
}
tr:hover td {
  background: color-mix(in oklch, var(--muted) 62%, transparent);
}
td input,
td select {
  height: 2rem;
  font-size: var(--font-size-sm);
}

.pill {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--secondary);
  color: var(--secondary-foreground);
  font-weight: var(--weight-medium);
}
.pill.e {
  background: color-mix(in oklch, var(--eigen) 12%, var(--card));
  color: color-mix(in oklch, var(--eigen) 72%, var(--foreground));
  border-color: color-mix(in oklch, var(--eigen) 30%, var(--border));
}
.pill.b {
  background: color-mix(in oklch, var(--chart-1) 12%, var(--card));
  color: color-mix(in oklch, var(--chart-1) 70%, var(--foreground));
  border-color: color-mix(in oklch, var(--chart-1) 30%, var(--border));
}

.drop {
  background: var(--surface-card-subtle);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--muted-foreground);
}
.drop.hot {
  background: color-mix(in oklch, var(--chart-1) 9%, var(--card));
  border-color: var(--chart-1);
  color: var(--foreground);
}
.status {
  background: var(--surface-card-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--foreground);
}
.legend,
.empty {
  color: var(--muted-foreground);
}

.month-head,
.week-head,
.day-head {
  background: transparent;
}
.month-head:hover,
.week-head:hover,
.day-head:hover {
  background: var(--surface-control-hover);
}
.month-body,
.res-left-list {
  background: var(--surface-card-subtle);
}

.dash-kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--space-4);
}
.dash-kpi-card {
  padding: var(--space-5);
  gap: var(--space-2);
}
.dash-kpi-label,
.dash-panel-title {
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--font-size-sm);
  font-weight: var(--weight-medium);
}
.dash-kpi-value {
  color: var(--foreground);
  font-size: var(--font-size-2xl);
  letter-spacing: -0.03em;
}
.dash-driver-pct-fill {
  background: var(--brand) !important;
}
.dash-kpi-trend.up { color: var(--eigen); }
.dash-kpi-trend.down { color: var(--destructive); }

.maand-tabs,
.res-person-tabs {
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--border);
}
.maand-tab,
.res-ptab {
  height: 2.5rem;
  border-radius: 0;
  color: var(--muted-foreground);
}
.maand-tab.active,
.res-ptab.active {
  border-bottom-color: var(--brand);
  color: var(--brand);
}

.res-month-row:hover {
  border-color: var(--ring);
  box-shadow: var(--shadow-sm);
}
.res-person-row {
  border-radius: var(--radius-md);
}
.res-person-row:hover {
  background: var(--surface-control-hover);
}
.res-person-row.selected,
.res-net-total {
  background: var(--primary);
  color: var(--primary-foreground);
}
.res-spec-btn,
.res-person-spec {
  border-radius: var(--radius-md);
}

/* shadcn/ui component coverage pass:
   map the app's legacy micro-controls to Button, Checkbox, Tabs and Badge
   primitives without changing DOM handlers. */
button,
.month-exp,
.res-spec-btn,
.res-claim-remove,
.claim-toggle,
.x {
  -webkit-tap-highlight-color: transparent;
}

button:not(:disabled),
[role="button"]:not(:disabled),
.month-exp,
.x {
  cursor: pointer;
}

.header-actions .ghost,
.nav-toggle,
#privacy-btn,
#theme-btn {
  justify-content: center;
}

#privacy-btn,
#theme-btn,
.nav-toggle {
  width: 2.25rem;
  min-width: 2.25rem;
  padding: 0;
}

button svg,
.ghost svg,
.btn svg {
  width: 1rem;
  height: 1rem;
  pointer-events: none;
}

.month-exp,
.res-spec-btn,
.res-person-spec,
.res-claim-remove,
button[data-beheer-action],
button[data-agenda-action],
[data-unmatched-action="save-entry"],
.claim-toggle {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  height: 2rem !important;
  min-height: 2rem;
  padding: 0 var(--space-3) !important;
  border-radius: var(--radius-md) !important;
  border: 1px solid var(--border) !important;
  background: var(--surface-control) !important;
  color: var(--foreground) !important;
  font-size: var(--font-size-sm) !important;
  font-weight: var(--weight-medium) !important;
  line-height: 1 !important;
  text-transform: none;
  letter-spacing: 0;
  box-shadow: var(--shadow-control);
  transition:
    background-color var(--duration-base) var(--ease-out),
    border-color var(--duration-base) var(--ease-out),
    color var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out);
}

.month-exp:hover,
.res-spec-btn:hover,
.res-person-spec:hover,
button[data-beheer-action]:hover,
button[data-agenda-action]:hover,
[data-unmatched-action="save-entry"]:hover,
.claim-toggle:hover {
  background: var(--surface-control-hover) !important;
  color: var(--accent-foreground) !important;
}

.claim-toggle[style*="#ef4444"],
.res-claim-remove,
button[title="Verwijder maand"],
button[data-agenda-action="del"],
button.x,
td.x {
  border-color: color-mix(in oklch, var(--destructive) 28%, var(--border)) !important;
  color: var(--destructive) !important;
  background: var(--surface-control) !important;
}

.claim-toggle[style*="#ef4444"]:hover,
.res-claim-remove:hover,
button[title="Verwijder maand"]:hover,
button[data-agenda-action="del"]:hover,
button.x:hover {
  background: var(--destructive) !important;
  border-color: var(--destructive) !important;
  color: var(--destructive-foreground) !important;
}

.claim-toggle[style*="var(--foreground)"] {
  background: var(--secondary) !important;
  border-color: var(--border) !important;
  color: var(--secondary-foreground) !important;
}

.res-month-actions .ghost {
  height: 2rem !important;
  padding: 0 var(--space-3) !important;
  font-size: var(--font-size-sm) !important;
}

.res-month-actions button[title="Verwijder maand"] {
  width: 2rem !important;
  min-width: 2rem;
  padding: 0 !important;
}

td.x,
button.x {
  position: relative;
  width: 2rem;
  min-width: 2rem;
  height: 2rem;
  padding: 0 !important;
  text-align: center;
  vertical-align: middle;
  color: transparent !important;
  user-select: none;
}

td.x::before,
button.x::before {
  content: "×";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid color-mix(in oklch, var(--destructive) 28%, var(--border));
  border-radius: var(--radius-sm);
  background: var(--surface-control);
  color: var(--destructive);
  font-size: 1rem;
  font-weight: var(--weight-medium);
  line-height: 1;
  transition:
    background-color var(--duration-base) var(--ease-out),
    border-color var(--duration-base) var(--ease-out),
    color var(--duration-base) var(--ease-out);
}

td.x:hover::before,
button.x:hover::before {
  background: var(--destructive);
  border-color: var(--destructive);
  color: var(--destructive-foreground);
}

input[type="checkbox"] {
  appearance: none;
  display: inline-grid;
  place-content: center;
  width: 1rem;
  height: 1rem;
  min-width: 1rem;
  padding: 0;
  margin: 0;
  border-radius: var(--radius-xs);
  border: 1px solid var(--input);
  background: var(--surface-control);
  color: var(--primary-foreground);
  box-shadow: none;
  vertical-align: middle;
  transition:
    background-color var(--duration-base) var(--ease-out),
    border-color var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out);
}

input[type="checkbox"]::before {
  content: "";
  width: .625rem;
  height: .625rem;
  transform: scale(0);
  clip-path: polygon(14% 44%, 0 65%, 43% 100%, 100% 16%, 79% 0, 39% 62%);
  background: currentColor;
  transition: transform 120ms ease-out;
}

input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
}

input[type="checkbox"]:checked::before {
  transform: scale(1);
}

input[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: .5;
}

label:has(input[type="checkbox"]) {
  display: inline-flex !important;
  align-items: center;
  gap: var(--space-2) !important;
  color: var(--foreground);
}

.maand-tabs,
.res-person-tabs {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: calc(100% - 2.5rem);
  gap: var(--space-1);
  margin: var(--space-4) var(--space-5) 0;
  padding: var(--space-1) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-card-subtle);
}

.maand-tab,
.res-ptab {
  height: 2rem;
  border: 0 !important;
  border-radius: var(--radius-sm) !important;
  background: transparent;
  color: var(--muted-foreground);
  padding: 0 var(--space-3);
  margin: 0;
  box-shadow: none;
}

.maand-tab:hover,
.res-ptab:hover {
  background: color-mix(in oklch, var(--surface-control) 72%, transparent);
  color: var(--foreground);
}

.maand-tab.active,
.res-ptab.active {
  background: var(--surface-selected);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
}

.res-person-tabs {
  margin-top: 1rem;
}

.res-claim-row.search-match {
  background: color-mix(in oklch, var(--chart-1) 10%, var(--card));
  border-radius: var(--radius-md);
}

.dash-kpi-trend,
.res-month-total,
.res-person-amount,
.res-net-total {
  font-variant-numeric: tabular-nums;
}

/* Line-hygiene polish: avoid stacked borders where legacy table cells,
   shadcn-style tabs and nested accordions meet. */
.maand-tabs,
.res-person-tabs {
  border: 0 !important;
  background: var(--muted);
  box-shadow: none;
}

.maand-tab,
.res-ptab {
  box-shadow: none !important;
}

.maand-tab.active,
.res-ptab.active {
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / .04) !important;
}

.res-list-detail {
  margin-top: .75rem;
}

.res-month-row,
.res-list-detail,
.scroll {
  box-shadow: none;
}

.scroll {
  overflow: auto;
}

.scroll table {
  border-collapse: separate;
  border-spacing: 0;
}

.scroll th,
.scroll td {
  border-bottom-color: color-mix(in oklch, var(--border) 72%, transparent);
}

.scroll tr:last-child td {
  border-bottom: 0;
}

.month:has(.month-body) > .month-head,
.week:has(.week-body) > .week-head {
  border-bottom: 1px solid var(--border);
}

.month-body {
  background: color-mix(in oklch, var(--muted) 78%, var(--card));
}

.week-body {
  background: var(--card);
}

.day-head {
  border: 1px solid transparent;
  background: transparent;
}

.day-head.open {
  border-color: var(--border);
  border-bottom-color: transparent;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: var(--background);
}

.day-head.open + table {
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 calc(var(--radius) - 2px) calc(var(--radius) - 2px);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

.day-head.open + table th:first-child {
  border-top-left-radius: 0;
}

.day-head.open + table th:last-child {
  border-top-right-radius: 0;
}

td.x {
  border-color: inherit !important;
  background: transparent !important;
  color: transparent !important;
}

td.x::before {
  margin-inline: auto;
}

td.x:hover {
  background: color-mix(in oklch, var(--muted) 68%, transparent) !important;
}

.card {
  padding: 1rem;
}
/* NB: geen `.card::before { display:none }` — die verbergde de eigenaar-balk op
   het display-bord (groen = eigen bus). De balk-regels staan bij .card::before /
   .card.eig::before in de Display-board sectie hierboven. */
.card .k {
  text-transform: none;
  letter-spacing: 0;
}

#auth-overlay,
.lock-screen {
  background: var(--muted) !important;
  backdrop-filter: none;
}
#auth-overlay > div,
.lock-screen > div {
  background: var(--card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-md) !important;
}

body.privacy-mode input.pv-field {
  color: transparent;
  text-shadow: 0 0 .5rem var(--muted-foreground);
  background: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

@media (max-width: 820px) {
  .wrap { display: block; }
  main.app-main { padding: .875rem .75rem calc(5.75rem + env(safe-area-inset-bottom)); }
  nav.nav {
    top: auto;
    background: color-mix(in oklch, var(--sidebar) 94%, transparent);
  }
  .view.on { gap: .875rem; }
  .grid { grid-template-columns: 1fr; }
}

.recon-table{width:100%;border-collapse:collapse;font-size:13px}
.recon-table td{padding:6px 8px;border-bottom:1px solid var(--border)}
.recon-table td:nth-child(2){font-variant-numeric:tabular-nums;color:var(--muted-foreground)}
.recon-ok{color:var(--brand)}
.recon-warn{color:var(--warning);font-weight:600}
.recon-note{color:var(--muted-foreground);font-size:12px}
.recon-empty{font-size:13px;color:var(--muted-foreground);padding:6px 0}

.mobile-more-toggle,
.mobile-actions-toggle,
.mobile-nav-drawer {
  display: none;
}

.mobile-actions-menu {
  display: contents;
}

.save-actions {
  display: contents;
}

/* Mobile contract: keep this layer last so desktop component rules cannot
   shrink touch targets or restore wide layouts after the responsive rules. */
@media (max-width: 820px) {
  html {
    scroll-padding-bottom: calc(6rem + env(safe-area-inset-bottom));
  }

  body {
    min-width: 0;
    overflow-x: hidden;
  }

  .wrap,
  body.menu-collapsed .wrap {
    display: block;
    min-width: 0;
  }

  header.bar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: auto;
    min-height: calc(3.25rem + env(safe-area-inset-top));
    padding: max(.5rem, env(safe-area-inset-top)) .75rem .5rem;
    gap: .5rem;
  }

  .header-actions {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .header-actions::-webkit-scrollbar,
  nav.nav::-webkit-scrollbar {
    display: none;
  }

  nav.nav,
  body.menu-collapsed nav.nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
    height: calc(4.5rem + env(safe-area-inset-bottom));
    padding: .375rem .5rem calc(.375rem + env(safe-area-inset-bottom));
    flex-direction: row;
    flex-wrap: nowrap;
    gap: .125rem;
    overflow-x: hidden;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    border: 0;
    border-top: 1px solid var(--sidebar-border);
    background: color-mix(in oklch, var(--sidebar) 94%, transparent);
    backdrop-filter: blur(12px);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .nav-head,
  .nav-group-label {
    display: none;
  }

  nav.nav button,
  body.menu-collapsed nav.nav button {
    display: inline-flex;
    width: auto;
    min-width: 0;
    height: 3.5rem;
    padding: .25rem;
    flex: none;
    flex-direction: column;
    justify-content: center;
    gap: .1875rem;
    border-radius: var(--radius-md);
    font-size: .6875rem;
    line-height: 1.1;
    text-align: center;
  }

  nav.nav > button[data-view] {
    display: none;
  }

  nav.nav > button[data-view="dashboard"],
  nav.nav > button[data-view="admin"],
  nav.nav > button[data-view="uren"],
  nav.nav > button[data-view="agenda"],
  nav.nav > .mobile-more-toggle {
    display: inline-flex;
  }

  nav.nav button > span:last-child {
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  nav.nav button .nav-icon,
  body.menu-collapsed nav.nav button .nav-icon {
    display: inline-grid;
    width: 1.125rem;
    height: 1.125rem;
    font-size: 1.125rem;
    line-height: 1;
  }

  nav.nav button .nav-icon svg {
    width: 1.125rem;
    height: 1.125rem;
  }

  body.menu-collapsed nav.nav button span:not(.nav-icon) {
    display: inline;
  }

  .mobile-nav-drawer {
    position: fixed;
    inset: 0;
    z-index: 46;
  }

  .mobile-nav-drawer.open {
    display: block;
  }

  .mobile-nav-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgb(0 0 0 / .48);
  }

  .mobile-nav-panel {
    position: absolute;
    right: 0;
    bottom: calc(4.5rem + env(safe-area-inset-bottom));
    left: 0;
    max-height: min(70vh, 32rem);
    padding: .75rem;
    overflow-y: auto;
    border-top: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    background: var(--card);
    box-shadow: 0 -4px 8px rgb(0 0 0 / .12);
  }

  .mobile-nav-panel-head {
    display: flex;
    min-height: 2.75rem;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 .25rem .5rem;
  }

  .mobile-nav-close {
    width: 2.75rem;
    min-width: 2.75rem;
    padding: 0;
    font-size: 1.25rem;
  }

  .mobile-nav-grid {
    display: grid;
    gap: .375rem;
  }

  .mobile-nav-grid button {
    display: grid;
    width: 100%;
    min-height: 3.5rem;
    height: auto;
    padding: .625rem .75rem;
    justify-items: start;
    gap: .125rem;
    border: 1px solid transparent;
    background: transparent;
    color: var(--foreground);
    text-align: left;
  }

  .mobile-nav-grid button small {
    color: var(--muted-foreground);
    font-size: .75rem;
    font-weight: 400;
    line-height: 1.35;
  }

  .mobile-nav-grid button.active {
    border-color: var(--border);
    background: var(--accent);
  }

  body.mobile-menu-open {
    overflow: hidden;
  }

  body.display-mode .mobile-nav-drawer,
  body.display-mode .mobile-actions-toggle,
  body.display-mode .mobile-actions-menu {
    display: none !important;
  }

  main.app-main {
    min-width: 0;
    padding: .875rem .75rem calc(6rem + env(safe-area-inset-bottom));
  }

  .view.on,
  section,
  .body {
    min-width: 0;
  }

  .view.on {
    gap: .875rem;
  }

  .page-header {
    min-height: 0;
    padding: .25rem 0;
  }

  .grid,
  .dash-two-col {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 600px) {
  header.bar .logo {
    font-size: .875rem;
    white-space: nowrap;
  }

  header.bar .logo::before {
    width: 1.25rem;
    height: 1.25rem;
  }

  #clock,
  #sync-status {
    display: none;
  }

  .header-actions {
    overflow: visible;
  }

  .mobile-actions-toggle {
    display: inline-flex;
    width: 2.75rem;
    min-width: 2.75rem;
    padding: 0;
    justify-content: center;
  }

  .mobile-actions-menu {
    position: fixed;
    top: calc(3.75rem + env(safe-area-inset-top));
    right: .75rem;
    z-index: 48;
    display: none;
    min-width: 11rem;
    padding: .375rem;
    flex-direction: column;
    gap: .25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--card);
    box-shadow: var(--shadow-md);
  }

  .mobile-actions-menu.open {
    display: flex;
  }

  .mobile-actions-menu .ghost {
    width: 100%;
    justify-content: flex-start;
  }

  .save-actions {
    display: none;
  }

  .save-actions:has(> #save-btn[style*="inline-block"]) {
    position: fixed;
    right: .75rem;
    bottom: calc(5.25rem + env(safe-area-inset-bottom));
    left: .75rem;
    z-index: 44;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
    padding: .5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--card);
    box-shadow: var(--shadow-md);
  }

  .save-actions:has(> #save-btn[style*="inline-block"]) > button {
    display: inline-flex !important;
    width: 100%;
    justify-content: center;
  }

  body:has(.save-actions > #save-btn[style*="inline-block"]) main.app-main {
    padding-bottom: calc(10rem + env(safe-area-inset-bottom));
  }

  #auth-overlay,
  .lock-screen {
    padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  }

  #auth-overlay > div,
  .lock-screen > div {
    width: 100% !important;
    max-width: 24rem !important;
    max-height: 100%;
    padding: 1.25rem !important;
    overflow-y: auto;
  }

  .page-title {
    font-size: 1.25rem;
  }

  .page-sub {
    margin-top: .25rem;
    line-height: 1.4;
  }

  .head {
    min-height: 0;
    padding: .75rem;
    flex-wrap: wrap;
  }

  .head .sub {
    width: 100%;
    margin-left: 0;
    line-height: 1.4;
    overflow-wrap: anywhere;
  }

  .head h2,
  .page-title,
  .page-sub,
  .legend,
  .status {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .body {
    max-width: 100%;
    padding: .75rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  input,
  select,
  textarea {
    max-width: 100%;
    min-height: 2.75rem;
    font-size: 1rem;
  }

  .grid {
    gap: .625rem;
  }

  .grid > div,
  .grid input,
  .grid select,
  .grid .btn,
  .addrow > div,
  .addrow > div[style],
  .addrow input,
  .addrow select {
    width: 100%;
    min-width: 0 !important;
  }

  .grid .btn,
  .addrow .btn {
    justify-content: center;
  }

  .addrow,
  .toolbar {
    align-items: stretch;
    gap: .625rem;
  }

  .addrow > div,
  .addrow > div[style],
  .toolbar > div,
  .toolbar > div[style] {
    flex: 1 1 100% !important;
    min-width: 0 !important;
  }

  .toolbar .spacer {
    display: none;
  }

  .toolbar > button {
    flex: 1 1 auto;
    justify-content: center;
    white-space: normal;
    text-align: center;
  }

  .body > div[style*="display:flex"] {
    max-width: 100%;
    flex-wrap: wrap;
  }

  .body > div[style*="display:flex"] > div {
    min-width: 0;
  }

  #maand-pane-verwerken .body > div[style*="display:flex"] {
    flex-wrap: wrap;
  }

  #maand-pane-verwerken .body > div[style*="display:flex"] > input,
  #maand-pane-verwerken .body > div[style*="display:flex"] > button {
    width: 100% !important;
  }

  .month-head,
  .week-head,
  .day-head {
    min-height: 2.75rem;
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .month-meta,
  .week-meta,
  .day-meta {
    width: calc(100% - 1.5rem);
    margin-left: 1.5rem;
    line-height: 1.4;
    white-space: normal;
  }

  .month-head {
    position: relative;
    padding-right: 4rem;
  }

  .month-exp {
    position: absolute;
    top: .375rem;
    right: .5rem;
  }

  .month-body,
  .week-body {
    padding: .375rem;
  }

  .week-body,
  .scroll {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .week-body table {
    min-width: 47.5rem;
  }

  .body > table,
  .scroll table {
    min-width: 35rem;
  }

  .dash-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .5rem;
  }

  .dash-kpi-card {
    min-width: 0;
    padding: .75rem;
  }

  .dash-kpi-value {
    font-size: 1.625rem;
    overflow-wrap: anywhere;
  }

  .dash-log-row {
    grid-template-columns: 2.625rem minmax(5.5rem, 1fr) minmax(4.5rem, 1fr) 2.125rem;
  }

  .board {
    grid-template-columns: minmax(0, 1fr);
  }

  .board-controls {
    width: 100%;
    flex-wrap: wrap;
  }

  .board-controls input,
  .board-controls button {
    width: 100% !important;
    justify-content: center;
  }

  .maand-tabs,
  .res-person-tabs {
    display: flex;
    width: auto;
    max-width: none;
    margin: .75rem .75rem 0;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }

  .maand-tab,
  .res-ptab {
    flex: 0 0 auto;
  }

  .res-month-row {
    margin: 0 0 .5rem;
    gap: .625rem;
    flex-wrap: wrap;
  }

  .res-month-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .res-month-total {
    margin-right: auto;
  }

  .res-month-actions .ghost {
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
  }

  .res-detail-header {
    padding: .875rem .75rem 0;
    flex-wrap: wrap;
  }

  .res-list-detail {
    margin: .75rem;
    min-height: 0;
    flex-direction: column;
  }

  .res-left-list,
  .res-right-panel {
    width: 100%;
  }

  .res-left-list {
    max-height: 13.75rem;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .res-claim-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .25rem .5rem;
  }

  .res-claim-code {
    grid-column: 1 / -1;
  }

  .res-claims-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .res-person-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .375rem .5rem;
  }

  .res-person-name {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .res-person-spec {
    grid-column: 1 / -1;
    width: 100%;
  }

  .res-right-panel {
    padding: .75rem;
  }

  .res-kv {
    grid-template-columns: minmax(0, 1fr) minmax(5.5rem, auto);
    column-gap: .75rem;
  }

  .res-kv span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  #modal-actions > button {
    flex: 1 1 100%;
    justify-content: center;
    white-space: normal;
  }

  #toast-container {
    right: .75rem !important;
    bottom: calc(5.25rem + env(safe-area-inset-bottom)) !important;
    left: .75rem;
    max-width: none !important;
  }
}

@media (pointer: coarse) {
  .btn,
  .ghost,
  input,
  select,
  textarea,
  .month-exp,
  .res-spec-btn,
  .res-person-spec,
  .res-claim-remove,
  button[data-beheer-action],
  button[data-agenda-action],
  [data-unmatched-action="save-entry"],
  .claim-toggle {
    min-height: 2.75rem !important;
  }

  td.x,
  button.x {
    width: 2.75rem;
    min-width: 2.75rem;
    height: 2.75rem;
  }

  td.x::before,
  button.x::before {
    width: 2.25rem;
    height: 2.25rem;
  }

  input[type="checkbox"] {
    width: 1.25rem;
    min-width: 1.25rem;
    height: 1.25rem;
    min-height: 1.25rem !important;
  }
}
