/* =====================================================================
 * Migoflow — design tokens + components
 * Modern, neutral, readable.
 * --------------------------------------------------------------------- */

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

:root, [data-theme="light"] {
    /* Surfaces */
    --color-bg: #f3f5f9;
    --color-surface: #ffffff;
    --color-surface-2: #fafafa;
    --color-surface-offset: #f4f4f5;
    --color-surface-dynamic: #e4e4e7;
    --color-divider: #e4e4e7;
    --color-border: #d4d4d8;

    /* Text */
    --color-text: #18181b;
    --color-text-muted: #52525b;
    --color-text-faint: #a1a1aa;
    --color-placeholder: #71717a;

    /* Primary — Rotterdam groen */
    --color-primary: #00811f;
    --color-primary-hover: #00602e;
    --color-primary-soft: #e1efe2;
    --color-primary-text: #00602e;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #00602e 0%, #00811f 40%, #4eb051 100%);
    --gradient-text: linear-gradient(135deg, #00602e, #00811f, #4eb051);
    --gradient-border: linear-gradient(135deg, rgba(0,129,31,0.3), rgba(0,96,46,0.2), rgba(78,176,81,0.3));

    /* Enhanced shadows */
    --shadow-glow: 0 0 20px -5px rgba(0, 129, 31, 0.15);
    --shadow-card-hover: 0 8px 30px rgba(15, 23, 42, 0.08), 0 2px 8px rgba(15, 23, 42, 0.04);
    --shadow-elevated: 0 20px 60px -15px rgba(15, 23, 42, 0.12), 0 8px 20px -8px rgba(15, 23, 42, 0.08);

    /* Semantic */
    --color-success: #047857;
    --color-success-soft: #ecfdf5;
    --color-warning: #b45309;
    --color-warning-soft: #fffbeb;
    --color-danger: #b91c1c;
    --color-danger-soft: #fef2f2;
    --color-info: #0e7490;
    --color-info-soft: #ecfeff;

    /* Effects */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.08), 0 4px 8px rgba(15, 23, 42, 0.04);

    /* Radii — softer, modern */
    --radius-sm: 0.375rem;   /* 6px */
    --radius-md: 0.5rem;     /* 8px */
    --radius-lg: 0.75rem;    /* 12px */
    --radius-xl: 1rem;       /* 16px */
    --radius-2xl: 1.25rem;   /* 20px */
    --radius-full: 9999px;

    /* Spacing scale */
    --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
    --space-4: 1rem;    --space-5: 1.25rem; --space-6: 1.5rem;
    --space-8: 2rem;    --space-10: 2.5rem; --space-12: 3rem;
    --space-16: 4rem;

    /* Type scale */
    --text-xs:   0.8125rem;            /* 13px */
    --text-sm:   0.875rem;             /* 14px */
    --text-base: 0.9375rem;            /* 15px — comfortable reading */
    --text-lg:   1.0625rem;            /* 17px */
    --text-xl:   clamp(1.25rem, 1.05rem + 0.6vw, 1.5rem);
    --text-2xl:  clamp(1.5rem,  1.20rem + 1.0vw, 1.875rem);
    --text-3xl:  clamp(1.875rem, 1.4rem + 1.5vw, 2.5rem);
    --text-4xl:  clamp(2.25rem, 1.6rem + 2vw, 3.25rem);

    --font-body: 'Geist', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'Geist Mono', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    --leading-tight: 1.2;
    --leading-snug:  1.4;
    --leading-base:  1.55;

    --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);

    --topbar-height: 52px;
    --topbar-bg: #00811f;
    --topbar-bg-hover: rgba(255, 255, 255, 0.12);
    --topbar-text: #ffffff;
    --topbar-text-muted: rgba(255, 255, 255, 0.82);
    --topbar-text-faint: rgba(255, 255, 255, 0.68);
    --topbar-accent: #ffffff;
    --topbar-rule: rgba(255, 255, 255, 0.28);
}

[data-theme="dark"] {
    --color-bg: #09090b;
    --color-surface: #111113;
    --color-surface-2: #18181b;
    --color-surface-offset: #1f1f23;
    --color-surface-dynamic: #27272a;
    --color-divider: #27272a;
    --color-border: #2e2e33;

    --color-text: #f4f4f5;
    --color-text-muted: #a1a1aa;
    --color-text-faint: #52525b;
    --color-placeholder: #a1a1aa;

    --color-primary: #4eb051;
    --color-primary-hover: #6bc86e;
    --color-primary-soft: rgba(0, 129, 31, 0.18);
    --color-primary-text: #7dcc80;

    --gradient-primary: linear-gradient(135deg, #00602e 0%, #00811f 40%, #4eb051 100%);
    --gradient-text: linear-gradient(135deg, #4eb051, #6bc86e, #99cca0);
    --gradient-border: linear-gradient(135deg, rgba(78,176,81,0.3), rgba(0,129,31,0.2), rgba(153,204,160,0.3));

    --shadow-glow: 0 0 20px -5px rgba(0, 129, 31, 0.25);
    --shadow-card-hover: 0 8px 30px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-elevated: 0 20px 60px -15px rgba(0, 0, 0, 0.5), 0 8px 20px -8px rgba(0, 0, 0, 0.3);

    --color-success: #34d399;
    --color-success-soft: rgba(16, 185, 129, 0.10);
    --color-warning: #fbbf24;
    --color-warning-soft: rgba(245, 158, 11, 0.10);
    --color-danger: #f87171;
    --color-danger-soft: rgba(239, 68, 68, 0.12);
    --color-info: #67e8f9;
    --color-info-soft: rgba(14, 165, 233, 0.10);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.30), 0 1px 2px rgba(0, 0, 0, 0.20);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.36), 0 2px 4px rgba(0, 0, 0, 0.24);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.50);
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
    color-scheme: light;
}
html[data-theme="dark"] {
    color-scheme: dark;
}
body {
    min-height: 100dvh;
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-base);
    letter-spacing: -0.005em;
    color: var(--color-text);
    background: var(--color-bg);
    display: flex; flex-direction: column;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-hover); text-decoration: underline; text-underline-offset: 2px; }
button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }

/* UPN-canvas: native SVG-maat in een viewport, schaal/pan via transform. */
.upn-viewer {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}
.upn-toolbar {
    scroll-margin-top: 1rem;
}
.upn-canvas-shell {
    overflow: hidden;
    height: calc(100dvh - 320px);
    min-height: 420px;
    max-height: none;
}
.upn-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: grab;
    touch-action: none;
    user-select: none;
    overscroll-behavior: contain;
}
.upn-container.is-panning {
    cursor: grabbing;
}
.upn-container.is-wheel-active {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 20%, transparent);
    outline: 1.5px solid color-mix(in srgb, var(--color-primary) 55%, transparent);
    outline-offset: -1px;
}
.upn-stage {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    will-change: transform;
}
.upn-stage svg {
    display: block;
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    margin: 0;
}
code, pre, kbd { font-family: var(--font-mono); font-size: 0.92em; }

a, button, input, textarea, [role="button"] {
    transition: color var(--transition-fast),
                background-color var(--transition-fast),
                border-color var(--transition-fast),
                box-shadow var(--transition-fast),
                transform var(--transition-fast);
}
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Headings — display weight, tighter tracking */
h1, h2, h3, h4 {
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: var(--leading-tight);
    color: var(--color-text);
}
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-base); font-weight: 600; }
p  { line-height: var(--leading-base); }

