/* ──────────────────────────────────────────────────────────────────────────
   MerlinXSL admin look — the "MerlinXSL Admin" design applied to every page
   on layout/base.html: warm paper palette, Newsreader headings, Instrument
   Sans text, JetBrains Mono code, 1 px hairlines instead of shadows.

   Layered on top of Tabler: the design tokens below feed Tabler's own
   variables, and the component rules restyle the Tabler classes our
   templates use (card, table, btn, badge, form, nav-tabs, modal, alert…).
   Light and dark follow `data-theme` on <html> (js/shared/theme-init.js).
   All fonts are self-hosted (SIL OFL), nothing is loaded from a CDN.
   ────────────────────────────────────────────────────────────────────────── */

/* ── Fonts ─────────────────────────────────────────────────────────────── */
@font-face {
    font-family: 'Instrument Sans';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/InstrumentSans-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Instrument Sans';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/InstrumentSans-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Newsreader';
    font-style: normal;
    font-weight: 400 500;
    font-display: swap;
    src: url('../fonts/newsreader-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Newsreader';
    font-style: normal;
    font-weight: 400 500;
    font-display: swap;
    src: url('../fonts/newsreader-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400 500;
    font-display: swap;
    src: url('../fonts/jetbrains-mono-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 400 500;
    font-display: swap;
    src: url('../fonts/jetbrains-mono-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ── Design tokens ─────────────────────────────────────────────────────── */
:root,
[data-theme=light] {
    --sans: 'Instrument Sans', system-ui, sans-serif;
    --serif: 'Newsreader', Georgia, serif;
    --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
    --bg: #f8f4ed;
    --surface: #fffdf9;
    --surface2: #efe9df;
    --border: #e4dccf;
    --text: #221c15;
    --muted: #7b6f61;
    --accent: #ea580c;
    --accent-soft: #ea580c1c;
    --accent-ink: #ffffff;
    --ok: #2f7d4f;
    --ok-soft: rgba(47, 125, 79, .12);
    --warn: #b4690e;
    --warn-soft: rgba(180, 105, 14, .14);
    --danger: #c0392b;
    --danger-soft: rgba(192, 57, 43, .12);
    --info: #1d4ed8;
    --info-soft: rgba(29, 78, 216, .1);
    /* Chart series (categorical, fixed order; validated against --surface for CVD separation). */
    --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
    --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
    --series-other: #a8a39a; --series-rest: #d8d1c5;
    --pad: 18px;
    --r: 8px;
    --overlay: rgba(10, 12, 16, .45);
    --pop-shadow: 0 20px 60px rgba(0, 0, 0, .35);
    --sidebar-w: 269px;
    --subnav-w: 220px;
    --topbar-h: 55px;
    color-scheme: light;
}

[data-theme=dark] {
    --bg: #17130f;
    --surface: #1e1914;
    --surface2: #2a231c;
    --border: #352c23;
    --text: #f2ebe1;
    --muted: #a3927f;
    --accent: #f97316;
    --accent-soft: rgba(249, 115, 22, .16);
    --accent-ink: #17130f;
    --ok: #5cb57f;
    --ok-soft: rgba(92, 181, 127, .14);
    --warn: #e3a04a;
    --warn-soft: rgba(227, 160, 74, .14);
    --danger: #ef6b5b;
    --danger-soft: rgba(239, 107, 91, .14);
    --info: #7aa2f7;
    --info-soft: rgba(122, 162, 247, .14);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --series-other: #7d7468; --series-rest: #4a4036;
    color-scheme: dark;
}

/* Tokens → Tabler. Repeated for dark because Tabler redefines these on [data-theme=dark]. */
:root,
[data-theme=light],
[data-theme=dark] {
    --tblr-font-sans-serif: var(--sans);
    --tblr-font-monospace: var(--mono);
    --tblr-body-font-family: var(--sans);
    --tblr-body-font-size: 14px;
    --tblr-body-line-height: 1.5;
    --tblr-body-bg: var(--bg);
    --tblr-body-color: var(--text);
    --tblr-emphasis-color: var(--text);
    --tblr-heading-color: var(--text);
    --tblr-bg-surface: var(--surface);
    --tblr-bg-surface-primary: var(--surface);
    --tblr-bg-surface-secondary: var(--surface2);
    --tblr-bg-surface-tertiary: var(--surface2);
    --tblr-bg-forms: var(--bg);
    --tblr-tertiary-bg: var(--surface2);
    --tblr-secondary-bg: var(--surface2);
    --tblr-border-color: var(--border);
    --tblr-border-color-translucent: var(--border);
    --tblr-border-radius: var(--r);
    --tblr-border-radius-sm: 4px;
    --tblr-border-radius-lg: var(--r);
    --tblr-secondary: var(--muted);
    --tblr-secondary-color: var(--muted);
    --tblr-muted: var(--muted);
    --tblr-gray-500: var(--muted);
    --tblr-primary: var(--accent);
    --tblr-primary-rgb: 234, 88, 12;
    --tblr-primary-fg: var(--accent-ink);
    --tblr-primary-lt: var(--accent-soft);
    --tblr-primary-text-emphasis: var(--accent);
    --tblr-link-color: var(--accent);
    --tblr-link-color-rgb: 234, 88, 12;
    --tblr-link-hover-color: var(--accent);
    --tblr-success: var(--ok);
    --tblr-green: var(--ok);
    --tblr-warning: var(--warn);
    --tblr-yellow: var(--warn);
    --tblr-orange: var(--accent);
    --tblr-danger: var(--danger);
    --tblr-red: var(--danger);
    --tblr-box-shadow: none;
    --tblr-box-shadow-card: none;
    --tblr-box-shadow-dropdown: 0 8px 24px rgba(0, 0, 0, .12);
    --tblr-focus-ring-color: var(--accent-soft);
}

/* ── Base ──────────────────────────────────────────────────────────────── */
html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent); text-decoration: underline; }
::placeholder { color: var(--muted); opacity: 1; }
code, kbd, pre, samp, .font-monospace { font-family: var(--mono); }
code { color: var(--text); background: var(--surface2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
pre code { background: none; padding: 0; }
.text-secondary, .text-muted, .form-hint, .text-body-secondary { color: var(--muted) !important; }
.text-success { color: var(--ok) !important; }
.text-warning { color: var(--warn) !important; }
.text-danger { color: var(--danger) !important; }
.text-primary { color: var(--accent) !important; }
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4 { color: var(--text); }
h1, h2, h3, .h1, .h2, .h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -.01em; }
.card-sm .h1, .card-sm .h2, .card .subheader + .h1, .card .subheader + .h2 { font-weight: 400; font-variant-numeric: tabular-nums; }
.subheader, .form-section-title {
    font: 600 11px var(--sans);
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
}
hr { border-color: var(--border); opacity: 1; }

@keyframes mx-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Light / dark switch of the public pages (sign-in, setup): the sidebar footer's underlined word. */
.theme-toggle {
    border: 0;
    background: none;
    padding: 4px 0;
    font: inherit;
    font-size: 12.5px;
    color: var(--muted);
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    white-space: nowrap;
}
.theme-toggle:hover, .theme-toggle:focus-visible { color: var(--text); }

/* ── Shell: sidebar · top bar · scrolling content ──────────────────────── */
.app-shell {
    display: flex;
    height: 100vh;
    min-height: 0;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-w);
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 22px 16px 18px;
    border-right: 1px solid var(--border);
    background: var(--bg);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 10px 20px;
    color: var(--text);
}
.sidebar-brand:hover { color: var(--text); text-decoration: none; }
.sidebar-brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; }
.sidebar-brand-logo { block-size: 24px; max-inline-size: 120px; object-fit: contain; flex: none; }
.sidebar-brand-name { font: 500 21px/1 var(--serif); letter-spacing: -.01em; }

.sidebar-search,
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    font: inherit;
    line-height: normal;
    text-align: left;
    color: var(--muted);
    cursor: pointer;
}
.sidebar-search { gap: 8px; }
.sidebar-search:hover,
.sidebar-search:focus-visible { color: var(--text); background: var(--surface2); }
.sidebar-search-label { flex: 1; }
.sidebar-search-key { font: 11.5px var(--sans); color: var(--muted); background: none; padding: 0; box-shadow: none; }

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
/* Section headings are buttons that collapse their group (js/shared/nav.js, remembered per user). */
.sidebar-group { display: flex; flex-direction: column; gap: 2px; }
.sidebar-group-body { display: flex; flex-direction: column; gap: 2px; }
.sidebar-group-body[hidden] { display: none; }
.sidebar-section {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    border: 0;
    border-radius: 6px;
    background: none;
    font: 600 11px var(--sans);
    letter-spacing: .1em;
    text-transform: uppercase;
    text-align: start;
    color: var(--muted);
    padding: 18px 10px 6px;
    cursor: pointer;
}
.sidebar-group:first-child .sidebar-section { padding-top: 12px; }
.sidebar-section:hover,
.sidebar-section:focus-visible { color: var(--text); }
.sidebar-section::after {
    content: "";
    width: 5px;
    height: 5px;
    margin-inline-start: auto;
    border: solid currentColor;
    border-width: 0 1.5px 1.5px 0;
    transform: translateY(-2px) rotate(45deg);
    transition: transform .15s ease-out;
}
.sidebar-section[aria-expanded="false"]::after { transform: rotate(-45deg); }

.sidebar-link { font-weight: 500; }
.sidebar-link:hover,
.sidebar-link:focus-visible { background: var(--surface2); color: var(--muted); text-decoration: none; }
.sidebar-link.active { font-weight: 600; color: var(--text); }
.sidebar-dot { width: 5px; height: 5px; border-radius: 50%; background: transparent; flex: none; }
.sidebar-link.active .sidebar-dot { background: var(--accent); }
.sidebar-badge { font-size: 12px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.sidebar-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Secondary sidebar: the open project's sections, a column between the sidebar and the page. */
.subnav {
    width: var(--subnav-w);
    flex: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 22px 12px 18px;
    border-inline-end: 1px solid var(--border);
    background: var(--surface2);
    overflow-y: auto;
}
.subnav-switch { margin: 4px 0 10px; }
.subnav-section { margin: 0; padding: 14px 10px 4px; font: 600 11px var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.subnav-switch + .subnav-section { padding-top: 4px; }
.subnav-link { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 6px; font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.subnav-link .ti { font-size: 17px; flex: none; }
.subnav-link:hover, .subnav-link:focus-visible { background: var(--bg); color: var(--text); text-decoration: none; }
.subnav-link.active { background: var(--bg); color: var(--text); font-weight: 600; box-shadow: inset 2px 0 var(--accent); }
.subnav-link.active .ti { color: var(--accent); }
.subnav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.sidebar-foot {
    padding: 14px 10px 0;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sidebar-status { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.sidebar-status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex: none; }
.sidebar-status-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    inline-size: calc(100% + 16px);
    margin-inline: -8px;
    padding: 6px 8px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: start;
    cursor: pointer;
}
.sidebar-user:hover,
.sidebar-user:focus-visible { background: var(--surface2); }
.sidebar-user-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.25; }
.sidebar-user-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-more { flex: none; color: var(--muted); }

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

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 32px;
    height: var(--topbar-h);
    flex: none;
    border-bottom: 1px solid var(--border);
}
.topbar-crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); min-width: 0; }
.topbar-crumbs > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-crumb-current { color: var(--text); font-weight: 500; }
.topbar-spacer { flex: 1; }
.topbar-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--surface2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}
.topbar-pill:hover { color: var(--muted); text-decoration: none; filter: brightness(.97); }
.topbar-pill-ok, .topbar-pill-ok:hover { background: var(--ok-soft); color: var(--ok); }
.topbar-pill-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.topbar-menu {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-left: -8px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--text);
    font-size: 18px;
}
.topbar-menu:hover { background: var(--surface2); }

