/* ==========================================================================
   Silk Naviora Admin — component layer
   --------------------------------------------------------------------------
   Every component here is token-driven and theme-agnostic. Loaded after
   Bootstrap's reboot/grid/utilities, which supply layout primitives only —
   all visual opinion lives in this file.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    color: var(--fg);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: var(--fw-semibold);
    line-height: var(--lh-tight);
    color: var(--fg-strong);
}

p { margin: 0 0 var(--sp-3); }
p:last-child { margin-bottom: 0; }

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

hr {
    height: 1px;
    margin: var(--sp-5) 0;
    border: 0;
    background: var(--border);
    opacity: 1;
}

code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.9em; }

/* One focus treatment for the whole product. Visible, branded, never removed. */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--r-xs);
}

::selection { background: var(--primary-soft); color: var(--primary-soft-fg); }

/* Scrollbars — subtle, themed, out of the way. */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border: 3px solid transparent;
    border-radius: var(--r-full);
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--fg-subtle); background-clip: content-box; }

/* Screen-reader-only, plus a skip link that becomes visible on focus. */
.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;
}
.skip-link {
    position: fixed; top: var(--sp-2); left: var(--sp-2);
    z-index: 100;
    padding: var(--sp-2) var(--sp-4);
    background: var(--primary); color: var(--primary-fg);
    border-radius: var(--r-md);
    font-weight: var(--fw-semibold);
    transform: translateY(-200%);
    transition: transform var(--dur) var(--ease);
}
.skip-link:focus { transform: translateY(0); color: var(--primary-fg); text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* --------------------------------------------------------------------------
   2. Type helpers
   -------------------------------------------------------------------------- */
.t-2xs  { font-size: var(--fs-2xs); }
.t-xs   { font-size: var(--fs-xs); }
.t-sm   { font-size: var(--fs-sm); }
.t-base { font-size: var(--fs-base); }
.t-md   { font-size: var(--fs-md); }
.t-lg   { font-size: var(--fs-lg); }
.t-xl   { font-size: var(--fs-xl); }
.t-2xl  { font-size: var(--fs-2xl); }
.t-3xl  { font-size: var(--fs-3xl); }

.t-normal   { font-weight: var(--fw-normal); }
.t-medium   { font-weight: var(--fw-medium); }
.t-semibold { font-weight: var(--fw-semibold); }
.t-bold     { font-weight: var(--fw-bold); }

.t-fg       { color: var(--fg); }
.t-strong   { color: var(--fg-strong); }
.t-muted    { color: var(--fg-muted); }
.t-subtle   { color: var(--fg-subtle); }
.t-primary  { color: var(--primary); }
.t-success  { color: var(--success); }
.t-warning  { color: var(--warning); }
.t-danger   { color: var(--danger); }
.t-mono     { font-family: var(--font-mono); }
.t-tabular  { font-variant-numeric: tabular-nums; }

.t-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-clamp-2 {
    display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden;
}

/* Small uppercase label used above grouped content. */
.eyebrow {
    font-size: var(--fs-2xs);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--fg-subtle);
}

/* --------------------------------------------------------------------------
   3. App shell
   -------------------------------------------------------------------------- */
.app {
    min-height: 100vh;
    min-height: 100dvh;
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: var(--sidebar-w);
    z-index: var(--z-sidebar);
    display: flex;
    flex-direction: column;
    background: var(--nav-bg);
    color: var(--nav-fg);
    transition: width var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    height: var(--topbar-h);
    padding-inline: var(--sp-5);
    flex-shrink: 0;
    color: var(--nav-fg-strong);
    border-bottom: 1px solid var(--nav-border);
}
.sidebar__brand:hover { color: var(--nav-fg-strong); text-decoration: none; }

/* Logo art is trimmed to its edges, so height alone sets the size. */
.sidebar__logo   { display: block; height: 40px; width: auto; max-width: 100%; }
.sidebar__emblem { display: none;  height: 36px; width: auto; }

.sidebar__nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--sp-4) var(--sp-3) var(--sp-6);
}

.sidebar__group + .sidebar__group { margin-top: var(--sp-5); }

.sidebar__group-label {
    padding: 0 var(--sp-3) var(--sp-2);
    font-size: var(--fs-2xs);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--nav-fg-muted);
}

.sidebar__list { list-style: none; margin: 0; padding: 0; }

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-3);
    margin-bottom: 2px;
    border-radius: var(--r-md);
    color: var(--nav-fg);
    font-size: var(--fs-base);
    font-weight: var(--fw-medium);
    line-height: 1.4;
    white-space: nowrap;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-item:hover {
    background: var(--nav-bg-hover);
    color: var(--nav-fg-strong);
    text-decoration: none;
}
.nav-item:focus-visible { outline-color: var(--nav-accent); outline-offset: -2px; }

.nav-item.is-active {
    background: var(--nav-bg-active);
    color: var(--nav-fg-strong);
    font-weight: var(--fw-semibold);
}
/* Gold rail marks the current location — the one place accent colour appears
   in the nav, so it can never be confused with anything else. */
.nav-item.is-active::before {
    content: "";
    position: absolute;
    inset-inline-start: calc(var(--sp-3) * -1 + 2px);
    inset-block: 20%;
    width: 3px;
    border-radius: var(--r-full);
    background: var(--nav-accent);
}

.nav-item__icon {
    flex-shrink: 0;
    font-size: 1.125rem;
    line-height: 1;
    width: 20px;
    text-align: center;
}
.nav-item__label { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.nav-item__count {
    flex-shrink: 0;
    min-width: 20px;
    padding: 1px var(--sp-2);
    border-radius: var(--r-full);
    background: var(--danger);
    color: #fff;
    font-size: var(--fs-2xs);
    font-weight: var(--fw-semibold);
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.nav-item__count--muted { background: var(--nav-bg-active); color: var(--nav-fg); }

.sidebar__footer {
    flex-shrink: 0;
    padding: var(--sp-3);
    border-top: 1px solid var(--nav-border);
}

/* ---- Mini (icon-only) sidebar ----
   Labels collapse to tooltips. Crucially the links stay real links — nothing
   here intercepts the click. */
@media (min-width: 992px) {
    body.is-mini .sidebar { width: var(--sidebar-w-mini); }
    body.is-mini .main    { margin-inline-start: var(--sidebar-w-mini); }

    body.is-mini .sidebar__logo { display: none; }
    body.is-mini .sidebar__emblem { display: block; }
    body.is-mini .nav-item__label,
    body.is-mini .sidebar__group-label > span { display: none; }

    body.is-mini .sidebar__brand { justify-content: center; padding-inline: 0; }
    body.is-mini .nav-item { justify-content: center; padding-inline: 0; }
    body.is-mini .nav-item.is-active::before { inset-inline-start: 0; }

    /* Keeps the visual rhythm of groups without the words. */
    body.is-mini .sidebar__group-label {
        padding: 0;
        margin-bottom: var(--sp-2);
        border-top: 1px solid var(--nav-border);
    }
    body.is-mini .sidebar__group:first-child .sidebar__group-label { border-top: 0; }

    body.is-mini .nav-item__count {
        position: absolute;
        top: 2px;
        inset-inline-end: 6px;
        min-width: 16px;
        padding: 0 4px;
        font-size: 9px;
        line-height: 16px;
        pointer-events: none;
    }

    body.is-mini .nav-item::after {
        content: attr(data-tip);
        position: absolute;
        inset-inline-start: calc(100% + var(--sp-3));
        top: 50%;
        transform: translateY(-50%) scale(0.96);
        padding: var(--sp-1) var(--sp-3);
        background: var(--n-900);
        color: #fff;
        font-size: var(--fs-sm);
        font-weight: var(--fw-medium);
        border-radius: var(--r-sm);
        box-shadow: var(--shadow-md);
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
        z-index: var(--z-dropdown);
    }
    body.is-mini .nav-item:hover::after,
    body.is-mini .nav-item:focus-visible::after {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

/* ---- Mobile drawer ---- */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-xl);
    }
    [dir="rtl"] .sidebar { transform: translateX(100%); }
    body.is-drawer-open .sidebar { transform: translateX(0); }
    .main { margin-inline-start: 0 !important; }
}

.scrim {
    position: fixed;
    inset: 0;
    z-index: var(--z-scrim);
    background: var(--scrim);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur) var(--ease), visibility var(--dur);
}
body.is-drawer-open .scrim { opacity: 1; visibility: visible; }
body.is-drawer-open { overflow: hidden; }

