:root {
    --bg: #eef0f4;
    --card-bg: #ffffff;
    --surface-sunken: #f4f5f8;

    --sidebar-width: 248px;
    --sidebar-bg: #12141c;
    --sidebar-bg-hover: #1c1f2b;
    --sidebar-border: rgba(255, 255, 255, .08);
    --sidebar-text: #aab0c0;
    --sidebar-text-active: #ffffff;

    --border: #e1e4ea;
    --border-strong: #c7cbd6;
    --text: #171a21;
    --muted: #5b6270;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-container: #e5e3fb;
    --on-accent-container: #3730a3;
    --success: #15803d;
    --success-bg: #dcfce7;
    --error: #b91c1c;
    --error-bg: #fee2e2;
    --running-bg: #e0e7ff;
    --running: #3730a3;

    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 24px;
    --sp-6: 32px;
    --sp-7: 48px;

    --radius-xs: 4px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-pill: 999px;

    --elevation-1: 0 1px 2px rgba(23, 26, 33, .06), 0 1px 3px rgba(23, 26, 33, .08);
    --elevation-2: 0 2px 6px rgba(23, 26, 33, .10), 0 1px 2px rgba(23, 26, 33, .08);

    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;

    --motion-fast: 120ms;
    --motion-standard: 200ms cubic-bezier(.2, 0, 0, 1);

    --focus-ring: 0 0 0 3px rgba(79, 70, 229, .35);
}

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

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-family);
    background: var(--bg);
    color: var(--text);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-xs);
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    background: var(--accent);
    color: #fff;
    padding: var(--sp-2) var(--sp-4);
    border-radius: 0 0 var(--radius-xs) 0;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}

.skip-link:focus {
    left: 0;
}

/* ---------- App shell: sidebar + content canvas ---------- */

.app-shell {
    display: flex;
    align-items: stretch;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 30;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-5) var(--sp-4) var(--sp-4);
    color: var(--sidebar-text-active);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.sidebar-brand svg {
    width: 22px;
    height: 22px;
    color: var(--accent);
    flex-shrink: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--sp-2) var(--sp-3);
    flex: 1;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background var(--motion-fast), color var(--motion-fast);
}

.sidebar-nav a svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-nav a:hover {
    background: var(--sidebar-bg-hover);
    color: var(--sidebar-text-active);
}

.sidebar-nav a.active {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

.sidebar-footer {
    padding: var(--sp-3);
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background var(--motion-fast), color var(--motion-fast);
}

.sidebar-footer a:hover {
    background: var(--sidebar-bg-hover);
    color: var(--sidebar-text-active);
}

.sidebar-footer a svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.content {
    flex: 1;
    min-width: 0;
}

.mobile-topbar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 20;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--sidebar-bg);
    color: var(--sidebar-text-active);
}

.mobile-topbar button {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: inherit;
    padding: var(--sp-1);
    cursor: pointer;
    border-radius: var(--radius-xs);
}

.mobile-topbar button svg {
    width: 22px;
    height: 22px;
}

.mobile-topbar span {
    font-weight: 600;
    font-size: 15px;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 11, 15, .5);
    z-index: 25;
}

@media (max-width: 900px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform var(--motion-standard);
        box-shadow: var(--elevation-2);
    }

    .sidebar.sidebar--open {
        transform: translateX(0);
    }

    .mobile-topbar {
        display: flex;
    }

    .sidebar-backdrop.sidebar-backdrop--visible {
        display: block;
    }
}

main {
    max-width: 1100px;
    margin: var(--sp-5) auto;
    padding: 0 var(--sp-5);
}

@media (max-width: 900px) {
    main {
        margin: var(--sp-4) auto;
        padding: 0 var(--sp-4);
    }
}

@media (max-width: 600px) {
    main {
        padding: 0 var(--sp-3);
    }

    /* auto-fill/minmax kan op zeer smalle schermen nog steeds een tegel
       forceren die breder is dan het scherm (minmax's minimum wint van de
       beschikbare ruimte) — hier expliciet naar één kolom zonder minimum. */
    .tile-grid {
        grid-template-columns: 1fr;
    }
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--elevation-1);
    padding: var(--sp-5);
    margin-bottom: var(--sp-5);
}

.card h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 var(--sp-3);
}

.card h3 {
    font-size: 14px;
    font-weight: 600;
    margin: var(--sp-4) 0 var(--sp-2);
}

.table-scroll {
    overflow-x: auto;
    border-radius: var(--radius-xs);
}

.table-scroll--tall {
    max-height: 480px;
    overflow-y: auto;
}