.app-scroll { flex: 1; overflow: auto; padding: 32px; min-height: 0; }
.app-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
    animation: mx-in .2s ease-out;
}
.page-content { min-width: 0; }

.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head-text { flex: 1; min-width: 240px; }
.page-head-title { margin: 0; font: 400 34px/1.1 var(--serif); letter-spacing: -.015em; color: var(--text); }
.page-head-sub { margin: 8px 0 0; color: var(--muted); font-size: 15px; max-width: 60ch; }
.page-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
/* A live region among the actions (e.g. the project's Activate / Deactivate) lays its buttons out as siblings. */
.page-head-actions > [data-live-region] { display: contents; }

.sidebar-scrim { display: none; }

/* Narrow screens: the sidebar slides in over the page. */
@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 1040;
        transform: translateX(-100%);
        transition: transform .2s ease-out;
        max-width: 85vw;
    }
    body.sidebar-open .sidebar { transform: none; }
    .sidebar-scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 1035; background: var(--overlay); }
    .topbar { padding: 0 16px; }
    .topbar-pill:not(.topbar-pill-ok) { display: none; }
    .topbar-menu { display: inline-flex; }
    .app-scroll { padding: 24px 16px; }
    .page-head-title { font-size: 28px; }
    /* the project sections become a scrolling strip above the page */
    .app-shell:has(> .subnav) { flex-direction: column; }
    .subnav { width: auto; flex-direction: row; align-items: center; padding: 8px 12px; border-inline-end: 0; border-block-end: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; }
    .subnav-switch .sidebar-context-info { display: none; }
    .subnav-switch { flex: none; margin: 0 6px 0 0; padding: 4px 6px; }
    .subnav-link { flex: none; }
    .subnav-section { display: none; }
    .app-main { min-height: 0; }
}