/* ---- Main column ---- */
.main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    margin-inline-start: var(--sidebar-w);
    transition: margin var(--dur) var(--ease);
}

/* ---- Topbar ---- */
.topbar {
    position: sticky;
    top: 0;
    z-index: var(--z-topbar);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    height: var(--topbar-h);
    padding-inline: var(--sp-4);
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}
@supports not (backdrop-filter: blur(1px)) {
    .topbar { background: var(--surface); }
}
@media (min-width: 768px) { .topbar { padding-inline: var(--sp-6); } }

.topbar__spacer { flex: 1; }

.content {
    flex: 1;
    width: 100%;
    max-width: var(--content-max);
    margin-inline: auto;
    padding: var(--sp-5) var(--sp-4) var(--sp-9);
}
@media (min-width: 768px) { .content { padding: var(--sp-6) var(--sp-6) var(--sp-10); } }

.app-footer {
    padding: var(--sp-4) var(--sp-6);
    border-top: 1px solid var(--border);
    color: var(--fg-subtle);
    font-size: var(--fs-xs);
}

/* --------------------------------------------------------------------------
   4. Page header — exactly one <h1> per page, and it names the page.
   -------------------------------------------------------------------------- */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
}
.page-head__text { min-width: 0; flex: 1 1 320px; }

.page-head__title {
    font-size: var(--fs-xl);
    font-weight: var(--fw-bold);
    letter-spacing: -0.02em;
    color: var(--fg-strong);
}
.page-head__sub {
    margin-top: var(--sp-1);
    font-size: var(--fs-sm);
    color: var(--fg-muted);
    max-width: 68ch;
}
.page-head__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    margin-inline-start: auto;
}
/* Full-width and thumb-reachable on a phone instead of stranded top-right. */
@media (max-width: 575.98px) {
    .page-head__actions { width: 100%; margin-inline-start: 0; }
    .page-head__actions > .btn { flex: 1; }
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    margin-bottom: var(--sp-2);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--fg-muted);
}
.back-link:hover { color: var(--fg); text-decoration: none; }

/* --------------------------------------------------------------------------
   5. Buttons
   -------------------------------------------------------------------------- */
.btn {
    --btn-bg: transparent;
    --btn-fg: var(--fg);
    --btn-border: transparent;
    --btn-bg-hover: var(--surface-hover);
    --btn-ring: var(--primary-ring);

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: 0 var(--sp-4);
    height: 38px;
    border: 1px solid var(--btn-border);
    border-radius: var(--r-md);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-family: inherit;
    font-size: var(--fs-base);
    font-weight: var(--fw-medium);
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background var(--dur-fast) var(--ease),
                border-color var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease);
}
.btn:hover { background: var(--btn-bg-hover); color: var(--btn-fg); text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--btn-ring); }
.btn:disabled, .btn.is-disabled {
    opacity: 0.5; pointer-events: none; cursor: not-allowed;
}
.btn i { font-size: 1.05em; line-height: 1; }

.btn--primary {
    --btn-bg: var(--primary);
    --btn-fg: var(--primary-fg);
    --btn-bg-hover: var(--primary-hover);
    --btn-border: var(--primary);
    box-shadow: var(--shadow-xs);
}
.btn--primary:hover { border-color: var(--primary-hover); }

.btn--secondary {
    --btn-bg: var(--surface);
    --btn-fg: var(--fg);
    --btn-border: var(--border-strong);
    --btn-bg-hover: var(--surface-hover);
}

.btn--ghost {
    --btn-bg: transparent;
    --btn-fg: var(--fg-muted);
    --btn-bg-hover: var(--surface-hover);
}
.btn--ghost:hover { --btn-fg: var(--fg); }

.btn--danger {
    --btn-bg: var(--danger);
    --btn-fg: #fff;
    --btn-border: var(--danger);
    --btn-bg-hover: var(--danger-hover);
    --btn-ring: var(--danger-ring);
}
.btn--danger:hover { border-color: var(--danger-hover); }

/* Destructive but not the primary path — quiet until you reach for it. */
.btn--danger-ghost {
    --btn-bg: transparent;
    --btn-fg: var(--fg-muted);
    --btn-bg-hover: var(--danger-soft);
    --btn-ring: var(--danger-ring);
}
.btn--danger-ghost:hover { --btn-fg: var(--danger); }

.btn--sm { height: 32px; padding-inline: var(--sp-3); font-size: var(--fs-sm); }
.btn--lg { height: 44px; padding-inline: var(--sp-6); font-size: var(--fs-md); }
.btn--block { width: 100%; }

/* Icon-only. ui.php refuses to render one of these without an accessible
   name, so the "16 unlabelled buttons" problem cannot come back. */
.btn--icon { width: 38px; padding: 0; }
.btn--icon.btn--sm { width: 32px; }
.btn--icon.btn--lg { width: 44px; }

.btn-group {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
}

/* --------------------------------------------------------------------------
   6. Card
   -------------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
}
.card + .card { margin-top: var(--sp-4); }

.card__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--border-subtle);
}
.card__title {
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    color: var(--fg-strong);
}
.card__sub { margin-top: 2px; font-size: var(--fs-xs); color: var(--fg-muted); }
.card__head-actions { margin-inline-start: auto; display: flex; gap: var(--sp-2); align-items: center; }

.card__body { padding: var(--sp-5); }
.card__body--flush { padding: 0; }
.card__body--tight { padding: var(--sp-4); }

.card__foot {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--border-subtle);
    background: var(--surface-sunk);
    border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* --------------------------------------------------------------------------
   7. Toolbar — search + filters + primary action, one pattern for every list
   -------------------------------------------------------------------------- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}
.toolbar__end { margin-inline-start: auto; display: flex; align-items: center; gap: var(--sp-2); }

/* On a phone the filter and the search each get a full row rather than
   squeezing into half-width slivers. */
@media (max-width: 575.98px) {
    .toolbar > *, .toolbar__end { width: 100%; margin-inline-start: 0; }
    .toolbar .seg { display: flex; }
    .search { max-width: none; flex-basis: auto; }
}

.search {
    position: relative;
    flex: 1 1 260px;
    max-width: 380px;
}
.search__icon {
    position: absolute;
    inset-inline-start: var(--sp-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--fg-subtle);
    font-size: 1rem;
    pointer-events: none;
}
/* Two classes deep so it beats .input's shorthand padding regardless of the
   order the two rules appear in. */
