/* DPDP Connect admin — design system v2 (plain CSS, light + dark). See DESIGN.md.
   "Calm surfaces, one clear signal": ink and violet carry structure, one lime dot marks what needs a person,
   white rounded surfaces sit on a warm canvas, evidence is set in mono.
   Semantic tokens first (the prototype's names); the app's older names (--background, --card, --foreground,
   --muted-foreground, --accent…) are aliases onto them so every existing rule keeps resolving. */
:root {
    /* ---- Brand scales (source of the semantic tokens; never used directly in components) ---- */
    --ink-950: #0C0B12;
    --ink-900: #14121F;
    --ink-800: #1D1A2B;
    --ink-700: #2A2740;
    --violet-50: #F5F2FF;
    --violet-100: #ECE6FF;
    --violet-200: #D9CEFF;
    --violet-300: #BCA9FF;
    --violet-400: #9B80FF;
    --violet-500: #7D5BFF;
    --violet-600: #4A2AC8;
    --violet-700: #3D22A8;
    --violet-800: #311B88;
    --violet-900: #24136A;
    --lime-100: #F1FCC9;
    --lime-300: #DBF76A;
    --lime-400: #C7F23A;
    --lime-500: #B2DF1E;
    --lime-700: #5E7A00;

    /* ---- Semantic (light) ---- */
    --bg: #F4F3F0;
    --bg-sunken: #ECEAE5;
    --surface: #FFFFFF;
    --surface-2: #FAF9F7;
    --surface-3: #F2F0EC;
    --border: #E7E4DD;
    --border-strong: #D5D1C7;
    --hairline: #EFECE6;

    --text: #14121F;
    --text-2: #4B4859;
    --muted: #6C6879;
    --faint: #9C98A9;

    --primary: var(--violet-600);
    --primary-hover: var(--violet-700);
    --primary-press: var(--violet-800);
    --primary-soft: var(--violet-50);
    --primary-soft-2: var(--violet-100);
    --primary-text: var(--violet-700);
    --on-primary: #FFFFFF;

    --signal: var(--lime-400);
    --on-signal: var(--ink-900);

    --success: #1C8B57;
    --success-soft: #E2F5EA;
    --success-text: #0F6A3E;
    --warning: #D98A0B;
    --warning-soft: #FFF0D3;
    --warning-text: #8F5300;
    --danger: #DC3B3B;
    --danger-soft: #FDE7E6;
    --danger-text: #AE2020;
    --info: #3563E9;
    --info-soft: #E7EEFF;
    --info-text: #1D47C0;
    --neutral-soft: #EEECF2;
    --neutral-text: #4B4859;
    --gold-soft: #F8EFC6;
    --gold-text: #6E5200;

    /* ---- Data-viz series ---- */
    --viz-1: var(--violet-600);
    --viz-2: var(--ink-900);
    --viz-3: #7C9C00;
    --viz-grid: #E9E6DF;
    --viz-axis: #6C6879;

    /* ---- Ink surfaces (hero cards) ---- */
    --hero-bg: var(--ink-900);
    --hero-bg-2: var(--ink-800);
    --hero-text: #FFFFFF;
    --hero-muted: #B6B2C6;
    --hero-line: rgba(255, 255, 255, .12);
    --hero-glass: rgba(255, 255, 255, .07);

    /* ---- Module code colours (reference prefixes DPR / INC / REG / CON) ---- */
    --code-rights: var(--violet-600);
    --code-incident: #E0338A;
    --code-regulator: var(--violet-400);
    --code-consent: #0F9D9D;
    --code-governance: #6C6879;

    /* ---- Shape ---- */
    --r-xs: 6px;
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-xl: 28px;
    --r-pill: 999px;

    /* ---- Elevation ---- */
    --shadow-xs: 0 1px 2px rgba(20, 18, 31, .05);
    --shadow-sm: 0 1px 2px rgba(20, 18, 31, .04), 0 6px 18px -10px rgba(20, 18, 31, .12);
    --shadow-md: 0 2px 4px rgba(20, 18, 31, .04), 0 16px 36px -16px rgba(20, 18, 31, .22);
    --shadow-lg: 0 8px 16px rgba(20, 18, 31, .06), 0 32px 64px -24px rgba(20, 18, 31, .35);
    --focus-ring: 0 0 0 3px rgba(var(--accent-rgb), .22);
    --overlay: rgba(12, 11, 18, .55);

    /* ---- Type ---- */
    --font: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --fs-2xs: 11px;
    --fs-xs: 12px;
    --fs-sm: 13px;
    --fs-base: 14px;
    --fs-md: 16px;
    --fs-lg: 20px;
    --fs-xl: 26px;
    --fs-2xl: 32px;
    --fs-3xl: 44px;

    /* ---- Layout ---- */
    /* The side navigation grows with the text size (Display settings), so the longest label still fits at "Largest". */
    --nav-w: max(280px, calc(288px * var(--ts-user, 1)));
    --content-max: 1520px;
    --gutter: 28px;
    --page-w: calc(var(--content-max) + var(--gutter) * 2);
    --shell-pad: 12px;
    --shell-gap: 8px;

    --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236C6879' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");

    /* ---- Motion ---- */
    --m-instant: 80ms;
    --m-quick: 150ms;
    --m-base: 250ms;
    --m-slow: 320ms;
    --m-stage: 560ms;
    --ease-out: cubic-bezier(.2, .8, .2, 1);
    --ease-in-out: cubic-bezier(.65, 0, .35, 1);
    --ease-spring: cubic-bezier(.3, 1.3, .5, 1);

    /* ---- Aliases: the app's earlier token names map onto the semantic set above ---- */
    --background: var(--bg);
    --foreground: var(--text);
    --card: var(--surface);
    --card-foreground: var(--text);
    --popover: var(--surface);
    --muted-foreground: var(--muted);
    --subtle: var(--faint);
    --nav-foreground: var(--text-2);
    --input: var(--border-strong);
    --ring: var(--primary);
    --primary-foreground: var(--on-primary);
    --secondary: var(--surface-3);
    --secondary-hover: var(--surface-3);
    --accent: var(--primary);
    --accent-hover: var(--primary-hover);
    --accent-soft: var(--primary-soft);
    --accent-foreground: var(--primary-text);
    --lime: var(--signal);
    --lime-soft: var(--lime-100);
    --lime-foreground: var(--on-signal);
    --destructive: var(--danger);
    --destructive-soft: var(--danger-soft);
    --ink-surface: var(--hero-bg);
    --ink-surface-2: var(--hero-bg-2);
    --ink-foreground: var(--hero-text);
    --on-ink-danger: #FF9A97;
    --on-ink-warning: #F6C46B;
    --chart-1: var(--viz-1);
    --chart-2: var(--success);
    --chart-3: var(--warning);
    --chart-4: var(--viz-3);
    --sidebar: var(--surface);
    --sidebar-foreground: var(--text-2);
    --sidebar-active: var(--surface-3);
    --shadow: var(--shadow-sm);
    --shadow-lift: var(--shadow-md);
    --radius: var(--r-md);
    --radius-sm: var(--r-sm);
    --radius-card: var(--r-lg);
    --radius-pill: var(--r-pill);
    --sans: var(--font);
    --serif: var(--font);
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0C0B12;
    --bg-sunken: #08070D;
    --surface: #15131F;
    --surface-2: #1B1927;
    --surface-3: #221F31;
    --border: #28253A;
    --border-strong: #3A3650;
    --hairline: #201D2E;

    --text: #F3F1FB;
    --text-2: #C4C0D4;
    --muted: #9591A8;
    --faint: #6F6B84;

    --primary: #7D5BFF;
    --primary-hover: #8F72FF;
    --primary-press: #6A45FF;
    --primary-soft: rgba(125, 91, 255, .14);
    --primary-soft-2: rgba(125, 91, 255, .24);
    --primary-text: #B9A6FF;
    --on-primary: #FFFFFF;

    --success: #3FCB8A;
    --success-soft: rgba(63, 203, 138, .14);
    --success-text: #6EE0AA;
    --warning: #F2B13C;
    --warning-soft: rgba(242, 177, 60, .14);
    --warning-text: #F6C46B;
    --danger: #FF6B68;
    --danger-soft: rgba(255, 107, 104, .15);
    --danger-text: #FF9A97;
    --info: #6F93FF;
    --info-soft: rgba(111, 147, 255, .15);
    --info-text: #9DB6FF;
    --neutral-soft: rgba(255, 255, 255, .08);
    --neutral-text: #C4C0D4;
    --gold-soft: rgba(232, 200, 80, .15);
    --gold-text: #EFD36A;

    --viz-1: #8F72FF;
    --viz-2: #E9E6F5;
    --viz-3: var(--lime-400);
    --viz-grid: #26233A;
    --viz-axis: #9591A8;

    --hero-bg: linear-gradient(135deg, #231D44 0%, #17142A 55%, #131120 100%);
    --hero-bg-2: #1B1830;
    --hero-line: rgba(255, 255, 255, .10);

    --code-rights: #9B80FF;
    --code-incident: #F06AA9;
    --code-regulator: #BCA9FF;
    --code-consent: #2FC4C4;
    --code-governance: #9591A8;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px -10px rgba(0, 0, 0, .6);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, .3), 0 16px 36px -16px rgba(0, 0, 0, .7);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, .4), 0 32px 64px -24px rgba(0, 0, 0, .8);
    --focus-ring: 0 0 0 3px rgba(125, 91, 255, .38);
    --overlay: rgba(0, 0, 0, .6);

    --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239591A8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
}

body {
    font-family: var(--sans);
    color: var(--foreground);
    background: var(--background);
    font-size: calc(var(--fs-body) * var(--ts));
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--foreground);
    text-underline-offset: 3px;
}

    a:hover {
        color: var(--accent-foreground);
    }

input, select, button, textarea {
    font: inherit;
    color: inherit;
}

:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

h1, h2, h3, h4 {
    margin: 0;
    letter-spacing: -.01em;
}

.mono {
    font-family: var(--mono);
    font-size: calc(14px * var(--ts));
    font-weight: 500;
    letter-spacing: -.01em;
}

.serif {
    font-family: var(--serif);
}

.muted {
    color: var(--muted-foreground);
}

.small {
    font-size: calc(14px * var(--ts));
}

.xsmall {
    font-size: calc(14px * var(--ts));
}

.nowrap {
    white-space: nowrap;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.hidden, [hidden] {
    display: none !important;
}

.row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.spacer {
    flex: 1;
}

.right {
    text-align: right;
}

.icon {
    width: 16px;
    height: 16px;
    flex: none;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---------- App shell */
.shell {
    min-height: 100vh;
    display: flex;
}

.sidenav {
    width: 272px;
    flex: none;
    background: var(--sidebar);
    color: var(--sidebar-foreground);
    padding: 16px 12px 12px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

@media (max-width: 1366px) {
    .sidenav {
        width: 248px;
    }
}

/* Only the menu scrolls; the logo (top) and the profile row (bottom) stay put. */
.nav-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0 -12px;
    padding: 2px 12px;
    scrollbar-width: thin;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px;
}

.brand-mark {
    display: block;
    width: auto;
    height: 30px;
    flex: none;
}

.brand-name {
    color: var(--foreground);
    font-weight: 600;
    font-size: calc(16px * var(--ts));
    line-height: 1.2;
}

.brand-sub {
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

/* Section labels (Main, Compliance, Settings) sit above the rows they hold. */
.nav-section {
    margin: 16px 0 6px;
    padding: 0 10px;
    font-size: calc(13px * var(--ts));
    font-weight: 500;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--subtle);
}

.nav-group:first-child .nav-section { margin-top: 4px; }

/* A group's title reads as a top-level row; its pages hang from a tree line below it. */
.nav-title {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 40px;
    flex: none;
    padding: 0 10px;
    font-size: calc(15px * var(--ts));
    font-weight: 500;
    color: var(--sidebar-foreground);
}

    .nav-title .icon { opacity: .85; }

/* Collapsible menu groups: the group holding the current page stays open. */
summary.nav-title {
    list-style: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background .15s, color .15s;
}

    summary.nav-title::-webkit-details-marker {
        display: none;
    }

    summary.nav-title:hover {
        background: var(--sidebar-active);
        color: var(--foreground);
    }

    summary.nav-title::after {
        content: '';
        width: 7px;
        height: 7px;
        margin: 0 3px 0 auto;
        border-right: 1.5px solid currentColor;
        border-bottom: 1.5px solid currentColor;
        transform: rotate(-45deg);
        transition: transform .15s;
    }

details.nav-group[open] > summary.nav-title::after {
    transform: rotate(45deg);
}

details.nav-group > .nav-link {
    position: relative;
    height: 36px;
    margin-left: 17px;
    padding-left: 16px;
}

    details.nav-group > .nav-link .icon { display: none; }

    details.nav-group > .nav-link::before {
        content: '';
        position: absolute;
        left: 0;
        top: -1px;
        bottom: -1px;
        width: 1px;
        background: var(--input);
        opacity: .5;
    }

.nav-link {
    height: 40px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-foreground);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: calc(15px * var(--ts));
    font-weight: 500;
    transition: background .15s, color .15s;
}

    .nav-link:hover {
        background: var(--sidebar-active);
        color: var(--foreground);
    }

    .nav-link.active {
        background: var(--accent-soft);
        color: var(--accent-foreground);
        font-weight: 600;
    }

    .nav-link.active .icon {
        color: var(--accent-foreground);
        opacity: 1;
    }

    .nav-link .icon {
        opacity: .85;
    }

.nav-count {
    margin-left: auto;
    font-size: calc(13px * var(--ts));
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-foreground);
}

.nav-foot {
    flex: none;
    display: flex;
    align-items: center;
    gap: 4px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.nav-user {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    color: inherit;
    text-decoration: none;
    transition: background .15s;
}

    .nav-user:hover, .nav-user.active { background: var(--sidebar-active); }
    .nav-user.active { box-shadow: inset 1px -1px 0 var(--accent); }
    .nav-user .avatar { flex: none; }

.nav-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.nav-user-text > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-signout { flex: none; }
.nav-signout .btn-icon { width: 40px; height: 40px; color: var(--muted-foreground); }
.nav-signout .btn-icon:hover { color: var(--destructive, #dc2626); }

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-foreground);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: calc(13px * var(--ts));
    flex: none;
    border: 1px solid var(--border);
}

.avatar-lg {
    width: 44px;
    height: 44px;
    font-size: calc(15px * var(--ts));
}

.nav-user-name {
    color: var(--foreground);
    font-weight: 600;
    font-size: calc(14px * var(--ts));
}

.nav-user-role {
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 32px;
    height: 64px;
    flex: none;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.crumbs {
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
    display: flex;
    align-items: center;
    gap: 8px;
}

    .crumbs strong {
        color: var(--foreground);
        font-weight: 500;
    }

.content {
    padding: 24px 32px 40px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 1640px;
    width: 100%;
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
}

.page-title {
    font-weight: 600;
    font-size: 24px;
    letter-spacing: -.02em;
    color: var(--foreground);
}

.page-sub {
    margin: 4px 0 0;
    font-size: calc(15px * var(--ts));
    color: var(--muted-foreground);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.btn.menu-btn {
    display: none;
}

/* ---------- Buttons */
.btn {
    height: 36px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: calc(14px * var(--ts));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--foreground);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    transition: background .15s, border-color .15s, color .15s, transform .05s;
}

    .btn:hover {
        background: var(--surface-2);
        color: var(--foreground);
    }

    .btn:active {
        transform: translateY(1px);
    }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-foreground);
}

    .btn-primary:hover {
        background: var(--primary-hover);
        border-color: var(--primary-hover);
        color: var(--primary-foreground);
    }

.btn-accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

    .btn-accent:hover {
        filter: brightness(1.06);
        color: #fff;
        background: var(--accent);
    }

.btn-secondary {
    background: var(--surface-3);
    border-color: transparent;
    box-shadow: none;
}

    .btn-secondary:hover {
        background: var(--surface-3);
    }

.btn-ghost {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

    .btn-ghost:hover {
        background: var(--surface-2);
    }

.btn-danger {
    background: var(--destructive);
    border-color: var(--destructive);
    color: #fff;
}

    .btn-danger:hover {
        filter: brightness(1.05);
        background: var(--destructive);
        color: #fff;
    }

.btn-sm {
    height: 36px;
    padding: 0 10px;
    font-size: calc(14px * var(--ts));
}

.btn-lg {
    height: 42px;
    padding: 0 18px;
    font-size: calc(15px * var(--ts));
}

.btn-icon {
    width: 36px;
    padding: 0;
}

.btn-sm.btn-icon {
    width: 36px;
}

.btn-block {
    width: 100%;
}

.btn-link {
    background: none;
    border: 0;
    padding: 0;
    color: var(--foreground);
    font-weight: 500;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.btn[disabled], .btn.disabled {
    opacity: .5;
    pointer-events: none;
}

.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

    .btn.loading::after {
        content: '';
        position: absolute;
        width: 15px;
        height: 15px;
        border-radius: 50%;
        border: 2px solid currentColor;
        border-color: var(--primary-foreground) transparent var(--primary-foreground) transparent;
        animation: spin .7s linear infinite;
    }

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---------- Cards, panels */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: var(--shadow-sm);
}

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.card-title {
    font-size: calc(17px * var(--ts));
    font-weight: 600;
    color: var(--foreground);
    letter-spacing: -.01em;
}

.card-desc {
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
    margin-top: 2px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
    gap: 16px;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) .45fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 1180px) {
    .split {
        grid-template-columns: 1fr;
    }
}

.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 20px;
    margin-block: 4px;
}

.kpi {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    text-decoration: none;
    color: var(--foreground);
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-sm);
    transition: border-color .15s, transform .15s;
}

    .kpi:hover {
        border-color: var(--accent);
        color: var(--foreground);
        transform: translateY(-1px);
    }

.kpi-label {
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
    font-weight: 500;
}

.kpi-value {
    font-size: 30px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -.02em;
}

.kpi-hint {
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
}

.list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 11px 0;
    border-top: 1px solid var(--border);
}

.dot {
    width: 8px;
    height: 8px;
    margin-top: 7px;
    border-radius: 50%;
    background: var(--accent);
    flex: none;
}

/* ---------- Alerts / toasts */
.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: calc(14px * var(--ts));
    line-height: 1.5;
    border: 1px solid var(--border);
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    align-items: flex-start;
    background: var(--card);
}

    /* Leading icon sits on the first text line; the text block takes the rest of the row. */
    .alert > .icon {
        flex: none;
        margin-top: 2.5px;
    }

    .alert > span {
        flex: 1;
        min-width: 0;
    }

.alert-ok {
    background: var(--success-soft);
    border-color: color-mix(in srgb, var(--success) 30%, transparent);
    color: var(--success);
}

.alert-err {
    background: var(--destructive-soft);
    border-color: color-mix(in srgb, var(--destructive) 30%, transparent);
    color: var(--destructive);
}

.alert-warn {
    background: var(--warning-soft);
    border-color: color-mix(in srgb, var(--warning) 30%, transparent);
    color: var(--warning);
}

.alert-info {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--muted-foreground);
}

.alert-close {
    margin-left: auto;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: calc(18px * var(--ts));
    cursor: pointer;
    line-height: 1;
    opacity: .7;
}

.toasts {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(420px, calc(100vw - 32px));
}

    .toasts .alert {
        box-shadow: var(--shadow-lg);
        animation: toast-in .25s ease-out;
        background: var(--popover);
    }

    .toasts .alert-ok {
        border-color: color-mix(in srgb, var(--success) 40%, var(--border));
        background: color-mix(in srgb, var(--success) 6%, var(--popover));
        color: var(--foreground);
    }

    .toasts .alert-err {
        border-color: color-mix(in srgb, var(--destructive) 40%, var(--border));
        background: color-mix(in srgb, var(--destructive) 6%, var(--popover));
        color: var(--foreground);
    }

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px) scale(.98);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ---------- Badges (status colours come from the status master as --badge) */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: calc(13px * var(--ts));
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid transparent;
}

    .badge::before {
        content: '';
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: currentColor;
    }

.badge-plain::before {
    display: none;
}

.badge-green {
    background: var(--success-soft);
    color: var(--success);
}

.badge-amber {
    background: var(--warning-soft);
    color: var(--warning);
}

.badge-red {
    background: var(--destructive-soft);
    color: var(--destructive);
}

.badge-dark {
    background: var(--surface-2);
    color: var(--foreground);
    border-color: var(--border);
}

.badge-blue {
    background: var(--info-soft);
    color: var(--info);
}

.badge-grey {
    background: var(--surface-2);
    color: var(--muted-foreground);
}

.badge-gold {
    background: var(--accent-soft);
    color: var(--accent-foreground);
}

.badge-dyn {
    background: color-mix(in srgb, var(--badge) 13%, transparent);
    color: var(--badge);
}

:root[data-theme="dark"] .badge-dyn {
    background: color-mix(in srgb, var(--badge) 22%, transparent);
    color: color-mix(in srgb, var(--badge) 60%, white);
}

/* ---------- Forms */
.form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: 14px 16px;
}

    .form-grid .span-2 {
        grid-column: 1 / -1;
    }

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: calc(var(--fs-label) * var(--ts));
    font-weight: 500;
    color: var(--foreground);
    min-width: 0;
}

.field-hint {
    font-size: calc(14px * var(--ts));
    font-weight: 400;
    color: var(--muted-foreground);
}

.req::after {
    content: ' *';
    color: var(--destructive);
}

.input, .select, .textarea {
    height: 36px;
    padding: 0 11px;
    border: 1px solid var(--input);
    border-radius: var(--radius-sm);
    background: var(--card);
    font-size: calc(14px * var(--ts));
    font-weight: 400;
    width: 100%;
    box-shadow: var(--shadow-sm);
    transition: border-color .15s, box-shadow .15s;
}

    .input:focus, .select:focus, .textarea:focus {
        outline: none;
        border-color: var(--ring);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 18%, transparent);
    }

    .input::placeholder, .textarea::placeholder {
        color: var(--subtle);
    }

/* A textarea styled as .input still grows to its rows, rather than the single-line control height. */
.textarea, textarea.input {
    height: auto;
    min-height: 96px;
    padding: 9px 11px;
    resize: vertical;
    line-height: 1.5;
}

.input[readonly], .input:disabled {
    background: var(--surface-2);
    color: var(--muted-foreground);
}

.input[type=file] {
    padding: 6px 8px;
    height: auto;
}

.input[type=date] {
    padding-right: 6px;
}

.input-error, .input.input-validation-error, .select.input-validation-error, .textarea.input-validation-error, .combo.input-validation-error .combo-btn {
    border-color: var(--destructive) !important;
}

.field-validation-error, .err {
    font-size: calc(14px * var(--ts));
    font-weight: 400;
    color: var(--destructive);
}

    .err:empty {
        display: none;
    }

.validation-summary-errors ul {
    margin: 0;
    padding-left: 18px;
}

.validation-summary-valid {
    display: none !important;
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: calc(14px * var(--ts));
    font-weight: 400;
    color: var(--foreground);
    cursor: pointer;
}

.input-group {
    display: flex;
    gap: 0;
}

    .input-group > .prefix {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
        border-right: 0;
    }

    .input-group > .input {
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
    }

.prefix {
    height: 36px;
    min-width: 64px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--input);
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
    font-family: var(--mono);
}

fieldset.plain {
    border: 0;
    padding: 0;
    margin: 0;
    min-width: 0;
}

/* Toggle switch: every checkbox renders as a switch (add .cb to keep a plain box). */
input[type=checkbox]:not(.cb) {
    appearance: none;
    -webkit-appearance: none;
    width: 36px;
    height: 20px;
    border-radius: 999px;
    background: var(--input);
    position: relative;
    cursor: pointer;
    flex: none;
    margin: 0;
    transition: background .2s;
    border: 0;
}

    input[type=checkbox]:not(.cb)::after {
        content: '';
        position: absolute;
        top: 2px;
        left: 2px;
        width: 16px;
        height: 16px;
        border-radius: 50%;
        background: #fff;
        box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
        transition: transform .2s cubic-bezier(.3, .7, .4, 1);
    }

    input[type=checkbox]:not(.cb):checked {
        background: var(--primary);
    }

:root[data-theme="dark"] input[type=checkbox]:not(.cb):checked {
    background: var(--accent);
}

input[type=checkbox]:not(.cb):checked::after {
    transform: translateX(16px);
}

input[type=checkbox]:not(.cb):disabled {
    opacity: .5;
    cursor: not-allowed;
}

input[type=checkbox].cb {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

input[type=radio] {
    accent-color: var(--primary);
}

/* ---------- Searchable select (combobox) */
.combo {
    position: relative;
    width: 100%;
    min-width: 0;
}

    .combo > select {
        position: absolute;
        opacity: 0;
        pointer-events: none;
        width: 1px;
        height: 1px;
        bottom: 0;
        left: 12px;
    }

.combo-btn {
    width: 100%;
    height: 36px;
    padding: 0 32px 0 11px;
    border: 1px solid var(--input);
    border-radius: var(--radius-sm);
    background: var(--card);
    text-align: left;
    cursor: pointer;
    font-size: calc(14px * var(--ts));
    font-weight: 400;
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    display: block;
}

    .combo-btn::after {
        content: '';
        position: absolute;
        right: 12px;
        top: 50%;
        width: 7px;
        height: 7px;
        border-right: 1.5px solid var(--muted-foreground);
        border-bottom: 1.5px solid var(--muted-foreground);
        transform: translateY(-70%) rotate(45deg);
    }

    .combo-btn.placeholder {
        color: var(--subtle);
    }

    .combo-btn:disabled {
        background: var(--surface-2);
        cursor: not-allowed;
        color: var(--muted-foreground);
    }

.combo.open .combo-btn {
    border-color: var(--ring);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 18%, transparent);
}

