:root {
    --bg-main: #f2f8f7;
    --bg-glow-1: #b4f5df;
    --bg-glow-2: #ffd6b4;
    --bg-soft: #ffffff;
    --ink-900: #12222a;
    --ink-700: #2f4752;
    --brand-1: #0f766e;
    --brand-2: #f97316;
    --line: #d3e3e0;
    --ok: #0f766e;
    --danger: #c2410c;
    --radius: 18px;
    /* Surfaces: --surface = cards / inputs, --surface-2 = soft rows, headers, hovers, --surface-3 = open / pressed. */
    --surface: #ffffff;
    --surface-2: #f6faf9;
    --surface-3: #eef5f3;
    /* Secondary text (hints, empty states, emails): 5:1 on --surface-2. */
    --ink-400: #5b6f78;
    --text: var(--ink-900);
    --text-muted: var(--ink-400);
    /* End of the teal gradient on buttons: white text stays at least 4.5:1 across the whole gradient. */
    --brand-1-end: #11837a;
    /* Brand colour for text and icons (links, active sort, edit actions): readable in both themes. */
    --brand-ink: #0f766e;
    --danger-line: #fecaca;
    --danger-soft: #fff5f2;
}

:root[data-theme="dark"] {
    --bg-main: #0c151b;
    --bg-glow-1: #174248;
    --bg-glow-2: #4a2f1a;
    --bg-soft: #122029;
    --ink-900: #e4eff4;
    --ink-700: #a6c0cb;
    --line: #29414b;
    --danger: #fda4af;
    --brand-ink: #2dd4bf;
    --surface: #122029;
    --surface-2: #172a34;
    --surface-3: #1c323d;
    --ink-400: #8aa3ae;
    --danger-line: color-mix(in srgb, #fda4af 35%, transparent);
    --danger-soft: color-mix(in srgb, #fda4af 10%, transparent);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Manrope', sans-serif;
    color: var(--ink-900);
    background:
        radial-gradient(1000px 500px at -10% -15%, var(--bg-glow-1) 0, transparent 60%),
        radial-gradient(900px 500px at 110% 0%, var(--bg-glow-2) 0, transparent 50%),
        var(--bg-main);
    transition: background 0.25s ease, color 0.25s ease;
}

h1, h2, h3 {
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    transition: grid-template-columns 0.25s ease;
}

/* Collapsed sidebar (icons only): desktop only. */
@media (min-width: 901px) {
    .app-shell[data-sidebar-state="collapsed"] {
        grid-template-columns: 92px minmax(0, 1fr);
    }
}

.sidebar {
    padding: 20px 16px;
    border-right: 1px solid var(--line);
    background: linear-gradient(180deg, #f8fffe 0%, #eef6f3 100%);
    position: relative;
    z-index: 20;
}

:root[data-theme="dark"] .sidebar {
    background: linear-gradient(180deg, #10202a 0%, #0e1a22 100%);
}

.sidebar-head {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.sidebar-toggle,
.mobile-menu-btn {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-900);
    border-radius: 12px;
    padding: 8px 10px;
    cursor: pointer;
}

.sidebar-toggle {
    width: 40px;
    height: 40px;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.sidebar-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--ink-900);
    margin: 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
    padding: 8px;
    border-radius: 14px;
}

.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--brand-1), var(--brand-1-end));
    color: #fff;
    font-weight: 800;
    font-family: 'Space Grotesk', sans-serif;
}

.brand strong {
    display: block;
    font-size: 15px;
}

.brand small {
    color: var(--ink-700);
    font-size: 13px;
}

.nav-links {
    display: grid;
    gap: 8px;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 12px;
    color: var(--ink-700);
    transition: all 0.2s ease;
}

.nav-icon {
    min-width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    border: 1px solid var(--line);
    background: #fff;
}

.nav-text {
    white-space: nowrap;
}

.nav-section {
    padding: 12px 10px 4px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-400);
    user-select: none;
}

.app-shell[data-sidebar-state="collapsed"] .nav-section {
    display: none;
}

/* A count beside a menu (e.g. requests waiting for approval). */
.nav-badge { margin-left: auto; min-width: 24px; padding: 2px 8px; border-radius: 999px; background: #f59e0b; color: #fff; font-size: 13px; font-weight: 800; text-align: center; }
.nav-links a { position: relative; }

.nav-links a:hover,
.nav-links a.active {
    color: #fff;
    background: linear-gradient(90deg, var(--brand-1), var(--brand-1-end));
    transform: translateX(2px);
}

.nav-links a:hover .nav-icon {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.16);
}

/* On the active (teal) item the chip sinks in: a lighter chip would drop its white letters below 4.5:1. */
.nav-links a.active .nav-icon {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(0, 0, 0, 0.14);
}

/* Collapsed sidebar (icons only): desktop only. */
@media (min-width: 901px) {
    .app-shell[data-sidebar-state="collapsed"] .brand-copy,
    .app-shell[data-sidebar-state="collapsed"] .nav-text {
        display: none;
    }
    
    .app-shell[data-sidebar-state="collapsed"] .sidebar {
        padding-left: 12px;
        padding-right: 12px;
    }
    
    .app-shell[data-sidebar-state="collapsed"] .brand {
        justify-content: center;
    }
    
    .app-shell[data-sidebar-state="collapsed"] .nav-links a {
        justify-content: center;
    }

    .app-shell[data-sidebar-state="collapsed"] .nav-badge {
        position: absolute; top: 2px; right: 2px; min-width: 18px; padding: 0 5px; font-size: 11px; line-height: 18px;
    }
}

.backdrop {
    display: none;
}

.content-wrap {
    padding: 24px;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    position: relative;
    z-index: 15;
}

.title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-menu-btn {
    display: none;
}


