/* Yaletree ERP – huisstijl en app-shell.
 *
 * Eén stylesheet voor de kern en alle modules. Modules gebruiken deze componenten en kleuren
 * (var(--…)) en zetten in hun eigen css alleen wat echt bij de module hoort.
 * Licht en donker: de kleuren hieronder; html[data-theme] kiest, zonder attribuut volgt de app het toestel.
 * Geen inline stijlen (CSP), geen framework. Zie layout/ONTWERP.md.
 */

@font-face { font-family: "Inter"; src: url("../fonts/inter-var.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

/* ------------------------------------------------------------------ Kleuren en maten */
:root {
    color-scheme: light;
    /* merk (gelijk aan de website) */
    --brand: #2f6f4f;          /* boomgroen */
    --brand-hover: #245a40;
    --brand-soft: #e4f1e9;
    --brand-ink: #1a4234;      /* groene tekst op lichte grond */
    --leaf: #9be3b4;
    --forest: #123026;         /* zijmenu */
    --forest-2: #1a4234;

    /* vlakken en tekst */
    --bg: #f5f6f3;
    --surface: #ffffff;
    --surface-2: #f0f2ee;      /* kop van tabel, rij bij hover */
    --surface-3: #e6e9e4;
    --text: #17211c;
    --text-2: #3e4a44;
    --muted: #5f6b65;          /* 5,3:1 op wit */
    --border: #dfe3dd;
    --border-strong: #c3cac4;
    --input-border: #8a958f;   /* 3:1 op wit: velden blijven herkenbaar (WCAG 1.4.11) */
    --overlay: rgba(11, 31, 24, .45);

    /* betekenis: tekst (…), achtergrond (…-soft), rand (…-line) */
    --success: #067647;  --success-soft: #e7f7ee;  --success-line: #abe5c4;
    --info: #175cd3;     --info-soft: #eaf3ff;     --info-line: #b2d1fb;
    --warning: #a14a06;  --warning-soft: #fff6e0;  --warning-line: #f6d28b;
    --danger: #b42318;   --danger-soft: #fdeeec;   --danger-line: #f6c2bc;
    --purple: #5925dc;   --purple-soft: #f2efff;   --purple-line: #d2c8fb;
    --neutral: #475467;  --neutral-soft: #eef0f2;  --neutral-line: #d5d9de;

    --primary: var(--brand);   /* oude naam, blijft voor bestaande modules */
    --primary-dark: var(--brand-hover);
    --link: var(--brand);
    --focus: #1f5e40;

    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(16, 32, 25, .06);
    --shadow: 0 1px 2px rgba(16, 32, 25, .05), 0 6px 20px rgba(16, 32, 25, .08);
    --shadow-lg: 0 8px 24px rgba(11, 31, 24, .14), 0 24px 64px rgba(11, 31, 24, .18);

    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --sidebar-w: 248px;
    --sidebar-w-mini: 68px;
    --topbar-h: 56px;
    --tabbar-h: 64px;
    --control-h: 36px;         /* knoppen en velden op pc */
    --gutter: 24px;
}

/* Donker: dezelfde namen, andere waarden. Twee keer: voor "volgt toestel" en voor de keuze "donker". */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --brand: #2f7a55; --brand-hover: #2a6d4b; --brand-soft: #183427; --brand-ink: #9be3b4;
        --forest: #0b1a14; --forest-2: #13281f;
        --bg: #0e1512; --surface: #151e1a; --surface-2: #1b2621; --surface-3: #24312b;
        --text: #e6ebe8; --text-2: #c3ccc7; --muted: #95a39b; --border: #27332d; --border-strong: #3a4842; --input-border: #6b7a72;
        --overlay: rgba(0, 0, 0, .6);
        --success: #6fd49c; --success-soft: #11291d; --success-line: #1f4d35;
        --info: #8bbcff;    --info-soft: #102238;    --info-line: #22426b;
        --warning: #f5b95c; --warning-soft: #2c2010; --warning-line: #5a4120;
        --danger: #ff8f84;  --danger-soft: #33150f;  --danger-line: #66281f;
        --purple: #b8a5ff;  --purple-soft: #1f1838;  --purple-line: #3d3170;
        --neutral: #b5bfc9; --neutral-soft: #1e2529; --neutral-line: #39434a;
        --link: #8fd6a9; --focus: #9be3b4;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
        --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --brand: #2f7a55; --brand-hover: #2a6d4b; --brand-soft: #183427; --brand-ink: #9be3b4;
    --forest: #0b1a14; --forest-2: #13281f;
    --bg: #0e1512; --surface: #151e1a; --surface-2: #1b2621; --surface-3: #24312b;
    --text: #e6ebe8; --text-2: #c3ccc7; --muted: #95a39b; --border: #27332d; --border-strong: #3a4842; --input-border: #6b7a72;
    --overlay: rgba(0, 0, 0, .6);
    --success: #6fd49c; --success-soft: #11291d; --success-line: #1f4d35;
    --info: #8bbcff;    --info-soft: #102238;    --info-line: #22426b;
    --warning: #f5b95c; --warning-soft: #2c2010; --warning-line: #5a4120;
    --danger: #ff8f84;  --danger-soft: #33150f;  --danger-line: #66281f;
    --purple: #b8a5ff;  --purple-soft: #1f1838;  --purple-line: #3d3170;
    --neutral: #b5bfc9; --neutral-soft: #1e2529; --neutral-line: #39434a;
    --link: #8fd6a9; --focus: #9be3b4;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
}

/* Aanraakscherm: grotere raakvlakken (minstens 44 px) en 16 px tekst in velden (geen inzoomen op iOS). */
@media (pointer: coarse) {
    :root { --control-h: 44px; }
}

/* ------------------------------------------------------------------ Basis */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg);
       font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { color: var(--text); letter-spacing: -.01em; }
