/*!
 * NexusCMP — admin panel stylesheet
 *
 * Single file, no build step. Tokens first, then layout, then components.
 * Light and dark are both first-class: the panel follows the OS unless the
 * operator forces a theme with the toggle (data-theme on <html>).
 */

/* ===================================================================== *
 * Tokens
 * ===================================================================== */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #fbfbfd;
    --surface-3: #f0f2f5;
    --border: #e3e6eb;
    --border-strong: #cbd1da;

    --text: #16181d;
    --text-muted: #5c6472;
    --text-faint: #8a92a1;

    --primary: #2f5bff;
    --primary-hover: #2449d6;
    --primary-soft: #eaefff;
    --primary-text: #ffffff;

    --success: #12855a;
    --success-soft: #e3f5ec;
    --warning: #b0700d;
    --warning-soft: #fdf3e0;
    --danger: #c02b3a;
    --danger-soft: #fdeced;
    --info: #1f6fb0;
    --info-soft: #e7f2fb;

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 18px;
    --shadow-sm: 0 1px 2px rgba(16, 20, 30, .06);
    --shadow: 0 1px 3px rgba(16, 20, 30, .07), 0 8px 24px -10px rgba(16, 20, 30, .18);
    --shadow-lg: 0 2px 6px rgba(16, 20, 30, .08), 0 24px 48px -16px rgba(16, 20, 30, .28);

    --sidebar-width: 264px;
    --ease: cubic-bezier(.22, .8, .34, 1);

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root[data-theme="auto"], :root:not([data-theme]) {
        --bg: #101216;
        --surface: #171a21;
        --surface-2: #1b1f27;
        --surface-3: #232833;
        --border: #272c36;
        --border-strong: #39404d;

        --text: #eef0f4;
        --text-muted: #a7b0be;
        --text-faint: #79828f;

        --primary: #6f8cff;
        --primary-hover: #8aa1ff;
        --primary-soft: #1e2436;
        --primary-text: #0c0f16;

        --success: #3ecf8e;
        --success-soft: #14261f;
        --warning: #e0a944;
        --warning-soft: #2a2114;
        --danger: #f2707c;
        --danger-soft: #2c1719;
        --info: #63b3ed;
        --info-soft: #142330;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 10px 28px -12px rgba(0, 0, 0, .7);
        --shadow-lg: 0 2px 8px rgba(0, 0, 0, .55), 0 28px 56px -20px rgba(0, 0, 0, .8);

        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #101216;
    --surface: #171a21;
    --surface-2: #1b1f27;
    --surface-3: #232833;
    --border: #272c36;
    --border-strong: #39404d;
    --text: #eef0f4;
    --text-muted: #a7b0be;
    --text-faint: #79828f;
    --primary: #6f8cff;
    --primary-hover: #8aa1ff;
    --primary-soft: #1e2436;
    --primary-text: #0c0f16;
    --success: #3ecf8e;
    --success-soft: #14261f;
    --warning: #e0a944;
    --warning-soft: #2a2114;
    --danger: #f2707c;
    --danger-soft: #2c1719;
    --info: #63b3ed;
    --info-soft: #142330;
    color-scheme: dark;
}

/* ===================================================================== *
 * Base
 * ===================================================================== */

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, p, figure, ul, ol, dl, dd { margin: 0; padding: 0; }
ul, ol { list-style: none; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

code, pre, .mono { font-family: var(--mono); font-size: .88em; }

.icon { width: 18px; height: 18px; flex: 0 0 auto; }

.sr-only {
    position: absolute !important;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; left: -9999px; top: 8px; z-index: 100;
    padding: 10px 16px; background: var(--primary); color: var(--primary-text);
    border-radius: var(--radius-sm);
}
.skip-link:focus { left: 8px; }

/* ===================================================================== *
 * App shell
 * ===================================================================== */

.app { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-inline-end: 1px solid var(--border);
    z-index: 40;
    transition: transform .26s var(--ease);
}

.sidebar__brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 18px 18px 14px;
}

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand__mark { display: inline-flex; width: 30px; height: 30px; color: var(--primary); }
.brand__mark svg { width: 100%; height: 100%; }
.brand__text { font-size: 16px; letter-spacing: -.01em; }