.topbar h1 {
    margin-top: 4px;
    font-size: clamp(26px, 2.4vw, 34px);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.lang-switch {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 6px 8px;
    font-size: 13px;
}

.lang-switch span {
    color: var(--ink-700);
    font-weight: 700;
}

.lang-switch select {
    min-height: 34px;
    padding: 6px 28px 6px 8px;
    border-radius: 8px;
    border: 0;
    background-color: color-mix(in srgb, var(--bg-main) 70%, var(--bg-soft));
    outline: none;
}

.theme-toggle,
.profile-trigger {
    border: 1px solid var(--line);
    background: var(--bg-soft);
    color: var(--ink-900);
    border-radius: 12px;
    min-height: 46px;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.theme-toggle:hover,
.profile-trigger:hover {
    border-color: #9ccfc8;
    box-shadow: 0 8px 16px rgba(15, 118, 110, 0.08);
}

.theme-icon {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.theme-icon.sun {
    display: inline-block;
}

.theme-icon.moon {
    display: none;
}

:root[data-theme="dark"] .theme-icon.sun {
    display: none;
}

:root[data-theme="dark"] .theme-icon.moon {
    display: inline-block;
}

.profile-menu {
    position: relative;
}

.profile-trigger {
    width: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.profile-trigger svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    width: min(280px, 82vw);
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 18px 36px rgba(18, 34, 42, 0.16);
    padding: 8px;
    display: grid;
}

.profile-dropdown[hidden] {
    display: none;
}

.profile-summary {
    padding: 8px 10px 10px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 6px;
    display: grid;
    gap: 2px;
}

.profile-summary strong {
    font-size: 15px;
}

.profile-summary small {
    color: var(--ink-700);
    font-size: 12px;
}

.profile-dropdown-link,
.profile-dropdown-logout {
    width: 100%;
    text-align: left;
    border-radius: 10px;
    border: 0;
    background: transparent;
    color: var(--ink-900);
    padding: 10px;
    font-size: 15px;
    font-weight: 700;
}

.profile-dropdown-link {
    display: block;
}

.profile-dropdown-link:hover,
.profile-dropdown-logout:hover {
    background: color-mix(in srgb, var(--brand-1) 12%, transparent);
}

.profile-dropdown-logout {
    color: #dc2626;
    cursor: pointer;
}

.logout-btn,
.button-link,
button {
    border: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 15px;
    padding: 11px 14px;
    border-radius: 12px;
    background: linear-gradient(90deg, var(--brand-1), var(--brand-1-end));
    color: #fff;
    font-weight: 700;
}

.logout-btn {
    background: var(--surface);
    color: var(--danger);
    border: 1px solid var(--danger-line);
}

.button-link.secondary {
    background: var(--surface);
    color: var(--ink-900);
    border: 1px solid var(--line);
}

.panel-card,
.hero-grid {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.84);
    backdrop-filter: blur(8px);
    box-shadow: 0 16px 40px rgba(18, 34, 42, 0.06);
}

.panel-card {
    padding: 20px;
}

.hero-grid {
    padding: 22px;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
}

.hero-chips {
    margin-top: 16px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.hero-chips span {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    font-size: 14px;
}

.stat-card {
    background: linear-gradient(135deg, #102a43, #0f766e);
    color: #fff;
    border-radius: 14px;
    padding: 16px;
}

.stat-card h3 {
    font-size: 40px;
}

.cards-grid {
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.panel-card.accent {
    background: linear-gradient(135deg, #fff7ed, #fff);
}

.section-head {
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.section-head h2 {
    font-size: clamp(22px, 2vw, 26px);
}

.section-head p {
    margin: 4px 0 0;
    color: var(--ink-700);
}

.back-link {
    display: inline-flex;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 700;
    color: var(--brand-ink);
}

.back-link:hover {
    text-decoration: underline;
}

.table-wrap {
    overflow: auto;
}

/*
 * A table wider than its card (marked by global.js): the row actions (View / Edit / Delete) stay
 * pinned on the right while the other columns scroll under them, with a soft edge until the end.
 */
.table-wrap.is-scrollable.has-row-actions tr > :is(th, td):last-child:not([colspan]) {
    position: sticky;
    right: 0;
    z-index: 1;
    box-shadow: -12px 0 12px -12px rgba(18, 34, 42, 0.28);
    transition: box-shadow .15s;
}
.table-wrap.is-scrollable.has-row-actions tbody tr > td:last-child:not([colspan]) { background-color: var(--surface); }
.table-wrap.is-scrollable.has-row-actions tbody tr:hover > td:last-child:not([colspan]) { background-color: color-mix(in srgb, var(--surface), #000 2%); }
.table-wrap.is-scrollable.has-row-actions .audit-table tbody tr:hover > td:last-child { background-color: color-mix(in srgb, var(--brand-1) 4%, var(--surface)); }
.table-wrap.is-scrolled-end.has-row-actions tr > :is(th, td):last-child { box-shadow: none; }
:root[data-theme="dark"] .table-wrap.is-scrollable.has-row-actions tr > :is(th, td):last-child:not([colspan]) { box-shadow: -12px 0 12px -12px rgba(0, 0, 0, 0.6); }
:root[data-theme="dark"] .table-wrap.is-scrolled-end.has-row-actions tr > :is(th, td):last-child { box-shadow: none; }

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th,
td {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    vertical-align: middle;
}

/* One look for every list table: small uppercase header on a light band, rows centred. */
th {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-400);
    background: var(--surface-2);
    border-bottom: 2px solid var(--line);
    padding: 10px 14px;
    white-space: nowrap;
}

tbody tr:hover td { background: rgba(0, 0, 0, .02); }

.actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.actions button {
    background: var(--surface);
    color: var(--danger);
    border: 1px solid var(--danger-line);
    padding: 8px 12px;
}

/* Row actions (View / Edit / Delete) as a cell: a flex cell breaks the row's border line. */
td.actions { display: table-cell; white-space: nowrap; width: 1%; }
/* Codes that must not break mid-way (e.g. an IT label "HAK-IKA-001"). */
td.nowrap { white-space: nowrap; }
td.actions > a,
td.actions > form,
td.actions > button { display: inline-block; vertical-align: middle; margin: 2px 6px 2px 0; }
td.actions > form { margin-right: 0; }
td.actions > a {
    padding: 6px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink-900);
    text-decoration: none;
    background: var(--surface);
}
td.actions > a:hover { border-color: var(--brand-1); color: var(--brand-ink); }
td.actions button { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.actions button.actions-login-as { color: var(--brand-ink); border-color: color-mix(in srgb, var(--brand-ink) 35%, var(--line)); }
.actions button.actions-login-as:hover { background: color-mix(in srgb, var(--brand-ink) 10%, var(--surface)); }
td.actions > form:has(.actions-login-as) { margin-right: 6px; }

/* "Login as": a Super Admin signed in as another user. */
.impersonation-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; padding: 10px 12px 10px 16px; border: 1px solid #fcd34d; border-radius: 12px; background: #fffbeb; color: #78350f; font-size: 15px; }
.impersonation-bar > svg { width: 20px; height: 20px; flex: none; }
.impersonation-bar > span { flex: 1; min-width: 0; }
.impersonation-bar form { flex: none; }
.impersonation-bar-btn { padding: 8px 14px; border: 1px solid #b45309; border-radius: 10px; background: #b45309; color: #fff; font-size: 14px; font-weight: 700; cursor: pointer; }
.impersonation-bar-btn:hover { background: #92400e; border-color: #92400e; }
:root[data-theme="dark"] .impersonation-bar { border-color: rgba(251, 191, 36, 0.45); background: rgba(251, 191, 36, 0.12); color: #fde68a; }
.audit-impersonator { display: block; margin-top: 2px; color: var(--text-muted); font-size: 12px; font-weight: 500; }
@media (max-width: 640px) {
    .impersonation-bar { flex-wrap: wrap; }
    .impersonation-bar form, .impersonation-bar-btn { width: 100%; }
}

.pill {
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
}

.pill.on {
    color: #065f46;
    background: #d1fae5;
}

.pill.off {
    color: #7f1d1d;
    background: #fee2e2;
}

:root[data-theme="dark"] .pill.on,
:root[data-theme="dark"] .ws-badge-on,
:root[data-theme="dark"] .ws-badge-active { color: #86efac; background: color-mix(in srgb, #22c55e 16%, transparent); }
:root[data-theme="dark"] .pill.off { color: #fca5a5; background: color-mix(in srgb, #ef4444 16%, transparent); }
:root[data-theme="dark"] .cts-modal-icon { background: color-mix(in srgb, #ef4444 16%, transparent); }
:root[data-theme="dark"] .cts-modal-overlay.is-positive .cts-modal-icon { background: color-mix(in srgb, #2dd4bf 16%, transparent); }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

/* Keep fields at their natural height instead of stretching to the tallest item in the row */
.form-grid > label {
    align-content: start;
    min-width: 0;
}

label {
    display: grid;
    gap: 7px;
    font-size: 15px;
    font-weight: 700;
}

.field-label {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 700;
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.permission-item {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 10px;
    padding: 8px 10px;
}

input,
textarea,
select {
    border: 1px solid var(--line);
    min-width: 0;
    max-width: 100%;
    /* background-color only: select keeps its arrow (background-image) in both themes. */
    background-color: var(--surface);
    border-radius: 11px;
    padding: 11px 12px;
    font: inherit;
    color: var(--ink-900);
    min-height: 44px;
}

input[type="date"] {
    font-family: 'Space Grotesk', sans-serif;
    letter-spacing: 0.03em;
}

input[type="file"] {
    padding: 8px;
    border-style: dashed;
    cursor: pointer;
}

select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--ink-700) 50%), linear-gradient(135deg, var(--ink-700) 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 36px;
}

input:focus,
textarea:focus,
select:focus {
    outline: 3px solid rgba(15, 118, 110, 0.2);
    border-color: var(--brand-1);
}

.file-link {
    display: inline-flex;
    margin-top: 4px;
    font-size: 13px;
    color: var(--brand-ink);
    text-decoration: underline;
}

.span-2 {
    grid-column: span 2;
}

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

.password-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrap input {
    width: 100%;
    padding-right: 42px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    line-height: 1;
}

.password-toggle:hover {
    color: var(--text);
}

.switch-wrap input {
    width: 18px;
    height: 18px;
    min-height: auto;
}

.form-actions {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.form-actions button,
.form-actions .button-link {
    min-width: 110px;
    text-align: center;
}

.form-actions-top {
    margin: 0 0 6px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.form-actions:not(.form-actions-top) {
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.alert-success,
.alert-error {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.alert-success {
    border: 1px solid #a7f3d0;
    background: #ecfdf5;
    color: #065f46;
}

.alert-error {
    border: 1px solid #fecaca;
    background: #fff1f2;
    color: #881337;
}

.alert-error ul {
    margin: 8px 0 0 18px;
}

/* A page message with its × (close) button. */
.alert-flash { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-right: 6px; }
.alert-flash > span { min-width: 0; }
.alert-close { flex: none; width: 40px; height: 40px; display: inline-grid; place-items: center; padding: 0; border: 0; border-radius: 10px; background: transparent; color: inherit; opacity: .75; cursor: pointer; }
.alert-close:hover { opacity: 1; background: color-mix(in srgb, currentColor 10%, transparent); }
.alert-close:focus-visible { opacity: 1; outline: 2px solid currentColor; outline-offset: 1px; }

/* Toast notifications (file validation, upload feedback) */
#cts-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.cts-toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14.5px;
    font-weight: 500;
    max-width: 340px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    pointer-events: auto;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity .2s, transform .2s;
}
.cts-toast.show { opacity: 1; transform: translateX(0); }
.cts-toast.hide { opacity: 0; transform: translateX(20px); }
.cts-toast-error {
    background: #fff1f2;
    border: 1px solid #fecaca;
    color: #881337;
}
.cts-toast-success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}
.cts-toast-icon { flex-shrink: 0; margin-top: 1px; }
.cts-toast-close {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: .6;
    font-size: 16px;
    padding: 0 0 0 8px;
    line-height: 1;
    flex-shrink: 0;
}
.cts-toast-close:hover { opacity: 1; }
:root[data-theme="dark"] .cts-toast-error {
    background: #2d0e12;
    border-color: #7f1d1d;
    color: #fca5a5;
}
:root[data-theme="dark"] .cts-toast-success {
    background: #052e16;
    border-color: #166534;
    color: #86efac;
}

:root[data-theme="dark"] .topbar,
:root[data-theme="dark"] .panel-card,
:root[data-theme="dark"] .hero-grid,
:root[data-theme="dark"] .dashboard-banner,
:root[data-theme="dark"] .kpi-card,
:root[data-theme="dark"] .permission-item,
:root[data-theme="dark"] .nav-icon,
:root[data-theme="dark"] .table-wrap,
:root[data-theme="dark"] .alert-success,
:root[data-theme="dark"] .alert-error,
:root[data-theme="dark"] .login-card {
    background: var(--bg-soft);
    color: var(--ink-900);
    border-color: var(--line);
}

:root[data-theme="dark"] .brand small,
:root[data-theme="dark"] .section-head p,
:root[data-theme="dark"] .login-card p {
    color: var(--ink-700);
}

:root[data-theme="dark"] .hero-chips span,
:root[data-theme="dark"] .dashboard-module-badge,
:root[data-theme="dark"] .logout-btn,
:root[data-theme="dark"] .button-link.secondary {
    background: #172933;
    color: var(--ink-900);
    border-color: var(--line);
}

:root[data-theme="dark"] .kpi-primary {
    background: linear-gradient(135deg, #123447, #115e59);
}

.pagination-wrap {
    margin-top: 16px;
}

.dashboard-shell {
    display: grid;
    gap: 18px;
    margin-bottom: 18px;
}

.dashboard-banner {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    background:
        radial-gradient(500px 180px at 100% -10%, rgba(20, 184, 166, 0.25), transparent 70%),
        radial-gradient(400px 200px at 0% 120%, rgba(249, 115, 22, 0.18), transparent 70%),
        rgba(255, 255, 255, 0.84);
    box-shadow: 0 16px 40px rgba(18, 34, 42, 0.06);
    display: grid;
    gap: 10px;
}

.dashboard-kicker {
    margin: 0;
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-700);
    font-weight: 800;
}

.dashboard-banner h2 {
    font-size: clamp(24px, 2.4vw, 34px);
}

.dashboard-banner > p {
    margin: 0;
    color: var(--ink-700);
    max-width: 850px;
}

.dashboard-module-badge {
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    background: #fff;
    font-size: 14px;
    font-weight: 700;
    width: fit-content;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.kpi-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 12px 24px rgba(18, 34, 42, 0.05);
}

.kpi-card p {
    margin: 0;
    font-size: 14px;
    color: var(--ink-700);
    font-weight: 700;
}

.kpi-card h3 {
    margin-top: 8px;
    font-size: clamp(30px, 2.4vw, 40px);
}

.kpi-primary {
    background: linear-gradient(135deg, #102a43, #0f766e);
    border: 0;
    color: #fff;
}

.kpi-primary p {
    color: rgba(255, 255, 255, 0.86);
}

.dashboard-filter-panel {
    padding: 22px;
}

.dashboard-results-wrap {
    margin-top: 14px;
}

.reveal {
    opacity: 0;
    transform: translateY(12px);
    animation: revealIn 0.55s ease forwards;
}

@keyframes revealIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
@keyframes revealFade {
    to { opacity: 1; }
}

@media (max-width: 1080px) {
    .cards-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .theme-toggle span {
        display: none;
    }
}

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

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(86vw, 320px);
        transform: translateX(-110%);
        transition: transform 0.25s ease;
        box-shadow: 0 20px 40px rgba(16, 42, 67, 0.2);
        /* The menu is taller than a phone screen: scroll inside the panel, not the page behind it. */
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }

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

    .backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(10, 16, 25, 0.4);
        border: 0;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    .app-shell.mobile-open .backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .content-wrap {
        padding: 16px;
    }

    /* One row: menu / logo and title on the left, the buttons on the right. */
    .topbar {
        gap: 12px;
        padding: 10px 12px;
    }

    .topbar-actions {
        flex: none;
        flex-wrap: nowrap;
        gap: 8px;
    }

    .title-wrap {
        flex: 1;
        min-width: 0;
    }

    .title-wrap h1 {
        font-size: clamp(20px, 4.6vw, 30px);
        line-height: 1.15;
        margin-top: 0;
        overflow-wrap: break-word;
        hyphens: auto;
    }

    .lang-switch {
        width: 100%;
        justify-content: space-between;
        padding: 6px 10px;
    }

    .lang-switch select {
        min-width: 72px;
    }

    .theme-toggle,
    .profile-trigger {
        min-height: 44px;
        border-radius: 11px;
    }

    .theme-toggle {
        padding: 10px;
    }

    .profile-dropdown {
        right: 0;
        width: min(260px, 92vw);
    }

    .section-head {
        flex-direction: column;
        align-items: stretch;
    }

    .section-head .button-link {
        align-self: flex-start;
        padding: 10px 13px;
        white-space: nowrap;
    }

    .panel-card {
        padding: 16px;
    }

    .table-wrap {
        border: 1px solid var(--line);
        border-radius: 12px;
        -webkit-overflow-scrolling: touch;
    }

    th,
    td {
        padding: 11px 10px;
        font-size: 14px;
    }

    .mobile-menu-btn {
        display: inline-flex;
    }


    .hero-grid,
    .cards-grid,
    .kpi-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-filter-panel {
        padding: 16px;
    }

    .span-2 {
        grid-column: span 1;
    }
}

.login-body {
    min-height: 100vh;
    margin: 0;
    font-family: 'Manrope', sans-serif;
    background:
        radial-gradient(700px 450px at 20% 0%, #bae6fd 0, transparent 60%),
        radial-gradient(700px 450px at 100% 100%, #fed7aa 0, transparent 50%),
        #f8fafc;
}

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(100%, 520px);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 24px;
}

.login-card h1 {
    font-family: 'Space Grotesk', sans-serif;
    margin: 0 0 8px;
}

.login-card p {
    margin: 0 0 14px;
    color: var(--ink-700);
}

.login-hint {
    margin-top: 16px;
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 10px;
    display: grid;
    gap: 2px;
}

.login-hint small {
    color: var(--ink-700);
}
/* ── Role · Permission Access Matrix ── */
.perm-access-wrap {
    margin-top: 6px;
}

.perm-access-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.perm-access-sub {
    margin: 0;
    font-size: 13.5px;
    color: var(--text-muted);
}

.perm-bar {
    position: sticky;
    top: 10px;
    z-index: 10;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 14px;
    box-shadow: 0 4px 14px rgba(15, 118, 110, 0.08);
}

.perm-bar .perm-search {
    flex: 1;
    min-width: 180px;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 7px 12px;
    background: var(--surface-2);
    color: var(--ink-900);
    font-size: 14px;
}

.perm-btn {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-900);
    border-radius: 10px;
    padding: 7px 12px;
    min-height: 38px;
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.perm-btn:hover {
    background: var(--surface-3);
    border-color: color-mix(in srgb, var(--brand-1) 35%, var(--line));
}

.perm-cnt {
    font-size: 13.5px;
    color: var(--text-muted);
    margin-left: auto;
    padding: 0 4px;
}

.perm-cnt b {
    color: var(--brand-ink);
    font-weight: 800;
}

.perm-sec-title {
    font-size: 11.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    margin: 20px 2px 8px;
}

.perm-sec:first-child .perm-sec-title {
    margin-top: 6px;
}

.perm-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    margin-bottom: 10px;
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.perm-hd {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    cursor: pointer;
    user-select: none;
    background: var(--surface);
    transition: background 0.15s ease;
}

.perm-hd:hover {
    background: var(--surface-2);
}

.perm-ab {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: color-mix(in srgb, var(--brand-1) 12%, var(--surface-2));
    color: var(--brand-ink);
    display: grid;
    place-items: center;
    font-size: 11.5px;
    font-weight: 800;
    flex: none;
    border: 1px solid color-mix(in srgb, var(--brand-1) 20%, transparent);
}

.perm-hd-copy {
    min-width: 0;
}

.perm-hd .perm-t {
    font-weight: 700;
    font-size: 14.5px;
    color: var(--ink-900);
}

.perm-hd .perm-m {
    color: var(--text-muted);
    font-size: 12.5px;
}

.perm-badge {
    margin-left: auto;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--brand-1) 12%, var(--surface-2));
    color: var(--brand-ink);
    font-weight: 700;
}

.perm-badge.is-full {
    background: linear-gradient(135deg, var(--brand-1), var(--brand-1-end));
    color: #fff;
}

.perm-chev {
    transition: transform 0.15s ease;
    color: var(--text-muted);
    font-size: 14px;
}

.perm-card.is-closed .perm-chev {
    transform: rotate(-90deg);
}

.perm-card.is-closed .perm-bd {
    display: none;
}

.perm-bd {
    border-top: 1px solid var(--line);
    overflow-x: auto;
}

.perm-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 540px;
}

.perm-table th {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
    padding: 9px 8px;
    background: var(--surface-2);
    text-align: center;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: color 0.15s ease, background 0.15s ease;
}

.perm-table th[data-perm-col]:hover {
    color: var(--brand-ink);
    background: var(--surface-3);
}

.perm-table th:first-child {
    text-align: left;
    padding-left: 14px;
    cursor: default;
    width: 42%;
}

.perm-table td {
    padding: 9px 8px;
    border-top: 1px solid var(--line);
    text-align: center;
    vertical-align: middle;
}

.perm-table td:first-child {
    text-align: left;
    padding-left: 14px;
}

.perm-table tr.perm-child td:first-child {
    padding-left: 34px;
    position: relative;
}

.perm-table tr.perm-child td:first-child::before {
    content: "";
    position: absolute;
    left: 20px;
    top: 0;
    bottom: 50%;
    width: 8px;
    border-left: 2px solid var(--line);
    border-bottom: 2px solid var(--line);
    border-radius: 0 0 0 6px;
}

.perm-rn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-900);
}

.perm-tag {
    font-size: 10.5px;
    padding: 2px 7px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--brand-1) 12%, var(--surface-2));
    color: var(--brand-ink);
    font-weight: 700;
}

.perm-tag.is-shared {
    background: #fef3c7;
    color: #92400e;
}

:root[data-theme="dark"] .perm-tag.is-shared {
    background: color-mix(in srgb, #f59e0b 18%, transparent);
    color: #fcd34d;
}

.perm-access-wrap input[type="checkbox"] {
    width: 17px;
    height: 17px;
    min-height: auto;
    padding: 0;
    accent-color: var(--brand-1);
    cursor: pointer;
    vertical-align: middle;
}

.perm-dash {
    color: var(--line);
    font-weight: 600;
}

.perm-other-wrap {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.perm-ot {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-700);
    cursor: pointer;
}

.perm-access-wrap input[type="checkbox"].is-overridden {
    outline: 2px solid color-mix(in srgb, var(--brand-2) 65%, transparent);
    outline-offset: 2px;
    border-radius: 3px;
}

.perm-table tr.is-hidden {
    display: none;
}

/* ── Web Settings > What's New ── */
.ws-whats-new-form {
    margin-bottom: 20px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.ws-whats-new-list {
    display: grid;
    gap: 12px;
}

.ws-whats-new-item {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 16px;
    background: var(--surface);
}

.ws-whats-new-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--line);
    font-size: 13.5px;
    color: var(--text-muted);
}

.ws-whats-new-meta time {
    font-weight: 700;
    color: var(--brand-ink);
}

.ws-whats-new-del {
    margin-left: auto;
}

.ws-whats-new-del .button-link {
    padding: 5px 11px;
    min-height: 32px;
    font-size: 13px;
}

.ws-whats-new-body {
    font-size: 15px;
    line-height: 1.6;
    color: var(--ink-900);
}

/* ── User Form > MS365 Checkbox under Email ── */
.user-email-group {
    display: grid;
    gap: 10px;
    align-content: start;
}

.user-ms365-box {
    display: grid;
    gap: 10px;
}

.user-ms365-check {
    cursor: pointer;
}

.user-ms365-purchase[hidden] {
    display: none;
}

/* ── Dashboard search bar ── */
/* Keyboard focus in a search bar's text field rings the whole bar (the field itself has no border). */
.db-search-bar:has(.db-search-input:focus-visible),
.dash-search:has(.dash-search-text input:focus-visible) {
    border-color: var(--brand-1);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-1) 22%, transparent);
}
.db-search-input:focus { outline: none; }

.db-search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px 14px;
    margin-bottom: 16px;
}
.db-search-input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 15px;
    flex: 1;
    min-width: 0;
    color: var(--ink-700);
    padding: 2px 0;
}
/* Placeholders: secondary text colour (at least 4.5:1); the browser default grey falls under it on soft surfaces. */
input::placeholder,
textarea::placeholder { color: var(--ink-400); opacity: 1; }
.db-search-sep {
    width: 1px;
    height: 20px;
    background: var(--line);
    flex-shrink: 0;
}
.db-date-input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    color: var(--ink-700);
    padding: 2px 0;
    flex-shrink: 0;
}
.db-search-btn {
    background: linear-gradient(90deg, var(--brand-1), var(--brand-1-end));
    color: #fff;
    border: none;
    border-radius: 9px;
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: opacity .15s;
}
.db-search-btn:hover { opacity: .85; }
.db-reset-btn {
    font-size: 14px;
    color: var(--ink-400);
    text-decoration: none;
    padding: 4px 4px;
    white-space: nowrap;
    flex-shrink: 0;
}
.db-reset-btn:hover { color: var(--danger); }

/* ── Legend ── */
.db-legend {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.db-legend-item {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
}
.legend-30d  { background: #fffbe6; color: #92400e; border: 1px solid #fde68a; }
.legend-3d   { background: #fce4ec; color: #9d174d; border: 1px solid #f9a8d4; }
.legend-1d   { background: #ffebee; color: #991b1b; border: 1px solid #fca5a5; }
.legend-expired { background: #ffcdd2; color: #7f1d1d; border: 1px solid #f87171; }

/* ── Dashboard table ── */
.db-table th {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-400);
    padding: 10px 14px;
    background: var(--surface-2);
    border-bottom: 2px solid var(--line);
}
.db-table td { padding: 13px 14px; vertical-align: middle; }
.db-table tbody tr:hover td { background: rgba(0,0,0,.02); }
.cert-type-cell { font-weight: 600; }
.empty-row { text-align: center; color: var(--ink-400); padding: 40px !important; }

/* ── Days left badges ── */
.days-badge {
    display: inline-block;
    font-size: 13px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}
.days-badge.safe    { background: #ecfdf5; color: #065f46; }
.days-badge.d30     { background: #fef9c3; color: #854d0e; }
.days-badge.d3      { background: #fce7f3; color: #9d174d; }
.days-badge.d1      { background: #fee2e2; color: #991b1b; }
.days-badge.expired { background: #fecaca; color: #7f1d1d; }

/* ── Nav group (collapsible) ── */
.nav-group { display: flex; flex-direction: column; }
.nav-group-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 12px;
    color: var(--ink-700);
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: all 0.2s ease;
    font-size: inherit;
    font-family: inherit;
    font-weight: inherit;
}
.nav-group-toggle:hover,
.nav-group.open .nav-group-toggle {
    color: #fff;
    background: linear-gradient(90deg, var(--brand-1), var(--brand-1-end));
    transform: translateX(2px);
}
.nav-group-toggle:hover .nav-icon,
.nav-group.open .nav-group-toggle .nav-icon {
    border-color: rgba(255,255,255,0.4);
    background: rgba(255,255,255,0.16);
}
.nav-group-chevron {
    width: 16px;
    height: 16px;
    margin-left: auto;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
.nav-group.open .nav-group-chevron { transform: rotate(180deg); }
.nav-group-sub {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding-left: 16px;
    margin-top: 4px;
}
.nav-group.open .nav-group-sub { display: flex; }
.nav-group-sub a { padding: 7px 10px; font-size: 0.9em; }
/* Collapsed sidebar (icons only): desktop only. */
@media (min-width: 901px) {
    .app-shell[data-sidebar-state="collapsed"] .nav-group-toggle .nav-text,
    .app-shell[data-sidebar-state="collapsed"] .nav-group-chevron,
    .app-shell[data-sidebar-state="collapsed"] .nav-group-sub { display: none; }
    .app-shell[data-sidebar-state="collapsed"] .nav-group-toggle { justify-content: center; }
}

/* ── Sidebar head: brand + toggle sejajar ── */
.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
}
.sidebar-head .brand {
    margin-bottom: 0;
    padding: 4px 6px;
    flex: 1;
    min-width: 0;
}
/* Collapsed sidebar (icons only): desktop only. */
@media (min-width: 901px) {
    .app-shell[data-sidebar-state="collapsed"] .sidebar-head {
        flex-direction: column;
        gap: 8px;
        align-items: center;
    }
}

/* ── Legend fixes: bigger text + 1 day darker ── */
.db-legend-item {
    font-size: 14px;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 999px;
    text-decoration: none;
    transition: opacity .15s, box-shadow .15s;
    cursor: pointer;
}

.db-legend-item:hover { opacity: .8; }
.db-legend-item.legend-active { box-shadow: 0 0 0 2px currentColor; }

.legend-30d  { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
.legend-3d   { background: #fce7f3; color: #9d174d; border: 1px solid #f9a8d4; }
.legend-1d   { background: #fee2e2; color: #7f1d1d; border: 1px solid #f87171; }
.legend-expired { background: #fecaca; color: #450a0a; border: 1px solid #ef4444; }

/* ── Web Settings accordion ── */
.ws-accordion { display: flex; flex-direction: column; gap: 8px; }

.ws-item {
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    transition: box-shadow .2s;
}

.ws-item.open { box-shadow: 0 4px 16px rgba(0,0,0,.06); }

.ws-header {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: var(--surface);
    color: var(--ink-900);
    border: none;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    font-size: inherit;
    transition: background .15s;
}

.ws-header:hover { background: var(--surface-2); }
.ws-item.open .ws-header { background: var(--surface-3); border-bottom: 1px solid var(--line); }

.ws-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    flex-shrink: 0;
}

.ws-label { font-size: 15px; font-weight: 700; flex: 1; color: var(--ink-900); }

.ws-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    flex-shrink: 0;
}

.ws-badge-on  { background: #d1fae5; color: #065f46; }
.ws-badge-off { background: var(--surface-3); color: var(--ink-400); }

.ws-chevron { flex-shrink: 0; opacity: .4; transition: transform .2s; }
.ws-item.open .ws-chevron { transform: rotate(180deg); opacity: .7; }

.ws-body { display: none; padding: 8px 16px 12px; }
.ws-item.open .ws-body { display: block; }

.ws-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 400;
    transition: background .12s;
}

.ws-row:hover { background: var(--surface-2); }
.ws-row input[type="checkbox"] { flex-shrink: 0; width: 15px; height: 15px; accent-color: var(--brand-1); }
.ws-name { font-size: 14px; font-weight: 600; min-width: 140px; }
.ws-email { font-size: 13px; color: var(--ink-400); }

/* ── Dark mode: days badges ── */
:root[data-theme="dark"] .days-badge.safe    { background: rgba(6,95,70,.4);   color: #6ee7b7; }
:root[data-theme="dark"] .days-badge.d30     { background: rgba(120,53,15,.4); color: #fde68a; }
:root[data-theme="dark"] .days-badge.d3      { background: rgba(131,24,67,.4); color: #f9a8d4; }
:root[data-theme="dark"] .days-badge.d1      { background: rgba(127,29,29,.4); color: #fca5a5; }
:root[data-theme="dark"] .days-badge.expired { background: rgba(127,29,29,.5); color: #f87171; }

/* ── Dark mode: legend items ── */
:root[data-theme="dark"] .legend-30d    { background: rgba(120,53,15,.35);  color: #fde68a; border-color: rgba(202,138,4,.4); }
:root[data-theme="dark"] .legend-3d     { background: rgba(131,24,67,.35);  color: #f9a8d4; border-color: rgba(190,24,93,.4); }
:root[data-theme="dark"] .legend-1d     { background: rgba(127,29,29,.35);  color: #fca5a5; border-color: rgba(185,28,28,.4); }
:root[data-theme="dark"] .legend-expired{ background: rgba(100,20,20,.45);  color: #f87171; border-color: rgba(153,27,27,.5); }

/* ── Dark mode: search bar & table ── */
:root[data-theme="dark"] .db-search-bar { background: #122029; border-color: var(--line); }
:root[data-theme="dark"] .db-search-input,
:root[data-theme="dark"] .db-date-input { color: var(--ink-900); }
:root[data-theme="dark"] .db-search-sep { background: var(--line); }
:root[data-theme="dark"] .db-table th   { background: #0f1e26; color: #6b9aaa; border-bottom-color: var(--line); }
:root[data-theme="dark"] .db-table td   { border-bottom-color: var(--line); }
:root[data-theme="dark"] .db-table tbody tr:hover td { background: rgba(255,255,255,.03); }

/* ── Pagination ── */
.cts-pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.cts-page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink-700);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all .15s;
}

.cts-page-link:hover {
    color: #fff;
    background: linear-gradient(90deg, var(--brand-1), var(--brand-1-end));
    border-color: transparent;
}

.cts-page-link.active {
    color: #fff;
    background: linear-gradient(90deg, var(--brand-1), var(--brand-1-end));
    border-color: transparent;
    cursor: default;
}

.cts-page-link.disabled {
    opacity: .4;
    cursor: default;
    pointer-events: none;
}

:root[data-theme="dark"] .cts-page-link { background: #122029; color: var(--ink-700); border-color: var(--line); }

/* ── Dashboard clickable row ── */
.db-row-clickable { cursor: pointer; }

/* ── Image gallery ── */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
    margin-top: 4px;
}

.image-gallery-item {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 1;
}

.image-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-gallery-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,.6);
    color: #fff;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.image-gallery-remove:hover { background: var(--danger); }

/* ── Form section divider & nested record list ── */
.form-section-divider {
    margin: 18px 0 4px;
    padding-top: 14px;
    border-top: 1px dashed var(--line);
}

.form-section-divider h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--brand-ink);
}

.form-section-divider h3 small {
    font-weight: 400;
    font-size: 13px;
    color: var(--ink-400);
}

.nested-record-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nested-record-list li a {
    font-size: 14px;
    color: var(--brand-ink);
    text-decoration: underline;
}

/* ── Web Settings: reminder days ── */
.ws-reminder-days {
    margin-bottom: 20px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-2);
}

.ws-reminder-days label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ws-reminder-days strong { font-size: 15px; }

.ws-reminder-days small {
    font-weight: 400;
    color: var(--ink-400);
    font-size: 13px;
}

.ws-reminder-days input {
    margin-top: 6px;
    max-width: 280px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    font-size: 15px;
}

/* ── File input with preview ── */
.cts-file-field, .cts-multi-file-field { display: flex; flex-direction: column; gap: 7px; font-size: 15px; font-weight: 700; }
.cts-file-label { font-size: 15px; font-weight: 700; }

.cts-file-drop, .cts-multi-drop {
    border: 1.5px dashed var(--line);
    border-radius: 12px;
    background: var(--surface-2);
    padding: 16px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-align: center;
    min-height: 90px;
}

.cts-file-drop:hover, .cts-multi-drop:hover,
.cts-file-drop.drag-over, .cts-multi-drop.drag-over {
    border-color: var(--brand-1);
    background: color-mix(in srgb, var(--brand-1) 6%, transparent);
}

.cts-file-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--ink-400); }
.cts-file-empty span { font-size: 14px; font-weight: 600; }
.cts-file-empty small { font-size: 12px; font-weight: 400; }

.cts-multi-drop span { font-size: 14px; font-weight: 600; color: var(--ink-400); }
.cts-multi-drop small { font-size: 12px; font-weight: 400; color: var(--ink-400); }

.cts-file-preview {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.cts-file-empty[hidden], .cts-file-preview[hidden] { display: none; }

.cts-file-preview img {
    max-width: 100%;
    max-height: 110px;
    border-radius: 8px;
    object-fit: cover;
}

.cts-file-doc {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-700);
}

.cts-file-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--danger);
    color: #fff;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cts-file-current {
    font-size: 13px;
    color: var(--brand-ink);
    text-decoration: underline;
}

.cts-multi-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

.cts-multi-thumb {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 6px;
    background: #fff;
}

.cts-multi-thumb img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
}

.cts-multi-thumb-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: var(--danger);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cts-multi-thumb span {
    font-size: 12px;
    color: var(--ink-400);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

:root[data-theme="dark"] .cts-file-drop,
:root[data-theme="dark"] .cts-multi-drop { background: #122029; border-color: var(--line); }
:root[data-theme="dark"] .cts-file-doc,
:root[data-theme="dark"] .cts-multi-thumb { background: #122029; color: var(--ink-900); }

/* ── Custom confirm/alert modal (replaces native browser popups) ── */
.cts-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 30, 0.55);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity .15s ease;
}

.cts-modal-overlay.open { opacity: 1; }
.cts-modal-overlay[hidden] { display: none; }

.cts-modal {
    background: #fff;
    border-radius: 18px;
    padding: 28px 28px 22px;
    max-width: 380px;
    width: calc(100% - 40px);
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
    transform: translateY(8px) scale(.97);
    transition: transform .15s ease;
}

.cts-modal-overlay.open .cts-modal { transform: translateY(0) scale(1); }

.cts-modal-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #fee2e2;
    color: var(--danger);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.cts-modal-message {
    font-size: 16px;
    font-weight: 600;
    color: var(--ink-900);
    margin: 0 0 20px;
    line-height: 1.5;
}

.cts-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.cts-modal-actions button {
    flex: 1;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: opacity .15s;
}

.cts-modal-cancel {
    background: var(--surface-2);
    color: var(--ink-700);
}

.cts-modal-cancel:hover { opacity: .8; }

.cts-modal-ok {
    background: var(--danger);
    color: #fff;
}

.cts-modal-ok:hover { opacity: .9; }

/* Positive confirm (approve, save): check icon, brand button. */
.cts-modal-icon-ok, .cts-modal-overlay.is-positive .cts-modal-icon-warn { display: none; }
.cts-modal-overlay.is-positive .cts-modal-icon-ok { display: block; }
.cts-modal-overlay.is-positive .cts-modal-icon { background: color-mix(in srgb, var(--brand-1, #0f766e) 14%, var(--surface)); color: var(--brand-ink); }
.cts-modal-overlay.is-positive .cts-modal-ok { background: var(--brand-1, #0f766e); }

:root[data-theme="dark"] .cts-modal { background: #122029; }
:root[data-theme="dark"] .cts-modal-message { color: var(--ink-900); }
:root[data-theme="dark"] .cts-modal-cancel { background: #1a2c36; color: var(--ink-700); }

/* ── Multi-file thumb: doc (non-image) preview ── */
.cts-multi-thumb-doc {
    width: 100%;
    height: 80px;
    border-radius: 6px;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-400);
}

/* ── Generic edit-record modal (Insurance/VPC inside Vehicle/Machinery) ── */
.cts-edit-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 30, 0.55);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 1000;
    opacity: 0;
    transition: opacity .15s ease;
    padding: 32px 16px;
}

.cts-edit-modal-overlay[hidden] { display: none; }
.cts-edit-modal-overlay.open { opacity: 1; }

.cts-edit-modal {
    background: #fff;
    border-radius: 18px;
    padding: 28px;
    max-width: 720px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
    transform: translateY(8px) scale(.97);
    transition: transform .15s ease;
    /* vertically center when content is shorter than viewport */
    margin: auto;
}

.cts-edit-modal-overlay.open .cts-edit-modal { transform: translateY(0) scale(1); }

.cts-edit-modal h3 {
    margin: 0 0 20px;
    font-size: 17px;
    font-weight: 700;
}

.cts-edit-modal-form { display: block; }

.cts-edit-modal-body { margin-bottom: 0; }

.cts-edit-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.cts-edit-modal-actions button[type="submit"] {
    background: linear-gradient(90deg, var(--brand-1), var(--brand-1-end));
    color: #fff;
    border: none;
    border-radius: 9px;
    padding: 10px 20px;
    font-weight: 700;
    cursor: pointer;
}

.cts-edit-modal-actions button[type="button"] {
    background: var(--surface-2);
    color: var(--ink-700);
    border: none;
    border-radius: 9px;
    padding: 10px 20px;
    font-weight: 700;
    cursor: pointer;
}

:root[data-theme="dark"] .cts-edit-modal { background: #122029; }

/* ── Nested record list (Insurance/VPC inside Vehicle/Machinery) ── */
.nested-record-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nested-record-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
    font-size: 14px;
}

.nested-record-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.nested-record-actions button {
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.nested-record-actions .btn-edit { color: var(--brand-ink); }
.nested-record-actions .btn-edit:hover { background: rgba(15,118,110,.1); }
.nested-record-actions .btn-delete { color: var(--danger); }
.nested-record-actions .btn-delete:hover { background: rgba(194,65,12,.1); }

.image-gallery-doc {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--surface-2);
    color: var(--ink-700);
    padding: 8px;
    text-align: center;
}

.image-gallery-doc span {
    font-size: 12px;
    word-break: break-all;
    line-height: 1.3;
}

/* ── Nested section (Insurance/VPC list below Vehicle/Machinery form) ── */
.nested-section {
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
}

.nested-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.nested-section-head h3 { font-size: 16px; }

.nested-section-head .button-link {
    background: linear-gradient(90deg, var(--brand-1), var(--brand-1-end));
    color: #fff;
    border: none;
    border-radius: 9px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.nested-section-head .button-link:hover { opacity: .9; }

.nested-section-empty {
    color: var(--ink-400);
    font-size: 14px;
    padding: 14px;
    background: var(--surface-2);
    border-radius: 10px;
    text-align: center;
}

/* ── Nested table (Insurance/VPC rows) ── */
.nested-table {
    width: 100%;
    border-collapse: collapse;
}

.nested-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-400);
    padding: 8px 12px;
    border-bottom: 2px solid var(--line);
    background: var(--surface-2);
}

.nested-table td {
    padding: 10px 12px;
    font-size: 14px;
    border-bottom: 1px solid var(--line);
}

.nested-table tbody tr:hover td { background: var(--surface-2); }

.nested-table .nested-record-actions {
    display: flex;
    gap: 8px;
    white-space: nowrap;
}

.nested-table .nested-record-actions button {
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.nested-table .btn-edit { color: var(--brand-ink); }
.nested-table .btn-edit:hover { background: rgba(15,118,110,.1); }
.nested-table .btn-delete { color: var(--danger); }
.nested-table .btn-delete:hover { background: rgba(194,65,12,.1); }

:root[data-theme="dark"] .nested-table th,
:root[data-theme="dark"] .nested-section-empty { background: #0f1e26; }

/* ── Page tabs (Vehicle/Machinery edit) ── */
.cts-tabs { margin-top: 8px; }

.cts-tab-nav {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--line);
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.cts-tab-btn {
    position: relative;
    padding: 12px 22px;
    font-size: 16px;
    font-weight: 600;
    color: var(--ink-400);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    transition: color .15s, background .15s;
    display: flex;
    align-items: center;
    gap: 7px;
}

.cts-tab-btn:hover { color: var(--ink-900, #111); background: var(--surface-2); }

.cts-tab-btn.active {
    color: var(--brand-ink);
    border-bottom-color: var(--brand-1, #0f766e);
    background: none;
}

.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    font-size: 12px;
    font-weight: 700;
    background: var(--surface-2);
    color: var(--brand-ink);
    border-radius: 10px;
}

.cts-tab-btn.active .tab-badge {
    background: var(--brand-1, #0f766e);
    color: #fff;
}

.cts-tab-panel { display: block; }
.cts-tab-panel[hidden] { display: none; }

:root[data-theme="dark"] .cts-tab-btn:hover { background: rgba(255,255,255,.05); color: #e2e8f0; }
:root[data-theme="dark"] .cts-tab-btn.active { color: #2dd4bf; border-bottom-color: #2dd4bf; }
:root[data-theme="dark"] .tab-badge { background: rgba(45,212,191,.12); color: #2dd4bf; }
:root[data-theme="dark"] .cts-tab-btn.active .tab-badge { background: #2dd4bf; color: #0f2027; }

.input-upper { text-transform: uppercase; }
.input-upper::placeholder { text-transform: none; }

/* Assets management */
.asset-filter-bar { flex-wrap: wrap; }
.asset-filter-bar .db-search-input { min-width: 220px; }
.asset-filter-select { min-height: 36px; padding: 6px 30px 6px 10px; font-size: 14px; border-radius: 9px; background-position: calc(100% - 15px) calc(50% - 2px), calc(100% - 10px) calc(50% - 2px); }
.asset-row-disposed td { background: rgba(194, 65, 12, 0.07); color: var(--ink-700); }
.asset-row-disposed td strong { text-decoration: line-through; }
.asset-serial { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-all; max-width: 220px; }
.asset-muted { color: var(--ink-700); font-size: 13px; font-weight: 500; opacity: .8; }
.form-section-divider.form-section-first { margin-top: 0; padding-top: 0; border-top: 0; }
:root[data-theme="dark"] .asset-row-disposed td { background: rgba(253, 164, 175, 0.08); }
.spec-field { display: flex; flex-direction: column; gap: 8px; }
.spec-head, .spec-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.4fr) 40px; gap: 8px; align-items: center; }
.spec-head span { color: var(--ink-700); font-size: 13px; font-weight: 600; }
.spec-list { display: flex; flex-direction: column; gap: 8px; }
.spec-row input { width: 100%; min-width: 0; }
.spec-row input:first-child { font-weight: 700; }
.spec-remove { width: 40px; height: 40px; padding: 0; border-radius: 10px; background: none; border: 1px solid var(--line); color: var(--ink-700); font-size: 18px; line-height: 1; }
.spec-remove:hover { color: var(--danger); border-color: var(--danger); }
.spec-add { align-self: flex-start; padding: 6px 2px; background: none; color: var(--brand-ink); font-size: 14px; }
.spec-add:hover { text-decoration: underline; }
@media (max-width: 900px) {
    .spec-head { display: none; }
    .spec-row { grid-template-columns: minmax(0, 1fr) 40px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
    .spec-row input:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
}
.spec-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.spec-paste { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px dashed var(--line); border-radius: 12px; }
.spec-paste[hidden] { display: none; }
.spec-paste textarea { width: 100%; resize: vertical; }
textarea[data-autogrow] { resize: vertical; min-height: 44px; overflow: hidden; line-height: 1.45; }
.asset-more { display: inline-block; margin-left: 4px; padding: 1px 6px; border-radius: 999px; background: rgba(15, 118, 110, 0.1); color: var(--brand-ink); font-size: 12px; font-weight: 700; white-space: nowrap; }

/* Web settings: email configuration */
.form-section-divider p { margin: 4px 0 0; }
.ws-inline-check { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 14px; font-weight: 500; }
.ws-inline-check input { width: 16px; height: 16px; min-height: auto; }
.ws-test-mail { margin-top: 8px; }
.ws-test-mail-row { display: flex; gap: 10px; margin-top: 10px; max-width: 560px; }
.ws-test-mail-row input { flex: 1; min-width: 0; }
@media (max-width: 640px) { .ws-test-mail-row { flex-direction: column; } }

/* ── Form cards (grouped sections inside a form) ── */
.form-grid:has(> .form-card) { row-gap: 18px; }
.form-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--bg-soft);
    padding: 18px 20px 20px;
    box-shadow: 0 4px 14px rgba(18, 34, 42, 0.04);
    min-width: 0;
}
.form-card-head {
    margin: -2px 0 16px;
    padding: 0 0 12px 12px;
    border-bottom: 1px solid var(--line);
    border-left: 4px solid var(--brand-1);
}
.form-card-head h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    color: var(--ink-900);
}
.form-card-head p { margin: 4px 0 0; color: var(--ink-700); font-size: 14px; }
.form-card-badge {
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(249, 115, 22, 0.12);
    color: #c2410c;
    font-family: 'Manrope', sans-serif;
    font-size: 12px;
    font-weight: 700;
}
:root[data-theme="dark"] .form-card-badge { color: #fdba74; }
.form-card .form-grid { gap: 14px; }

/* ── Expiry cards on module lists ── */
.expiry-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.expiry-card {
    --tone: var(--brand-1);
    --tone-bg: rgba(15, 118, 110, 0.08);
    display: grid;
    gap: 4px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-left: 5px solid var(--tone);
    border-radius: 14px;
    background: var(--bg-soft);
    box-shadow: 0 4px 14px rgba(18, 34, 42, 0.04);
    transition: transform .15s, box-shadow .15s, background .15s;
}
.expiry-card:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(18, 34, 42, 0.08); }
.expiry-card.is-active { background: var(--tone-bg); border-color: var(--tone); box-shadow: 0 0 0 2px var(--tone-bg); }
.expiry-card-label { font-size: 14px; font-weight: 700; color: var(--ink-700); }
.expiry-card strong { font-family: 'Space Grotesk', sans-serif; font-size: 32px; line-height: 1.1; color: var(--tone); }
.expiry-card small { font-size: 13px; color: var(--ink-700); }
.expiry-card.is-zero strong { color: var(--ink-400); }
.expiry-tone-expired { --tone: #dc2626; --tone-bg: rgba(220, 38, 38, 0.08); }
.expiry-tone-1 { --tone: #ea580c; --tone-bg: rgba(234, 88, 12, 0.08); }
.expiry-tone-2 { --tone: #d97706; --tone-bg: rgba(217, 119, 6, 0.08); }
.expiry-tone-3 { --tone: #ca8a04; --tone-bg: rgba(202, 138, 4, 0.08); }
:root[data-theme="dark"] .expiry-tone-expired { --tone: #f87171; --tone-bg: rgba(248, 113, 113, 0.12); }
:root[data-theme="dark"] .expiry-tone-1 { --tone: #fb923c; --tone-bg: rgba(251, 146, 60, 0.12); }
:root[data-theme="dark"] .expiry-tone-2 { --tone: #fbbf24; --tone-bg: rgba(251, 191, 36, 0.12); }
:root[data-theme="dark"] .expiry-tone-3 { --tone: #facc15; --tone-bg: rgba(250, 204, 21, 0.12); }
:root[data-theme="dark"] .expiry-tone-active { --tone: #2dd4bf; --tone-bg: rgba(45, 212, 191, 0.12); }
.expiry-filter-note { margin: -6px 0 14px; font-size: 14px; color: var(--ink-700); }
.expiry-filter-note a { margin-left: 8px; color: var(--brand-ink); font-weight: 700; }

/* ── Dashboard per-module cards ── */
.module-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
    margin: 18px 0;
}
.module-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--bg-soft);
    padding: 14px;
    display: grid;
    gap: 12px;
    box-shadow: 0 4px 14px rgba(18, 34, 42, 0.04);
    transition: box-shadow .15s, border-color .15s;
}
.module-card:hover { box-shadow: 0 10px 22px rgba(18, 34, 42, 0.08); }
.module-card.is-active { border-color: var(--brand-1); box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.18); }
.module-card-head { display: flex; align-items: center; gap: 10px; }
.module-card-head strong { font-size: 16px; flex: 1; }
.module-card-icon {
    width: 34px; height: 34px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: rgba(15, 118, 110, 0.1); color: var(--brand-ink);
    font-family: 'Space Grotesk', sans-serif; font-size: 13px; font-weight: 700;
}
.module-card-more { font-size: 13px; font-weight: 700; color: var(--brand-ink); opacity: .75; }
.module-card-head:hover .module-card-more { opacity: 1; text-decoration: underline; }
.module-card-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.module-stat {
    --tone: #dc2626; --tone-bg: rgba(220, 38, 38, 0.08);
    display: grid; gap: 2px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--tone-bg);
    border: 1px solid transparent;
    transition: border-color .15s, transform .15s;
}
.module-stat.stat-soon { --tone: #d97706; --tone-bg: rgba(217, 119, 6, 0.1); }
:root[data-theme="dark"] .module-stat { --tone: #f87171; --tone-bg: rgba(248, 113, 113, 0.12); }
:root[data-theme="dark"] .module-stat.stat-soon { --tone: #fbbf24; --tone-bg: rgba(251, 191, 36, 0.12); }
.module-stat:hover { border-color: var(--tone); transform: translateY(-1px); }
.module-stat.is-active { border-color: var(--tone); box-shadow: 0 0 0 2px var(--tone-bg); }
.module-stat strong { font-family: 'Space Grotesk', sans-serif; font-size: 28px; line-height: 1.1; color: var(--tone); }
.module-stat span { font-size: 13px; font-weight: 600; color: var(--ink-700); }
.module-stat.is-zero { --tone: var(--ink-700); --tone-bg: rgba(127, 127, 127, 0.07); }
.module-stat.is-zero strong { color: var(--ink-400); }

.module-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.1);
    color: var(--brand-ink);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}
:root[data-theme="dark"] .module-tag { color: #5eead4; background: rgba(45, 212, 191, 0.12); }

/* ── Detail (read-only) pages ── */
.detail-page { display: grid; gap: 18px; }
.detail-page > .section-head { margin-bottom: 0; }
.detail-head h2 { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.detail-head h2 .pill { font-family: 'Manrope', sans-serif; }
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px 24px;
    margin: 0;
}
.detail-item { min-width: 0; }
.detail-item dt { font-size: 13px; font-weight: 700; color: var(--ink-700); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.detail-item dd { margin: 0; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.detail-wide { grid-column: 1 / -1; }
.detail-empty { color: var(--ink-400); font-weight: 500; margin: 0; }
.detail-muted { color: var(--ink-700); font-size: 14px; font-weight: 500; }
.detail-multiline { white-space: pre-line; }
.detail-link { color: var(--brand-ink); font-weight: 700; text-decoration: underline; text-decoration-color: rgba(15, 118, 110, .35); text-underline-offset: 3px; }
.detail-link:hover { text-decoration-color: currentColor; }
:root[data-theme="dark"] .detail-link { color: #5eead4; }
.detail-file { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--brand-ink); font-size: 14px; font-weight: 700; max-width: 100%; overflow-wrap: anywhere; }
.detail-file:hover { border-color: var(--brand-1); }
.detail-table { min-width: 640px; }
.detail-table td { vertical-align: middle; }
.detail-secret { display: inline-flex; align-items: center; gap: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.detail-secret-toggle { padding: 4px 10px; font-size: 13px; border-radius: 8px; background: none; border: 1px solid var(--line); color: var(--brand-ink); }
.expiry-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 13px; font-weight: 700; background: rgba(15, 118, 110, .1); color: var(--brand-ink); white-space: nowrap; }
.expiry-badge.is-soon { background: rgba(217, 119, 6, .12); color: #b45309; }
.expiry-badge.is-expired { background: rgba(220, 38, 38, .1); color: #b91c1c; }
:root[data-theme="dark"] .expiry-badge { color: #5eead4; }
:root[data-theme="dark"] .expiry-badge.is-soon { color: #fbbf24; }
:root[data-theme="dark"] .expiry-badge.is-expired { color: #f87171; }
/* No expiry date on record: neutral, so it reads as "unknown", not as "fine". */
.expiry-badge.is-none { background: var(--surface-3); color: var(--ink-400); }
:root[data-theme="dark"] .expiry-badge.is-none { color: var(--ink-400); }
/* A list row's validity (x-next-expiry) and a record's validity in its detail header (x-record-validity). */
.next-expiry { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; white-space: nowrap; }
.record-inactive { font-size: 13px; font-weight: 600; color: var(--ink-400); }
.detail-head h2 .record-validity { font-family: 'Manrope', sans-serif; font-size: 13px; vertical-align: middle; }
.detail-head h2 .record-inactive { font-family: 'Manrope', sans-serif; vertical-align: middle; margin-left: 4px; }

/* Valid / Expired highlight of certificate files and periods (<x-validity-badge>, App\Support\Validity) */
.validity-badge { display: inline-block; margin-left: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1.5; vertical-align: middle; white-space: nowrap; }
.validity-badge[hidden] { display: none; }
.validity-badge.is-valid { background: rgba(22, 163, 74, .12); color: #15803d; }
.validity-badge.is-expired { background: rgba(220, 38, 38, .12); color: #b91c1c; }
:root[data-theme="dark"] .validity-badge.is-valid { color: #4ade80; }
:root[data-theme="dark"] .validity-badge.is-expired { color: #f87171; }
.detail-file-wrap.is-expired, .detail-file-wrap.is-valid,
.doc-field-dates.is-expired, .doc-field-dates.is-valid { border: 1px solid; border-radius: 10px; padding: 8px 10px; }
.cts-file-item.is-valid, .detail-file-wrap.is-valid, .doc-field-dates.is-valid { border-color: rgba(22, 163, 74, .4); }
.cts-file-item.is-expired, .detail-file-wrap.is-expired, .doc-field-dates.is-expired { border-color: rgba(220, 38, 38, .35); background: rgba(220, 38, 38, .06); }
.upload-history tr.is-expired td, .upload-history tr.is-current.is-expired td { background: rgba(220, 38, 38, .07); }
:root[data-theme="dark"] .cts-file-item.is-expired, :root[data-theme="dark"] .detail-file-wrap.is-expired,
:root[data-theme="dark"] .doc-field-dates.is-expired, :root[data-theme="dark"] .upload-history tr.is-expired td { background: rgba(248, 113, 113, .1); }
.doc-field-dates > .validity-badge { grid-column: 1 / -1; justify-self: start; margin-left: 0; }
.table-link { color: inherit; font-weight: 700; }
.table-link:hover { color: var(--brand-ink); text-decoration: underline; }

.record-meta { margin: 0; font-size: 13px; color: var(--ink-700); text-align: right; }
.detail-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex-shrink: 0; }
.detail-actions .button-link { min-width: 96px; text-align: center; }

/* ── Document field: upload with its start/end dates ── */
.doc-field {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 16px 16px;
    background: var(--surface-2);
    min-width: 0;
}
.doc-field-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 10px; }
.doc-field-head h4 { margin: 0; font-size: 16px; font-weight: 800; color: var(--ink-900); }
.doc-field-head p { margin: 0; font-size: 13px; color: var(--ink-700); }
.doc-field-body {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}
.doc-field-body.no-dates { grid-template-columns: minmax(0, 1fr); }
.doc-field-file { min-width: 0; }
.doc-field-file .cts-file-drop, .doc-field-file .cts-multi-drop { background: var(--bg-soft); }
.doc-field-dates { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; min-width: 0; }
.doc-field-dates label { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
:root[data-theme="dark"] .doc-field { background: rgba(255,255,255,.02); }
:root[data-theme="dark"] .doc-field-file .cts-file-drop,
:root[data-theme="dark"] .doc-field-file .cts-multi-drop { background: transparent; }
.cts-edit-modal .doc-field { padding: 12px; }

@media (max-width: 760px) {
    .doc-field-body { grid-template-columns: minmax(0, 1fr); }
}

/* ── File details ── */
.cts-file-current-wrap { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cts-file-current-wrap[hidden] { display: none; }
/* File details under each file (<x-file-info>), always shown. */
.file-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 12px; font-weight: 500; line-height: 1.35; color: var(--ink-700); }
.file-meta-name { font-size: 13px; font-weight: 700; color: var(--ink-900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta-row { display: inline-flex; align-items: center; gap: 5px; min-width: 0; overflow-wrap: anywhere; }
.file-meta-row svg { flex-shrink: 0; opacity: .75; }
.file-meta-ext {
    padding: 1px 6px; border-radius: 5px; font-size: 10px; font-weight: 800; letter-spacing: .04em;
    color: var(--brand-ink); background: color-mix(in srgb, var(--brand-1) 10%, transparent);
}
/* compact: one line, "·" between the parts (wraps on narrow screens). */
.file-meta-compact { flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: 0; row-gap: 2px; }
.file-meta-compact > .file-meta-row + .file-meta-row::before { content: "·"; margin: 0 7px; opacity: .6; }
.cts-file-item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
/* Attachment tile: thumbnail and its details in one card. */
.image-gallery-cell { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg-soft); }
.image-gallery-cell .image-gallery-item { border: 0; border-radius: 0; border-bottom: 1px solid var(--line); }
.image-gallery-cell .file-meta { padding: 9px 10px 10px; }
.image-gallery:has(.image-gallery-cell) { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; align-items: start; }
.detail-file-wrap { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }

/* ── Upload history ── */
.upload-history td { vertical-align: top; }
.upload-history .pill { margin-left: 6px; }
.upload-history-file { overflow-wrap: anywhere; }
.upload-history tr.is-current td { background: color-mix(in srgb, var(--brand-1) 5%, transparent); }

/* ── Detail page: document rows ── */
.doc-list { display: grid; gap: 12px; }
.doc-row { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; min-width: 0; }
.doc-row-title { margin: 0 0 10px; font-size: 16px; font-weight: 800; color: var(--ink-900); }
.doc-row-grid { margin: 0; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.doc-row-grid .detail-item dd { align-items: flex-start; }
@media (max-width: 760px) {
    .doc-row-grid { grid-template-columns: minmax(0, 1fr); }
}
.upload-history-block h4, .detail-card .upload-history-title { margin: 6px 0 10px; font-size: 16px; font-weight: 800; color: var(--ink-900); }
.upload-history-toggle summary { cursor: pointer; font-weight: 700; color: var(--brand-ink); padding: 4px 0; }
.upload-history-toggle[open] summary { margin-bottom: 10px; }

/* ── Document file list (several files per document) ── */
.cts-file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cts-file-list[hidden] { display: none; }
.cts-file-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 10px;
    background: var(--bg-soft);
    font-weight: 400;
    min-width: 0;
}
.cts-file-item-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cts-file-item-icon { flex-shrink: 0; color: var(--ink-700); }
.cts-file-item-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.cts-file-item-name { font-size: 14px; font-weight: 700; color: var(--ink-900); overflow-wrap: anywhere; }
a.cts-file-item-name { color: var(--brand-ink); text-decoration: underline; }
.cts-file-item-meta { font-size: 12px; color: var(--ink-700); }
.cts-file-item-badge { font-weight: 700; color: var(--brand-ink); }
.cts-file-item input[type="file"] { display: none; }
.cts-file-item-remove {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: var(--danger);
    color: #fff;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.cts-file-item.is-new { border-style: dashed; border-color: var(--brand-1); }
.cts-file-item.is-removed { opacity: .55; }
.cts-file-item.is-removed .cts-file-item-name { text-decoration: line-through; }
.cts-file-item.is-removed .cts-file-item-remove { background: var(--ink-700); }
.detail-item dd:has(> .detail-file-wrap + .detail-file-wrap) { flex-direction: column; align-items: flex-start; gap: 10px; }
/* Each file's own start / end date, on the file's row. */
.cts-file-item-dates { display: flex; gap: 10px; margin: 0; flex-shrink: 0; }
.cts-file-item-dates label { display: flex; flex-direction: column; gap: 2px; font-size: 11px; font-weight: 600; color: var(--ink-700); text-transform: uppercase; letter-spacing: .03em; }
.cts-file-item-dates input[type="date"] { width: 150px; min-height: 34px; padding: 5px 8px; font-size: 13px; border-radius: 8px; text-transform: none; letter-spacing: 0; }
.cts-file-item.is-removed .cts-file-item-dates { opacity: .45; pointer-events: none; }
.doc-field-note { margin: 8px 0 0; font-size: 13px; color: var(--ink-700); }
@media (max-width: 760px) {
    .cts-file-item-row { flex-wrap: wrap; }
    .cts-file-item-text { flex: 1 1 calc(100% - 70px); }
    .cts-file-item-dates { order: 3; flex-basis: 100%; padding-left: 28px; }
    .cts-file-item-dates label { flex: 1 1 0; }
    .cts-file-item-dates input[type="date"] { width: 100%; }
}


/* Audit trail */
.pill.neutral { color: var(--ink-700); background: color-mix(in srgb, var(--ink-700) 12%, transparent); }
/* Search on its own row, filters and dates on the next. */
.audit-filter-bar .db-search-input { flex: 1 1 calc(100% - 40px); }
.audit-filter-bar .db-search-sep { display: none; }
.audit-filter-bar .asset-filter-select { flex: 1 1 150px; }
.audit-dates { display: flex; flex-wrap: wrap; gap: 10px; }
.audit-filter-bar .audit-date { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-700); }
.audit-filter-bar .audit-date input { min-height: 36px; padding: 6px 10px; font-size: 14px; border-radius: 9px; }
.audit-table th, .audit-table td { padding: 10px 12px; font-size: 14px; vertical-align: middle; }
.audit-table th { white-space: nowrap; }
.audit-table tbody tr:hover td { background: color-mix(in srgb, var(--brand-1) 4%, transparent); }
.audit-time { white-space: nowrap; }
.audit-time small, .audit-record small { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-700); }
.audit-user { white-space: nowrap; }
.audit-record { min-width: 160px; }
.audit-table .pill { white-space: nowrap; font-size: 12px; }
.audit-summary { max-width: 360px; overflow-wrap: anywhere; color: var(--ink-700); }
.audit-none { color: var(--line); }
.audit-ip { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ink-700); }
.audit-action { text-align: right; white-space: nowrap; }
.audit-view { display: inline-block; padding: 5px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--ink-900); text-decoration: none; }
.audit-view:hover { border-color: var(--brand-1); color: var(--brand-ink); }
.audit-more { margin: 10px 0 0; }
.audit-changes td { overflow-wrap: anywhere; }

/* User Activity Story */
.story-modal { max-width: 520px; }
.story-range { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.story-range legend { margin-bottom: 8px; font-size: 14px; font-weight: 600; color: var(--ink-700); }
.story-range-option { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; cursor: pointer; }
.story-range-option:has(input:checked) { border-color: var(--brand-1); color: var(--brand-ink); background: color-mix(in srgb, var(--brand-1) 7%, transparent); }
.story-range-option input { margin: 0; accent-color: var(--brand-1); }
.story-custom { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.story-custom[hidden] { display: none; }
.story-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.story-stats div { border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; display: flex; flex-direction: column; }
.story-stats strong { font-size: 24px; font-weight: 800; color: var(--ink-900); }
.story-stats span { font-size: 13px; color: var(--ink-700); }
.story-day + .story-day { margin-top: 26px; }
.story-day-title { margin: 0 0 12px; font-size: 16px; font-weight: 800; color: var(--ink-900); padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.story-session { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.story-session + .story-session { margin-top: 12px; }
.story-session-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin-bottom: 12px; font-size: 14px; }
.story-session-head span { color: var(--ink-700); font-size: 13px; }
.story-steps { list-style: none; margin: 0; padding: 0; position: relative; }
.story-steps::before { content: ""; position: absolute; left: 53px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.story-step { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 22px; padding: 6px 0; position: relative; }
.story-step::before { content: ""; position: absolute; left: 48px; top: 11px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 3px solid #94a3b8; box-sizing: border-box; }
.story-step--auth::before { border-color: #2563eb; }
.story-step--change::before { border-color: #059669; }
.story-step--file::before { border-color: #7c3aed; }
.story-step--danger::before { border-color: #dc2626; }
.story-time { font-size: 13px; font-weight: 700; color: var(--ink-700); text-decoration: none; padding-top: 2px; font-variant-numeric: tabular-nums; }
.story-time:hover { color: var(--brand-ink); }
.story-text p { margin: 0; font-size: 14px; color: var(--ink-900); overflow-wrap: anywhere; }
.story-step--view .story-text p { color: var(--ink-700); }
.story-step--danger .story-text p { color: var(--danger); }
.story-record { margin-left: 6px; font-size: 13px; }
.story-details { margin: 4px 0 0; padding-left: 16px; font-size: 13px; color: var(--ink-700); }
.story-empty { padding: 24px 0; }
@media (max-width: 640px) {
    .story-stats { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
    .story-stats div { padding: 10px; }
    .story-stats strong { font-size: 20px; }
    .story-custom { grid-template-columns: 1fr; }
}

/* Module exports */
.section-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.export-btn { font-size: 14px; padding: 9px 12px; }
@media (max-width: 640px) {
    .section-head:has(.section-actions) { flex-wrap: wrap; }
    .section-actions { justify-content: flex-start; }
}

/* List search */
.list-search { flex-wrap: wrap; }
.list-search .db-search-input { min-width: 200px; }
.list-date-range { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-700); flex-shrink: 0; }
.list-date-range input { min-height: 36px; padding: 6px 10px; font-size: 14px; border-radius: 9px; }
.list-date-sep { font-weight: 400; opacity: .6; }
@media (max-width: 640px) {
    .list-date-range { flex: 1 1 100%; }
    .list-date-range input { flex: 1 1 0; min-width: 0; }
}
.detail-file-period { display: inline-block; margin-left: 6px; font-size: 12px; color: var(--ink-700); white-space: nowrap; }
.db-detail-cell small { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-700); }

/* Insured Part column: names stacked, extra ones behind "More" */

:root[data-theme="dark"] th { background: #0f1e26; }
:root[data-theme="dark"] td.actions > a { background: transparent; color: var(--ink-900); }

/* Buttons inside table rows: compact, and Delete always in the danger style. */
td .button-link { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.button-link.danger { background: var(--surface); color: var(--danger); border: 1px solid var(--danger-line); }
.button-link.danger:hover, .actions button:hover { background: var(--danger-soft); }

/* Web Settings: WhatsApp */
.ws-wa { margin-left: auto; font-size: 12px; color: var(--ink-700); white-space: nowrap; }
.ws-wa.is-missing { color: var(--ink-400); font-style: italic; }
.ws-reminder-days { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.ws-switch { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.ws-switch input[type="checkbox"] { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand-1); }
/* Web Settings > Notification Log */
.ws-log-filters select { min-height: 36px; padding: 6px 30px 6px 10px; font-size: 14px; border-radius: 9px; width: auto; flex: 0 0 auto; }
.ws-log-error { margin-top: 4px; color: #b42318; font-size: 13px; white-space: normal; word-break: break-word; }
:root[data-theme="dark"] .ws-log-error { color: #fda29b; }
@media (max-width: 640px) { .ws-log-filters select { flex: 1 1 0; } }
.ws-switch span { display: flex; flex-direction: column; gap: 2px; }
.ws-switch small { color: var(--ink-700); font-size: 13px; font-weight: 400; }
.ws-templates-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 28px; }
.ws-template-preview { color: var(--ink-700); max-width: 420px; }
.ws-placeholders { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ws-placeholders .field-label, .ws-placeholders .asset-muted { flex-basis: 100%; margin: 0; }
.ws-placeholder { padding: 4px 9px; border: 1px dashed var(--brand-1); border-radius: 8px; background: transparent; color: var(--brand-ink); font-size: 12px; font-weight: 700; font-family: ui-monospace, Menlo, monospace; cursor: pointer; }
.ws-help { flex-basis: 100%; min-width: 0; max-width: 100%; }
.ws-help-body .table-wrap { overflow-x: auto; }
.cts-edit-modal.ws-template-modal { width: min(860px, calc(100vw - 32px)); max-width: none; }
.ws-help summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--brand-ink); list-style: none; }
.ws-help summary::-webkit-details-marker { display: none; }
.ws-help summary span { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid currentColor; font-size: 11px; font-weight: 700; font-style: italic; font-family: Georgia, serif; }
.ws-help[open] summary { margin-bottom: 8px; }
.ws-help-body { padding: 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.ws-help-body p { margin: 0 0 8px; }
.ws-help-body .table-wrap { margin-bottom: 12px; }
.ws-help-body th, .ws-help-body td { padding: 6px 8px; font-size: 12px; vertical-align: top; }
.ws-help-body code { font-family: ui-monospace, Menlo, monospace; font-weight: 700; color: var(--brand-ink); white-space: nowrap; }
.ws-help-example { margin: 0 0 8px; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--ink-700) 8%, transparent); font-family: ui-monospace, Menlo, monospace; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.ws-placeholder:hover { background: color-mix(in srgb, var(--brand-1) 8%, transparent); }
.ws-reminder-days select { margin-top: 6px; max-width: 280px; }

/* Assets import */
.import-steps { display: grid; gap: 14px; }
.import-step { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border: 1px solid var(--line); border-radius: 14px; }
.import-step h3 { margin: 2px 0 6px; font-size: 16px; }
.import-step p { margin: 0 0 10px; color: var(--ink-700); font-size: 14px; }
.import-step-no { flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; background: linear-gradient(90deg, var(--brand-1), var(--brand-1-end)); }
.import-notes { margin: 0; padding-left: 18px; color: var(--ink-700); font-size: 14px; line-height: 1.6; }
.import-notes code, .import-step code { font-size: 13px; padding: 1px 5px; border-radius: 5px; background: color-mix(in srgb, var(--ink-700) 10%, transparent); }
.import-upload { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.import-upload input[type=file] { flex: 1 1 240px; min-width: 0; padding: 8px; border: 1px dashed var(--line); border-radius: 10px; font-size: 14px; }
.import-hint { display: block; margin-top: 6px; color: var(--ink-700); font-size: 12px; }
.import-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.import-summary-item { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.import-summary-item strong { display: block; font-size: 22px; line-height: 1.1; }
.import-summary-item span { font-size: 13px; color: var(--ink-700); }
.import-summary-item.create strong { color: #059669; }
.import-summary-item.update strong { color: #2563eb; }
.import-summary-item.error strong { color: #dc2626; }
.import-table td { vertical-align: top; font-size: 14px; }
.import-line { color: var(--ink-700); white-space: nowrap; }
.import-details { line-height: 1.5; }
.import-field { font-weight: 600; margin-right: 4px; }
.import-field::after { content: ':'; }
.import-old { color: var(--ink-700); text-decoration: line-through; opacity: .75; }
.import-errors { margin: 0; padding-left: 16px; color: #dc2626; }
.import-row-error td { background: color-mix(in srgb, #dc2626 5%, transparent); }
.pill.muted { color: var(--ink-700); background: color-mix(in srgb, var(--ink-700) 7%, transparent); opacity: .8; }
@media (max-width: 640px) {
    .import-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .import-step { flex-direction: column; }
}

/* ── Loading state for save / update / delete (public/js/submit-loading.js) ── */
@keyframes cts-spin { to { transform: rotate(360deg); } }

.cts-spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    flex: 0 0 auto;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: cts-spin .6s linear infinite;
    vertical-align: -0.15em;
}

button.is-loading,
.button-link.is-loading,
input[type="submit"].is-loading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: progress;
    opacity: .85;
    pointer-events: none;
}

td.actions button.is-loading { display: inline-flex; }

button.is-locked,
input[type="submit"].is-locked {
    cursor: not-allowed;
    opacity: .5;
}

form[aria-busy="true"] { cursor: progress; }

/* The confirmation modal while it deletes: the OK button spins, Cancel cannot be used. */
.cts-modal-overlay.is-busy { cursor: progress; }
.cts-modal-overlay.is-busy .cts-modal-cancel { opacity: .45; cursor: not-allowed; }

/* A deleted row / card fades out before it is removed. */
.cts-removing {
    opacity: 0 !important;
    transform: scale(.98);
    transition: opacity .25s ease, transform .25s ease;
}

/* Thin bar along the top while the page is being sent. */
.cts-page-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 2000;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s ease;
}
.cts-page-progress.active { opacity: 1; }
.cts-page-progress::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -40%;
    width: 40%;
    border-radius: 0 3px 3px 0;
    background: linear-gradient(90deg, transparent, var(--brand-1), #14b8a6, var(--brand-2));
    animation: cts-progress 1.1s ease-in-out infinite;
}
@keyframes cts-progress {
    0% { left: -40%; width: 40%; }
    60% { width: 55%; }
    100% { left: 100%; width: 30%; }
}

/* Screen-wide layer while saving / updating / deleting: nothing else can be clicked. */
html.cts-busy, html.cts-busy body { cursor: progress; }
.cts-busy-overlay {
    position: fixed;
    inset: 0;
    z-index: 1990;
    display: grid;
    place-items: center;
    padding: 16px;
    background: transparent;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s ease, visibility .2s ease;
}
.cts-busy-overlay.active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    cursor: progress;
}
.cts-busy-overlay.has-card {
    background: rgba(15, 23, 42, .28);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.cts-busy-card {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-width: 220px;
    max-width: 100%;
    padding: 24px 28px 20px;
    border-radius: 16px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    box-shadow: 0 20px 50px rgba(15, 23, 42, .22);
    text-align: center;
    transform: translateY(6px) scale(.97);
    transition: transform .2s ease;
}
.cts-busy-overlay.has-card .cts-busy-card { display: flex; }
.cts-busy-overlay.active .cts-busy-card { transform: none; }
.cts-busy-ring {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 3px solid rgba(20, 184, 166, .18);
    border-top-color: var(--brand-1);
    border-right-color: #14b8a6;
    animation: cts-spin .75s linear infinite;
}
.cts-busy-text { font-size: 15px; color: var(--ink-900); }
.cts-busy-card small { font-size: 12px; color: var(--ink-700); }
:root[data-theme="dark"] .cts-busy-overlay.has-card { background: rgba(0, 0, 0, .45); }
/* The card takes over from a delete confirmation that led to it. */
html.cts-busy-with-card .cts-modal-overlay { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
    /* Panels still appear softly, but without moving up. */
    .reveal { transform: none; animation: revealFade 0.2s ease-out forwards; }
    .cts-spinner { animation-duration: 1.6s; }
    .cts-page-progress::before { animation-duration: 2.4s; }
    .cts-busy-ring { animation-duration: 1.8s; }
}


/* ── Tabs that switch a list page (CoreTrade Certificate: CoreTrade / BCA / ISO / GGBS) ── */
.list-tab-nav { margin: 0 0 16px; }
.list-tab-nav a.cts-tab-btn { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }


/* Field errors (form-errors.js): red border, message under the field, list in a corner toast */
.has-field-error input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.has-field-error select,
.has-field-error textarea,
.has-field-error .cts-file-drop,
.has-field-error .cts-multi-drop {
    border-color: #e11d48 !important;
    box-shadow: 0 0 0 3px rgba(225, 29, 72, .12);
}
.field-error {
    display: flex;
    align-items: flex-start;
    gap: 5px;
    margin-top: 6px;
    color: #be123c;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.35;
}
.field-error::before {
    content: "!";
    flex-shrink: 0;
    display: inline-grid;
    place-items: center;
    width: 15px;
    height: 15px;
    margin-top: 1px;
    border-radius: 50%;
    background: #e11d48;
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
}
.cts-error-toast { max-width: 380px; }
.cts-error-toast-body { min-width: 0; }
.cts-error-toast-body ul {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
    max-height: 50vh;
    overflow-y: auto;
}
.cts-error-toast-body li + li { margin-top: 4px; }
.cts-error-toast-body li > button,
.cts-error-toast-body li > span {
    display: block;
    width: 100%;
    text-align: left;
    padding: 5px 8px;
    border: 0;
    border-radius: 7px;
    background: rgba(225, 29, 72, .07);
    color: inherit;
    font: inherit;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
}
.cts-error-toast-body li > button { cursor: pointer; }
.cts-error-toast-body li > button:hover { background: rgba(225, 29, 72, .15); }
.cts-error-toast-body b { font-weight: 600; }
:root[data-theme="dark"] .field-error { color: #fda4af; }
:root[data-theme="dark"] .has-field-error input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
:root[data-theme="dark"] .has-field-error select,
:root[data-theme="dark"] .has-field-error textarea { border-color: #fb7185 !important; }
@media (max-width: 640px) {
    #cts-toast-container { left: 12px; right: 12px; top: 12px; }
    .cts-error-toast { max-width: none; }
}

/* ---- Rich text (Quill editor + display) ---- */
.rich-text-field {
    display: grid;
    gap: 7px;
    min-width: 0;
    align-content: start;
}

.rich-text-label {
    font-size: 15px;
    font-weight: 700;
    cursor: text;
}

.rich-text-field .ql-toolbar.ql-snow {
    border: 1px solid var(--line);
    border-radius: 11px 11px 0 0;
    background: #fff;
    font-family: inherit;
    padding: 6px 8px;
}

.rich-text-field .ql-container.ql-snow {
    border: 1px solid var(--line);
    border-top: 0;
    border-radius: 0 0 11px 11px;
    background: #fff;
    font: inherit;
    font-size: 15px;
    font-weight: 400;
    color: var(--ink-900);
}

.rich-text-field .ql-editor {
    min-height: 110px;
    max-height: 360px;
    overflow-y: auto;
    padding: 11px 12px;
    line-height: 1.5;
}

.rich-text-field .ql-editor.ql-blank::before {
    left: 12px;
    right: 12px;
    font-style: normal;
    color: var(--ink-700);
    opacity: 0.7;
}

.rich-text-field:focus-within .ql-container.ql-snow,
.rich-text-field:focus-within .ql-toolbar.ql-snow {
    border-color: var(--brand-1);
}

.rich-text-field:focus-within .ql-container.ql-snow {
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.2);
}

.rich-text-field .ql-snow .ql-stroke { stroke: var(--ink-700); }
.rich-text-field .ql-snow .ql-fill { fill: var(--ink-700); }
.rich-text-field .ql-snow.ql-toolbar button:hover .ql-stroke,
.rich-text-field .ql-snow.ql-toolbar button:focus .ql-stroke,
.rich-text-field .ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--brand-1); }
.rich-text-field .ql-snow.ql-toolbar button:hover .ql-fill,
.rich-text-field .ql-snow.ql-toolbar button:focus .ql-fill,
.rich-text-field .ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--brand-1); }
.rich-text-field .ql-snow .ql-editor a,
.rich-text-field .ql-snow .ql-tooltip a.ql-preview { color: var(--brand-ink); }
.rich-text-field .ql-snow .ql-tooltip {
    z-index: 5;
    border-radius: 10px;
    border-color: var(--line);
    box-shadow: 0 8px 24px rgba(18, 34, 42, 0.12);
    font-weight: 400;
}
.rich-text-field .ql-snow .ql-tooltip input[type="text"] {
    min-height: 30px;
    padding: 4px 8px;
}

.has-field-error .ql-toolbar.ql-snow,
.has-field-error .ql-container.ql-snow {
    border-color: var(--danger);
}

:root[data-theme="dark"] .rich-text-field .ql-toolbar.ql-snow,
:root[data-theme="dark"] .rich-text-field .ql-container.ql-snow,
:root[data-theme="dark"] .rich-text-field .ql-snow .ql-tooltip {
    background: var(--bg-soft);
    color: var(--ink-900);
}

/* Formatted text on the detail page and in lists. */
.rich-text {
    font-weight: 500;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.rich-text p { margin: 0; }
.rich-text strong,
.rich-text b { font-weight: 800; }
.rich-text p + p,
.rich-text p + ul,
.rich-text p + ol,
.rich-text ul + p,
.rich-text ol + p { margin-top: 6px; }
.rich-text ul,
.rich-text ol { margin: 0; padding-left: 20px; }
.rich-text a { color: var(--brand-ink); text-decoration: underline; }

/* In a table cell: at most 3 lines, the full text is in the tooltip. */
.rich-text-clamp {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
    max-width: 280px;
    min-width: 160px;
}

/* Second line under a detail value (e.g. a linked certificate's expiry). */
.detail-sub { margin-top: 4px; font-size: 13px; font-weight: 500; color: var(--ink-700); }

/* ════════════════════════════════════════════════════════════════════
   Dashboard (KPI summary, module cards, certificate list)
   ════════════════════════════════════════════════════════════════════ */
.dash {
    --d-card: #ffffff;
    --d-card-2: #f6faf9;
    --d-muted: #4a6370;
    --d-track: #e8f1ef;
    --d-red: #c0362c;
    --d-red-bg: #fdecea;
    --d-red-line: #f4c7c2;
    --d-orange: #b45309;
    --d-orange-bg: #fff4e5;
    --d-orange-line: #f6d9b0;
    --d-green: #0f766e;
    --d-green-bg: #e3f4f0;
    --d-zero: #6b8089;
    --d-zero-bg: #f3f7f6;
    --d-hero: #0b3d3f;
    --d-hero-ink: #ffffff;
    --d-hero-muted: #b9dcd6;
    --d-alert: #9f1d17;
    --d-alert-muted: #fde2df;
    --d-expired-row: #fff8f7;
    --d-shadow: 0 1px 2px rgba(18, 34, 42, 0.05), 0 10px 28px rgba(18, 34, 42, 0.06);
    display: grid;
    /* minmax(0, 1fr): the wide table scrolls inside its box instead of widening the page. */
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
}
.dash > * { min-width: 0; }
:root[data-theme="dark"] .dash {
    --d-card: #122029;
    --d-card-2: #16262f;
    --d-muted: #a6c0cb;
    --d-track: #1c2f38;
    --d-red: #fb8a80;
    --d-red-bg: #3a1f20;
    --d-red-line: #5a2b2b;
    --d-orange: #fbbf24;
    --d-orange-bg: #3a2c12;
    --d-orange-line: #5a4417;
    --d-green: #5eead4;
    --d-green-bg: #123532;
    --d-zero: #7f99a3;
    --d-zero-bg: #16262f;
    --d-hero: #0f3a3c;
    --d-hero-ink: #e9fffb;
    --d-hero-muted: #a9d8d0;
    --d-alert: #6b1a17;
    --d-alert-muted: #fbd0cb;
    --d-expired-row: #1b1b21;
    --d-shadow: none;
}
.dash h2 {
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 24px;
    font-weight: 700;
}
.dash svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}
.dash .tone-expired { --tone: var(--d-red); --tone-bg: var(--d-red-bg); --tone-line: var(--d-red-line); }
.dash .tone-soon { --tone: var(--d-orange); --tone-bg: var(--d-orange-bg); --tone-line: var(--d-orange-line); }
.dash .tone-valid,
.dash .tone-ok { --tone: var(--d-green); --tone-bg: var(--d-green-bg); --tone-line: var(--line); }
.dash .tone-none { --tone: var(--d-zero); --tone-bg: var(--d-zero-bg); --tone-line: var(--line); }

/* KPI row */
.dash-kpis {
    display: grid;
    /* 4 in a row when they fit, else 2 x 2 (never 3 + 1 alone), 1 per row on phones. */
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}
@media (min-width: 1360px) { .dash-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 640px) { .dash-kpis { grid-template-columns: minmax(0, 1fr); } }
.dash-kpi {
    background: var(--d-card);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: var(--d-shadow);
    color: var(--ink-900);
}
a.dash-kpi { transition: transform .16s ease, border-color .16s ease; }
a.dash-kpi:hover { transform: translateY(-3px); border-color: var(--tone); }
.dash-kpi-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 700;
    color: var(--d-muted);
}
.dash-kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--tone-bg);
    color: var(--tone);
}
.dash-kpi-icon svg { width: 20px; height: 20px; }
.dash-kpi-num {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 52px;
    font-weight: 700;
    line-height: 1;
}
.dash-kpi.tone-expired:not(.is-zero) .dash-kpi-num { color: var(--d-red); }
.dash-kpi.tone-soon:not(.is-zero) .dash-kpi-num { color: var(--d-orange); }
.dash-kpi-bar {
    display: flex;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--d-track);
}
.dash-kpi-bar > span { display: block; height: 100%; background: var(--tone); border-radius: 999px; }
.dash-kpi small { font-size: 13px; color: var(--d-muted); }
.dash-kpi-hero {
    background: var(--d-hero);
    border-color: transparent;
    color: var(--d-hero-ink);
}
.dash-kpi-hero .dash-kpi-head,
.dash-kpi-hero small { color: var(--d-hero-muted); }
.dash-kpi-hero .dash-kpi-icon { background: rgba(255, 255, 255, 0.12); color: var(--d-hero-ink); }
/* Something expired: the Expired card leads the row as the hero, in red. */
.dash-kpi-alert {
    background: var(--d-alert);
    border-color: transparent;
    color: #ffffff;
}
.dash-kpi-alert .dash-kpi-head,
.dash-kpi-alert small { color: var(--d-alert-muted); }
.dash-kpi-alert .dash-kpi-icon { background: rgba(255, 255, 255, 0.14); color: #ffffff; }
.dash-kpi.tone-expired.dash-kpi-alert .dash-kpi-num { color: #ffffff; }
.dash-kpi-alert .dash-kpi-bar { background: rgba(255, 255, 255, 0.18); }
.dash-kpi-alert .dash-kpi-bar > span { background: #ffffff; }
a.dash-kpi-alert:hover { border-color: transparent; box-shadow: 0 10px 28px rgba(127, 29, 29, 0.28); }
/* Tracked: the neutral total, with the expired / expiring / valid split as a bar. */
.dash-kpi-total .dash-kpi-bar { background: var(--d-track); }
.dash-kpi-total .dash-kpi-stack > .tone-expired { background: var(--d-red); }
.dash-kpi-total .dash-kpi-stack > .tone-soon { background: var(--d-orange); }
.dash-kpi-total .dash-kpi-stack > .tone-valid { background: var(--d-green); }
.dash-kpi-stack { background: rgba(255, 255, 255, 0.15); }
.dash-kpi-stack > span { border-radius: 0; }
.dash-kpi-stack > .tone-valid { background: #5eead4; }

/* Module cards */
.dash-section { display: grid; gap: 14px; }
.dash-section-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 8px 16px;
}
.dash-section-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--d-muted);
}
.dash-toggle {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--d-card);
    color: var(--ink-900);
    font-size: 14px;
    font-weight: 800;
}
.dash-toggle[hidden] { display: none; }
.dash-toggle:hover { border-color: var(--brand-1); }
.dash-toggle svg { width: 16px; height: 16px; stroke-width: 2.4; transition: transform .2s ease; }
.dash-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.dash-modules {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
    gap: 16px;
    padding-top: 4px;
    margin-top: -4px;
}
.dash-modules.is-collapsed { overflow: hidden; }
.dash-module {
    background: var(--d-card);
    border: 1px solid var(--tone-line);
    border-radius: 20px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: var(--d-shadow);
    transition: transform .16s ease, box-shadow .16s ease;
}
.dash-module:hover { transform: translateY(-3px); }
.dash-module.is-active { border-color: var(--brand-1); box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.22); }
.dash-module-head { display: flex; align-items: center; gap: 12px; color: var(--ink-900); }
.dash-module-head strong { flex: 1 1 auto; min-width: 0; font-size: 17px; font-weight: 800; line-height: 1.25; }
.dash-module-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    background: var(--tone-bg);
    color: var(--tone);
}
.dash-module.tone-ok .dash-module-icon { background: rgba(15, 118, 110, 0.1); color: var(--brand-ink); }
:root[data-theme="dark"] .dash-module.tone-ok .dash-module-icon { background: #173039; color: #2dd4bf; }
.dash-module-icon svg { width: 22px; height: 22px; stroke-width: 1.9; }
.dash-module-arrow { width: 18px; height: 18px; opacity: .55; }
.dash-module-head:hover .dash-module-arrow { opacity: 1; }
.dash-module-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.dash-stat {
    display: flex;
    flex-direction: column;
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--tone-bg);
    border: 1.5px solid transparent;
    transition: border-color .15s ease;
}
.dash-stat:hover,
.dash-stat.is-active { border-color: var(--tone); }
.dash-stat strong {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
    color: var(--tone);
}
.dash-stat span { font-size: 13px; font-weight: 700; color: var(--d-muted); }
.dash-stat.is-zero { --tone: var(--d-zero); --tone-bg: var(--d-zero-bg); }
.dash-pill {
    align-self: flex-start;
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--tone-bg);
    color: var(--tone);
    font-size: 13px;
    font-weight: 800;
}
.dash-pill > span,
.dash-chip > span,
.dash-days > span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
}

/* Certificate list */
.dash-list.panel-card { display: grid; gap: 16px; padding: 24px; border-radius: 22px; }
.dash-list h2 { font-size: 22px; }
.dash-search {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    background: var(--d-card-2);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 10px 10px 10px 16px;
}
.dash-search > svg { width: 20px; height: 20px; color: var(--d-muted); }
.dash-search label { display: flex; gap: 0; font-weight: 500; }
.dash-search-text { flex: 1 1 260px; min-width: 0; }
.dash-search-text input {
    flex: 1 1 auto;
    border: 0;
    background: transparent;
    padding: 0;
    font-size: 16px;
    outline: none;
}
/* The input has no border of its own: the whole search bar shows the focus (below). */
.dash-search-text input:focus-visible { box-shadow: none; outline: none; }
.dash-search-date { flex: 0 1 180px; }
.dash-search-date input { flex: 1 1 auto; background: var(--d-card); }
.dash-search button { min-height: 44px; padding: 0 22px; font-weight: 800; }
.dash-clear { font-size: 14px; font-weight: 700; color: var(--d-muted); padding: 0 6px; }
.dash-clear:hover { color: var(--danger); }
.dash-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dash-chip {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1.5px solid var(--line);
    background: var(--d-card);
    color: var(--ink-900);
    font-size: 14px;
    font-weight: 800;
}
.dash-chip > span { color: var(--tone); }
.dash-chip:hover { border-color: var(--tone); }
.dash-chip.is-active { background: var(--tone-bg); border-color: var(--tone); color: var(--tone); }
.dash-filter-note { margin: 0; font-size: 14px; color: var(--d-muted); }
.dash-filter-note a { margin-left: 8px; color: var(--brand-ink); font-weight: 700; }
.dash-filter-hint { font-size: 13px; }
/* Module card: records without any expiry date (link to the "No expiry date" list). */
.dash-no-expiry { justify-self: start; align-self: start; padding: 3px 10px; border: 1px dashed var(--d-zero); border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--d-muted); text-decoration: none; }
.dash-no-expiry:hover, .dash-no-expiry.is-active { border-style: solid; color: var(--ink-900); background: var(--d-zero-bg); }
.dash-table-wrap { border: 1px solid var(--line); border-radius: 16px; }
.dash-table { min-width: 860px; font-size: 15px; }
.dash-table th {
    background: var(--d-card-2);
    color: var(--d-muted);
    font-weight: 800;
    letter-spacing: .08em;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}
.dash-table td { padding: 16px; font-size: 15px; }
.dash-table tbody tr:last-child td { border-bottom: 0; }
.dash-table tr.is-expired td { background: var(--d-expired-row); }
.dash-table tbody tr:hover td { background: var(--d-card-2); }
.dash-cert-type { font-weight: 800; }
.dash-date { font-weight: 600; white-space: nowrap; }
.dash-days {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--tone-bg);
    color: var(--tone);
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}
.dash-days > span { width: 7px; height: 7px; }

@media (max-width: 640px) {
    .dash { gap: 22px; }
    .dash-kpi { padding: 18px 20px; }
    .dash-kpi-num { font-size: 44px; }
    .dash-list.panel-card { padding: 16px; }
    .dash-search { padding: 10px; }
    .dash-search button { flex: 1 1 auto; }
}

/* Text for screen readers only. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ── Sidebar on phones / tablets: a slide-in drawer with its own close button ── */
.sidebar-close { display: none; }
@media (max-width: 900px) {
    .sidebar-toggle { display: none; }
    .sidebar-close {
        width: 40px;
        height: 40px;
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: #fff;
        color: var(--ink-900);
    }
    :root[data-theme="dark"] .sidebar-close { background: #172933; }
    .sidebar-close:hover { border-color: var(--brand-1); color: var(--brand-ink); }
    /* Brand + close stay on top while the menu scrolls. */
    .sidebar-head { position: sticky; top: -20px; z-index: 2; margin: -20px -16px 16px; padding: 16px 16px 12px; background: #f8fffe; border-bottom: 1px solid var(--line); }
    :root[data-theme="dark"] .sidebar-head { background: #10202a; }
    /* The page behind an open drawer stays put. */
    body.sidebar-locked { overflow: hidden; }
}

/* User form: "Non-Apps User" hides the login fields (password, roles). */
.app-only[hidden] { display: none !important; }
.non-app-toggle { align-items: flex-start; }
.non-app-toggle small { display: block; margin-top: 2px; font-weight: 400; }

/* ── List tables: clickable rows, sortable headers, default sort bar (App\Support\ListSort) ── */
tr[data-href] { cursor: pointer; }
tr[data-href] > td.actions { cursor: default; }
tr[data-href]:hover > td { background: color-mix(in srgb, var(--brand-1) 6%, transparent); }
.sort-th { display: inline-flex; align-items: center; gap: 4px; color: inherit; text-decoration: none; white-space: nowrap; }
.sort-th-icon { font-size: 12px; opacity: .35; }
.sort-th:hover .sort-th-icon, .sort-th.is-active .sort-th-icon { opacity: 1; color: var(--brand-ink); }
.sort-th.is-active { color: var(--brand-ink); }
.sort-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: -4px 0 12px; font-size: 13px; color: var(--ink-700); }
.sort-bar form { display: inline; margin: 0; }
.sort-bar-link { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--brand-ink); text-decoration: underline; cursor: pointer; }


/* ── Web Settings > Menu: rename / reorder the sidebar menus ── */
.menu-edit { display: grid; gap: 8px; max-width: 760px; }
.menu-edit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.menu-edit-sub { margin: 8px 0 2px 34px; padding-left: 14px; border-left: 2px dashed var(--line); }
.menu-edit-row {
    display: flex; align-items: center; gap: 10px; min-width: 0;
    padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-soft);
    transition: border-color .15s, box-shadow .15s;
}
.menu-edit-row:hover { border-color: color-mix(in srgb, var(--brand-1) 45%, var(--line)); }
.menu-edit-row.is-group { background: color-mix(in srgb, var(--brand-1) 5%, var(--bg-soft)); }
.menu-edit-row.is-section { background: var(--surface-2); border-style: dashed; }
.menu-edit-icon-static.is-section-badge { background: color-mix(in srgb, var(--brand-1) 10%, var(--surface-2)); color: var(--brand-ink); border-color: color-mix(in srgb, var(--brand-1) 25%, transparent); }
.menu-edit-row.is-fixed { background: transparent; border-style: dashed; color: var(--ink-700); }
.menu-edit-handle {
    flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 32px; border-radius: 6px; color: var(--ink-700); opacity: .6; cursor: grab; touch-action: none;
}
.menu-edit-handle:hover { opacity: 1; background: color-mix(in srgb, var(--brand-1) 8%, transparent); }
.menu-edit-handle.is-locked { cursor: default; opacity: .45; }
.menu-edit-handle.is-locked:hover { background: none; }
input.menu-edit-icon, .menu-edit-icon-static {
    flex-shrink: 0; width: 48px; min-height: 34px; padding: 4px; text-align: center;
    font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; border-radius: 9px;
}
.menu-edit-icon-static { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); }
.menu-edit-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.menu-edit-name input { width: 100%; min-height: 34px; padding: 5px 10px; font-weight: 700; }
.menu-edit-name-static { flex: 1; font-weight: 700; padding-left: 4px; }
.menu-edit-default { font-size: 12px; color: var(--ink-700); }
.menu-edit-default::before { content: "↺ "; }
.menu-edit-note, .menu-edit-tag {
    flex-shrink: 0; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
    color: var(--ink-700); border: 1px solid var(--line); white-space: nowrap;
}
.menu-edit-tag { color: var(--brand-ink); border-color: color-mix(in srgb, var(--brand-1) 35%, transparent); }
.menu-edit-move { flex-shrink: 0; display: inline-flex; gap: 4px; }
.menu-edit-move button {
    width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--ink-700); cursor: pointer; box-shadow: none;
}
.menu-edit-move button:hover { border-color: var(--brand-1); color: var(--brand-ink); background: transparent; }
.menu-edit-list > .menu-edit-item:first-child > .menu-edit-row [data-menu-move="-1"],
.menu-edit-list > .menu-edit-item:last-child > .menu-edit-row [data-menu-move="1"] { opacity: .3; pointer-events: none; }
.menu-edit-item.is-dragging > .menu-edit-row { opacity: .45; border-style: dashed; border-color: var(--brand-1); }
.menu-edit-item.is-moved > .menu-edit-row { animation: menu-edit-moved .9s ease-out; }
@keyframes menu-edit-moved {
    from { border-color: var(--brand-1); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-1) 22%, transparent); }
}
.menu-edit-actions { max-width: 760px; justify-content: flex-end; margin-top: 16px; }
/* Collapsible groups: the "Group · n menus" tag opens / closes the group's menus. */
.menu-edit-collapse { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; background: transparent; box-shadow: none; }
.menu-edit-collapse:hover { background: color-mix(in srgb, var(--brand-1) 8%, transparent); color: var(--brand-ink); }
.menu-edit-collapse svg { transition: transform .15s; }
.menu-edit-item.is-collapsed > .menu-edit-row .menu-edit-collapse svg { transform: rotate(-90deg); }
.menu-edit-item.is-collapsed > .menu-edit-sub { display: none; }
.menu-edit-toolbar { display: flex; justify-content: flex-end; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-700); }
.menu-edit-toolbar button {
    padding: 2px 4px; border: 0; background: transparent; box-shadow: none; color: var(--brand-ink);
    font-size: 12px; font-weight: 700; cursor: pointer;
}
.menu-edit-toolbar button:hover { text-decoration: underline; background: transparent; color: var(--brand-ink); }
/* Group select of a menu, delete group, New Group / Restore, and an empty group's drop area. */
.menu-edit-parent { flex-shrink: 0; margin: 0; }
.menu-edit-parent select {
    width: 170px; min-height: 32px; padding: 4px 28px 4px 10px; font-size: 12px; font-weight: 600;
    border-radius: 8px; color: var(--ink-700); text-overflow: ellipsis;
}
.menu-edit-item.in-group > .menu-edit-row .menu-edit-parent select { color: var(--brand-ink); border-color: color-mix(in srgb, var(--brand-1) 40%, var(--line)); }
.menu-edit-delete {
    flex-shrink: 0; width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--ink-700); cursor: pointer; box-shadow: none;
}
.menu-edit-delete:hover { border-color: var(--danger); color: var(--danger); background: transparent; }
.menu-edit-add {
    justify-self: start; display: inline-flex; align-items: center; gap: 6px; margin-top: 2px;
    padding: 8px 14px; border: 1px dashed color-mix(in srgb, var(--brand-1) 55%, var(--line)); border-radius: 10px;
    background: transparent; color: var(--brand-ink); font-weight: 700; font-size: 13px; cursor: pointer; box-shadow: none;
}
.menu-edit-add:hover { background: color-mix(in srgb, var(--brand-1) 7%, transparent); color: var(--brand-ink); }
.menu-edit-adds { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.menu-edit-adds .menu-edit-add { margin-top: 0; }
.menu-edit-add.is-restore { border-color: var(--line); color: var(--ink-700); }
.menu-edit-add.is-restore:hover { border-color: var(--brand-1); color: var(--brand-ink); }
.menu-edit-add[hidden] { display: none; }
.menu-edit-sub.is-empty, .menu-edit-sub:empty { min-height: 44px; }
.menu-edit-sub.is-empty::before, .menu-edit-sub:empty::before {
    content: attr(data-empty-text); display: flex; align-items: center; min-height: 44px; padding: 8px 12px;
    border: 1px dashed var(--line); border-radius: 12px; font-size: 12px; color: var(--ink-700); opacity: .8;
}
@media (max-width: 640px) {
    /* One line per menu: the arrows stack, the group tag hides (its menus show it is a group). */
    .menu-edit-sub { margin-left: 10px; padding-left: 8px; }
    .menu-edit-row { gap: 6px; padding: 6px 8px; }
    .menu-edit-handle { width: 18px; }
    input.menu-edit-icon, .menu-edit-icon-static { width: 42px; }
    .menu-edit-tag:not(.menu-edit-collapse) { display: none; }
    .menu-edit-collapse [data-menu-count] { display: none; }
    .menu-edit-row { flex-wrap: wrap; }
    .menu-edit-name { flex: 1 1 0; }
    /* The Group select goes on its own line under the name. */
    .menu-edit-parent { order: 10; flex-basis: 100%; padding-left: 24px; }
    .menu-edit-parent select { width: 100%; }
    .menu-edit-move { flex-direction: column; gap: 2px; }
    .menu-edit-move button { width: 28px; height: 18px; border-radius: 6px; }
}


/* Web Settings: a tab without its ".update" permission is view only (fields disabled). */
.ws-fieldset { display: contents; border: 0; margin: 0; padding: 0; min-width: 0; }
.ws-readonly-note {
    display: flex; align-items: center; gap: 8px; margin: 0 0 14px; padding: 10px 14px;
    border: 1px dashed var(--line); border-radius: 12px; background: color-mix(in srgb, var(--ink-700) 5%, transparent);
    font-size: 13px; font-weight: 600; color: var(--ink-700);
}
.ws-fieldset:disabled input, .ws-fieldset:disabled select, .ws-fieldset:disabled textarea { cursor: not-allowed; opacity: .75; }

/* Assets Management: the asset's user (form picker, detail). */
.holder-field { display: flex; flex-direction: column; gap: 12px; }
.holder-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.holder-pick .asset-muted { grid-column: 1 / -1; }
.holder-pick label[hidden] { display: none; }
.holder-pick input[readonly] { background: var(--surface-2); color: var(--text); cursor: default; }
.holder-new { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding: 14px; border: 1px dashed var(--line); border-radius: 12px; background: var(--surface-2); }
.holder-new[hidden] { display: none; }
.holder-new .asset-muted { grid-column: 1 / -1; }
.holder-legacy { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-3); color: var(--text); font-size: 14px; }
@media (max-width: 640px) {
    .holder-new, .holder-pick { grid-template-columns: 1fr; }
}

/* Profile only, without the menu (a user without any permission). */
.app-shell.is-portal { grid-template-columns: minmax(0, 1fr); }
.app-shell.is-portal .content-wrap { width: 100%; max-width: 1180px; margin: 0 auto; }
.portal-logo { display: block; height: 40px; width: auto; max-width: 46vw; margin-right: 6px; }
:root[data-theme="dark"] .portal-logo { padding: 4px 8px; border-radius: 8px; background: #fff; }

/* Avatar: the profile photo, or the user's initials. */
.avatar { --avatar-size: 40px; width: var(--avatar-size); height: var(--avatar-size); flex: none; display: inline-grid; place-items: center; overflow: hidden; border-radius: 50%; background: color-mix(in srgb, var(--brand-ink) 14%, var(--surface)); color: var(--brand-ink); font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: calc(var(--avatar-size) * 0.38); letter-spacing: 0.02em; line-height: 1; user-select: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-trigger .avatar { pointer-events: none; }
/* The top-bar profile button is the round avatar itself, with a thin ring. */
.topbar .profile-trigger { width: 46px; height: 46px; min-height: 46px; padding: 0; border-radius: 50%; }
.topbar .profile-trigger:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand-ink) 45%, transparent); outline-offset: 2px; }
.profile-summary { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 12px; }
.profile-summary > div { display: grid; gap: 2px; min-width: 0; }
.profile-summary small { overflow-wrap: anywhere; }

/* Profile page. */
.profile-hero { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 36px; align-items: center; padding: 32px 36px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: 0 10px 30px rgba(16, 42, 67, 0.06); }
.profile-photo { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.profile-photo .avatar { box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--line); }
.profile-photo-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 12px; }
.profile-photo-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 14px; font-weight: 700; cursor: pointer; transition: border-color .15s ease, background-color .15s ease; }
.profile-photo-btn svg { width: 18px; height: 18px; color: var(--brand-ink); }
.profile-photo-btn:hover { border-color: var(--brand-ink); background: var(--surface-2); }
.profile-photo-btn:focus-within { outline: 3px solid color-mix(in srgb, var(--brand-ink) 40%, transparent); outline-offset: 2px; }
.profile-photo-remove { min-height: 40px; padding: 8px 6px; background: none; border: 0; color: var(--text-muted); font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.profile-photo-remove:hover { color: var(--danger); }
.profile-photo-error { margin: 0; max-width: 220px; color: var(--danger); font-size: 14px; text-align: center; }
.profile-identity h2 { font-size: 30px; line-height: 1.15; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.profile-contact { display: grid; gap: 8px; margin: 16px 0 0; }
.profile-contact > div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; align-items: baseline; }
.profile-contact dt { color: var(--text-muted); font-size: 15px; font-weight: 600; }
.profile-contact dd { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.profile-missing { color: var(--text-muted); font-style: italic; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.profile-actions .button-link { min-height: 44px; }
.profile-modal { max-width: 560px; }

/* Profile > My assets. */
.my-assets { margin-top: 36px; }
.my-assets-head { display: flex; align-items: center; gap: 12px; }
.my-assets-head h2 { font-size: 24px; }
.my-assets-count { min-width: 32px; padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb, var(--brand-ink) 12%, transparent); color: var(--brand-ink); font-weight: 700; font-size: 15px; text-align: center; }
.my-assets-intro { margin: 6px 0 18px; color: var(--text-muted); font-size: 16px; }
.asset-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.asset-tile { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 20px 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); transition: border-color .2s ease, box-shadow .2s ease, transform .2s cubic-bezier(.2, .8, .2, 1); }
.asset-tile:hover { border-color: color-mix(in srgb, var(--brand-ink) 45%, var(--line)); box-shadow: 0 12px 28px rgba(16, 42, 67, 0.09); transform: translateY(-2px); }
.asset-tile-link { color: inherit; }
.asset-tile-link::after { content: ''; position: absolute; inset: 0; border-radius: 16px; }
.asset-tile-link:focus-visible { outline: none; }
.asset-tile-link:focus-visible::after { outline: 3px solid color-mix(in srgb, var(--brand-ink) 45%, transparent); outline-offset: 3px; }
.asset-tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; padding-top: 16px; }
.asset-tile-foot .asset-tile-more { margin-top: 0; padding-top: 0; }
.asset-tile-change { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font-size: 15px; font-weight: 700; transition: border-color .15s ease, background .15s ease; }
.asset-tile-change svg { width: 18px; height: 18px; color: var(--brand-ink); }
a.asset-tile-change:hover { border-color: var(--brand-ink); background: color-mix(in srgb, var(--brand-ink) 8%, var(--surface)); }
.asset-tile-change.is-disabled { color: var(--text-muted); background: var(--surface-2); cursor: not-allowed; font-weight: 600; }
.asset-tile.is-inactive { background: var(--surface-2); }
.asset-tile-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.asset-tile-type { display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 15px; font-weight: 600; }
.asset-tile-type .hw-icon { width: 24px; height: 24px; color: var(--brand-ink); }
.asset-tile-label { font-family: 'Space Grotesk', sans-serif; font-size: 22px; line-height: 1.2; }
.asset-tile-model { font-size: 16px; }
.asset-tile-meta { color: var(--text-muted); font-size: 14px; }
.asset-tile-more { display: inline-flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 16px; color: var(--brand-ink); font-size: 15px; font-weight: 700; }
.asset-tile-more svg { width: 18px; height: 18px; transition: transform .2s ease; }
.asset-tile:hover .asset-tile-more svg { transform: translateX(3px); }
.my-assets-empty { display: flex; align-items: center; gap: 18px; padding: 24px; border: 1px dashed var(--line); border-radius: 16px; color: var(--text-muted); font-size: 16px; }
.my-assets-empty .hw-icon { width: 44px; height: 44px; flex: none; }
.my-assets-empty p { margin: 0; }
.my-assets-empty strong { color: var(--text); }

/* Profile > one asset. */
.profile-back { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; margin-bottom: 12px; color: var(--brand-ink); font-size: 16px; font-weight: 700; }
.profile-back svg { width: 20px; height: 20px; }
.profile-back:hover { text-decoration: underline; text-underline-offset: 3px; }
.asset-hero { padding: 28px 32px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: 0 10px 30px rgba(16, 42, 67, 0.06); }
.asset-hero-main { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 20px; align-items: center; }
.asset-hero-icon { width: 72px; height: 72px; display: grid; place-items: center; border-radius: 18px; background: color-mix(in srgb, var(--brand-ink) 12%, var(--surface)); color: var(--brand-ink); }
.asset-hero-icon .hw-icon { width: 36px; height: 36px; }
.asset-hero-type { margin: 0; color: var(--brand-ink); font-size: 14px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.asset-hero-title h2 { margin: 2px 0 0; font-size: 32px; line-height: 1.1; }
.asset-hero-model { margin: 6px 0 0; color: var(--text-muted); font-size: 17px; }
.asset-hero-main .pill { align-self: start; }
.asset-glance { margin: 24px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1px; border: 1px solid var(--line); border-radius: 14px; background: var(--line); overflow: hidden; }
.asset-glance > div { padding: 12px 16px; background: var(--surface-2); }
.asset-glance dt { color: var(--text-muted); font-size: 13px; font-weight: 600; }
.asset-glance dd { margin: 2px 0 0; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.asset-glance dd.is-code, .asset-rows dd { font-variant-numeric: tabular-nums; }

.asset-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; margin-top: 20px; }
.asset-layout:has(.asset-side) { grid-template-columns: minmax(0, 1fr) 340px; }
.asset-side { display: grid; gap: 20px; position: sticky; top: 20px; }
.asset-panel { padding: 24px 28px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.asset-panel h3 { margin: 0 0 6px; font-size: 20px; }
.asset-panel-empty { margin: 8px 0 0; color: var(--text-muted); font-size: 16px; }
.asset-group + .asset-group { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--line); }
.asset-group h4 { margin: 0 0 2px; padding-top: 14px; color: var(--text-muted); font-family: 'Manrope', sans-serif; font-size: 13px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
/* Wide: two columns, label above value. Phones: one column, label beside value. */
.asset-rows { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
.asset-rows > div { padding: 12px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.asset-rows dt { color: var(--text-muted); font-size: 14px; }
.asset-rows dd { margin: 2px 0 0; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.asset-rows > div.is-text dd { margin: 0; font-weight: 500; }
.asset-rows > div:last-child, .asset-rows > div:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
.asset-remark { margin: 8px 0 0; font-size: 16px; }
.asset-stack { margin: 10px 0 0; display: grid; gap: 14px; }
.asset-stack dt { color: var(--text-muted); font-size: 14px; }
.asset-stack dd { margin: 2px 0 0; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }

/* Asset change requests (Profile and Asset Acceptance). */
.pill.wait { color: #92400e; background: #fef3c7; }
:root[data-theme="dark"] .pill.wait { color: #fcd34d; background: color-mix(in srgb, #f59e0b 16%, transparent); }
.my-requests { margin-top: 36px; }
.my-requests.is-waiting { padding: 22px 24px; border: 1px solid color-mix(in srgb, #f59e0b 45%, var(--line)); border-radius: 18px; background: color-mix(in srgb, #f59e0b 7%, var(--surface)); }
.my-requests.is-waiting .my-assets-count { background: #f59e0b; color: #fff; }
.my-requests.is-waiting + .my-assets { margin-top: 28px; }
.request-rows { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.request-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 16px; align-items: center; padding: 14px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); transition: border-color .15s ease; }
.request-row:hover { border-color: color-mix(in srgb, var(--brand-ink) 45%, var(--line)); }
.request-row-main { display: grid; gap: 2px; min-width: 0; }
.request-row-main strong { font-size: 16px; overflow-wrap: anywhere; }
.request-row-main small { color: var(--text-muted); font-size: 14px; }
.request-row-cta { display: inline-flex; align-items: center; gap: 6px; color: var(--brand-ink); font-size: 15px; font-weight: 700; }
.request-row-cta svg { width: 18px; height: 18px; }

.acr-tone-pending_hr { --tone: #b45309; --tone-bg: rgba(180, 83, 9, 0.08); }
.acr-tone-pending_holder { --tone: #2563eb; --tone-bg: rgba(37, 99, 235, 0.08); }
.acr-tone-approved { --tone: #0f766e; --tone-bg: rgba(15, 118, 110, 0.08); }
.acr-tone-rejected { --tone: #dc2626; --tone-bg: rgba(220, 38, 38, 0.08); }
.acr-tone-cancelled { --tone: #64748b; --tone-bg: rgba(100, 116, 139, 0.08); }
:root[data-theme="dark"] .acr-tone-pending_hr { --tone: #fbbf24; --tone-bg: rgba(251, 191, 36, 0.12); }
:root[data-theme="dark"] .acr-tone-pending_holder { --tone: #60a5fa; --tone-bg: rgba(96, 165, 250, 0.12); }
:root[data-theme="dark"] .acr-tone-approved { --tone: #2dd4bf; --tone-bg: rgba(45, 212, 191, 0.12); }
:root[data-theme="dark"] .acr-tone-rejected { --tone: #f87171; --tone-bg: rgba(248, 113, 113, 0.12); }
:root[data-theme="dark"] .acr-tone-cancelled { --tone: #94a3b8; --tone-bg: rgba(148, 163, 184, 0.12); }
.acr-cards { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.acr-tabs { margin-bottom: 18px; }
.acr-tabs .cts-tab-btn { text-decoration: none; }
.acr-callout { margin: 0 0 18px; padding: 12px 16px; border-radius: 12px; background: color-mix(in srgb, #2563eb 8%, var(--surface)); font-size: 15px; }
.acr-body { display: grid; gap: 22px; }

.acr-swap, .acr-form-swap { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 16px; align-items: stretch; }
.acr-swap-arrow { align-self: center; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--brand-ink) 12%, var(--surface)); color: var(--brand-ink); }
.acr-swap-arrow svg { width: 22px; height: 22px; }
.acr-asset { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); }
.acr-asset.is-to { border-color: color-mix(in srgb, var(--brand-ink) 40%, var(--line)); background: color-mix(in srgb, var(--brand-ink) 6%, var(--surface)); }
.acr-asset-side { margin: 0; color: var(--text-muted); font-size: 13px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.acr-asset-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; }
.acr-asset-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 12px; background: color-mix(in srgb, var(--brand-ink) 12%, var(--surface)); color: var(--brand-ink); }
.acr-asset-icon .hw-icon { width: 24px; height: 24px; }
.acr-asset-head > div > strong { display: block; font-family: 'Space Grotesk', sans-serif; font-size: 20px; line-height: 1.2; }
.acr-asset-head > div > span { display: block; color: var(--text-muted); font-size: 15px; overflow-wrap: anywhere; }
.acr-specs { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
.acr-specs dt { color: var(--text-muted); font-size: 13px; }
.acr-specs dd { margin: 0; font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
/* Asset Acceptance list: request, From / To cells (user, asset, all specs), status. */
.acr-list-table > tbody > tr > td { vertical-align: top; padding-top: 18px; padding-bottom: 18px; }
.acr-list-request { width: 190px; }
.acr-list-request .table-link { font-weight: 700; }
.acr-list-date { display: block; margin-top: 2px; color: var(--text-muted); font-size: 13px; }
.acr-list-reason { margin: 10px 0 0; max-width: 190px; color: var(--text-muted); font-size: 13px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.acr-list-cell { min-width: 250px; }
.acr-list-cell.is-to { position: relative; padding-left: 30px; }
.acr-list-arrow { position: absolute; left: -12px; top: 22px; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--brand-ink); }
.acr-list-arrow svg { width: 14px; height: 14px; }
.acr-list-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.acr-list-person > div { min-width: 0; }
.acr-list-person strong { display: block; font-size: 15px; line-height: 1.3; }
.acr-list-person strong.is-muted { color: var(--text-muted); }
.acr-list-person small { display: block; color: var(--text-muted); font-size: 13px; overflow-wrap: anywhere; }
.acr-list-nobody { width: 32px; height: 32px; flex: none; border-radius: 50%; border: 1.5px dashed var(--line); }
.acr-list-asset { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.acr-list-icon { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 9px; background: color-mix(in srgb, var(--brand-ink) 10%, var(--surface)); color: var(--brand-ink); }
.acr-list-icon .hw-icon { width: 18px; height: 18px; }
.acr-list-asset strong { display: block; font-size: 15px; line-height: 1.3; }
.acr-list-asset span:not(.acr-list-icon) { display: block; color: var(--text-muted); font-size: 13px; }
.acr-list-specs { margin: 10px 0 0 42px; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 14px; font-size: 13px; }
.acr-list-specs > div { display: contents; }
.acr-list-specs dt { color: var(--text-muted); }
.acr-list-specs dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.acr-list-specs dd.is-diff { justify-self: start; margin-left: -5px; padding: 0 5px; border-radius: 5px; background: color-mix(in srgb, var(--brand-ink) 11%, transparent); color: var(--brand-ink); }
.acr-list-gone { margin: 14px 0 0; color: var(--text-muted); font-size: 13px; }
.acr-list-status { min-width: 170px; }
.acr-list-status .pill { white-space: nowrap; }
.acr-list-status small { display: block; margin-top: 6px; color: var(--text-muted); font-size: 13px; line-height: 1.4; }
.acr-asset-user { margin: auto 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 15px; font-weight: 600; }
.acr-asset-user span { display: block; color: var(--text-muted); font-size: 13px; font-weight: 600; }
.acr-asset-user small { display: block; color: var(--text-muted); font-size: 14px; font-weight: 500; }

.acr-facts { margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; border: 1px solid var(--line); border-radius: 14px; background: var(--line); overflow: hidden; }
.acr-facts > div { padding: 12px 16px; background: var(--surface); }
.acr-facts > div.is-wide { grid-column: 1 / -1; }
.acr-facts dt { color: var(--text-muted); font-size: 13px; font-weight: 600; }
.acr-facts dd { margin: 2px 0 0; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.acr-facts > div.is-wide dd { font-weight: 500; }

.acr-steps h3, .acr-files h3 { margin: 0 0 12px; font-size: 19px; }
.acr-steps ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 0; }
.acr-steps ol > li { position: relative; display: grid; gap: 2px; padding: 0 0 18px 34px; }
.acr-steps ol > li::before { content: ''; position: absolute; left: 0; top: 2px; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); box-sizing: border-box; }
.acr-steps ol > li::after { content: ''; position: absolute; left: 8px; top: 24px; bottom: 2px; width: 2px; background: var(--line); }
.acr-steps ol > li:last-child { padding-bottom: 0; }
.acr-steps ol > li:last-child::after { display: none; }
.acr-steps ol > li.is-done::before { border-color: var(--brand-1, #0f766e); background: var(--brand-1, #0f766e); box-shadow: inset 0 0 0 3px var(--surface); }
.acr-steps ol > li.is-current::before { border-color: #f59e0b; background: color-mix(in srgb, #f59e0b 25%, var(--surface)); }
.acr-steps ol > li.is-rejected::before { border-color: var(--danger); background: var(--danger); box-shadow: inset 0 0 0 3px var(--surface); }
.acr-steps ol > li strong { font-size: 16px; }
.acr-steps ol > li span { color: var(--text-muted); font-size: 15px; }
.acr-steps ol > li.is-current span { color: #b45309; font-weight: 600; }
:root[data-theme="dark"] .acr-steps ol > li.is-current span { color: #fbbf24; }
.acr-steps ol > li .acr-step-note { color: var(--text); }
.acr-outcome { margin-top: 18px; padding: 14px 18px; border-radius: 14px; background: var(--surface-2); }
.acr-outcome p { margin: 0 0 6px; color: var(--text-muted); font-size: 13px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.acr-outcome ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 15px; }

.acr-page { display: grid; gap: 22px; }
.acr-page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.acr-page-head h2 { margin: 2px 0 0; font-size: 30px; line-height: 1.1; }
.acr-page-cancel { margin-left: auto; }
.acr-answer { padding: 20px 22px; border: 1px solid color-mix(in srgb, #f59e0b 45%, var(--line)); border-radius: 16px; background: color-mix(in srgb, #f59e0b 7%, var(--surface)); }
.acr-answer h3 { margin: 0; font-size: 19px; }
.acr-answer > p { margin: 4px 0 14px; color: var(--text-muted); font-size: 15px; }
.acr-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.acr-choice { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; }
.acr-choice:has(input:checked) { border-color: var(--brand-ink); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-ink) 20%, transparent); }
.acr-choice input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand-1, #0f766e); }
.acr-choice strong { display: block; font-size: 16px; }
.acr-choice small { display: block; color: var(--text-muted); font-size: 14px; }
.acr-choice.is-disabled { opacity: .6; cursor: not-allowed; }
.acr-new-asset { display: grid; gap: 6px; margin-top: 12px; max-width: 420px; font-weight: 600; }
.acr-new-asset[hidden] { display: none; }
.acr-answer-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.acr-form { display: grid; gap: 18px; }
.acr-form-head h2 { margin: 0; font-size: 28px; }
.acr-form-head p { margin: 6px 0 0; color: var(--text-muted); font-size: 16px; max-width: 70ch; }
.acr-form h3 { margin: 0 0 12px; font-size: 19px; }
.acr-form .acr-facts > div { background: var(--surface-2); }
.acr-field { display: grid; gap: 6px; margin-bottom: 14px; font-weight: 600; }
.acr-preview { display: grid; gap: 12px; padding: 16px; border-radius: 14px; background: var(--surface-2); }
.acr-preview[hidden], .acr-empty[hidden], .acr-preview-hint[hidden] { display: none; }
.acr-preview-hint, .acr-empty { margin: 0; padding: 16px; border: 1px dashed var(--line); border-radius: 14px; color: var(--text-muted); font-size: 15px; }
.acr-warning { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; margin: 0; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, #f59e0b 14%, var(--surface)); color: var(--text); font-size: 15px; }
.acr-warning svg { width: 20px; height: 20px; color: #b45309; }
:root[data-theme="dark"] .acr-warning svg { color: #fbbf24; }
.acr-form-actions { display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 1080px) {
    .acr-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .acr-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .acr-swap, .acr-form-swap { grid-template-columns: 1fr; }
    .acr-swap-arrow { justify-self: center; transform: rotate(90deg); }
    .acr-choices { grid-template-columns: 1fr; }
    .request-row { grid-template-columns: 1fr; gap: 8px; }
    .request-row .pill { justify-self: start; }
    .request-row-cta { display: none; }
    .acr-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .acr-tabs .cts-tab-btn { flex: none; padding: 12px 14px; }
}
@media (max-width: 640px) {
    .acr-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .my-requests.is-waiting { padding: 18px 16px; }
    .acr-page-head h2, .acr-form-head h2 { font-size: 24px; }
    .acr-page-cancel { margin-left: 0; width: 100%; }
    .acr-page-cancel .button-link { width: 100%; justify-content: center; }
    .acr-form-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .acr-form-actions .button-link { justify-content: center; }
    .acr-answer-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .acr-answer-actions .button-link { justify-content: center; }
    .asset-tile-foot { flex-wrap: wrap; }
}
@media (max-width: 380px) {
    .acr-facts, .acr-specs { grid-template-columns: 1fr; }
}

@media (max-width: 1080px) {
    .asset-layout, .asset-layout:has(.asset-side) { grid-template-columns: 1fr; }
    .asset-side { position: static; }
}
@media (max-width: 640px) {
    /* Profile only (no menu): the logo already says where you are, so the title is left for screen readers. */
    .app-shell.is-portal .title-wrap h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .portal-logo { height: 30px; max-width: 100%; }
    .profile-hero { padding: 24px 18px 20px; border-radius: 18px; }
    .profile-photo .avatar { width: 96px; height: 96px; font-size: 36px; }
    .profile-identity { width: 100%; }
    .profile-identity h2 { font-size: 26px; }
    .profile-contact { margin-top: 14px; gap: 0; border: 1px solid var(--line); border-radius: 14px; text-align: left; overflow: hidden; }
    .profile-contact > div { padding: 10px 14px; background: var(--surface-2); }
    .profile-contact > div + div { border-top: 1px solid var(--line); }
    .profile-contact dt { font-size: 14px; }
    .profile-contact dd { font-size: 16px; }
    .profile-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
    .profile-actions .button-link { width: 100%; justify-content: center; padding-left: 8px; padding-right: 8px; }
    .my-assets { margin-top: 28px; }
    .my-assets-head h2 { font-size: 22px; }
    .my-assets-intro { margin-bottom: 14px; font-size: 15px; }
    .asset-tiles { gap: 12px; }
    .asset-tile { padding: 18px; }
    .asset-hero, .asset-panel { padding: 20px 18px; border-radius: 18px; }
    .asset-hero-main { gap: 14px; }
    .asset-hero-icon { width: 56px; height: 56px; border-radius: 16px; }
    .asset-hero-icon .hw-icon { width: 28px; height: 28px; }
    .asset-hero-title h2 { font-size: 26px; }
    .asset-hero-model { font-size: 16px; }
    .asset-glance { grid-template-columns: 1fr 1fr; margin-top: 18px; }
    .asset-glance > div:has(.is-code) { grid-column: 1 / -1; }
    .asset-layout, .asset-side { gap: 14px; }
    .asset-layout { margin-top: 14px; }
    .asset-rows { grid-template-columns: 1fr; }
    .asset-rows > div { display: grid; grid-template-columns: minmax(0, 40%) minmax(0, 1fr); gap: 12px; padding: 11px 0; }
    .asset-rows > div.is-text { grid-template-columns: 1fr; }
    .asset-rows dd { margin: 0; }
    .asset-rows > div:nth-last-child(2):nth-child(odd) { border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
}
@media (max-width: 380px) {
    .profile-actions { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
    .profile-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 28px 20px; gap: 20px; }
    .profile-contact > div { grid-template-columns: 1fr; gap: 0; }
    .profile-actions { justify-content: center; }
    .asset-hero-main { grid-template-columns: auto minmax(0, 1fr); }
    .asset-hero-main .pill { grid-column: 2; grid-row: 2; justify-self: start; }
}
@media (prefers-reduced-motion: reduce) {
    .asset-tile, .asset-tile-more svg { transition: none; }
    .asset-tile:hover { transform: none; }
}

/*
 * Lists on phones: the expiry cards, the buttons above a list, the search, and the table rows as
 * cards (global.js labels each cell with its column and adds a "Sort by" picker).
 */
.mobile-sort { display: none; }
@media (max-width: 640px) {
    .expiry-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .expiry-card { padding: 12px 14px; }
    .expiry-card strong { font-size: 28px; }
    .expiry-card:last-child:nth-child(odd) { grid-column: 1 / -1; }

    .section-head:has(.section-actions) { gap: 14px; }
    .section-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 8px; }
    .section-actions > * { width: 100%; justify-content: center; text-align: center; min-height: 44px; margin: 0; }
    /* The main action (Add …) first and full width; Export / Import side by side under it. */
    .section-actions > .button-link:not(.secondary) { grid-column: 1 / -1; order: -1; }
    /* An odd last secondary button (e.g. Import after the two exports) takes the full row. */
    .section-actions > .secondary:nth-last-child(2):nth-child(odd) { grid-column: 1 / -1; }

    .db-search-bar select { flex: 1 1 100%; min-height: 44px; }
    .db-search-bar input[type="date"] { flex: 1 1 0; min-width: 0; min-height: 44px; }

    .list-search { gap: 10px; padding: 12px; }
    .list-search .db-search-input { flex: 1 1 calc(100% - 30px); min-width: 0; font-size: 16px; }
    .list-date-range { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; width: 100%; }
    .list-date-range > span:first-child { grid-column: 1 / -1; font-size: 14px; }
    .list-date-range input { width: 100%; min-width: 0; min-height: 44px; }
    .list-search .db-search-btn { flex: 1 1 auto; min-height: 44px; }
    .list-search .db-reset-btn { min-height: 44px; display: inline-flex; align-items: center; }

    .mobile-sort { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 15px; font-weight: 700; color: var(--text-muted); }
    .mobile-sort select { flex: 1; min-width: 0; min-height: 44px; font-size: 16px; }

    .table-wrap.can-cards { overflow: visible; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
    .table-wrap.can-cards > table,
    .table-wrap.can-cards > table > tbody,
    .table-wrap.can-cards > table > tbody > tr,
    .table-wrap.can-cards > table > tbody > tr > td { display: block; width: 100%; }
    .table-wrap.can-cards > table { min-width: 0; border: 0; background: transparent; }
    .table-wrap.can-cards > table > thead { display: none; }
    .table-wrap.can-cards > table > tbody > tr { margin-bottom: 12px; padding: 6px 16px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 4px 14px rgba(18, 34, 42, 0.05); }
    /* Label on the left (absolutely placed), the cell's own content flowing on the right. */
    .table-wrap.can-cards > table > tbody > tr > td { position: relative; padding: 8px 0 8px calc(36% + 12px); min-height: 38px; border: 0; background: transparent; white-space: normal; text-align: left; font-size: 15px; box-shadow: none; overflow-wrap: anywhere; }
    .table-wrap.can-cards > table > tbody > tr > td::before { content: attr(data-label); position: absolute; left: 0; top: 9px; width: 36%; color: var(--text-muted); font-size: 14px; font-weight: 600; overflow-wrap: break-word; }
    .table-wrap.can-cards > table > tbody > tr > td:not([data-label])::before { content: none; }
    .table-wrap.can-cards > table > tbody > tr > td:not([data-label]) { padding-left: 0; }
    /* Asset Acceptance From / To: label above, the user, asset and specs at full width. */
    .table-wrap.can-cards > table > tbody > tr > td.acr-list-cell { min-width: 0; padding: 32px 0 10px; }
    .table-wrap.can-cards > table > tbody > tr > td.acr-list-request { width: auto; }
    .acr-list-arrow { display: none; }
    .table-wrap.can-cards > table > tbody > tr > td.acr-list-cell.is-to { margin-top: 8px; border-top: 1px solid var(--line); }
    .acr-list-reason { max-width: none; }
    .table-wrap.can-cards > table > tbody > tr > td.acr-list-cell::before { width: 100%; }
    .table-wrap.can-cards > table > tbody > tr > td.cell-index { display: none !important; }
    /* No sticky "row actions" column on a card. */
    .table-wrap.can-cards > table > tbody > tr > td:last-child { position: static !important; box-shadow: none !important; }
    .table-wrap.can-cards > table > tbody > tr > td.actions :is(a, button) { white-space: nowrap; }
    /* The first column (ID, name, label…) is the card's title. */
    .table-wrap.can-cards > table > tbody > tr > td:first-child:not([colspan]),
    .table-wrap.can-cards > table > tbody > tr > td.cell-index + td { display: block; padding: 10px 0; margin-bottom: 4px; border-bottom: 1px solid var(--line); font-size: 17px; font-weight: 700; }
    /* A card with only a title and actions (Master Data): one divider, not two. */
    .table-wrap.can-cards > table > tbody > tr > td.cell-index + td + td.actions { margin-top: 0; padding-top: 10px; border-top: 0; }
    .table-wrap.can-cards > table > tbody > tr > td:first-child:not([colspan])::before,
    .table-wrap.can-cards > table > tbody > tr > td.cell-index + td::before { content: none; }
    .table-wrap.can-cards > table > tbody > tr > td[colspan] { display: block; padding: 18px 0 10px; text-align: center; color: var(--text-muted); }
    .table-wrap.can-cards > table > tbody > tr > td.actions { padding-left: 0; min-height: 0; overflow-wrap: normal; }
    .table-wrap.can-cards > table > tbody > tr > td[colspan]::before { content: none; }
    .table-wrap.can-cards > table > tbody > tr > td.actions { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
    .table-wrap.can-cards > table > tbody > tr > td.actions::before { content: none; }
    .table-wrap.can-cards > table > tbody > tr > td.actions > :is(a, form, button) { flex: 1 1 0; margin: 0; }
    .table-wrap.can-cards > table > tbody > tr > td.actions > a,
    .table-wrap.can-cards > table > tbody > tr > td.actions button { width: 100%; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
}