.combo-pop {
    position: absolute;
    z-index: 60;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    min-width: 220px;
    background: var(--popover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    animation: pop-in .12s ease-out;
}

    .combo-pop.up {
        top: auto;
        bottom: calc(100% + 4px);
    }

@keyframes pop-in {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(.98);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.combo-search {
    width: 100%;
    height: 34px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    padding: 0 8px 0 30px;
    font-size: calc(14px * var(--ts));
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 9px center;
}

.combo-list {
    max-height: 260px;
    overflow-y: auto;
    padding: 4px 0 0;
    list-style: none;
    margin: 0;
}

.combo-opt {
    padding: 7px 8px 7px 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: calc(14px * var(--ts));
    position: relative;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

    .combo-opt.active {
        background: var(--surface-2);
    }

    .combo-opt.selected::before {
        content: '';
        position: absolute;
        left: 10px;
        top: 50%;
        width: 8px;
        height: 4px;
        border-left: 2px solid var(--foreground);
        border-bottom: 2px solid var(--foreground);
        transform: translateY(-70%) rotate(-45deg);
    }

    .combo-opt .sub {
        color: var(--muted-foreground);
        font-size: calc(14px * var(--ts));
    }

.combo-empty {
    padding: 14px 8px;
    text-align: center;
    color: var(--muted-foreground);
    font-size: calc(14px * var(--ts));
}

.toolbar .combo {
    width: auto;
    min-width: 180px;
}

/* ---------- Toolbar + tabs */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
}

    .toolbar .input, .toolbar .select {
        width: auto;
        min-width: 160px;
    }

    .toolbar .grow {
        flex: 1 1 240px;
    }

    .toolbar .field {
        gap: 4px;
        font-size: calc(14px * var(--ts));
        color: var(--muted-foreground);
    }

.filters {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow-sm);
}

.tabs {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--surface-2);
    border-radius: var(--radius);
    overflow-x: auto;
    position: relative;
    max-width: 100%;
}

.tab {
    height: 30px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    color: var(--muted-foreground);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: calc(14px * var(--ts));
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    border: 0;
    background: transparent;
    position: relative;
    z-index: 1;
    transition: color .2s;
}

    .tab:hover {
        color: var(--foreground);
    }

    .tab.active {
        color: var(--foreground);
    }

.tabs:not(.js-tabs) .tab.active {
    background: var(--card);
    box-shadow: var(--shadow);
}

.tab-ink {
    position: absolute;
    z-index: 0;
    top: 3px;
    bottom: 3px;
    left: 0;
    border-radius: var(--radius-sm);
    background: var(--card);
    box-shadow: var(--shadow);
    transition: transform .28s cubic-bezier(.3, .7, .4, 1), width .28s cubic-bezier(.3, .7, .4, 1);
}

.tab-count {
    font-size: calc(13px * var(--ts));
    padding: 0 6px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--muted-foreground);
    line-height: 18px;
}

.tab.active .tab-count {
    background: var(--primary);
    color: var(--primary-foreground);
}

.tabs-line {
    display: flex;
    gap: 18px;
    border-bottom: 1px solid var(--border);
    background: none;
    padding: 0;
    border-radius: 0;
}

    .tabs-line .tab {
        height: 38px;
        padding: 0 2px;
        border-radius: 0;
    }

    .tabs-line .tab-ink {
        top: auto;
        bottom: -1px;
        height: 2px;
        background: var(--foreground);
        box-shadow: none;
        border-radius: 2px;
    }

.tab-panel {
    animation: panel-in .28s ease-out;
}

    .tab-panel:not(.active) {
        display: none;
    }

@keyframes panel-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ---------- Tables */
.table-wrap {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: calc(14px * var(--ts));
}

.table th.right { text-align: right; }

.table th {
    text-align: left;
    padding: 10px 14px;
    font-size: calc(14px * var(--ts));
    font-weight: 500;
    color: var(--muted-foreground);
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface-2) 55%, transparent);
}

.table td {
    padding: 11px 14px;
    border-top: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr:first-child td {
    border-top: 0;
}

.table tr.selected td {
    background: var(--accent-soft);
}

.table tbody tr {
    transition: background .12s;
}

    .table tbody tr:hover td {
        background: color-mix(in srgb, var(--surface-2) 60%, transparent);
    }

.table tr.clickable {
    cursor: pointer;
}

.table td.mono {
    white-space: nowrap;
}

.table .row-link {
    color: var(--foreground);
    font-weight: 500;
    text-decoration: none;
}

    .table .row-link:hover {
        text-decoration: underline;
    }

/* Case references (DPR-2026-00003): the body face with even-width digits reads easier than a heavy monospace. */
.ref-id,
.table .row-link.ref-id {
    font-family: inherit;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    letter-spacing: .01em;
    white-space: nowrap;
}

.table-foot {
    padding: 10px 14px;
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.pager {
    display: flex;
    gap: 4px;
    align-items: center;
}

.pager-status {
    display: none;
}

.empty {
    padding: 48px 14px;
    text-align: center;
    color: var(--muted-foreground);
}

    .empty .icon {
        width: 28px;
        height: 28px;
        margin-bottom: 8px;
        opacity: .6;
    }

/* ---------- Detail panel */
.panel {
    min-width: 400px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 72px;
    box-shadow: var(--shadow-sm);
}

@media (max-width: 480px) {
    .panel {
        min-width: fit-content;
    }
}

.dl {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 9px 12px;
    margin: 0;
    font-size: calc(14px * var(--ts));
}

    .dl dt {
        color: var(--muted-foreground);
    }

    .dl dd {
        margin: 0;
        min-width: 0;
        overflow-wrap: anywhere;
    }

.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

    .timeline li {
        display: flex;
        gap: 10px;
        font-size: calc(14px * var(--ts));
    }

.section-title {
    font-size: calc(14px * var(--ts));
    font-weight: 500;
    color: var(--muted-foreground);
}

.divider {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 0;
}

/* ---------- Choice cards */
.choice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card);
    cursor: pointer;
    font-weight: 400;
    transition: border-color .15s, background .15s;
}

    .choice:hover {
        border-color: var(--subtle);
    }

    .choice:has(input:checked) {
        border-color: var(--accent);
        background: var(--accent-soft);
        box-shadow: 0 0 0 1px var(--accent);
    }

/* ---------- Dialog (modal) + sheet (side panel) */
dialog.modal, dialog.sheet {
    border: 1px solid var(--border);
    background: var(--popover);
    color: var(--foreground);
    padding: 0;
    box-shadow: var(--shadow-lg);
}

dialog.modal {
    border-radius: 14px;
    width: min(640px, calc(100vw - 32px));
}

/* Dialogs with many fields: wider, two columns, so they fit without scrolling (one column on phones). */
dialog.modal.modal-wide {
    width: min(880px, calc(100vw - 32px));
}

    dialog.modal.modal-wide .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

@media (max-width: 639.98px) {
    dialog.modal.modal-wide .form-grid {
        grid-template-columns: 1fr;
    }
}

    dialog.modal[open] {
        animation: modal-in .2s ease-out;
    }

dialog::backdrop {
    background: var(--overlay);
    backdrop-filter: blur(2px);
    animation: fade-in .2s ease-out;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(8px) scale(.97);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-body {
    padding: 26px 28px 28px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

    /* Dialog forms breathe: fields get room between rows and columns, and the title sits apart from them. */
    .modal-body .form-grid {
        gap: 20px 20px;
    }

    .modal-body > .modal-title + * {
        margin-top: 2px;
    }

.modal-title {
    font-size: calc(17px * var(--ts));
    font-weight: 600;
}

.modal-desc {
    color: var(--muted-foreground);
    font-size: calc(14px * var(--ts));
    margin: 0;
}

.modal-foot {
    padding: 16px 28px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface-2) 50%, transparent);
    border-radius: 0 0 14px 14px;
}

dialog.sheet {
    margin: 0 0 0 auto;
    height: 100vh;
    max-height: 100vh;
    max-width: 100vw;
    width: min(640px, 100vw);
    border-radius: 0;
    border-width: 0 0 0 1px;
}

    dialog.sheet[open] {
        animation: sheet-in .3s cubic-bezier(.3, .7, .4, 1);
    }

@keyframes sheet-in {
    from {
        transform: translateX(100%);
    }

    to {
        transform: none;
    }
}

.sheet-head {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    position: sticky;
    top: 0;
    background: var(--popover);
    z-index: 2;
}

.sheet-body {
    padding: 18px 22px 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sheet-loading {
    padding: 60px;
    text-align: center;
    color: var(--muted-foreground);
}

.summary {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px 12px;
    padding: 14px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    font-size: calc(14px * var(--ts));
    margin: 0;
}

    .summary dt {
        color: var(--muted-foreground);
    }

    .summary dd {
        margin: 0;
        font-weight: 500;
    }

/* ---------- Issue certificate workspace */
.stepper {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
    font-weight: 500;
}

.step-num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(13px * var(--ts));
    background: var(--card);
}

.step.done .step-num {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.step.current {
    color: var(--foreground);
}

    .step.current .step-num {
        background: var(--primary);
        border-color: var(--primary);
        color: var(--primary-foreground);
    }

.step-line {
    width: 28px;
    height: 1px;
    background: var(--border);
}

.search-hero {
    position: relative;
}

    /* :not() raises specificity above the shared control padding, so text clears the icon. */
    .search-hero .input:not([type=file]) {
        padding-left: 42px;
        border-radius: var(--radius);
    }

    .search-hero > .icon {
        position: absolute;
        left: 14px;
        top: 50%;
        transform: translateY(-50%);
        pointer-events: none;
        color: var(--muted-foreground);
        width: 17px;
        height: 17px;
    }

.results {
    position: absolute;
    z-index: 40;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    background: var(--popover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    animation: pop-in .14s ease-out;
}

.result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

    .result.active, .result:hover {
        background: var(--surface-2);
    }

.result-main {
    flex: 1;
    min-width: 0;
}

.result-name {
    font-weight: 500;
}

.result-sub {
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result mark {
    background: var(--accent-soft);
    color: var(--accent-foreground);
    border-radius: 3px;
    padding: 0 1px;
}

.result-foot {
    border-top: 1px solid var(--border);
    margin-top: 6px;
    padding-top: 6px;
}

.person {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.person-name {
    font-size: calc(17px * var(--ts));
    font-weight: 600;
    letter-spacing: -.01em;
}

.slide-in {
    animation: panel-in .3s ease-out;
}

.section-card {
    border-top: 3px solid var(--accent);
}

.preview-wrap {
    background: var(--surface-2);
    border-radius: var(--radius);
    padding: 14px;
    border: 1px solid var(--border);
}

.preview-frame {
    width: 100%;
    aspect-ratio: 297 / 210;
    border: 0;
    background: #fff;
    border-radius: 6px;
    box-shadow: var(--shadow);
    display: block;
}

    .preview-frame.portrait {
        aspect-ratio: 210 / 297;
    }

.preview-ribbon {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: calc(13px * var(--ts));
    color: var(--muted-foreground);
    margin-bottom: 10px;
}

.tpl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.tpl {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px;
    cursor: pointer;
    background: var(--card);
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: border-color .15s, box-shadow .15s;
    font-weight: 400;
}

    .tpl:hover {
        border-color: var(--subtle);
    }

    .tpl:has(input:checked) {
        border-color: var(--accent);
        box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent);
    }

    .tpl input {
        position: absolute;
        opacity: 0;
        pointer-events: none;
    }

.tpl-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 297 / 210;
    overflow: hidden;
    border-radius: 4px;
    background: #fff;
    border: 1px solid var(--border);
}

    .tpl-thumb iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 1123px;
        height: 794px;
        border: 0;
        transform-origin: 0 0;
        pointer-events: none;
    }

.tpl-name {
    font-size: calc(14px * var(--ts));
    font-weight: 500;
    padding: 0 2px 2px;
}

/* ---------- Masters / code editor */
.editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
}

@media (max-width: 1200px) {
    .editor-grid {
        grid-template-columns: 1fr;
    }
}

.CodeMirror {
    height: 420px !important;
    border: 1px solid var(--input);
    border-radius: var(--radius-sm);
    font-family: var(--mono) !important;
    font-size: calc(14px * var(--ts));
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    font-family: var(--mono);
    font-size: calc(13px * var(--ts));
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    cursor: pointer;
    color: var(--foreground);
}

    .chip:hover {
        border-color: var(--accent);
    }

.swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    display: inline-block;
    vertical-align: -2px;
    border: 1px solid var(--border);
}

.color-input {
    width: 44px;
    height: 36px;
    padding: 3px;
    border: 1px solid var(--input);
    border-radius: var(--radius-sm);
    background: var(--card);
    cursor: pointer;
}

/* ---------- Permission matrix */
.matrix td, .matrix th {
    text-align: center;
}

    .matrix td:first-child, .matrix th:first-child {
        text-align: left;
    }

.role-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card);
    text-decoration: none;
    color: var(--foreground);
    transition: border-color .15s;
}

    .role-btn:hover {
        border-color: var(--subtle);
        color: var(--foreground);
    }

    .role-btn.active {
        border-color: var(--accent);
        box-shadow: 0 0 0 1px var(--accent);
        background: var(--accent-soft);
    }

/* ---------- Auth screens: one wave across the page, behind a white-framed card. The left half of the card is a window onto it. */
.auth2 {
    position: relative;
    isolation: isolate;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px;
    background: var(--sidebar);
}

.auth2-canvas {
    position: fixed;
    z-index: -1;
    inset: -5%;
    width: 110%;
    height: 110%;
    display: block;
    pointer-events: none;
    animation: auth-drift 5s ease-out both;
    will-change: transform;
}

@keyframes auth-drift {
    from { transform: translate3d(-1.5%, -1.5%, 0); }
    to { transform: translate3d(1.5%, 1.5%, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .auth2-canvas { animation: none; }
}

.auth2-card {
    width: min(1160px, 100%);
    min-height: min(700px, calc(100vh - 64px));
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    overflow: hidden;
    border: 6px solid var(--card);
    border-radius: 24px;
    box-shadow: 0 24px 60px -36px rgba(22, 24, 29, .28);
}

.auth2-art {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 36px;
}

.auth2-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: calc(16px * var(--ts));
    font-weight: 600;
    color: var(--foreground);
}

.auth2-copy { position: relative; }

.auth2-headline {
    font-size: 30px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -.02em;
    color: var(--foreground);
    max-width: 16ch;
    text-wrap: balance;
}

.auth2-copy p {
    margin: 10px 0 0;
    font-size: calc(15px * var(--ts));
    line-height: 1.55;
    color: var(--muted-foreground);
    max-width: 38ch;
}

.auth2-main {
    display: flex;
    flex-direction: column;
    padding: 20px 32px;
    min-width: 0;
    background: var(--card);
}

.auth2-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 40px;
}

.auth2-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 0;
}

.auth2-form {
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth2-head { margin-bottom: 8px; }

.auth2-title {
    font-size: var(--fs-title);
    font-weight: 600;
    letter-spacing: -.025em;
    line-height: 1.2;
    text-wrap: balance;
}

.auth2-sub {
    margin: 6px 0 0;
    color: var(--muted-foreground);
    font-size: calc(15px * var(--ts));
    line-height: 1.55;
}

.auth2-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 12px;
    font-size: calc(15px * var(--ts));
}

    .auth2-options a { font-weight: 500; text-decoration: none; }
    .auth2-options a:hover { text-decoration: underline; }

.auth2-switch {
    margin: 0;
    text-align: center;
    font-size: calc(15px * var(--ts));
    color: var(--muted-foreground);
}

    .auth2-switch a { font-weight: 600; text-decoration: none; }
    .auth2-switch a:hover { text-decoration: underline; }

.auth2-label-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

    .auth2-label-row a {
        font-size: calc(14px * var(--ts));
        font-weight: 500;
        text-decoration: none;
        /* larger tap target without moving the layout */
        padding: 8px 0;
        margin: -8px 0;
    }

/* Issue page, renewal mode: the fixed certification and the banner */
.locked-value {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    color: var(--foreground);
    cursor: default;
}

    .locked-value .muted { font-size: var(--fs-label, 12.5px); }
    .locked-value svg { margin-left: auto; width: 15px; height: 15px; color: var(--muted-foreground); }

.renewal-banner { align-items: center; }

/* Revealed ID number (registered user panel): briefly highlighted when it appears */
[data-id-number].is-revealed { animation: revealed 1.2s ease-out; border-radius: 4px; }
@keyframes revealed { from { background: var(--accent-soft); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { [data-id-number].is-revealed { animation: none; } }

/* Edit candidate: the ID document already on file, above the upload box */
.file-current {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 7px);
    background: var(--surface-2);
}

    .file-current-icon { display: inline-flex; color: var(--muted-foreground); }
    .file-current-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; font-size: var(--fs-body, 14px); }
    .file-current-text .muted { font-size: var(--fs-label, 12.5px); }
    .file-current .btn { margin-left: auto; }

/* Multi-select dropdown (e.g. Certificates › certification filter): a checkbox per option and a footer */
.combo-opt.multi { gap: 10px; }

.combo-check {
    flex: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--input);
    border-radius: 4px;
    background: var(--background, #fff);
    transition: background .15s, border-color .15s;
    position: relative;
}

.combo-opt.multi.selected { background: transparent; font-weight: 500; }
.combo-opt.multi.selected.active, .combo-opt.multi.active { background: var(--surface-2); }
.combo-opt.multi.selected .combo-check { background: var(--primary); border-color: var(--primary); }

    .combo-opt.multi.selected .combo-check::after {
        content: '';
        position: absolute;
        left: 4.5px;
        top: 1.5px;
        width: 4px;
        height: 8px;
        border: solid var(--primary-foreground, #fff);
        border-width: 0 2px 2px 0;
        transform: rotate(45deg);
    }

:root[data-theme="dark"] .combo-opt.multi.selected .combo-check { background: var(--accent); border-color: var(--accent); }

.combo-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-top: 1px solid var(--border);
}

    .combo-foot .combo-count { flex: 1; text-align: center; font-size: calc(14px * var(--ts)); color: var(--muted-foreground); }

.combo.has-value .combo-btn { color: var(--foreground); font-weight: 500; }

/* Close button on every modal dialog (added by site.js) */
dialog.modal { position: fixed; }

.modal-x {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted-foreground);
    cursor: pointer;
    transition: background .15s, color .15s;
}

    .modal-x:hover { background: var(--surface-2); color: var(--foreground); }
    .modal-x:focus-visible { outline: 2px solid var(--ring, var(--accent)); outline-offset: 1px; }

dialog.modal .modal-title { padding-right: 36px; }

/* Infinite activity lists (side panels) */
.timeline-more, .timeline-end {
    list-style: none;
    padding: 10px 0 4px;
    text-align: center;
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
}

.timeline-more .timeline-loading::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 8px;
    vertical-align: -2px;
    border: 2px solid var(--border);
    border-top-color: var(--muted-foreground);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.timeline-in { animation: cand-in .24s ease-out both; }

@media (prefers-reduced-motion: reduce) {
    .timeline-in { animation: none; }
    .timeline-more .timeline-loading::before { animation: none; }
}

/* Two-column grids: a .col-2 field spans the row */
.form-grid.form-grid-2 > .col-2 { grid-column: 1 / -1; }

/* Issue page candidate card: read-only summary <-> edit fields.
   The card animates its height between the two and the incoming pane fades up (site: Issue.cshtml morph()). */
.cand-swap { position: relative; }
.cand-pane-in { animation: cand-in .26s cubic-bezier(.2, .8, .2, 1) both; }

@keyframes cand-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.cand-edit-actions {
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

[data-candidate].is-editing [data-cand-tools] { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
    .cand-pane-in { animation: none; }
}

/* Candidate card on the Issue page: renew links next to each certificate */
.cand-cert-renew { padding: 0 8px; min-height: 28px; height: 28px; }

/* Registered users: the certificate that expires next, when it is within the expiring-soon window */
.expires-soon {
    color: var(--warning);
    font-weight: 500;
}

/* "Keep me signed in": the whole row is the tap target */
.auth2 .check {
    min-height: 32px;
}

        .auth2-label-row a:hover {
            text-decoration: underline;
        }

.auth2-password {
    position: relative;
    display: flex;
}

    .auth2-password .input {
        padding-right: 76px;
    }

    /* Our Show/Hide button is the only one: Edge's own eye would sit beside it and compete for the same clicks. */
    .auth2-password .input::-ms-reveal,
    .auth2-password .input::-ms-clear {
        display: none;
    }

    .auth2-password .btn {
        position: absolute;
        right: 6px;
        top: 50%;
        transform: translateY(-50%);
    }

.auth2-note {
    display: flex;
    gap: 10px;
    margin: 6px 0 0;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: calc(14px * var(--ts));
    line-height: 1.55;
    color: var(--muted-foreground);
}

    .auth2-note svg {
        width: 16px;
        height: 16px;
        flex: none;
        margin-top: 2px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
    }

.auth2-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent-foreground);
}

    .auth2-icon svg {
        width: 24px;
        height: 24px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

.auth2-icon-warn {
    background: var(--warning-soft);
    color: var(--warning);
}

.auth2-back {
    align-self: flex-start;
    font-size: calc(15px * var(--ts));
    font-weight: 500;
    text-decoration: none;
}

    .auth2-back:hover {
        text-decoration: underline;
    }

.auth2-foot {
    margin: 0;
    font-size: calc(14px * var(--ts));
    color: var(--subtle);
    text-align: center;
}

/* Tablet and phone: only the form, with the logo above it. */
@media (max-width: 860px) {
    .auth2 { padding: 12px; place-items: stretch; }
    .auth2-card { grid-template-columns: 1fr; min-height: calc(100vh - 24px); border-width: 1px; border-color: var(--border); }
    .auth2-art { display: none; }
    .auth2-main { padding: 12px 18px; }
    .auth2-body { align-items: flex-start; padding: 24px 0; }
}

.auth-top {
    width: 100%;
    max-width: 1200px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.rules {
    margin: 0;
    padding: 12px 14px;
    list-style: none;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
}

/* ---------- Public verify page */
.verify {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 16px;
    gap: 28px;
    background: radial-gradient(900px 400px at 50% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent);
}

.verify-card {
    width: 100%;
    max-width: 560px;
}

.verify-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius);
    font-weight: 600;
}

    .verify-status .icon {
        width: 22px;
        height: 22px;
    }

@media (max-width: 1100px) {
    .sidenav {
        position: fixed;
        z-index: 70;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        visibility: hidden; /* closed, it is out of the tab order too */
        transition: transform .25s, visibility .25s;
    }

    .shell.nav-open .sidenav {
        transform: none;
        visibility: visible;
        box-shadow: var(--shadow-lg);
    }

    /* Phone/tablet menu: wider panel, full dynamic height (Sign out stays visible above the browser bar), dimmed page behind. */
    .sidenav {
        width: 270px;
        height: 100dvh;
    }

    .nav-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 69;
        background: var(--overlay);
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s;
    }

    .shell.nav-open .nav-scrim {
        opacity: 1;
        pointer-events: auto;
    }

    body:has(.shell.nav-open) {
        overflow: hidden;
    }

    .nav-close {
        display: inline-flex;
        margin-left: auto;
    }

    .btn.menu-btn {
        display: inline-flex;
    }

    .content {
        padding: 16px;
    }

    .topbar {
        padding: 0 16px;
    }

    .dl, .summary {
        grid-template-columns: 1fr;
    }
}
/* =====================================================================
   UI v2 — sizing tokens, list pages (tabs · filter bar · table/cards · pager), sheets, date picker.
   Breakpoints: desktop ≥1680 · laptop 1280–1679 · tablet 768–1279 · mobile <768
   ===================================================================== */
:root {
    --fs-body: 15px;
    --fs-label: 14px;
    --h-control: 44px;
    --h-btn: 42px;
    --h-tab: 40px;
    --h-row-btn: 36px;
    --fs-control: 15px;
    --fs-tab: 15px;
    --fs-title: 26px;
    --fs-table: 15px;
}

@media (min-width: 1680px) {
    :root {
        --h-control: 50px;
        --h-btn: 45px;
        --h-tab: 42px;
        --h-row-btn: 36px;
        --fs-control: 16px;
        --fs-tab: 15.5px;
        --fs-title: 28px;
        --fs-table: 15.5px;
    }
}

@media (min-width: 1680px) {
    dialog.modal, dialog.sheet {
        --h-control: 45px;
    }
}

@media (max-width: 1279.98px) {
    :root {
        --h-control: 44px;
    }
}

@media (max-width: 767.98px) {
    :root {
        --h-control: 44px;
        --h-btn: 44px;
        --h-tab: 40px;
        --h-row-btn: 40px;
        --fs-control: 16px;
        --fs-tab: 14px;
        --fs-title: 22px;
    }
}

::selection {
    background: color-mix(in srgb, var(--accent) 28%, transparent);
    color: var(--foreground);
}

.page-title {
    font-size: var(--fs-title);
    letter-spacing: -.025em;
}

.page-sub {
    margin-top: 6px;
}

.input:not([type=file]), .select, .combo-btn, .prefix {
    height: var(--h-control);
    font-size: calc(var(--fs-control) * var(--ts));
}

.input:not([type=file]), .combo-btn {
    padding-left: 14px;
}