.sidebar__close { display: none; font-size: 24px; line-height: 1; color: var(--text-faint); padding: 4px 8px; }

.sidebar__nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 4px 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: background-color .15s var(--ease), color .15s var(--ease);
}
.nav-item:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-item.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-item.is-active .icon { color: var(--primary); }
.nav-item--sub { padding-inline-start: 14px; font-size: 13.5px; }

.nav-group { margin-top: 18px; display: flex; flex-direction: column; gap: 2px; }
.nav-group__label {
    padding: 0 12px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.sidebar__footer {
    flex: 0 0 auto;
    padding: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text);
}
.user-chip:hover { background: var(--surface-3); text-decoration: none; }
.user-chip__avatar {
    display: grid; place-items: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary); color: var(--primary-text);
    font-weight: 700; font-size: 14px;
}
.user-chip__meta { display: flex; flex-direction: column; min-width: 0; }
.user-chip__name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip__role { font-size: 11.5px; color: var(--text-faint); text-transform: capitalize; }

.sidebar-scrim {
    position: fixed; inset: 0; z-index: 35;
    background: rgba(10, 12, 18, .5);
    backdrop-filter: blur(2px);
}

.shell {
    flex: 1 1 auto;
    min-width: 0;
    margin-inline-start: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 28px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.topbar__menu { display: none; padding: 6px; border-radius: var(--radius-sm); color: var(--text-muted); }
.topbar__title { flex: 1 1 auto; min-width: 0; }
.topbar__title h1 { font-size: 20px; font-weight: 680; letter-spacing: -.015em; }
.topbar__title p { font-size: 13px; color: var(--text-muted); }
.topbar__actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; flex-wrap: wrap; }

/*
 * Fills the shell. The readable-width cap applies only to prose-heavy screens
 * that opt in with .main--narrow: tables, the consent register and the designer
 * all want every pixel the viewport can give them.
 */
.main {
    flex: 1 1 auto;
    width: 100%;
    padding: 24px clamp(16px, 2vw, 32px) 48px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.main--narrow {
    max-width: 1120px;
    margin-inline: auto;
}

.footer {
    padding: 18px 28px 28px;
    font-size: 12.5px;
    color: var(--text-faint);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===================================================================== *
 * Buttons
 * ===================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    white-space: nowrap;
    transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

.btn--primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--secondary:hover { background: var(--surface-3); }

.btn--ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn--ghost:hover { color: var(--text); border-color: var(--border-strong); }

.btn--danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn--danger:hover { background: var(--danger); color: #fff; }

.btn--sm { min-height: 32px; padding: 5px 12px; font-size: 12.5px; }
.btn--lg { min-height: 46px; padding: 12px 22px; font-size: 15px; }
.btn--block { width: 100%; }
.btn--icon { padding: 8px; min-width: 38px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ===================================================================== *
 * Cards, sections
 * ===================================================================== */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.card__title { font-size: 15px; font-weight: 650; letter-spacing: -.005em; }
.card__subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.card__body { padding: 20px; }
.card__body--flush { padding: 0; }
.card__footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius) var(--radius);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.grid { display: grid; gap: 18px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.stack--sm { gap: 8px; }
.stack--lg { gap: 24px; }

.section-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-faint);
}

/* ===================================================================== *
 * Stats
 * ===================================================================== */

.stat {
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.stat__label { font-size: 12.5px; color: var(--text-muted); font-weight: 550; }
.stat__value { font-size: 27px; font-weight: 690; letter-spacing: -.02em; margin-top: 4px; line-height: 1.15; }
.stat__meta { font-size: 12.5px; color: var(--text-faint); margin-top: 4px; }
.stat__meta strong { color: var(--text-muted); }

.meter {
    height: 6px;
    border-radius: 999px;
    background: var(--surface-3);
    overflow: hidden;
    margin-top: 10px;
    display: flex;
}
.meter__part { height: 100%; }
.meter__part--accept { background: var(--success); }
.meter__part--custom { background: var(--primary); }
.meter__part--reject { background: var(--border-strong); }

.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--text-muted); }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__dot { width: 8px; height: 8px; border-radius: 2px; }

/* ===================================================================== *
 * Chart (inline SVG, no library)
 * ===================================================================== */

.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart__grid { stroke: var(--border); stroke-width: 1; }
.chart__axis { fill: var(--text-faint); font-size: 10px; }
.chart__area-accept { fill: color-mix(in srgb, var(--success) 16%, transparent); }
.chart__line-accept { stroke: var(--success); stroke-width: 2; fill: none; }
.chart__area-reject { fill: color-mix(in srgb, var(--danger) 12%, transparent); }
.chart__line-reject { stroke: var(--danger); stroke-width: 2; fill: none; }
.chart__line-custom { stroke: var(--primary); stroke-width: 2; fill: none; stroke-dasharray: 4 3; }

/* ===================================================================== *
 * Tables
 * ===================================================================== */

.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 11px 16px; text-align: start; vertical-align: middle; }
.table thead th {
    position: sticky; top: 0;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-faint);
    white-space: nowrap;
}
.table tbody tr { border-bottom: 1px solid var(--border); }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.is-numeric, .table th.is-numeric { text-align: end; font-variant-numeric: tabular-nums; }
.table .cell-muted { color: var(--text-muted); }
.table .cell-nowrap { white-space: nowrap; }