/* ----- TOPBAR ------------------------------------------------------- */
.topbar {
    position: sticky; top: 0; z-index: 100;
    flex-shrink: 0;
    height: var(--topbar-height);
    background: var(--topbar-bg);
    color: var(--topbar-text);
    border-bottom: 1px solid #00602e;
    display: flex; align-items: center; gap: 12px;
    padding: 0 16px;
}
.topbar :focus-visible {
    outline-color: var(--topbar-accent);
}
.topbar-logo {
    display: flex; align-items: center; gap: var(--space-2);
    color: var(--topbar-text); flex-shrink: 0;
}
.topbar-logo img {
    height: 26px; width: auto;
    filter: brightness(4) contrast(0.92);
}
.topbar-public .topbar-logo img {
    height: 32px;
}
.topbar-actions {
    display: flex; align-items: center; gap: 4px; margin-left: auto;
}
.topbar-rule {
    width: 1px;
    height: 18px;
    background: var(--topbar-rule);
    margin: 0 6px;
    flex-shrink: 0;
}
.topbar .btn-icon {
    color: var(--topbar-text-muted);
}
.topbar .btn-icon:hover {
    background: var(--topbar-bg-hover);
    color: var(--topbar-text);
}
.topbar-public .btn-ghost {
    color: var(--topbar-text);
}
.topbar-public .btn-ghost:hover {
    background: var(--topbar-bg-hover);
    color: var(--topbar-text);
}
.topbar-public .btn-primary {
    background: var(--topbar-text);
    color: var(--topbar-bg);
    border-color: var(--topbar-text);
}
.topbar-public .btn-primary:hover {
    background: var(--topbar-accent);
    border-color: var(--topbar-accent);
    color: var(--topbar-bg);
}
.btn-icon {
    width: 32px; height: 32px; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    color: var(--color-text-muted);
}
.btn-icon:hover { background: var(--color-surface-offset); color: var(--color-text); }
.avatar {
    width: 32px; height: 32px; border-radius: var(--radius-full);
    background: var(--color-primary-soft); color: var(--color-primary-text);
    display: flex; align-items: center; justify-content: center;
    font-size: var(--text-xs); font-weight: 600;
}

/* ----- LAYOUT ------------------------------------------------------- */
.app-layout { display: flex; flex: 1; min-height: 0; }

.main {
    flex: 1; overflow-y: auto;
    padding: var(--space-10) var(--space-8);
    display: flex; flex-direction: column; gap: var(--space-6);
    max-width: 1100px; width: 100%; margin: 0 auto;
}
/* Wide pages (detail with diagram, edit) follow window width so the
   diagram has room to breathe. Applied via {% block main_class %} in
   base.html. */
.main.main-wide {
    max-width: none;
    padding-left: var(--space-6);
    padding-right: var(--space-6);
}
.main.main-detail,
.main:has(.process-detail-sticky) {
    padding-top: 0;
}
.main.main-flush {
    max-width: none;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: calc(100dvh - var(--topbar-height));
}
.main.main-flush .bpmn-container-flush {
    flex: 1;
    height: auto;
    min-height: 0;
}

@media (max-width: 768px) {
    .main { padding: var(--space-5) var(--space-4); }
    .topbar { padding: var(--space-2) var(--space-3); gap: var(--space-2); }
}

/* ----- CARDS / SURFACES -------------------------------------------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-6) var(--space-8);
    box-shadow: var(--shadow-sm);
}
.card.narrow {
    max-width: 440px; margin: var(--space-12) auto; padding: var(--space-8);
    box-shadow: var(--shadow-lg);
}
.card h1 { margin-bottom: var(--space-2); }
.card h1 + p { color: var(--color-text-muted); margin-bottom: var(--space-5); }
.card h2, .card h3 { margin-top: var(--space-6); margin-bottom: var(--space-2); }

.row-between {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--space-4); flex-wrap: wrap;
}
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--space-4); flex-wrap: wrap;
    margin-bottom: var(--space-2);
}
.page-header h1 {
    font-size: var(--text-2xl);
    margin: 0;
}
.page-header p.muted {
    margin-top: var(--space-1);
    font-size: var(--text-sm);
}
.muted { color: var(--color-text-muted); }
.small { font-size: var(--text-xs); }

/* ----- FORMS -------------------------------------------------------- */
form label {
    display: block; margin-bottom: var(--space-4);
    font-weight: 500; font-size: var(--text-sm);
    color: var(--color-text);
}
form input[type=text],
form input[type=email],
form input[type=password],
form input[type=search],
form textarea {
    display: block; width: 100%; margin-top: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font: inherit; font-size: var(--text-sm);
    background: var(--color-surface); color: var(--color-text);
    line-height: var(--leading-snug);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.03);
}
form textarea { resize: vertical; font-family: inherit; line-height: var(--leading-base); min-height: 6rem; }
form input:hover:not(:focus), form textarea:hover:not(:focus) {
    border-color: color-mix(in srgb, var(--color-primary) 25%, var(--color-border));
}
form input:focus, form textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px var(--color-primary-soft),
                inset 0 1px 2px rgba(15, 23, 42, 0.03);
}
form input::placeholder, form textarea::placeholder { color: var(--color-placeholder); }
.inline-form { display: inline; margin: 0; }

/* ----- BUTTONS ------------------------------------------------------ */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: var(--color-surface-offset);
    color: var(--color-text);
    font: inherit; font-size: var(--text-sm); font-weight: 500;
    line-height: 1.2; cursor: pointer; text-decoration: none;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(0.5px); box-shadow: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }
.btn-lg { padding: var(--space-3) var(--space-5); font-size: var(--text-base); }
.btn-primary {
    background: var(--topbar-bg); color: #fff;
    border-color: transparent;
    box-shadow:
        0 1px 0 rgba(255,255,255,0.10) inset,
        0 1px 2px rgba(0, 129, 31, 0.25),
        0 4px 10px -2px rgba(0, 129, 31, 0.30);
}
.btn-primary:hover {
    background: #00602e; color: #fff;
    transform: translateY(-1px);
    box-shadow:
        0 1px 0 rgba(255,255,255,0.10) inset,
        0 2px 4px rgba(0, 129, 31, 0.30),
        0 8px 18px -4px rgba(0, 129, 31, 0.35);
}
[data-theme="dark"] .btn-primary {
    background: var(--topbar-bg);
    color: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] .btn-primary:hover {
    background: #006e32;
    color: #fff;
}
.btn-lg.btn-primary { padding: var(--space-3) var(--space-6); }
.btn-secondary {
    background: var(--color-surface); color: var(--color-text);
    border-color: var(--color-border);
    box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
    background: var(--color-surface-offset); border-color: var(--color-border);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.btn-ghost { background: transparent; border-color: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { background: var(--color-surface-offset); color: var(--color-text); }
.btn-danger {
    background: var(--color-surface); color: var(--color-danger);
    border-color: var(--color-border);
}
.btn-danger:hover { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-danger-solid {
    background: var(--color-danger); color: #fff;
    border-color: transparent;
}
.btn-danger-solid:hover { background: #991b1b; color: #fff; }

/* ----- ALERTS ------------------------------------------------------- */
.alert {
    padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    font-size: var(--text-sm);
    border: 1px solid transparent;
}
.alert ul { margin: 0; padding-left: var(--space-5); }
.alert-error   { background: var(--color-danger-soft);  color: var(--color-danger);  border-color: color-mix(in srgb, var(--color-danger) 25%, transparent); }
.alert-warn    { background: var(--color-warning-soft); color: var(--color-warning); border-color: color-mix(in srgb, var(--color-warning) 25%, transparent); }
.alert-success { background: var(--color-success-soft); color: var(--color-success); border-color: color-mix(in srgb, var(--color-success) 25%, transparent); }
.alert-info    { background: var(--color-info-soft);    color: var(--color-info);    border-color: color-mix(in srgb, var(--color-info) 25%, transparent); }

/* ----- BADGES ------------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: var(--space-1);
    padding: 2px var(--space-2); border-radius: var(--radius-full);
    font-size: var(--text-xs); font-weight: 500;
    background: var(--color-surface-offset);
    color: var(--color-text-muted);
    border: 1px solid transparent;
    line-height: 1.4;
}
.badge-primary { background: var(--color-primary-soft); color: var(--color-primary-text); }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warn    { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-info    { background: var(--color-info-soft); color: var(--color-info); }

.badge-task       { background: var(--color-success-soft); color: var(--color-success); }
.badge-decision   { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-event      { background: var(--color-info-soft); color: var(--color-info); }
.badge-subprocess { background: var(--color-primary-soft); color: var(--color-primary-text); }

/* ----- PROCESS LIST ------------------------------------------------- */
.process-list {
    list-style: none; padding: 0;
    margin: var(--space-5) 0 0;
    display: grid; gap: var(--space-3);
}
.process-list-item {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: var(--space-5);
    padding: var(--space-4) var(--space-5);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition-fast),
                transform var(--transition-fast),
                box-shadow var(--transition-fast),
                background-color var(--transition-fast);
}
.process-list-item:hover {
    background: var(--color-surface);
    border-color: color-mix(in srgb, var(--color-primary) 35%, var(--color-border));
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.process-list-item > div:first-child { min-width: 0; flex: 1; }
.process-list-item h3 {
    margin: 0 0 var(--space-1);
    font-size: var(--text-lg); font-weight: 600;
    letter-spacing: -0.015em;
}
.process-list-item h3 a { color: var(--color-text); }
.process-list-item h3 a:hover { color: var(--color-primary); text-decoration: none; }
.process-list-item .actions {
    display: flex; gap: var(--space-2); flex-shrink: 0;
    align-items: center;
}

.empty {
    padding: var(--space-12) var(--space-4); text-align: center;
    color: var(--color-text-muted);
    background: var(--color-surface-2);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-lg);
    margin-top: var(--space-4);
}
.empty a { font-weight: 600; }

/* ----- TABS --------------------------------------------------------- */
.tabs {
    display: flex; gap: 0;
    margin: var(--space-5) 0 var(--space-4);
    border-bottom: 1px solid var(--color-border);
}
.tab {
    padding: var(--space-3) var(--space-4);
    color: var(--color-text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-size: var(--text-sm); font-weight: 500;
}
.tab:hover { color: var(--color-text); }
.tab.active {
    color: var(--color-text);
    border-bottom-color: var(--color-primary);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.toolbar {
    display: flex; gap: var(--space-2); margin-bottom: var(--space-4);
    flex-wrap: wrap;
}

/* ----- BPMN viewer -------------------------------------------------- */
.bpmn-container {
    width: 100%;
    height: calc(100dvh - 280px);
    min-height: 480px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}
.bpmn-container.bpmn-container-flush {
    border-radius: 0; border-left: none; border-right: none;
    height: calc(100dvh - 110px);
}
/* Diagram blijft op lichte achtergrond in dark mode — BPMN-notatie
   (zwarte lijnen op wit) blijft zo leesbaar en print-/exporteerbaar. */
[data-theme="dark"] .bpmn-container,
[data-theme="dark"] .bpmn-container.bpmn-container-flush {
    background: #f4f4f5;
    color-scheme: light;
}
[data-theme="dark"] .bpmn-container {
    border-color: #3f3f46;
}

/* ----- PRE/CODE ----------------------------------------------------- */
.code, pre.code {
    background: #0a0a0b; color: #e4e4e7;
    padding: var(--space-4); border-radius: var(--radius-md);
    overflow: auto; font-size: 0.8125rem;
    max-height: 400px;
    font-family: var(--font-mono);
    line-height: var(--leading-snug);
}
pre.prose {
    background: var(--color-surface-offset); padding: var(--space-4);
    border-radius: var(--radius-md); white-space: pre-wrap;
    border: 1px solid var(--color-border);
    font-family: inherit; font-size: var(--text-sm);
    color: var(--color-text);
    line-height: var(--leading-base);
}

/* ----- STEPS TABLE (detail page) ----------------------------------- */
.steps-table th.num, .steps-table td.num {
    width: 52px; text-align: center;
    font-variant-numeric: tabular-nums;
    color: var(--color-text-muted); font-weight: 600;
}
.steps-table tbody td { padding: var(--space-4); }
.steps-table tbody td:nth-child(2) { color: var(--color-text-muted); }
.steps-table tbody td:nth-child(3) { font-weight: 500; }
.steps-table tbody tr:hover td.num { color: var(--color-primary-text); }

/* ----- STEP LIST (legacy, will be reworked in step 3) -------------- */
.step-list { list-style: none; padding: 0; margin: var(--space-4) 0 0; }
.step-row {
    display: grid; grid-template-columns: 40px 1fr auto;
    gap: var(--space-4); align-items: start;
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--color-divider);
}
.step-row:last-child { border-bottom: none; }
.step-number { font-weight: 600; color: var(--color-text-muted); font-size: var(--text-base); font-variant-numeric: tabular-nums; }
.step-header {
    display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap;
}
.step-desc { margin: var(--space-2) 0 0; color: var(--color-text-muted); font-size: var(--text-sm); }
.step-row-editing { background: var(--color-surface-offset); border-radius: var(--radius-lg); padding: var(--space-4); }
.step-edit-form .form-actions { display: flex; gap: var(--space-2); margin-top: var(--space-2); }

/* ----- TABLE -------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; margin-top: var(--space-3); }
.table th, .table td {
    text-align: left; padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-divider); font-size: var(--text-sm);
}
.table th {
    font-weight: 600; color: var(--color-text-faint);
    font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.06em;
    background: var(--color-surface-2);
    position: sticky; top: 0;
}
.table tbody tr { transition: background-color var(--transition-fast); }
.table tbody tr:hover { background: var(--color-surface-2); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .total-row td { background: var(--color-surface-offset); font-weight: 600; border-top: 1px solid var(--color-border); }

/* ----- USER MENU (avatar + dropdown) ------------------------------ */
.user-menu { position: relative; }
.user-avatar {
    width: 28px; height: 28px; border-radius: var(--radius-full);
    display: flex; align-items: center; justify-content: center;
    background: var(--color-primary-soft); color: var(--color-primary-text);
    font-size: 11px; font-weight: 650; letter-spacing: 0.02em;
    flex-shrink: 0;
}
.user-menu-trigger {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 4px 8px 4px 4px;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--topbar-text-muted);
    font-size: var(--text-xs); font-weight: 500;
    border: 1px solid transparent;
}
.user-menu-trigger:hover {
    background: var(--topbar-bg-hover);
    color: var(--topbar-text);
}
.user-menu.open .user-menu-trigger {
    background: var(--topbar-bg-hover);
    border-color: var(--topbar-rule);
    color: var(--topbar-text);
}
.topbar .user-avatar {
    background: rgba(255, 255, 255, 0.16);
    color: var(--topbar-text);
}
.role-dot {
    width: 8px; height: 8px; border-radius: var(--radius-full);
    flex-shrink: 0;
}
.role-specialist { background: var(--color-primary); }
.role-medewerker { background: var(--color-success); }

.user-menu-panel {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    min-width: 280px;
    max-width: calc(100vw - 24px);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    opacity: 0; transform: translateY(-4px) scale(0.98);
    pointer-events: none;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    z-index: 200;
}
.user-menu.open .user-menu-panel {
    opacity: 1; transform: translateY(0) scale(1);
    pointer-events: auto;
}
.user-menu-header {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-divider);
}
.user-menu-email {
    font-size: var(--text-sm); font-weight: 500; color: var(--color-text);
    overflow: hidden; text-overflow: ellipsis;
}
.user-menu-role {
    font-size: var(--text-xs); color: var(--color-text-muted);
    margin-top: 2px;
}
.user-menu-item-form { display: block; margin: 0; }
.user-menu-item {
    width: 100%;
    display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm); color: var(--color-text);
    text-align: left; background: none; border: none; cursor: pointer;
    text-decoration: none;
}
.user-menu-item:hover { background: var(--color-surface-offset); text-decoration: none; }
.user-menu-item svg { color: var(--color-text-muted); }

/* ----- DETAILS / DISCLOSURE ---------------------------------------- */
details > summary { cursor: pointer; user-select: none; }
details > summary::-webkit-details-marker { display: none; }


/* ----- EXCEPTIONS FIELDSET (in step instruction edit form) -------- */
.exceptions-fieldset {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-5) var(--space-5);
    background: var(--color-surface-2);
}
.exceptions-fieldset legend {
    font-size: 0.6875rem; font-weight: 600;
    color: var(--color-text-faint);
    text-transform: uppercase; letter-spacing: 0.06em;
    padding: 0 var(--space-2);
}
.exceptions-help {
    font-size: var(--text-xs); color: var(--color-text-muted);
    margin-bottom: var(--space-4);
}
.exceptions-list { display: flex; flex-direction: column; gap: var(--space-3); }
.exceptions-empty {
    color: var(--color-text-faint);
    font-size: var(--text-sm); padding: var(--space-3) 0;
}
.exception-edit-row {
    display: flex; align-items: flex-end; gap: var(--space-3);
    padding: var(--space-3); background: var(--color-surface);
    border: 1px solid var(--color-border); border-radius: var(--radius-md);
}
.exception-edit-fields {
    flex: 1;
    display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3);
}
.exception-edit-fields label { margin-bottom: 0; }
.exception-edit-label {
    display: block;
    font-size: 0.6875rem; font-weight: 600;
    color: var(--color-text-faint);
    text-transform: uppercase; letter-spacing: 0.06em;
    margin-bottom: var(--space-1);
}
.exception-edit-fields input { margin-top: 0 !important; }
.exception-edit-remove { flex-shrink: 0; }
@media (max-width: 768px) {
    .exception-edit-row { flex-direction: column; align-items: stretch; }
    .exception-edit-fields { grid-template-columns: 1fr; }
}