.textarea {
    font-size: calc(var(--fs-control) * var(--ts));
}

.btn:not(.btn-sm):not(.btn-icon) {
    height: var(--h-btn);
    font-size: calc(var(--fs-control) * var(--ts));
    padding: 0 16px;
}

.toolbar .btn:not(.btn-sm), .row > .btn:not(.btn-sm), .filter-bar .btn:not(.btn-icon) {
    height: var(--h-control);
}

.tabs:not(.tabs-line) .tab {
    height: var(--h-tab);
    font-size: calc(var(--fs-tab) * var(--ts));
    padding: 0 14px;
}

.combo-opt {
    font-size: calc(var(--fs-control) * var(--ts));
}

/* ---- Status tabs + layout switch */
.list-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.tabs-scroll {
    position: relative;
    min-width: 0;
    display: flex;
}

    .tabs-scroll .tabs {
        scrollbar-width: none;
        scroll-behavior: smooth;
    }

        .tabs-scroll .tabs::-webkit-scrollbar {
            display: none;
        }

.scroll-hint {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 2;
    width: 52px;
    display: none;
    align-items: center;
    border: 0;
    padding: 0 5px;
    cursor: pointer;
    color: var(--foreground);
}

    .scroll-hint .icon {
        width: 26px;
        height: 26px;
        padding: 5px;
        border-radius: 50%;
        background: var(--card);
        box-shadow: var(--shadow);
    }

    .scroll-hint.left {
        left: 0;
        justify-content: flex-start;
        border-radius: var(--radius) 0 0 var(--radius);
        background: linear-gradient(90deg, var(--surface-2) 45%, transparent);
    }

    .scroll-hint.right {
        right: 0;
        justify-content: flex-end;
        border-radius: 0 var(--radius) var(--radius) 0;
        background: linear-gradient(270deg, var(--surface-2) 45%, transparent);
    }

.tabs-scroll.has-left .scroll-hint.left, .tabs-scroll.has-right .scroll-hint.right {
    display: flex;
}

    .tabs-scroll.has-right .scroll-hint.right .icon {
        animation: hint-nudge 1.4s cubic-bezier(.3, .7, .4, 1) .6s 2;
    }

@keyframes hint-nudge {
    0%, 100% {
        transform: none;
    }

    40% {
        transform: translateX(4px);
    }
}

.view-switch {
    display: none;
    flex: none;
}

    .view-switch .tab {
        padding: 0 12px;
    }

        .view-switch .tab[aria-pressed="true"] {
            background: var(--card);
            color: var(--foreground);
            box-shadow: var(--shadow);
        }

/* ---- Filters: everything inline on laptop/desktop */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.f-search {
    position: relative;
    flex: 2 1 0;
    min-width: 190px;
}

    .f-search > .icon {
        position: absolute;
        left: 14px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--muted-foreground);
        pointer-events: none;
    }

.f-search .input:not([type=file]) {
    padding-left: 40px;
}

.f-cert, .f-core {
    flex: 1 1 0;
    min-width: 170px;
}

.f-more {
    display: contents;
}

.f-source, .f-field {
    flex: 1 1 0;
    min-width: 170px;
}

.f-dates {
    display: flex;
    align-items: center;
    gap: 2px;
    height: var(--h-control);
    padding: 0 4px 0 14px;
    border: 1px solid var(--input);
    border-radius: var(--radius-sm);
    background: var(--card);
    box-shadow: var(--shadow-sm);
    transition: border-color .15s, box-shadow .15s;
}

    .f-dates:focus-within {
        border-color: var(--ring);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 18%, transparent);
    }

.f-dates-label {
    font-size: calc(14px * var(--ts));
    font-weight: 500;
    color: var(--muted-foreground);
    margin-right: 4px;
    white-space: nowrap;
}

.f-dates-sep {
    color: var(--subtle);
}

.f-dates .input {
    border: 0;
    box-shadow: none;
    background: transparent;
    height: calc(var(--h-control) - 2px);
    width: 142px;
    padding: 0 6px;
}

@media (max-width: 1679.98px) {
    .f-dates .input {
        width: 128px;
        padding: 0 4px;
    }

    .f-dates {
        padding-left: 12px;
    }
}

@media (min-width: 1280px) {
    .filter-bar {
        flex-wrap: nowrap;
    }

    .f-search {
        min-width: 150px;
    }

    .f-cert, .f-core, .f-source, .f-field {
        min-width: 150px;
    }

    .f-dates, .f-actions {
        flex: none;
    }
}

.f-dates .input:focus {
    box-shadow: none;
}

input[type=date]::-webkit-calendar-picker-indicator {
    opacity: .5;
    cursor: pointer;
}

    input[type=date]::-webkit-calendar-picker-indicator:hover {
        opacity: .9;
    }

/* ---- Date picker (site.js initDatePickers) */
.dp {
    position: relative;
    display: inline-flex;
    min-width: 0;
}

.dp-btn {
    height: var(--h-control);
    width: 100%;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid var(--input);
    border-radius: var(--radius-sm);
    background: var(--card);
    box-shadow: var(--shadow-sm);
    font-size: calc(var(--fs-control) * var(--ts));
    color: var(--foreground);
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

    .dp-btn .icon {
        width: 15px;
        height: 15px;
        color: var(--muted-foreground);
    }

    .dp-btn.placeholder span {
        color: var(--subtle);
    }

.f-dates .dp-btn {
    border: 0;
    box-shadow: none;
    background: transparent;
    height: calc(var(--h-control) - 2px);
    width: 142px;
    padding: 0 8px;
    border-radius: 6px;
}

    .f-dates .dp-btn:hover, .f-dates .dp-btn[aria-expanded="true"] {
        background: var(--surface-2);
    }

    .f-dates .dp-btn:focus-visible {
        outline-offset: -2px;
    }

@media (max-width: 1679.98px) {
    .f-dates .dp-btn {
        width: 128px;
        padding: 0 6px;
    }
}

.dp-pop {
    position: absolute;
    z-index: 60;
    top: calc(100% + 8px);
    left: 0;
    width: 292px;
    padding: 12px;
    background: var(--popover);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    animation: pop-in .14s ease-out;
}

    .dp-pop.right {
        left: auto;
        right: 0;
    }

    .dp-pop.up {
        top: auto;
        bottom: calc(100% + 8px);
    }

.dp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.dp-title {
    font-size: calc(15px * var(--ts));
    font-weight: 600;
    letter-spacing: -.01em;
}

.dp-nav {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--foreground);
    cursor: pointer;
}

    .dp-nav:hover {
        background: var(--surface-2);
    }

.dp-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dp-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.dp-wd {
    height: 28px;
    display: grid;
    place-items: center;
    font-size: calc(13px * var(--ts));
    font-weight: 500;
    color: var(--muted-foreground);
}

.dp-day {
    height: 36px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--foreground);
    font-size: calc(14px * var(--ts));
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    position: relative;
    transition: background .12s;
}

    .dp-day:hover:not(:disabled) {
        background: var(--surface-2);
    }

    .dp-day.out {
        color: var(--subtle);
    }

    .dp-day.today {
        font-weight: 600;
        box-shadow: inset 0 0 0 1px var(--border);
    }

    .dp-day.in-range {
        background: color-mix(in srgb, var(--accent) 14%, transparent);
        border-radius: 0;
    }

    .dp-day.edge {
        background: color-mix(in srgb, var(--primary) 12%, transparent);
    }

    .dp-day.sel, .dp-day.sel:hover {
        background: var(--primary);
        color: var(--primary-foreground);
        font-weight: 600;
        box-shadow: none;
    }

    .dp-day:disabled {
        color: var(--subtle);
        opacity: .45;
        cursor: not-allowed;
    }

    .dp-day:focus-visible {
        outline: 2px solid var(--ring);
        outline-offset: 1px;
        z-index: 1;
    }

.dp-foot {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.dp-link {
    height: 30px;
    padding: 0 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
    cursor: pointer;
}

    .dp-link:hover:not(:disabled) {
        background: var(--surface-2);
        color: var(--foreground);
    }

    .dp-link.strong {
        color: var(--foreground);
        font-weight: 500;
    }

    .dp-link:disabled {
        opacity: .45;
        cursor: not-allowed;
    }

/* Date and time fields: the calendar plus a time row; picking a day keeps the popover open until Done. */
.dp-dt {
    display: flex;
    width: 100%;
}

.dp-time {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.dp-time-icon {
    display: inline-flex;
    color: var(--muted-foreground);
}

    .dp-time-icon .icon {
        width: 16px;
        height: 16px;
    }

.dp-time-label {
    flex: 1;
    font-size: calc(14px * var(--ts));
    font-weight: 500;
}

.dp-time-fields {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 36px;
    padding: 0 6px;
    border: 1px solid var(--input);
    border-radius: var(--radius-sm);
    background: var(--card);
    transition: border-color .15s, box-shadow .15s;
}

    .dp-time-fields:focus-within {
        border-color: var(--ring);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 18%, transparent);
    }

.dp-time-in {
    width: 28px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: var(--foreground);
    font: inherit;
    font-size: calc(15px * var(--ts));
    font-weight: 500;
    text-align: center;
    font-variant-numeric: tabular-nums;
    outline: none;
}

    .dp-time-in:focus {
        background: var(--accent-soft);
        color: var(--accent-foreground);
    }

.dp-time-sep {
    color: var(--muted-foreground);
    font-weight: 600;
}

.dp-done {
    height: 32px;
    padding: 0 16px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: var(--primary-foreground);
    font-size: calc(14px * var(--ts));
    font-weight: 500;
    cursor: pointer;
    transition: background .15s;
}

    .dp-done:hover {
        background: var(--primary-hover);
    }

    .dp-done:focus-visible {
        outline: 2px solid var(--ring);
        outline-offset: 2px;
    }

.f-actions {
    display: flex;
    gap: 8px;
}

.f-toggle, .f-scrim, .f-sheet-head, .f-sheet-foot, .f-chips {
    display: none;
}

.f-count {
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--primary);
    color: var(--primary-foreground);
    font-size: calc(14px * var(--ts));
    font-weight: 600;
    display: grid;
    place-items: center;
    border: 2px solid var(--background);
}

.f-chips {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: -8px;
}

.f-chip {
    height: 30px;
    padding: 0 8px 0 12px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-soft);
    color: var(--accent-foreground);
    font-size: calc(14px * var(--ts));
    font-weight: 500;
    text-decoration: none;
}

    .f-chip .icon {
        width: 14px;
        height: 14px;
    }

    .f-chip:hover {
        color: var(--accent-foreground);
        background: color-mix(in srgb, var(--accent) 22%, var(--card));
    }

.f-chip-clear {
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
}

/* ---- Results panel + table */
.list-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px 18px 4px;
    box-shadow: var(--shadow-sm);
}

.list-panel-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 0 2px 14px;
}

.list-panel-title {
    font-size: calc(16px * var(--ts));
    font-weight: 600;
    letter-spacing: -.01em;
}

.list-panel-count {
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
}

.list-panel .table-foot {
    padding: 14px 2px;
}

.list-panel-head {
    align-items: center;
}

.list-sort {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
    white-space: nowrap;
}

    .list-sort .combo {
        width: auto;
        position: relative;
    }

.list-sort .combo-btn {
    height: 32px;
    width: auto;
    padding: 0 26px 0 6px;
    border: 0;
    background: transparent;
    box-shadow: none;
    font-size: calc(14px * var(--ts));
    font-weight: 600;
    color: var(--foreground);
}

    .list-sort .combo-btn:hover {
        background: var(--surface-2);
    }

.list-sort .combo-btn::after {
    right: 9px;
}

.list-sort .combo-pop {
    left: auto;
    right: 0;
    min-width: 180px;
}

.list-sort .combo-search {
    position: absolute;
    opacity: 0;
    height: 0;
    padding: 0;
    border: 0;
    pointer-events: none;
}
/* short list: keep it focusable for arrow keys, but hidden */
/* Pager: rounded number buttons, filled current page */
.list-panel .pager {
    gap: 6px;
}

    .list-panel .pager .btn-sm {
        min-width: 36px;
        height: 36px;
        padding: 0 10px;
        border-radius: 10px;
        border: 1px solid var(--border);
        background: var(--card);
        box-shadow: var(--shadow-sm);
        font-variant-numeric: tabular-nums;
    }

        .list-panel .pager .btn-sm:hover {
            background: var(--surface-2);
        }

    .list-panel .pager .btn-primary {
        background: var(--primary);
        border-color: var(--primary);
        color: var(--primary-foreground);
    }

        .list-panel .pager .btn-primary:hover {
            background: var(--primary-hover);
        }

.data-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: calc(var(--fs-table) * var(--ts));
    font-variant-numeric: tabular-nums;
}

.data-table thead th {
    position: relative;
    padding: 12px 14px;
    font-size: calc(14px * var(--ts));
    background: var(--surface-2);
    border: 0;
}

    .data-table thead th:first-child {
        border-radius: 10px 0 0 10px;
    }

    .data-table thead th:last-child {
        border-radius: 0 10px 10px 0;
    }

.data-table td {
    padding: 14px;
    border-top: 0;
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: -2px;
}

.data-table .row-link {
    font-weight: 600;
}

.cell-meta {
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
    margin-top: 2px;
}

.data-table td.ref {
    color: var(--muted-foreground);
    font-size: calc(14px * var(--ts));
}

.data-table .btn-sm {
    height: var(--h-row-btn);
    padding: 0 12px;
}

.data-table tr:hover .row-act, .data-table tr:focus-within .row-act {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-foreground);
}

.empty-title {
    font-weight: 500;
    color: var(--foreground);
}

.empty-text {
    font-size: calc(14px * var(--ts));
    margin: 4px 0 14px;
}

/* ---- Cards (tablet + mobile only) */
.list-cards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: none;
    gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
}

.list-card {
    height: 100%;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: border-color .15s, transform .1s;
}

    .list-card:hover {
        border-color: var(--subtle);
    }

    .list-card:focus-visible {
        outline: 2px solid var(--ring);
        outline-offset: 2px;
    }

    .list-card:active {
        transform: scale(.995);
    }

.list-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.list-card-name {
    font-weight: 600;
    font-size: calc(15px * var(--ts));
    line-height: 1.35;
}

.list-card-meta {
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
    overflow-wrap: anywhere;
}

.list-card-main {
    font-size: calc(15px * var(--ts));
}

.list-card-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: calc(14px * var(--ts));
    color: var(--muted-foreground);
    font-variant-numeric: tabular-nums;
}

    .list-card-foot .mono {
        margin-left: auto;
        font-size: calc(14px * var(--ts));
    }

/* ---- Laptop + desktop: table only, sticky header */
@media (min-width: 1280px) {
    .data-table thead th {
        position: sticky;
        top: 56px;
        z-index: 3;
    }

    .list-panel[data-view] .list-cards {
        display: none;
    }
}

/* ---- Tablet + mobile */
@media (max-width: 1279.98px) {
    .view-switch {
        display: inline-flex;
    }

    .table-scroll {
        position: relative;
        overflow-x: auto;
        margin: 0 -18px;
        padding: 0 18px;
    }

    .list-panel[data-view="cards"] {
        background: none;
        border: 0;
        padding: 0;
        box-shadow: none;
    }

        .list-panel[data-view="cards"] .table-scroll {
            display: none;
        }

        .list-panel[data-view="cards"] .list-cards {
            display: grid;
        }

        .list-panel[data-view="cards"] .table-foot {
            border-top: 0;
            padding: 14px 0 0;
        }

    .f-search {
        max-width: none;
    }

    .filter-bar.f-open .f-source, .filter-bar.f-open .f-field {
        flex: 1 1 200px;
    }

    .f-toggle {
        display: inline-flex;
        position: relative;
        width: var(--h-control);
        padding: 0 !important;
        flex: none;
    }

        .f-toggle[aria-expanded="true"] {
            background: var(--surface-2);
            border-color: var(--subtle);
        }

    .f-more {
        display: none;
    }

    .filter-bar.f-open .f-more {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        flex-basis: 100%;
        order: 10;
        padding: 12px;
        border-radius: var(--radius);
        background: var(--surface-2);
        animation: panel-in .22s ease-out;
    }

    .f-actions .btn-ghost {
        display: none;
    }

    .f-chips {
        display: flex;
    }
}

/* ---- Mobile: filters + details become bottom sheets */
@media (max-width: 767.98px) {
    .view-switch .tab {
        padding: 0 10px;
    }

        .view-switch .tab span {
            display: none;
        }

    .f-search {
        flex-basis: 100%;
        min-width: 0;
    }

    .f-cert, .f-core {
        flex: 1 1 0;
        min-width: 0;
    }

    .f-actions {
        display: none;
    }

    .filter-bar .f-more, .filter-bar.f-open .f-more {
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 14px;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 81;
        padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
        margin: 0;
        background: var(--popover);
        border-radius: 18px 18px 0 0;
        border-top: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
        transform: translateY(105%);
        visibility: hidden;
        animation: none;
        transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s .3s;
    }

    .filter-bar.f-sheet-open .f-more {
        transform: none;
        visibility: visible;
        transition: transform .3s cubic-bezier(.2, .8, .2, 1);
    }

    .f-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 80;
        background: var(--overlay);
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s;
    }

    .f-sheet-open .f-scrim {
        opacity: 1;
        pointer-events: auto;
    }

    body:has(.f-sheet-open) {
        overflow: hidden;
    }

    .f-sheet-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-top: 12px;
        position: relative;
    }

        .f-sheet-head::before {
            content: '';
            position: absolute;
            top: -2px;
            left: 50%;
            width: 40px;
            height: 4px;
            margin-left: -20px;
            border-radius: 4px;
            background: var(--border);
        }

    .f-sheet-title {
        font-size: calc(16px * var(--ts));
        font-weight: 600;
    }

    .f-source, .f-field, .f-dates, .filter-bar.f-open .f-source, .filter-bar.f-open .f-field {
        flex: none;
        width: 100%;
        min-width: 0;
    }

    .f-dates {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 6px 2px 14px;
    }

    .f-dates-label {
        flex-basis: 100%;
        font-size: calc(14px * var(--ts));
    }

    .f-dates .input {
        flex: 1 1 0;
        width: auto;
        min-width: 0;
        padding: 0 2px;
    }

    .f-dates .dp {
        flex: 1 1 0;
    }

    .f-dates .dp-btn {
        width: 100%;
    }

    .f-sheet-foot {
        display: flex;
        gap: 10px;
        padding-top: 4px;
    }

        .f-sheet-foot .btn-primary {
            flex: 1;
        }

    .combo-search {
        font-size: calc(16px * var(--ts));
        height: 42px;
    }

    .pager .pg-num, .pager .pg-gap {
        display: none;
    }

    .pager-status {
        display: inline;
        font-size: calc(14px * var(--ts));
        color: var(--muted-foreground);
        padding: 0 8px;
    }

    .list-panel .table-foot {
        justify-content: center;
    }

        .list-panel .table-foot > span:first-child {
            display: none;
        }

    .list-panel .pager .btn-sm {
        height: 40px;
        padding: 0 14px;
    }

    dialog.sheet {
        --sheet-mode: bottom;
        margin: auto 0 0;
        width: 100vw;
        height: auto;
        max-height: 92dvh;
        border-radius: 18px 18px 0 0;
        border-width: 1px 0 0;
    }

        dialog.sheet[open] {
            animation: sheet-up .32s cubic-bezier(.2, .8, .2, 1);
        }

        dialog.sheet .sheet-head {
            padding: 22px 18px 14px;
            border-radius: 18px 18px 0 0;
        }

            dialog.sheet .sheet-head::before {
                content: '';
                position: absolute;
                top: 8px;
                left: 50%;
                width: 40px;
                height: 4px;
                margin-left: -20px;
                border-radius: 4px;
                background: var(--border);
            }

        dialog.sheet .sheet-body {
            padding: 16px 18px 16px;
        }

        dialog.sheet .dl {
            grid-template-columns: 104px minmax(0, 1fr);
            gap: 10px 12px;
        }

    .sheet-body > .sheet-cta {
        order: 99;
        position: sticky;
        bottom: 0;
        z-index: 2;
        margin: 0 -18px -16px;
        padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
        background: var(--popover);
        border-top: 1px solid var(--border);
    }
}

@keyframes sheet-up {
    from {
        transform: translateY(100%);
    }

    to {
        transform: none;
    }
}

/* ---- UI v2: shared list-page additions */
.tab-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: none;
}

@media (min-width: 1280px) and (max-width: 1679.98px) {
    /* Laptops: pages with many filters wrap to two rows instead of squeezing every field (one row on desktop). */
    .filter-bar.filter-bar-wrap {
        flex-wrap: wrap;
    }

        /* Row 1: keyword + the main dropdown across the full width; row 2: the rest, actions on the right. */
        .filter-bar.filter-bar-wrap .f-search {
            flex: 1 1 calc(100% - 320px);
            min-width: 260px;
        }

        .filter-bar.filter-bar-wrap .f-core {
            flex: 0 0 300px;
        }

        .filter-bar.filter-bar-wrap .f-actions {
            margin-left: auto;
        }
}

.dp-btn:disabled {
    background: var(--surface-2);
    color: var(--muted-foreground);
    cursor: not-allowed;
}

/* Simple search + action bars (Masters, Users & roles): no hidden filters. */
.filter-bar:not([data-filters]) .f-search {
    max-width: 520px;
}

.toolbar-note {
    align-items: center;
}

/* Lists without status tabs (Audit log) keep the layout switch in the panel header. */
.list-panel-switch {
    margin-left: auto;
}

.list-card-foot > .mono:first-child {
    margin-left: 0;
}

.list-card-foot .btn-sm {
    margin-left: auto;
}

/* Header-only styling: row headers inside tbody (permission matrix) stay plain. */
.data-table tbody th {
    text-align: left;
    font-weight: 500;
    font-size: inherit;
    color: var(--foreground);
    padding: 14px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody tr:last-child th {
    border-bottom: 0;
}

/* Pinned first column while the table scrolls sideways. */
@media (max-width: 1279.98px) {
    .data-table.pin-first thead th:first-child, .data-table.pin-first tbody > tr > :first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        background: var(--card);
        box-shadow: 1px 0 0 var(--border);
    }

    .data-table.pin-first thead th:first-child {
        background: var(--surface-2);
    }

    .data-table.pin-first tbody tr:hover > :first-child {
        background: color-mix(in srgb, var(--surface-2) 60%, var(--card));
    }
}

/* Table / Cards switch added to list headings by site.js (initListViews); like .view-switch, tablets and phones only. */
.list-panel-head-auto {
    display: none;
}

@media (max-width: 1279.98px) {
    .list-panel-head-auto {
        display: flex;
        justify-content: flex-end;
    }

    .list-view-switch {
        margin-left: auto;
    }

    .list-panel-head .list-sort ~ .list-view-switch {
        margin-left: 8px;
    }

    /* Table view keeps the first column readable: the table scrolls sideways instead of squeezing it. */
    .stack-table > thead > tr > th:first-child, .stack-table > tbody > tr > td:first-child {
        min-width: 260px;
    }

    /* A first column that is only a short number (#100) stays narrow. */
    .stack-table > thead > tr > th.col-id:first-child, .stack-table > tbody > tr > td.col-id:first-child {
        min-width: 0;
    }

    .list-panel[data-view="cards"] .stack-table > tbody > tr > td:first-child {
        display: block;
        min-width: 0;
    }

        .list-panel[data-view="cards"] .stack-table > tbody > tr > td:first-child .cell-meta {
            font-weight: 400;
            margin-top: 2px;
        }
}

/* Stacked tables: the same rows become cards in card view (keeps every action button working). */
@media (max-width: 1279.98px) {
    .list-panel.stacked[data-view="cards"] .table-scroll {
        display: block;
        overflow: visible;
        margin: 0;
        padding: 0;
    }

    .list-panel[data-view="cards"] .stack-table, .list-panel[data-view="cards"] .stack-table tbody {
        display: block;
    }

    .list-panel[data-view="cards"] .stack-table thead {
        display: none;
    }

    .list-panel[data-view="cards"] .stack-table tbody {
        display: grid;
        gap: 10px;
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    }

    .list-panel[data-view="cards"] .stack-table tr {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 14px 16px;
        background: var(--card);
        border: 1px solid var(--border);
        border-radius: 12px;
        box-shadow: var(--shadow-sm);
    }

        .list-panel[data-view="cards"] .stack-table tr[hidden] {
            display: none;
        }

    /* Each field is a label column and a value column; a cell's value and its grey sub-line stack in the value column. */
    .list-panel[data-view="cards"] .stack-table td {
        display: block;
        position: relative;
        min-height: 22px;
        padding: 0 0 0 126px;
        border: 0;
        background: none !important;
        box-shadow: none;
        text-align: left;
        font-size: calc(15px * var(--ts));
        line-height: 1.45;
        min-width: 0;
        white-space: normal;
        overflow-wrap: anywhere;
    }

        .list-panel[data-view="cards"] .stack-table td .cell-meta {
            margin-top: 2px;
            font-size: calc(14px * var(--ts));
            color: var(--muted-foreground);
        }

        .list-panel[data-view="cards"] .stack-table td::before {
            content: attr(data-label);
            position: absolute;
            left: 0;
            top: 0;
            width: 112px;
            font-family: var(--sans);
            font-weight: 400;
            letter-spacing: normal;
            font-size: calc(14px * var(--ts));
            line-height: 1.45;
            color: var(--muted-foreground);
            text-align: left;
        }

        .list-panel[data-view="cards"] .stack-table td:not([data-label]) {
            padding-left: 0;
            min-height: 0;
        }

        .list-panel[data-view="cards"] .stack-table td:first-child {
            display: block;
            padding-left: 0;
            text-align: left;
            font-weight: 600;
            font-size: calc(15px * var(--ts));
            padding-bottom: 10px;
            margin-bottom: 2px;
            border-bottom: 1px solid var(--border);
        }

            .list-panel[data-view="cards"] .stack-table td:first-child::before, .list-panel[data-view="cards"] .stack-table td:not([data-label])::before {
                display: none;
            }

            .list-panel[data-view="cards"] .stack-table td:first-child .cell-meta {
                font-weight: 400;
                margin-top: 2px;
            }

        .list-panel[data-view="cards"] .stack-table td.row-actions {
            display: flex;
            justify-content: flex-end;
            padding-top: 10px;
            border-top: 1px solid var(--border);
        }

            .list-panel[data-view="cards"] .stack-table td.row-actions:empty {
                display: none;
            }

    .list-panel[data-view="cards"] .stack-table.pin-first tbody > tr > :first-child {
        position: static;
        box-shadow: none;
    }

    .list-panel.stacked[data-view="cards"] {
        background: none;
        border: 0;
        padding: 0;
        box-shadow: none;
    }

    .list-panel.stacked[data-view="cards"] .list-panel-head {
        padding-left: 0;
    }
}