.search > .search__input { padding-inline-start: var(--sp-8); }
.search__clear {
    position: absolute;
    inset-inline-end: var(--sp-2);
    top: 50%;
    transform: translateY(-50%);
    display: none;
    place-items: center;
    width: 24px; height: 24px;
    border: 0; border-radius: var(--r-full);
    background: transparent;
    color: var(--fg-subtle);
    cursor: pointer;
}
.search__clear:hover { background: var(--surface-active); color: var(--fg); }
.search.has-value .search__clear { display: grid; }

/* Segmented filter — replaces the old pill nav. */
.seg {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: var(--surface-sunk);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }

.seg__item {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-1) var(--sp-3);
    height: 30px;
    border-radius: var(--r-sm);
    color: var(--fg-muted);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    white-space: nowrap;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.seg__item:hover { background: var(--surface-hover); color: var(--fg); text-decoration: none; }
.seg__item.is-active {
    background: var(--surface);
    color: var(--fg-strong);
    font-weight: var(--fw-semibold);
    box-shadow: var(--shadow-xs);
}
.seg__count {
    min-width: 18px;
    padding: 0 5px;
    border-radius: var(--r-full);
    background: var(--surface-active);
    color: var(--fg-muted);
    font-size: var(--fs-2xs);
    font-weight: var(--fw-semibold);
    line-height: 17px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.seg__item.is-active .seg__count { background: var(--primary-soft); color: var(--primary-soft-fg); }

/* --------------------------------------------------------------------------
   8. Table — one list pattern, collapsing to cards on small screens
   -------------------------------------------------------------------------- */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--fs-base);
}

.table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface-sunk);
    border-bottom: 1px solid var(--border);
    color: var(--fg-muted);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    letter-spacing: 0.03em;
    text-transform: uppercase;
    text-align: start;
    white-space: nowrap;
}

.table tbody td {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }

.table tbody tr { transition: background var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-hover); }

.table .num { text-align: end; font-variant-numeric: tabular-nums; }
.table .center { text-align: center; }
.table .shrink { width: 1%; white-space: nowrap; }
/* Timestamps and short labels should never wrap onto three lines. */
.table .nowrap { white-space: nowrap; }

/* Row actions stay quiet until the row is engaged, so the eye reads content
   first and controls second — but they remain keyboard reachable at all times. */
.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-1);
    opacity: 0;
    transition: opacity var(--dur-fast) var(--ease);
}
tr:hover .row-actions,
tr:focus-within .row-actions { opacity: 1; }
@media (hover: none) { .row-actions { opacity: 1; } }

/* The whole row is a target: a stretched link behind the content. */
.row-link { position: relative; }
.row-link__target::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
}
.row-link > td > *:not(.row-link__target) { position: relative; z-index: 1; }
.row-actions, .row-select { position: relative; z-index: 2; }

/* Primary cell: thumbnail + title + secondary line */
.cell-media {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    min-width: 0;
}
/* The text column must be allowed to shrink, or a long email address holds
   the whole table open and squeezes every other column. Scoped away from the
   avatar/thumb, which are fixed-size siblings. */
.cell-media > span:not(.avatar):not(.thumb) { min-width: 0; flex: 1; }
.cell-media__title {
    font-weight: var(--fw-semibold);
    color: var(--fg-strong);
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}
a.cell-media__title:hover { color: var(--primary); text-decoration: none; }
.cell-media__meta {
    display: block;
    margin-top: 1px;
    font-size: var(--fs-xs);
    color: var(--fg-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.thumb {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    background: var(--surface-active);
    border-radius: var(--r-sm);
    color: var(--fg-subtle);
    overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb--wide { width: 64px; height: 44px; }
.thumb--round { border-radius: var(--r-full); }
.thumb--lg { width: 56px; height: 56px; }

.avatar {
    display: grid;
    place-items: center;
    width: 34px; height: 34px;
    flex-shrink: 0;
    border-radius: var(--r-full);
    background: var(--primary-soft);
    color: var(--primary-soft-fg);
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
}
.avatar--lg { width: 56px; height: 56px; font-size: var(--fs-lg); }

/* ---- Table → cards below 768px ----
   The old panel pushed Edit/Delete off-screen on phones. Here every row
   becomes a self-contained card with its actions in reach. */
@media (max-width: 767.98px) {
    .table--stack thead { display: none; }
    .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }

    .table--stack tbody tr {
        position: relative;
        padding: var(--sp-4);
        border-bottom: 1px solid var(--border);
    }
    .table--stack tbody tr:last-child { border-bottom: 0; }

    .table--stack tbody td {
        padding: 0;
        border: 0;
        display: flex;
        align-items: center;
        gap: var(--sp-3);
        min-height: 28px;
    }
    /* The 1%-wide sizing hint only makes sense in a real table; stacked, it
       would squeeze the actions bar into a sliver. */
    .table--stack tbody td.shrink { width: 100%; }
    .table--stack tbody td .row-select { flex: 0 0 auto; }

    /* Stacked, each row is a block, so the unread rail can sit on the row
       itself and mark the whole card rather than just its first field. */
    .table--stack tbody tr.is-unread > td:first-child::after { display: none; }
    .table--stack tbody tr.is-unread { position: relative; }
    .table--stack tbody tr.is-unread::before {
        content: "";
        position: absolute;
        inset-block: 0;
        inset-inline-start: 0;
        width: 3px;
        background: var(--primary);
    }
    .table--stack tbody td + td { margin-top: var(--sp-2); }

    /* Field label comes from the column header via data-label. */
    .table--stack tbody td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 34%;
        font-size: var(--fs-xs);
        font-weight: var(--fw-semibold);
        letter-spacing: 0.03em;
        text-transform: uppercase;
        color: var(--fg-subtle);
    }
    .table--stack tbody td[data-label] > * { flex: 1; min-width: 0; }

    /* The identity cell spans full width with no label. */
    .table--stack tbody td.cell-primary { margin-bottom: var(--sp-3); }
    .table--stack tbody td.cell-primary::before { display: none; }

    .table--stack .row-actions {
        opacity: 1;
        justify-content: flex-start;
        margin-top: var(--sp-3);
        padding-top: var(--sp-3);
        border-top: 1px solid var(--border-subtle);
        width: 100%;
    }
    .table--stack td.center, .table--stack td.num { text-align: start; }
}

/* --------------------------------------------------------------------------
   9. Status, badges, chips
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 2px var(--sp-2);
    border-radius: var(--r-sm);
    background: var(--surface-active);
    color: var(--fg-muted);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    line-height: 1.5;
    white-space: nowrap;
}
.badge--primary { background: var(--primary-soft); color: var(--primary-soft-fg); }
.badge--success { background: var(--success-soft); color: var(--success-soft-fg); }
.badge--warning { background: var(--warning-soft); color: var(--warning-soft-fg); }
.badge--danger  { background: var(--danger-soft);  color: var(--danger-soft-fg); }
.badge--info    { background: var(--info-soft);    color: var(--info-soft-fg); }
.badge--accent  { background: var(--accent-soft);  color: var(--accent-soft-fg); }
.badge--outline { background: transparent; border: 1px solid var(--border-strong); color: var(--fg-muted); }

/* Status = dot + word. Colour is never the only signal. */
.status {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--fg);
    white-space: nowrap;
}
.status__dot {
    width: 7px; height: 7px;
    flex-shrink: 0;
    border-radius: var(--r-full);
    background: var(--fg-subtle);
}
.status--new     .status__dot { background: var(--primary); }
.status--success .status__dot { background: var(--success); }
.status--warning .status__dot { background: var(--warning); }
.status--danger  .status__dot { background: var(--danger); }
.status--muted   .status__dot { background: var(--fg-subtle); }
.status--muted { color: var(--fg-muted); }