/* Read-only "exceptions in other steps" panel below the editable list. */
.exceptions-other { background: var(--color-bg); }
.other-step-block + .other-step-block { margin-top: var(--space-4); }
.other-step-block-head {
    display: flex; justify-content: space-between; align-items: center;
    gap: var(--space-3); flex-wrap: wrap;
    margin-bottom: var(--space-2);
}
.other-step-block-title {
    font-size: var(--text-sm); font-weight: 600; color: var(--color-text);
}
.other-step-exceptions {
    margin: 0; padding-left: var(--space-5);
    font-size: var(--text-sm); line-height: var(--leading-base);
    color: var(--color-text-muted);
    display: flex; flex-direction: column; gap: var(--space-1);
}
.other-step-exceptions strong { color: var(--color-text); font-weight: 500; }

/* ----- DIALOG ------------------------------------------------------- */
dialog.app-dialog {
    border: none;
    background: transparent;
    padding: 0;
    max-width: min(560px, calc(100vw - 2rem));
    width: 100%;
}
dialog.app-dialog::backdrop {
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.app-dialog-body {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: var(--space-6) var(--space-8);
    display: flex; flex-direction: column; gap: var(--space-4);
    color: var(--color-text);
}
.app-dialog-body h2 {
    font-size: var(--text-xl);
    margin: 0;
}
.app-dialog-list {
    margin: 0;
    padding-left: var(--space-5);
    display: flex; flex-direction: column; gap: var(--space-2);
    font-size: var(--text-sm);
    line-height: var(--leading-base);
    color: var(--color-text);
}
.app-dialog-list li strong { color: var(--color-text); font-weight: 600; }
.app-dialog-actions {
    display: flex; justify-content: flex-end; gap: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-divider);
    margin-top: var(--space-2);
}

/* ----- ENTRY ANIMATION --------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
    .card, .process-list-item, .step-card {
        animation: pf-rise 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
    }
    .process-list-item:nth-child(1) { animation-delay: 0ms; }
    .process-list-item:nth-child(2) { animation-delay: 30ms; }
    .process-list-item:nth-child(3) { animation-delay: 60ms; }
    .process-list-item:nth-child(4) { animation-delay: 90ms; }
    .process-list-item:nth-child(5) { animation-delay: 120ms; }
    .process-list-item:nth-child(n+6) { animation-delay: 150ms; }
}
@keyframes pf-rise {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ----- SPINNER ------------------------------------------------------ */
.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ====================================================================
 * Process detail page (medewerker-view) — work-instruction layout
 * ==================================================================== */

/* Step cards stay readable; the diagram tab uses the full window width. */
.view-panel[data-panel="instruction"],
.view-panel[data-panel="meta"] {
    max-width: 1100px; width: 100%; margin-left: auto; margin-right: auto;
    padding-top: var(--space-6);
}
.view-panel[data-panel="diagram"] {
    max-width: none;
    margin-top: var(--space-5);
    padding-top: var(--space-5);
}
.view-panel[data-panel="diagram"] .toolbar,
.view-panel[data-panel="upn"] .toolbar {
    margin-bottom: var(--space-5);
}
.view-panel[data-panel="upn"] {
    max-width: none;
    margin-top: var(--space-5);
    padding-top: var(--space-5);
}

/* Sticky header — process title, view-switcher, progress-track. Stays
   under the topbar so the user always sees where they are in the flow.
   Fully opaque background so content scrolling underneath never bleeds
   through. */
.process-detail-sticky {
    position: sticky;
    top: 0;
    z-index: 90;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-divider);
    padding: var(--space-5) var(--space-6) var(--space-3);
    margin: 0 calc(-1 * var(--space-6));
}
.process-detail-sticky-inner {
    max-width: 1100px; width: 100%; margin-left: auto; margin-right: auto;
    display: flex; flex-direction: column; gap: var(--space-3);
}

.process-detail-header {
    display: flex; flex-direction: column; gap: var(--space-2);
    margin-bottom: var(--space-2);
}
.process-detail-header .breadcrumb {
    font-size: var(--text-xs); color: var(--color-text-muted);
}
.process-detail-header .breadcrumb a { color: var(--color-text-muted); }
.process-detail-header .breadcrumb a:hover { color: var(--color-primary); }
.process-detail-header h1 {
    font-size: var(--text-3xl);
    margin: 0;
}

/* Editable process title (HTMX inline edit) */
.process-title-display {
    display: flex; align-items: center; gap: var(--space-3);
}
.process-title-display .process-title-edit-btn {
    opacity: 0;
    width: 28px; height: 28px;
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
}
.process-title-display:hover .process-title-edit-btn,
.process-title-display .process-title-edit-btn:focus-visible {
    opacity: 1;
}
.process-title-display .process-title-edit-btn:hover {
    background: var(--color-surface-offset);
    color: var(--color-text);
}
.process-title-edit {
    display: flex; align-items: center; gap: var(--space-2);
    flex-wrap: wrap;
}
.process-title-edit input[type=text] {
    margin-top: 0;
    font-size: var(--text-2xl);
    font-weight: 600;
    letter-spacing: -0.02em;
    padding: var(--space-2) var(--space-3);
    min-width: 320px;
}
.process-detail-meta {
    display: flex; gap: var(--space-2); flex-wrap: wrap;
    margin-top: var(--space-1);
    font-size: var(--text-xs); color: var(--color-text-muted);
    align-items: center;
}
.process-detail-actions {
    display: flex; gap: var(--space-2); flex-wrap: wrap;
    align-items: center;
}

/* ----- View switcher (specialist) ---------------------------------- */
.view-switcher {
    display: inline-flex;
    background: var(--color-surface-offset);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 4px;
    gap: 2px;
}
.view-switcher .view-btn {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-xs); font-weight: 500;
    color: var(--color-text-muted);
    border-radius: var(--radius-md);
}
.view-switcher .view-btn.active {
    background: var(--color-surface);
    color: var(--color-primary-text);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}
.view-switcher .view-btn:hover:not(.active) {
    color: var(--color-text);
    background: color-mix(in srgb, var(--color-surface) 60%, transparent);
}

/* ----- Progress track (horizontal step timeline) ------------------- */
.progress-track {
    display: flex;
    overflow-x: auto;
    padding: var(--space-4) 0;
    scrollbar-width: thin;
}
.progress-step {
    flex: 0 0 auto;
    min-width: 88px; max-width: 130px;
    display: flex; flex-direction: column; align-items: center;
    gap: var(--space-2);
    text-decoration: none;
    color: var(--color-text-muted);
    position: relative;
}
.progress-step:hover { color: var(--color-text); text-decoration: none; }
.progress-step::after {
    content: '';
    position: absolute;
    top: 17px;
    left: 50%; right: -50%;
    height: 2px;
    background: var(--color-divider);
    z-index: 0;
}
.progress-step:last-child::after { display: none; }
.progress-step .dot {
    width: 36px; height: 36px;
    border-radius: var(--radius-full);
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    display: flex; align-items: center; justify-content: center;
    font-size: var(--text-xs); font-weight: 600;
    color: var(--color-text-muted);
    position: relative; z-index: 1;
    font-variant-numeric: tabular-nums;
}
.progress-step .dot-label {
    font-size: var(--text-xs);
    text-align: center;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.progress-step.done::after { background: var(--color-success); }
.progress-step.done .dot {
    background: var(--color-success);
    border-color: var(--color-success);
    color: #fff;
}
.progress-step.done .dot-label { color: var(--color-text); }

.progress-step.active .dot {
    background: var(--color-surface);
    border-color: var(--color-primary);
    color: var(--color-primary-text);
    box-shadow: 0 0 0 4px var(--color-primary-soft);
}
.progress-step.active .dot-label {
    color: var(--color-primary-text);
    font-weight: 600;
}

/* ----- Stap-card --------------------------------------------------- */
.step-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    scroll-margin-top: 80px;
}
.step-card + .step-card { margin-top: var(--space-4); }