.empty {
    padding: 44px 24px;
    text-align: center;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.empty .icon { width: 32px; height: 32px; color: var(--text-faint); }
.empty h3 { font-size: 15px; color: var(--text); font-weight: 650; }
.empty p { font-size: 13.5px; max-width: 44ch; }

/* ===================================================================== *
 * Badges, pills
 * ===================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 650;
    white-space: nowrap;
    background: var(--surface-3);
    color: var(--text-muted);
}
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger  { background: var(--danger-soft); color: var(--danger); }
.badge--info    { background: var(--info-soft); color: var(--info); }
.badge--primary { background: var(--primary-soft); color: var(--primary); }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--surface);
}

.key {
    font-family: var(--mono);
    font-size: 12.5px;
    background: var(--surface-3);
    padding: 3px 8px;
    border-radius: 6px;
    word-break: break-all;
}

/* ===================================================================== *
 * Alerts
 * ===================================================================== */

.flash-stack { display: flex; flex-direction: column; gap: 10px; }

.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 13.5px;
}
.alert p { flex: 1 1 auto; min-width: 0; }
.alert__icon { display: inline-flex; flex: 0 0 auto; margin-top: 1px; }
.alert__close { flex: 0 0 auto; font-size: 20px; line-height: 1; opacity: .6; padding: 0 4px; }
.alert__close:hover { opacity: 1; }

.alert--success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 22%, transparent); }
.alert--error   { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.alert--warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert--info    { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 22%, transparent); }

/* ===================================================================== *
 * Forms
 * ===================================================================== */

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 13px; font-weight: 600; }
.field__hint { font-size: 12.5px; color: var(--text-muted); }
.field__error { font-size: 12.5px; color: var(--danger); font-weight: 550; }

.input, .select, .textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-faint); }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--danger); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.input--mono { font-family: var(--mono); font-size: 13px; }

.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a92a1' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-inline-end: 34px;
}

.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.form-grid--full > .field--wide { grid-column: 1 / -1; }

.fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.fieldset > legend {
    padding: 0 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-faint);
}

