/* ==========================================================================
   Asset Manager — theme tokens, then layout, then components.
   Dark mode is driven by <html data-theme="dark"> (set by the toggle / system pref).
   ========================================================================== */

:root,
:root[data-theme="light"] {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #e2e5ea;
    --text: #1a2230;
    --muted: #667085;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-contrast: #ffffff;
    --accent-soft: #eef0ff;
    --danger: #b42318;
    --danger-bg: #fef3f2;
    --danger-border: #fecdca;
    --success: #067647;
    --success-bg: #ecfdf3;
    --success-border: #abefc6;
    --info: #175cd3;
    --info-bg: #eff8ff;
    --info-border: #b2ddff;
    --warn: #b54708;
    --warn-bg: #fffaeb;
    --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
    --sidebar-bg: #ffffff;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1d2430;
    --border: #2b3340;
    --text: #e6e9ef;
    --muted: #98a2b3;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-contrast: #0d1117;
    --accent-soft: #232a4a;
    --danger: #fda29b;
    --danger-bg: #3a1a18;
    --danger-border: #6e2a25;
    --success: #75e0a7;
    --success-bg: #12301f;
    --success-border: #1f5a39;
    --info: #84caff;
    --info-bg: #14263d;
    --info-border: #1f4a7a;
    --warn: #fec84b;
    --warn-bg: #3a2a0c;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    --sidebar-bg: #12171e;
    color-scheme: dark;
}

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

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    transition: background-color .15s ease, color .15s ease;
}

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

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

.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.icon { flex: none; }

/* ---------- App shell ---------- */

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

.sidebar {
    width: 240px;
    flex: none;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 18px;
    color: var(--text);
    font-weight: 650;
    font-size: 1.05rem;
}
.brand:hover { text-decoration: none; color: var(--text); }

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--accent);
    color: var(--accent-contrast);
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 56px;
    padding: 0 24px;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar-title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    color: var(--text);
    font-weight: 500;
}
.user-chip:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }

.content { padding: 24px; max-width: 1280px; width: 100%; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.icon-btn.menu-btn { display: none; }
.scrim { display: none; }

@media (max-width: 860px) {
    .sidebar {
        position: fixed;
        z-index: 30;
        left: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: var(--shadow);
    }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / 45%); }
    .icon-btn.menu-btn { display: inline-grid; }
    .topbar { padding: 0 12px; }
    .content { padding: 16px 12px; }
    .user-chip span { display: none; }
}

/* ---------- Components ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat { padding: 16px 18px; }
a.stat-link { display: block; color: inherit; text-decoration: none; }
a.stat-link:hover { border-color: var(--accent); color: inherit; text-decoration: none; }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 1.75rem; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 18px; text-align: left; border-bottom: 1px solid var(--border); }
.table th {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    font-weight: 600;
    background: var(--surface-2);
}
.table th.num, .table td.num { text-align: right; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }

.badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 600;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
}
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }

.empty { padding: 32px 18px; text-align: center; color: var(--muted); }

.pager { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 14px; border-top: 1px solid var(--border); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 550;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-contrast); }
.btn-block { width: 100%; padding: 10px 14px; }
.btn-danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.card.danger-card { border-color: var(--danger-border); }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.inline-form { margin: 0; display: inline-flex; }

/* Theme toggle shows the icon for the mode you'd switch to. */
[data-theme="dark"] .only-light { display: none; }
:root:not([data-theme="dark"]) .only-dark { display: none; }

/* Forms */
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-weight: 550; font-size: .9rem; }
.field small { display: block; margin-top: 4px; }
input[type="text"], input[type="password"], input[type="search"], input[type="email"], input[type="number"], select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}
input::placeholder { color: var(--muted); opacity: .8; }
input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

.form-card { padding: 20px; max-width: 460px; }
.form-card.wide { max-width: 760px; }
/* Form pages: header, alerts and cards share one column, so header buttons line up with the cards. */
.narrow-col { max-width: 760px; }
.narrow-col .form-card { max-width: none; }
/* Full-width form pages (Theme, Email): the same width as the list pages; cards fill it. */
.wide-col .form-card { max-width: none; }
.form-card h2 { margin-bottom: 14px; }
.form-card > p { margin-bottom: 14px; }
.form-card .card-head { margin: -20px -20px 14px; }
.form-card .card-head h2 { margin: 0; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.center { text-align: center !important; }
.perm-note { margin-bottom: 8px; }
.perm-table td, .perm-table th { padding: 8px 14px; }
.perm-table input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; }
input[type="file"] { width: 100%; padding: 8px; border: 1px dashed var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); font: inherit; }
.issue-list { margin: 0; padding-left: 20px; }
.issue-list li { margin-bottom: 8px; }
.issue-list .small { display: block; }
.upload-warning { color: var(--danger); font-weight: 600; }
.upload-warning[hidden] { display: none; }
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    resize: vertical;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
input[type="date"] { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
input:disabled { opacity: .6; cursor: not-allowed; }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }

/* A search box is 320px wide but may shrink. It needs a definite width (not a percentage or flex-basis):
   its wrapper is sized by its contents, so anything relative to the wrapper made neighbours wrap. */
.search { position: relative; flex: 0 1 auto; width: 320px; min-width: 180px; max-width: 100%; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 34px; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 8px; border: 1px solid; margin-bottom: 16px; font-size: .92rem; }
.alert-danger  { background: var(--danger-bg);  border-color: var(--danger-border);  color: var(--danger); }
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.alert-warning { background: var(--warn-bg);    border-color: var(--warn);            color: var(--warn); }
.alert-info    { background: var(--info-bg);    border-color: var(--info-border);    color: var(--info); }

/* ---------- Login / error pages ---------- */

.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-theme { position: fixed; top: 12px; right: 12px; }
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card { padding: 28px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand .brand-mark { width: 44px; height: 44px; border-radius: 12px; margin-bottom: 10px; }
.auth-brand h1 { font-size: 1.35rem; }

.search-form { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
.search-form select { width: auto; flex: none; }
@media (max-width: 620px) {
    /* On phones: the search box gets a full row; the filter and the action button share the next one. */
    .page-actions { width: 100%; }
    .search-form { display: contents; }
    .search-form .search, .page-actions > .search { width: 100%; flex: 1 1 100%; }
    .search-form select, .search-form .btn, .page-actions > .btn { flex: 1 1 0; }
    .search-form .btn-icon { flex: none; }
}

/* Asset filters: the Filter button, its panel, and the chips for what is applied */
.btn-icon { padding: 8px 10px; flex: none; }
.filter-count:empty { display: none; }
.filter-panel { padding: 16px 18px 12px; margin-bottom: 16px; }
.filter-group { border: 0; margin: 0 0 6px; padding: 0; min-width: 0; }
.filter-group legend { padding: 0; margin-bottom: 8px; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 14px; }
.filter-grid.wide { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.filter-grid .field { margin-bottom: 12px; min-width: 0; }
.field .field-label { display: block; margin-bottom: 6px; font-weight: 550; font-size: .9rem; }
/* minmax(0, 1fr) and min-width 0 let two date boxes shrink to fit their cell instead of spilling out of it. */
.range { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.range > * { min-width: 0; }
.range input[type="date"] { padding-left: 8px; padding-right: 8px; }
/* The list of choices floats over the content below, like a normal drop-down. */
.pick { position: relative; }
.pick summary { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.pick summary::-webkit-details-marker { display: none; }
.pick summary::after { content: "▾"; color: var(--muted); }
.pick[open] summary { border-color: var(--accent); }
.pick-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30; min-width: 200px; max-height: 240px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-lg, 0 8px 24px rgba(0, 0, 0, .18)); padding: 6px 10px; }
.pick-list label { display: flex; gap: 8px; align-items: center; margin: 0; padding: 3px 0; font-size: .9rem; font-weight: 400; cursor: pointer; }
.pick-list input { accent-color: var(--accent); }
.filter-group > p { margin: 0 0 12px; }
.filter-foot { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding-top: 4px; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .85rem; font-weight: 600; text-decoration: none; }
.chip:hover { text-decoration: none; filter: brightness(.95); }
.chip-clear { font-size: .85rem; }
.check-col { width: 36px; padding-right: 0 !important; }
.check-col input { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: middle; }
.is-retired td { color: var(--muted); }
.more-note { padding: 0 18px 14px; }
.bulk-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 10px 18px;
    background: var(--accent-soft);
    border-bottom: 1px solid var(--border);
    border-radius: 12px 12px 0 0;
}
.bulk-bar[hidden], .bulk-bar [hidden] { display: none; }
.bulk-count { font-weight: 600; }
.bulk-buttons { margin-left: auto; display: flex; gap: 8px; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.back-link { display: inline-block; margin-bottom: 6px; font-size: .88rem; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.section { margin-top: 20px; }
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0;
    margin: 0;
}
.detail-grid > div { padding: 12px 18px; border-bottom: 1px solid var(--border); min-width: 0; }
.detail-grid dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; }
.notes { padding: 14px 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.auth-wide { max-width: 560px; margin: 24px 0; }
.small { font-size: .85rem; }
.note { margin-top: 12px; }
.form-section { margin-bottom: 22px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.form-section:last-of-type { border-bottom: 0; }
.form-section h2 { margin-bottom: 12px; }
.form-section > p { margin-bottom: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 110px; gap: 12px; }
.field-row.even { grid-template-columns: 1fr 1fr; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 16px; font-size: .9rem; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.steps { margin: 0 0 16px; padding-left: 20px; }
.steps li { margin-bottom: 6px; }
code { font-size: .88em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.code-block { overflow: auto; background: var(--surface-2); padding: 12px; border-radius: 8px; font-size: .8rem; }
.badge-ok { background: var(--success-bg); color: var(--success); border-color: transparent; }

@media (max-width: 520px) {
    .field-row, .field-row.even { grid-template-columns: 1fr; gap: 0; }
}

.error-card { padding: 40px 24px; text-align: center; max-width: 520px; margin: 40px auto; }
.error-code { font-size: 3rem; font-weight: 700; color: var(--accent); line-height: 1; margin-bottom: 8px; }
.error-card h1 { margin-bottom: 8px; }
.error-card p { margin-bottom: 16px; }
.error-detail { text-align: left; overflow: auto; font-size: .8rem; background: var(--surface-2); padding: 12px; border-radius: 8px; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* ---------- Attachments ---------- */
.attach-form { padding: 16px 18px 4px; border-bottom: 1px solid var(--border); }
.attach-form input[type="file"] { max-width: 100%; }
.attach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; padding: 16px 18px; }
.attach-tile { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.attach-thumb {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    aspect-ratio: 4 / 3; background: var(--surface-2); color: var(--muted); text-decoration: none; overflow: hidden;
}
.attach-thumb:hover { color: var(--text); text-decoration: none; }
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-kind { font-size: .75rem; font-weight: 700; letter-spacing: .05em; }
.attach-body { padding: 10px 12px 12px; min-width: 0; }
.attach-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-caption { margin: 2px 0; overflow-wrap: anywhere; }
.attach-actions { display: flex; gap: 12px; margin-top: 6px; }
.attach-delete { color: var(--danger); }
.attach-preview { max-width: 100%; max-height: 260px; border-radius: 8px; border: 1px solid var(--border); }
.paperclip { display: inline-flex; align-items: center; gap: 2px; margin-left: 6px; color: var(--muted); font-size: .8rem; vertical-align: middle; }
.dropzone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    background: var(--surface);
    transition: border-color .15s, background-color .15s;
}
.dropzone.is-over { border-color: var(--accent); background: var(--surface-2); }
.dropzone-text { margin: 0 0 8px; color: var(--muted); }
.dropzone input[type="file"] { display: block; max-width: 100%; }
.file-list { margin: 10px 0 0; padding-left: 20px; font-size: .88rem; overflow-wrap: anywhere; }

/* Sortable table headers */
.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-link:hover { color: var(--accent); text-decoration: none; }
.table th[aria-sort="ascending"], .table th[aria-sort="descending"] { color: var(--text); }
.sort-arrow { font-size: .65rem; margin-left: 2px; }

/* ---------- Theme page ---------- */
.palette-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-top: 12px; }
.palette {
    position: relative; display: flex; flex-direction: column; gap: 6px; padding: 10px;
    border: 2px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer;
}
.palette:hover { border-color: var(--muted); }
.palette.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.palette:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.palette input { position: absolute; opacity: 0; pointer-events: none; }
.palette-name { font-weight: 600; font-size: .9rem; }
.palette-custom { min-height: 46px; }
.swatches { display: flex; height: 20px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
.swatches span { flex: 1; }
.colour-table td { vertical-align: middle; }
.colour-table input[type="color"] { width: 44px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; vertical-align: middle; }
.hex { margin-left: 8px; }
.contrast-note { margin-top: 10px; color: var(--success); }
.contrast-note.is-bad { color: var(--danger); font-weight: 600; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 12px; }
/* The preview panels set their own colour variables (from theme.js), so they show the chosen light or dark look. */
.pv { display: flex; min-height: 190px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg); color: var(--text); }
.pv-side { width: 38%; padding: 10px; display: flex; flex-direction: column; gap: 4px; background: var(--sidebar-bg); border-right: 1px solid var(--border); }
.pv-brand { display: flex; align-items: center; gap: 6px; font-weight: 650; font-size: .85rem; margin-bottom: 8px; overflow: hidden; white-space: nowrap; }
.pv-mark { flex: none; width: 16px; height: 16px; border-radius: 5px; background: var(--accent); }
.pv-nav { padding: 4px 6px; border-radius: 6px; font-size: .8rem; color: var(--muted); }
.pv-nav.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pv-main { flex: 1; padding: 10px; }
.pv-card { padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: .8rem; display: flex; flex-direction: column; gap: 4px; }
.pv-link { color: var(--accent); }
.pv-muted { color: var(--muted); }
.pv-btn { display: inline-block; padding: 3px 10px; border-radius: 6px; background: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.pv-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.reset-form { margin: 18px 0 8px; }

/* ---------- Email page ---------- */
.label-like { display: block; margin-bottom: 6px; font-weight: 550; font-size: .9rem; }
.log-to { font-size: .85rem; white-space: nowrap; }

/* ---------- Departments & types ---------- */
.usage-list { margin: 0 0 14px; padding-left: 20px; }
.usage-list li { margin-bottom: 4px; }

/* Tabs: ordinary links, one per list, with the current one marked (Reference data) */
.tabs { display: flex; gap: 4px; margin: 0 0 16px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
    padding: 10px 14px; white-space: nowrap; font-weight: 550;
    color: var(--muted); border-bottom: 2px solid transparent; text-decoration: none;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-count { margin-left: 4px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .78rem; font-weight: 600; }
.tab.is-active .tab-count { background: var(--accent-soft); color: var(--accent); }

/* The one-time temporary password after creating a user */
.temp-password { margin: 12px 0 0; }
.temp-password code { font-size: 1.4rem; letter-spacing: .06em; padding: 10px 14px; user-select: all; }

.perm-all td { background: var(--surface-2); }
.perm-all[hidden] { display: none; }

/* ----- Toasts (messages after an action; see app.js and templates/partials-flashes.php) ----- */
.toasts {
    position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
    z-index: 1000; display: flex; flex-direction: column; gap: 8px;
    width: min(520px, calc(100vw - 24px)); pointer-events: none;
}
.toast {
    pointer-events: auto; position: relative; overflow: hidden;
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 12px 12px 14px; border: 1px solid; border-radius: 10px;
    background: var(--surface); box-shadow: 0 8px 24px rgb(16 24 40 / 18%), 0 2px 6px rgb(16 24 40 / 10%);
    font-size: .92rem; line-height: 1.4;
    animation: toast-in .22s ease-out;
}
.toast.is-leaving { animation: toast-out .2s ease-in forwards; }
.toast-icon { flex: none; width: 20px; height: 20px; margin-top: 1px; display: grid; place-items: center; border-radius: 50%; font-size: .75rem; font-weight: 700; color: #fff; }
.toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--text); }
.toast-close { flex: none; border: 0; background: transparent; color: var(--muted); font-size: 1.2rem; line-height: 1; padding: 0 4px; cursor: pointer; border-radius: 6px; }
.toast-close:hover { color: var(--text); background: var(--surface-2); }
.toast-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; transform-origin: left; animation: toast-bar linear forwards; }

.toast-success { border-color: var(--success-border); } .toast-success .toast-icon, .toast-success .toast-bar { background: var(--success); }
.toast-info    { border-color: var(--info-border); }    .toast-info .toast-icon,    .toast-info .toast-bar    { background: var(--info); }
.toast-warning { border-color: var(--warn); }           .toast-warning .toast-icon, .toast-warning .toast-bar { background: var(--warn); }
.toast-danger  { border-color: var(--danger-border); }  .toast-danger .toast-icon,  .toast-danger .toast-bar  { background: var(--danger); }
:root[data-theme="dark"] .toast-icon { color: #0d1117; }

@keyframes toast-in  { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(-12px); } }
@keyframes toast-bar { to   { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .toast, .toast.is-leaving { animation-duration: 1ms; } .toast-bar { display: none; } }

.auth-alt { text-align: center; margin: 14px 0 0; font-size: .9rem; }
/* Plain reading text (the privacy policy). */
.prose { line-height: 1.55; }
.prose h1 { font-size: 1.35rem; margin-bottom: 4px; }
.prose h2 { margin: 20px 0 6px; }
.prose p, .prose ul { margin: 0 0 10px; }
.prose ul { padding-left: 20px; }
.prose li { margin-bottom: 4px; }
/* "or" rule between the password form and Google's button. */
.auth-or { display: flex; align-items: center; gap: 12px; margin: 20px 0 16px; color: var(--muted); font-size: .85rem; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
/* Google's button sits in an iframe; a light colour scheme keeps it from getting an opaque box in dark mode. */
.google-signin { display: flex; justify-content: center; color-scheme: light; min-height: 44px; }
