/* ==========================================================================
   Irixs Migrator — brandbook foundation
   Tokens and components follow the irixs-ui-brandbook skill exactly.
   No component library: everything here is hand-written CSS on these tokens.
   Never introduce a colour outside the token set below.
   ========================================================================== */

/* --- 1. Reset ----------------------------------------------------------- */

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

/* --- 2. Tokens ---------------------------------------------------------- */

:root {
    /* Surfaces */
    --paper: #FAF7F2;
    --cream: #F2EBDD;
    --tan: #E5D8C2;
    --white: #FFFFFF;

    /* Text */
    --ink: #1A0E22;
    --ink-soft: #3A2E45;
    --muted: #6E6878;

    /* Brand */
    --purple: #340C46;
    --purple-light: #46235A;
    --purple-mid: #7D2776;
    --purple-deep: #1B0626;

    /* Accent */
    --yellow: #FDB940;
    --yellow-soft: #FDE2A8;
    --yellow-deep: #A06200;
    --cyan: #0081BD;
    --orange: #F68C3D;
    --pink: #C64B9B;

    /* Status */
    --success: #1A7F4B;
    --success-soft: #D1FAE5;
    --warning: #A06200;
    --warning-soft: #FDE2A8;
    --danger: #B91C1C;
    --danger-soft: #FEE2E2;
    --info: #0081BD;
    --info-soft: #DBEAFE;

    /* Structure */
    --rule: rgba(52, 12, 70, .14);
    --rule-soft: rgba(52, 12, 70, .07);
    --rule-focus: rgba(52, 12, 70, .55);

    /* Animation */
    --ease: cubic-bezier(.22, .61, .36, 1);
    --ease-out: cubic-bezier(.16, 1, .3, 1);

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 10px;
    --radius-pill: 999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(52, 12, 70, .08), 0 1px 2px rgba(52, 12, 70, .06);
    --shadow-md: 0 4px 12px rgba(52, 12, 70, .10), 0 2px 6px rgba(52, 12, 70, .07);
    --shadow-lg: 0 12px 32px rgba(52, 12, 70, .14), 0 4px 12px rgba(52, 12, 70, .08);
}

/* --- 3. Base ------------------------------------------------------------ */

html,
body {
    height: 100%;
}

body {
    font-family: 'Poppins', sans-serif;
    background: var(--paper);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--cyan);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

:focus-visible {
    outline: 2px solid var(--yellow);
    outline-offset: 3px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* --- 4. Typography ----------------------------------------------------- */

h1,
h2,
h3,
h4 {
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.text-h1 { font-size: clamp(28px, 3vw, 40px); letter-spacing: -0.03em; line-height: 1.1; }
.text-h2 { font-size: clamp(22px, 2.2vw, 30px); letter-spacing: -0.025em; line-height: 1.2; }
.text-h3 { font-size: clamp(18px, 1.6vw, 22px); letter-spacing: -0.02em; line-height: 1.3; }
.text-h4 { font-size: 16px; letter-spacing: -0.01em; line-height: 1.4; }

.text-body-lg { font-size: 17px; line-height: 1.65; }
.text-body { font-size: 15px; line-height: 1.6; }
.text-body-sm { font-size: 13px; line-height: 1.55; }

.text-label { font-size: 13px; font-weight: 600; letter-spacing: .01em; }
.text-caption { font-size: 11.5px; color: var(--muted); letter-spacing: .02em; }
.text-overline { font-size: 11px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase; }

.text-muted { color: var(--muted); }
.text-soft { color: var(--ink-soft); }

.eyebrow {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--purple);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: var(--space-3);
}

.eyebrow::before {
    content: "";
    width: 20px;
    height: 1px;
    background: var(--purple);
}

.accent-bar {
    width: 48px;
    height: 3px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--yellow), var(--purple-mid));
    margin: var(--space-3) 0 var(--space-5);
}

.divider {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, var(--tan) 0%, transparent 100%);
    margin: var(--space-6) 0;
}

/* --- 5. App shell ------------------------------------------------------- */

.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: 60px 1fr;
    height: 100vh;
    overflow: hidden;

    /* Grid track sizes animate, so collapsing slides rather than jumps. */
    transition: grid-template-columns .18s var(--ease);
}