/* Audit log details (expanded row / card). */
.audit-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    gap: 16px;
    padding: 4px 0;
    text-align: left;
}

    .audit-details .section-title {
        margin-bottom: 8px;
    }

.audit-changes {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    margin: 0;
    padding: 0;
}

.list-card.is-open {
    border-color: var(--subtle);
}

    .list-card.is-open .audit-details {
        margin-top: 8px;
        padding-top: 12px;
        border-top: 1px solid var(--border);
        grid-template-columns: 1fr;
    }

/* Users & roles: role list + editor. */
.roles-grid {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

@media (max-width: 1023.98px) {
    .roles-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767.98px) {
    .filter-bar:not([data-filters]) {
        flex-wrap: nowrap;
    }

        .filter-bar:not([data-filters]) .f-search {
            flex: 1 1 0;
            min-width: 0;
        }

        .filter-bar:not([data-filters]) .btn {
            flex: none;
        }

        .filter-bar:not([data-filters]) > .small {
            display: none;
        }
}

/* Four columns on laptop/desktop (registered user form), two on tablets, one on phones; .col-2 spans half a row. */
.form-grid.form-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

    .form-grid.form-grid-4 > .col-2 {
        grid-column: span 2;
    }

@media (max-width: 1279.98px) {
    .form-grid.form-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767.98px) {
    .form-grid.form-grid-4 {
        grid-template-columns: 1fr;
    }

        .form-grid.form-grid-4 > .col-2 {
            grid-column: auto;
        }
}

.form-actions {
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Three equal columns (Issue certificate course details); one column on phones. */
.form-grid.form-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 767.98px) {
    .form-grid.form-grid-3 {
        grid-template-columns: 1fr;
    }
}

/* Two equal columns (Issue certificate registration); one column on phones. */
.form-grid.form-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 767.98px) {
    .form-grid.form-grid-2 {
        grid-template-columns: 1fr;
    }
}

/* File fields (site.js initFileFields): the native input covers the drop area invisibly, so click, keyboard and drag-and-drop all work. */
.file-field {
    position: relative;
    display: block;
}

    .file-field input[type=file] {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        opacity: 0;
        cursor: pointer;
        z-index: 1;
    }

.file-ui {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: calc(var(--h-control) + 12px);
    padding: 10px 10px 10px 14px;
    border: 1px dashed color-mix(in srgb, var(--muted-foreground) 45%, var(--border));
    border-radius: var(--radius-sm);
    background: var(--card);
    font-size: calc(var(--fs-control) * var(--ts));
    transition: border-color .15s, background .15s, box-shadow .15s;
}

    .file-ui > .icon {
        width: 34px;
        height: 34px;
        padding: 8px;
        border-radius: 9px;
        background: var(--surface-2);
        color: var(--muted-foreground);
        flex: none;
    }

.file-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.35;
}

.file-name {
    font-weight: 500;
    color: var(--foreground);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-meta {
    font-size: calc(14px * var(--ts));
    font-weight: 400;
    color: var(--muted-foreground);
}

.file-btn {
    flex: none;
    pointer-events: none;
}

.file-field:hover .file-ui, .file-field.drag .file-ui {
    border-color: var(--subtle);
    background: color-mix(in srgb, var(--surface-2) 50%, var(--card));
}

.file-field:focus-within .file-ui {
    border-color: var(--ring);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 18%, transparent);
}

.file-field.has-file .file-ui {
    border-style: solid;
}

    .file-field.has-file .file-ui > .icon {
        background: var(--accent-soft);
        color: var(--accent-foreground);
    }

.file-field:has(.input-validation-error) .file-ui {
    border-color: var(--destructive);
}

@media (min-width: 1100.02px) {
    .nav-scrim, .nav-close {
        display: none;
    }
}

/* ---- Phones: bigger touch targets and type (52px fields and buttons, 15.5px body). */
@media (max-width: 767.98px) {
    :root {
        --fs-body: 16px;
        --fs-label: 15px;
        --h-control: 52px;
        --h-btn: 52px;
        --h-tab: 44px;
        --h-row-btn: 42px;
        --fs-control: 16.5px;
        --fs-tab: 15px;
        --fs-title: 26px;
        --fs-table: 15.5px;
    }

    .page-sub {
        font-size: calc(15.5px * var(--ts));
    }

    .nav-link {
        font-size: calc(15.5px * var(--ts));
    }

    .nav-title {
        font-size: calc(15.5px * var(--ts));
    }

    .cell-meta, .field-hint, .card-desc {
        font-size: calc(14px * var(--ts));
    }

    .list-card-name {
        font-size: calc(16.5px * var(--ts));
    }

    .list-card-meta {
        font-size: calc(15px * var(--ts));
    }

    .list-card-main {
        font-size: calc(15px * var(--ts));
    }

    .list-card-foot {
        font-size: calc(14px * var(--ts));
    }

    .list-panel-title, .card-title {
        font-size: calc(17px * var(--ts));
    }

    .badge {
        font-size: calc(14px * var(--ts));
    }

    .btn-sm {
        font-size: calc(15px * var(--ts));
    }

    .kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .auth2-sub {
        font-size: calc(16px * var(--ts));
    }

    .auth2-note {
        font-size: calc(14px * var(--ts));
    }

    }

/* Label text with an inline hint, e.g. "Mobile (optional)", kept on one line. */
.field-label .field-hint {
    display: inline;
    margin-left: 4px;
}

/* Certificate template editor: background image card. */
.bg-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
}

.bg-current {
    margin: 0;
    width: 220px;
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

    .bg-current img {
        width: 100%;
        aspect-ratio: 297 / 210;
        object-fit: cover;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--surface-2);
    }

    .bg-current figcaption {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
        font-size: calc(14px * var(--ts));
        color: var(--muted-foreground);
    }

.bg-upload {
    flex: 1 1 320px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bg-warn {
    color: var(--warning);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0s !important;
        transition-duration: 0s !important;
    }
}

/* ---------- Deactivated candidates: a paused account, not a certificate state (dashed outline, no fill) */
.badge-off {
    background: transparent;
    color: var(--muted-foreground);
    border: 1px dashed color-mix(in srgb, var(--muted-foreground) 55%, transparent);
}

    .badge-off::before {
        background: transparent;
        box-shadow: inset 0 0 0 1.5px currentColor;
    }

/* The row's Issue action while deactivated: looks unavailable; a click falls through to the row and opens the panel. */
.btn.is-locked {
    color: var(--muted-foreground);
    background: transparent;
    border-style: dashed;
    box-shadow: none;
    cursor: pointer;
}

    .btn.is-locked:hover { background: var(--surface-2); }

.deactivated-note { align-items: center; }
    .deactivated-note > form, .deactivated-note > .btn { flex: none; margin: 0; }
    .deactivated-note .btn { background: var(--card); color: var(--foreground); }

@media (max-width: 639.98px) {
    .deactivated-note { flex-wrap: wrap; }
    .deactivated-note > form, .deactivated-note > .btn { margin-left: 26px; }
}

/* Quiet destructive action (Deactivate): reads as secondary until hovered. */
.btn-quiet-danger { color: var(--muted-foreground); }
    .btn-quiet-danger:hover { color: var(--destructive); background: var(--destructive-soft); }

/* ---------- Side sheet: in-place navigation (candidate → certificate details) with a Back button */
.sheet-back { flex: none; margin: -4px 0 0 -8px; }

dialog.sheet.is-busy > * { opacity: .55; transition: opacity .15s; pointer-events: none; }

dialog.sheet.sheet-enter > *, dialog.sheet.sheet-enter-back > * { animation: sheet-swap .26s cubic-bezier(.2, .8, .2, 1); }
dialog.sheet.sheet-enter-back > * { animation-name: sheet-swap-back; }

@keyframes sheet-swap { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes sheet-swap-back { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }

/* ---------- Certificate viewer (View, and Expand on the Issue preview) */
dialog.modal.modal-doc {
    width: min(1180px, calc(100vw - 32px));
    max-width: none;
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--card);
}

    dialog.modal.modal-doc:not([open]) { display: none; }

    dialog.modal.modal-doc[open] { animation: doc-in .32s cubic-bezier(.16, 1, .3, 1); }
    dialog.modal.modal-doc.is-closing { animation: doc-out .2s cubic-bezier(.4, 0, 1, 1) forwards; }
    dialog.modal.modal-doc.is-closing::backdrop { animation: fade-out .2s ease-in forwards; }