.table-scroll--tall thead th {
    position: sticky;
    top: 0;
    background: var(--card-bg);
    box-shadow: 0 1px 0 var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

tbody tr:nth-child(even) {
    background: var(--surface-sunken);
}

th, td {
    text-align: left;
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

/* Eerste kolom blijft zichtbaar bij horizontaal scrollen op smalle schermen,
   zodat een rij nog te identificeren is terwijl de rest van de tabel scrollt. */
.table-scroll td:first-child,
.table-scroll th:first-child {
    position: sticky;
    left: 0;
    background: var(--card-bg);
}

.table-scroll tbody tr:nth-child(even) td:first-child {
    background: var(--surface-sunken);
}

.badge {
    display: inline-block;
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 600;
}

.badge.success { background: var(--success-bg); color: var(--success); }
.badge.error { background: var(--error-bg); color: var(--error); }
.badge.running { background: var(--running-bg); color: var(--running); }
.badge.info { background: var(--running-bg); color: var(--running); }
.badge.inactief { background: var(--bg); color: var(--text); border: 1px solid var(--border-strong); }
.badge.actief { background: var(--success-bg); color: var(--success); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    border: 1px solid var(--border-strong);
    background: var(--card-bg);
    color: var(--text);
    padding: var(--sp-2) var(--sp-4);
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    transition: background var(--motion-fast), box-shadow var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast);
}

.btn:hover {
    box-shadow: var(--elevation-1);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-filled {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    text-decoration: none;
}

.btn-filled:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}

.btn-destructive {
    border-color: var(--error);
    background: var(--error-bg);
    color: var(--error);
}

.btn-destructive:hover {
    background: var(--error);
    border-color: var(--error);
    color: #fff;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.login-body {
    background: var(--sidebar-bg);
}

.login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--sp-4);
}

.login-card {
    width: 100%;
    max-width: 360px;
}

.login-card h1 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 var(--sp-5);
}

.login-card label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: var(--sp-1);
}

.login-card input {
    width: 100%;
    padding: var(--sp-3);
    margin-bottom: var(--sp-4);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    font-size: 14px;
    font-family: inherit;
}

.login-card button {
    width: 100%;
    padding: var(--sp-3);
    border: none;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: white;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--motion-fast);
}

.login-card button:hover {
    background: var(--accent-hover);
}

.fout {
    color: var(--error);
    background: var(--error-bg);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-xs);
    font-size: 13px;
    margin-bottom: var(--sp-4);
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

.module-card-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--sp-1) var(--sp-2);
    margin-bottom: var(--sp-2);
}

.module-card-header h2 {
    font-size: 16px;
    margin: 0;
}

.module-card-header code {
    min-width: 0;
    overflow-wrap: anywhere;
}

.module-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

code {
    background: var(--surface-sunken);
    padding: 1px 5px;
    border-radius: var(--radius-xs);
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Een lange, niet-afbreekbare regel (bv. het cron-commando) mag binnen zijn
   eigen kaartje horizontaal scrollen in plaats van de pagina te verbreden. */
pre {
    max-width: 100%;
    overflow-x: auto;
}

.workflow-graph-scroll {
    overflow: auto;
    max-height: 70vh;
    margin: var(--sp-2) 0 var(--sp-4);
}

.workflow-graph {
    display: block;
    margin: 0 auto;
}

.workflow-link {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}

.workflow-link:hover {
    color: var(--accent);
}

.legenda {
    display: flex;
    gap: var(--sp-5);
    font-size: 12px;
    color: var(--muted);
    margin-bottom: var(--sp-3);
}

.legenda span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legenda .lijn {
    display: inline-block;
    width: 20px;
    height: 0;
    border-top: 2px solid var(--accent);
}

.legenda .lijn.optioneel {
    border-top: 2px dashed var(--muted);
}

.terug {
    display: inline-block;
    margin-bottom: var(--sp-3);
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
}

.terug:hover {
    color: var(--accent);
}

.claude-aanroep {
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: var(--sp-2) var(--sp-3);
    margin-bottom: var(--sp-2);
}

.claude-aanroep summary {
    cursor: pointer;
    font-size: 13px;
    color: var(--muted);
    padding: var(--sp-1) 0;
}

.claude-aanroep h4 {
    margin: var(--sp-3) 0 var(--sp-1);
    font-size: 12px;
    color: var(--muted);
}

.claude-aanroep pre {
    background: var(--surface-sunken);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-xs);
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 12px;
    margin: 0;
    max-height: 320px;
    overflow-y: auto;
}

/* ---------- Tegels: workflow-overzicht (dashboard). Vervangt een dichte
   tabel door losse, scanbare kaarten. Applications en het per-workflow
   overzicht binnen modules gebruiken de rij-tegels verderop in dit bestand. ---------- */

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--sp-4);
}

.tile {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--elevation-1);
    padding: var(--sp-4);
}

.tile-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--sp-1) var(--sp-2);
}

.tile-header a {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    text-decoration: none;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
}

.tile-header .badge {
    flex-shrink: 0;
}

.tile-header a:hover {
    color: var(--accent);
}

.tile-omschrijving {
    margin: 0;
}

.tile-body {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    flex: 1;
}