/* Unread emphasis: a left rail, not a whole coloured border.
   The rail hangs off the first cell rather than the row — a ::before on a
   <tr> gets wrapped in an anonymous table cell and shunts every real column
   sideways. */
/* Drawn with ::after, not ::before — stacked rows use ::before to print the
   column name in front of each field, and one element only gets one of each. */
.is-unread > td:first-child { position: relative; }
.is-unread > td:first-child::after {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    inset-block: 0;
    width: 3px;
    background: var(--primary);
}
.feed__item.is-unread { position: relative; }
.feed__item.is-unread::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    inset-block: 0;
    width: 3px;
    background: var(--primary);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: 3px var(--sp-2);
    border: 1px solid var(--border);
    border-radius: var(--r-full);
    background: var(--surface-sunk);
    color: var(--fg-muted);
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
}

/* --------------------------------------------------------------------------
   10. Forms
   -------------------------------------------------------------------------- */
.field { margin-bottom: var(--sp-4); }
.field:last-child { margin-bottom: 0; }

.label {
    display: block;
    margin-bottom: var(--sp-2);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--fg);
}
.label__req { color: var(--danger); margin-inline-start: 2px; }
.label__opt { color: var(--fg-subtle); font-weight: var(--fw-normal); margin-inline-start: var(--sp-1); }

.input, .select, .textarea {
    display: block;
    width: 100%;
    height: 38px;
    padding: 0 var(--sp-3);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    color: var(--fg);
    font-family: inherit;
    font-size: var(--fs-base);
    line-height: 1.5;
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
    -webkit-appearance: none;
    appearance: none;
}
.textarea { height: auto; min-height: 92px; padding: var(--sp-3); resize: vertical; }

.input::placeholder, .textarea::placeholder { color: var(--fg-subtle); }

.input:hover, .select:hover, .textarea:hover { border-color: var(--fg-subtle); }

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

.input:disabled, .select:disabled, .textarea:disabled {
    background: var(--surface-sunk);
    color: var(--fg-subtle);
    cursor: not-allowed;
}

.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select[aria-invalid="true"] {
    border-color: var(--danger);
}
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--danger-ring); }

.select {
    padding-inline-end: var(--sp-8);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%236d7b91' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--sp-3) center;
    background-size: 16px;
}
[dir="rtl"] .select { background-position: left var(--sp-3) center; }
[data-theme="dark"] .select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2393a1b5' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M4 6.5 8 10.5 12 6.5'/%3E%3C/svg%3E");
}

.hint {
    margin-top: var(--sp-2);
    font-size: var(--fs-xs);
    color: var(--fg-muted);
    line-height: var(--lh-snug);
}
.error-text {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    margin-top: var(--sp-2);
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    color: var(--danger);
}

.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-group__addon {
    display: inline-flex;
    align-items: center;
    padding-inline: var(--sp-3);
    border: 1px solid var(--border-strong);
    border-inline-start: 0;
    border-radius: 0 var(--r-md) var(--r-md) 0;
    background: var(--surface-sunk);
    color: var(--fg-muted);
    font-size: var(--fs-sm);
    white-space: nowrap;
}

/* Checkbox & radio */
.check {
    display: inline-flex;
    align-items: flex-start;
    gap: var(--sp-2);
    cursor: pointer;
    font-size: var(--fs-base);
}
.check input[type="checkbox"], .check input[type="radio"] {
    flex-shrink: 0;
    width: 17px; height: 17px;
    margin: 2px 0 0;
    accent-color: var(--primary);
    cursor: pointer;
}
.check__text { color: var(--fg); line-height: 1.45; }
.check__hint { display: block; font-size: var(--fs-xs); color: var(--fg-muted); }

/* Radio cards — for genuine mode choices (e.g. hero image vs video) where the
   selection must visibly govern what appears below it. */
.radio-cards { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.radio-card {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-4);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--surface);
    cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.radio-card:hover { border-color: var(--fg-subtle); }
.radio-card:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 0 0 1px var(--primary);
}
.radio-card:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--primary-ring); }
.radio-card__title { font-weight: var(--fw-semibold); color: var(--fg-strong); font-size: var(--fs-base); }
.radio-card__desc { font-size: var(--fs-xs); color: var(--fg-muted); margin-top: 2px; }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: var(--sp-3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
    position: relative;
    width: 38px; height: 22px;
    flex-shrink: 0;
    background: var(--border-strong);
    border-radius: var(--r-full);
    transition: background var(--dur) var(--ease);
}
.switch__track::after {
    content: "";
    position: absolute;
    top: 3px; inset-inline-start: 3px;
    width: 16px; height: 16px;
    background: #fff;
    border-radius: var(--r-full);
    box-shadow: var(--shadow-sm);
    transition: transform var(--dur) var(--ease);
}
.switch input:checked + .switch__track { background: var(--primary); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 3px var(--primary-ring); }

/* Form section: a titled block inside a card, replacing the old prose columns */
.form-section + .form-section {
    margin-top: var(--sp-6);
    padding-top: var(--sp-6);
    border-top: 1px solid var(--border-subtle);
}
.form-section__title {
    font-size: var(--fs-base);
    font-weight: var(--fw-semibold);
    color: var(--fg-strong);
    margin-bottom: var(--sp-1);
}
.form-section__desc {
    font-size: var(--fs-xs);
    color: var(--fg-muted);
    margin-bottom: var(--sp-4);
    max-width: 72ch;
}

.form-grid { display: grid; gap: var(--sp-4); }
@media (min-width: 640px) {
    .form-grid--2 { grid-template-columns: 1fr 1fr; }
    .form-grid--3 { grid-template-columns: repeat(3, 1fr); }
}
.form-grid .field { margin-bottom: 0; }
.col-span-full { grid-column: 1 / -1; }

/* --------------------------------------------------------------------------
   11. Sticky save bar — the save button never wanders off down the page
   -------------------------------------------------------------------------- */
.sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: var(--z-sticky);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-3);
    margin-top: var(--sp-6);
    padding: var(--sp-3) var(--sp-4);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
}
@supports not (backdrop-filter: blur(1px)) { .sticky-actions { background: var(--surface); } }
.sticky-actions__note { font-size: var(--fs-xs); color: var(--fg-muted); }
.sticky-actions__end { margin-inline-start: auto; display: flex; gap: var(--sp-2); align-items: center; }
@media (max-width: 575.98px) {
    .sticky-actions__end { width: 100%; }
    .sticky-actions__end .btn { flex: 1; }
}

/* Unsaved-changes indicator */
.dirty-dot {
    display: none;
    width: 7px; height: 7px;
    border-radius: var(--r-full);
    background: var(--warning);
}
form.is-dirty .dirty-dot { display: inline-block; }