@keyframes doc-in { from { opacity: 0; transform: translateY(14px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes doc-out { to { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes fade-out { to { opacity: 0; } }

.doc-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 22px;
    border-bottom: 1px solid var(--border);
}

.doc-title-wrap { flex: 1; min-width: 0; }
    .doc-title-wrap .modal-title { padding-right: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .doc-title-wrap .modal-title.mono { font-family: var(--mono); font-size: calc(15px * var(--ts)); }

.doc-sub { font-size: calc(14px * var(--ts)); color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.doc-tools { display: flex; align-items: center; gap: 6px; flex: none; }

/* The page sits on a soft stage and is sized so the whole certificate fits the window (width or height, whichever binds). */
.doc-stage {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 24px;
    background:
        radial-gradient(circle at 50% 0, color-mix(in srgb, var(--accent) 7%, transparent), transparent 60%),
        var(--surface-2);
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.doc-paper {
    position: relative;
    overflow: hidden;
    width: min(100%, calc((100dvh - 32px - 80px - 48px) * 1.4144)); /* dialog margin, header (+ slack), stage padding */
    flex: none;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 1px 2px rgb(0 0 0 / .06), 0 12px 32px -8px rgb(0 0 0 / .22);
}

    .doc-paper iframe { position: absolute; top: 0; left: 0; border: 0; transform-origin: 0 0; background: #fff; transition: opacity .2s; }
    .doc-paper.is-loading iframe { opacity: 0; }

.doc-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 26px;
    height: 26px;
    margin: -13px 0 0 -13px;
    border-radius: 50%;
    border: 2.5px solid rgb(0 0 0 / .1);
    border-top-color: var(--accent);
    animation: spin .8s linear infinite;
    opacity: 0;
    transition: opacity .2s;
    pointer-events: none;
}

    .doc-paper.is-loading .doc-spinner { opacity: 1; }

@media (max-width: 639.98px) {
    dialog.modal.modal-doc { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
    .doc-head { padding: 10px 8px 10px 16px; flex-wrap: wrap; }
    .doc-tools .btn:not(.btn-icon) { padding: 0 8px; }
    .doc-tools .badge { display: none; }
    .doc-stage { padding: 12px; align-items: center; }
    .doc-paper { width: 100%; }
}

/* ---------- Issue page: the live preview opens large on click */
.preview-hit {
    position: absolute;
    inset: 0;
    z-index: 1;
    border: 0;
    padding: 10px;
    background: transparent;
    cursor: zoom-in;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    transition: background .2s;
}

    .preview-hit:hover { background: color-mix(in srgb, var(--navy, #2563eb) 6%, transparent); }

.preview-hit-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: calc(13px * var(--ts));
    font-weight: 500;
    color: #fff;
    background: rgb(20 33 58 / .82);
    backdrop-filter: blur(4px);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .18s, transform .18s;
}

    .preview-hit-chip .icon { width: 13px; height: 13px; }
    .preview-hit:hover .preview-hit-chip { opacity: 1; transform: none; }

@media (hover: none) {
    .preview-hit-chip { opacity: 1; transform: none; }
}

/* White text only on the darker light-theme accent; dark text on the bright dark-theme accent. */
:root[data-theme="dark"] .btn-accent, :root[data-theme="dark"] .btn-accent:hover { color: #14171a; }

/* Keyboard users can jump past the menu. */
.skip-link {
    position: absolute;
    left: 16px;
    top: -60px;
    z-index: 100;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: var(--primary-foreground);
    font-weight: 500;
}

    .skip-link:focus { top: 12px; color: var(--primary-foreground); }

/* References stay on one line in tables. */
.table .mono { white-space: nowrap; }

/* Phones: the breadcrumb stays on one line and the notification count stays readable in dark mode. */
@media (max-width: 767.98px) {
    .crumbs { min-width: 0; white-space: nowrap; overflow: hidden; }
    .crumbs strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
    .viz-head { flex-wrap: wrap; }
    .viz-switch button { height: 40px; }
}

:root[data-theme="dark"] .live-badge { color: #14171a; }

/* ---------- Browser surfaces carry the design too */
html { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
body { font-feature-settings: "cv11", "ss01"; caret-color: var(--accent); }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--foreground); }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
a:hover { color: var(--accent-foreground); }

/* ---------- Type utilities */
.lbl, .overline {
    font-size: calc(12px * var(--ts));
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted-foreground);
}

.tnum { font-variant-numeric: tabular-nums; }
.figure { font-size: 28px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.display { font-size: 40px; font-weight: 700; line-height: 1; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.desc { font-size: calc(14px * var(--ts)); line-height: 1.55; color: var(--muted-foreground); }
.meta { font-size: calc(13.5px * var(--ts)); line-height: 1.45; color: var(--subtle); }

/* Code tag: the prefix of a reference in its module colour, in a fixed column before the title. */
.code-tag {
    display: inline-block;
    min-width: 44px;
    font-size: calc(14px * var(--ts));
    font-weight: 600;
    letter-spacing: .02em;
    font-variant-numeric: tabular-nums;
    color: var(--code-governance);
    white-space: nowrap;
}

    .code-tag[data-code="DPR"] { color: var(--code-rights); }
    .code-tag[data-code="INC"] { color: var(--code-incident); }
    .code-tag[data-code="REG"] { color: var(--code-regulator); }
    .code-tag[data-code="CON"], .code-tag[data-code="FRM"], .code-tag[data-code="CR"] { color: var(--code-consent); }

.code-num { font-weight: 500; font-variant-numeric: tabular-nums; color: var(--muted-foreground); white-space: nowrap; }

/* Deltas and scale steps */
.delta { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.is-up { color: var(--success); }
.delta.is-down { color: var(--destructive); }
.scale-steps { display: inline-flex; align-items: center; gap: 8px; font-size: calc(14px * var(--ts)); font-weight: 600; white-space: nowrap; }
.scale-steps .was { color: var(--chart-3); font-weight: 500; }
.scale-steps .now { color: var(--success); }
.scale-steps .arr { color: var(--subtle); font-weight: 400; }

/* Inline code reads as a chip. */
code:not(pre code), .chip-code {
    font-family: var(--mono);
    font-size: .9em;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--surface-3);
    color: var(--foreground);
    overflow-wrap: anywhere;
}


/* ---------- Floating surfaces grow from where they were called */
.live-panel, .combo-pop, [data-tour-menu], .org-switch-menu {
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    transform-origin: top right;
    animation: grow-in var(--m-base) var(--ease-out);
}

@keyframes grow-in { from { opacity: 0; transform: scale(.96); } }
.toasts .alert { border-radius: 12px; animation: toast-in var(--m-base) var(--ease-spring); }
@keyframes toast-in { from { opacity: 0; transform: translateY(20px) scale(.96); } }
dialog.modal { border-radius: 20px; box-shadow: var(--shadow-lg); }
.skip-link { background: var(--primary); color: var(--primary-foreground); }

/* ---------- Liveness */
.live-dot { background: var(--subtle); transition: background var(--m-base); }
    .live-dot.on { background: var(--lime); animation: breathe 3s infinite; }
@keyframes breathe {
    0% { box-shadow: 0 0 0 2px var(--card), 0 0 0 2px color-mix(in srgb, var(--lime) 60%, transparent); }
    70% { box-shadow: 0 0 0 2px var(--card), 0 0 0 8px color-mix(in srgb, var(--lime) 0%, transparent); }
    100% { box-shadow: 0 0 0 2px var(--card), 0 0 0 2px color-mix(in srgb, var(--lime) 0%, transparent); }
}

.live-refresh { border: 1px solid var(--border-strong); background: var(--card); border-radius: var(--radius-pill); font-weight: 500; animation: arrive var(--m-base) var(--ease-out); }
.live-pulse { animation: none; }

/* A row or feed item that arrives live slides into place and carries an accent wash that fades. */
.is-arriving { animation: arrive var(--m-base) var(--ease-out), wash 2s var(--ease-out); }
@keyframes arrive { from { opacity: 0; transform: translateY(-10px); } }
@keyframes wash { from { background-color: var(--accent-soft); } to { background-color: transparent; } }

/* Rolling figures: each digit is a column that slides to its value. */
.roll { display: inline-block; height: 1em; overflow: hidden; line-height: 1; vertical-align: baseline; }
    .roll > span { display: block; transition: transform var(--m-stage) var(--ease-out); will-change: transform; }
    .roll > span > i { display: block; height: 1em; font-style: normal; }
[data-roll] { display: inline-flex; align-items: flex-end; line-height: 1; font-variant-numeric: tabular-nums; }
    [data-roll] > span { display: block; height: 1em; line-height: 1; }

/* The overdue dot pulses three times when the page opens, then holds. */
.pulse-3 { animation: pulse-3 1.2s ease-out 3; }
@keyframes pulse-3 { 50% { transform: scale(1.8); opacity: .4; } }

/* Entrance choreography: once per visit, in reading order. JS adds the class, so nothing hides without it. */
.enter-stage > * { opacity: 0; transform: translateY(12px); animation: rise var(--m-stage) var(--ease-out) forwards; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes rise { to { opacity: 1; transform: none; } }

/* Page transitions: the shell stays still, the content cross-fades with a small rise. */
@view-transition { navigation: auto; }
.sidenav { view-transition-name: sidenav; }
.topbar { view-transition-name: topbar; }
::view-transition-old(root) { animation: vt-out var(--m-base) var(--ease-in-out) both; }
::view-transition-new(root) { animation: vt-in var(--m-slow) var(--ease-out) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }
::view-transition-group(sidenav), ::view-transition-group(topbar) { animation-duration: 0s; }

@media (prefers-reduced-motion: reduce) {
    .btn:active, a.card:hover, a.inner-card:hover, a.stat:hover { transform: none; }
    .nav-pill, .tab-ink { transition: none; }
    .live-dot.on, .is-arriving, .pulse-3, .live-panel, .combo-pop, .org-switch-menu, .toasts .alert, .live-refresh { animation: none; }
    .roll > span { transition: none; }
    .enter-stage > * { animation: none; opacity: 1; transform: none; }
    ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
    @view-transition { navigation: none; }
}


/* =====================================================================
   Design system v2 — "Calm surfaces, one clear signal" (DESIGN.md, November 2026).
   Ink and violet carry structure, one lime dot marks what needs a person, white rounded surfaces sit on a warm
   canvas, evidence is set in mono. This block restyles the shell, the controls and the page patterns; the older
   blocks above still hold page-specific rules on the same tokens.
   ===================================================================== */
:root {
    --fs-body: 14px;
    --fs-label: 13px;
    --fs-title: 32px;
    --h-btn: 40px;
    --h-control: 42px;
    --h-tab: 34px;
    --h-row-btn: 32px;
    --fs-control: 13.5px;
    --fs-tab: 13.5px;
    --fs-table: 13.5px;
    --sidebar-w: var(--nav-w);
}

@media (min-width: 1680px) {
    :root { --h-control: 42px; --h-btn: 40px; --h-tab: 34px; --fs-control: 13.5px; --fs-tab: 13.5px; --fs-title: 32px; --fs-table: 13.5px; }
    dialog.modal, dialog.sheet { --h-control: 42px; }
}

@media (max-width: 1100px) {
    :root { --gutter: 20px; }
}

@media (max-width: 767.98px) {
    :root { --fs-body: 14px; --fs-label: 13px; --h-control: 44px; --h-btn: 42px; --h-tab: 36px; --h-row-btn: 34px; --fs-control: 14px; --fs-tab: 13.5px; --fs-title: 26px; --fs-table: 13.5px; }
    .page-sub { font-size: calc(14px * var(--ts)); }
    .nav-link, .nav-title { font-size: calc(14px * var(--ts)); }
    .cell-meta, .field-hint, .card-desc { font-size: calc(12.5px * var(--ts)); }
    .list-panel-title, .card-title { font-size: calc(16px * var(--ts)); }
    .badge { font-size: calc(12px * var(--ts)); }
    .btn-sm { font-size: calc(12.5px * var(--ts)); }
}

@media (max-width: 720px) {
    :root { --gutter: 14px; --fs-title: 26px; }
}

/* ---------- Base: type, selection, focus, links */
body {
    font: 400 var(--fs-base)/1.5 var(--font);
    font-feature-settings: "ss01", "cv11";
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    caret-color: var(--primary);
}

::selection { background: var(--lime-400); color: var(--ink-900); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--r-xs); }
a { color: var(--primary-text); }
    a:hover { color: var(--primary-text); text-decoration: underline; }
h1, h2, h3, h4 { letter-spacing: -.01em; }
.mono, code, kbd, samp { font-family: var(--mono); font-size: .92em; font-weight: 400; letter-spacing: 0; font-feature-settings: normal; }
.small { font-size: calc(var(--fs-sm) * var(--ts)); }
.xsmall { font-size: calc(var(--fs-xs) * var(--ts)); }
.num { font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.center { text-align: center; }
.left { text-align: left; }
.stack { gap: 16px; }
.row { flex-wrap: wrap; }
.row-between { justify-content: space-between; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: start; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.icon { stroke-width: 1.8; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.skip-link { background: var(--ink-900); color: #fff; border-radius: var(--r-pill); font-weight: 600; }

/* ---------- Shell: floating side navigation, translucent top bar, one centred column */
.shell {
    display: grid;
    grid-template-columns: var(--nav-w) minmax(0, 1fr);
    min-height: 100dvh;
    padding: var(--shell-pad);
    gap: var(--shell-gap);
}

.sidenav {
    position: sticky;
    top: var(--shell-pad);
    align-self: start;
    width: auto;
    height: calc(100dvh - var(--shell-pad) * 2);
    padding: 0;
    gap: 0;
    background: var(--surface);
    color: var(--text-2);
    border: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    z-index: 40;
}

.brand { gap: 12px; padding: 18px 18px 14px; margin: 0; }
.brand-link { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; color: inherit; text-decoration: none; }
    .brand-link:hover { text-decoration: none; color: inherit; }
.brand-mark { width: 40px; height: 40px; padding: 0; border-radius: 12px; background: none; box-shadow: 0 6px 14px -6px rgba(var(--accent-rgb), .65); object-fit: contain; }
.brand-name { display: block; font-size: calc(17px * var(--ts)); font-weight: 700; letter-spacing: -.02em; line-height: 1.15; color: var(--text); }
.brand-sub { display: block; font-size: calc(var(--fs-xs) * var(--ts)); color: var(--muted); line-height: 1.3; }
.sidenav .nav-close { display: none; margin-left: auto; }

.nav-scroll { margin: 0; padding: 4px 12px 12px; gap: 0; scrollbar-color: var(--border-strong) transparent; }
    .nav-scroll::-webkit-scrollbar { width: 8px; }
    .nav-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid var(--surface); }
.nav-group { gap: 0; }

.nav-section {
    margin: 18px 10px 6px;
    padding: 0;
    font-size: calc(var(--fs-2xs) * var(--ts));
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--faint);
}

.nav-group:first-child .nav-section, .nav-scroll > .nav-section:first-child { margin-top: 6px; }

.nav-link, .nav-title {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 11px;
    height: auto;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: var(--r-md);
    color: var(--text-2);
    font-weight: 550;
    font-size: calc(14px * var(--ts));
    line-height: 1.25;
    white-space: nowrap;
    transition: background-color var(--m-quick), color var(--m-quick);
}

    .nav-link .icon, .nav-title .icon { width: 18px; height: 18px; opacity: 1; color: var(--muted); transition: color var(--m-quick); }
    .nav-link:hover, summary.nav-title:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
        .nav-link:hover .icon, summary.nav-title:hover .icon { color: var(--text); }

summary.nav-title::after { content: none; }
.nav-title .nav-chev { margin-left: auto; width: 16px; height: 16px; color: var(--faint); transition: transform .2s; }
details[open] > .nav-title .nav-chev { transform: rotate(90deg); }
details[open] > .nav-title { color: var(--text); }
    details[open] > .nav-title .icon:first-child { color: var(--primary-text); }

/* The current top-level page: a soft accent pill with accent text and icon, a hairline ring and a faint accent shadow.
   Every colour is an accent token, so it follows Violet, Teal or Emerald and works in dark as it is. */
:root {
    --nav-top-bg: linear-gradient(180deg, var(--primary-soft), color-mix(in srgb, var(--primary-soft-2) 70%, var(--primary-soft)));
    --nav-top-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .22), 0 6px 14px -10px rgba(var(--accent-rgb), .55);
}
.nav-link.nav-top.active { background: var(--nav-top-bg); color: var(--primary-text); font-weight: 650; box-shadow: var(--nav-top-shadow); }
    .nav-link.nav-top.active .icon { color: var(--primary); }
:root[data-theme="dark"] .nav-link.nav-top.active .icon { color: var(--primary-text); }

/* Sub navigation: a thin guide line and compact pills. */
.nav-sub { margin: 2px 0 6px 21px; padding-left: 12px; border-left: 1.5px solid var(--hairline); display: grid; gap: 1px; }
    .nav-sub .nav-link, details.nav-group > .nav-link { height: auto; min-height: 34px; margin-left: 0; padding: 6px 10px; font-size: calc(13.5px * var(--ts)); font-weight: 500; border-radius: 10px; }
        .nav-sub .nav-link .icon, details.nav-group > .nav-link .icon { display: block; width: 16px; height: 16px; }
        .nav-sub .nav-link::before, details.nav-group > .nav-link::before { display: none; }
    .nav-sub .nav-link.active, details.nav-group > .nav-link.active { background: var(--primary-soft); color: var(--primary-text); font-weight: 650; box-shadow: none; }
        .nav-sub .nav-link.active .icon, details.nav-group > .nav-link.active .icon { color: var(--primary-text); }
.nav-link.active { background: var(--primary-soft); color: var(--primary-text); font-weight: 650; }
    .nav-link.active .icon { color: var(--primary-text); }

/* The active pill slides between items (site.js); it takes the ink look behind a top-level page. */
.nav-pill {
    position: absolute;
    left: 0;
    top: 0;
    height: 34px;
    border-radius: 10px;
    background: var(--primary-soft);
    pointer-events: none;
    opacity: 0;
    transition: transform var(--m-base) var(--ease-in-out), width var(--m-base) var(--ease-in-out), height var(--m-base) var(--ease-in-out), border-radius var(--m-base) var(--ease-in-out), background-color var(--m-base), opacity var(--m-quick);
}

    .nav-pill.is-top { border-radius: var(--r-md); background: var(--nav-top-bg); box-shadow: var(--nav-top-shadow); }
/* The pill lives inside the scrolling menu, so it scrolls with the item it sits behind. */
.nav-scroll.has-pill { position: relative; }
.nav-scroll.has-pill .nav-pill { opacity: 1; }
/* Gone at once when its group collapses: a fade would show it over the item that moved up into its spot. */
.nav-scroll.has-pill .nav-pill.is-hidden { opacity: 0; transition: none; }
.nav-scroll.has-pill .nav-link.active { background: transparent; box-shadow: none; }
.nav-scroll.has-pill .nav-link.is-going { color: var(--primary-text); font-weight: 650; }
    .nav-scroll.has-pill .nav-link.is-going .icon { color: var(--primary-text); }
.nav-scroll.has-pill .nav-link.nav-top.is-going { color: var(--primary-text); }
    .nav-scroll.has-pill .nav-link.nav-top.is-going .icon { color: var(--primary); }
:root[data-theme="dark"] .nav-scroll.has-pill .nav-link.nav-top.is-going .icon { color: var(--primary-text); }
.nav-scroll.has-pill .nav-link.active.is-leaving { color: var(--text-2); font-weight: 550; }
    .nav-scroll.has-pill .nav-link.active.is-leaving .icon { color: var(--muted); }

.nav-count { background: var(--surface-3); color: var(--muted); font-size: calc(11.5px * var(--ts)); font-weight: 700; padding: 1px 7px; }
.nav-link.active .nav-count { background: var(--surface); color: var(--primary-text); }
.nav-soon { margin-left: auto; font-size: calc(10px * var(--ts)); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 1px 7px; border-radius: var(--r-pill); border: 1px solid var(--border); color: var(--muted); }

/* The user card: a raised tile with the avatar, the name, the role and sign out. */
.nav-foot { margin: 0 12px 12px; padding: 8px; gap: 6px; border: 1px solid var(--hairline); border-top: 1px solid var(--hairline); border-radius: var(--r-lg); background: var(--surface-2); }
.nav-user { padding: 2px; gap: 10px; border-radius: var(--r-md); }
    .nav-user:hover, .nav-user.active { background: var(--surface-3); box-shadow: none; }
.nav-user-text { gap: 0; line-height: 1.25; }
.nav-user-name { font-size: calc(13.5px * var(--ts)); font-weight: 650; color: var(--text); }
.nav-user-role { font-size: calc(var(--fs-xs) * var(--ts)); color: var(--muted); }
.nav-signout .btn-icon, .nav-signout .btn-sm.btn-icon { width: 32px; height: 32px; color: var(--muted); border-radius: var(--r-pill); }
    .nav-signout .btn-icon:hover { color: var(--text); }

.avatar {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(140deg, var(--violet-400), var(--violet-700));
    color: #fff;
    font-size: calc(12px * var(--ts));
    font-weight: 700;
    letter-spacing: .02em;
}

.avatar-sm { width: 28px; height: 28px; font-size: calc(11px * var(--ts)); }
.avatar-lg { width: 44px; height: 44px; font-size: calc(15px * var(--ts)); }
.avatar-lime { background: var(--lime-400); color: var(--ink-900); }
.avatar-ink { background: var(--ink-900); color: #fff; }

.main { min-width: 0; }

.topbar {
    display: block;
    height: auto;
    min-height: 68px;
    padding: 12px 0 10px;
    gap: 0;
    background: color-mix(in srgb, var(--bg) 84%, transparent);
    backdrop-filter: blur(14px) saturate(1.2);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    border-bottom: 0;
    top: 0;
    z-index: 30;
}

.topbar-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    width: 100%;
    max-width: var(--page-w);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

.crumbs { flex: 1 1 auto; gap: 8px; min-width: 0; font-size: calc(13.5px * var(--ts)); color: var(--muted); white-space: nowrap; }
    .crumbs .crumb-parent { color: var(--muted); }
    .crumbs strong { font-weight: 650; color: var(--text); overflow: hidden; text-overflow: ellipsis; }

/* Round white controls on the top bar */
.topbar .btn-icon, .topbar .btn.btn-icon, .topbar .btn-ghost.btn-icon {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    box-shadow: var(--shadow-xs);
}

    .topbar .btn-icon:hover, .topbar .btn.btn-icon:hover, .topbar .btn-ghost.btn-icon:hover { background: var(--surface-3); color: var(--text); border-color: var(--border); }
    .topbar .btn-icon .icon { width: 18px; height: 18px; }
.topbar .btn.menu-btn { display: none; }

.content {
    width: 100%;
    max-width: var(--page-w);
    margin: 0 auto;
    padding: 6px var(--gutter) 56px;
    gap: 22px;
}

/* Layouts answer to the column they get, not the window: with the side nav open, a 1150px window
   leaves under 800px for the page, so window breakpoints left sidebars and the hero crushed. */
.content { container: page / inline-size; }

/* Blocks directly in the page are spaced by the column's gap alone. Many views still carry an inline top or bottom
   margin from before the gap existed, which doubled the space between cards to about 42px; the gap is the one spacing.
   Dialogs keep their own margins, which centre them. */
.content { gap: 20px; }
.content > :not(dialog) { margin-top: 0 !important; margin-bottom: 0 !important; }

    .content:focus { outline: none; }

/* Notifications and help: the bell's lime dot and red count, and the panel */
.live-wrap { position: relative; }
.live-bell { position: relative; overflow: visible; }
.live-dot {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--faint);
    box-shadow: 0 0 0 2px var(--surface);
    transition: background var(--m-base), box-shadow var(--m-base);
}

html.live-on .live-dot, .live-dot.is-on, .live-dot.on { background: var(--lime-400); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px rgba(94, 122, 0, .25); }
.live-badge {
    position: absolute;
    right: -4px;
    top: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: var(--r-pill);
    background: var(--danger);
    color: #fff;
    font-size: calc(11px * var(--ts));
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    border: 2px solid var(--bg);
}

:root[data-theme="dark"] .live-badge { color: #fff; }
.live-panel, [data-tour-menu] {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    z-index: 80;
    width: min(360px, calc(100vw - 32px));
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
}

.live-panel-head { padding: 10px 12px 8px; margin: 0; border: 0; font-weight: 700; font-size: calc(13.5px * var(--ts)); }
.live-list:empty::after { content: "You're all caught up."; display: block; padding: 14px 12px 16px; color: var(--muted); font-size: calc(var(--fs-sm) * var(--ts)); }
.live-item { display: block; padding: 10px 12px; border: 0; border-radius: var(--r-md); color: inherit; text-decoration: none; }
    .live-item:hover { background: var(--surface-3); text-decoration: none; color: inherit; }
    .live-item::before { display: none; }
.live-item-title { display: block; font-weight: 650; font-size: calc(13.5px * var(--ts)); }
.live-item-text { display: block; margin: 2px 0 0; color: var(--muted); font-size: calc(var(--fs-sm) * var(--ts)); line-height: 1.45; opacity: 1; }
.live-item-time { display: block; margin: 4px 0 0; color: var(--faint); font-size: calc(var(--fs-xs) * var(--ts)); opacity: 1; }
.live-item.unread { background: var(--primary-soft); }
.live-item.live-critical .live-item-title { color: var(--danger-text); }
.live-empty { padding: 14px 12px 16px; color: var(--muted); font-size: calc(var(--fs-sm) * var(--ts)); opacity: 1; }

/* Organisation switcher */
.org-switch { position: relative; }
    .org-switch > summary { list-style: none; }
        .org-switch > summary::-webkit-details-marker { display: none; }
.topbar .org-switch-btn, .org-switch-btn {
    gap: 10px;
    height: 40px;
    max-width: 300px;
    padding: 0 14px 0 5px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-xs);
    font-weight: 600;
    font-size: calc(13.5px * var(--ts));
}

    .org-switch-btn:hover { background: var(--surface-3); border-color: var(--border); }
    .org-switch-btn > .icon { width: 16px; height: 16px; color: var(--muted); }
.org-switch-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: calc(13.5px * var(--ts)); }
.org-switch-mark {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: calc(11.5px * var(--ts));
    font-weight: 700;
    background: var(--lime-400);
    color: var(--ink-900);
}

    .org-switch-mark.ghost { background: var(--surface-3); color: var(--muted); }
    .org-switch-mark .icon { width: 15px; height: 15px; color: inherit; }
.org-switch-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    z-index: 80;
    min-width: 300px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
}

.org-switch-title { font-size: calc(var(--fs-xs) * var(--ts)); color: var(--muted); font-weight: 650; padding: 8px 10px 6px; text-transform: uppercase; letter-spacing: .06em; }
.org-switch-item { gap: 12px; padding: 10px; border-radius: var(--r-md); }
    .org-switch-item:hover:not(:disabled) { background: var(--surface-3); text-decoration: none; }
    .org-switch-item.current { cursor: default; background: var(--primary-soft); }
.org-switch-item-name { font-weight: 650; }
.org-switch-item .icon { color: var(--primary-text); }
.org-switch-item .org-switch-mark { width: 28px; height: 28px; font-size: calc(11.5px * var(--ts)); }

/* Toasts: ink cards that rise in */
.toasts { z-index: 200; width: min(380px, calc(100vw - 40px)); }
    .toasts .alert, .toasts .alert-ok, .toasts .alert-err, .toasts .alert-warn, .toasts .alert-info {
        padding: 12px 16px;
        border: 0;
        border-radius: var(--r-md);
        background: var(--ink-900);
        color: #fff;
        box-shadow: var(--shadow-lg);
        font-size: calc(var(--fs-sm) * var(--ts));
    }

    .toasts .alert > .icon { color: var(--hero-muted); }
    .toasts .alert-ok > .icon { color: var(--lime-400); }
    .toasts .alert-err > .icon { color: #FF9A97; }
    .toasts .alert-warn > .icon { color: #F6C46B; }
    .toasts .alert a { color: #fff; }
:root[data-theme="dark"] .toasts .alert { background: var(--ink-700); border: 1px solid var(--border-strong); }

/* Drawer navigation on tablets and phones */
@media (max-width: 1100px) {
    .shell { grid-template-columns: minmax(0, 1fr); padding: 0; gap: 0; }
    .sidenav {
        position: fixed;
        left: 10px;
        top: 10px;
        bottom: 10px;
        height: auto;
        width: min(max(300px, var(--nav-w)), calc(100vw - 20px));
        border-radius: var(--r-xl);
        border: 1px solid var(--border);
        padding-top: 0;
        transform: translateX(calc(-100% - 20px));
        transition: transform .28s var(--ease-out), visibility .28s;
        box-shadow: var(--shadow-lg);
        z-index: 70;
    }

    .shell.nav-open .sidenav, .nav-open .sidenav { transform: none; }
    .sidenav .nav-close { display: inline-flex; }
    .nav-scrim { background: rgba(12, 11, 18, .5); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
    .topbar .btn.menu-btn { display: inline-flex; box-shadow: var(--shadow-xs); }
    .topbar { min-height: 64px; padding: 10px 0 8px; }
    .content { padding: 6px var(--gutter) 48px; }
}

@media (max-width: 720px) {
    .org-switch-name { display: none; }
    .topbar .org-switch-btn, .org-switch-btn { padding: 0 10px 0 5px; }
    .crumbs .crumb-parent { display: none; }
    .topbar-inner { gap: 8px; }
}

/* ---------- Buttons: pills; violet primary, white default, ink, signal, light, ghost, danger */
.btn {
    height: 40px;
    padding: 0 18px;
    gap: 8px;
    border-radius: var(--r-pill);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-size: calc(13.5px * var(--ts));
    font-weight: 600;
    line-height: 1;
    box-shadow: var(--shadow-xs);
    transition: background-color var(--m-quick), border-color var(--m-quick), color var(--m-quick), box-shadow var(--m-quick), transform var(--m-instant);
}

    .btn:hover { background: var(--surface-3); border-color: var(--border-strong); color: var(--text); text-decoration: none; }
    .btn:active { transform: translateY(1px); }
    .btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
    .btn .icon { width: 16px; height: 16px; }
    .btn:disabled, .btn[disabled], .btn.disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }

.btn-primary, .btn-accent { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: 0 8px 18px -10px rgba(var(--accent-rgb), .9); }
    .btn-primary:hover, .btn-accent:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); filter: none; }
    .btn-primary:active, .btn-accent:active { background: var(--primary-press); }
:root[data-theme="dark"] .btn-accent, :root[data-theme="dark"] .btn-accent:hover { color: var(--on-primary); }
.btn-dark { background: var(--ink-900); border-color: var(--ink-900); color: #fff; }
    .btn-dark:hover { background: var(--ink-700); border-color: var(--ink-700); color: #fff; }
:root[data-theme="dark"] .btn-dark { background: #fff; border-color: #fff; color: var(--ink-900); }
    :root[data-theme="dark"] .btn-dark:hover { background: #E4E1F2; border-color: #E4E1F2; color: var(--ink-900); }
.btn-signal { background: var(--lime-400); border-color: var(--lime-400); color: var(--ink-900); }
    .btn-signal:hover { background: var(--lime-300); border-color: var(--lime-300); color: var(--ink-900); }
.btn-light { background: #fff; border-color: #fff; color: var(--ink-900); box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .5); }
    .btn-light:hover { background: #ECE7FF; border-color: #ECE7FF; color: var(--ink-900); }
.btn-secondary { background: var(--surface-3); border-color: transparent; box-shadow: none; }
    .btn-secondary:hover { background: var(--surface-3); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
    .btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
    .btn-danger:hover { filter: none; background: #C42F2F; border-color: #C42F2F; color: #fff; }
.btn-quiet-danger { color: var(--danger-text); }
    .btn-quiet-danger:hover { background: var(--danger-soft); border-color: var(--border-strong); color: var(--danger-text); }
.btn-sm { height: 32px; padding: 0 13px; font-size: calc(12.5px * var(--ts)); gap: 6px; }
    .btn-sm .icon { width: 14px; height: 14px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: calc(14px * var(--ts)); }
.btn-icon, .btn-sm.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: var(--r-pill); }
.btn-sm.btn-icon { width: 32px; height: 32px; }
.btn:not(.btn-sm):not(.btn-icon):not(.btn-lg) { height: var(--h-btn); font-size: calc(var(--fs-control) * var(--ts)); padding: 0 18px; }
.btn-link { color: var(--primary-text); }
.btn.loading::after { border-color: currentColor transparent currentColor transparent; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Back pill above a detail title */
.back-link, .back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: auto;
    margin: 0 0 12px;
    padding: 5px 12px 5px 8px;
    border: 1px solid var(--border);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--text-2);
    font-size: calc(13px * var(--ts));
    font-weight: 600;
    text-decoration: none;
    box-shadow: var(--shadow-xs);
    transition: background var(--m-quick), border-color var(--m-quick), color var(--m-quick);
}

    .back-link:hover, .back-btn:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
    .back-link .icon, .back-btn .icon { width: 15px; height: 15px; }

/* Success: a check draws in inside the button, then the label returns. */
.btn .btn-check { display: none; position: absolute; inset: 0; margin: auto; width: 20px; height: 20px; }
.btn.is-done { position: relative; color: transparent !important; }
    .btn.is-done .btn-check { display: block; color: var(--on-primary); }
    .btn.is-done:not(.btn-primary) .btn-check { color: var(--success); }
    .btn.is-done .btn-check path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw-check 360ms var(--ease-spring) forwards; }
@keyframes draw-check { to { stroke-dashoffset: 0; } }

/* ---------- Page head */
.page-head { align-items: flex-end; gap: 20px 28px; padding: 4px 0 2px; }
    .page-head > div:first-child { min-width: 0; flex: 1 1 420px; }
.page-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    font-size: var(--fs-title);
    font-weight: 650;
    letter-spacing: -.035em;
    line-height: 1.12;
    color: var(--text);
}

    .page-title .badge { font-size: calc(12.5px * var(--ts)); letter-spacing: 0; transform: translateY(2px); }
    .page-title .soft { color: var(--faint); font-weight: 500; }
    .page-title .mono { font-size: .92em; letter-spacing: -.02em; }
.page-sub { margin: 10px 0 0; max-width: 78ch; color: var(--muted); font-size: calc(14.5px * var(--ts)); line-height: 1.55; text-wrap: pretty; }
    .page-sub strong { color: var(--text-2); font-weight: 650; }
.actions { gap: 10px; }
    .actions form { margin: 0; }

/* ---------- Forms: quiet labels, 14px-radius fields, violet focus */
.field { gap: 7px; font-size: calc(13px * var(--ts)); font-weight: 600; color: var(--text); }
    .field .muted { font-weight: 500; }
.field-label { font-size: calc(13px * var(--ts)); font-weight: 600; }
.field-hint, .field > .small, .field > .xsmall { font-size: calc(var(--fs-xs) * var(--ts)); font-weight: 450; color: var(--muted); line-height: 1.45; }
.field-error, .field-validation-error, .err { font-size: calc(var(--fs-xs) * var(--ts)); font-weight: 550; color: var(--danger-text); }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
    .form-grid > .span-2, .form-grid .span-2 { grid-column: span 2; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } .form-grid > .span-2, .form-grid .span-2 { grid-column: auto; } }

.input, .select, .textarea, textarea.input, .combo-btn {
    height: var(--h-control);
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--surface);
    color: var(--text);
    font-size: calc(14px * var(--ts));
    font-weight: 450;
    line-height: 1.3;
    box-shadow: none;
    transition: border-color var(--m-quick), box-shadow var(--m-quick), background-color var(--m-quick);
}

.textarea, textarea.input { height: auto; min-height: 88px; padding: 11px 14px; line-height: 1.5; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--faint); }
.input:focus, .select:focus, .textarea:focus, .combo.open .combo-btn, .combo-btn:focus-visible { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
.input[readonly], .input:disabled, .select:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
.input[type="color"] { padding: 4px; width: 56px; cursor: pointer; }
.input[type="number"] { font-variant-numeric: tabular-nums; }
.input[type="date"], .input[type="datetime-local"] { min-width: 150px; padding-right: 10px; }
.input-error, .input.input-validation-error, .select.input-validation-error, .textarea.input-validation-error, .combo.input-validation-error .combo-btn { border-color: var(--danger) !important; box-shadow: 0 0 0 3px var(--danger-soft); }
.select {
    padding-right: 38px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: var(--chev);
    background-repeat: no-repeat;
    background-position: right 13px center;
    background-size: 16px;
}

.select-sm, .input-sm { height: 34px; font-size: calc(13px * var(--ts)); padding-left: 12px; border-radius: var(--r-sm); }
.select-sm { padding-right: 32px; background-position: right 10px center; }
.prefix { height: var(--h-control); border-radius: var(--r-md); border-color: var(--border-strong); background: var(--surface-3); color: var(--muted); font-size: calc(13px * var(--ts)); }

/* Checkbox (.cb) and radio: 18px, 6px corners, violet when checked */
input[type=checkbox].cb, input[type=radio] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    flex: none;
    margin: 0;
    border: 1.5px solid var(--border-strong);
    border-radius: 6px;
    background: var(--surface);
    display: inline-grid;
    place-content: center;
    cursor: pointer;
    accent-color: var(--primary);
    transition: background-color .12s, border-color .12s;
}

    input[type=checkbox].cb:checked, input[type=radio]:checked {
        background: var(--primary);
        border-color: var(--primary);
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
        background-size: 13px;
        background-position: center;
        background-repeat: no-repeat;
    }

input[type=radio] { border-radius: 50%; }
    input[type=radio]:checked { background-image: radial-gradient(circle, #fff 0 3.2px, transparent 3.6px); background-size: auto; }
input[type=checkbox].cb:focus-visible, input[type=radio]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.check, .check-row { gap: 10px; font-size: calc(13.5px * var(--ts)); font-weight: 550; color: var(--text); }
    .check .muted, .check-row .muted { font-weight: 450; }

/* Switch: every bare checkbox is one (42 × 24, violet when on); .switch > input + .switch-track is the explicit form */
input[type=checkbox]:not(.cb) { width: 42px; height: 24px; background: var(--border-strong); transition: background .18s; }
    input[type=checkbox]:not(.cb)::after { top: 3px; left: 3px; width: 18px; height: 18px; box-shadow: 0 1px 3px rgba(20, 18, 31, .35); transition: transform .18s var(--ease-spring); }
    input[type=checkbox]:not(.cb):checked { background: var(--primary); }
    input[type=checkbox]:not(.cb):checked::after { transform: translateX(18px); }
    input[type=checkbox]:not(.cb):focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
:root[data-theme="dark"] input[type=checkbox]:not(.cb):checked { background: var(--primary); }
.switch { position: relative; display: inline-flex; width: 42px; height: 24px; flex: none; }
    .switch input[type="checkbox"] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; border: 0; background: none; opacity: 0; cursor: pointer; z-index: 1; }
    .switch-track { position: absolute; inset: 0; border-radius: var(--r-pill); background: var(--border-strong); transition: background .18s; }
        .switch-track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(20, 18, 31, .35); transition: transform .18s var(--ease-spring); }
    .switch input:checked + .switch-track { background: var(--primary); }
    .switch input:checked + .switch-track::after { transform: translateX(18px); }
    .switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Combobox popover and options */
.combo-pop { padding: 6px; border-radius: var(--r-md); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.combo-opt { border-radius: var(--r-sm); padding: 8px 10px 8px 30px; font-size: calc(13.5px * var(--ts)); }
.combo-search { height: 36px; font-size: calc(13.5px * var(--ts)); }

/* ---------- Cards and section cards */
.card {
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 22px 24px;
    gap: 16px;
    box-shadow: var(--shadow-xs);
    min-width: 0;
}

    .card > .card-title { margin: 0; }
.card-flush { padding: 0; overflow: hidden; }
.card-soft { background: var(--surface-2); box-shadow: none; }
.card-title { font-size: calc(var(--fs-md) * var(--ts)); font-weight: 700; letter-spacing: -.01em; line-height: 1.3; color: var(--text); }
.card-head { gap: 12px; flex-wrap: wrap; }
    .card-head .card-title { margin: 0; }
.card-sub, .card-desc { color: var(--muted); font-size: calc(var(--fs-sm) * var(--ts)); margin-top: 3px; }
.inner-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px 18px; }
a.card, a.inner-card { transition: transform var(--m-quick) var(--ease-out), box-shadow var(--m-quick), border-color var(--m-quick); }
    a.card:hover, a.inner-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); color: inherit; text-decoration: none; }
@media (max-width: 767.98px) { .card { padding: 20px 18px; } }

/* Section cards: an icon chip, a title, a description, then the work */
.sec {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
    padding: 22px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
}

.sec-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 14px; align-items: center; min-width: 0; }
    .sec-head > .tile, .sec-head > .chip-icon { grid-row: 1 / span 2; align-self: start; }
.sec-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0; font-size: calc(17px * var(--ts)); font-weight: 700; letter-spacing: -.015em; line-height: 1.3; min-height: 38px; }
    .sec-title .badge { font-size: calc(12px * var(--ts)); letter-spacing: 0; }
.sec-desc { grid-column: 2; margin: 0; max-width: 88ch; font-size: calc(13.5px * var(--ts)); line-height: 1.6; color: var(--muted); text-wrap: pretty; }
    .sec-head:has(.sec-desc) .sec-title { min-height: 0; }
.sec-body { display: grid; gap: 16px; min-width: 0; align-content: start; }
.sec-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sec-foot { margin-top: 0; padding-top: 12px; border-top: 1px solid var(--hairline); }
.card > .sec-head { margin-bottom: -2px; }

/* ---------- Icon chips: a tinted rounded square that names a card, a section or a stat */
.tile, .chip-icon, .stat-chip {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 11px;
    background: var(--neutral-soft);
    color: var(--neutral-text);
}

    .tile .icon, .chip-icon .icon, .stat-chip .icon { width: 18px; height: 18px; }
.chip-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--primary-soft); color: var(--primary-text); }
    .chip-icon .icon { width: 20px; height: 20px; }
.stat-chip { width: 34px; height: 34px; }
    .stat-chip:not([class*="tone-"]) { background: var(--primary-soft); color: var(--primary-text); }
.tile-lg { width: 40px; height: 40px; border-radius: 12px; }
    .tile-lg .icon { width: 20px; height: 20px; }
.tile-accent, .tone-violet, .tile-violet { background: var(--primary-soft); color: var(--primary-text); }
.tone-violet { background: var(--primary-soft-2); }
.tile-success, .tone-success { background: var(--success-soft); color: var(--success-text); }
.tile-warning, .tone-warning { background: var(--warning-soft); color: var(--warning-text); }
.tile-danger, .tone-danger { background: var(--danger-soft); color: var(--danger-text); }
.tile-info, .tone-info { background: var(--info-soft); color: var(--info-text); }
.tile-neutral, .tone-neutral { background: var(--neutral-soft); color: var(--neutral-text); }
.tile-lime, .tone-lime { background: var(--lime-300); color: var(--ink-900); }

/* ---------- Stat tiles: label and chip, the figure, a hint */
/* 140px lets the six-tile rows (Rights requests, Incidents) sit on one line on a laptop instead of wrapping one tile alone. */
.stats, .stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
    color: inherit;
    text-decoration: none;
    transition: transform var(--m-quick), box-shadow .2s, border-color .2s;
}

    a.stat:hover, .stat[data-href]:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); color: inherit; text-decoration: none; }
.stat-head, .stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-label { font-size: calc(13px * var(--ts)); font-weight: 550; color: var(--muted); line-height: 1.3; }
.stat-value {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    font-size: 34px;
    font-weight: 650;
    letter-spacing: -.04em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

    .stat-value .badge { font-size: calc(12px * var(--ts)); letter-spacing: 0; }
    .stat-value.is-small, .stat-value:has(.badge), .stat-value:has(a) { font-size: calc(17px * var(--ts)); letter-spacing: -.015em; line-height: 1.3; min-height: 30px; }
    .stat-value a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-decoration-thickness: 1.5px; }
        .stat-value a:hover { color: var(--primary-text); text-decoration-color: currentColor; }
.stat-meta, .stat-hint { font-size: calc(12.5px * var(--ts)); line-height: 1.45; color: var(--muted); }
    .stat-meta.is-warn { color: var(--warning-text); }
    .stat-hint.is-alert, .stat-meta.is-alert { color: var(--danger-text); font-weight: 600; }
.stat.is-alert .stat-value, .stat-value.is-alert { color: var(--danger-text); }
.stat.is-alert { border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.stat-delta { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--r-pill); font-size: calc(12px * var(--ts)); font-weight: 700; background: var(--lime-300); color: var(--ink-900); }
.live-mark { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--faint); }
    .live-mark.is-on { background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); animation: live-pulse 2.4s ease-out infinite; }
@keyframes live-pulse { 0%, 100% { box-shadow: 0 0 0 3px var(--success-soft); } 50% { box-shadow: 0 0 0 6px transparent; } }
@media (max-width: 640px) { .stat-value { font-size: 28px; } .stat-row, .stats { gap: 10px; } }

/* ---------- Badges, purpose chips, state dots */
.badge {
    height: 24px;
    padding: 0 10px;
    gap: 6px;
    border: 0;
    border-radius: var(--r-pill);
    font-size: calc(12px * var(--ts));
    font-weight: 650;
    line-height: 1;
    background: var(--neutral-soft);
    color: var(--neutral-text);
    vertical-align: middle;
}

    .badge::before { opacity: .9; flex: none; }
    .badge .icon { width: 13px; height: 13px; }
    .badge:has(.icon)::before { display: none; }
.badge-green { background: var(--success-soft); color: var(--success-text); }
.badge-red { background: var(--danger-soft); color: var(--danger-text); }
.badge-amber { background: var(--warning-soft); color: var(--warning-text); }
.badge-blue { background: var(--info-soft); color: var(--info-text); }
.badge-violet { background: var(--primary-soft-2); color: var(--primary-text); }
.badge-gold { background: var(--gold-soft); color: var(--gold-text); }
.badge-grey { background: var(--neutral-soft); color: var(--neutral-text); }
.badge-lime { background: var(--lime-300); color: var(--ink-900); }
.badge-ink, .badge-dark { background: var(--ink-900); color: #fff; border: 0; }
:root[data-theme="dark"] .badge-ink, :root[data-theme="dark"] .badge-dark { background: #fff; color: var(--ink-900); }
.badge-plain { background: transparent; box-shadow: inset 0 0 0 1px currentColor; }
    .badge-plain::before { display: inline-block; }
    .badge-plain.badge-grey { color: var(--muted); box-shadow: inset 0 0 0 1px var(--border-strong); }
    .badge-plain.badge-gold { color: var(--gold-text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold-text) 45%, transparent); }
    .badge-plain.badge-red { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger-text) 40%, transparent); }
.badge-nodot::before { display: none; }
.badge-lg { height: 28px; padding: 0 12px; font-size: calc(13px * var(--ts)); }
.badge-dyn { background: color-mix(in srgb, var(--badge) 13%, transparent); color: color-mix(in srgb, var(--badge) 80%, black); }
:root[data-theme="dark"] .badge-dyn { background: color-mix(in srgb, var(--badge) 22%, transparent); color: color-mix(in srgb, var(--badge) 60%, white); }

.purpose-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pchip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--r-pill);
    font-size: calc(12px * var(--ts));
    font-weight: 600;
    white-space: nowrap;
    line-height: 1;
    background: var(--neutral-soft);
    color: var(--muted);
}

    .pchip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
    .pchip.granted { background: var(--success-soft); color: var(--success-text); }
        .pchip.granted::before { background: currentColor; }
    .pchip.denied { background: var(--neutral-soft); color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
        .pchip.denied::before { opacity: .6; }

.state-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; background: var(--faint); vertical-align: 1px; flex: none; }
    .state-dot.OVERDUE, .state-dot.Overdue, .state-dot.is-late { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
    .state-dot.DueSoon, .state-dot.is-soon { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
    .state-dot.OnTrack, .state-dot.is-ok { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
    .state-dot.Paused { background: var(--faint); box-shadow: 0 0 0 3px var(--neutral-soft); }
    .state-dot.MET, .state-dot.Met { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft-2); }
.kbd { font-family: var(--mono); font-size: calc(11.5px * var(--ts)); padding: 2px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }

/* ---------- Filter bar: a white card of 40px controls on the raised surface */
.filter-bar, .filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
}

    .filter-bar .input, .filter-bar .select, .filter-bar .combo-btn, .filter-bar .f-dates { height: 40px; background-color: var(--surface-2); border-color: var(--hairline); box-shadow: none; border-radius: var(--r-md); }
        .filter-bar .input:hover, .filter-bar .select:hover, .filter-bar .combo-btn:hover, .filter-bar .f-dates:hover { border-color: var(--border-strong); }
        .filter-bar .input:focus, .filter-bar .select:focus, .filter-bar .f-dates:focus-within { background-color: var(--surface); border-color: var(--primary); box-shadow: var(--focus-ring); }
    .filter-bar > .select, .filter-bar > .combo { flex: 0 1 190px; width: 190px; min-width: 0; }
    .filter-bar > .input[type="date"] { flex: 0 1 150px; width: 150px; }
    .filter-bar > .btn { height: 40px; }
    .filter-bar .f-dates .input { height: 36px; background: transparent; border: 0; box-shadow: none; }
.f-search { position: relative; flex: 1 1 260px; min-width: 200px; display: block; }
    .f-search > .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; width: 17px; height: 17px; }
    .f-search .input:not([type=file]) { padding-left: 40px; }