/* Collapsed: a rail of icons. Wide enough to keep the icons centred and the hit area comfortable. */
.app-shell.is-collapsed {
    grid-template-columns: 56px 1fr;
}

.app-topnav {
    grid-column: 1 / -1;
}

.app-sidebar {
    overflow-y: auto;
}

.app-content {
    overflow-y: auto;
    padding: var(--space-8);
    background: var(--paper);
}

@media (max-width: 768px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        display: none;
    }

    .app-sidebar.open {
        display: block;
        position: fixed;
        inset: 60px 0 0 0;
        z-index: 200;
        background: var(--paper);
    }

    .app-content {
        padding: var(--space-5);
    }
}

/* --- 6. Top navigation -------------------------------------------------- */

.topnav {
    height: 60px;
    background: var(--purple-deep);
    display: flex;
    align-items: center;
    padding: 0 var(--space-6);
    gap: var(--space-6);
    border-bottom: 1px solid rgba(250, 247, 242, .1);
}

.topnav-logo {
    height: 30px;
    width: auto;
    display: block;
}

.topnav-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-left: auto;
}

.topnav-user {
    font-size: 13px;
    color: rgba(250, 247, 242, .78);
}

.topnav-link {
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    color: rgba(250, 247, 242, .75);
    transition: all .15s var(--ease);
}

.topnav-link:hover {
    color: var(--paper);
    background: rgba(250, 247, 242, .1);
    text-decoration: none;
}

.topnav-link.active {
    color: var(--yellow);
    background: rgba(253, 185, 64, .12);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--paper);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-md);
}

/* An icon-only button on the dark bar. A <button> keeps the browser's own light background and border
   unless both are cleared, which is why .topnav-link — written for an <a> — leaves a white box behind. */
.topnav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    color: rgba(250, 247, 242, .75);
    cursor: pointer;
    transition: color .15s var(--ease), background-color .15s var(--ease);
}

.topnav-icon:hover {
    color: var(--paper);
    background: rgba(250, 247, 242, .1);
}

@media (max-width: 768px) {
    .nav-toggle {
        display: inline-flex;
    }
}

/* --- 7. Sidebar --------------------------------------------------------- */

.sidebar {
    background: var(--paper);
    border-right: 1px solid var(--rule);
    padding: var(--space-4) var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    height: 100%;
}

.sidebar-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--muted);
    padding: var(--space-3) var(--space-3) var(--space-1);
    margin-top: var(--space-2);
}

.sidebar-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px var(--space-3);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    color: var(--ink-soft);
    cursor: pointer;
    transition: all .15s var(--ease);
}

.sidebar-item:hover {
    background: var(--cream);
    color: var(--ink);
    text-decoration: none;
}

.sidebar-item.active {
    background: rgba(52, 12, 70, .08);
    color: var(--purple);
    font-weight: 600;
}

.sidebar-item.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    background: var(--yellow);
    border-radius: 0 2px 2px 0;
}

.sidebar-badge {
    margin-left: auto;
    padding: 1px 7px;
    background: var(--yellow-soft);
    color: var(--yellow-deep);
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 700;
}

.sidebar-icon {
    flex-shrink: 0;
    color: currentColor;
}

/* The collapse control sits at the bottom, out of the way of what it is collapsing. */
.sidebar-collapse {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding: 9px var(--space-3);
    border: none;
    border-radius: var(--radius-md);
    background: none;
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
    transition: all .15s var(--ease);
}

.sidebar-collapse:hover {
    background: var(--cream);
    color: var(--ink-soft);
}

/* --- Collapsed sidebar -------------------------------------------------- */

.is-collapsed .sidebar {
    padding-left: var(--space-2);
    padding-right: var(--space-2);
}

/* The text goes, the icon stays, and the title attribute carries the name on hover. */
.is-collapsed .sidebar-text,
.is-collapsed .sidebar-label {
    display: none;
}