h1 { font-size: 1.5rem; line-height: 1.25; font-weight: 650; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; line-height: 1.35; font-weight: 620; margin: 0 0 .75rem; }
h3 { font-size: .95rem; font-weight: 620; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
code, .code, kbd { font-family: var(--mono); font-size: .88em; }
kbd { padding: .05rem .35rem; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; color: var(--muted); background: var(--surface); }
img, svg { max-width: 100%; }
.muted { color: var(--muted); font-size: .92em; }
.hint { color: var(--muted); font-size: .86em; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.spaced { margin-top: 1.25rem; }
h2.spaced { margin-top: 1.5rem; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 28px; height: 28px; }

/* Toegankelijkheid: zichtbare focus, overslaan naar inhoud, minder beweging */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip-link { position: absolute; left: 1rem; top: -4rem; z-index: 100; padding: .6rem 1rem; border-radius: var(--radius);
             background: var(--text); color: var(--bg); font-weight: 600; }
.skip-link:focus { top: .75rem; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ------------------------------------------------------------------ App-shell
 * ┌ sidebar ┬ topbar ──────────────────────────────┐
 * │         ├ main ─────────────────────────────────┤
 * │         │                                       │
 * └─────────┴───────────────────────────────────────┘   (gsm: tabbar onderaan)
 */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.shell.is-mini { grid-template-columns: var(--sidebar-w-mini) minmax(0, 1fr); }
.shell-main { display: flex; flex-direction: column; min-width: 0; }
.content { width: 100%; max-width: 1360px; margin: 0 auto; padding: var(--gutter); flex: 1; }
.content.is-wide { max-width: none; }   /* planbord, pipeline, kaart */

/* Zijmenu */
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--forest); color: #dfe9e3;
           border-right: 1px solid rgba(255, 255, 255, .04); z-index: 30; }
.sidebar a { color: inherit; }
.sidebar-brand { display: flex; align-items: center; gap: .65rem; height: var(--topbar-h); padding: 0 1rem; flex: none;
                 color: #fff; font-weight: 700; font-size: 1.05rem; letter-spacing: -.01em; }
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand .logo { width: 30px; height: 30px; flex: none; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .5rem .6rem 1rem; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.nav-link { display: flex; align-items: center; gap: .7rem; min-height: 36px; padding: .4rem .65rem; border-radius: var(--radius-sm);
            color: #cfdcd4; font-size: .93rem; font-weight: 500; line-height: 1.25; }
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-link[aria-current="page"] { background: rgba(155, 227, 180, .14); color: #fff; box-shadow: inset 3px 0 0 var(--leaf); }
.nav-link .icon { color: #9fb8aa; }
.nav-badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--leaf); color: var(--forest);
             font-size: .72rem; font-weight: 700; line-height: 20px; text-align: center; }
.nav-group > summary .nav-badge { margin-right: .25rem; }
.nav-group[open] > summary .nav-badge { display: none; }
.nav-link, .nav-group > summary, .tabbar a { position: relative; }
.shell.is-mini .nav-group[open] > summary .nav-badge { display: block; }
.shell.is-mini .nav-badge { position: absolute; top: 3px; right: 3px; min-width: 8px; height: 8px; padding: 0; overflow: hidden; color: transparent; }
.tab-badge { position: absolute; top: 6px; left: calc(50% + 4px); min-width: 18px; padding: 0 5px; border-radius: 999px; border: 2px solid var(--surface);
             background: var(--danger); color: #fff; font-size: .66rem; font-weight: 700; line-height: 14px; text-align: center; }
.nav-link[aria-current="page"] .icon { color: var(--leaf); }
.nav-group { margin-top: .35rem; }
.nav-group > summary { display: flex; align-items: center; gap: .7rem; min-height: 36px; padding: .4rem .65rem; border-radius: var(--radius-sm);
                       list-style: none; cursor: pointer; color: #e8f0eb; font-size: .93rem; font-weight: 600; user-select: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { background: rgba(255, 255, 255, .07); }
.nav-group > summary .icon { color: #9fb8aa; }
.nav-group > summary .chev { margin-left: auto; width: 16px; height: 16px; transition: transform .15s; opacity: .6; }
.nav-group[open] > summary .chev { transform: rotate(90deg); }
.nav-group.has-active > summary .icon { color: var(--leaf); }
.nav-sub { list-style: none; margin: .1rem 0 .3rem; padding: 0 0 0 1.95rem; position: relative; }
.nav-sub::before { content: ""; position: absolute; left: 1.2rem; top: .2rem; bottom: .2rem; width: 1px; background: rgba(255, 255, 255, .12); }
.nav-sub .nav-link { min-height: 32px; padding: .3rem .6rem; font-size: .9rem; color: #b9cbc0; }
.nav-sub .nav-link[aria-current="page"] { box-shadow: none; }
.nav-sub .nav-link[aria-current="page"]::before { content: ""; position: absolute; left: calc(-.75rem - 1px); top: 50%; width: 3px; height: 18px; margin-top: -9px; border-radius: 2px; background: var(--leaf); }
.nav-sub li { position: relative; }
.sidebar-foot { flex: none; padding: .6rem; border-top: 1px solid rgba(255, 255, 255, .07); }
.sidebar-collapse { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .45rem .65rem; border: 0; border-radius: var(--radius-sm);
                    background: none; color: #9fb8aa; font: inherit; font-size: .86rem; cursor: pointer; }
.sidebar-collapse:hover { background: rgba(255, 255, 255, .07); color: #fff; }

/* Ingeklapt zijmenu (pc): alleen iconen; de groep opent als zwevend paneel */
.shell.is-mini .sidebar-brand span, .shell.is-mini .nav-label, .shell.is-mini .sidebar .chev, .shell.is-mini .sidebar-collapse span { display: none; }
.shell.is-mini .nav-sub .nav-link[aria-current="page"]::before { display: none; }
.shell.is-mini .sidebar-brand { justify-content: center; padding: 0; }
.shell.is-mini .nav-link, .shell.is-mini .nav-group > summary { justify-content: center; padding: .5rem; }
.shell.is-mini .sidebar-nav { overflow: visible; }
.shell.is-mini .nav-group { position: relative; }
.shell.is-mini .nav-group:not(:hover):not(:focus-within) > .nav-sub { display: none; }
.shell.is-mini .nav-group > .nav-sub { position: absolute; left: calc(100% + 6px); top: 0; min-width: 220px; padding: .4rem; margin: 0;
                                         background: var(--forest-2); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.shell.is-mini .nav-group > .nav-sub::before { display: none; }
.shell.is-mini .nav-sub .nav-link { justify-content: flex-start; }
.shell.is-mini .sidebar-collapse { justify-content: center; }
.shell.is-mini .sidebar-collapse .icon { transform: rotate(180deg); }

/* Bovenbalk */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .5rem; height: var(--topbar-h); padding: 0 var(--gutter);
          background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px);
          border-bottom: 1px solid var(--border); }
.icon-btn.topbar-menu { display: none; }
.topbar-brand { display: none; }
.topbar-search { position: relative; flex: 0 1 460px; margin-right: auto; }
.topbar-search .icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.topbar-search input { height: 38px; padding-left: 2.3rem; padding-right: 3.2rem; background: var(--surface-2); border-color: transparent; }
.topbar-search input:hover { border-color: var(--border); }
.topbar-search input:focus { background: var(--surface); }
.topbar-search kbd { position: absolute; right: .6rem; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search-suggest { position: absolute; left: 0; right: 0; top: calc(100% + 6px); padding: .35rem; margin: 0; list-style: none; z-index: 40;
                  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.search-suggest[hidden] { display: none; }
.search-suggest a { display: flex; gap: .6rem; align-items: center; padding: .5rem .6rem; border-radius: var(--radius-sm); color: var(--text); }
.search-suggest a:hover, .search-suggest a[aria-selected="true"] { background: var(--surface-2); text-decoration: none; }
.search-suggest .muted { margin-left: auto; font-size: .8rem; }
.search-suggest-head { padding: .35rem .6rem .2rem; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none;
            border: 0; border-radius: var(--radius); background: none; color: var(--text-2); cursor: pointer; list-style: none; }
.icon-btn::-webkit-details-marker { display: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.dot-count { position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; border: 2px solid var(--surface);
             background: var(--danger); color: var(--surface); font-size: .68rem; font-weight: 700; line-height: 14px; text-align: center; }
.help-btn { display: inline-flex; align-items: center; gap: .45rem; height: 36px; padding: 0 .8rem 0 .65rem; margin: 0 .25rem;
             border: 1px solid var(--brand); border-radius: 999px; background: var(--brand-soft); color: var(--brand-ink);
             font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; }
.help-btn:hover { background: var(--brand); color: #fff; text-decoration: none; }

/* Uitklapmenu's (details/summary werkt zonder JavaScript) */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 240px; padding: .35rem;
              background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.menu-panel.is-wide { width: min(380px, calc(100vw - 24px)); }
.menu-head { display: flex; justify-content: space-between; align-items: center; padding: .5rem .6rem .4rem; font-size: .8rem; color: var(--muted); }
.menu-head strong { font-size: .95rem; color: var(--text); }
.menu-item { display: flex; align-items: center; gap: .6rem; width: 100%; min-height: 38px; padding: .45rem .6rem; border: 0; border-radius: var(--radius-sm);
             background: none; color: var(--text); font: inherit; font-size: .92rem; text-align: left; cursor: pointer; }
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item[aria-current="true"] { font-weight: 600; }
.menu-item[aria-current="true"]::after { content: "✓"; margin-left: auto; color: var(--brand-ink); }
.menu-item .icon { color: var(--muted); }
.menu-sep { height: 1px; margin: .35rem .25rem; background: var(--border); }
.menu-panel form { margin: 0; }
.menu-label { padding: .5rem .6rem .2rem; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.theme-choice { display: grid; grid-template-columns: repeat(3, 1fr); gap: .25rem; padding: .2rem .35rem .35rem; }
.theme-choice button { display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .45rem .2rem; border: 1px solid var(--border);
                       border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2); font: inherit; font-size: .78rem; cursor: pointer; }
.lang-choice { display: grid; grid-template-columns: repeat(4, 1fr); gap: .25rem; padding: .2rem .35rem .35rem; }
.lang-choice button { min-height: 34px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2); font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; }
.lang-choice button[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }
.theme-choice button[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }

/* Organisatie en gebruiker */
.org-btn { display: flex; align-items: center; gap: .55rem; max-width: 240px; height: 40px; padding: 0 .55rem 0 .35rem; border-radius: var(--radius); color: var(--text); }
.org-btn:hover { background: var(--surface-2); }
.org-btn .org-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: .9rem; }
.org-btn .chev { width: 16px; height: 16px; color: var(--muted); }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; flex: none; border-radius: 50%;
          background: var(--brand-soft); color: var(--brand-ink); font-size: .78rem; font-weight: 700; letter-spacing: .02em; }
.avatar.is-org { border-radius: 8px; background: var(--brand); color: #fff; }
.avatar.is-org img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; background: #fff; }
.user-btn { padding: 0; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.user-btn:hover .avatar { box-shadow: 0 0 0 3px var(--surface-3); }

/* Meldingen */
.notif-list { list-style: none; margin: 0; padding: 0; max-height: min(420px, 60vh); overflow-y: auto; }
.notif-list a { display: grid; grid-template-columns: 10px 1fr; gap: .2rem .65rem; padding: .55rem .6rem; border-radius: var(--radius-sm); color: var(--text); font-size: .9rem; }
.notif-list a:hover { background: var(--surface-2); text-decoration: none; }
.notif-list .tone { width: 8px; height: 8px; margin-top: .45rem; border-radius: 50%; background: var(--neutral); }
.notif-list .tone-danger { background: var(--danger); }
.notif-list .tone-warning { background: var(--warning); }
.notif-list .tone-info { background: var(--info); }
.notif-list .tone-success { background: var(--success); }
.notif-list .muted { grid-column: 2; font-size: .8rem; }
.notif-empty { padding: 1.25rem .75rem; text-align: center; color: var(--muted); font-size: .9rem; }

/* Hulppaneel: uitleg bij het scherm en de AI (de coachmodule levert coach/_panel) */
.drawer { position: fixed; inset: 0 0 0 auto; z-index: 60; width: min(420px, 100vw); display: flex; flex-direction: column;
          background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
          transform: translateX(100%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; }
.drawer.is-open { transform: none; visibility: visible; transition: transform .2s ease; }
.drawer-head { display: flex; align-items: center; gap: .6rem; height: var(--topbar-h); padding: 0 .75rem 0 1rem; border-bottom: 1px solid var(--border); flex: none; }
.drawer-head h2 { margin: 0; font-size: 1rem; flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 1rem; }
.backdrop { position: fixed; inset: 0; z-index: 25; background: var(--overlay); opacity: 0; visibility: hidden; transition: opacity .2s, visibility 0s linear .2s; }
.backdrop.is-open { opacity: 1; visibility: visible; transition: opacity .2s; }

/* Zelfuitleg (ONTWERP §10): tooltips, veldhulp en het hulppaneel */
.tooltip { position: fixed; left: 0; top: 0; z-index: 80; max-width: min(280px, calc(100vw - 16px)); padding: .4rem .6rem;
           transform: translate(var(--x, 0), var(--y, 0)); border-radius: 6px; background: var(--text); color: var(--surface);
           font-size: .8rem; font-weight: 500; line-height: 1.35; box-shadow: var(--shadow-lg); pointer-events: auto; }
.tooltip[hidden] { display: none; }
.label-row { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .35rem; }
.label-row > label { margin: 0; }
.field-help { display: contents; }
.field-help > summary { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; list-style: none;
                        color: var(--muted); cursor: pointer; }
.field-help > summary::-webkit-details-marker { display: none; }
.field-help > summary:hover, .field-help[open] > summary { color: var(--brand-ink); background: var(--brand-soft); }
.field-help-body { flex-basis: 100%; margin: .15rem 0 .3rem; padding: .55rem .75rem; border-left: 3px solid var(--brand);
                   border-radius: 0 6px 6px 0; background: var(--brand-soft); color: var(--text); font-size: .86rem; font-weight: 400; line-height: 1.45; }
.field-help-body > :first-child { margin-top: 0; }
.field-help-body > :last-child { margin-bottom: 0; }
.help-page h3, .help-ask h3 { display: flex; align-items: center; gap: .4rem; margin: 0 0 .6rem; font-size: .8rem; font-weight: 650;
                               text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.help-topic { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.help-topic + .help-topic { margin-top: .4rem; }
.help-topic > summary { padding: .6rem .75rem; font-weight: 600; cursor: pointer; }
.help-topic[open] > summary { border-bottom: 1px solid var(--border); }
.help-body { padding: .2rem .75rem .5rem; font-size: .9rem; line-height: 1.5; color: var(--text-2); }
.help-body h4 { margin: .75rem 0 .25rem; font-size: .9rem; color: var(--text); }
.help-more { margin: .6rem 0 0; font-size: .88rem; }
.help-ask { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.help-doc { max-width: 760px; }
.help-doc section { scroll-margin-top: calc(var(--topbar-h) + 1rem); }
.help-doc section + section { margin-top: 1.5rem; }
.help-doc h2 { font-size: 1.1rem; }
.help-doc :target > h2 { color: var(--brand-ink); }
.help-index { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; padding: 0; list-style: none; }
.help-index a { display: block; height: 100%; padding: .9rem 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
.help-index a:hover { border-color: var(--brand); text-decoration: none; }
.help-index strong { display: block; }
.help-index span { font-size: .85rem; color: var(--muted); }
.md-table { border-collapse: collapse; margin: .5rem 0; font-size: .86rem; }
.md-table th, .md-table td { padding: .3rem .5rem; border: 1px solid var(--border); text-align: left; }

/* Onderbalk op de gsm (techniekers) */
.tabbar { display: none; }

/* ------------------------------------------------------------------ Pagina */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-header h1 { margin: 0; }
.page-header .subtitle, .page-header > div > .muted { margin: .25rem 0 0; }
.page-header + .segmented { margin-top: -.5rem; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 .35rem; padding: 0; list-style: none; font-size: .85rem; color: var(--muted); }
.breadcrumb li + li::before { content: "/"; margin-right: .35rem; color: var(--border-strong); }
.breadcrumb a { color: var(--muted); }
.actions, .form-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.actions form, .form-actions form { margin: 0; display: inline-flex; gap: .4rem; align-items: center; }
.toolbar { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar form.inline select, .search select.narrow, .filters select { width: auto; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters input[type=search] { flex: 1; min-width: 220px; }
.inline-form, .form-inline { display: inline-flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.form-inline { display: flex; align-items: flex-end; }
.form-inline label { flex: 1 1 140px; margin: 0; }

/* Tabs binnen een module (bestaande class .segmented) */
.segmented, .tabs { display: flex; gap: .25rem; margin: 0 0 1.25rem; padding: 0; border-bottom: 1px solid var(--border);
                    overflow-x: auto; scrollbar-width: none; background: none; border-radius: 0; }
.segmented::-webkit-scrollbar { display: none; }
.segmented a, .tabs a { position: relative; flex: none; padding: .6rem .8rem; color: var(--muted); font-weight: 550; font-size: .92rem; white-space: nowrap; border: 0; }
.segmented a + a { border-left: 0; }
.segmented a:hover, .tabs a:hover { color: var(--text); text-decoration: none; }
.segmented a.active, .segmented a[aria-current="page"], .tabs a[aria-current="page"] { color: var(--text); background: none; }
.segmented a.active::after, .segmented a[aria-current="page"]::after, .tabs a[aria-current="page"]::after {
    content: ""; position: absolute; left: .5rem; right: .5rem; bottom: -1px; height: 2px; border-radius: 2px; background: var(--brand); }
/* Kleine schakelaar (bv. bord/lijst): .segmented.pills */
.segmented.pills { display: inline-flex; gap: 0; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); margin: 0; }
.segmented.pills a { padding: .3rem .7rem; border-radius: 6px; }
.segmented.pills a.active { background: var(--surface); box-shadow: var(--shadow-sm); }
.segmented.pills a.active::after { display: none; }
.toolbar .segmented { margin: 0; }

/* ------------------------------------------------------------------ Knoppen */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: var(--control-h); padding: 0 .9rem;
       border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text);
       font: inherit; font-size: .92rem; font-weight: 550; line-height: 1.2; white-space: nowrap; cursor: pointer;
       box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger-line); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-danger.btn-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: none; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-small { min-height: 30px; padding: 0 .6rem; font-size: .85rem; }
.btn-large, .trk-big { min-height: 52px; padding: 0 1.25rem; font-size: 1.05rem; }
.btn-block { display: flex; width: 100%; }
.btn-link { min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; color: var(--link); font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }
.btn-link:hover { background: none; }
.btn .icon { width: 18px; height: 18px; }

/* ------------------------------------------------------------------ Panelen, tegels, details */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.1rem 1.25rem; box-shadow: var(--shadow-sm); }
.panel + .panel, .panel + table, table + .panel { margin-top: 1rem; }
.grid-2 > .panel, .grid-3 > .panel, .stack > .panel, .tiles > * { margin-top: 0; }
.grid-2 > *, .grid-3 > *, .stack > * { min-width: 0; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.panel-header h2 { margin: 0; }
.panel > table:last-child { margin-bottom: -.35rem; }
.panel > table { border: 0; box-shadow: none; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 1rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }

/* Tegels (kerngetal). Oud: .cards/.card/.card-value en .mk-tiles/.mk-tile/.mk-tile-n */
.tiles, .cards, .mk-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; margin: 0 0 1.25rem; }
.tile, .card, .mk-tile { position: relative; display: flex; flex-direction: column; gap: .15rem; padding: 1rem 1.1rem; color: var(--muted);
                         background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); font-size: .9rem; }
a.tile:hover, a.card:hover, a.mk-tile:hover { border-color: var(--border-strong); text-decoration: none; box-shadow: var(--shadow); }
.tile-label { order: -1; font-size: .82rem; font-weight: 550; color: var(--muted); }
.tile-value, .card-value, .mk-tile-n { display: block; color: var(--text); font-size: 1.65rem; font-weight: 680; line-height: 1.2; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile-foot { display: flex; align-items: center; gap: .35rem; font-size: .82rem; }
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }
.tile.is-alert { border-color: var(--danger-line); }
.tile.is-alert .tile-value { color: var(--danger); }
.mk-tiles-small .mk-tile-n { font-size: 1.15rem; }

.details { display: grid; grid-template-columns: minmax(110px, 160px) 1fr; gap: .45rem 1rem; margin: 0; }
.details dt { color: var(--muted); font-size: .9rem; }
.details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.notes { white-space: normal; border-top: 1px solid var(--border); padding-top: .75rem; }
ul.plain, ul.timeline, ul.task-list { list-style: none; padding: 0; margin: 0; }
ul.plain li, ul.timeline li, ul.task-list li { padding: .55rem 0; border-bottom: 1px solid var(--border); }
ul.plain li:last-child, ul.timeline li:last-child, ul.task-list li:last-child { border-bottom: 0; }
ul.timeline li.done { opacity: .6; }
ul.task-list li.overdue, .overdue { color: var(--danger); }

/* Lege staat */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .35rem; padding: 2.5rem 1.25rem;
         border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); }
.empty > .icon { width: 40px; height: 40px; padding: 8px; margin-bottom: .35rem; border-radius: 12px; background: var(--brand-soft); color: var(--brand-ink); stroke-width: 1.6; }
.empty h2, .empty h3 { margin: 0; font-size: 1rem; }
.empty p { margin: 0 0 .5rem; max-width: 38ch; color: var(--muted); }

/* ------------------------------------------------------------------ Labels (status) */
.badge, .stage-pill, .temp, .wr-status { display: inline-flex; align-items: center; gap: .3rem; padding: .1rem .55rem; border-radius: 999px;
         border: 1px solid var(--neutral-line); background: var(--neutral-soft); color: var(--neutral);
         font-size: .76rem; font-weight: 600; line-height: 1.5; white-space: nowrap; vertical-align: middle; }
.badge-success, .badge-customer, .badge-good, .stage-pill.won   { background: var(--success-soft); color: var(--success); border-color: var(--success-line); }
.badge-info, .badge-prospect, .badge-service, .stage-pill       { background: var(--info-soft); color: var(--info); border-color: var(--info-line); }
.badge-warning, .badge-supplier, .badge-rental                  { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-line); }
.badge-danger, .badge-error, .stage-pill.lost                   { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.badge-purple, .badge-partner, .badge-project                   { background: var(--purple-soft); color: var(--purple); border-color: var(--purple-line); }
.badge-brand { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ------------------------------------------------------------------ Meldingen in de pagina */
.flash, .alert { display: flex; gap: .65rem; align-items: flex-start; padding: .75rem 1rem; margin-bottom: 1rem; border-radius: var(--radius);
                 border: 1px solid var(--info-line); background: var(--info-soft); color: var(--text); }
.flash::before, .alert::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: .45rem; border-radius: 50%; background: var(--info); }
.flash-success, .alert-success { background: var(--success-soft); border-color: var(--success-line); }
.flash-success::before, .alert-success::before { background: var(--success); }
.flash-error, .alert-danger { background: var(--danger-soft); border-color: var(--danger-line); }
.flash-error::before, .alert-danger::before { background: var(--danger); }
.flash-warning, .alert-warning { background: var(--warning-soft); border-color: var(--warning-line); }
.flash-warning::before, .alert-warning::before { background: var(--warning); }
.flash-close { margin-left: auto; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: .1rem .25rem; }
.toast { position: fixed; bottom: 1rem; right: 1rem; z-index: 70; padding: .75rem 1rem; border-radius: var(--radius); background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); }
.toast.error { background: var(--danger); color: #fff; }

/* ------------------------------------------------------------------ Tabellen */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.table-wrap > table { border: 0; box-shadow: none; border-radius: 0; }
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); font-size: .92rem; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
thead th:first-child { border-top-left-radius: inherit; }
thead th:last-child { border-top-right-radius: inherit; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.list { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
table.list tbody tr:hover td { background: var(--surface-2); }
table.list td a:first-child { font-weight: 550; }
tr.inactive td, tr.not-valid td { color: var(--muted); }
tr.total td, tfoot td { font-weight: 650; background: var(--surface-2); }
tr.row-error td { background: var(--danger-soft); }
table.compact th, table.compact td { padding: .35rem .6rem; }
.search { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.search input { flex: 1; min-width: 200px; }
.pagination { display: flex; gap: 1rem; justify-content: center; align-items: center; margin-top: 1rem; color: var(--muted); font-size: .9rem; }
.pagination a { display: inline-flex; align-items: center; min-height: var(--control-h); padding: 0 .8rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

/* ------------------------------------------------------------------ Formulieren */
input, select, textarea { width: 100%; min-height: var(--control-h); padding: .4rem .65rem; border: 1px solid var(--input-border); border-radius: var(--radius);
                          background: var(--surface); color: var(--text); font: inherit; font-size: .93rem; transition: border-color .12s, box-shadow .12s; }
textarea { min-height: 6rem; line-height: 1.45; resize: vertical; }
select { appearance: none; padding-right: 2rem; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
         background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
select[multiple] { background-image: none; padding-right: .65rem; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:hover, select:hover, textarea:hover { border-color: var(--text-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--brand); box-shadow: none; flex: none; }
input[type=file] { padding: .35rem; }
input[type=color] { padding: .2rem; width: 3.5rem; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
[aria-invalid="true"], .is-invalid { border-color: var(--danger) !important; }
@media (pointer: coarse) { input, select, textarea { font-size: 16px; } }

.form fieldset, .mk-form fieldset { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: .9rem 1rem;
         margin: 0 0 1rem; padding: 1.1rem 1.25rem 1.25rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.mk-form fieldset { display: block; }
.form legend, .mk-form legend { float: left; grid-column: 1 / -1; width: 100%; padding: 0; margin: 0 0 .25rem; font-weight: 650; font-size: 1rem; }
.form legend + * { clear: left; }
.form label, .field { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; font-weight: 550; color: var(--text-2); }
.form label.span-2 { grid-column: span 2; }
.form label.span-full, .form fieldset > .span-full { grid-column: 1 / -1; }
.form label.checkbox, label.checkbox { flex-direction: row; align-items: center; gap: .55rem; font-weight: 450; color: var(--text); }
.form label.checkbox input, label.checkbox input { width: 18px; }
.form .hint { grid-column: 1 / -1; margin: 0; }
.form label .hint { font-weight: 400; }
.required::after { content: " *"; color: var(--danger); }
.field-error { color: var(--danger); font-size: .84rem; font-weight: 500; }
.form-actions { margin-top: .25rem; }
.form-actions.is-sticky { position: sticky; bottom: 0; z-index: 5; margin: 0 calc(var(--gutter) * -1); padding: .75rem var(--gutter);
                          background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); border-top: 1px solid var(--border); }
.readonly-field { font-size: .9em; color: var(--muted); }
.readonly-field strong { color: var(--text); }
.wr-block, .trk-block { display: block; margin: .6rem 0; }
.wr-block input, .wr-block textarea, .wr-block select, .trk-block input { display: block; width: 100%; margin-top: .25rem; }

/* Zoekveld met suggesties (crm/_customer_picker), uit de kern van 28/10 */
.picker { position: relative; display: block; }
.picker-list { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: .25rem; list-style: none;
               background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
               box-shadow: var(--shadow-lg); max-height: 18rem; overflow-y: auto; }
.picker-list li { padding: .45rem .7rem; border-radius: var(--radius-sm); cursor: pointer; color: var(--text); }
.picker-list li small { display: block; color: var(--muted); }
.picker-list li[aria-selected="true"], .picker-list li:hover { background: var(--surface-2); }
.picker-list li.empty { display: block; padding: .45rem .7rem; border: 0; text-align: left; color: var(--muted); cursor: default; background: none; }
.lookup-status { display: block; font-size: .85em; color: var(--muted); min-height: 1.2em; }
.lookup-status.error { color: var(--danger); }
.input-with-button { display: flex; gap: .4rem; }
.input-with-button input { flex: 1; }

/* ------------------------------------------------------------------ Inloggen en keuzepagina */
body.guest { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 1rem;
             background: radial-gradient(1200px 600px at 20% -10%, color-mix(in srgb, var(--brand) 22%, transparent), transparent), var(--bg); }
body.guest .container { width: 100%; max-width: 400px; }
.guest-brand { display: flex; align-items: center; justify-content: center; gap: .6rem; margin-bottom: 1.25rem; font-weight: 700; font-size: 1.2rem; color: var(--text); }
.guest-brand .logo { width: 36px; height: 36px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2rem; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.3rem; }
.auth-card form { display: flex; flex-direction: column; gap: 1rem; }
.auth-card form + form { margin-top: .5rem; }
.auth-card label { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; font-weight: 550; color: var(--text-2); }
.org-choice { width: 100%; min-height: 52px; justify-content: flex-start; gap: .75rem; text-align: left; }
.org-choice strong { flex: 1; }

/* ------------------------------------------------------------------ Gemeenschappelijk uit de CRM (pipeline) */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: .75rem; overflow-x: auto; padding-bottom: .5rem; }
.column { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; min-height: 320px; }
.column header { padding: .65rem .75rem; border-bottom: 3px solid var(--brand); }
.column-won header { border-bottom-color: var(--success); }
.column-lost header { border-bottom-color: var(--danger); }
.column-total, .stage-desc { font-size: .8rem; color: var(--muted); }
.stage-desc { margin: .25rem 0 0; line-height: 1.3; }
.column-body { padding: .5rem; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.column.drop-target { outline: 2px dashed var(--brand); outline-offset: -2px; }
.stage-code { display: inline-block; min-width: 1.5em; margin-right: .2em; padding: 0 .3em; border-radius: 4px; background: var(--brand); color: #fff; font-weight: 700; font-size: .8em; text-align: center; }
.column-won .stage-code { background: var(--success); }
.column-lost .stage-code { background: var(--danger); }
.opp-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .7rem; font-size: .9em; box-shadow: var(--shadow-sm); }
.opp-card[draggable="true"] { cursor: grab; }
.opp-card.dragging { opacity: .5; }
.opp-card.overdue { border-left: 3px solid var(--danger); color: var(--text); }
.opp-title { font-weight: 600; display: block; }
.opp-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 .5rem; margin-top: .25rem; }
.opp-meta strong { white-space: nowrap; }
.opp-meta span, .opp-owner { font-size: .85em; color: var(--muted); }
.opp-next { margin-top: .25rem; font-size: .9em; }
.board-hint { margin: 0 0 .5rem; }
.stage-track { display: flex; list-style: none; padding: 0; margin: 0 0 1rem; gap: 2px; }
.stage-track li { flex: 1; background: var(--surface-3); text-align: center; font-size: .9em; }
.stage-track li:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.stage-track li:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.stage-track li.done { background: var(--brand-soft); }
.stage-track li.current { background: var(--brand); color: #fff; font-weight: 600; }
.stage-track.is-lost li { opacity: .7; }
.stage-track li form { margin: 0; }
.stage-track li button, .stage-track li > span { display: block; width: 100%; padding: .55rem .25rem; background: none; border: 0; font: inherit; color: inherit; cursor: pointer; }
.stage-track li > span { cursor: default; }
.stage-track li.current .stage-code { background: #fff; color: var(--brand); }
.stage-actions { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.stage-actions form { margin: 0; }
.lost-form { display: flex; gap: .5rem; flex: 1; min-width: min(300px, 100%); }

/* ------------------------------------------------------------------ Tablet: zijmenu als lade */
@media (max-width: 1023px) {
    .shell, .shell.is-mini { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); transform: translateX(-100%); visibility: hidden;
               transition: transform .2s ease, visibility 0s linear .2s; box-shadow: var(--shadow-lg); }
    .shell.nav-open .sidebar { transform: none; visibility: visible; transition: transform .2s ease; }
    .sidebar-foot { display: none; }
    .icon-btn.topbar-menu { display: inline-flex; margin-left: -.5rem; }
    .shell.is-mini .sidebar-brand span, .shell.is-mini .nav-label, .shell.is-mini .sidebar .chev { display: initial; }
}

/* ------------------------------------------------------------------ Gsm */
@media (max-width: 719px) {
    :root { --gutter: 16px; --topbar-h: 56px; }
    body { font-size: 16px; }
    h1 { font-size: 1.3rem; }
    .topbar { gap: .15rem; padding: 0 .5rem 0 var(--gutter); }
    .topbar-brand { display: inline-flex; align-items: center; gap: .5rem; margin-right: auto; font-weight: 700; color: var(--text); min-width: 0; }
    .topbar-brand .logo { width: 28px; height: 28px; flex: none; }
    .topbar-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .topbar-search { position: absolute; inset: 0; z-index: 2; display: none; flex: none; padding: 8px var(--gutter); margin: 0; background: var(--surface); }
    .topbar-search.is-open { display: block; }
    .topbar-search .icon { left: calc(var(--gutter) + .7rem); }
    .topbar-search kbd { display: none; }
    .topbar-search input { height: 40px; }
    .search-suggest { left: var(--gutter); right: var(--gutter); }
    .search-toggle { display: inline-flex !important; }
    /* Menu en hulp zitten in de onderbalk ("Meer" en "Hulp") */
    .icon-btn.topbar-menu, .help-btn { display: none; }
    .org-btn .org-name, .org-btn .chev { display: none; }
    .org-btn { padding: 0 .3rem; }
    .content { padding: 1rem var(--gutter) calc(var(--tabbar-h) + 1.5rem + env(safe-area-inset-bottom)); }
    .menu-panel { position: fixed; left: 8px; right: 8px; top: calc(var(--topbar-h) + 4px); width: auto; min-width: 0; }

    .tabbar { position: fixed; inset: auto 0 0 0; z-index: 20; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
              height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
              background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(0, 0, 0, .05); }
    .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .2rem; min-width: 0;
                                border: 0; background: none; color: var(--muted); font: inherit; font-size: .72rem; font-weight: 600; cursor: pointer; }
    .tabbar a:hover { text-decoration: none; }
    .tabbar .icon { width: 24px; height: 24px; }
    .tabbar [aria-current="page"] { color: var(--brand-ink); }
    .tabbar [aria-current="page"] .icon { background: var(--brand-soft); border-radius: 999px; width: 52px; padding: 2px 14px; box-sizing: content-box; margin: -2px 0; }

    .page-header { flex-direction: column; align-items: stretch; }
    .page-header .actions { width: 100%; }
    .page-header .actions > .btn, .page-header .actions > form { flex: 1; }
    .page-header .actions > form .btn { width: 100%; }
    .form-actions .btn-primary { flex: 1; }
    .form label.span-2 { grid-column: auto; }
    .form fieldset { padding: 1rem; }
    .panel { padding: 1rem; border-radius: var(--radius); }
    .tiles, .cards, .mk-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
    .tile, .card, .mk-tile { padding: .8rem .9rem; }
    .tile-value, .card-value, .mk-tile-n { font-size: 1.35rem; }
    .details { grid-template-columns: 1fr; gap: .1rem; }
    .details dd { margin-bottom: .55rem; }
    .grid-2 { grid-template-columns: 1fr; }
    .stage-track { flex-direction: column; }
    .stage-track li { border-radius: 0 !important; }

    /* Lijsten worden kaarten: app.js zet data-label op elke cel en data-stack op de tabel */
    table.list[data-stack] { border: 0; background: none; box-shadow: none; overflow: visible; }
    table.list[data-stack] thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    table.list[data-stack] tbody { display: flex; flex-direction: column; gap: .6rem; }
    table.list[data-stack] tr { display: grid; grid-template-columns: 1fr 1fr; gap: .2rem .75rem; padding: .75rem .9rem;
                                background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
    table.list[data-stack] td { display: block; padding: 0; border: 0; background: none !important; text-align: left; min-width: 0; overflow-wrap: anywhere; }
    table.list[data-stack] td::before { content: attr(data-label); display: block; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
    table.list[data-stack] td:first-child { grid-column: 1 / -1; font-size: 1.02rem; }
    table.list[data-stack] td:first-child::before { display: none; }
    table.list[data-stack] td[data-label=""]::before { display: none; }
    table.list[data-stack] td:empty { display: none; }
    table.list[data-stack] tfoot tr { background: var(--surface-2); }
    table:not([data-stack]) { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .panel-header { flex-wrap: wrap; }
}

/* ------------------------------------------------------------------ Afdrukken */
@media print {
    .sidebar, .topbar, .tabbar, .drawer, .backdrop, .tooltip, .field-help > summary, .skip-link, .actions, .form-actions, .segmented { display: none !important; }
    .shell { display: block; }
    .content { padding: 0; max-width: none; }
    body { background: #fff; color: #000; }
    .panel, table.list, .tile { box-shadow: none; }
}