.f-chip { border-radius: var(--r-pill); }
@media (max-width: 760px) {
    .filter-bar > .select, .filter-bar > .combo, .filter-bar > .input[type="date"] { flex: 1 1 calc(50% - 10px); width: auto; min-width: 130px; }
    .filter-bar > .btn { flex: 1 1 100%; }
}

/* ---------- List panel: a card that clips its table */
.list-panel {
    padding: 0;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
}

.list-panel-head { align-items: center; gap: 10px; padding: 18px 22px 14px; }
.list-panel-title { font-size: calc(var(--fs-md) * var(--ts)); font-weight: 700; letter-spacing: -.01em; }
.list-panel-count {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 10px;
    border-radius: var(--r-pill);
    background: var(--surface-3);
    color: var(--muted);
    font-size: calc(12px * var(--ts));
    font-weight: 700;
}

.list-panel .table th, .list-panel .data-table thead th { border-radius: 0; }
.list-panel .table th:first-child, .list-panel .table td:first-child { padding-left: 22px; }
.list-panel .table th:last-child, .list-panel .table td:last-child { padding-right: 22px; }
.list-panel .table-foot { padding: 14px 22px; }
.list-panel > .filter-bar, .list-panel > form.filter-bar { margin: 0 22px 14px; }
.list-panel > .empty { padding: 48px 24px; }
.list-panel > .list-bar { padding: 0 22px 14px; }

/* ---------- Tables: small capitals for heads, hairlines between rows, a violet tint on hover */
table.table, .table, .data-table { font-size: calc(var(--fs-table) * var(--ts)); border-collapse: separate; border-spacing: 0; }
.table th, .data-table thead th {
    position: relative;
    top: auto;
    padding: 11px 16px;
    text-align: left;
    white-space: nowrap;
    font-size: calc(11.5px * var(--ts));
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-2);
    border: 0;
    border-bottom: 1px solid var(--border);
}

    .table th:first-child, .data-table thead th:first-child { border-top-left-radius: var(--r-md); border-bottom-left-radius: 0; }
    .table th:last-child, .data-table thead th:last-child { border-top-right-radius: var(--r-md); border-bottom-right-radius: 0; }
    .table th.right { text-align: right; }
.table td, .data-table td { padding: 14px 16px; vertical-align: top; border-top: 0; border-bottom: 1px solid var(--hairline); }
.table tbody tr:last-child td, .data-table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:first-child td { border-top: 0; }
.table tbody tr, .data-table tbody tr { transition: background-color .12s; }
    .table tbody tr:hover td, .data-table tbody tr:hover td { background: color-mix(in srgb, var(--primary-soft) 60%, transparent); }
    .table tbody tr:nth-child(even) td { background: transparent; }
.table tr.selected td { background: var(--primary-soft); }
.table tfoot td, .table tfoot th { background: var(--surface-2); font-weight: 650; text-transform: none; letter-spacing: 0; font-size: calc(13.5px * var(--ts)); color: var(--text); border-bottom: 0; border-top: 1px solid var(--border); }
.table .col-id { width: 72px; }
.table td.right, .table th.right { text-align: right; }
.table-compact th { padding-top: 9px; padding-bottom: 9px; }
.table-compact td { padding-top: 11px; padding-bottom: 11px; }
.cell-meta { margin-top: 3px; font-size: calc(12.5px * var(--ts)); color: var(--muted); line-height: 1.45; }
.row-link, .table .row-link, .data-table .row-link { color: var(--text); font-weight: 650; text-decoration: none; }
    .row-link:hover, .table .row-link:hover { color: var(--primary-text); text-decoration: underline; }
.ref-id, .table .row-link.ref-id { font-family: var(--mono); font-size: calc(13px * var(--ts)); letter-spacing: -.01em; font-variant-numeric: normal; }
.hash { font-family: var(--mono); font-size: calc(12px * var(--ts)); line-height: 1.5; word-break: break-all; color: var(--text-2); }
.table-wrap { border-radius: var(--r-lg); box-shadow: var(--shadow-xs); }
.table-scroll { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.table-foot { padding: 14px 20px; border-top: 1px solid var(--hairline); font-size: calc(var(--fs-sm) * var(--ts)); color: var(--muted); gap: 14px; }
.data-table .btn-sm { height: var(--h-row-btn); }
.data-table tr:hover .row-act, .data-table tr:focus-within .row-act { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.data-table td.ref { color: var(--muted); font-size: calc(13px * var(--ts)); }
.data-table tbody tr:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

/* Pager: 34px pills, the current page in ink */
.pager, .list-panel .pager { display: inline-flex; align-items: center; gap: 6px; }
    .pager .btn-sm, .list-panel .pager .btn-sm, .pager a, .pager .pg-num, .pager .pg-btn {
        min-width: 34px;
        height: 34px;
        padding: 0 12px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: 1px solid var(--border);
        border-radius: var(--r-pill);
        background: var(--surface);
        box-shadow: none;
        font-size: calc(13px * var(--ts));
        font-weight: 600;
        color: var(--text-2);
        text-decoration: none;
        font-variant-numeric: tabular-nums;
    }

        .pager .btn-sm:hover, .list-panel .pager .btn-sm:hover, .pager a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
    .pager .btn-primary, .list-panel .pager .btn-primary, .pager .pg-num.current, .pager a.current, .pager [aria-current="page"] { background: var(--ink-900); border-color: var(--ink-900); color: #fff; box-shadow: none; }
        .pager .btn-primary:hover, .list-panel .pager .btn-primary:hover { background: var(--ink-700); border-color: var(--ink-700); color: #fff; }
    :root[data-theme="dark"] .pager [aria-current="page"], :root[data-theme="dark"] .pager .btn-primary, :root[data-theme="dark"] .list-panel .pager .btn-primary { background: #fff; color: var(--ink-900); border-color: #fff; }
    .pager .disabled { opacity: .45; pointer-events: none; }
    .pager .pg-gap { border: 0; background: none; min-width: 16px; padding: 0 2px; color: var(--faint); }

/* ---------- Tabs: a segmented pill track; the active tab lifts onto a white pill, counts turn lime */
.tabs {
    gap: 4px;
    padding: 4px;
    border-radius: var(--r-pill);
    background: var(--surface-3);
    border: 1px solid var(--hairline);
}

.tab {
    height: var(--h-tab);
    padding: 0 16px;
    border-radius: var(--r-pill);
    color: var(--muted);
    font-size: calc(var(--fs-tab) * var(--ts));
    font-weight: 600;
    gap: 8px;
    transition: color var(--m-quick), background-color var(--m-quick), box-shadow var(--m-quick);
}

    .tab:hover { color: var(--text); }
    .tab[aria-selected="true"], .tab.active, .tab.is-active, .tab[aria-current="true"] { color: var(--text); }
.tabs:not(.js-tabs) .tab.active, .tabs:not(.js-tabs) .tab[aria-selected="true"] { background: var(--surface); box-shadow: var(--shadow-sm); }
.tab-ink { top: 4px; bottom: 4px; border-radius: var(--r-pill); background: var(--surface); box-shadow: var(--shadow-sm); transition: transform var(--m-base) var(--ease-in-out), width var(--m-base) var(--ease-in-out); }
.tab-count {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--r-pill);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: calc(11.5px * var(--ts));
    font-weight: 700;
    line-height: 1;
    background: var(--surface-3);
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.tab.active .tab-count, .tab[aria-selected="true"] .tab-count { background: var(--lime-400); color: var(--ink-900); }
.tabs-line { background: none; border: 0; padding: 0; border-radius: 0; }
    .tabs-line .tab-ink { background: var(--primary); box-shadow: none; }
.tabs-scroll { margin: 0 -2px; padding: 2px; }
.scroll-hint.left { background: linear-gradient(90deg, var(--bg) 45%, transparent); }
.scroll-hint.right { background: linear-gradient(270deg, var(--bg) 45%, transparent); }
.scroll-hint .icon { background: var(--surface); box-shadow: var(--shadow-sm); }
.tab-panel { animation: panel-in .25s ease-out; }

/* Small segmented toggle (Chart / Table) */
.viz-switch, .view-switch { gap: 0; padding: 3px; border-radius: var(--r-pill); background: var(--surface-3); border: 1px solid var(--hairline); }
    .viz-switch .tab, .view-switch .tab { height: 28px; padding: 0 14px; font-size: calc(12.5px * var(--ts)); font-weight: 650; }
    .viz-switch .tab[aria-pressed="true"], .view-switch .tab[aria-pressed="true"], .viz-switch .tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg-toggle { display: inline-flex; padding: 3px; border-radius: var(--r-pill); background: var(--surface-3); border: 1px solid var(--hairline); }
    .seg-toggle button { height: 28px; padding: 0 14px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--muted); font-size: calc(12.5px * var(--ts)); font-weight: 650; cursor: pointer; }
        .seg-toggle button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Dialogs and sheets */
dialog.modal {
    width: min(560px, calc(100vw - 28px));
    max-height: calc(100dvh - 40px);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

    dialog.modal.modal-wide { width: min(880px, calc(100vw - 28px)); }
    dialog.modal[open] { animation: modal-in .22s cubic-bezier(.2, .9, .3, 1.1); }
dialog::backdrop { background: rgba(12, 11, 18, .55); backdrop-filter: blur(3px); }
dialog.modal > form { display: flex; flex-direction: column; max-height: calc(100dvh - 40px); margin: 0; }
.modal-body { padding: 26px 28px 8px; gap: 16px; overflow-y: auto; }
    .modal-body .form-grid { gap: 16px 18px; }
.modal-title { font-size: calc(20px * var(--ts)); font-weight: 700; letter-spacing: -.02em; padding-right: 36px; }
.modal-desc { color: var(--muted); font-size: calc(13.5px * var(--ts)); }
.modal-foot { padding: 18px 28px 24px; gap: 10px; border-top: 0; background: transparent; border-radius: 0; }
.modal-x { top: 16px; right: 16px; width: 32px; height: 32px; border-radius: var(--r-pill); color: var(--text-2); }
    .modal-x:hover { background: var(--surface-3); color: var(--text); }
dialog.sheet { border-radius: 0; background: var(--surface); }
.sheet-head { padding: 20px 24px; font-size: calc(17px * var(--ts)); font-weight: 700; background: var(--surface); }
.sheet-body { padding: 20px 24px 28px; }
.summary, .dl-box { border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--hairline); padding: 16px 18px; }
.choice { border-radius: var(--r-md); }

/* ---------- Alerts: a soft fill with its text colour, an icon at the top */
.alert {
    padding: 14px 18px;
    gap: 12px;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    font-size: calc(13.5px * var(--ts));
    line-height: 1.5;
    background: var(--info-soft);
    color: var(--info-text);
}

    .alert > .icon { margin-top: 1px; }
    .alert a { color: inherit; font-weight: 650; text-decoration: underline; }
.alert-ok { background: var(--success-soft); color: var(--success-text); border-color: transparent; }
.alert-warn { background: var(--warning-soft); color: var(--warning-text); border-color: transparent; }
.alert-danger, .alert-err { background: var(--danger-soft); color: var(--danger-text); border-color: transparent; }
.alert-info { background: var(--info-soft); color: var(--info-text); border-color: transparent; }

/* ---------- Description lists, code, timeline, disclosure, empty states */
.dl { grid-template-columns: minmax(110px, 160px) minmax(0, 1fr); gap: 0; font-size: calc(13.5px * var(--ts)); }
    .dl dt, .dl dd { padding: 10px 0; border-bottom: 1px solid var(--hairline); margin: 0; }
    .dl dt { color: var(--muted); font-weight: 550; padding-right: 14px; }
    .dl dd { overflow-wrap: anywhere; }
    .dl dt:last-of-type, .dl dd:last-of-type { border-bottom: 0; }
.dl-tight { grid-template-columns: 78px minmax(0, 1fr); font-size: calc(13px * var(--ts)); }
    .dl-tight dt, .dl-tight dd { padding: 6px 0; border: 0; }
.summary dt { color: var(--muted); }

code:not(pre code), .chip-code { font-family: var(--mono); font-size: .9em; font-weight: 400; padding: 1px 6px; border-radius: 6px; background: var(--surface-3); color: var(--text); overflow-wrap: anywhere; }
.code-block, pre.code-block {
    margin: 0;
    padding: 12px 14px;
    border-radius: var(--r-md);
    background: var(--surface-3);
    border: 1px solid var(--hairline);
    font: calc(12.5px * var(--ts))/1.55 var(--mono);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--text-2);
}

/* Ink code block: a lime-dot caption, a glass copy pill, mono text */
.codeblk, .dom-code { --code-bg: var(--ink-900); --code-line: var(--ink-700); min-width: 0; overflow: hidden; border-radius: var(--r-md); border: 1px solid var(--code-line); background: var(--code-bg); color: var(--hero-text); }
:root[data-theme="dark"] .codeblk, :root[data-theme="dark"] .dom-code { --code-bg: var(--ink-950); --code-line: var(--border); }
.codeblk-head, .dom-code-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 8px 8px 16px;
    border-bottom: 1px solid var(--hero-line);
    font-size: calc(12.5px * var(--ts));
    font-weight: 600;
    color: var(--hero-muted);
}

    .codeblk-head > span, .dom-code-head > span { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
        .codeblk-head > span::before, .dom-code-head > span::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--signal); }
    .codeblk-head .btn, .dom-code-head .btn { flex: none; height: 30px; padding: 0 12px; font-size: calc(12.5px * var(--ts)); background: var(--hero-glass); border-color: var(--hero-line); color: var(--hero-text); box-shadow: none; }
        .codeblk-head .btn:hover, .dom-code-head .btn:hover { background: color-mix(in srgb, var(--hero-text) 16%, transparent); border-color: var(--hero-line); color: var(--hero-text); }
.codeblk-body, .dom-code-body { margin: 0; padding: 14px 16px 16px; font: calc(12.5px * var(--ts))/1.7 var(--mono); tab-size: 2; color: var(--hero-text); white-space: pre-wrap; overflow-wrap: anywhere; background: transparent; }

.timeline-list { list-style: none; margin: 0; padding: 0 0 0 4px; display: grid; gap: 0; }
    .timeline-list li { position: relative; display: flex; grid-template-columns: none; gap: 0; padding: 0 0 20px 26px; }
        .timeline-list li:last-child { padding-bottom: 0; }
        .timeline-list li::before { content: ""; position: absolute; left: 4px; top: 18px; bottom: -2px; width: 2px; height: auto; margin: 0; border-radius: 0; background: var(--hairline); }
        .timeline-list li:last-child::before { display: none; }
        .timeline-list li::after { content: ""; display: block; position: absolute; left: 0; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--primary); }
        .timeline-list li.internal::after { border-color: var(--faint); }
        .timeline-list li.requester::after { border-color: var(--primary); background: var(--primary); }
        .timeline-list li > div { flex: 1; min-width: 0; }
.tl-meta { font-size: calc(var(--fs-xs) * var(--ts)); color: var(--muted); font-weight: 550; }
.tl-body { margin-top: 3px; font-size: calc(13.5px * var(--ts)); line-height: 1.55; }

details.disclosure > summary { font-weight: 600; }
details > summary::marker { color: var(--faint); }

.empty { padding: 48px 24px; text-align: center; }
.empty-title { font-weight: 700; font-size: calc(var(--fs-md) * var(--ts)); color: var(--text); }
.empty-text { color: var(--muted); margin: 6px auto 16px; max-width: 48ch; font-size: calc(13.5px * var(--ts)); }

.readiness-dot, .proof-dot { width: 24px; height: 24px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; }
    .readiness-dot .icon { width: 14px; height: 14px; stroke-width: 2.6; }
    .readiness-dot.ok { background: var(--success-soft); color: var(--success-text); }
    .readiness-dot.todo { background: var(--warning-soft); color: var(--warning-text); }
.proof-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
    .proof-list li { display: flex; gap: 12px; align-items: flex-start; }
    .proof-list strong { font-weight: 650; }

/* ---------- Patterns: 12-column grid, case layout, clocks, action stack, charts, ink card */
.grid-12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; align-items: start; }
    .grid-12 > * { min-width: 0; }
    .grid-12 > .span-12 { grid-column: span 12; }
    .grid-12 > .span-8 { grid-column: span 8; }
    .grid-12 > .span-7 { grid-column: span 7; }
    .grid-12 > .span-6 { grid-column: span 6; }
    .grid-12 > .span-5 { grid-column: span 5; }
    .grid-12 > .span-4 { grid-column: span 4; }
    .grid-12 > .span-3 { grid-column: span 3; }
@container page (max-width: 939.98px) { .grid-12 > [class*="span-"] { grid-column: span 12; } }
@media (max-width: 760px) { .grid-12 > [class*="span-"] { grid-column: span 12; } }

.case-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
    .case-grid > .stack { min-width: 0; gap: 16px; }
.case-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 84px; min-width: 0; }
@container page (max-width: 879.98px) { .case-grid { grid-template-columns: 1fr; } .case-side { position: static; } }
@media (max-width: 760px) { .case-grid { grid-template-columns: 1fr; } .case-side { position: static; } }

.clock {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: var(--r-md);
    background: var(--surface-3);
    border: 1px solid var(--hairline);
}