.is-collapsed .sidebar-item,
.is-collapsed .sidebar-collapse {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

/* The active marker would sit under a centred icon at this width, so it becomes the background instead. */
.is-collapsed .sidebar-item.active::before {
    display: none;
}

.is-collapsed .sidebar-item.active {
    background: rgba(52, 12, 70, .12);
}

@media (max-width: 768px) {
    /* On a phone the sidebar is a drawer that covers the screen. Collapsing it to a rail there would hide the
       labels for no gain, so the rail is a desktop affordance only. */
    .app-shell.is-collapsed {
        grid-template-columns: 1fr;
    }

    .is-collapsed .sidebar-text,
    .is-collapsed .sidebar-label {
        display: revert;
    }

    .is-collapsed .sidebar-item,
    .is-collapsed .sidebar-collapse {
        justify-content: flex-start;
        padding-left: var(--space-3);
        padding-right: var(--space-3);
    }

    .sidebar-collapse {
        display: none;
    }
}

/* --- 8. Page header ----------------------------------------------------- */

/* The way out of a detail screen. Above the title on the left, where it is read before the screen itself
   rather than among the actions on the right, a misclick away from the primary button. */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: var(--space-2);
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 13px;
    color: var(--ink-soft);
    cursor: pointer;
}

.btn-back:hover { color: var(--purple); }

.btn-back:focus-visible {
    outline: 2px solid var(--purple);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}

.page-header {
    margin-bottom: var(--space-8);
    padding-bottom: var(--space-5);
    border-bottom: 1px solid var(--rule);
}

.page-header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
}

/* The buttons on the right of a page header. Their own class rather than an inline style on each page, so
   the spacing between them is decided once. */
.page-header-actions {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    flex-shrink: 0;
}

.page-title {
    font-size: clamp(22px, 2.5vw, 28px);
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.025em;
}

.page-subtitle {
    font-size: 14px;
    color: var(--muted);
    margin-top: var(--space-1);
}

/* --- 9. Buttons -------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px var(--space-5);
    border-radius: var(--radius-md);
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all .2s var(--ease);
    white-space: nowrap;
}

.btn-primary {
    background: var(--purple);
    color: var(--paper);
}

.btn-primary:hover {
    background: var(--purple-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn-accent {
    background: var(--yellow);
    color: var(--purple-deep);
}

.btn-accent:hover {
    background: #FFC84A;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

.btn-accent:focus-visible {
    outline-color: var(--purple);
}

.btn-secondary {
    background: transparent;
    color: var(--purple);
    border: 1.5px solid var(--purple);
}

.btn-secondary:hover {
    background: var(--cream);
    text-decoration: none;
}

.btn-ghost {
    background: transparent;
    color: var(--ink-soft);
    border: 1px solid var(--rule);
}

.btn-ghost:hover {
    background: var(--cream);
    border-color: var(--tan);
    color: var(--ink);
    text-decoration: none;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #991B1B;
    text-decoration: none;
}

.btn-sm { padding: 6px var(--space-4); font-size: 12px; }
.btn-lg { padding: 13px 28px; font-size: 15px; }

.btn-icon {
    padding: var(--space-2);
    border-radius: var(--radius-md);
    aspect-ratio: 1;
}

.btn-icon.btn-sm { padding: 6px; }

.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* --- 10. Cards and panels ---------------------------------------------- */

.card {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    transition: box-shadow .2s var(--ease), border-color .2s var(--ease);
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--tan);
}

.card-interactive {
    cursor: pointer;
    display: block;
    color: inherit;
}

.card-interactive:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--purple);
    text-decoration: none;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    padding: 22px var(--space-5);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    height: 4px;
    width: 100%;
    background: linear-gradient(90deg, var(--yellow), var(--cyan));
}

.stat-card .stat-value {
    font-size: 36px;
    font-weight: 600;
    color: var(--purple);
    line-height: 1;
    letter-spacing: -0.04em;
    margin-top: var(--space-2);
    font-variant-numeric: tabular-nums;
}

.stat-card .stat-label {
    font-size: 12.5px;
    color: var(--ink-soft);
    margin-top: var(--space-2);
    font-weight: 500;
}

.panel {
    background: var(--white);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.panel-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--rule);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.panel-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    flex: 1;
}

/* A heading that opens a block of a page, below the page header. For a screen with more than one subject
   where a whole .panel would be too much furniture. */
.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: var(--space-3);
}

/* The same idea inside a .card, one step down. Sized like .panel-title so a card and a panel read alike. */
.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: var(--space-4);
}