/* In single-step mode (data-mode="single") only the active card is
   visible. Used on the medewerker work-instruction view. */
.view-panel[data-mode="single"] .step-card { display: none; }
.view-panel[data-mode="single"] .step-card.active { display: block; }

/* Footer with Vorige / Volgende buttons. */
.step-card-footer {
    display: flex; justify-content: space-between; align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    background: var(--color-surface-2);
    border-top: 1px solid var(--color-divider);
}
.step-card-footer .step-progress-text {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}
.step-card-footer .btn svg { flex-shrink: 0; }
.step-card-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: var(--space-4);
    align-items: center;
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--color-divider);
}
.step-card-num {
    width: 36px; height: 36px;
    border-radius: var(--radius-md);
    background: var(--color-primary-soft);
    color: var(--color-primary-text);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: var(--text-sm);
    font-variant-numeric: tabular-nums;
}
.step-card-title {
    display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.step-card-title h3 { margin: 0; font-size: var(--text-lg); font-weight: 600; }
.step-card-title .step-meta {
    display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap;
    font-size: var(--text-xs); color: var(--color-text-muted);
}
.step-card-actions {
    display: flex; gap: var(--space-2); align-items: center;
}

.step-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
    padding: var(--space-5) var(--space-6);
}
@media (max-width: 768px) {
    .step-card-body { grid-template-columns: 1fr; }
}
.step-section { display: flex; flex-direction: column; gap: var(--space-2); }
.step-section-label {
    font-size: 0.6875rem; font-weight: 600;
    color: var(--color-text-faint);
    text-transform: uppercase; letter-spacing: 0.06em;
}
.step-section p { font-size: var(--text-sm); line-height: var(--leading-base); margin: 0; }
.step-section .system-pill {
    display: inline-flex; align-items: center; gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--color-surface-offset);
    border-radius: var(--radius-md);
    font-size: var(--text-sm); font-weight: 500;
    align-self: start;
}
.step-section .system-pill svg {
    width: 14px; height: 14px; color: var(--color-text-muted);
}
.step-section.tips {
    background: color-mix(in srgb, var(--color-primary-soft) 60%, transparent);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    border-left: 3px solid var(--color-primary);
    grid-column: 1 / -1;
}
.step-section.tips .step-section-label { color: var(--color-primary-text); }
.step-section.tips p { color: var(--color-text); }

.step-card-instruction {
    padding: var(--space-5) var(--space-6);
    background: var(--color-surface-2);
    border-top: 1px solid var(--color-divider);
}
.step-card-instruction details > summary {
    display: flex; align-items: center; gap: var(--space-2);
    font-size: var(--text-sm); font-weight: 500;
    color: var(--color-text);
}
.step-card-instruction details > summary::after {
    content: '';
    width: 8px; height: 8px;
    border-right: 1.5px solid var(--color-text-muted);
    border-bottom: 1.5px solid var(--color-text-muted);
    transform: rotate(45deg);
    margin-left: auto;
    transition: transform var(--transition);
}
.step-card-instruction details[open] > summary::after { transform: rotate(-135deg); }
.step-card-instruction .markdown-body {
    margin-top: var(--space-4);
    font-size: var(--text-sm);
    line-height: var(--leading-base);
    color: var(--color-text);
}
.step-card-empty {
    padding: var(--space-4) var(--space-6);
    color: var(--color-text-faint);
    font-size: var(--text-xs);
    background: var(--color-surface-2);
    border-top: 1px solid var(--color-divider);
}

/* Per-step "Wat doe ik als…" — lives on the step-card so each step
   shows only its own exceptions in single-step navigation. */
.step-card-exceptions {
    padding: var(--space-4) var(--space-6);
    background: var(--color-warning-soft);
    border-top: 1px solid var(--color-divider);
}
.step-card-exceptions h4 {
    font-size: var(--text-sm);
    font-weight: 600;
    margin: 0 0 var(--space-3);
    color: var(--color-warning);
    display: flex; align-items: center; gap: var(--space-2);
}
.step-card-exceptions h4::before {
    content: '?';
    width: 18px; height: 18px;
    border-radius: var(--radius-full);
    background: var(--color-warning); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
}
.step-card-exceptions ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.step-exception {
    background: var(--color-surface);
    border: 1px solid color-mix(in srgb, var(--color-warning) 25%, var(--color-border));
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
}
.step-exception summary {
    font-size: var(--text-sm); font-weight: 500;
    display: flex; align-items: center; gap: var(--space-2);
}
.step-exception summary::after {
    content: '';
    width: 7px; height: 7px;
    border-right: 1.5px solid var(--color-text-muted);
    border-bottom: 1.5px solid var(--color-text-muted);
    transform: rotate(45deg);
    margin-left: auto;
    transition: transform var(--transition);
}
.step-exception[open] summary::after { transform: rotate(-135deg); }
.step-exception p { margin: var(--space-2) 0 0; font-size: var(--text-sm); color: var(--color-text-muted); }

/* ----- Markdown body ----------------------------------------------- */
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
    margin-top: var(--space-4); margin-bottom: var(--space-2);
}
.markdown-body h3 { font-size: var(--text-base); font-weight: 600; }
.markdown-body h4 { font-size: var(--text-sm); font-weight: 600; }
.markdown-body p { margin: var(--space-3) 0; }
.markdown-body ul, .markdown-body ol { padding-left: var(--space-5); margin: var(--space-3) 0; }
.markdown-body li { margin: var(--space-1) 0; }
.markdown-body code { background: var(--color-surface-offset); padding: 1px 5px; border-radius: 4px; }
.markdown-body strong { color: var(--color-text); font-weight: 600; }
.markdown-body a { color: var(--color-primary); }

/* ----- Exceptions ("wat als…") ------------------------------------ */
.exceptions-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xs);
    padding: var(--space-6);
}
.exceptions-card h2 {
    font-size: var(--text-lg);
    margin: 0 0 var(--space-1);
}
.exceptions-card .lead {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    margin-bottom: var(--space-4);
}
.exception-item {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface-2);
}
.exception-item + .exception-item { margin-top: var(--space-2); }
.exception-item summary {
    display: flex; align-items: center; gap: var(--space-3);
    font-size: var(--text-sm); font-weight: 500;
}
.exception-item summary::after {
    content: '';
    width: 7px; height: 7px;
    border-right: 1.5px solid var(--color-text-muted);
    border-bottom: 1.5px solid var(--color-text-muted);
    transform: rotate(45deg);
    margin-left: auto;
    transition: transform var(--transition);
}
.exception-item[open] summary::after { transform: rotate(-135deg); }
.exception-item .answer {
    margin-top: var(--space-3);
    color: var(--color-text);
    font-size: var(--text-sm);
    line-height: var(--leading-base);
}
.exception-source-row {
    display: flex; justify-content: space-between; align-items: center;
    gap: var(--space-3); flex-wrap: wrap;
    margin-top: var(--space-3);
}
.exception-source {
    display: inline-flex; align-items: center;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}
.exception-source a { color: var(--color-text-muted); }
.exception-source a:hover { color: var(--color-primary); }

/* ----- Tag chips --------------------------------------------------- */
.tag-chip {
    display: inline-block;
    padding: 1px var(--space-2);
    background: var(--color-surface-offset);
    color: var(--color-text-muted);
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    line-height: 1.4;
    margin-right: var(--space-1);
}