/* --------------------------------------------------------------------------
   12. Empty & loading states
   -------------------------------------------------------------------------- */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--sp-9) var(--sp-5);
}
.empty__icon {
    display: grid;
    place-items: center;
    width: 52px; height: 52px;
    margin-bottom: var(--sp-4);
    border-radius: var(--r-lg);
    background: var(--surface-active);
    color: var(--fg-subtle);
    font-size: 1.5rem;
}
.empty__title { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--fg-strong); }
.empty__body { margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--fg-muted); max-width: 44ch; }
.empty__actions { margin-top: var(--sp-5); display: flex; gap: var(--sp-2); flex-wrap: wrap; justify-content: center; }

.spinner {
    width: 18px; height: 18px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--primary);
    border-radius: var(--r-full);
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   13. Alerts & toasts
   -------------------------------------------------------------------------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    margin-bottom: var(--sp-4);
    border: 1px solid transparent;
    border-radius: var(--r-md);
    font-size: var(--fs-sm);
}
.alert__icon { flex-shrink: 0; font-size: 1.1rem; line-height: 1.3; }
.alert__body { flex: 1; min-width: 0; }
.alert__title { font-weight: var(--fw-semibold); }
.alert__close {
    flex-shrink: 0;
    border: 0; background: transparent;
    color: inherit; opacity: 0.6;
    cursor: pointer; padding: 0; font-size: 1.1rem; line-height: 1;
}
.alert__close:hover { opacity: 1; }

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

.toast-region {
    position: fixed;
    inset-block-end: var(--sp-5);
    inset-inline-end: var(--sp-5);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    max-width: min(400px, calc(100vw - var(--sp-8)));
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    font-size: var(--fs-sm);
    color: var(--fg);
    pointer-events: auto;
    animation: toast-in var(--dur-slow) var(--ease);
}
.toast.is-leaving { animation: toast-out var(--dur) var(--ease) forwards; }
.toast__icon { flex-shrink: 0; font-size: 1.1rem; line-height: 1.3; }
.toast--success .toast__icon { color: var(--success); }
.toast--danger  .toast__icon { color: var(--danger); }
.toast--info    .toast__icon { color: var(--info); }
@keyframes toast-in  { from { opacity: 0; transform: translateY(10px) scale(0.97); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(6px) scale(0.98); } }

@media (max-width: 575.98px) {
    .toast-region { inset-inline: var(--sp-4); max-width: none; inset-block-end: var(--sp-4); }
}

/* --------------------------------------------------------------------------
   14. Tabs
   -------------------------------------------------------------------------- */
.tabs {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    margin-bottom: var(--sp-5);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    border: 0;
    background: transparent;
    color: var(--fg-muted);
    font-family: inherit;
    font-size: var(--fs-base);
    font-weight: var(--fw-medium);
    white-space: nowrap;
    cursor: pointer;
    transition: color var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--fg); text-decoration: none; }
.tab.is-active { color: var(--primary); font-weight: var(--fw-semibold); }
.tab.is-active::after {
    content: "";
    position: absolute;
    inset-inline: var(--sp-2);
    bottom: -1px;
    height: 2px;
    border-radius: var(--r-full) var(--r-full) 0 0;
    background: var(--primary);
}
/* Sub-tabs inside a card (e.g. EN / RU language panes) */
.tabs--inline { border-bottom: 0; gap: 2px; margin-bottom: var(--sp-4); padding: 3px; background: var(--surface-sunk); border-radius: var(--r-md); display: inline-flex; }
.tabs--inline .tab { padding: var(--sp-1) var(--sp-4); height: 30px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.tabs--inline .tab.is-active { background: var(--surface); color: var(--fg-strong); box-shadow: var(--shadow-xs); }
.tabs--inline .tab.is-active::after { display: none; }

.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: fade-in var(--dur) var(--ease); }
@keyframes fade-in { from { opacity: 0; } }

/* --------------------------------------------------------------------------
   15. Dropdown menu
   -------------------------------------------------------------------------- */
.menu {
    position: absolute;
    z-index: var(--z-dropdown);
    min-width: 200px;
    padding: var(--sp-2);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px) scale(0.98);
    transform-origin: top right;
    transition: opacity var(--dur-fast) var(--ease),
                transform var(--dur-fast) var(--ease),
                visibility var(--dur-fast);
}
.menu.is-open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.menu--end { inset-inline-end: 0; }
.dropdown { position: relative; }

.menu__item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--fg);
    font-family: inherit;
    font-size: var(--fs-base);
    text-align: start;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease);
}
.menu__item:hover { background: var(--surface-hover); color: var(--fg); text-decoration: none; }
.menu__item i { font-size: 1.05rem; color: var(--fg-muted); flex-shrink: 0; }
.menu__item--danger { color: var(--danger); }
.menu__item--danger:hover { background: var(--danger-soft); color: var(--danger); }
.menu__item--danger i { color: currentColor; }
.menu__sep { height: 1px; margin: var(--sp-2) calc(var(--sp-1) * -1); background: var(--border-subtle); }
.menu__head { padding: var(--sp-2) var(--sp-3); }

.menu__count {
    margin-inline-start: auto;
    padding: 0 var(--sp-2);
    border-radius: var(--r-full);
    background: var(--surface-active);
    color: var(--fg-muted);
    font-size: var(--fs-2xs);
    font-weight: var(--fw-semibold);
    font-variant-numeric: tabular-nums;
}
.menu__count--alert { background: var(--danger); color: #fff; }

/* --------------------------------------------------------------------------
   16. Topbar controls
   -------------------------------------------------------------------------- */
.icon-btn {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 36px; height: 36px;
    flex-shrink: 0;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--fg-muted);
    font-size: 1.15rem;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--fg); }
.icon-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }

.icon-btn__dot {
    position: absolute;
    top: 6px; inset-inline-end: 6px;
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    border-radius: var(--r-full);
    background: var(--danger);
    color: #fff;
    font-size: 9px;
    font-weight: var(--fw-bold);
    line-height: 15px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Theme control: three explicit states, so clicking "Light" always means
   light. No blind toggling. */
.theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: var(--surface-sunk);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}
.theme-switch__btn {
    display: grid;
    place-items: center;
    width: 28px; height: 26px;
    border: 0;
    border-radius: var(--r-xs);
    background: transparent;
    color: var(--fg-subtle);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.theme-switch__btn:hover { color: var(--fg); }
.theme-switch__btn[aria-pressed="true"] {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-xs);
}
.theme-switch__btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--primary-ring); }

.user-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-1) var(--sp-2) var(--sp-1) var(--sp-1);
    border: 1px solid transparent;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--fg);
    font-family: inherit;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease);
}
.user-btn:hover { background: var(--surface-hover); }
.user-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }
.user-btn__name { font-size: var(--fs-sm); font-weight: var(--fw-semibold); line-height: 1.2; }
.user-btn__role { font-size: var(--fs-2xs); color: var(--fg-muted); line-height: 1.2; }

/* --------------------------------------------------------------------------
   17. Stat / metric cards
   -------------------------------------------------------------------------- */
.stat-grid {
    display: grid;
    gap: var(--sp-4);
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    margin-bottom: var(--sp-5);
}