.tile-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    font-size: 13px;
}

.tile-meta-label {
    color: var(--muted);
}

.tile-footer {
    margin-top: auto;
    padding-top: var(--sp-3);
    border-top: 1px solid var(--border);
}

.tile-footer .btn {
    width: 100%;
    justify-content: center;
}

/* ---------- Rij-tegels: applications en het per-workflow overzicht binnen
   modules, als volle-breedte tegels met kolommen ernaast — een tegel die er
   weer als een tabelrij uitziet, i.p.v. een grid van losse kaarten. Elke
   contextklasse (--applicaties/--modules-claude/--modules-agent) zet alleen
   --row-cols; header en rijen delen daardoor precies dezelfde kolombreedtes. ---------- */

.row-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

/* Vaste breedte i.p.v. auto op de laatste (actie-)kolom: "auto" sizet per
   grid-container aan zijn eigen inhoud, en de header-cel daar is leeg terwijl
   de rij-cel een knop bevat — daardoor kregen header en rijen elk hun eigen
   kolombreedtes i.p.v. dezelfde, en liep de uitlijning steeds verder uit
   elkaar naar rechts. */
.row-list--applicaties { --row-cols: 1.8fr 1fr 0.9fr 1.3fr 1fr 132px; }
.row-list--modules-claude { --row-cols: 1.8fr 1fr 0.9fr 1.3fr; }
.row-list--modules-agent { --row-cols: 1.8fr 0.9fr 1fr 1.3fr; }
.row-list--logs { --row-cols: 160px 90px 1fr; }

.row-list-header {
    display: grid;
    grid-template-columns: var(--row-cols, 1fr);
    gap: var(--sp-3);
    padding: 0 var(--sp-4);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.row-list-header > * {
    min-width: 0;
    overflow-wrap: break-word;
}

.tile-row {
    display: grid;
    grid-template-columns: var(--row-cols, 1fr);
    align-items: center;
    gap: var(--sp-3);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--elevation-1);
    padding: var(--sp-3) var(--sp-4);
}

.tile-row--nested {
    background: var(--surface-sunken);
    box-shadow: none;
}

.tile-row-field {
    min-width: 0;
    font-size: 14px;
}

.tile-row-name {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--sp-2);
}

.tile-row-name a {
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.tile-row-name a:hover {
    color: var(--accent);
}

.tile-row-actions {
    justify-self: end;
}

@media (max-width: 700px) {
    .row-list-header {
        display: none;
    }

    .tile-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .tile-row-field:not(.tile-row-name):not(.tile-row-actions) {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: var(--sp-2);
        padding: var(--sp-2) 0;
        border-top: 1px solid var(--border);
    }

    .tile-row-field:not(.tile-row-name):not(.tile-row-actions)::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 13px;
        flex-shrink: 0;
    }

    .tile-row-name {
        padding-bottom: var(--sp-2);
    }

    .tile-row-actions {
        justify-self: stretch;
        margin-top: var(--sp-2);
    }

    .tile-row-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-4);
}

.kpi-tile {
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--sp-3) var(--sp-4);
}

.kpi-label {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: var(--sp-1);
}

.kpi-waarde {
    font-size: 22px;
    font-weight: 700;
}

.kpi-waarde.muted {
    font-size: 15px;
    font-weight: 400;
}

.trend-omhoog {
    color: var(--error);
}

.trend-omlaag {
    color: var(--success);
}

.kpi-waarde.error {
    color: var(--error);
}

.instellingen-form {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: var(--sp-3);
}

.instellingen-form label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: var(--sp-1);
}

.instellingen-form select,
.instellingen-form input {
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    font-size: 14px;
    font-family: inherit;
}

.instellingen-form select {
    min-width: 280px;
}

.instellingen-form input[type="number"] {
    width: 140px;
}

.instelling-veld {
    display: flex;
    flex-direction: column;
    min-width: 160px;
}

.instellingen-form-groot .instelling-veld {
    max-width: 320px;
}

.instelling-veld .muted {
    margin: var(--sp-1) 0 0;
    font-size: 12px;
}

.periode-form {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.periode-form label {
    font-size: 13px;
    color: var(--muted);
}

.periode-form select {
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    font-size: 14px;
    font-family: inherit;
}

.insight-tekst {
    font-size: 13px;
    color: var(--text);
    margin: 0;
    line-height: 1.6;
}

.chart-container {
    width: 100%;
    height: 320px;
}

.chart-container-klein {
    width: 100%;
    height: 280px;
}

@media (max-width: 600px) {
    .instellingen-form,
    .instellingen-form-groot {
        align-items: stretch;
    }

    .instellingen-form select,
    .instellingen-form input,
    .instellingen-form .instelling-veld,
    .instellingen-form-groot .instelling-veld {
        width: 100%;
        max-width: none;
        min-width: 0;
    }

    .instellingen-form .btn {
        width: 100%;
        justify-content: center;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
}