.clock-big { font-size: 22px; font-weight: 700; letter-spacing: -.025em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.clock.OVERDUE, .clock.Overdue, .clock.is-late { background: var(--danger-soft); border-color: transparent; color: var(--danger-text); }
.clock.DueSoon, .clock.is-soon { background: var(--warning-soft); border-color: transparent; color: var(--warning-text); }
.clock.OnTrack, .clock.is-ok { background: var(--info-soft); border-color: transparent; color: var(--info-text); }
.clock.MET, .clock.Met, .clock.is-met { background: var(--success-soft); border-color: transparent; color: var(--success-text); }
.clock.Paused { background: var(--neutral-soft); }
.clock .muted { color: inherit; opacity: .8; }

.action-stack { display: grid; gap: 8px; }
    .action-stack > details { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); overflow: hidden; }
        .action-stack > details > summary { display: flex; align-items: center; gap: 10px; padding: 11px 14px; font-weight: 600; font-size: calc(13.5px * var(--ts)); list-style: none; cursor: pointer; }
            .action-stack > details > summary::-webkit-details-marker { display: none; }
            .action-stack > details > summary .icon { color: var(--primary-text); }
        .action-stack > details[open] > summary { border-bottom: 1px solid var(--border); background: var(--surface); }
        .action-stack > details > form, .action-stack > details > div { display: grid; gap: 10px; padding: 14px; }

.viz-card { display: flex; flex-direction: column; gap: 14px; }
.viz-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: nowrap; }
    .viz-head > div:first-child { min-width: 0; flex: 1 1 auto; }
.viz-sub { margin-top: 4px; font-size: calc(13px * var(--ts)); color: var(--muted); max-width: 60ch; }
.viz-series { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: calc(13px * var(--ts)); color: var(--text-2); }
    .viz-series li { display: inline-flex; align-items: center; gap: 8px; }
    .viz-series b { font-size: calc(18px * var(--ts)); font-weight: 700; letter-spacing: -.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.viz-line { stroke: var(--viz-1); stroke-width: 3; stroke-linecap: round; }
    .viz-line.is-second { stroke: var(--viz-2); stroke-dasharray: 5 4; }
    .viz-line.is-third { stroke: var(--viz-3); stroke-dasharray: 1 5; stroke-width: 3.5; }
.viz-figure { position: relative; min-height: 220px; }
.viz-svg { width: 100%; height: auto; overflow: visible; display: block; touch-action: pan-y; }
    .viz-svg .grid-line { stroke: var(--viz-grid); stroke-width: 1; }
        .viz-svg .grid-line.base { stroke: var(--border-strong); }
    .viz-svg text { fill: var(--viz-axis); font-size: calc(12px * var(--ts)); font-family: var(--font); font-variant-numeric: tabular-nums; }
    .viz-svg .s1 { fill: none; stroke: var(--viz-1); stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
    .viz-svg .s2 { fill: none; stroke: var(--viz-2); stroke-width: 2; stroke-dasharray: 6 5; stroke-linejoin: round; stroke-linecap: round; }
    .viz-svg .s3 { fill: none; stroke: var(--viz-3); stroke-width: 2.8; stroke-dasharray: 1 5.5; stroke-linecap: round; stroke-linejoin: round; }
    .viz-svg .area { fill: url(#viz-area-grad); }
    .viz-svg .cursor { stroke: var(--text); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
    .viz-svg .dot { opacity: 0; stroke: var(--surface); stroke-width: 2.5; }
        .viz-svg .dot.d1 { fill: var(--viz-1); }
        .viz-svg .dot.d2 { fill: var(--viz-2); }
        .viz-svg .dot.d3 { fill: var(--viz-3); }
    .viz-svg.is-hover .cursor, .viz-svg.is-hover .dot { opacity: 1; }
.viz-tip {
    position: absolute;
    z-index: 5;
    pointer-events: none;
    min-width: 170px;
    padding: 10px 12px;
    border-radius: var(--r-md);
    background: var(--ink-900);
    color: #fff;
    font-size: calc(12.5px * var(--ts));
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity .12s, transform .12s;
}

    .viz-tip.on { opacity: 1; transform: none; }
    .viz-tip b { display: block; margin-bottom: 6px; font-size: calc(12.5px * var(--ts)); }
    .viz-tip div { display: flex; align-items: center; justify-content: space-between; gap: 14px; line-height: 1.7; }
    .viz-tip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 7px; }
:root[data-theme="dark"] .viz-tip { background: #2A2740; border: 1px solid var(--border-strong); }
.viz-table { max-height: 340px; overflow: auto; border: 1px solid var(--hairline); border-radius: var(--r-md); }
    .viz-table .table th { position: sticky; top: 0; z-index: 1; }

.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 20px; }
    .hbars.viz-figure { min-height: 0; align-content: start; }
.hbar { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: baseline; }
.hbar-label { font-size: calc(13.5px * var(--ts)); font-weight: 600; }
.hbar-value { font-size: calc(14px * var(--ts)); font-weight: 700; font-variant-numeric: tabular-nums; }
.hbar-track { grid-column: 1 / -1; height: 10px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.hbar-fill { display: block; height: 100%; width: var(--w, 0); border-radius: var(--r-pill); background: var(--c, var(--viz-1)); animation: bar-grow .9s var(--ease-out) both; transform-origin: left; }
@keyframes bar-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.hbars-compact { gap: 16px; }

.ink-card {
    position: relative;
    overflow: hidden;
    padding: 24px 26px;
    border-radius: var(--r-xl);
    background: var(--hero-bg);
    color: var(--hero-text);
    box-shadow: var(--shadow-md);
}

    .ink-card::before {
        content: "";
        position: absolute;
        right: -160px;
        top: -180px;
        width: 460px;
        height: 460px;
        background: radial-gradient(closest-side, rgba(var(--accent-rgb), .4), rgba(var(--accent-rgb), .16) 45%, rgba(var(--accent-rgb), 0) 100%);
        filter: blur(40px);
        pointer-events: none;
    }

    .ink-card > * { position: relative; }
    .ink-card .muted, .ink-card .xsmall.muted { color: var(--hero-muted); }

/* ---------- Option rows with a switch, selectable chips (domain settings, banner editor) */
.opt-list { display: grid; gap: 10px; }
.opt, .dom-opt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 16px;
    min-width: 0;
    border: 1px solid var(--hairline);
    border-radius: var(--r-md);
    background: var(--surface-2);
    cursor: pointer;
    transition: border-color var(--m-quick), background-color var(--m-quick);
}

    .opt:hover, .dom-opt:hover { border-color: var(--border-strong); }
    .opt:has(input:checked), .dom-opt:has(input:checked) { background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface)); border-color: color-mix(in srgb, var(--primary) 22%, var(--border)); }
    .opt:has(input:focus-visible), .dom-opt:has(:focus-visible) { box-shadow: var(--focus-ring); }
.opt-text, .dom-opt-text { display: block; min-width: 0; font-size: calc(13.5px * var(--ts)); font-weight: 550; line-height: 1.5; color: var(--text); }
.opt-title, .dom-opt-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; font-size: calc(14px * var(--ts)); font-weight: 650; line-height: 1.4; }
.opt-desc, .dom-opt-desc { display: block; margin-top: 3px; max-width: 68ch; font-size: calc(12.5px * var(--ts)); font-weight: 450; line-height: 1.5; color: var(--muted); }
.opt-compact { min-height: 42px; padding: 9px 14px; }
    .opt-compact .opt-text { font-size: calc(13px * var(--ts)); font-weight: 450; color: var(--text-2); }
.opt code, .dom-opt-desc code { white-space: nowrap; }
.opt .switch, .dom-opt .switch, .dom-opt input[type=checkbox] { align-self: center; flex: none; }
.dom-opt-master { padding: 16px 18px; border-color: var(--border); background: var(--surface-2); }
    .dom-opt-master:has(input[type="checkbox"]:checked) { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); background: var(--primary-soft); }
.dom-dependent { display: grid; gap: 20px; min-width: 0; transition: opacity var(--m-quick); }
.dom-fieldset:has(> .dom-opt-master [data-dom-master]:not(:checked)) > .dom-dependent { opacity: .55; }
.dom-opts { display: grid; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
    .dom-opts .dom-opt { padding: 15px 18px; border: 0; border-radius: 0; background: transparent; }
        .dom-opts .dom-opt + .dom-opt { border-top: 1px solid var(--hairline); }

.lang-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 8px; }
.lang-chip, .dom-check {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 10px;
    min-width: 0;
    padding: 10px 14px 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface);
    cursor: pointer;
    font-size: calc(13.5px * var(--ts));
    font-weight: 600;
    line-height: 1.3;
    transition: border-color var(--m-quick), background-color var(--m-quick), box-shadow var(--m-quick);
}

    .lang-chip:hover, .dom-check:hover { border-color: var(--border-strong); background: var(--surface-2); }
    .lang-chip:has(input:checked), .dom-check:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary); }
    .lang-chip:has(input:focus-visible), .dom-check:has(:focus-visible) { box-shadow: var(--focus-ring); }
.lang-name { min-width: 0; overflow-wrap: anywhere; }
.lang-native { justify-self: end; font-size: calc(13px * var(--ts)); font-weight: 500; color: var(--muted); white-space: nowrap; }
.lang-chip:has(input:checked) .lang-native { color: var(--primary-text); }
.dom-check { display: flex; align-items: flex-start; gap: 12px; padding: 13px 14px; }
    .dom-check .cb { margin-top: 1px; }
.dom-check-text { display: grid; gap: 2px; min-width: 0; }
.dom-check-name { font-size: calc(13.5px * var(--ts)); font-weight: 600; line-height: 1.4; }
.dom-check-hint { font-size: calc(12.5px * var(--ts)); line-height: 1.4; color: var(--muted); font-weight: 450; }

/* A linked thing (a banner, a verified site) and an info callout */
.dom-item { display: flex; align-items: center; gap: 14px; min-width: 0; padding: 14px 16px; border: 1px solid var(--hairline); border-radius: var(--r-md); background: var(--surface-2); }
.dom-item-icon { flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--primary-soft-2); color: var(--primary-text); }
    .dom-item-icon .icon { width: 20px; height: 20px; }
    .dom-item-icon.is-ok { background: var(--success-soft); color: var(--success-text); }
.dom-item-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.dom-item-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: calc(14.5px * var(--ts)); font-weight: 650; line-height: 1.4; }
.dom-item-meta { font-size: calc(13px * var(--ts)); line-height: 1.45; color: var(--muted); }
.dom-item-actions { flex: none; display: flex; gap: 8px; }
.dom-callout { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 12px; padding: 14px 16px; border: 1px solid color-mix(in srgb, var(--info) 18%, transparent); border-radius: var(--r-md); background: var(--info-soft); color: var(--info-text); }
    .dom-callout > .icon { grid-row: 1 / span 2; margin-top: 2px; }
    .dom-callout > p { font-size: calc(13.5px * var(--ts)); line-height: 1.6; margin: 0; }
    .dom-callout > form { grid-column: 2; justify-self: start; margin: 0; }
.dom-note { max-width: 78ch; font-size: calc(13.5px * var(--ts)); line-height: 1.6; color: var(--muted); }
    .dom-note strong { color: var(--text); font-weight: 650; }
.dom-state { font-size: calc(12px * var(--ts)); letter-spacing: 0; }
.dom-disclosure { min-width: 0; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
    .dom-disclosure > summary { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-radius: var(--r-md); font-size: calc(14px * var(--ts)); font-weight: 650; list-style: none; user-select: none; cursor: pointer; transition: background-color var(--m-quick); }
        .dom-disclosure > summary::-webkit-details-marker { display: none; }
        .dom-disclosure > summary:hover { background: var(--surface-2); }
        .dom-disclosure > summary > .icon { width: 24px; height: 24px; padding: 5px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); transition: transform .18s, background-color var(--m-quick); }
    .dom-disclosure[open] > summary { border-bottom: 1px solid var(--hairline); border-radius: var(--r-md) var(--r-md) 0 0; }
        .dom-disclosure[open] > summary > .icon { transform: rotate(90deg); background: var(--primary-soft-2); color: var(--primary-text); }
.dom-disclosure-body { display: grid; gap: 16px; min-width: 0; padding: 18px; }
.dom-form-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--hairline); }
    .dom-form-foot .dom-note { flex: 1 1 280px; }
    .dom-form-foot .btn { margin-left: auto; }
.dom-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; align-items: start; }

/* ---------- Progress stepper (rights detail): numbered dots joined by lines; done violet, current lime */
.status-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); counter-reset: step; }
    .status-steps > li, .status-steps > span { counter-increment: step; position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; padding: 0 2px; text-align: center; font-size: calc(12.5px * var(--ts)); font-weight: 600; line-height: 1.3; color: var(--muted); text-wrap: balance; }
        .status-steps > li + li::before, .status-steps > span + span::before { content: ""; position: absolute; top: 14px; height: 2px; left: calc(-50% + 22px); right: calc(50% + 22px); border-radius: 2px; background: var(--border-strong); }
        .status-steps > .done::before, .status-steps > .current::before { background: var(--primary); }
        .status-steps > span::after { content: counter(step); position: relative; z-index: 1; order: -1; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-3); border: 1.5px solid var(--border-strong); color: var(--muted); font-size: calc(12.5px * var(--ts)); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
        .status-steps > span.done::after { content: "✓"; background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
        .status-steps > span.current::after { background: var(--signal); border-color: var(--signal); color: var(--on-signal); box-shadow: 0 0 0 5px color-mix(in srgb, var(--signal) 30%, transparent); }
        .status-steps > .done { color: var(--text-2); }
        .status-steps > .current { color: var(--text); font-weight: 700; }
.step-dot { position: relative; z-index: 1; width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface-3); border: 1.5px solid var(--border-strong); color: var(--muted); font-size: calc(12.5px * var(--ts)); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
    .step-dot::before { content: counter(step); }
    .step-dot .icon { display: none; width: 15px; height: 15px; stroke-width: 3; }
.step-label { font-size: calc(12.5px * var(--ts)); font-weight: 600; line-height: 1.3; color: var(--muted); text-wrap: balance; }
.status-steps li.done .step-dot { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
    .status-steps li.done .step-dot::before { content: none; }
    .status-steps li.done .step-dot .icon { display: block; }
.status-steps li.done .step-label { color: var(--text-2); }
.status-steps li.current .step-dot { background: var(--signal); border-color: var(--signal); color: var(--on-signal); box-shadow: 0 0 0 5px color-mix(in srgb, var(--signal) 30%, transparent); }
.status-steps li.current .step-label { color: var(--text); font-weight: 700; }
@media (max-width: 760px) {
    .status-steps { display: flex; flex-wrap: wrap; gap: 6px; }
        .status-steps > li, .status-steps > span { flex-direction: row; gap: 8px; padding: 4px 12px 4px 4px; border-radius: var(--r-pill); background: var(--surface-3); text-align: left; }
            .status-steps > li + li::before, .status-steps > span + span::before { display: none; }
        .status-steps > span::after, .step-dot { width: 22px; height: 22px; font-size: calc(11px * var(--ts)); background: var(--surface); }
        .step-dot .icon { width: 12px; height: 12px; }
        .status-steps > .done { background: var(--primary-soft); color: var(--primary-text); }
        .status-steps > .current { background: var(--signal); color: var(--on-signal); }
            .status-steps > span.current::after, .status-steps li.current .step-dot { background: var(--ink-900); border-color: var(--ink-900); color: #fff; box-shadow: none; }
}

/* ---------- Floating surfaces grow from where they were called */
.live-panel, .combo-pop, [data-tour-menu], .org-switch-menu { transform-origin: top right; animation: pop-in var(--m-base) var(--ease-out); }
@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: none; } }
.combo-pop { transform-origin: top left; }
@media (prefers-reduced-motion: reduce) { .live-panel, .combo-pop, [data-tour-menu], .org-switch-menu { animation: none; } }

/* Auth screens and portal on the new tokens */
.auth2-card { border-radius: var(--r-xl); }
.portal-mark { border-radius: 12px; background: var(--primary); color: var(--on-primary); }
.pt-summary { border-radius: var(--r-lg); box-shadow: var(--shadow-xs); }
.pt-next { background: var(--primary-soft); border-radius: var(--r-md); }

/* ---------- Work grid: below the head every screen is twelve columns; a block earns its span from what it holds */
.work { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; align-items: start; }
    .work > * { grid-column: span 12; min-width: 0; }
.work > .sec, .work > .card, .grid-2 > .card, .work > .list-panel, .work > .stat-row, .dash > .sec, .sec, .list-panel { container-type: inline-size; }

@media (min-width: 1440px) {
    .work > .l-4 { grid-column: span 4; } .work > .l-5 { grid-column: span 5; } .work > .l-6 { grid-column: span 6; }
    .work > .l-7 { grid-column: span 7; } .work > .l-8 { grid-column: span 8; } .work > .l-12 { grid-column: span 12; }
}

@media (min-width: 1680px) {
    .work > .w-3 { grid-column: span 3; } .work > .w-4 { grid-column: span 4; } .work > .w-5 { grid-column: span 5; }
    .work > .w-6 { grid-column: span 6; } .work > .w-7 { grid-column: span 7; } .work > .w-8 { grid-column: span 8; }
    .work > .w-9 { grid-column: span 9; } .work > .w-12 { grid-column: span 12; }
}

/* Text beside its subject (a form, a code block, a QR, a table) once the card is wide enough */
.sec-split { display: grid; gap: 20px; align-items: start; min-width: 0; }
    .sec-split > .sec-text { display: grid; gap: 12px; max-width: 60ch; min-width: 0; }
@container (min-width: 720px) { .sec-split { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 20px 32px; } }

/* A QR code with its text and address beside it; inside a card it sits on the card surface */
.qr-split { display: grid; gap: 16px; align-items: start; min-width: 0; }
    .qr-split > .stack { min-width: 0; }
@container (min-width: 480px) { .qr-split { grid-template-columns: 196px minmax(0, 1fr); gap: 16px 24px; } }
.sec .qr-box, .card .qr-box { border: 0; padding: 0; border-radius: 0; }

/* Label / value lists run two pairs per row in a wide card */
@container (min-width: 640px) { .dl { grid-template-columns: 130px minmax(0, 1fr) 130px minmax(0, 1fr); } .dl dd.wide { grid-column: 2 / -1; } }

/* Compact table columns take their content width; one text column absorbs the rest */
th.col-fit, td.col-fit { width: 1%; white-space: nowrap; }

/* A code chip that can be copied: the address and a copy pill */
.copy-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
    .copy-row code { flex: 1 1 240px; min-width: 0; padding: 8px 12px; border-radius: 10px; font-size: calc(13.5px * var(--ts)); overflow-wrap: anywhere; }

/* ---------- Devices shared by the dashboard and the modules (DESIGN.md Components) */
/* Initials chip: who holds a thing */
.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-foreground);
    font-size: calc(11px * var(--ts));
    font-weight: 700;
    letter-spacing: .02em;
    vertical-align: middle;
}

    .chip-sm { width: 22px; height: 22px; font-size: calc(10px * var(--ts)); }
    .chip-none { background: transparent; border: 1.5px dashed var(--input); }
    .chip-system { background: var(--surface-3); color: var(--muted-foreground); }
        .chip-system .icon { width: 13px; height: 13px; }
    .chip-live { background: var(--lime); color: var(--lime-foreground); }
        .chip-live .icon { width: 13px; height: 13px; }

/* Pips: a reference as a mark in its module colour */
.pip { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--code-governance); }
.pip-rights { background: var(--code-rights); }
.pip-incident { background: var(--code-incident); }
.pip-regulator { background: var(--code-regulator); border-radius: 2px; }

/* Window bar: a runway that drains */
.window { position: relative; display: block; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
    .window-fill { position: absolute; inset: 0; border-radius: 999px; background: var(--accent); transform: scaleX(var(--left, 1)); transform-origin: left; }
    .window.is-draining .window-fill { transition: transform var(--m-stage) var(--ease-out); }
    .window.is-soon .window-fill { background: var(--warning); }
    .window.is-over .window-fill { transform: scaleX(0); }
    .window-sm { height: 4px; }

/* Segmented distribution bar and its legend */
.seg-block { display: grid; gap: 10px; min-width: 0; }
.seg { display: block; height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
    .seg-thin { height: 6px; }
    .seg-track { display: flex; height: 100%; gap: 2px; background: var(--card); }
    .seg-part { display: block; flex: 1; min-width: 6px; height: 100%; border-radius: 2px; transition: opacity var(--m-quick); text-decoration: none; }
    .seg-part:first-child { border-radius: 999px 2px 2px 999px; }
    .seg-part:last-child { border-radius: 2px 999px 999px 2px; }
    .seg-part:only-child { border-radius: 999px; }
    .seg-block:has(.is-hot) .seg-part:not(.is-hot) { opacity: .45; }
.seg-key { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
    .seg-key li { border-radius: 8px; transition: background var(--m-quick); }
    .seg-key li.is-hot { background: var(--surface-3); }
    .seg-key li.is-zero { opacity: .6; }
    .seg-key a, .seg-key .seg-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; min-height: 28px; padding: 0 6px; color: var(--foreground); text-decoration: none; font-size: calc(14px * var(--ts)); }
    .seg-key a:hover { color: var(--foreground); }
    .seg-key .swatch { width: 10px; height: 10px; border-radius: 3px; }
    .seg-key .seg-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .seg-key .seg-label small { font-size: calc(12.5px * var(--ts)); color: var(--muted-foreground); margin-left: 6px; }
    .seg-key b { font-weight: 700; }
    .seg-key small { font-size: calc(13px * var(--ts)); color: var(--muted-foreground); min-width: 36px; text-align: right; }
@container (min-width: 520px) { .seg-key { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; } }

/* Figure row: three figures with their words */
.figrow { display: flex; flex-wrap: wrap; gap: 8px 28px; }
.figcell { display: grid; gap: 2px; color: var(--foreground); text-decoration: none; border-radius: 10px; padding: 2px 6px; margin: -2px -6px; transition: background var(--m-quick); }
    .figcell:hover { background: var(--surface-2); color: var(--foreground); }
    .figcell b { font-size: 26px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; }
    .figcell span { font-size: calc(13.5px * var(--ts)); color: var(--muted-foreground); }
    .figcell.is-late b { color: var(--destructive); }
    .figcell.is-soon b { color: var(--warning); }

/* Stage strip: where open work sits */
.stage-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--border); padding-top: 12px; }
.stage { display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; color: var(--foreground); text-decoration: none; transition: background var(--m-quick); }
    .stage + .stage { border-left: 1px solid var(--border); border-radius: 0 10px 10px 0; }
    .stage:hover, .stage:focus-visible { background: var(--surface-3); color: var(--foreground); }
    .stage b { font-size: calc(20px * var(--ts)); font-weight: 700; line-height: 1.1; }
    .stage span { font-size: calc(13px * var(--ts)); color: var(--muted-foreground); line-height: 1.3; }
    .stage.is-zero b { color: var(--subtle); }
    .stage.is-accent b { color: var(--accent-foreground); }

@media (prefers-reduced-motion: reduce) {
    .window.is-draining .window-fill, .seg-part, .seg-key li, .figcell, .stage { transition: none; }
}

/* A list panel that holds its own filter bar keeps no containment, so the phone filter sheet (position: fixed) can leave it. */
.list-panel:has(.filter-bar) { container-type: normal; }

/* Verification methods (domain ownership) and tab items keep their size */
.verify-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.verify-method { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 16px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
    .verify-method h3 { margin: 0; font-size: calc(14.5px * var(--ts)); font-weight: 700; }
    .verify-method form { margin-top: auto; }
.tabs > * { flex: none; }

/* ---------- Icon chips and badge without a dot (prototype ds-components) */
.chip-icon { width: 40px; height: 40px; border-radius: 12px; flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary-text); }
    .chip-icon .icon { width: 20px; height: 20px; }
.tone-danger { background: var(--danger-soft); color: var(--danger-text); }
.tone-warning { background: var(--warning-soft); color: var(--warning-text); }
.tone-success { background: var(--success-soft); color: var(--success-text); }
.tone-info { background: var(--info-soft); color: var(--info-text); }
.tone-neutral { background: var(--neutral-soft); color: var(--neutral-text); }
.tone-violet { background: var(--primary-soft-2); color: var(--primary-text); }
.tone-lime { background: var(--lime-300); color: var(--ink-900); }
.badge-nodot::before { display: none; }

/* In a filter bar "All types" or "Any deadline" is a real choice, not a placeholder (prototype filter selects). */
.filter-bar .combo-btn.placeholder { color: var(--text); }
.opt > input[type=checkbox] { align-self: center; flex: none; }

/* DPDP Connect logo (the product website's): the image lockup, navy words on light, white words with the colour mark on dark.
   The tagline sits under the words, lined up with the D (the mark is 44 of the lockup's 180 pixels, plus its gap). */