.stat {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-4) var(--sp-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
    color: var(--fg);
    transition: border-color var(--dur-fast) var(--ease),
                box-shadow var(--dur-fast) var(--ease),
                transform var(--dur-fast) var(--ease);
}
a.stat:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    text-decoration: none;
    color: var(--fg);
}
.stat__icon {
    display: grid;
    place-items: center;
    width: 42px; height: 42px;
    flex-shrink: 0;
    border-radius: var(--r-md);
    background: var(--surface-active);
    color: var(--fg-muted);
    font-size: 1.25rem;
}
.stat--primary .stat__icon { background: var(--primary-soft); color: var(--primary-soft-fg); }
.stat--warning .stat__icon { background: var(--warning-soft); color: var(--warning-soft-fg); }
.stat--danger  .stat__icon { background: var(--danger-soft);  color: var(--danger-soft-fg); }
.stat--success .stat__icon { background: var(--success-soft); color: var(--success-soft-fg); }
.stat--info    .stat__icon { background: var(--info-soft);    color: var(--info-soft-fg); }

.stat__value {
    display: block;
    font-size: var(--fs-2xl);
    font-weight: var(--fw-bold);
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--fg-strong);
    font-variant-numeric: tabular-nums;
}
.stat__label { display: block; font-size: var(--fs-sm); color: var(--fg-muted); margin-top: 2px; }
.stat__cta {
    margin-inline-start: auto;
    color: var(--fg-subtle);
    font-size: 1.1rem;
    flex-shrink: 0;
    transition: transform var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
a.stat:hover .stat__cta { color: var(--primary); transform: translateX(2px); }
/* Zero is calm; a real number earns emphasis. */
.stat.is-zero .stat__value { color: var(--fg-subtle); font-weight: var(--fw-semibold); }

/* --------------------------------------------------------------------------
   18. Feed list (dashboard activity, inbox previews)
   -------------------------------------------------------------------------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed__item {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-5);
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--dur-fast) var(--ease);
}
.feed__item:last-child { border-bottom: 0; }
.feed__item:hover { background: var(--surface-hover); }
.feed__body { flex: 1; min-width: 0; }
.feed__title { font-weight: var(--fw-medium); color: var(--fg-strong); }
.feed__meta { font-size: var(--fs-xs); color: var(--fg-muted); margin-top: 1px; }
.feed__end { flex-shrink: 0; text-align: end; display: flex; flex-direction: column; align-items: flex-end; gap: var(--sp-1); }
.feed__time { font-size: var(--fs-xs); color: var(--fg-subtle); white-space: nowrap; }

/* --------------------------------------------------------------------------
   19. Bulk selection bar
   -------------------------------------------------------------------------- */
.bulk-bar {
    display: none;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-4);
    margin-bottom: var(--sp-3);
    background: var(--primary-soft);
    border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
    border-radius: var(--r-md);
    font-size: var(--fs-sm);
    animation: fade-in var(--dur) var(--ease);
}
.bulk-bar.is-visible { display: flex; flex-wrap: wrap; }
.bulk-bar__count { font-weight: var(--fw-semibold); color: var(--primary-soft-fg); }
.bulk-bar__actions { margin-inline-start: auto; display: flex; gap: var(--sp-2); }

.row-select { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }
tr.is-selected { background: var(--primary-soft) !important; }

/* --------------------------------------------------------------------------
   20. Uploader
   -------------------------------------------------------------------------- */
.upload {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 168px;
    padding: var(--sp-6) var(--sp-4);
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--r-lg);
    background: var(--surface-sunk);
    color: var(--fg-muted);
    text-align: center;
    cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease),
                background var(--dur-fast) var(--ease),
                color var(--dur-fast) var(--ease);
}
.upload:hover, .upload.is-dragover {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-soft-fg);
}
.upload input[type="file"] {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    opacity: 0; cursor: pointer; z-index: 2;
}
.upload:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }

.upload__icon { font-size: 1.75rem; margin-bottom: var(--sp-2); line-height: 1; }
.upload__text { font-size: var(--fs-base); font-weight: var(--fw-medium); color: inherit; }
.upload__hint { font-size: var(--fs-xs); opacity: 0.8; margin-top: 2px; }

.upload__preview {
    position: absolute;
    inset: var(--sp-2);
    z-index: 3;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--sp-3);
    background: var(--surface);
    border-radius: var(--r-md);
}
.upload.has-file .upload__preview { display: flex; }
.upload.has-file .upload__icon,
.upload.has-file .upload__text,
.upload.has-file .upload__hint { visibility: hidden; }
.upload__preview img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--r-sm); }
.upload__preview video { max-width: 100%; max-height: 100%; border-radius: var(--r-sm); }
.upload__preview--dark { background: var(--navy-800); }

.upload__file {
    display: flex; flex-direction: column; align-items: center; gap: var(--sp-1);
    color: var(--fg); font-size: var(--fs-sm);
}
.upload__file i { font-size: 1.75rem; color: var(--primary); }

.upload__remove {
    position: absolute;
    top: calc(var(--sp-2) * -1);
    inset-inline-end: calc(var(--sp-2) * -1);
    z-index: 4;
    display: grid; place-items: center;
    width: 26px; height: 26px;
    border: 2px solid var(--surface);
    border-radius: var(--r-full);
    background: var(--danger);
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform var(--dur-fast) var(--ease);
}
.upload__remove:hover { transform: scale(1.08); }

.upload__progress {
    position: absolute; inset: 0; z-index: 5;
    display: none;
    flex-direction: column; align-items: center; justify-content: center;
    gap: var(--sp-2);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    border-radius: var(--r-lg);
}
.upload.is-uploading .upload__progress { display: flex; }
.upload__bar { width: min(70%, 220px); height: 6px; background: var(--surface-active); border-radius: var(--r-full); overflow: hidden; }
.upload__bar span { display: block; height: 100%; width: 0; background: var(--primary); transition: width 100ms linear; }
.upload__pct { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--fg); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   21. Repeatable rows (route points, social links)
   -------------------------------------------------------------------------- */
.repeat-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3);
    background: var(--surface-sunk);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}
.repeat-row + .repeat-row { margin-top: var(--sp-2); }
.repeat-row__index {
    display: grid; place-items: center;
    width: 24px; height: 24px;
    flex-shrink: 0;
    border-radius: var(--r-full);
    background: var(--primary-soft);
    color: var(--primary-soft-fg);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    font-variant-numeric: tabular-nums;
}
.repeat-row .input, .repeat-row .select { height: 34px; font-size: var(--fs-sm); }

/* --------------------------------------------------------------------------
   22. Map
   -------------------------------------------------------------------------- */
.map-canvas {
    width: 100%;
    height: 320px;
    border-radius: var(--r-md);
    background: var(--surface-active);
    border: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   23. Rich text (Quill) — themed to match the form controls
   -------------------------------------------------------------------------- */
.editor-wrap { border: 1px solid var(--border-strong); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.editor-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }

.ql-toolbar.ql-snow {
    border: 0 !important;
    border-bottom: 1px solid var(--border) !important;
    background: var(--surface-sunk);
    padding: var(--sp-2) var(--sp-3);
}
.ql-container.ql-snow { border: 0 !important; font-family: var(--font-sans); font-size: var(--fs-base); }
.ql-editor { min-height: 200px; color: var(--fg); line-height: var(--lh-base); }
.ql-editor.ql-blank::before { color: var(--fg-subtle); font-style: normal; }
.ql-editor img { max-width: 100%; height: auto; border-radius: var(--r-sm); }

.ql-snow .ql-stroke { stroke: var(--fg-muted); }
.ql-snow .ql-fill, .ql-snow .ql-stroke.ql-fill { fill: var(--fg-muted); }
.ql-snow .ql-picker { color: var(--fg-muted); }
.ql-snow .ql-picker-options { background: var(--surface-raised); border-color: var(--border) !important; box-shadow: var(--shadow-md); border-radius: var(--r-sm); }
.ql-snow.ql-toolbar button:hover .ql-stroke,
.ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--primary); }
.ql-snow.ql-toolbar button:hover .ql-fill,
.ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--primary); }
.ql-snow.ql-toolbar button:hover, .ql-snow.ql-toolbar button.ql-active { background: var(--surface-hover); border-radius: var(--r-xs); }