@media print {
    .sidebar, .subnav, .topbar { display: none; }
    .app-shell, .app-main, .app-scroll { height: auto; overflow: visible; }
}

/* ── ⌘K palette ────────────────────────────────────────────────────────── */
.palette {
    width: min(560px, 92vw);
    margin: 12vh auto auto;
    padding: 0;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--pop-shadow);
    overflow: hidden;
}
.palette[open] { animation: mx-in .15s ease-out; }
.palette::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
.palette-input {
    width: 100%;
    box-sizing: border-box;
    padding: 14px 16px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font: 15px var(--sans);
    outline: none;
}
.palette-input:focus { outline: none; }
.palette-list { list-style: none; margin: 0; max-height: 360px; overflow: auto; padding: 6px; }
.palette-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 6px;
    cursor: pointer;
}
.palette-item:hover, .palette-item[aria-selected=true] { background: var(--surface2); }
.palette-kind {
    font: 600 10.5px var(--sans);
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--surface2);
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}
.palette-label { flex: 1; }
.palette-hint { font-size: 11.5px; color: var(--muted); }
.palette-empty { padding: 9px 10px; color: var(--muted); }
.palette-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted); }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
    --tblr-card-bg: var(--surface);
    --tblr-card-border-color: var(--border);
    --tblr-card-border-radius: var(--r);
    --tblr-card-inner-border-radius: calc(var(--r) - 1px);
    --tblr-card-box-shadow: none;
    --tblr-card-cap-bg: transparent;
    --tblr-card-spacer-x: var(--pad);
    --tblr-card-spacer-y: var(--pad);
    --tblr-card-cap-padding-y: 14px;
    --tblr-card-cap-padding-x: var(--pad);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: none;
    color: var(--text);
}
.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px var(--pad);
    min-height: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
}
.card-title, .card-header .card-title, .modal-title {
    margin: 0;
    font: 500 17px var(--serif);
    color: var(--text);
}
.card-subtitle { color: var(--muted); font-size: 12.5px; }
.card-body { padding: var(--pad); }
.card-footer { padding: 14px var(--pad); border-top: 1px solid var(--border); background: transparent; }
.card-sm > .card-body { padding: 14px var(--pad); }
.card-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.row-cards { --tblr-gutter-x: 14px; --tblr-gutter-y: 14px; }