.panel-body {
    padding: var(--space-5);
}

.card-grid { display: grid; gap: var(--space-5); }
.card-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 900px) {
    .card-grid-4,
    .card-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    .card-grid-2,
    .card-grid-3,
    .card-grid-4 { grid-template-columns: minmax(0, 1fr); }
}

/* --- 11. Badges -------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .01em;
}

.badge-default { background: var(--cream); color: var(--ink-soft); }
.badge-brand { background: rgba(52, 12, 70, .1); color: var(--purple); }
.badge-accent { background: var(--yellow-soft); color: var(--yellow-deep); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }

.badge-dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* Environment badge sits on the dark topnav, so it carries its own contrast. */
.env-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.env-badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.env-badge-test { background: var(--info-soft); color: #0B4A6B; }
.env-badge-accept { background: var(--warning-soft); color: #7C4A00; }
.env-badge-production { background: var(--danger-soft); color: #7F1D1D; }

/* --- 12. Alerts -------------------------------------------------------- */

.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: 14px var(--space-4);
    border-radius: var(--radius-md);
    border-left: 4px solid;
    font-size: 14px;
    line-height: 1.5;
}

.alert-info { background: var(--info-soft); border-color: var(--info); color: #1E3A5F; }
.alert-success { background: var(--success-soft); border-color: var(--success); color: #065F46; }
.alert-warning { background: var(--warning-soft); border-color: var(--warning); color: #7C4A00; }
.alert-danger { background: var(--danger-soft); border-color: var(--danger); color: #7F1D1D; }

.alert-title { font-weight: 600; margin-bottom: 2px; }
.alert-body { font-size: 13.5px; opacity: .85; }

/* --- 13. Tables -------------------------------------------------------- */

.table-wrap {
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

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

.data-table thead {
    background: var(--cream);
}

.data-table th {
    padding: 11px var(--space-4);
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid var(--rule);
}

.data-table td {
    padding: var(--space-3) var(--space-4);
    color: var(--ink-soft);
    border-bottom: 1px solid var(--rule-soft);
    line-height: 1.5;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr {
    transition: background .1s var(--ease);
}

.data-table tbody tr:hover {
    background: var(--cream);
}

.data-table td.num,
.data-table th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

/* --- 14. Loading and empty states -------------------------------------- */

.spinner {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2.5px solid var(--tan);
    border-top-color: var(--purple);
    animation: spin .7s linear infinite;
}

.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.skeleton {
    background: linear-gradient(90deg, var(--cream) 25%, var(--tan) 50%, var(--cream) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text { height: 14px; }
.skeleton-title { height: 22px; }

@keyframes skeleton-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-12) var(--space-6);
    text-align: center;
}

.empty-state-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--cream);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-4);
    color: var(--muted);
    font-size: 24px;
}

.empty-state-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 6px;
}

.empty-state-body {
    font-size: 14px;
    color: var(--muted);
    max-width: 34ch;
    margin-bottom: var(--space-5);
}

/* --- 15. Blazor error UI ----------------------------------------------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: var(--space-4) var(--space-6);
    background: var(--danger-soft);
    color: #7F1D1D;
    border-top: 3px solid var(--danger);
    font-size: 14px;
}

#blazor-error-ui .reload {
    color: #7F1D1D;
    font-weight: 600;
    text-decoration: underline;
}

.loading-splash {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    height: 100vh;
    color: var(--muted);
    font-size: 14px;
}

/* ============================================================================
   Forms — brandbook section 5
   ========================================================================= */

.form-field { margin-bottom: var(--space-4); }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
  letter-spacing: .01em;
}

.form-label .required { color: var(--danger); margin-left: 3px; }

.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--tan);
  border-radius: var(--radius-md);
  font-family: 'Poppins', sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--white);
  line-height: 1.5;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}

.form-control::placeholder { color: var(--muted); font-weight: 300; }
.form-control:hover { border-color: var(--purple-mid); }

.form-control:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(52, 12, 70, .12);
}

.form-control:disabled {
  background: var(--cream);
  color: var(--muted);
  cursor: not-allowed;
  opacity: .7;
}