.spoiler {
    background: var(--surface-active);
    color: transparent;
    border-radius: var(--r-xs);
    padding: 0 0.15em;
    cursor: help;
    transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.spoiler:hover { color: inherit; background: transparent; }

.quill-img-tools {
    position: absolute;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: var(--n-900);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-lg);
}
.quill-img-tools button {
    border: 0; background: transparent; color: #fff;
    font-size: var(--fs-2xs); line-height: 1;
    padding: 4px 6px; border-radius: var(--r-xs); cursor: pointer;
}
.quill-img-tools button:hover { background: rgba(255, 255, 255, 0.18); }
.quill-img-tools .sep { width: 1px; height: 16px; background: rgba(255, 255, 255, 0.25); margin: 0 3px; }

/* Choices.js multi-select — matched to .input */
.choices { margin-bottom: 0; }
.choices__inner {
    min-height: 38px;
    padding: 4px 4px 0;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md) !important;
    font-size: var(--fs-base);
}
.choices.is-focused .choices__inner { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.choices__list--multiple .choices__item {
    background: var(--primary-soft);
    border: 0;
    color: var(--primary-soft-fg);
    border-radius: var(--r-sm);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    padding: 3px var(--sp-2);
    margin: 0 4px 4px 0;
}
.choices__list--multiple .choices__item .choices__button {
    border-inline-start-color: color-mix(in srgb, var(--primary) 35%, transparent);
    opacity: 0.7;
}
.choices__list--dropdown, .choices__list[aria-expanded] {
    background: var(--surface-raised);
    border-color: var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
}
.choices__list--dropdown .choices__item--selectable.is-highlighted { background: var(--surface-hover); }
.choices__input { background: transparent !important; color: var(--fg); }
.choices[data-type*="select-multiple"] .choices__button { filter: none; }

/* --------------------------------------------------------------------------
   24. Confirm dialog
   -------------------------------------------------------------------------- */
.dialog {
    padding: 0;
    max-width: min(420px, calc(100vw - var(--sp-8)));
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface-raised);
    color: var(--fg);
    box-shadow: var(--shadow-xl);
}
.dialog::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
.dialog__body { padding: var(--sp-6) var(--sp-6) var(--sp-5); }
.dialog__icon {
    display: grid; place-items: center;
    width: 42px; height: 42px;
    margin-bottom: var(--sp-4);
    border-radius: var(--r-md);
    background: var(--danger-soft); color: var(--danger);
    font-size: 1.3rem;
}
.dialog__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.dialog__text { margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--fg-muted); }
.dialog__foot {
    display: flex; justify-content: flex-end; gap: var(--sp-2);
    padding: var(--sp-4) var(--sp-6);
    background: var(--surface-sunk);
    border-top: 1px solid var(--border-subtle);
    border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* --------------------------------------------------------------------------
   25. Login
   -------------------------------------------------------------------------- */
.login {
    display: grid;
    place-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: var(--sp-5);
    background:
        radial-gradient(1100px 520px at 50% -12%, color-mix(in srgb, var(--primary) 12%, transparent), transparent 65%),
        var(--canvas);
}
.login__inner { width: 100%; max-width: 380px; }
.login__brand { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-6); }
.login__logo { display: block; height: 72px; width: auto; }
.login__logo--on-dark { display: none; }
:root[data-theme="dark"] .login__logo--on-light { display: none; }
:root[data-theme="dark"] .login__logo--on-dark  { display: block; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .login__logo--on-light { display: none; }
    :root:not([data-theme]) .login__logo--on-dark  { display: block; }
}
.login__title { font-size: var(--fs-xl); font-weight: var(--fw-bold); letter-spacing: -0.02em; }
.login__foot { margin-top: var(--sp-5); text-align: center; font-size: var(--fs-xs); color: var(--fg-subtle); }

.pw-field { position: relative; }
.pw-toggle {
    position: absolute;
    inset-inline-end: var(--sp-1);
    top: 50%;
    transform: translateY(-50%);
    display: grid; place-items: center;
    width: 32px; height: 32px;
    border: 0; border-radius: var(--r-sm);
    background: transparent;
    color: var(--fg-subtle);
    cursor: pointer;
}
.pw-toggle:hover { color: var(--fg); background: var(--surface-hover); }

/* --------------------------------------------------------------------------
   26. Utilities used often enough to earn a name
   -------------------------------------------------------------------------- */