/* ── Tables ────────────────────────────────────────────────────────────── */
.table {
    --tblr-table-bg: transparent;
    --tblr-table-color: var(--text);
    --tblr-table-border-color: var(--border);
    --tblr-table-hover-bg: var(--surface2);
    --tblr-table-hover-color: var(--text);
    --tblr-table-striped-bg: var(--surface2);
    --tblr-table-active-bg: var(--surface2);
    color: var(--text);
    border-color: var(--border);
    font-variant-numeric: tabular-nums;
    margin-bottom: 0;
}
.table > :not(caption) > * > * {
    padding: 11px var(--pad);
    border-bottom: 1px solid var(--border);
    background: transparent;
    box-shadow: none;
}
.table thead th,
.table > thead > tr > th {
    padding: 8px var(--pad);
    font: 600 11px/14px var(--sans);
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    background: transparent;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table-hover > tbody > tr:hover > * { background: var(--surface2); color: var(--text); --tblr-table-bg-state: var(--surface2); }
.table-vcenter > :not(caption) > * > * { vertical-align: middle; }
.card-table { margin-bottom: 0; }
.card-table > :not(caption) > tr:last-child > *,
.card-table > tbody > tr:last-child > * { border-bottom: 0; }
.table-responsive { border-radius: inherit; }
.table small, .table .small { font-size: 11.5px; }
.table a:not(.btn) { color: var(--text); font-weight: 500; }
.table a:not(.btn):hover { color: var(--accent); text-decoration: none; }
.table code { padding: 0; background: none; font: 500 13px var(--mono); color: var(--text); }

/* Filter, column chooser (shared/data-table.js) — the design's pill filter. */
.table-toolbar { padding: 10px var(--pad); gap: 8px; border-block-end: 1px solid var(--border); }
.table-toolbar .table-filter,
.table-toolbar input[type=search] {
    inline-size: min(100%, 200px);
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    font-size: 13px;
    line-height: normal;
}
.table-toolbar .table-choice {
    inline-size: auto;
    padding-block: 6px;
    border-radius: 999px;
    font-size: 13px;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
    --tblr-btn-padding-x: 16px;
    --tblr-btn-padding-y: 9px;
    --tblr-btn-font-size: 14px;
    --tblr-btn-font-weight: 500;
    --tblr-btn-line-height: normal;
    --tblr-btn-border-radius: 999px;
    --tblr-btn-box-shadow: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    font: 500 14px/normal var(--sans);
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    box-shadow: none;
    transition: border-color .12s ease, filter .12s ease, background-color .12s ease, color .12s ease;
}
.btn:hover, .btn:focus-visible { border-color: var(--accent); background: var(--surface); color: var(--text); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; box-shadow: none; }
.btn:disabled, .btn.disabled { opacity: .55; }
.btn-primary, .btn-primary:disabled {
    border: 0;
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
}
.btn-primary:hover, .btn-primary:focus-visible, .btn-primary:active, .btn-primary.active {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
    filter: brightness(1.08);
}
.btn-dark { border-color: var(--text); background: var(--text); color: var(--bg); font-weight: 600; }
.btn-dark:hover { border-color: var(--text); background: var(--text); color: var(--bg); filter: brightness(1.15); }
.btn-outline-secondary, .btn-secondary, .btn-light, .btn-outline-primary, .btn-ghost-secondary, .btn-outline-dark {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text);
}
.btn-outline-primary { color: var(--text); }
.btn-outline-danger, .btn-danger { border-color: var(--border); background: var(--surface); color: var(--danger); }
.btn-outline-danger:hover, .btn-outline-danger:focus-visible, .btn-danger:hover {
    border-color: var(--danger); background: var(--surface); color: var(--danger);
}
.modal .btn-danger, .btn-danger.btn-solid { border-color: var(--danger); background: var(--danger); color: #fff; font-weight: 600; }
.modal .btn-danger:hover { border-color: var(--danger); background: var(--danger); color: #fff; filter: brightness(1.08); }
.btn-outline-success, .btn-success { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.btn-outline-success:hover, .btn-success:hover { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); filter: brightness(1.05); }
.btn-outline-warning, .btn-warning { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.btn-link, .btn-ghost {
    border-color: transparent;
    background: none;
    color: var(--muted);
    padding-inline: 8px;
}
.btn-link:hover, .btn-ghost:hover { border-color: transparent; background: none; color: var(--text); }
.btn-sm, .btn-group-sm > .btn {
    --tblr-btn-padding-x: 10px;
    --tblr-btn-padding-y: 5px;
    --tblr-btn-font-size: 12px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 400;
    border-radius: 6px;
}
.btn-sm.btn-primary { padding: 6px 12px; font-size: 12.5px; font-weight: 600; }
.btn-icon { padding: 7px; aspect-ratio: 1; }
.btn-sm.btn-icon { padding: 5px; }
/* The design's buttons are words only: an icon placed before a label is hidden, icon-only buttons keep theirs. */
.btn > .ti.me-1, .btn > .ti.me-2 { display: none; }
.btn-close { filter: none; opacity: .6; }
[data-theme=dark] .btn-close { filter: invert(1) grayscale(1) brightness(2); }
.btn-list { gap: 8px; }

/* ── Badges, chips, status ─────────────────────────────────────────────── */
.badge {
    --tblr-badge-padding-x: 8px;
    --tblr-badge-padding-y: 2px;
    --tblr-badge-font-size: 11.5px;
    --tblr-badge-font-weight: 500;
    --tblr-badge-border-radius: 999px;
    padding: 2px 8px;
    font: 500 11.5px/normal var(--sans);
    border: 0;
    border-radius: 999px;
    background: var(--surface2);
    color: var(--text);
    text-transform: none;
    letter-spacing: 0;
}
.badge.bg-secondary-lt, .badge.bg-secondary, .badge.bg-light { background: var(--surface2) !important; color: var(--muted) !important; }
.badge.bg-green-lt, .badge.bg-success-lt, .badge.bg-success, .badge.bg-green { background: var(--ok-soft) !important; color: var(--ok) !important; }
.badge.bg-yellow-lt, .badge.bg-warning-lt, .badge.bg-warning, .badge.bg-orange-lt, .badge.bg-yellow { background: var(--warn-soft) !important; color: var(--warn) !important; }
.badge.bg-red-lt, .badge.bg-danger-lt, .badge.bg-danger, .badge.bg-red { background: var(--danger-soft) !important; color: var(--danger) !important; }
.badge.bg-blue-lt, .badge.bg-azure-lt, .badge.bg-primary-lt, .badge.bg-primary, .badge.bg-purple-lt, .badge.bg-info, .badge.bg-blue {
    background: var(--accent-soft) !important; color: var(--accent) !important;
}
.status-dot, .status-indicator { background: currentColor; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.form-label {
    margin-bottom: 5px;
    font-size: 12px;
    font-weight: 400;
    color: var(--muted);
}
.form-label.required::after, .form-required { color: var(--danger); }
/* The design's fields take the 12 px of their label (33 px high). */
.form-control, .form-select {
    padding: 8px 10px;
    font: 12px/normal var(--sans);
    color: var(--text);
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: none;
}
.form-select { padding-right: 2rem; }
.form-control:focus, .form-select:focus {
    color: var(--text);
    background-color: var(--bg);
    border-color: var(--border);
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    box-shadow: none;
}
.form-control:disabled, .form-control[readonly], .form-select:disabled { background-color: var(--surface2); color: var(--muted); }
.form-control-sm, .form-select-sm { padding: 5px 8px; font-size: 12.5px; }
.form-select-sm { padding-right: 1.75rem; }   /* room for the chevron, which the shorthand above would cover */
.form-control-color { padding: 4px; width: 48px; height: 38px; }
textarea.form-control.code-area, .code-area, .form-control.font-monospace { font: 12.5px/1.55 var(--mono); }
.form-check-input { border-color: var(--border); background-color: var(--bg); box-shadow: none; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
.form-switch .form-check-input:checked { background-color: var(--accent); }
.form-hint { font-size: 12px; margin-top: 4px; }
.invalid-feedback { color: var(--danger); font-size: 12px; }
.is-invalid, .form-control.is-invalid { border-color: var(--danger) !important; }
.input-group-text { background: var(--surface2); border-color: var(--border); color: var(--muted); border-radius: 6px; }
.form-fieldset { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r); }

/* ── Tabs ──────────────────────────────────────────────────────────────── */
.nav-tabs {
    --tblr-nav-tabs-border-width: 0;
    --tblr-nav-tabs-link-active-bg: transparent;
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    background: transparent;
}
.nav-tabs .nav-link {
    padding: 8px 14px;
    line-height: normal;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: none;
    font-weight: 500;
    color: var(--muted);
}
.nav-tabs .nav-link:hover { color: var(--text); border: 0; background: none; }
.nav-tabs .nav-link > .ti { display: none; }
.nav-tabs .nav-link.active, .nav-tabs .nav-item.show .nav-link {
    color: var(--accent);
    background: none;
    border: 0;
    box-shadow: inset 0 -2px var(--accent);
}
.card-header-tabs { margin: -14px calc(var(--pad) * -1) -1px; padding: 6px 8px 0; border-bottom: 0; flex-wrap: wrap; row-gap: 0; }
.card-header:has(> .card-header-tabs), .card-header:has(> .nav-tabs) { padding-bottom: 0; }
.nav-pills .nav-link { border-radius: 6px; color: var(--muted); font-weight: 500; padding: 8px 10px; }
.nav-pills .nav-link.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.list-group { --tblr-list-group-bg: transparent; --tblr-list-group-border-color: var(--border); }
.list-group-item { background: transparent; color: var(--text); border-color: var(--border); }
.list-group-item.active { background: var(--accent-soft); color: var(--text); border-color: var(--border); font-weight: 600; }
.list-group-item-action:hover { background: var(--surface2); color: var(--text); }

/* ── Dropdowns ─────────────────────────────────────────────────────────── */
.dropdown-menu {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
    color: var(--text);
    padding: 6px;
}
.dropdown-item { border-radius: 6px; padding: 7px 10px; color: var(--text); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface2); color: var(--text); }

/* ── Modals ────────────────────────────────────────────────────────────── */
.modal-backdrop { --tblr-backdrop-bg: rgb(10, 12, 16); --tblr-backdrop-opacity: .45; background: var(--overlay); }
.modal-backdrop.show { opacity: 1; }
.modal-blur { backdrop-filter: blur(2px); }
.modal-content {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--pop-shadow);
}
.modal-header { padding: 14px var(--pad); border-bottom: 1px solid var(--border); min-height: 0; }
.modal-body { padding: var(--pad); }
.modal-footer { padding: 12px var(--pad); border-top: 1px solid var(--border); gap: 8px; background: transparent; }
.modal-footer > * { margin: 0; }
.modal-status { display: none; }

/* ── Alerts, toasts, empty states ──────────────────────────────────────── */
.alert {
    --tblr-alert-bg: var(--surface2);
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: var(--surface2);
    color: var(--text);
    box-shadow: none;
    font-size: 13px;
}
.alert::before { display: none; }
.alert-success { border-color: transparent; background: var(--ok-soft); color: var(--ok); }
.alert-warning { border-color: transparent; background: var(--warn-soft); color: var(--warn); }
.alert-danger { border-color: transparent; background: var(--danger-soft); color: var(--danger); }
.alert-info, .alert-primary { border-color: transparent; background: var(--accent-soft); color: var(--text); }
.alert-title { font-weight: 600; }
.alert .alert-icon { color: inherit; }

.toast {
    background: var(--text);
    color: var(--bg);
    border: 0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
    font-size: 13px;
}
.toast-header { background: transparent; color: var(--bg); border-bottom-color: rgba(255, 255, 255, .12); }
.toast-body { padding: 10px 16px; }
.toast .btn-close { filter: invert(1); }
[data-theme=dark] .toast .btn-close { filter: none; }

.empty { color: var(--muted); padding: 22px; text-align: center; font-size: 13px; }
.empty-title { font: 500 17px var(--serif); color: var(--text); }

/* ── Misc Tabler pieces ────────────────────────────────────────────────── */
.avatar {
    --tblr-avatar-bg: var(--surface2);
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: var(--surface2);
    color: var(--text);
    font: 600 11px var(--sans);
    box-shadow: none;
}
.progress { height: 5px; border-radius: 3px; background: var(--surface2); }
.progress-bar { background: var(--accent); }
.spinner-border { color: var(--accent); }
.datagrid-title { font: 600 11px var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.page-link { color: var(--text); border-color: var(--border); background: var(--surface); }
.page-item.active .page-link { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.border, .border-top, .border-bottom, .border-start, .border-end { border-color: var(--border) !important; }
.bg-white, .bg-light { background: var(--surface) !important; }
.shadow, .shadow-sm { box-shadow: none !important; }

/* ── Design patterns used by our own pages ─────────────────────────────── */
/* Top-bar deploy counts: a live region wrapper that lays out like its pills. */
.topbar-pills { display: contents; }

/* Promote chain of the project environments tab: one station per environment, arrow to the next. */
.env-chain { display: flex; flex-wrap: wrap; gap: 12px; margin: 0; padding: 0; list-style: none; }
.env-station {
    flex: 1 1 180px; min-width: 0; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
.env-station-name { display: flex; align-items: baseline; gap: 6px; font-weight: 600; }
.env-station-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.env-station-ready { color: var(--accent); font-weight: 600; }
.env-station-next { margin-top: 4px; }
.env-legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 12px 0 0; padding: 0; list-style: none; }
.env-legend li { display: flex; align-items: center; gap: 6px; }
.env-legend-ready {
    display: inline-block; inline-size: 18px; block-size: 12px; border-radius: 3px;
    background: var(--accent-soft); border-inline-start: 3px solid var(--accent);
}
/* Matrix cells: installed version on top, the cell's actions below; a cell the predecessor can promote into is tinted. */
.env-matrix td.env-cell-ready { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.env-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.env-cell-installed, .env-cell-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.env-cell-version { display: flex; flex-direction: column; gap: 4px; }
.env-cell-version + .env-cell-version { padding-block-start: 6px; border-block-start: 1px dashed var(--tblr-border-color); }

/* KPI strip: hairline on top, serif figure (dashboard, statistics). */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 24px; }
.kpi { padding: 14px 0 4px; border-top: 1px solid var(--text); min-width: 0; }
.kpi-wide { grid-column: span 2; }
.kpi-label { font-size: 12.5px; color: var(--muted); }
.kpi-value {
    margin-top: 6px;
    font: 400 34px/1.1 var(--serif);
    letter-spacing: -.01em;
    font-variant-numeric: tabular-nums;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.kpi-sub { margin-top: 4px; font-size: 12px; color: var(--muted); }
@media (max-width: 575.98px) { .kpi-wide { grid-column: auto; } }

/* Tiles: the design's project cards — a whole card is the link. */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.tile {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--pad);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    color: var(--text);
}
.tile:hover, .tile:focus-visible { border-color: var(--accent); color: var(--text); text-decoration: none; }
.tile-name { font-weight: 600; font-size: 15px; }
.tile-key { font-size: 12px; color: var(--muted); }
.tile-text { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.dashboard { display: flex; flex-direction: column; gap: 28px; }

/* ── Dashboard ─────────────────────────────────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; }
@media (max-width: 899.98px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } }
.dash-card { display: flex; flex-direction: column; }
.dash-card-title { flex: 1; }
.dash-peak { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dash-chart { display: block; inline-size: 100%; block-size: 140px; overflow: visible; }
.dash-chart-area { fill: var(--accent-soft); stroke: none; }
.dash-chart-line { fill: none; stroke: var(--accent); }
.dash-axis { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.dash-deploys { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.dash-deploy { display: flex; align-items: center; gap: 10px; padding: 10px var(--pad); border-bottom: 1px solid var(--border); }
.dash-chip { padding: 2px 8px; border-radius: 4px; background: var(--surface2); font: 500 12px var(--sans); }
.dash-deploy-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-deploy-status { font-size: 12px; font-weight: 500; color: var(--muted); }
.dash-deploy-status.is-deployed { color: var(--ok); }
.dash-deploy-when { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dash-empty { color: var(--muted); }
.dash-link { margin-left: auto; font-size: 12.5px; }
.dash-project a { display: block; }
.dash-project-desc { font-size: 11.5px; color: var(--muted); }
.dash-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dash-status-healthy { color: var(--ok); }
.dash-status-degraded { color: var(--warn); }
.dash-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
#dashboard-projects tbody tr[data-id] { cursor: pointer; }

/* ── Design parity: tags and the Runtime figure row ────────────────────── */
/* The design's tags are lower-case ("staging", "archived"); enum names arrive upper-case. */
.badge { text-transform: lowercase; }
/* API Explorer badges show literal API values (methods, enum constants): keep them as written. */
body:has(#api-docs-data) .badge { text-transform: none; }
/* Runtime KPIs: every figure the same serif 30 px, columns of at least 150 px, 24 px apart. */
.kpis.kpis-dense { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 24px; }
.kpis-dense .kpi-value, .kpis-dense .kpi-value-text { font-size: 30px; white-space: nowrap; }

/* ── About dialog (sidebar foot → modal, ported from trakr) ───────────────────── */
.sidebar-about {
    inline-size: calc(100% + 16px);
    border: 0;
    background: none;
    padding: 6px 8px;
    margin-inline: -8px;
    border-radius: 6px;
    font: inherit;
    font-size: 12.5px;
    text-align: start;
    cursor: pointer;
}
.sidebar-about:hover,
.sidebar-about:focus-visible { background: var(--surface2); color: var(--text); }
.sidebar-about-icon { flex: none; opacity: .7; }

.about-modal { overflow: hidden; }
.about-hero {
    position: relative;
    padding: 28px 24px 22px;
    text-align: center;
    background: var(--surface2);
    border-block-end: 1px solid var(--border);
}
.about-hero-close { position: absolute; inset-block-start: 14px; inset-inline-end: 14px; }
.about-mark {
    display: inline-grid;
    place-items: center;
    inline-size: 56px;
    block-size: 56px;
    border-radius: 14px;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 28px;
    margin-block-end: 12px;
}
.about-name { margin: 0; font-size: 20px; font-weight: 700; }
.about-tagline { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.about-body { display: flex; flex-direction: column; gap: 16px; }
.about-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.about-fact {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.about-fact-label,
.about-section-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.about-fact-value { font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.about-europe { display: flex; gap: 12px; align-items: flex-start; }
.about-europe-flag { font-size: 24px; line-height: 1; }
.about-europe-title { font-weight: 600; }
.about-europe-text { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.about-runtime-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 16px;
    margin: 6px 0 0;
    font-size: 13px;
}
.about-runtime-grid dt { color: var(--muted); font-weight: 400; }
.about-runtime-grid dd { margin: 0; overflow-wrap: anywhere; }
.about-makers { display: flex; flex-direction: column; gap: 2px; }
.about-makers-names { font-weight: 600; }

/* ── Context switcher (sidebar top → modal, ported from trakr) ────────────────── */
.sidebar-context {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: -8px 0 14px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: start;
    cursor: pointer;
}
.sidebar-context:hover,
.sidebar-context:focus-visible { border-color: var(--muted); }
.sidebar-context-icon {
    display: grid;
    place-items: center;
    inline-size: 28px;
    block-size: 28px;
    flex: none;
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 16px;
}
.sidebar-context-info { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 1px; }
.sidebar-context-tenant {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-context-org { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-context-arrow { flex: none; color: var(--muted); }

.context-list { display: flex; flex-direction: column; gap: 4px; max-block-size: 50vh; overflow-y: auto; }
.context-item {
    display: flex;
    align-items: center;
    gap: 10px;
    inline-size: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    text-align: start;
    cursor: pointer;
}
.context-item:hover:not(:disabled),
.context-item:focus-visible { border-color: var(--accent); }
.context-item.is-current { border-color: var(--accent); background: var(--accent-soft); cursor: default; }
.context-item:disabled { opacity: .6; cursor: progress; }
.context-item-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.context-item-hint { font-size: 12px; color: var(--muted); }
.context-empty { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

/* ── User menu (sidebar foot → modal, ported from trakr's avatar dropdown) ────── */
.user-avatar {
    display: grid;
    place-items: center;
    inline-size: 30px;
    block-size: 30px;
    flex: none;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
}
.user-avatar-lg { inline-size: 44px; block-size: 44px; font-size: 16px; }
/* User menu: popover anchored above the sidebar's user button; user-menu.js sets the inset. */
.user-menu {
    position: fixed;
    inset: auto;
    margin: 0;
    inline-size: 260px;
    max-inline-size: calc(100vw - 16px);
    padding: 0;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--pop-shadow);
    overflow: hidden;
}
.user-menu:popover-open { animation: mx-in .12s ease-out; }
.user-menu-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 14px 12px;
    border-block-end: 1px solid var(--border);
}
.user-menu-identity { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 2px; }
.user-menu-name { font-weight: 700; overflow-wrap: anywhere; }
.user-menu-org { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.user-menu-role {
    align-self: flex-start;
    margin-block-start: 4px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--surface2);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--muted);
}
.user-menu-list { display: flex; flex-direction: column; padding: 8px; }
.user-menu-form { margin: 0; }
.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    inline-size: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    text-align: start;
    cursor: pointer;
}
.user-menu-item:hover,
.user-menu-item:focus-visible { background: var(--surface2); color: var(--text); text-decoration: none; }
.user-menu-item .ti { font-size: 18px; color: var(--muted); }
.user-menu-item-danger,
.user-menu-item-danger .ti { color: var(--danger); }
.user-menu-divider { block-size: 1px; margin: 6px 4px; background: var(--border); }

/* Code is read character by character: no ligatures (JetBrains Mono turns <!-- and -> into arrows).
   Last rule of the last stylesheet, so no `font` shorthand above can switch them back on. */
code, kbd, pre, samp, .table code, .font-monospace, .form-control.font-monospace, .code-area, .code-view,
.code-input, .code-gutter, .code-highlight, .wb-output-text {
    font-variant-ligatures: none;
    font-feature-settings: "liga" 0, "calt" 0;
}