.form-control.is-error { border-color: var(--danger); }
.form-control.is-error:focus { box-shadow: 0 0 0 3px rgba(185, 28, 28, .12); }

textarea.form-control { resize: vertical; min-height: 76px; }

.form-hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 5px; font-weight: 500; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* Starting a run. The environment gets a fixed, generous share rather than an equal half: its options read
   "productie — P92974AA - Marxi", and a truncated one is a choice made without seeing it. */
.run-start-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(20rem, 26rem);
  gap: var(--space-4);
  align-items: start;
}

.run-start-row.has-sample {
  grid-template-columns: minmax(0, 1fr) minmax(20rem, 26rem) 9rem;
}

.run-start-row .form-field { margin-bottom: 0; }

@media (max-width: 900px) {
  .run-start-row,
  .run-start-row.has-sample { grid-template-columns: minmax(0, 1fr); }
}

/* A label with its state beside it, so the pill sits on the same line as the word it qualifies. */
.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: 6px;
}

.form-label-row .form-label { margin-bottom: 0; }

/* Which environment a run writes to, marked on the control itself. A dropdown that says "productie" in the
   same grey as every other field is one careless scroll away from being read as test — and that mistake
   writes into a customer's live administration. */
.env-select { border-left-width: 4px; }
.env-select-test { border-left-color: var(--info); }
.env-select-accept { border-left-color: var(--warning); }

.env-select-production {
  border-left-color: var(--danger);
  background: var(--danger-soft);
  font-weight: 500;
}

/* ============================================================================
   Modal — brandbook section 11
   ========================================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 6, 38, .55);
  display: grid;
  place-items: center;
  z-index: 8000;
  padding: var(--space-4);
  animation: fade-in .2s var(--ease);
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(560px, 100%);
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  animation: modal-in .25s var(--ease-out);
}

/* For a dialog whose content is a wall of text, such as a pasted value table. */
.modal-wide { width: min(820px, 100%); }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.modal-title { font-size: 17px; font-weight: 600; color: var(--ink); flex: 1; }

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-md);
  line-height: 1;
  transition: color .15s var(--ease), background .15s var(--ease);
}

.modal-close:hover { color: var(--ink); background: var(--cream); }

.modal-body { padding: 24px; overflow-y: auto; flex: 1; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: scale(.96) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ============================================================================
   Toasts — brandbook section 10
   ========================================================================= */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9000;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--purple-deep);
  color: var(--paper);
  box-shadow: var(--shadow-lg);
  max-width: 380px;
  animation: toast-in .3s var(--ease-out);
}

.toast-success { border-left: 3px solid var(--success); }
.toast-danger { border-left: 3px solid var(--danger); }
.toast-accent { border-left: 3px solid var(--yellow); }

.toast-title { font-size: 14px; font-weight: 600; }
.toast-body { font-size: 13px; color: rgba(250, 247, 242, .75); margin-top: 2px; }

.toast-close {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(250, 247, 242, .55);
  cursor: pointer;
  padding: 2px;
  line-height: 1;
  flex-shrink: 0;
}

.toast-close:hover { color: var(--paper); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================================
   Tabs — brandbook section 7
   ========================================================================= */

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--rule); margin-bottom: var(--space-6); }

.tab {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}

.tab:hover { color: var(--ink); }
.tab.active { color: var(--purple); font-weight: 600; border-bottom-color: var(--purple); }

/* ============================================================================
   Run progress — three segments, so a run's outcome reads at a glance
   ========================================================================= */

.progress {
  display: flex;
  height: 8px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--tan);
}

.progress-success { background: var(--success); }
.progress-warning { background: var(--orange); }
.progress-danger { background: var(--danger); }

.progress-legend { display: flex; gap: var(--space-3); margin-top: 6px; flex-wrap: wrap; }

/* ============================================================================
   Step list — the migration plan, with its dependency chips
   ========================================================================= */

.step-list { display: flex; flex-direction: column; gap: var(--space-3); }

.step-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 14px 16px;
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}

.step-row:hover { border-color: var(--tan); box-shadow: var(--shadow-sm); }
.step-row.is-disabled { opacity: .6; }
.step-row.is-clickable { cursor: pointer; }
.step-row.is-clickable:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.step-row.is-selected { border-color: var(--purple); background: var(--cream); }