.stack       { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack--sm   { gap: var(--sp-2); }
.stack--lg   { gap: var(--sp-6); }
.row-flex    { display: flex; align-items: center; gap: var(--sp-3); }
.row-flex--wrap { flex-wrap: wrap; }
.push-end    { margin-inline-start: auto; }
.divider     { height: 1px; background: var(--border-subtle); margin: var(--sp-4) 0; }
.v-divider   { width: 1px; align-self: stretch; background: var(--border); margin-inline: var(--sp-1); }

.split {
    display: grid;
    gap: var(--sp-4);
    grid-template-columns: 1fr;
}
@media (min-width: 992px) {
    .split--main-aside { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
    .split--half { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.split > * { min-width: 0; }

/* A right-hand rail that stays put while the main column scrolls. */
@media (min-width: 992px) {
    .aside-sticky { position: sticky; top: calc(var(--topbar-h) + var(--sp-5)); }
}

.hide { display: none !important; }
@media (max-width: 767.98px)  { .hide-sm-down { display: none !important; } }
@media (max-width: 991.98px)  { .hide-md-down { display: none !important; } }
@media (min-width: 992px)     { .hide-lg-up   { display: none !important; } }

/* ==========================================================================
   27. Bootstrap bridge
   --------------------------------------------------------------------------
   We load Bootstrap's reboot/grid/utilities for layout primitives, but not its
   component or theme CSS. Those utilities reference --bs-* variables that
   normally come from the theme layer we dropped, so we map them onto our own
   tokens here. Two benefits: utilities keep working, and they become
   theme-aware — which is what silently fixes the old bg-white / text-dark
   blocks that used to glare white in dark mode.
   ========================================================================== */
:root,
[data-theme="light"],
[data-theme="dark"] {
    --bs-body-color: var(--fg);
    --bs-body-bg: var(--canvas);
    --bs-emphasis-color: var(--fg-strong);
    --bs-secondary-color: var(--fg-muted);
    --bs-tertiary-color: var(--fg-subtle);
    --bs-secondary-bg: var(--surface-sunk);
    --bs-tertiary-bg: var(--surface-sunk);
    --bs-border-color: var(--border);
    --bs-border-radius: var(--r-md);
    --bs-link-color: var(--primary);
    --bs-link-hover-color: var(--primary-hover);

    --bs-primary: var(--primary);
    --bs-secondary: var(--fg-muted);
    --bs-success: var(--success);
    --bs-danger: var(--danger);
    --bs-warning: var(--warning);
    --bs-info: var(--info);
    --bs-light: var(--surface-sunk);
    --bs-dark: var(--fg-strong);
    --bs-white: var(--surface);
    --bs-black: var(--fg-strong);

    --bs-primary-bg-subtle: var(--primary-soft);
    --bs-secondary-bg-subtle: var(--surface-active);
    --bs-success-bg-subtle: var(--success-soft);
    --bs-danger-bg-subtle: var(--danger-soft);
    --bs-warning-bg-subtle: var(--warning-soft);
    --bs-info-bg-subtle: var(--info-soft);

    --bs-primary-text-emphasis: var(--primary-soft-fg);
    --bs-success-text-emphasis: var(--success-soft-fg);
    --bs-danger-text-emphasis: var(--danger-soft-fg);
    --bs-warning-text-emphasis: var(--warning-soft-fg);
    --bs-info-text-emphasis: var(--info-soft-fg);
}

/* These four utilities are absolute in Bootstrap (literally white / literally
   black), which is exactly why the old panel had glaring white panels in dark
   mode. Redefine them as surface-relative. */
.bg-white       { background-color: var(--surface) !important; }
.bg-light       { background-color: var(--surface-sunk) !important; }
.bg-light-subtle{ background-color: var(--surface-sunk) !important; }
.text-dark      { color: var(--fg-strong) !important; }
.text-muted     { color: var(--fg-muted) !important; }
.text-body-secondary { color: var(--fg-muted) !important; }

/* ==========================================================================
   28. Legacy components used by the webmail
   --------------------------------------------------------------------------
   email.php drives its mailbox switcher and composer with Bootstrap's JS,
   which needs these class names. Rather than reintroduce Bootstrap's stylesheet
   we give the same hooks our own appearance, so the Mail screen matches the
   rest of the product.
   ========================================================================== */

/* Buttons */
.btn:not([class*="btn--"]) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: 0 var(--sp-4);
    height: 38px;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    background: transparent;
    color: var(--fg);
    font-family: inherit;
    font-size: var(--fs-base);
    font-weight: var(--fw-medium);
    line-height: 1;
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.btn:not([class*="btn--"]):hover { background: var(--surface-hover); text-decoration: none; }
.btn-primary {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: var(--primary-fg) !important;
}
.btn-primary:hover { background: var(--primary-hover) !important; border-color: var(--primary-hover) !important; }
.btn-outline-secondary {
    border-color: var(--border-strong) !important;
    color: var(--fg) !important;
    background: var(--surface) !important;
}
.btn-outline-secondary:hover { background: var(--surface-hover) !important; }
.btn-sm { height: 32px; padding-inline: var(--sp-3); font-size: var(--fs-sm); }

.btn-close {
    width: 30px; height: 30px;
    padding: 0;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--fg-muted);
    font-size: 0;
    cursor: pointer;
    position: relative;
    opacity: 1;
}
.btn-close::before {
    content: "\ea76"; /* remixicon close */
    font-family: "remixicon";
    font-size: 20px;
    line-height: 30px;
}
.btn-close:hover { background: var(--surface-hover); color: var(--fg); }
.btn-close-white { color: var(--fg-on-solid); }

/* Form controls */
.form-control, .form-select {
    display: block;
    width: 100%;
    min-height: 38px;
    padding: var(--sp-2) var(--sp-3);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    color: var(--fg);
    font-family: inherit;
    font-size: var(--fs-base);
    line-height: 1.5;
}
.form-control::placeholder { color: var(--fg-subtle); }
.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}
.form-label {
    display: block;
    margin-bottom: var(--sp-2);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--fg);
}

/* Badges (Bootstrap-shaped) */
.badge:not([class*="badge--"]) {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--sp-2);
    border-radius: var(--r-sm);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    line-height: 1.5;
}
.rounded-pill { border-radius: var(--r-full) !important; }

/* Alerts (Bootstrap-shaped) */
.alert:not([class*="alert--"]) {
    display: block;
    padding: var(--sp-3) var(--sp-4);
    margin-bottom: var(--sp-4);
    border: 1px solid transparent;
    border-radius: var(--r-md);
    font-size: var(--fs-sm);
}
.alert-danger {
    background: var(--danger-soft);
    color: var(--danger-soft-fg);
    border-color: color-mix(in srgb, var(--danger) 28%, transparent);
}

/* Dropdown (Bootstrap JS toggles .show) */
.dropdown-menu {
    position: absolute;
    z-index: var(--z-dropdown);
    display: none;
    min-width: 200px;
    margin-top: var(--sp-1);
    padding: var(--sp-2);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    list-style: none;
}
.dropdown-menu.show { display: block; }
.dropdown-menu-end { inset-inline-end: 0; }
.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--fg);
    font-size: var(--fs-base);
    text-align: start;
    cursor: pointer;
}
.dropdown-item:hover { background: var(--surface-hover); color: var(--fg); text-decoration: none; }
.dropdown-header {
    padding: var(--sp-2) var(--sp-3);
    color: var(--fg-subtle);
    font-size: var(--fs-2xs);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
}
.dropdown-divider { height: 1px; margin: var(--sp-2) 0; background: var(--border-subtle); border: 0; }

/* Modal (Bootstrap JS toggles .show and sets display) */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1055;
    display: none;
    overflow-x: hidden;
    overflow-y: auto;
    outline: 0;
}
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1050;
    background: var(--scrim);
}
.modal-backdrop.show { opacity: 1; }
.modal-dialog {
    position: relative;
    width: auto;
    margin: var(--sp-6) auto;
    max-width: 560px;
    pointer-events: none;
}
.modal-lg { max-width: 820px; }
.modal.show .modal-dialog { pointer-events: auto; }
.modal-content {
    display: flex;
    flex-direction: column;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xl);
    pointer-events: auto;
}
.modal-header {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--border-subtle);
}
.modal-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); margin: 0; }
.modal-body { padding: var(--sp-5); }
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-2);
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--border-subtle);
    background: var(--surface-sunk);
    border-radius: 0 0 var(--r-lg) var(--r-lg);
}
@media (max-width: 575.98px) {
    .modal-dialog { margin: var(--sp-3); }
}

/* Spinner */
.spinner-border {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: var(--r-full);
    animation: spin 0.75s linear infinite;
    vertical-align: -0.125em;
}
.spinner-border-sm { width: 14px; height: 14px; border-width: 2px; }

/* ---- Settings: brand preview ---- */
.brand-preview { display: grid; grid-template-columns: 2fr 2fr 1fr; gap: var(--sp-4); }
.brand-preview__item { margin: 0; min-width: 0; }
.brand-preview__item figcaption { margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--fg-muted); }
.brand-preview__tile {
    display: grid; place-items: center;
    height: 112px;
    background: var(--surface-sunk);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
}
.brand-preview__tile img { display: block; height: 56px; width: auto; max-width: 80%; }
.brand-preview__tile--navy  { background: var(--navy-700); border-color: transparent; }
.brand-preview__tile--white { background: #fff; }
.brand-preview__item:last-child .brand-preview__tile img { height: 72px; border-radius: var(--r-md); }
@media (max-width: 575px) {
    .brand-preview { grid-template-columns: 1fr 1fr; }
    .brand-preview__item--wide { grid-column: 1 / -1; }
}