/* ----- Radio-group (generator mode keuze) -------------------------- */
.radio-group {
    border: none;
    padding: 0;
    margin: var(--space-4) 0 var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.radio-group legend {
    font-weight: 600;
    margin-bottom: var(--space-2);
}
.radio-option {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    background: var(--color-surface);
    transition: background 0.15s, border-color 0.15s;
}
.radio-option:hover {
    background: var(--color-surface-offset);
}
.radio-option input[type="radio"] {
    margin-top: 0.15rem;
    flex-shrink: 0;
}
.radio-option:has(input:checked) {
    border-color: var(--color-primary);
    background: var(--color-surface-offset);
}

/* ----- Usage table (LLM-pipeline doorlooptijd) --------------------- */
.usage-table {
    width: 100%;
    max-width: 640px;
    border-collapse: collapse;
    margin-top: var(--space-3);
    font-size: var(--text-sm);
}
.usage-table th,
.usage-table td {
    padding: var(--space-2) var(--space-3);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}
.usage-table th {
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.usage-table td:nth-child(3),
.usage-table td:nth-child(4),
.usage-table th:nth-child(3),
.usage-table th:nth-child(4) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ====================================================================
 * HERO / LANDING (new.html)
 * ==================================================================== */
.hero-section {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: left;
    padding: 0 0 var(--space-6);
    position: relative;
    width: 100%;
    max-width: 1360px;
    margin: 0 auto;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-4);
    border-radius: var(--radius-full);
    background: var(--color-primary-soft);
    color: var(--color-primary-text);
    font-size: var(--text-xs);
    font-weight: 600;
    margin-bottom: var(--space-5);
    letter-spacing: 0.02em;
    border: 1px solid color-mix(in srgb, var(--color-primary) 20%, transparent);
}
.hero-badge .dot {
    width: 6px; height: 6px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    animation: hero-pulse 2s ease-in-out infinite;
}
@keyframes hero-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

.hero-title {
    font-size: var(--text-3xl);
    font-weight: 650;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin-bottom: var(--space-2);
    max-width: 40rem;
}
.hero-title .accent {
    background: var(--gradient-text);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    max-width: 40rem;
    line-height: var(--leading-base);
    margin: var(--space-1) 0 0;
}
.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-6);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
    position: sticky;
    top: 0;
    z-index: 50;
}

.hero-form-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-6) var(--space-6) var(--space-5);
    box-shadow: var(--shadow-sm);
    width: 100%;
    max-width: 1360px;
    text-align: left;
    position: relative;
}

.btn-hero {
    width: 100%;
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-base);
    font-weight: 600;
    border-radius: var(--radius-lg);
    background: var(--gradient-primary);
    color: #fff;
    border: none;
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    box-shadow:
        0 1px 0 rgba(255,255,255,0.10) inset,
        0 2px 8px rgba(13, 115, 119, 0.30),
        0 8px 24px -6px rgba(13, 115, 119, 0.35);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}
.btn-hero:hover {
    transform: translateY(-2px);
    box-shadow:
        0 1px 0 rgba(255,255,255,0.10) inset,
        0 4px 12px rgba(13, 115, 119, 0.35),
        0 12px 32px -8px rgba(13, 115, 119, 0.40);
}
.btn-hero:active { transform: translateY(0); }
.btn-hero:disabled { opacity: 0.7; transform: none; cursor: not-allowed; }

.hero-features {
    display: flex;
    justify-content: center;
    gap: var(--space-6);
    margin-top: var(--space-8);
    flex-wrap: wrap;
}
.hero-feature {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}
.hero-feature svg { color: var(--color-primary); flex-shrink: 0; }

/* ----- Generation progress (in hero-form-card) --------------------- */
.generation-progress {
    margin-top: var(--space-4);
    width: 100%;
}

/* ── Nieuwe voortgangsbalk ─────────────────────────────────────────── */
.gen-progress-wrap {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.gen-progress-top {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text);
}

.gen-progress-label {
    flex: 1;
    min-width: 0;
}

.gen-progress-pct {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--color-primary-text);
    min-width: 2.75rem;
    text-align: right;
}

.gen-progress-time {
    font-variant-numeric: tabular-nums;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    min-width: 2.5rem;
    text-align: right;
}

/* Draaiend rondje */
.gen-spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 2.5px solid color-mix(in srgb, var(--color-primary) 25%, transparent);
    border-top-color: var(--color-primary);
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}
.gen-spinner--hidden {
    animation: none;
    border-top-color: var(--color-success);
    border-color: var(--color-success);
}
.gen-spinner--error {
    animation: none;
    border-top-color: var(--color-danger);
    border-color: var(--color-danger);
}

/* Balk: absolute fill zodat de kleur nooit tot 0 hoogte inklapt. */
.gen-progress-track {
    position: relative;
    height: 10px;
    border-radius: 99px;
    background: color-mix(in srgb, var(--color-primary) 18%, var(--color-surface-offset));
    overflow: hidden;
}

.gen-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 0%;
    border-radius: 99px;
    background: var(--gradient-primary);
    overflow: hidden;
    transition: width 0.45s cubic-bezier(.4, 0, .2, 1);
}
.gen-progress-fill.is-running::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.45) 50%,
        transparent 100%
    );
    animation: gen-progress-sheen 1.4s linear infinite;
}
.gen-progress-fill--error {
    background: var(--color-danger);
    transition: background 0.3s;
}
.gen-progress-fill--error::after {
    display: none;
}

@keyframes gen-progress-sheen {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}

.intake-preview-footer .generation-progress {
    margin-top: var(--space-3);
}

/* Verborgen fase-items die de JS gebruikt om data-phase te vinden */
.progress-phases-hidden {
    display: none;
    list-style: none; margin: 0; padding: 0;
}


@media (max-width: 768px) {
    .hero-section { padding: var(--space-6) 0 var(--space-4); }
    .hero-title { font-size: var(--text-3xl); }
    .hero-form-card { padding: var(--space-5); }
    .hero-features { flex-direction: column; align-items: center; gap: var(--space-3); }
}

/* ====================================================================
 * AUTH PAGES
 * ==================================================================== */
.auth-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100dvh - var(--topbar-height) - var(--space-8));
    padding: var(--space-8) var(--space-4);
}
.auth-logo {
    margin-bottom: var(--space-6);
}
.auth-logo img {
    height: 56px; width: auto;
}
[data-theme="dark"] .auth-logo img {
    filter: brightness(4) contrast(0.9);
}
.card.narrow {
    max-width: 420px; margin: 0 auto;
    padding: var(--space-8);
    box-shadow: var(--shadow-elevated);
    border-radius: var(--radius-2xl);
    position: relative;
    overflow: hidden;
}
.card.narrow::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--gradient-primary);
}
.card.narrow h1 { text-align: center; font-size: var(--text-2xl); }
.card.narrow > p.muted { text-align: center; margin-top: var(--space-4); }
.card.narrow .btn-primary {
    width: 100%;
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-base);
    border-radius: var(--radius-lg);
    margin-top: var(--space-2);
}

/* ====================================================================
 * ENHANCED PROCESS LIST
 * ==================================================================== */
.process-list-item {
    position: relative;
    overflow: hidden;
}
.process-list-item::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity var(--transition);
}
.process-list-item:hover::before { opacity: 1; }

.empty {
    background: color-mix(in srgb, var(--color-primary) 4%, var(--color-surface-2));
    border: 1px dashed color-mix(in srgb, var(--color-primary) 25%, var(--color-border));
}
.empty svg { margin: 0 auto var(--space-4); color: var(--color-primary); }

/* ====================================================================
 * ENHANCED DETAIL PAGE (CSS-only)
 * ==================================================================== */
.process-detail-sticky::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, var(--color-divider), color-mix(in srgb, var(--color-primary) 20%, var(--color-divider)), var(--color-divider));
}

.view-switcher {
    border-radius: var(--radius-full);
    padding: 3px;
}
.view-switcher .view-btn {
    border-radius: var(--radius-full);
}
.view-switcher .view-btn.active {
    box-shadow: var(--shadow-sm), 0 0 0 1px var(--color-border);
}

.step-card-num {
    background: var(--gradient-primary);
    color: #fff;
    border-radius: var(--radius-lg);
}

.progress-step.active .dot {
    box-shadow: 0 0 0 4px var(--color-primary-soft),
                0 0 16px -4px rgba(13, 115, 119, 0.3);
}

/* ====================================================================
 * MICRO-INTERACTIONS + FORM POLISH
 * ==================================================================== */
.btn:active:not(:disabled) {
    transform: translateY(1px) scale(0.99);
    transition-duration: 60ms;
}
.card:hover {
    border-color: color-mix(in srgb, var(--color-primary) 15%, var(--color-border));
}