/* Uploading source data: the first thing on the screen, not behind a button. */
.upload-panel {
  padding: var(--space-5);
  margin-bottom: var(--space-6);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
}

/* --- Searchable select ------------------------------------------------- */
/* A select you can type in. An AFAS update connector runs to hundreds of fields with codes nobody remembers,
   so scrolling is not a realistic way to find one. */

.ss { position: relative; }

.ss-input { cursor: text; }
.ss.is-open .ss-input { border-color: var(--purple); }

/* Clicking anywhere else closes the popup. Cheaper and more reliable than blur handling, which fires before
   the click it was meant to let through. */
.ss-backdrop {
  position: fixed;
  inset: 0;
  z-index: 8400;
}

/* Fixed, not absolute: inside a dialog an absolutely positioned popup is clipped by the dialog's own scroll
   box, and no z-index fixes that — the clipping happens before stacking is considered. The position is
   therefore measured in JavaScript and re-measured whenever anything scrolls or resizes.

   The z-index sits above the modal overlay (8000) so a popup opened inside a dialog covers it, and below the
   toasts (9000) so a message about what just happened is never hidden by a list. */
.ss-popup {
  position: fixed;
  z-index: 8500;
  max-height: 300px;
  overflow-y: auto;
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md, 8px);
  box-shadow: var(--shadow-lg);
  padding: 4px;
}

.ss-option {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm, 5px);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}

.ss-option.is-highlighted { background: var(--cream); }
.ss-option.is-selected { font-weight: 600; }
.ss-option.is-selected.is-highlighted { background: var(--cream); }

.ss-label { flex: 1; overflow-wrap: anywhere; }
.ss-hint { font-size: 11px; color: var(--muted); white-space: nowrap; }

.ss-group {
  padding: 8px 10px 3px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

.ss-empty {
  padding: 10px;
  font-size: 12.5px;
  color: var(--muted);
}

/* What a run did to its rows, at a glance in the run list. */
.run-counts {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.text-danger { color: var(--danger); }

/* A preview grid is dense and wide by nature; it scrolls in its own box rather than stretching the page. */
.preview-table { font-size: 12.5px; }
.preview-table th { padding: 8px 10px; text-transform: none; letter-spacing: 0; font-size: 12px; color: var(--ink); }
.preview-table td { padding: 5px 10px; white-space: nowrap; }

.step-order {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--cream);
  color: var(--ink-soft);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
}

.step-main { flex: 1; min-width: 0; }
.step-name { font-size: 14px; font-weight: 500; color: var(--ink); }

.step-flow {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.step-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* A run level: everything inside may run at the same time. */
.run-level { border-left: 2px solid var(--rule); padding-left: var(--space-4); margin-bottom: var(--space-4); }
.run-level-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--space-3);
}

.form-check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.form-check input[type="checkbox"], .form-check input[type="radio"] { width: 16px; height: 16px; accent-color: var(--purple); cursor: pointer; }
.form-check-label { font-size: 14px; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 6px; }

/* Fact list on a connection card: label and value in two columns, so they line up down the card. */
.conn-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px var(--space-4);
  margin: var(--space-4) 0 0;
  font-size: 12.5px;
}

.conn-facts dt { color: var(--muted); }
.conn-facts dd { margin: 0; color: var(--ink-soft); overflow-wrap: anywhere; }

/* ============================================================================
   Step editor — three panes: source, target, preview
   ========================================================================= */

.editor-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) minmax(0, 1.6fr) minmax(260px, 1fr);
  gap: var(--space-4);
  align-items: start;
}

/* Below this the three columns stop being readable; the panes stack instead. */
@media (max-width: 1200px) {
  .editor-grid { grid-template-columns: 1fr; }
}

.pane {
  background: var(--white);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.pane-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.pane-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  flex: 1;
}

.pane-body { padding: var(--space-4); }
.pane-body-flush { padding: 0; }

/* Source columns: clickable, because clicking one maps it onto the selected field. */
.column-list { display: flex; flex-direction: column; }

.column-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 16px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  border-bottom: 1px solid var(--rule-soft);
}