.brand-dc { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.brand-lockups { display: block; line-height: 0; }
.brand-lockup { display: block; height: 32px; width: auto; max-width: 100%; }
.brand-lockup-dark { display: none; }
:root[data-theme="dark"] .brand-lockup-light { display: none; }
:root[data-theme="dark"] .brand-lockup-dark { display: block; }
.brand-dc .brand-sub { margin-top: -7px; padding-left: 44px; font-size: calc(var(--fs-xs) * var(--ts)); font-weight: 500; color: var(--muted); white-space: nowrap; }
.auth2-logo.brand-dc .brand-lockup { height: 30px; }
.auth2-logo.brand-dc .brand-sub { padding-left: 41px; }

/* ---------- Display settings (the gear in the top bar): text size, accent colour, light or dark.
   Every text size up to 20px is multiplied by --ts. The default is a little larger than the original type, and the
   largest choice is capped so card and table content still fits; headings and big figures stay fixed. */
:root { --ts-base: 1.07; --ts-user: 1; --ts: calc(var(--ts-base) * var(--ts-user)); --accent-rgb: 74, 42, 200; }
:root[data-text="sm"] { --ts-user: .935; }
:root[data-text="lg"] { --ts-user: 1.07; }
:root[data-text="xl"] { --ts-user: 1.14; }
:root[data-theme="dark"] { --accent-rgb: 125, 91, 255; }

/* Teal accent (#12AC94). White text on it is too faint (2.9:1), so fills carry dark text (5.8:1) and teal text uses #0D7868, which reads on white (5.4:1). */
:root[data-accent="teal"] {
    --violet-50: #ECF8F6;
    --violet-100: #D4F0EC;
    --violet-200: #A5DFD6;
    --violet-300: #76CFC1;
    --violet-400: #46BEAC;
    --violet-500: #2AB49F;
    --violet-600: #12AC94;
    --violet-700: #0D7868;
    --violet-800: #0A5F51;
    --violet-900: #074138;
    --primary: #12AC94;
    --primary-hover: #119E88;
    --primary-press: #0F907C;
    --primary-soft: #ECF8F6;
    --primary-soft-2: #D4F0EC;
    --primary-text: #0D7868;
    --on-primary: #FFFFFF;
    --accent-rgb: 18, 172, 148;
}
:root[data-accent="teal"][data-theme="dark"] {
    --primary: #12AC94;
    --primary-hover: #36B8A4;
    --primary-press: #119E88;
    --primary-soft: rgba(18, 172, 148, .15);
    --primary-soft-2: rgba(18, 172, 148, .28);
    --primary-text: #71CDBF;
    --on-primary: #FFFFFF;
    --accent-rgb: 18, 172, 148;
    --focus-ring: 0 0 0 3px rgba(18, 172, 148, .45);
    --viz-1: #36B8A4;
}
:root[data-accent="teal"] .btn-accent:hover, :root[data-accent="teal"] .btn-primary:hover { color: var(--on-primary); }

/* Emerald accent (#127A61): the deep green-teal of the light dashboard. White text on it reads at 5.3:1 and emerald text
   (#0D6652) at 6.6:1 on white. In dark the fill lightens to #2FA383, so it carries dark text there, as teal does. */
:root[data-accent="emerald"] {
    --violet-50: #EBF7F2;
    --violet-100: #D3EEE4;
    --violet-200: #A7DCC9;
    --violet-300: #77C5AB;
    --violet-400: #46A98B;
    --violet-500: #258F72;
    --violet-600: #127A61;
    --violet-700: #0D6652;
    --violet-800: #0A5244;
    --violet-900: #073B31;
    --primary: #127A61;
    --primary-hover: #0F6C56;
    --primary-press: #0D6652;
    --primary-soft: #EBF7F2;
    --primary-soft-2: #D3EEE4;
    --primary-text: #0D6652;
    --on-primary: #FFFFFF;
    --accent-rgb: 18, 122, 97;
}
:root[data-accent="emerald"][data-theme="dark"] {
    --primary: #2FA383;
    --primary-hover: #46B394;
    --primary-press: #258F72;
    --primary-soft: rgba(47, 163, 131, .15);
    --primary-soft-2: rgba(47, 163, 131, .28);
    --primary-text: #7CCFB4;
    --on-primary: #04241C;
    --accent-rgb: 47, 163, 131;
    --focus-ring: 0 0 0 3px rgba(47, 163, 131, .45);
    --viz-1: #46B394;
}
:root[data-accent="emerald"] .btn-accent:hover, :root[data-accent="emerald"] .btn-primary:hover { color: var(--on-primary); }

/* The panel */
.ui-panel { width: min(320px, calc(100vw - 32px)); padding: 6px 6px 8px; }
.ui-panel .live-panel-head { display: flex; align-items: center; gap: 8px; }
.ui-group { display: grid; gap: 8px; padding: 10px 10px 12px; border: 0; margin: 0; min-width: 0; }
    .ui-group + .ui-group { border-top: 1px solid var(--border); }
.ui-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0; font-size: calc(12px * var(--ts)); font-weight: 650; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }
    .ui-label output { font-size: calc(12.5px * var(--ts)); font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--text-2); }
.ui-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; padding: 3px; border-radius: var(--r-md); background: var(--surface-3); }
.ui-opt { position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 0 8px; border-radius: calc(var(--r-md) - 3px); font-size: calc(13px * var(--ts)); font-weight: 600; color: var(--muted); cursor: pointer; user-select: none; transition: background-color var(--m-quick), color var(--m-quick), box-shadow var(--m-quick); }
    .ui-opt input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
    .ui-opt .icon { width: 15px; height: 15px; }
    .ui-opt:hover { color: var(--text); }
    .ui-opt:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
    .ui-opt:has(input:focus-visible) { box-shadow: var(--focus-ring); }
/* Text size: four "A"s, each a step bigger. Fixed sizes, so the control itself doesn't grow. */
.ui-seg-text .ui-opt { font-weight: 700; color: var(--text-2); }
    .ui-seg-text .ui-opt[data-step="sm"] { font-size: 12px; }
    .ui-seg-text .ui-opt[data-step="md"] { font-size: 14px; }
    .ui-seg-text .ui-opt[data-step="lg"] { font-size: 16px; }
    .ui-seg-text .ui-opt[data-step="xl"] { font-size: 18px; }
/* Accent colours: round swatches only, named by their tooltip and label for screen readers. The chosen one gets a ring and a tick. */
.ui-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
    .ui-swatches .ui-opt { position: relative; flex: none; width: 36px; min-height: 36px; height: 36px; padding: 0; border-radius: 50%; background: none; box-shadow: none; }
    .ui-swatches .ui-opt:has(input:checked) { background: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--sw); }
    .ui-swatches .ui-opt:has(input:focus-visible) { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--sw), var(--focus-ring); }
.ui-swatch { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); transition: transform var(--m-quick); }
    .ui-swatches .ui-opt:hover .ui-swatch { transform: scale(1.06); }
.ui-swatch-check { position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; opacity: 0; color: #fff; stroke-width: 3; pointer-events: none; transition: opacity var(--m-quick); }
    .ui-opt:has(input:checked) .ui-swatch-check { opacity: 1; }
    .ui-swatches .ui-opt[data-swatch="teal"] .ui-swatch-check { color: #05231E; } /* white on that teal is too faint */
.ui-foot { display: flex; justify-content: flex-end; padding: 4px 4px 0; }

/* Top-bar panels (notifications, help, display settings) never run past the window: they scroll inside, the heading stays put. */
.live-panel, [data-tour-menu] { max-height: calc(100vh - 96px); max-height: calc(100dvh - 96px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
    .live-panel > .live-panel-head, [data-tour-menu] > .live-panel-head { position: sticky; top: -8px; z-index: 1; margin: -8px -8px 0; padding: 16px 20px 10px; background: var(--surface); border-radius: 16px 16px 0 0; }
    .ui-panel > .live-panel-head { top: -6px; margin: -6px -6px 0; padding: 14px 16px 8px; }

/* ---------------- Plans and billing (theme v2): locked menu items, plan usage, the client's plans page, invoices.
   Built on the design system's surfaces, radii, accent and text scale, so light/dark, the accent colour and the
   text-size setting all apply. */

/* Menu items outside the client's plan: muted, with a lock, and they open the plans page. */
.nav-link.is-locked { color: var(--muted); }
    .nav-link.is-locked:hover { color: var(--text-2); }
    .nav-link.is-locked .nav-lock { display: inline-flex; margin-left: auto; padding-left: 8px; color: var(--muted); opacity: .8; }
    .nav-link.is-locked .nav-lock .icon, .nav-link.is-locked .nav-lock svg { width: 14px; height: 14px; }
details.nav-group .nav-link.is-locked .nav-lock .icon { display: inline-block; }

/* Usage against the plan: three quiet tiles. */
.plan-usage { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin: 0; }
    .plan-usage > div { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); }
.plan-usage-label { font-size: calc(13px * var(--ts)); font-weight: 550; color: var(--muted); }
.plan-usage-value { font-size: calc(17px * var(--ts)); font-weight: 650; letter-spacing: -.01em; color: var(--text); font-variant-numeric: tabular-nums; }
    .plan-usage-value.is-alert { color: var(--danger-text); }

.plan-feature-note strong { color: inherit; }

/* Monthly / yearly switch: the same segmented pill as the chart switches. */
.pricing { display: flex; flex-direction: column; gap: 22px; margin-top: 8px; }
.pricing-cycle { position: relative; display: inline-flex; align-self: center; gap: 3px; padding: 4px; border-radius: var(--r-pill); background: var(--surface-3); }
    .pricing-cycle input { position: absolute; opacity: 0; pointer-events: none; }
    .pricing-cycle label { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 18px; border-radius: var(--r-pill); font-size: calc(14px * var(--ts)); font-weight: 650; color: var(--muted); cursor: pointer; transition: background-color var(--m-quick), color var(--m-quick), box-shadow var(--m-quick); }
    .pricing-cycle label:hover { color: var(--text); }
    .pricing-cycle input:checked + label { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
    .pricing-cycle input:focus-visible + label { box-shadow: var(--focus-ring); }
.pricing-save { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: var(--r-pill); background: var(--lime-300); color: var(--ink-900); font-size: calc(11.5px * var(--ts)); font-weight: 700; }
.pricing .py { display: none; }
.pricing:has(#cycle-yearly:checked) .py { display: flex; }
.pricing:has(#cycle-yearly:checked) .pm { display: none; }
.pricing .pm, .pricing .py { flex-direction: column; gap: 2px; }
.pricing:has(#cycle-monthly:checked) .pm { display: flex; }

/* Plan cards */
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; align-items: stretch; }
.price-card { position: relative; display: flex; flex-direction: column; gap: 16px; padding: 26px 24px 22px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-xs); transition: box-shadow var(--m-base), transform var(--m-base); }
    .price-card:hover { box-shadow: var(--shadow-md); }
    .price-card.is-popular { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), 0 18px 40px -26px rgba(var(--accent-rgb), .55); }
    .price-card.is-current { border-color: color-mix(in srgb, var(--success) 55%, var(--border)); background: linear-gradient(180deg, color-mix(in srgb, var(--success-soft) 70%, var(--surface)) 0, var(--surface) 140px); }
.price-flag { position: absolute; top: -12px; left: 22px; display: inline-flex; align-items: center; height: 24px; padding: 0 12px; border-radius: var(--r-pill); background: var(--ink-900); color: #fff; font-size: calc(11.5px * var(--ts)); font-weight: 700; letter-spacing: .02em; }
    .price-flag.is-popular { background: var(--primary); color: var(--on-primary); }
    :root[data-theme="dark"] .price-flag:not(.is-popular) { background: #fff; color: var(--ink-900); }
.price-name { margin: 0; font-size: calc(13px * var(--ts)); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.price-card.is-popular .price-name { color: var(--primary-text); }
.price-amount { min-height: 64px; }
.price-big { font-size: 36px; font-weight: 700; line-height: 1.05; letter-spacing: -.03em; color: var(--text); font-variant-numeric: tabular-nums; }
.price-per { font-size: calc(13px * var(--ts)); color: var(--muted); }
.price-amount > .price-big + .price-per { display: block; margin-top: 4px; }
.price-desc { margin: 0; min-height: 42px; font-size: calc(14px * var(--ts)); line-height: 1.5; color: var(--text-2); }
.price-card form { margin: 0; }
.price-mail { display: block; margin-top: -6px; text-align: center; color: var(--muted); }
.price-limits { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; margin: 0; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); font-size: calc(14px * var(--ts)); }
    .price-limits dt { color: var(--muted); }
    .price-limits dd { margin: 0; font-weight: 650; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.price-features { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; font-size: calc(14px * var(--ts)); }
    .price-features li { display: flex; align-items: flex-start; gap: 10px; }
    .price-features li > span { display: flex; flex-direction: column; gap: 1px; }
    .price-features li > svg { flex: none; width: 20px; height: 20px; padding: 3px; margin-top: 0; border-radius: 50%; stroke-width: 3; }
    .price-features li.yes > svg { background: var(--success-soft); color: var(--success-text); }
    .price-features li.no { color: var(--muted); }
    .price-features li.no > svg { background: var(--surface-3); color: var(--muted); }
    .price-features li.no strong { font-weight: 500; text-decoration: line-through; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); }
    .price-features li.is-feature { margin: 0 -8px; padding: 6px 8px; border-radius: var(--r-md); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary-soft-2); }

/* Questions: one bordered row each, the answer opening under it. */
.plan-faq { display: flex; flex-direction: column; gap: 0; }
    .plan-faq .card-title { margin-bottom: 8px; }
    .plan-faq details { border-top: 1px solid var(--border); padding: 0; }
    .plan-faq details:first-of-type { border-top: 0; }
    .plan-faq summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 2px; cursor: pointer; list-style: none; font-size: calc(15px * var(--ts)); font-weight: 600; color: var(--text); }
    .plan-faq summary::-webkit-details-marker { display: none; }
    .plan-faq summary::after { content: ""; flex: none; width: 8px; height: 8px; margin-right: 6px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translateY(-2px); transition: transform var(--m-base) var(--ease-out); }
    .plan-faq details[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
    .plan-faq summary:hover { color: var(--primary-text); }
    .plan-faq summary:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }
    .plan-faq p { margin: 0 0 16px; max-width: 75ch; font-size: calc(14px * var(--ts)); line-height: 1.6; color: var(--text-2); }

/* Popup headings used by the provider pages (and Consent requests): the same look as .modal-title. */
.modal-head { padding: 24px 28px 0; padding-right: 64px; }
    .modal-head h2 { margin: 0; font-size: calc(20px * var(--ts)); font-weight: 700; letter-spacing: -.02em; color: var(--text); }
    .modal-head + .modal-body, .modal-head + form > .modal-body, .modal-head + form.modal-body { padding-top: 16px; }

/* GST invoice: a document card, printable. */
.invoice-wrap { max-width: 900px; margin: 28px auto; padding: 0 16px; }
.invoice { display: flex; flex-direction: column; gap: 22px; padding: 32px 34px; border-radius: var(--r-xl); }
.invoice-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 18px; border-bottom: 1px solid var(--border-strong); }
.invoice-kind { font-size: calc(12px * var(--ts)); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary-text); }
.invoice-number { margin: 4px 0 0; font-size: 26px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.invoice-status .badge { font-size: calc(13px * var(--ts)); }
.invoice-parties { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; font-size: calc(14px * var(--ts)); line-height: 1.55; color: var(--text-2); }
    .invoice-parties > div { padding: 16px 18px; border-radius: var(--r-lg); background: var(--surface-2); }
    .invoice-parties strong { color: var(--text); }
.invoice-label { margin-bottom: 6px; font-size: calc(11.5px * var(--ts)); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.invoice-addr { white-space: pre-line; }
.invoice .invoice-dates { margin: 0; grid-template-columns: max-content minmax(0, 1fr); column-gap: 16px; font-size: inherit; }
    .invoice .invoice-dates dt, .invoice .invoice-dates dd { padding: 4px 0; border: 0; }
    .invoice .invoice-dates dd.wide { grid-column: auto; }
.invoice-lines tfoot td { border-top: 1px solid var(--border); color: var(--text-2); }
.invoice-total td { padding-top: 14px; font-size: calc(17px * var(--ts)); font-weight: 700; color: var(--text) !important; border-top: 2px solid var(--text) !important; }
@media print {
    .invoice-wrap { margin: 0; max-width: none; padding: 0; }
    .invoice { padding: 0; border: 0; box-shadow: none; }
    .invoice-parties > div { background: none; padding: 0; }
    .no-print { display: none !important; }
}
@container page (max-width: 640px) { .invoice { padding: 22px 18px; } }
@media (max-width: 640px) { .invoice { padding: 22px 18px; } .price-card { padding: 22px 18px 18px; } }

/* Provider dashboard: six tiles, three a row, so they wrap evenly. */
.provider-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@container page (max-width: 759.98px) { .provider-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .provider-stats { grid-template-columns: 1fr; } }

/* Cookie register (features merge): the "Add by hand" button sits at the end of the table header, the third-party tick
   lines up with the fields beside it, and placeholders in code-style inputs read in the body font. */
.list-panel-head > .list-panel-action { margin-left: auto; }
/* A panel's own action (Add feed, Add by hand) sits just before the Table/Cards switch, not halfway across the header. */
.list-panel-head > .list-panel-action ~ .list-view-switch { margin-left: 10px; }
/* A line under a panel's heading, lined up with the heading in both views. */
.list-panel-desc { margin: -6px 22px 16px; max-width: 70ch; }
.list-panel[data-view="cards"] > .list-panel-desc { margin-inline: 0; }
.form-grid > .check.field-check { align-self: end; min-height: 40px; }
.input.mono::placeholder { font-family: var(--font); }

/* Rights case: the requester shows masked, with "View in full" (or "Hide") on its own line under the details. */
.rd-person .rd-reveal { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; }

/* Danger zone (profile page): a red-edged card for deleting one's own account. */
.tile-danger { background: var(--danger-soft); color: var(--danger-text, var(--danger)); }
.card.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }

/* Whole-row links (site.js): a row that opens something shows the hand over the whole row, not only over its link. */
.table tbody tr.is-row-link, .data-table tbody tr.is-row-link { cursor: pointer; }

/* ---------- Wide tables ----------
   Compact row actions: icon buttons in table view. */
@media (min-width: 768px) {
    /* Icon-only actions in table view; the words stay for cards and screen readers, and as a tooltip. */
    .list-panel:not([data-view="cards"]) .row-actions .act-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .list-panel:not([data-view="cards"]) .row-actions .btn:has(.act-label) { width: 34px; padding: 0; justify-content: center; }
    .list-panel:not([data-view="cards"]) .data-table td.row-actions:has(.act-label) { width: 1%; padding-left: 10px; padding-right: 14px; }
    .list-panel:not([data-view="cards"]) .data-table td.row-actions:has(.act-label) > form { margin-left: 2px; }
}

/* A wide table's sideways scroll bar sits at the bottom of the window, not at the bottom of a long table (site.js adds
   the rail). The table's own bar is hidden while the rail is there, so there is only one. */
.table-rail { position: sticky; bottom: 0; z-index: 3; height: 16px; margin: 0 -18px; padding: 0 18px; overflow-x: auto; overflow-y: hidden; background: color-mix(in srgb, var(--surface) 92%, transparent); scrollbar-width: auto; scrollbar-color: var(--border-strong) transparent; }
    .table-rail > div { height: 1px; }
    .table-rail[hidden] { display: none; }
.table-scroll.has-rail { scrollbar-width: none; }
    .table-scroll.has-rail::-webkit-scrollbar { display: none; }
.list-panel[data-view="cards"] .table-rail { display: none; }
/* The panel clips its rounded corners with clip, not hidden: hidden would make it a scroll box, and the rail would stick
   to the panel instead of the window. */
.list-panel:has(.table-rail:not([hidden])) { overflow: clip; }

/* Cookie register: each column wide enough to read; the name and its address take what is left. */
@media (min-width: 768px) {
    .list-panel:not([data-view="cards"]) .tracker-table > thead > tr > th:first-child,
    .list-panel:not([data-view="cards"]) .tracker-table > tbody > tr > td.tr-name { width: 220px; min-width: 210px; max-width: 220px; overflow-wrap: anywhere; }
    .list-panel:not([data-view="cards"]) .tracker-table td[data-label="Domain"] { white-space: nowrap; }
    .list-panel:not([data-view="cards"]) .tracker-table td[data-label="Kind"] { min-width: 130px; }
    .list-panel:not([data-view="cards"]) .tracker-table td[data-label="Category"] { min-width: 140px; }
    .list-panel:not([data-view="cards"]) .tracker-table td[data-label="Review"] { white-space: nowrap; }
}

/* Detail pages with two columns of cards (consent record, form consent): each column stacks its own cards, and the last
   card in the shorter column stretches, so both columns end level with no gap under either. Narrow screens get one
   column, with the cards in reading order (--order on each card). */
.detail-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: stretch; }
.detail-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
    .detail-col > .card { margin: 0; container-type: inline-size; }
    .detail-col > .card:last-child { flex: 1 1 auto; }
@media (max-width: 900px) {
    .detail-cols { display: flex; flex-direction: column; }
    .detail-col { display: contents; }
    .detail-col > .card { order: var(--order, 0); }
}

/* A button beside a form field (Update next to a name box, Apply at the end of a filter bar, Add next to an input) is
   as tall as the field, whatever its size class says. Small fields (input-sm, select-sm) and the password box's own
   Show button keep their sizes. */
:where(:has(> :is(.input:not(.input-sm), .select:not(.select-sm), .combo, .f-search))):not(.auth2-password) > .btn:not(.btn-icon) {
    height: var(--h-control);
    padding-left: 16px;
    padding-right: 16px;
}

/* Summary cards: two by two on narrow screens instead of four squeezed into one row. An odd last card takes the full row. */
@media (max-width: 680px) {
    .stat-row:not(.kpis) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-row:not(.kpis) > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* Consent analytics. Outcome colours in a fixed order (agreeing, refused, withdrawn, lapsed), checked for colour-blind
   readers on the light and dark surfaces; every bar has its numbers beside it or in the table, so colour never works alone. */
:root { --oc-granted: #2a78d6; --oc-refused: #eb6834; --oc-withdrawn: #1baf7a; --oc-lapsed: #eda100; --oc-rate: #2a78d6; }
:root[data-theme="dark"] { --oc-granted: #3987e5; --oc-refused: #d95926; --oc-withdrawn: #199e70; --oc-lapsed: #c98500; --oc-rate: #3987e5; }
.ca-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 16px; }
.ca-filters .field { min-width: 150px; }
.ca-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: calc(12.5px * var(--ts)); color: var(--muted); margin: 0; padding: 0; list-style: none; }
.ca-legend li { display: inline-flex; align-items: center; gap: 6px; }
.ca-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.ca-stack { display: flex; gap: 2px; height: 12px; min-width: 140px; border-radius: 4px; overflow: hidden; background: var(--surface-3); }
.ca-stack > span { display: block; height: 100%; min-width: 2px; }
.ca-rate { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.ca-rate-track { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.ca-rate-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--oc-rate); }
.ca-rate-num { font-variant-numeric: tabular-nums; min-width: 3.5em; text-align: right; }
.ca-cols { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 8px 0 0; border-bottom: 1px solid var(--border-strong); }
.ca-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; position: relative; }
.ca-col-bar { width: min(36px, 70%); border-radius: 4px 4px 0 0; background: var(--oc-rate); }
.ca-col-bar.is-empty { height: 2px !important; background: var(--border-strong); }
.ca-col-val { font-size: calc(11.5px * var(--ts)); color: var(--muted); font-variant-numeric: tabular-nums; margin-bottom: 4px; }
.ca-col:hover .ca-col-bar { outline: 2px solid var(--surface); box-shadow: 0 0 0 4px var(--oc-rate); }
.ca-col-labels { display: flex; gap: 6px; margin-top: 6px; }
.ca-col-labels > span { flex: 1; text-align: center; font-size: calc(11.5px * var(--ts)); color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media print { .ca-filters, .tabs, .page-head .actions, .side-nav, .topbar { display: none !important; } }

/* Limits tracker: every plan limit with its use. Green under 50%, orange from 50%, red from 80% (the 80% warning). */
.limits-tracker { display: flex; flex-direction: column; gap: 12px; }
.limits-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.limits-head .card-title { margin: 0; }
.limits-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.limits-row { --tone: var(--success); display: grid; grid-template-columns: minmax(150px, 220px) 1fr auto; align-items: center; gap: 4px 14px; }
.limits-row[data-colour="orange"] { --tone: var(--warning); }
.limits-row[data-colour="red"] { --tone: var(--danger); }
.limits-row[data-colour="none"] { --tone: var(--border); }
.limits-label { font-size: calc(13.5px * var(--ts)); font-weight: 550; color: var(--text); }
.limits-bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.limits-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--tone); }
.limits-value { font-variant-numeric: tabular-nums; font-size: calc(13.5px * var(--ts)); font-weight: 600; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.limits-note { grid-column: 2 / -1; }
@media (max-width: 640px) {
    .limits-row { grid-template-columns: 1fr auto; }
    .limits-bar { grid-column: 1 / -1; grid-row: 2; }
    .limits-note { grid-column: 1 / -1; }
}
.pack-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.pack-card { display: flex; flex-direction: column; gap: 8px; }
.pack-card .pack-price { font-size: calc(18px * var(--ts)); font-weight: 700; }
.clause-text { white-space: pre-wrap; font-size: calc(13.5px * var(--ts)); line-height: 1.55; margin: 0; padding: 12px 14px; border-radius: var(--r-md, 8px); background: var(--surface-2); }

/* Channel and frequency choices under a purpose (consent pages and the person's portal). */
.channel-choices { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 6px 0 4px 26px; }
td .channel-choices { margin-left: 0; }
.channel-frequency { display: inline-flex; align-items: center; gap: 6px; }
/* Channels appear only once the purpose itself is ticked, so nothing looks agreed before the person agrees. */
label:has(> input[name="granted"]:not(:checked)) + .channel-choices { display: none; }