form input[type=text],
form input[type=email],
form input[type=password],
form input[type=search],
form textarea {
    border-radius: var(--radius-lg);
    transition: border-color var(--transition-fast),
                box-shadow var(--transition-fast);
}
form input:focus, form textarea:focus {
    box-shadow: 0 0 0 4px var(--color-primary-soft),
                0 0 16px -8px rgba(13, 115, 119, 0.2),
                inset 0 1px 2px rgba(15, 23, 42, 0.03);
}

#charcount { font-variant-numeric: tabular-nums; }

/* Gradient text utility */
.gradient-text {
    background: var(--gradient-text);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

@keyframes shimmer {
    from { background-position: -200% 0; }
    to { background-position: 200% 0; }
}
.skeleton {
    background: linear-gradient(90deg, var(--color-surface-offset) 25%, var(--color-surface) 37%, var(--color-surface-offset) 63%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

/* ====================================================================
 * PRODUCT UI UPGRADE
 * ==================================================================== */
.topbar-nav {
    display: flex;
    align-items: stretch;
    align-self: stretch;
    gap: 4px;
    margin-left: 4px;
}
.topbar-link {
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    position: relative;
    color: var(--topbar-text-muted);
    font-size: 13.5px;
    font-weight: 500;
}
.topbar-link:hover {
    color: var(--topbar-text);
    text-decoration: none;
}
.topbar-link.active {
    color: var(--topbar-text);
    font-weight: 600;
}
.topbar-link.active::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: -1px;
    height: 2px;
    background: var(--topbar-accent);
    border-radius: 2px 2px 0 0;
}
.topbar-balance {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--topbar-text);
    text-decoration: none;
}
.topbar-balance:hover {
    background: var(--topbar-bg-hover);
    text-decoration: none;
}
.topbar-balance-label {
    color: var(--topbar-text-faint);
    font-size: 12px;
    font-weight: 500;
}
.topbar-balance strong {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}
.topbar-balance.is-negative,
.topbar-balance.is-negative .topbar-balance-label {
    color: #fecaca;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.hero-section-upgraded {
    gap: var(--space-5);
}
.hero-section-upgraded .page-header {
    margin-bottom: 0;
}
.hero-dashboard {
    width: 100%;
    max-width: 1360px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4);
}
.hero-stat-card {
    background: color-mix(in srgb, var(--color-surface) 86%, transparent);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    text-align: left;
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: inherit;
}
.hero-stat-card:hover {
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.hero-stat-card-muted {
    background: color-mix(in srgb, var(--color-surface-offset) 88%, transparent);
}
.hero-stat-label {
    display: block;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: var(--space-2);
}
.hero-stat-value {
    display: block;
    font-size: var(--text-2xl);
    line-height: 1;
    margin-bottom: var(--space-2);
}
.hero-stat-meta {
    display: block;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}
.hero-form-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}
.hero-form-header h2 {
    margin: 0 0 var(--space-2);
}
.hero-form-header p {
    margin: 0;
}
.progress-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
    padding: var(--space-4);
    background: color-mix(in srgb, var(--color-primary) 5%, var(--color-surface));
    border: 1px solid color-mix(in srgb, var(--color-primary) 14%, var(--color-border));
    border-radius: var(--radius-xl);
}
.progress-summary-label {
    display: block;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.progress-summary-value {
    font-size: var(--text-lg);
    font-weight: 600;
    margin-top: 2px;
}
.progress-summary-metrics {
    display: flex;
    gap: var(--space-6);
    align-items: center;
}
.progress-state-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    padding: 6px 10px;
    border-radius: var(--radius-full);
    background: var(--color-primary-soft);
    color: var(--color-primary-text);
}
.progress-phase-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.progress-phase-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text);
}
.progress-phase-subtitle {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.recent-processes {
    margin-top: var(--space-2);
    width: 100%;
    max-width: 1360px;
    margin-left: auto;
    margin-right: auto;
}
.recent-process-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4);
    margin-top: var(--space-5);
}
.recent-process-card {
    background: color-mix(in srgb, var(--color-surface-2) 88%, transparent);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    box-shadow: var(--shadow-xs);
}
.recent-process-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}
.recent-process-card-head h3 {
    margin: 0 0 var(--space-1);
}
.recent-process-description {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    margin-bottom: var(--space-4);
}
.recent-process-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.process-list-item-rich {
    background: color-mix(in srgb, var(--color-surface-2) 82%, transparent);
}
.process-list-topline {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-bottom: var(--space-2);
}

.diagram-panel {
    padding-top: var(--space-5);
}
.diagram-panel-head {
    margin-bottom: var(--space-3);
}
.diagram-panel-head h2 {
    margin: 0 0 var(--space-2);
}
.diagram-viewer {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}
.diagram-toolbar {
    position: sticky;
    top: calc(var(--space-4) + 1rem);
    z-index: 4;
    padding: var(--space-3);
    background: color-mix(in srgb, var(--color-surface) 94%, transparent);
    border: 1px solid color-mix(in srgb, var(--color-border) 88%, transparent);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-sm);
}
.toolbar-spread {
    justify-content: space-between;
    align-items: center;
}
.toolbar-group {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}
.diagram-status {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--color-surface-offset) 72%, transparent);
    color: var(--color-text-muted);
}
.diagram-status strong {
    color: var(--color-text);
    font-size: var(--text-sm);
    min-width: 4rem;
}
.diagram-canvas-shell {
    position: relative;
    padding: var(--space-3);
    background:
        linear-gradient(180deg, color-mix(in srgb, #f8fafc 92%, transparent), color-mix(in srgb, #ffffff 97%, transparent)),
        radial-gradient(circle at top left, color-mix(in srgb, var(--color-primary) 10%, transparent), transparent 32%);
    border: 1px solid color-mix(in srgb, var(--color-border) 88%, transparent);
    border-radius: var(--radius-xl);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.diagram-canvas-shell .alert {
    margin-bottom: var(--space-3);
}
.bpmn-container-upgraded {
    height: calc(100dvh - 300px);
    min-height: 720px;
    border-radius: calc(var(--radius-xl) - 4px);
    background:
        radial-gradient(circle at top, rgba(14, 116, 144, 0.06), transparent 28%),
        linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.98));
    overflow: hidden;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    border: 1.5px solid transparent;
}
.bpmn-container-upgraded.is-wheel-active {
    border-color: color-mix(in srgb, var(--color-primary, #00811f) 65%, transparent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary, #00811f) 20%, transparent);
}
[data-theme="dark"] .bpmn-container-upgraded {
    background:
        radial-gradient(circle at top, rgba(56, 189, 248, 0.12), transparent 28%),
        linear-gradient(180deg, rgba(17,17,19,0.96), rgba(12,14,18,0.98));
}
.diagram-viewer:fullscreen {
    padding: var(--space-5);
    background: var(--color-bg);
}
.diagram-viewer:fullscreen .diagram-toolbar {
    top: var(--space-4);
}
.diagram-viewer:fullscreen .bpmn-container-upgraded {
    min-height: 0;
    height: calc(100dvh - 180px);
}
.upn-viewer:fullscreen {
    padding: var(--space-5);
    background: var(--color-bg);
    overflow: auto;
}
.upn-viewer:fullscreen .upn-toolbar {
    top: var(--space-4);
}
.upn-viewer:fullscreen .upn-canvas-shell {
    min-height: 0;
    height: calc(100dvh - 180px);
}
.diagram-viewer .djs-container,
.diagram-viewer .djs-container > svg,
.diagram-viewer .viewport {
    width: 100%;
    height: 100%;
}
.diagram-viewer .pf-message-flow .djs-visual > :first-child {
    stroke: color-mix(in srgb, var(--color-primary) 58%, #475569);
    stroke-width: 2.6px;
    stroke-dasharray: 8 6;
    opacity: 0.92;
}
.diagram-viewer .pf-message-flow.djs-hover .djs-visual > :first-child,
.diagram-viewer .pf-message-flow-active .djs-visual > :first-child {
    stroke: var(--color-primary);
    stroke-width: 3.2px;
    opacity: 1;
}
.diagram-viewer .pf-message-flow-active .djs-visual > :first-child {
    filter: drop-shadow(0 0 10px color-mix(in srgb, var(--color-primary) 28%, transparent));
}
.btn-danger-inline {
    color: var(--color-danger);
}
.btn-danger-inline:hover {
    background: var(--color-danger-soft);
    color: var(--color-danger);
}

.billing-page h1 { margin-bottom: 0; }
.billing-page h2 {
    margin: var(--space-8) 0 var(--space-2);
    font-size: var(--text-xl);
}
.billing-section-lede {
    margin: 0 0 var(--space-4);
    max-width: 42rem;
}
.billing-balance {
    margin: var(--space-5) 0 0;
}
.billing-card-label {
    display: block;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: var(--space-2);
}
.billing-balance-value {
    display: block;
    font-size: var(--text-xl);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--space-2);
}
.billing-balance-note {
    display: block;
    margin-top: var(--space-2);
    font-weight: 700;
}
.billing-package-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-4);
    margin-top: 0;
}
.billing-package-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    box-shadow: var(--shadow-sm);
}
.billing-package-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
}
.billing-package-head h3 {
    margin: 0 0 var(--space-1);
}
.billing-package-head p {
    margin: 0;
}
.billing-package-value {
    font-size: var(--text-xl);
    font-weight: 700;
}
.billing-table td:nth-child(4),
.billing-table td:nth-child(5),
.billing-table th:nth-child(4),
.billing-table th:nth-child(5) {
    text-align: right;
}
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }

@media (max-width: 980px) {
    .hero-dashboard,
    .billing-package-grid,
    .recent-process-grid,
    .billing-summary-grid {
        grid-template-columns: 1fr;
    }
    .toolbar-spread,
    .diagram-status,
    .hero-form-header,
    .progress-summary {
        flex-direction: column;
        align-items: stretch;
    }
    .progress-summary-metrics {
        justify-content: space-between;
    }
}

@media (max-width: 768px) {
    .topbar {
        height: auto;
        min-height: var(--topbar-height);
        flex-wrap: wrap;
        row-gap: 0;
        padding: 0 12px;
        gap: 8px;
    }
    .topbar-nav {
        order: 3;
        width: calc(100% + 24px);
        margin-left: -12px;
        margin-right: -12px;
        padding: 0 4px;
        height: 40px;
        border-top: 1px solid var(--topbar-rule);
    }
    .topbar-link.active::after {
        bottom: 0;
    }
    .process-detail-actions {
        width: 100%;
        justify-content: space-between;
    }
    .view-switcher {
        width: 100%;
        overflow-x: auto;
    }
    .recent-process-actions,
    .page-header-actions,
    .toolbar-group {
        width: 100%;
    }
    .recent-process-actions .btn,
    .page-header-actions .btn,
    .toolbar-group .btn {
        flex: 1;
    }
    .bpmn-container-upgraded {
        min-height: 560px;
        height: calc(100dvh - 260px);
    }
}

/* ====================================================================
 * AI PROCESS INTERVIEWER (BEGELEIDE INTAKE)
 * ==================================================================== */

.new-process-page h1 {
    margin-bottom: 0;
}
.page-lede {
    color: var(--color-text-muted);
    margin: 0.35rem 0 1.25rem;
    max-width: 42rem;
}
.intake-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.intake-topbar .intake-tabs {
    margin-bottom: 0;
}
.direct-form {
    max-width: 720px;
}

.intake-tabs {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
    background: color-mix(in srgb, var(--color-surface-offset) 70%, transparent);
    padding: var(--space-1);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    width: fit-content;
}

.intake-tab-btn {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.intake-tab-btn:hover {
    color: var(--color-text);
}

.intake-tab-btn.active {
    background: var(--color-surface);
    color: var(--color-primary);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

.intake-split {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: var(--space-5);
    align-items: stretch;
}

.intake-chat-pane {
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    height: 600px;
    box-shadow: var(--shadow-sm);
}

.intake-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    background: color-mix(in srgb, var(--color-surface-offset) 60%, transparent);
    border-bottom: 1px solid var(--color-border);
}

.intake-consultant-badge {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text);
}

.intake-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.intake-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    scroll-behavior: smooth;
}

.chat-bubble {
    display: flex;
    gap: var(--space-3);
    max-width: 88%;
    animation: fadeIn 0.2s ease-out;
}

.chat-bubble-assistant {
    align-self: flex-start;
}

.chat-bubble-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: var(--text-sm);
}

.chat-avatar-assistant {
    background: color-mix(in srgb, var(--color-primary) 15%, transparent);
    color: var(--color-primary);
}

.chat-avatar-user {
    background: color-mix(in srgb, var(--color-text-muted) 20%, transparent);
    color: var(--color-text);
}

.chat-text {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    line-height: 1.5;
    white-space: pre-wrap;
}

.chat-bubble-assistant .chat-text {
    background: color-mix(in srgb, var(--color-surface-offset) 80%, transparent);
    color: var(--color-text);
    border-top-left-radius: var(--space-1);
    border: 1px solid var(--color-border);
}

.chat-bubble-user .chat-text {
    background: var(--color-primary);
    color: #ffffff;
    border-top-right-radius: var(--space-1);
}

.quick-replies-container {
    padding: 0 var(--space-4) var(--space-2);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.quick-reply-btn {
    background: color-mix(in srgb, var(--color-primary) 10%, transparent);
    color: var(--color-primary);
    border: 1px solid color-mix(in srgb, var(--color-primary) 30%, transparent);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full, 9999px);
    font-size: var(--text-xs);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.quick-reply-btn:hover {
    background: var(--color-primary);
    color: #ffffff;
}

.intake-chat-input-area {
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
}

.intake-input-form {
    display: flex;
    gap: var(--space-2);
    align-items: flex-end;
}

.intake-textarea {
    flex: 1;
    resize: none;
    min-height: 42px;
    max-height: 120px;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    line-height: 1.4;
    background: var(--color-surface);
    color: var(--color-text);
}
.intake-textarea::placeholder {
    color: var(--color-placeholder);
    opacity: 1;
}

.model-selection-wrapper {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.model-choice {
    display: flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface-offset);
}
.model-choice-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--color-text-muted);
    font: inherit;
    font-size: var(--text-sm);
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    white-space: nowrap;
}
.model-choice-btn:hover { color: var(--color-text); }
.model-choice-btn.active {
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}
[data-theme="dark"] .model-choice {
    background: #18181b;
    border-color: #52525b;
}
[data-theme="dark"] .model-choice-btn.active {
    background: #27272a;
    color: #f4f4f5;
}
.model-select {
    appearance: auto;
    padding: 4px 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    font: inherit;
    font-size: var(--text-sm);
    background: var(--color-surface-offset);
    color: var(--color-text);
    color-scheme: inherit;
}
.model-select option {
    background: var(--color-surface-offset);
    color: var(--color-text);
}
[data-theme="dark"] .model-select {
    background: #27272a;
    border-color: #71717a;
    color: #f4f4f5;
}
[data-theme="dark"] .model-select option {
    background: #27272a;
    color: #f4f4f5;
}

.intake-send-btn {
    height: 42px;
    padding: 0 var(--space-4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.typing-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: var(--space-2) var(--space-3);
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-text-muted);
    animation: typingPulse 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingPulse {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Live Draft Preview Pane */
.intake-preview-pane {
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    height: 600px;
    box-shadow: var(--shadow-sm);
}

.intake-preview-header {
    padding: var(--space-3) var(--space-4);
    background: color-mix(in srgb, var(--color-surface-offset) 60%, transparent);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.intake-preview-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.draft-box {
    background: color-mix(in srgb, var(--color-surface-offset) 50%, transparent);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
}

.draft-box-title {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: var(--space-2);
    font-weight: 600;
}

.draft-badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.draft-badge {
    background: color-mix(in srgb, var(--color-primary) 12%, transparent);
    color: var(--color-primary);
    font-size: var(--text-xs);
    font-weight: 500;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid color-mix(in srgb, var(--color-primary) 24%, transparent);
}

.draft-step-list {
    margin: 0;
    padding-left: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    font-size: var(--text-sm);
}

.intake-preview-footer {
    padding: var(--space-3) var(--space-4);
    background: color-mix(in srgb, var(--color-surface-offset) 40%, transparent);
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}

@media (max-width: 980px) {
    .intake-split {
        grid-template-columns: 1fr;
    }
    .intake-chat-pane,
    .intake-preview-pane {
        height: 480px;
    }
}