.column-item:hover { background: var(--cream); }
.column-item:disabled { cursor: default; opacity: .55; }
.column-name { flex: 1; overflow-wrap: anywhere; }
.column-type { font-size: 10.5px; color: var(--muted); }
.column-sample { font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }

/* Target entity tree. The left border is the nesting cue; depth comes from margin. */
.entity {
  border-left: 2px solid var(--rule);
  border-radius: 0;
  padding-left: var(--space-3);
  margin-bottom: var(--space-4);
}

.entity-root { border-left-color: var(--purple); }

.entity-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.entity-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.entity-label { font-size: 11.5px; color: var(--muted); }
.entity-children { margin-left: var(--space-4); margin-top: var(--space-3); }
.entity-ok { font-size: 12px; color: var(--success); }

/* The grouped detail rows are a tree of their own: same fields, evaluated once per row of the group. */
.detail-tree {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px dashed var(--tan);
}

.detail-tree-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--space-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}

.group-fields { display: flex; flex-wrap: wrap; gap: 5px; }

/* A row rule: its name, its condition chain, and whether it is applied. */
.rule-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 0;
  border-bottom: 1px solid var(--rule-soft);
}

.rule-row.is-invalid input { border-color: var(--danger); }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--rule-soft);
  flex-wrap: wrap;
}

.field-row.is-selected { background: var(--cream); }
.field-row.is-invalid .field-name { color: var(--danger); }

.field-name {
  min-width: 96px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.field-equals { color: var(--muted); font-size: 12px; }
.field-chain { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; flex: 1; }

.op-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(52, 12, 70, .08);
  color: var(--purple);
  font-size: 11.5px;
  font-weight: 500;
  border: none;
  font-family: 'Poppins', sans-serif;
  cursor: pointer;
}

.op-chip:hover { background: rgba(52, 12, 70, .14); }
.op-chip-source { background: var(--cream); color: var(--ink-soft); }
.op-chip-invalid { background: var(--danger-soft); color: var(--danger); }
.op-chip-add { background: none; color: var(--muted); border: 1px dashed var(--tan); }
.op-chip-add:hover { color: var(--purple); border-color: var(--purple); background: none; }

/* A free field is worth spotting: it is customer-specific and the old tool could not map it at all. */
.badge-free-field { background: rgba(125, 39, 118, .12); color: var(--purple-mid); }

.preview-json {
  margin: 0;
  padding: var(--space-4);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--paper);
  max-height: 46vh;
  overflow-y: auto;
}

.record-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.editor-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.editor-bar-spacer { flex: 1; }

/* --- 20. Markdown — de handleiding -------------------------------------- */

/* Rendered from the repository's README, so this has to cover whatever ordinary markdown produces rather
   than a fixed set of components. Deliberately narrow: prose past about 80 characters costs the reader the
   start of the next line. */

.markdown-body {
    max-width: 82ch;
    color: var(--ink-soft);
    font-size: 14.5px;
    line-height: 1.7;
}

.markdown-body > h1:first-child { margin-top: 0; }

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    color: var(--ink);
    font-weight: 600;
    line-height: 1.3;

    /* scroll-margin, not padding: the topnav is fixed, so an anchored heading would land underneath it and
       read as if the link jumped to the wrong place. */
    scroll-margin-top: 24px;
}

.markdown-body h1 { font-size: 26px; margin: var(--space-8) 0 var(--space-4); }
.markdown-body h3 { font-size: 16px; margin: var(--space-6) 0 var(--space-3); }
.markdown-body h4 { font-size: 14.5px; margin: var(--space-5) 0 var(--space-2); }

/* A rule above each chapter, so the eye finds them while scrolling. */
.markdown-body h2 {
    font-size: 20px;
    margin: var(--space-8) 0 var(--space-4);
    border-top: 1px solid var(--tan);
    padding-top: var(--space-5);
}

.markdown-body p { margin: 0 0 var(--space-4); }

.markdown-body ul,
.markdown-body ol { margin: 0 0 var(--space-4); padding-left: 22px; }

.markdown-body li { margin-bottom: 5px; }
.markdown-body li > ul,
.markdown-body li > ol { margin-top: 5px; }

.markdown-body a { text-decoration: underline; text-underline-offset: 2px; }
.markdown-body a:hover { color: var(--purple); }