/* switch */
.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.switch__input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
    position: relative;
    flex: 0 0 auto;
    width: 40px; height: 23px;
    margin-top: 1px;
    border-radius: 999px;
    background: var(--border-strong);
    transition: background-color .18s var(--ease);
}
.switch__thumb {
    position: absolute; top: 3px; left: 3px;
    width: 17px; height: 17px; border-radius: 50%;
    background: #fff; box-shadow: var(--shadow-sm);
    transition: transform .18s var(--ease);
}
.switch__input:checked + .switch__track { background: var(--primary); }
.switch__input:checked + .switch__track .switch__thumb { transform: translateX(17px); }
.switch__input:focus-visible + .switch__track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.switch__text { display: flex; flex-direction: column; gap: 2px; }
.switch__label { font-size: 13.5px; font-weight: 550; }
.switch__hint { font-size: 12.5px; color: var(--text-muted); }

/* checkbox list */
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.check input[type="checkbox"], .check input[type="radio"] { width: 16px; height: 16px; accent-color: var(--primary); }
.check-list { display: flex; flex-wrap: wrap; gap: 10px 18px; }

/* segmented control */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: var(--radius-sm); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span {
    display: block;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color .15s var(--ease), color .15s var(--ease);
}
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 1px; }

.segmented__link {
    display: block;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}
.segmented__link:hover { color: var(--text); text-decoration: none; }
.segmented__link.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* filter bar */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.filters .field { flex: 1 1 150px; min-width: 0; }
.filters .field--grow { flex: 2 1 240px; }