/* Table-of-contents links carry no href, so they need the pointer back. */
.markdown-body .md-anchor { color: var(--cyan); cursor: pointer; }

.markdown-body strong { color: var(--ink); font-weight: 600; }

.markdown-body code {
    font-family: 'Cascadia Mono', 'Consolas', monospace;
    font-size: .88em;
    background: var(--cream);
    border-radius: var(--radius-sm);
    padding: 1px 5px;
}

.markdown-body pre {
    background: var(--cream);
    border: 1px solid var(--tan);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    overflow-x: auto;
    margin: 0 0 var(--space-4);
}

.markdown-body pre code { background: none; padding: 0; font-size: 13px; line-height: 1.55; }

/* Tables carry most of the reference material. In their own scroll box: a wide table must not make the
   page scroll sideways. */
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 var(--space-5);
    font-size: 13.5px;
    display: block;
    overflow-x: auto;
}

.markdown-body th,
.markdown-body td {
    border-bottom: 1px solid var(--tan);
    padding: 8px 12px;
    text-align: left;
    vertical-align: top;
}

.markdown-body th {
    background: var(--cream);
    color: var(--ink);
    font-weight: 600;
    white-space: nowrap;
}

.markdown-body tbody tr:hover { background: var(--paper); }

/* Blockquotes carry the things that cost money when they are ignored. */
.markdown-body blockquote {
    margin: 0 0 var(--space-4);
    padding: var(--space-3) var(--space-4);
    border-left: 4px solid var(--yellow);
    background: var(--paper);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.markdown-body blockquote p:last-child { margin-bottom: 0; }

.markdown-body hr { border: 0; border-top: 1px solid var(--tan); margin: var(--space-8) 0; }

.markdown-body img { max-width: 100%; }

/* --- 21. Sneltoetsen ----------------------------------------------------- */

kbd {
    display: inline-block;
    min-width: 22px;
    padding: 2px 6px;
    border: 1px solid var(--tan);
    border-bottom-width: 2px;
    border-radius: var(--radius-sm);
    background: var(--paper);
    color: var(--ink);
    font-family: 'Poppins', sans-serif;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.5;
    text-align: center;
    white-space: nowrap;
}

.shortcut-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--space-6);
    margin: var(--space-5) 0;
}

.shortcut-group {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--purple);
    margin-bottom: var(--space-3);
}

/* Keys left, meaning right. A grid rather than a table so the key column stays exactly as wide as the
   widest combination and no wider. */
.shortcut-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 7px var(--space-3);
    align-items: baseline;
    margin: 0;
}

.shortcut-list dt { display: flex; align-items: center; gap: 3px; }
.shortcut-list dd { margin: 0; font-size: 13px; color: var(--ink-soft); }

.shortcut-then { font-size: 11px; color: var(--muted); }

/* Het veldoverzicht van een doelentiteit: alle nog te mappen velden zichtbaar in plaats van achter een
   keuzelijst. Begrensd in hoogte omdat een connector tot honderden velden loopt en de boom navigeerbaar moet
   blijven; scrollen binnen het vak in plaats van de pagina laten groeien. */
.field-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 168px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  background: var(--paper);
}

/* Het veld zelf leest voor, de omschrijving erachter is context. Zonder dit onderscheid wordt een rij van
   twintig chips één grijze massa waarin de veldnaam niet opvalt. */
.field-picker .op-chip { align-items: baseline; }
.field-picker .op-chip > span:first-child { font-weight: 600; }
.field-picker .op-chip > .text-muted { font-weight: 400; font-size: 11px; }

/* De uitkomst van de groepering, in cijfers. Een eigen blok en geen form-hint: dit is geen toelichting bij
   een veld maar het antwoord op de vraag die de keuze oproept — hoeveel records worden dit. Een stap die
   op een urenkolom groepeerde maakte van 5.260 rijen 6 records, en de toelichting eronder was waar zonder
   dat iemand het kon zien. */
.grouping-count {
    font-size: 12px;
    color: var(--ink);
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    background: var(--cream);
    border-left: 3px solid var(--cyan);
}

.grouping-count-warn { border-left-color: var(--warning); }

.grouping-count-note { margin-top: 6px; color: var(--muted); }