/* ===================================================================== *
 * Tabs
 * ===================================================================== */

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}
.tab {
    padding: 9px 14px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===================================================================== *
 * Accordion / disclosure
 * ===================================================================== */

.disclosure { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.disclosure + .disclosure { margin-top: 8px; }
.disclosure__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}
.disclosure__summary::-webkit-details-marker { display: none; }
.disclosure__summary:hover { background: var(--surface-2); }
.disclosure[open] .disclosure__summary { border-bottom: 1px solid var(--border); }
.disclosure__body { padding: 16px; background: var(--surface-2); display: flex; flex-direction: column; gap: 14px; }
.disclosure__chevron { transition: transform .2s var(--ease); color: var(--text-faint); }
.disclosure[open] .disclosure__chevron { transform: rotate(180deg); }

/* ===================================================================== *
 * Code blocks
 * ===================================================================== */

.code-block {
    position: relative;
    background: #12141a;
    color: #e6e9ef;
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    overflow-x: auto;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.7;
    tab-size: 2;
}
.code-block code { white-space: pre; }
.code-copy {
    position: absolute;
    top: 8px;
    inset-inline-end: 8px;
    padding: 5px 10px;
    font-size: 11.5px;
    font-weight: 600;
    color: #b9c0cc;
    background: rgba(255, 255, 255, .08);
    border-radius: 6px;
}
.code-copy:hover { background: rgba(255, 255, 255, .16); color: #fff; }
.code-copy.is-done { background: var(--success); color: #fff; }

/* ===================================================================== *
 * Generated cookie policy preview
 * ===================================================================== */

.policy-preview {
    max-height: 620px;
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding: 4px 18px 4px 4px;
}

.policy-preview .ncmp-policy__title { font-size: 24px; letter-spacing: -.02em; margin: 0 0 8px; }
.policy-preview h2 { font-size: 17px; margin: 28px 0 8px; }
.policy-preview h3 { font-size: 15px; margin: 20px 0 6px; }
.policy-preview p { margin: 0 0 12px; font-size: 14px; line-height: 1.7; }
.policy-preview ul { margin: 0 0 12px 20px; list-style: disc; font-size: 14px; }
.policy-preview .ncmp-policy__meta,
.policy-preview .ncmp-policy__muted { color: var(--text-muted); font-size: 13px; }
.policy-preview .ncmp-policy__note {
    font-size: 13px; color: var(--text-muted);
    border-left: 3px solid var(--border); padding-left: 12px;
}
.policy-preview .ncmp-policy__tag {
    display: inline-block; padding: 2px 9px; border-radius: 999px;
    background: var(--success-soft); color: var(--success); font-size: 11.5px; font-weight: 650;
}
.policy-preview .ncmp-policy__link {
    font: inherit; color: var(--primary); background: none; border: 0; padding: 0;
    text-decoration: underline; cursor: pointer;
}
.policy-preview .ncmp-policy__table {
    width: 100%; border-collapse: collapse; margin: 10px 0 18px; font-size: 13px;
}
.policy-preview .ncmp-policy__table th,
.policy-preview .ncmp-policy__table td {
    padding: 8px 10px; text-align: start; vertical-align: top;
    border-bottom: 1px solid var(--border);
}
.policy-preview .ncmp-policy__table th {
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint);
}
.policy-preview .ncmp-policy__table code {
    font-family: var(--mono); font-size: 12.5px;
    background: var(--surface-3); padding: 2px 6px; border-radius: 5px;
}

/* The live consent widget cannot render here — the SDK is not loaded in the
   panel — so show what its placeholder is for instead of an empty gap. */
.policy-preview [data-cmp-widget]::before {
    content: "Qui compare il riepilogo del consenso del visitatore.";
    display: block;
    padding: 16px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-faint);
    font-size: 13px;
    text-align: center;
}

/* ===================================================================== *
 * Timeline (audit, revisions)
 * ===================================================================== */

.timeline { display: flex; flex-direction: column; }
.timeline__item {
    position: relative;
    padding: 0 0 18px 26px;
    border-inline-start: 2px solid var(--border);
    margin-inline-start: 6px;
}
.timeline__item:last-child { border-color: transparent; padding-bottom: 0; }
.timeline__dot {
    position: absolute;
    inset-inline-start: -7px;
    top: 3px;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border-strong);
}
.timeline__dot--primary { border-color: var(--primary); background: var(--primary); }
.timeline__dot--success { border-color: var(--success); background: var(--success); }
.timeline__dot--danger { border-color: var(--danger); background: var(--danger); }
.timeline__title { font-size: 13.5px; font-weight: 600; }
.timeline__meta { font-size: 12.5px; color: var(--text-faint); }
.timeline__body { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ===================================================================== *
 * Designer preview
 * ===================================================================== */

/*
 * The form column stays readable; the preview takes everything else, because a
 * banner shown in a 380px box tells you nothing about how it will look on a
 * real page.
 */
.designer {
    display: grid;
    grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.preview {
    position: sticky;
    top: 88px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.preview__bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-size: 12.5px;
    color: var(--text-muted);
}
.preview__dots { display: flex; gap: 5px; flex: 0 0 auto; }
.preview__dots span { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); }
.preview__label { flex: 1 1 auto; }

.preview__viewport {
    display: flex;
    justify-content: center;
    background: var(--surface-3);
    padding: 0;
    transition: padding .2s var(--ease);
}
.preview__viewport[data-device="tablet"] { padding: 18px; }
.preview__viewport[data-device="mobile"] { padding: 18px; }

.preview__frame {
    width: 100%;
    /* Tall enough that a bottom-anchored banner is not the only thing visible. */
    height: clamp(520px, calc(100vh - 260px), 900px);
    border: 0;
    display: block;
    background: #fff;
    transition: width .2s var(--ease), max-width .2s var(--ease);
}
.preview__viewport[data-device="tablet"] .preview__frame {
    width: 768px;
    max-width: 100%;
    height: clamp(520px, calc(100vh - 296px), 860px);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.preview__viewport[data-device="mobile"] .preview__frame {
    width: 390px;
    max-width: 100%;
    height: clamp(520px, calc(100vh - 296px), 780px);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.preview__actions {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    align-items: center;
}
.preview__actions .segmented { margin-inline-start: auto; }

/*
 * Expanded mode: the form column is hidden and the preview takes the whole
 * content area. In a side-by-side split the banner is always squeezed, and a
 * squeezed banner is exactly what you cannot judge.
 */
.designer.is-preview-expanded { grid-template-columns: minmax(0, 1fr); }
.designer.is-preview-expanded > form { display: none; }
.designer.is-preview-expanded .preview { position: static; }
.designer.is-preview-expanded .preview__frame { height: calc(100vh - 220px); }

.preview__expand { margin-inline-start: 8px; }

.swatch-row { display: flex; align-items: center; gap: 10px; }
.swatch-row input[type="color"] {
    width: 42px; height: 34px; padding: 2px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
}

/* ===================================================================== *
 * Auth
 * ===================================================================== */

.auth {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    min-height: 100vh;
}

.auth__panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 40px 24px;
}

.auth__card {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth__brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.auth__brand .brand__mark { width: 32px; height: 32px; color: var(--primary); }
.auth__note { font-size: 12.5px; color: var(--text-faint); }

.auth__aside {
    background: linear-gradient(160deg, var(--primary) 0%, color-mix(in srgb, var(--primary) 62%, #101a3a) 100%);
    color: #fff;
    display: grid;
    place-items: center;
    padding: 48px;
}
.auth__aside-inner { max-width: 30rem; }
.auth__aside h2 { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; margin-bottom: 22px; }
.auth__aside ul { display: flex; flex-direction: column; gap: 12px; }
.auth__aside li {
    position: relative;
    padding-inline-start: 26px;
    font-size: 15px;
    opacity: .92;
}
.auth__aside li::before {
    content: "";
    position: absolute;
    inset-inline-start: 0; top: 9px;
    width: 8px; height: 8px;
    border-radius: 2px;
    background: rgba(255, 255, 255, .8);
}

/* ===================================================================== *
 * Utilities
 * ===================================================================== */

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 12.5px; }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.text-end { text-align: end; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex--between { justify-content: space-between; }
.flex--wrap { flex-wrap: wrap; }
.flex--top { align-items: flex-start; }
.grow { flex: 1 1 auto; min-width: 0; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================================================================== *
 * Responsive
 * ===================================================================== */

@media (max-width: 1240px) {
    .designer { grid-template-columns: minmax(0, 1fr); }
    .preview { position: static; }
    .preview__frame { height: 620px; }
    .grid--sidebar { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 960px) {
    .auth { grid-template-columns: minmax(0, 1fr); }
    .auth__aside { display: none; }
}

@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.is-open { transform: none; }
    .sidebar__close { display: block; }
    .shell { margin-inline-start: 0; }
    .topbar__menu { display: inline-flex; }
    .topbar, .main, .footer { padding-inline: 16px; }
    .main { padding-top: 18px; gap: 16px; }
    .table th, .table td { padding: 10px 12px; }
}

@media print {
    .sidebar, .topbar__menu, .topbar__actions, .footer, .btn { display: none !important; }
    .shell { margin: 0; }
    .card { break-inside: avoid; box-shadow: none; }
}

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

/* Usato dal designer per segnalare una bozza diversa da ciò che è in produzione:
   la differenza fra "salvato" e "pubblicato" deve saltare all'occhio. */
.text-warning { color: var(--warning); }

/* --- Lingue e testi -------------------------------------------------------
   La percentuale sulla scheda e il testo di riferimento accanto al campo sono
   il modo in cui questa pagina smette di chiedere all'operatore di contare 41
   campi a memoria e di saltare fra due schede per tradurne uno. */

.tab__badge {
    display: inline-block;
    margin-left: 6px;
    padding: 0 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
}
.tab__badge.is-done { background: var(--success-soft); color: var(--success); }
.tab__badge.is-partial { background: var(--warning-soft); color: var(--warning); }

.lang-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin: 14px 0 4px;
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.lang-bar__state { margin: 0; font-size: 14px; }
.lang-bar__ref { display: flex; align-items: center; gap: 8px; margin: 0; }
.lang-bar__actions { margin-left: auto; }
.select--sm { padding: 4px 26px 4px 8px; font-size: 13px; }

/* La frase nella lingua di riferimento, sopra il campo da tradurre. */
.field__source {
    margin: 0 0 6px;
    padding: 7px 10px;
    background: var(--surface-2);
    border-left: 3px solid var(--border-strong, var(--border));
    border-radius: 0 6px 6px 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}
.field__source-tag {
    display: inline-block;
    margin-right: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--faint);
}
