/* =====================================================================
   Dev-Tracker re-skin - design system foundation layer
   ---------------------------------------------------------------------
   Loaded AFTER site.css (and after Bootstrap), so token re-definitions
   and component restyles here win the cascade by load order.

   Principles: flat, calm, dense, professional. No gradients, no drop
   shadows (focus rings only). Sentence case. Two weights (400 / 500).
   0.5px borders. Radius: cards 12px, controls/badges 8px, pills 999px.
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. TOKENS - LIGHT (default)
   These re-define the variables site.css already consumes (--primary,
   --surface, --border, --radius, status tints, ...) plus new tokens
   (--accent, --surface-alt, --text-muted, --shadow, type/priority).
   --------------------------------------------------------------------- */
:root {
    /* Brand / accent: Dot.Cy orange (spec Dot.Cy Brand Theme, section 7.1). The orange is a FILL colour only:
       it is 2.28:1 on white, so text uses --accent-text (R3) and lines, borders and focus rings use
       --accent-line, the brand's darker orange at 3.12:1 (R2). Text on an orange fill is --on-accent (D4). */
    --accent: #F79420;
    --accent-hover: #E8850F;
    --accent-active: #D97A0C;
    --accent-subtle: #FBF2E7;
    --on-accent: #2E2B2C;
    --accent-text: #9A4C00;
    --accent-text-hover: #7A3C00;
    --accent-line: #D97A0C;

    /* Secondary accent: Dot.Cy ink. Quiet highlights (favourite star, aging figure, new activity rows) that
       must stay distinct from the orange primary; an amber next to the orange would read as a wrong shade. */
    --accent-2: #333333;
    --accent-2-hover: #2E2B2C;
    --accent-2-subtle: #EFEAEB;
    --on-accent-2: #FFFFFF;

    /* Re-point the legacy primary tokens at the new accent so every
       existing .button-primary / link / focus ring inherits the brand. */
    --primary: #F79420;
    --primary-hover: #E8850F;

    /* Surfaces & text: Dot.Cy warm greys. Ink #333333 for text (12.63:1), body grey #5E5A5B for muted text (6.80:1). */
    --bg: #FAF8F8;
    --surface: #FFFFFF;
    --surface-alt: #F7F4F4;   /* quiet zebra / header-cell fill */
    --surface-muted: #EFEAEB; /* search field, soft chips */
    --text: #333333;
    --muted: #5E5A5B;
    --text-muted: #5E5A5B;    /* alias used by some existing rules */
    --border: #E1DBDC;        /* rendered at 0.5px via component rules */
    --border-strong: #CFC7C8;

    /* Status (focus ring) */
    --focus-ring: 0 0 0 3px var(--accent-line);

    /* Danger (kept, slightly calmer) */
    --danger: #A32D2D;
    --danger-hover: #7F2222;

    /* Radii */
    --radius: 12px;            /* cards / panels */
    --radius-control: 8px;     /* buttons, inputs, badges */
    --radius-pill: 999px;

    /* Type: one standard system stack, no downloaded web fonts (spec section 7.3, R5). Segoe UI on Windows,
       the platform UI font elsewhere. Headings use the same family at weight 600 rather than a second face. */
    --font-sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-display: var(--font-sans);
    --font-mono: Consolas, "Cascadia Mono", ui-monospace, monospace;

    /* Flat: kill shadows globally (focus rings only). */
    --shadow: none;

    /* Shell metrics */
    --rail-width: 54px;
    --settings-width: 264px;
    --topbar-height: 56px;

    /* ---- Workflow status tints (self-contained chips) ---- */
    /* Open */
    --status-open-bg: #E6F1FB;
    --status-open-text: #0C447C;
    --status-open-border: #C5DDF5;
    --status-open-accent: #185FA5;
    /* Reopen */
    --status-reopen-bg: #FAEEDA;
    --status-reopen-text: #633806;
    --status-reopen-border: #ECD7AE;
    --status-reopen-accent: #9A6212;
    /* In progress */
    --status-inprogress-bg: #EEEDFE;
    --status-inprogress-text: #3C3489;
    --status-inprogress-border: #D7D4F7;
    --status-inprogress-accent: #5B50C9;
    /* On hold */
    --status-onhold-bg: #F1EFE8;
    --status-onhold-text: #444441;
    --status-onhold-border: #DFDCD2;
    --status-onhold-accent: #6E6B62;
    /* Resume */
    --status-resume-bg: #E1F5EE;
    --status-resume-text: #085041;
    --status-resume-border: #BFE6D9;
    --status-resume-accent: #0E8A6E;
    /* Future phase */
    --status-futurephase-bg: #F1EFE8;
    --status-futurephase-text: #5F5E5A;
    --status-futurephase-border: #DFDCD2;
    --status-futurephase-accent: #87857E;
    /* In spec */
    --status-inspec-bg: #F4EAF7;
    --status-inspec-text: #5B2266;
    --status-inspec-border: #E4CFEA;
    --status-inspec-accent: #9B4DB0;
    /* Pending plan */
    --status-pendingplan-bg: #FAEEDA;
    --status-pendingplan-text: #633806;
    --status-pendingplan-border: #EED9B5;
    --status-pendingplan-accent: #B8741A;
    /* Planned */
    --status-planned-bg: #E6F1FB;
    --status-planned-text: #0C447C;
    --status-planned-border: #C7DDF2;
    --status-planned-accent: #2F78C4;
    /* Parked */
    --status-parked-bg: #EEEDEA;
    --status-parked-text: #4A4943;
    --status-parked-border: #DCDAD3;
    --status-parked-accent: #7A786F;
    /* Resolved */
    --status-resolved-bg: #EAF3DE;
    --status-resolved-text: #27500A;
    --status-resolved-border: #D2E5BB;
    --status-resolved-accent: #4E8C1E;
    /* Canceled */
    --status-canceled-bg: #FCEBEB;
    --status-canceled-text: #791F1F;
    --status-canceled-border: #F2D2D2;
    --status-canceled-accent: #B53A3A;
    /* Soft close */
    --status-softclose-bg: #F1EFE8;
    --status-softclose-text: #444441;
    --status-softclose-border: #DFDCD2;
    --status-softclose-accent: #6E6B62;

    /* ---- Priority tints (text-forward + subtle bg) ---- */
    --priority-low-text: #5F5E5A;
    --priority-low-bg: #F1EFE8;
    --priority-medium-text: #185FA5;
    --priority-medium-bg: #E6F1FB;
    --priority-high-text: #854F0B;
    --priority-high-bg: #FAEEDA;
    --priority-critical-text: #A32D2D;
    --priority-critical-bg: #FCEBEB;

    /* ---- Type tints ---- */
    --type-bug-bg: #FAECE7;
    --type-bug-text: #993C1D;
    --type-task-bg: #E6F1FB;
    --type-task-text: #185FA5;

    /* Bootstrap surface bridge (site.css already maps these). */
    --bs-primary: var(--accent);
    --bs-link-color: var(--accent-text);
    --bs-link-hover-color: var(--accent-text-hover);
    --bs-border-color: var(--border);
}

/* ---------------------------------------------------------------------
   2. TOKENS - DARK
   Every new token gets a dark counterpart. Status/priority/type chips
   keep readable on dark surfaces (own bg + text).
   --------------------------------------------------------------------- */
html[data-theme="dark"] {
    --accent: #F79420;
    --accent-hover: #FFA640;
    --accent-active: #D97A0C;
    --accent-subtle: rgba(247, 148, 32, 0.16);
    --on-accent: #2E2B2C;
    /* On dark surfaces the fill orange itself clears 3:1 (7.35:1 on --bg), so lines use it; text is lighter still. */
    --accent-text: #FFB15C;
    --accent-text-hover: #FFC883;
    --accent-line: #F79420;

    /* Secondary accent: light ink, the dark-mode counterpart of the light theme's ink highlight. */
    --accent-2: #F2EFEF;
    --accent-2-hover: #FFFFFF;
    --accent-2-subtle: #383435;
    --on-accent-2: #2E2B2C;

    --primary: #F79420;
    --primary-hover: #FFA640;

    --bg: #1F1D1E;
    --surface: #2E2B2C;
    --surface-alt: #383435;
    --surface-muted: #332F30;
    --text: #F2EFEF;
    --muted: #B8B1B2;
    --text-muted: #B8B1B2;
    --border: #4A4546;
    --border-strong: #5C5657;

    --focus-ring: 0 0 0 3px var(--accent-line);

    --danger: #F08A8A;
    --danger-hover: #F6ABAB;

    --shadow: none;
    color-scheme: dark;

    /* Status tints - dark surfaces, light text. */
    --status-open-bg: #122A44;
    --status-open-text: #9EC8F2;
    --status-open-border: #234B72;
    --status-open-accent: #5BA0E8;
    --status-reopen-bg: #352608;
    --status-reopen-text: #E7C489;
    --status-reopen-border: #5C461A;
    --status-reopen-accent: #C9952F;
    --status-inprogress-bg: #211C3E;
    --status-inprogress-text: #BDB6F2;
    --status-inprogress-border: #3E3678;
    --status-inprogress-accent: #8F84E0;
    --status-onhold-bg: #26241D;
    --status-onhold-text: #C8C4B6;
    --status-onhold-border: #423E33;
    --status-onhold-accent: #8C887C;
    --status-resume-bg: #0C2A23;
    --status-resume-text: #8FD9C5;
    --status-resume-border: #1C5042;
    --status-resume-accent: #1FA888;
    --status-futurephase-bg: #25241F;
    --status-futurephase-text: #B6B4AC;
    --status-futurephase-border: #413F37;
    --status-futurephase-accent: #8C8A82;
    /* In spec */
    --status-inspec-bg: #2B1F2F;
    --status-inspec-text: #D9B8E3;
    --status-inspec-border: #4A3352;
    --status-inspec-accent: #B57CC7;
    /* Pending plan */
    --status-pendingplan-bg: #2E2416;
    --status-pendingplan-text: #E6C38E;
    --status-pendingplan-border: #4D3B1F;
    --status-pendingplan-accent: #C98D3A;
    /* Planned */
    --status-planned-bg: #172636;
    --status-planned-text: #A9CBEE;
    --status-planned-border: #27415C;
    --status-planned-accent: #5B9BD8;
    /* Parked */
    --status-parked-bg: #262522;
    --status-parked-text: #BDBBB3;
    --status-parked-border: #403E38;
    --status-parked-accent: #8E8C84;
    --status-resolved-bg: #1B2D10;
    --status-resolved-text: #ABCE84;
    --status-resolved-border: #38561E;
    --status-resolved-accent: #6FA53A;
    --status-canceled-bg: #371717;
    --status-canceled-text: #ECA7A7;
    --status-canceled-border: #5E2A2A;
    --status-canceled-accent: #C95555;
    --status-softclose-bg: #26241D;
    --status-softclose-text: #C8C4B6;
    --status-softclose-border: #423E33;
    --status-softclose-accent: #8C887C;

    /* Priority - dark */
    --priority-low-text: #B6B4AC;
    --priority-low-bg: #25241F;
    --priority-medium-text: #9EC8F2;
    --priority-medium-bg: #122A44;
    --priority-high-text: #E7C489;
    --priority-high-bg: #352608;
    --priority-critical-text: #ECA7A7;
    --priority-critical-bg: #371717;

    /* Type - dark */
    --type-bug-bg: #3A1F15;
    --type-bug-text: #E5A98F;
    --type-task-bg: #122A44;
    --type-task-text: #9EC8F2;
}

/* ---------------------------------------------------------------------
   3. BASE
   --------------------------------------------------------------------- */
body {
    /* The one system font stack (spec Dot.Cy Brand Theme R5), so a change of face is made once, in the token. */
    font-family: var(--font-sans);
    font-weight: 400;
    letter-spacing: 0.1px;
}

/* Two weights only: anything heavier than medium collapses to 500. */
.brand,
.page-header h1,
.dashboard-stat dd,
.manual-stat dd,
.item-details-panel-title,
.item-preview-pop-title,
.activity-entry-summary,
.md-preview strong,
.md-preview h1,
.md-preview h2,
.md-preview h3,
.md-preview h4,
.detail-list dt,
.checkbox-label,
.status-picker-trigger,
.status-picker-option,
.sort-link,
.button-primary,
.button-secondary,
.button-danger,
.badge,
.tag-chip,
.api-docs-method,
.dashboard-stat dt {
    font-weight: 500;
}

a {
    color: var(--accent-text);
}

a:hover {
    color: var(--accent-text-hover);
}

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-control);
}

/* 0.5px borders on the major surfaces. */
.card,
.item-form,
.table-wrap,
.items-list-desktop,
.features-list-desktop,
.item-mobile-card,
.item-details-summary-card,
.item-details-panel,
.empty-state,
.modal-card,
.dashboard-stat,
.item-link-row {
    border-width: 0.5px;
}

/* ---------------------------------------------------------------------
   4. SHELL - icon nav rail + top bar
   The chat-mode branch wraps everything in #app-layout > .app-primary.
   We anchor a fixed-width icon rail on the left of .app-primary and turn
   .site-header into a compact top bar. The non-chat branch (logged out /
   AI disabled) keeps a plain top bar (no rail) - handled at the end.
   --------------------------------------------------------------------- */

/* Default (no chat dock): make room for the rail under .site-header via
   a body padding hook only when the rail is present. The rail itself is
   created from the existing #site-nav on desktop. */

.app-layout {
    /* keep dock layout owned by ai-chat-dock; we only theme our column. */
    background: var(--bg);
}

.app-primary {
    position: relative;
    min-width: 0;
}

/* ---- Top bar ---- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1200;
    background: var(--surface);
    border-bottom: 0.5px solid var(--border);
    margin-bottom: 1.25rem;
    box-shadow: none;
}

.header-inner {
    gap: 0.85rem;
    padding-block: 0.5rem;
    min-height: var(--topbar-height);
}

/* Leave space for the rail on desktop, but only when the nav rail exists
   (authenticated pages). Login / no-nav pages keep full width. */
@media (min-width: 992px) {
    .site-header:has(#site-nav) .header-inner {
        padding-left: calc(var(--rail-width) + 0.5rem);
    }
}

.brand-block {
    flex-direction: row;
    align-items: baseline;
    gap: 0.5rem;
}

.brand {
    font-size: 1.05rem;
    letter-spacing: 0.2px;
    color: var(--text);
}

.brand-user-name {
    font-weight: 400;
    color: var(--muted);
}

/* Main content gets a left gutter so it clears the rail on desktop, only
   when the rail exists (authenticated). */
@media (min-width: 992px) {
    body:has(#site-nav) #main-content {
        padding-left: calc(var(--rail-width) + var(--layout-inline-padding));
    }

    /* In the settings area the secondary sidebar docks statically beside the
       rail, so shift the header and main content past both (no overlay). */
    .site-header:has(#admin-nav-dropdown.is-admin-active) .header-inner {
        padding-left: calc(var(--rail-width) + var(--settings-width) + 0.5rem);
    }

    body:has(#admin-nav-dropdown.is-admin-active) #main-content {
        padding-left: calc(var(--rail-width) + var(--settings-width) + var(--layout-inline-padding));
    }
}

/* ---- Left icon-nav rail ----
   We re-use the existing #site-nav links on desktop, presenting them as
   a fixed vertical rail. Each link becomes an icon tile; the active one
   gets accent-subtle bg + a 3px accent left bar. The dropdown, the New
   button, change-password, sign-out and chat toggle remain in the rail
   bottom group. site-nav.js still finds every element by id, untouched. */
@media (min-width: 992px) {
    .site-nav {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1300;
        width: var(--rail-width);
        flex-direction: column;
        align-items: stretch;
        gap: 0.15rem;
        padding: calc(var(--topbar-height) + 0.4rem) 0.3rem 0.6rem;
        background: var(--surface);
        border-right: 0.5px solid var(--border);
        overflow: visible;
    }

    .site-nav > a,
    .site-nav .nav-chat-toggle,
    .site-nav .button-primary,
    .site-nav .link-button,
    .site-nav .nav-dropdown-toggle {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        margin: 0 auto;
        padding: 0;
        border: 0;
        background: transparent;
        border-radius: var(--radius-control);
        color: var(--muted);
        line-height: 1;
    }

    /* Real centered icon; the text label is kept for tooltip + a11y but
       visually hidden in the narrow rail. */
    .site-nav .nav-ico {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .site-nav .nav-ico .icon {
        width: 23px;
        height: 23px;
    }

    .site-nav .nav-label {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
        border: 0;
    }

    .site-nav > a:hover,
    .site-nav .nav-chat-toggle:hover,
    .site-nav .nav-dropdown-toggle:hover,
    .site-nav .link-button:hover {
        background: var(--surface-muted);
        color: var(--text);
        text-decoration: none;
    }

    .site-nav > a.is-active,
    .site-nav > a[aria-current="page"] {
        background: var(--accent-subtle);
        color: var(--accent-text);
    }

    .site-nav > a.is-active::after,
    .site-nav > a[aria-current="page"]::after {
        content: "";
        position: absolute;
        left: -0.3rem;
        top: 8px;
        bottom: 8px;
        width: 3px;
        border-radius: 0 2px 2px 0;
        background: var(--accent);
    }

    /* Settings (gear) lights up when its panel is open or you are on an
       admin page. */
    .site-nav .nav-dropdown.is-open .nav-dropdown-toggle,
    .site-nav .nav-dropdown.is-admin-active .nav-dropdown-toggle {
        background: var(--accent-subtle);
        color: var(--accent-text);
    }

    /* New item = accent tile in the rail. */
    .site-nav .button-primary {
        background: var(--accent);
        color: var(--on-accent);
        margin-top: 0.35rem;
    }

    .site-nav .button-primary:hover {
        background: var(--accent-hover);
        color: var(--on-accent);
    }

    .site-nav .link-button:hover {
        color: var(--danger);
    }

    /* Push the settings + bottom actions to the bottom of the rail. */
    .site-nav .nav-dropdown {
        margin-top: auto;
    }

    .site-nav .inline-form {
        display: flex;
        width: 100%;
        margin: 0;
        justify-content: center;
    }

    /* ---- Settings secondary sidebar: docks statically beside the rail while
       you are in the settings area (server adds .is-admin-active). Content is
       padded to clear it, so it reads as a docked column, not an overlay. ---- */
    #admin-nav-dropdown:not(.is-admin-active) .nav-dropdown-menu {
        display: none;
    }

    #admin-nav-dropdown.is-admin-active .nav-dropdown-menu {
        display: flex;
        position: fixed;
        top: 0;
        left: var(--rail-width);
        bottom: 0;
        height: 100vh;
        max-height: none;
        width: var(--settings-width);
        max-width: calc(100vw - var(--rail-width));
        flex-direction: column;
        gap: 0;
        margin: 0;
        padding: 0;
        background: var(--surface);
        border: 0;
        border-right: 0.5px solid var(--border);
        border-radius: 0;
        box-shadow: none;
        overflow-y: auto;
        z-index: 1290;
    }

    /* nav toggle (hamburger) is desktop-hidden already; keep it so. */
}

/* The rail occupies the left edge; the top bar's hamburger stays hidden
   on desktop (site.css handles <992 already). */

/* Base icon sizing for nav + settings (overridden per breakpoint). */
.nav-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-ico .icon {
    width: 20px;
    height: 20px;
}

/* ---- Settings secondary sidebar internals (shared desktop + mobile) ---- */
.settings-panel-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 0.9rem 0.6rem;
    background: var(--surface);
    border-bottom: 0.5px solid var(--border);
}

.settings-panel-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
}

.settings-panel-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: var(--radius-control);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.settings-panel-close:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.settings-panel-close .icon {
    width: 17px;
    height: 17px;
}

.settings-group {
    padding: 0.65rem 0.6rem 0.15rem;
}

.settings-group-label {
    margin: 0 0 0.35rem;
    padding: 0 0.35rem;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

.settings-panel .settings-card {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.55rem;
    margin-bottom: 0.2rem;
    border: 0.5px solid transparent;
    border-radius: var(--radius-control);
    color: var(--text);
    text-decoration: none;
}

.settings-panel .settings-card:hover {
    background: var(--surface-muted);
    text-decoration: none;
}

.settings-panel .settings-card.is-active {
    background: var(--accent-subtle);
    border-color: var(--accent-subtle);
}

.settings-card-ico {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-control);
    background: var(--surface-muted);
    color: var(--muted);
}

.settings-card-ico .icon {
    width: 18px;
    height: 18px;
}

.settings-panel .settings-card.is-active .settings-card-ico {
    background: var(--surface);
    color: var(--accent-text);
}

.settings-card-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.settings-card-name {
    font-weight: 500;
    line-height: 1.25;
    color: var(--text);
}

.settings-panel .settings-card.is-active .settings-card-name {
    color: var(--accent-text);
}

.settings-card-desc {
    font-size: 0.75rem;
    line-height: 1.3;
    color: var(--muted);
}

/* ---- Header project selector (top bar) ---- */
.header-project-selector {
    display: flex;
    align-items: center;
    min-width: 0;
}

.header-project-select {
    max-width: 16rem;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text);
    font-weight: 500;
    font-size: 0.85rem;
    padding: 0.3rem 1.6rem 0.3rem 0.75rem;
    line-height: 1.2;
    cursor: pointer;
    text-overflow: ellipsis;
    /* Native chevron, themed via the foreground color. */
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='1.5'><path d='M4 6l4 4 4-4'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
    background-size: 0.85rem;
}

.header-project-select:hover {
    border-color: var(--accent-line);
    color: var(--accent-text);
}

.header-project-select:focus-visible {
    outline: 2px solid var(--accent-line);
    outline-offset: 1px;
}

.header-project-select:disabled {
    opacity: 0.6;
    cursor: progress;
}

@media (max-width: 991.98px) {
    .header-project-select {
        max-width: 9rem;
    }
}

/* ---- Theme toggle (top bar pill) ---- */
.theme-toggle {
    border: 0.5px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text);
    font-weight: 500;
}

.theme-toggle:hover {
    border-color: var(--accent-line);
    color: var(--accent-text);
    background: var(--accent-subtle);
}

/* Mobile: rail collapses back to the existing stacked dropdown nav, with the
   icon shown inline beside the label. */
@media (max-width: 991.98px) {
    .header-inner {
        padding-left: var(--layout-inline-padding, 1rem);
    }

    #main-content {
        padding-left: var(--layout-inline-padding);
    }

    .site-nav > a,
    .site-nav .nav-chat-toggle,
    .site-nav .button-primary,
    .site-nav .link-button,
    .site-nav .nav-dropdown-toggle {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        font-size: 1rem;
    }

    .site-nav .nav-ico {
        flex: none;
    }

    .site-nav .nav-ico .icon {
        width: 20px;
        height: 20px;
    }

    /* On mobile the settings modules render inline within the stacked menu
       while you are in the settings area. */
    #admin-nav-dropdown.is-admin-active .nav-dropdown-menu {
        display: flex;
        position: static;
        width: 100%;
        margin-top: 0.3rem;
        border: 0.5px solid var(--border);
        border-radius: var(--radius-control);
        overflow: hidden;
    }
}

/* ---------------------------------------------------------------------
   5. BUTTONS
   --------------------------------------------------------------------- */
.button-primary,
.button-secondary,
.button-danger {
    border-radius: var(--radius-control);
    border-width: 0.5px;
    font-weight: 500;
    padding: 0.5rem 0.95rem;
    transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.button-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}

.button-primary:hover:not(:disabled):not(.is-busy) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.button-primary:active:not(:disabled):not(.is-busy) {
    background: var(--accent-active);
    border-color: var(--accent-active);
    transform: none;
}

.button-secondary {
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--text);
}

.button-secondary:hover:not(:disabled):not(.is-busy) {
    background: var(--surface-muted);
    border-color: var(--accent-line);
    color: var(--accent-text);
}

.button-secondary:active:not(:disabled):not(.is-busy) {
    background: var(--surface-muted);
    transform: none;
}

.button-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.button-danger:hover:not(:disabled):not(.is-busy) {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
}

.button-danger:active:not(:disabled):not(.is-busy) {
    transform: none;
}

/* Ghost button (additive convenience class) - transparent, accent text. */
.button-ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem;
    border: 0.5px solid transparent;
    border-radius: var(--radius-control);
    background: transparent;
    color: var(--accent-text);
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
}

.button-ghost:hover:not(:disabled):not(.is-busy) {
    background: var(--accent-subtle);
    color: var(--accent-text-hover);
    text-decoration: none;
}

.link-button {
    color: var(--accent-text);
    font-weight: 500;
}

.link-button:hover:not(:disabled):not(.is-busy) {
    color: var(--accent-text-hover);
}

.icon-button {
    border: 0.5px solid var(--border);
    border-radius: var(--radius-control);
    color: var(--text);
    background: var(--surface);
}

.icon-button:hover:not(:disabled) {
    border-color: var(--accent-line);
    color: var(--accent-text);
    background: var(--accent-subtle);
}

.icon-button-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}

.icon-button-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--on-accent);
}

/* ---------------------------------------------------------------------
   6. CARDS / PANELS / SURFACES
   --------------------------------------------------------------------- */
.card,
.item-form,
.modal-card,
.item-details-summary-card,
.item-details-panel,
.item-mobile-card,
.dashboard-stat {
    border-radius: var(--radius);
    box-shadow: none;
    background: var(--surface);
}

.callout {
    border: 0.5px solid var(--border);
    background: var(--surface-alt);
    border-radius: var(--radius-control);
}

.callout-success {
    border-color: var(--status-resolved-border);
    background: var(--status-resolved-bg);
    color: var(--status-resolved-text);
}

.callout-info {
    border-color: var(--status-open-border);
    background: var(--status-open-bg);
    color: var(--status-open-text);
}

.danger-card {
    border-color: var(--status-canceled-border);
    background: var(--status-canceled-bg);
    color: var(--status-canceled-text);
}

.empty-state {
    border-radius: var(--radius);
    border-style: dashed;
    border-width: 1px;
}

/* ---------------------------------------------------------------------
   7. INPUTS / SELECTS
   --------------------------------------------------------------------- */
.form-control {
    border: 0.5px solid var(--border-strong);
    border-radius: var(--radius-control);
    background: var(--surface);
    color: var(--text);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-line);
    box-shadow: var(--focus-ring);
}

.form-control-readonly {
    background: var(--surface-muted);
    color: var(--muted);
}

html[data-theme="dark"] .form-control {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border-strong);
}

html[data-theme="dark"] .form-control-readonly {
    background: var(--surface-alt);
}

.paste-zone {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-alt);
}

.paste-zone.drag-over,
.paste-zone:focus {
    border-color: var(--accent-line);
    background: var(--accent-subtle);
    outline: none;
}

/* ---------------------------------------------------------------------
   8. TABLES / DATA LISTS
   11px muted column headers, 0.5px row separators, quiet zebra.
   --------------------------------------------------------------------- */
.table-wrap,
.items-list-desktop,
.features-list-desktop {
    border-radius: var(--radius);
    box-shadow: none;
}

.data-table th {
    background: var(--surface-alt);
    color: var(--muted);
    font-size: 0.6875rem;          /* 11px */
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-bottom: 0.5px solid var(--border);
}

.data-table th .sort-link {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.data-table td {
    border-bottom: 0.5px solid var(--border);
}

#items-table tbody tr.item-row-striped td,
#features-table tbody tr.item-row-striped td {
    background: var(--surface-alt);
}

html[data-theme="dark"] .data-table th {
    background: var(--surface-alt);
}

html[data-theme="dark"] #items-table tbody tr.item-row-striped td,
html[data-theme="dark"] #features-table tbody tr.item-row-striped td {
    background: var(--surface-alt);
}

/* Two-line work-item row: title prominent, meta quiet. */
.items-table-title-link {
    font-weight: 500;
    color: var(--text);
}

.items-table-title-link:hover {
    color: var(--accent-text);
}

.items-table-title-link-row {
    color: var(--muted);
}

.audit-by,
.items-table-title-link-text {
    color: var(--muted);
}

/* Attachment / inline count indicator on the meta line. */
.items-attach-indicator {
    background: var(--accent-subtle);
    color: var(--accent-text);
    border-radius: 6px;
}

/* ---------------------------------------------------------------------
   9. BADGES - generic + STATUS (JS hooks) + PRIORITY + TYPE
   These class names are toggled by item-status-colors.js /
   item-status-transitions.js and emitted by Razor. DO NOT rename.
   --------------------------------------------------------------------- */
.badge {
    border-radius: var(--radius-control);
    background: var(--surface-muted);
    color: var(--text);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.15rem 0.5rem;
    line-height: 1.5;
    border: 0.5px solid transparent;
}

/* All status chips carry their own bg + text (legible on light & dark). */
.badge[class*="badge-status-"] {
    border: 0.5px solid transparent;
}

.badge-status-open       { background: var(--status-open-bg);       color: var(--status-open-text); }
.badge-status-reopen     { background: var(--status-reopen-bg);     color: var(--status-reopen-text); }
.badge-status-inprogress { background: var(--status-inprogress-bg); color: var(--status-inprogress-text); }
.badge-status-onhold     { background: var(--status-onhold-bg);     color: var(--status-onhold-text); }
.badge-status-resume     { background: var(--status-resume-bg);     color: var(--status-resume-text); }
.badge-status-futurephase{ background: var(--status-futurephase-bg);color: var(--status-futurephase-text); }
.badge-status-inspec     { background: var(--status-inspec-bg); color: var(--status-inspec-text); }
.badge-status-pendingplan{ background: var(--status-pendingplan-bg); color: var(--status-pendingplan-text); }
.badge-status-planned    { background: var(--status-planned-bg); color: var(--status-planned-text); }
.badge-status-parked     { background: var(--status-parked-bg); color: var(--status-parked-text); }
.badge-status-resolved   { background: var(--status-resolved-bg);   color: var(--status-resolved-text); }
.badge-status-canceled   { background: var(--status-canceled-bg);   color: var(--status-canceled-text); }
.badge-status-softclose  { background: var(--status-softclose-bg);  color: var(--status-softclose-text); }

/* Status swatches (status-picker dropdown) - solid accent dot. */
.status-swatch {
    border-radius: 3px;
    border: 0.5px solid rgba(0, 0, 0, 0.12);
}
.status-swatch-open        { background: var(--status-open-accent); }
.status-swatch-reopen      { background: var(--status-reopen-accent); }
.status-swatch-inprogress  { background: var(--status-inprogress-accent); }
.status-swatch-onhold      { background: var(--status-onhold-accent); }
.status-swatch-resume      { background: var(--status-resume-accent); }
.status-swatch-futurephase { background: var(--status-futurephase-accent); }
.status-swatch-inspec      { background: var(--status-inspec-accent); }
.status-swatch-pendingplan { background: var(--status-pendingplan-accent); }
.status-swatch-planned     { background: var(--status-planned-accent); }
.status-swatch-parked      { background: var(--status-parked-accent); }
.status-swatch-resolved    { background: var(--status-resolved-accent); }
.status-swatch-canceled    { background: var(--status-canceled-accent); }
.status-swatch-softclose   { background: var(--status-softclose-accent); }

/* Status picker dropdown menu surface. */
.status-picker-menu {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-control);
    box-shadow: none;
}

.status-picker-option:hover,
.status-picker-option.is-selected {
    background: var(--accent-subtle);
}

html[data-theme="dark"] .status-picker-menu {
    background: var(--surface);
    border-color: var(--border);
    box-shadow: none;
}

html[data-theme="dark"] .status-picker-option:hover,
html[data-theme="dark"] .status-picker-option.is-selected {
    background: var(--accent-subtle);
}

/* ---- Priority badges (existing JS/Razor hooks) ---- */
.badge-priority-low      { background: var(--priority-low-bg);      color: var(--priority-low-text); }
.badge-priority-medium   { background: var(--priority-medium-bg);   color: var(--priority-medium-text); }
.badge-priority-high     { background: var(--priority-high-bg);     color: var(--priority-high-text); }
.badge-priority-critical { background: var(--priority-critical-bg); color: var(--priority-critical-text); }

/* Text-forward priority with a flag glyph (additive; renders before the
   label inside any .badge-priority-* chip). */
.badge[class*="badge-priority-"]::before {
    content: "\2691";   /* flag */
    margin-right: 0.3rem;
    font-weight: 400;
    opacity: 0.9;
}

/* ---- Type badges ----
   Markup renders <span class="badge items-type-badge">Bug|Task</span>.
   We tint by the text via :has on the badge itself isn't reliable, so we
   provide (a) a sensible default for items-type-badge and (b) explicit
   convenience classes badge-type-bug / badge-type-task for static markup
   and for the Items agent to opt into. */
.items-type-badge {
    background: var(--type-task-bg);
    color: var(--type-task-text);
}

.badge-type-bug {
    background: var(--type-bug-bg);
    color: var(--type-bug-text);
}

.badge-type-bug::before {
    content: "\2638\FE0E";  /* gear-ish bug mark, text presentation */
    margin-right: 0.3rem;
    font-variant-emoji: text;
}

.badge-type-task {
    background: var(--type-task-bg);
    color: var(--type-task-text);
}

.badge-type-task::before {
    content: "\2713";   /* check */
    margin-right: 0.3rem;
    font-weight: 500;
}

/* ---------------------------------------------------------------------
   10. PILLS / TAG CHIPS / AVATARS / FILTER PILLS
   --------------------------------------------------------------------- */
.tag-chip {
    border-radius: var(--radius-pill);
    background: var(--surface-muted);
    color: var(--muted);
    font-weight: 400;
    border: 0.5px solid var(--border);
}

html[data-theme="dark"] .tag-chip {
    background: var(--surface-muted);
    color: var(--text);
    border-color: var(--border);
}

/* Saved-filter / filter pills (existing .saved-filter-chip) + additive
   .filter-pill convenience class for static markup. */
.saved-filter-chip,
.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.7rem;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
}

.saved-filter-chip:hover,
.filter-pill:hover {
    border-color: var(--accent-line);
    color: var(--accent-text);
    background: var(--accent-subtle);
}

.filter-pill.is-active,
.filter-pill[aria-pressed="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}

/* Avatar (additive convenience class). */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: var(--radius-pill);
    background: var(--accent-subtle);
    color: var(--accent-text);
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1;
    text-transform: uppercase;
    flex: 0 0 auto;
    overflow: hidden;
    border: 0.5px solid var(--border);
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-sm { width: 1.5rem; height: 1.5rem; font-size: 0.65rem; }
.avatar-lg { width: 2.5rem; height: 2.5rem; font-size: 0.95rem; }

/* ---------------------------------------------------------------------
   11. DASHBOARD TILES - flat, accent-subtle, no shadow.
   --------------------------------------------------------------------- */
.dashboard-stat {
    box-shadow: none;
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
}

.dashboard-stat dt {
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.04em;
}

.dashboard-stat dd {
    font-weight: 500;
}

.dashboard-stat-open       { background: var(--status-open-bg);       border-color: var(--status-open-border); }
.dashboard-stat-reopen     { background: var(--status-reopen-bg);     border-color: var(--status-reopen-border); }
.dashboard-stat-inprogress { background: var(--status-inprogress-bg); border-color: var(--status-inprogress-border); }
.dashboard-stat-onhold     { background: var(--status-onhold-bg);     border-color: var(--status-onhold-border); }
.dashboard-stat-resume     { background: var(--status-resume-bg);     border-color: var(--status-resume-border); }
.dashboard-stat-futurephase{ background: var(--status-futurephase-bg);border-color: var(--status-futurephase-border); }
.dashboard-stat-resolved   { background: var(--status-resolved-bg);   border-color: var(--status-resolved-border); }
.dashboard-stat-softclose  { background: var(--status-softclose-bg);  border-color: var(--status-softclose-border); }
.dashboard-stat-critical   { background: var(--priority-critical-bg); border-color: var(--status-canceled-border); }
.dashboard-stat-workable   { background: var(--status-resolved-bg);   border-color: var(--status-resolved-border); }
.dashboard-stat-pending    { background: var(--status-reopen-bg);     border-color: var(--status-reopen-border); }
.dashboard-stat-createdtoday { background: var(--status-open-bg);     border-color: var(--status-open-border); }

html[data-theme="dark"] .dashboard-stat-workable {
    background: var(--status-resolved-bg);
    border-color: var(--status-resolved-border);
}

/* ---------------------------------------------------------------------
   12. BULK BAR / MISC ACCENT SURFACES re-pointed to brand.
   --------------------------------------------------------------------- */
.bulk-actions-bar {
    background: var(--accent-subtle);
    border: 0.5px solid var(--status-open-border);
    border-radius: var(--radius);
}

.activity-timeline-user > li.activity-entry {
    background: var(--surface-alt);
    border: 0.5px solid var(--border);
    border-left: 3px solid var(--accent-line);
    border-radius: var(--radius);
    box-shadow: none;
}

.item-details-panel-accent {
    border-left: 3px solid var(--accent-line);
}

.md-preview {
    background: var(--surface-alt);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
}

.md-preview blockquote {
    border-left: 3px solid var(--accent-line);
}

.md-preview a {
    color: var(--accent-text);
}

/* Approve pill - keep semantic, align to palette. */
.approve-pill.is-approved {
    background: var(--status-resolved-bg);
    border-color: var(--status-resolved-border);
    color: var(--status-resolved-text);
}

.approve-pill.is-pending {
    background: var(--status-reopen-bg);
    border-color: var(--status-reopen-border);
    color: var(--status-reopen-text);
}

/* Modal busy overlay - theme-aware (was hard-coded white). */
html[data-theme="dark"] .modal-busy-overlay {
    background: rgba(14, 20, 27, 0.85);
}

.modal-spinner {
    border-color: var(--accent-subtle);
    border-top-color: var(--accent-line);
}

/* Skip link uses brand. */
.skip-link {
    background: var(--accent);
    color: var(--on-accent);
}

/* =====================================================================
   13. FOUNDATION POLISH LAYER (additive)
   Motion tokens + reduced-motion, focus-visible, tabular numerics,
   skeleton shimmer. Shared by the global UI modules (toast, command
   palette, shortcuts, list enhancements).
   ===================================================================== */

/* ---- (a) Motion tokens -------------------------------------------- */
:root {
    --motion-fast: 0.12s;
    --motion-base: 0.18s;
    --motion-slow: 0.28s;
    --motion-ease: cubic-bezier(0.2, 0, 0.2, 1);
    --motion-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Honour user preference: collapse interactive transitions/animations. */
@media (prefers-reduced-motion: reduce) {
    :root {
        --motion-fast: 0.01ms;
        --motion-base: 0.01ms;
        --motion-slow: 0.01ms;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---- (b) Consistent focus-visible outline ------------------------- */
/* Adds an accent outline on top of the existing focus ring (box-shadow
   from the global :focus-visible rule above) - does not clobber it. */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.settings-card:focus-visible,
.nav-item:focus-visible {
    outline: 2px solid var(--accent-line);
    outline-offset: 2px;
}

/* ---- (c) Tabular numerics ----------------------------------------- */
.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* Apply to the numeric badges / counts / effort figures already in use
   so aligned digits don't jitter as values change. */
.dashboard-stat dd,
.features-item-count-cell,
.activity-effort-hours,
.feature-filter-effort,
.features-effort-cell,
.features-effort-linked {
    font-variant-numeric: tabular-nums;
}

/* ---- (d) Skeleton shimmer utility --------------------------------- */
.skeleton {
    position: relative;
    overflow: hidden;
    background: var(--surface-muted);
    border-radius: var(--radius-control);
    color: transparent !important;
    user-select: none;
    pointer-events: none;
}

.skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.45) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: apt-skeleton-shimmer 1.25s var(--motion-ease) infinite;
}

html[data-theme="dark"] .skeleton::after {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.08) 50%,
        rgba(255, 255, 255, 0) 100%
    );
}

@keyframes apt-skeleton-shimmer {
    100% { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
    .skeleton::after {
        animation: none;
    }
}

/* =====================================================================
   14. QC FIX LAYER (additive overrides - loads last, no !important)
   Dark-mode parity, responsive reachability, hover/focus affordances
   and layout clipping fixes flagged in design QC.
   ===================================================================== */

/* ---------------------------------------------------------------------
   (1) Select2 widgets - dark mode parity.
   Pickers init with theme:"bootstrap-5" (container .select2-container--
   bootstrap-5); library renders white-on-dark otherwise. We target both
   the bootstrap-5 theme and the generic base classes (and the --default
   theme as a fallback) so dark surfaces win regardless of theme.
   Affects AI-create project picker + parent-feature picker.
   --------------------------------------------------------------------- */
html[data-theme="dark"] .select2-container .select2-selection,
html[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection,
html[data-theme="dark"] .select2-container--default .select2-selection--single,
html[data-theme="dark"] .select2-container--default .select2-selection--multiple {
    background-color: var(--surface);
    border-color: var(--border-strong);
    color: var(--text);
}

html[data-theme="dark"] .select2-container .select2-selection__rendered,
html[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection__rendered,
html[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text);
}

html[data-theme="dark"] .select2-container .select2-selection__placeholder {
    color: var(--muted);
}

html[data-theme="dark"] .select2-container--default .select2-selection__arrow b {
    border-color: var(--muted) transparent transparent transparent;
}

html[data-theme="dark"] .select2-dropdown,
html[data-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown {
    background-color: var(--surface);
    border-color: var(--border-strong);
    color: var(--text);
}

html[data-theme="dark"] .select2-results__option {
    background-color: var(--surface);
    color: var(--text);
}

html[data-theme="dark"] .select2-container--default .select2-results__option--highlighted,
html[data-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected],
html[data-theme="dark"] .select2-container--bootstrap-5 .select2-results__option--highlighted,
html[data-theme="dark"] .select2-results__option--highlighted {
    background-color: var(--accent);
    color: var(--on-accent);
}

html[data-theme="dark"] .select2-container--default .select2-results__option[aria-selected="true"],
html[data-theme="dark"] .select2-container--bootstrap-5 .select2-results__option[aria-selected="true"],
html[data-theme="dark"] .select2-results__option[aria-selected="true"] {
    background-color: var(--surface-muted);
    color: var(--text);
}

html[data-theme="dark"] .select2-search--dropdown .select2-search__field,
html[data-theme="dark"] .select2-container--bootstrap-5 .select2-search__field,
html[data-theme="dark"] .select2-search__field {
    background-color: var(--bg);
    border-color: var(--border-strong);
    color: var(--text);
}

html[data-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice,
html[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection__choice {
    background-color: var(--surface-muted);
    border-color: var(--border);
    color: var(--text);
}

/* ---------------------------------------------------------------------
   (2) Prose panels (.md-preview / .activity-md-readonly) - dark surface.
   Dashboard recent-activity, item details description, features cells.
   --------------------------------------------------------------------- */
html[data-theme="dark"] .md-preview {
    background: var(--surface-alt);
    border-color: var(--border);
    color: var(--text);
}

html[data-theme="dark"] .md-preview code {
    background: var(--surface-muted);
    color: var(--text);
}

html[data-theme="dark"] .activity-md-readonly,
html[data-theme="dark"] .feature-description-cell .md-preview {
    background: transparent;
}

/* (6) Item-details Description body text reads like a link in light mode
   (blue/teal tint); pin prose body text to the neutral text token. */
.md-preview,
.md-preview p,
.md-preview li,
.md-preview td,
.activity-md-readonly,
.activity-md-readonly p {
    color: var(--text);
}

.md-preview .muted,
.md-preview blockquote {
    color: var(--muted);
}

/* ---------------------------------------------------------------------
   (3) Modals - give the card visible separation in dark and strengthen
   the backdrop so the card lifts off the page (theme zeroed --shadow).
   --------------------------------------------------------------------- */
html[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.6);
}

html[data-theme="dark"] .modal-card {
    border-color: var(--border-strong);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55), 0 0 0 0.5px var(--border-strong);
}

/* ---------------------------------------------------------------------
   (4) Kanban / badge dark colour - keep semantic per-variant colour.
   The base 'html[data-theme=dark] .badge:not([badge-status-])' flattens
   priority/type badges to one gray; restore tinted darks (tokens already
   define dark priority/type bg + text).
   --------------------------------------------------------------------- */
html[data-theme="dark"] .badge.badge-priority-low      { background: var(--priority-low-bg);      color: var(--priority-low-text); }
html[data-theme="dark"] .badge.badge-priority-medium   { background: var(--priority-medium-bg);   color: var(--priority-medium-text); }
html[data-theme="dark"] .badge.badge-priority-high     { background: var(--priority-high-bg);     color: var(--priority-high-text); }
html[data-theme="dark"] .badge.badge-priority-critical { background: var(--priority-critical-bg); color: var(--priority-critical-text); }

html[data-theme="dark"] .badge.badge-type-bug,
html[data-theme="dark"] .badge.items-type-badge.badge-type-bug { background: var(--type-bug-bg);  color: var(--type-bug-text); }
html[data-theme="dark"] .badge.badge-type-task,
html[data-theme="dark"] .badge.items-type-badge { background: var(--type-task-bg); color: var(--type-task-text); }

/* Kanban category / approved chips: theme-aware (were hardcoded light
   #1d4ed8 / #15803d that fail on dark). */
.kanban-card-category {
    background: var(--accent-subtle);
    color: var(--accent-text);
}

.kanban-card-approved {
    background: var(--status-resolved-bg);
    color: var(--status-resolved-text);
}

html[data-theme="dark"] .kanban-card-category {
    background: var(--accent-subtle);
    color: var(--accent-text);
}

html[data-theme="dark"] .kanban-card-approved {
    background: var(--status-resolved-bg);
    color: var(--status-resolved-text);
}

/* (5) Native select.form-control - inherit dark form tokens (Dashboard
   Project/Owner filters were staying white). */
html[data-theme="dark"] select.form-control,
html[data-theme="dark"] .form-control select,
html[data-theme="dark"] select {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border-strong);
}

html[data-theme="dark"] select.form-control option,
html[data-theme="dark"] select option {
    background: var(--surface);
    color: var(--text);
}

/* ---------------------------------------------------------------------
   (17) Dashboard recent-activity badges - distinct theme-aware colours
   per variant (were near-monochrome indigo). Light + dark.
   --------------------------------------------------------------------- */
.badge-activity-created { background: var(--status-open-bg); color: var(--status-open-text); }
.badge-activity-statuschanged { background: var(--status-inprogress-bg); color: var(--status-inprogress-text); }
.badge-activity-prioritychanged { background: var(--status-reopen-bg); color: var(--status-reopen-text); }
.badge-activity-categorychanged,
.badge-activity-featurechanged { background: var(--accent-subtle); color: var(--accent-text); }
.badge-activity-ownerchanged,
.badge-activity-tagschanged { background: var(--surface-muted); color: var(--text); }
.badge-activity-approvalchanged { background: var(--status-resolved-bg); color: var(--status-resolved-text); }
.badge-activity-linkadded,
.badge-activity-testcaseadded,
.badge-activity-attachmentadded { background: var(--status-resume-bg); color: var(--status-resume-text); }
.badge-activity-linkremoved,
.badge-activity-testcaseremoved,
.badge-activity-attachmentremoved { background: var(--status-canceled-bg); color: var(--status-canceled-text); }
.badge-activity-comment { background: var(--accent-subtle); color: var(--accent-text); }
.badge-activity-deleted { background: var(--status-canceled-bg); color: var(--status-canceled-text); }
.badge-activity-bulkaction { background: var(--surface-muted); color: var(--muted); }

/* (7) Dark-mode edge-fade shadow for the shared table scroller (the
   site.css base uses rgba(0,0,0,.10) which vanishes on dark). */
html[data-theme="dark"] .table-wrap {
    background:
        linear-gradient(to right, var(--surface) 30%, transparent),
        linear-gradient(to left, var(--surface) 30%, transparent),
        linear-gradient(to right, rgba(0, 0, 0, 0.45), transparent 1.25rem),
        linear-gradient(to left, rgba(0, 0, 0, 0.45), transparent 1.25rem);
    background-color: var(--surface);
    background-repeat: no-repeat;
    background-size: 2.5rem 100%, 2.5rem 100%, 1.25rem 100%, 1.25rem 100%;
    background-position: left center, right center, left center, right center;
    background-attachment: local, local, scroll, scroll;
}

/* ---------------------------------------------------------------------
   (8) Items table card-swap breakpoint: cards must show <= ~900px (was
   720px) so the 10-col desktop table never renders at tablet widths.
   --------------------------------------------------------------------- */
@media (max-width: 900px) {
    .items-list-desktop {
        display: none;
    }

    .items-mobile-list {
        display: grid;
    }
}

/* ---------------------------------------------------------------------
   (9) Features mobile/tablet card layout (was MISSING below ~900px).
   Mirrors the Items .items-mobile-list / .item-mobile-card pattern.
   Markup agent emits .features-mobile-list + .feature-mobile-card.
   --------------------------------------------------------------------- */
.features-mobile-list {
    display: none;
    gap: 0.75rem;
    /* Single full-width column so cards never stretch to max-content and
       overflow narrow viewports (mirrors .items-mobile-list). */
    grid-template-columns: minmax(0, 1fr);
}

.feature-mobile-card {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    box-shadow: none;
    padding: 0.9rem 1rem;
}

.feature-mobile-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.feature-mobile-card-code {
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
}

.feature-mobile-card-title {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.35;
}

.feature-mobile-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem 0.75rem;
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
}

.feature-mobile-meta dt {
    margin: 0;
    color: var(--muted);
    font-weight: 500;
}

.feature-mobile-meta dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.feature-mobile-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.25rem;
}

@media (max-width: 900px) {
    #features-table,
    .features-list-desktop {
        display: none;
    }

    .features-mobile-list {
        display: grid;
    }
}

/* ---------------------------------------------------------------------
   (10) Kanban: 2-col filter grid in the 600-900px band, and cap each
   column body height so a tall column doesn't balloon the page.
   --------------------------------------------------------------------- */
@media (min-width: 600px) and (max-width: 900px) {
    .filter-grid-primary,
    .filter-grid-advanced {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.kanban-column-body {
    max-height: calc(100vh - var(--topbar-height) - 12rem);
    overflow-y: auto;
    /* Pin overflow-x explicitly: setting only overflow-y promotes overflow-x
       from visible to auto, which turned each column into a horizontal scroll
       container and clipped/offset card content. Vertical scroll only. */
    overflow-x: hidden;
}

/* ---------------------------------------------------------------------
   (11) Feature search dropdown - whole-row max-height + scroll so the
   last row is never clipped. Fix the option row height (2.5rem) and cap
   the list at an exact multiple (6 rows = 15rem).
   --------------------------------------------------------------------- */
.feature-search-option {
    box-sizing: border-box;
    min-height: 2.5rem;
    padding-block: 0.55rem;
    line-height: 1.4;
}

.feature-search-results {
    max-height: 15rem; /* 6 x 2.5rem rows */
    overflow-y: auto;
}

/* ---------------------------------------------------------------------
   (12) AI chat dock on <= 991.98px: offset below the site header so the
   expanded header/close button is reachable (was a one-way trap), and
   keep the collapsed rail button on-screen (translate the panel only).
   --------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    /* Offset the expanded dock below the sticky site header (z-index 1200,
       top:0) so its header + close button are no longer painted over -
       was a one-way trap. */
    .app-layout[data-chat-mode="expanded"] .ai-chat-dock {
        top: var(--topbar-height);
        height: calc(100vh - var(--topbar-height));
        max-height: calc(100vh - var(--topbar-height));
    }

    /* In rail (collapsed) mode the dock keeps transform: translateX(100%),
       which becomes the containing block for the fixed rail button and pushes
       it off-screen. Neutralise the transform so the rail button's own fixed
       positioning resolves against the viewport and stays reachable. */
    .app-layout[data-chat-mode="rail"] .ai-chat-dock {
        transform: none;
        width: auto;
        pointer-events: none;
    }

    .app-layout[data-chat-mode="rail"] .ai-chat-dock-rail {
        top: var(--topbar-height);
        pointer-events: auto;
    }
}

/* ---------------------------------------------------------------------
   (13) Items row controls must never overlap the WI-id / preview hit
   area. Clipping is handled in site.css; here we give the id cell +
   preview button a stacking context so they stay topmost at their spot.
   --------------------------------------------------------------------- */
#items-table .item-id-cell {
    position: relative;
    z-index: 2;
}

#items-table .item-preview {
    position: relative;
    z-index: 3;
}

/* (14) Type badge: trim padding so 'Bug'/'Task' fit the widened column
   without ellipsis. */
#items-table .items-type-badge {
    padding-inline: 0.3rem;
}

/* ---------------------------------------------------------------------
   (15) Features 'Updated by' (.audit-by) - ellipsis instead of hard cut.
   --------------------------------------------------------------------- */
.audit-by {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------------------------------------------------------------------
   (16) Hover / focus affordances.
   --------------------------------------------------------------------- */
/* Kanban card: accent border + subtle lift on hover. */
.kanban-card:hover {
    border-color: var(--accent-line);
    background: var(--accent-subtle);
}

html[data-theme="dark"] .kanban-card:hover {
    border-color: var(--accent-line);
    background: var(--surface-muted);
}

/* Dashboard metric tiles - fully clickable via stretched link + cursor. */
.dashboard-stat {
    position: relative;
}

.dashboard-stat:has(.dashboard-stat-link) {
    cursor: pointer;
}

.dashboard-stat-link {
    cursor: pointer;
}

.dashboard-stat-link::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
}

.dashboard-stat:has(.dashboard-stat-link:hover) {
    border-color: var(--accent-line);
}

/* Log rows - hover that reads clearly over each level tint + cursor.
   Box-shadow is unreliable on <tr>, so tint the cells and lift the row. */
.log-row {
    cursor: pointer;
}

.log-row:hover,
.log-row:focus-visible {
    filter: brightness(0.95);
    outline: none;
}

.log-row:hover > td,
.log-row:focus-visible > td {
    background-image: linear-gradient(color-mix(in srgb, var(--accent) 10%, transparent), color-mix(in srgb, var(--accent) 10%, transparent));
}

html[data-theme="dark"] .log-row:hover,
html[data-theme="dark"] .log-row:focus-visible {
    filter: brightness(1.18);
}

html[data-theme="dark"] .log-row:hover > td,
html[data-theme="dark"] .log-row:focus-visible > td {
    background-image: linear-gradient(color-mix(in srgb, var(--accent) 16%, transparent), color-mix(in srgb, var(--accent) 16%, transparent));
}

/* Input focus ring - clearly visible in both themes. */
.form-control:focus,
.form-control:focus-visible,
input.form-control:focus,
select.form-control:focus,
textarea.form-control:focus {
    border-color: var(--accent-line);
    box-shadow: var(--focus-ring);
    outline: none;
}

html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] select.form-control:focus,
html[data-theme="dark"] textarea.form-control:focus {
    border-color: var(--accent-line);
    box-shadow: var(--focus-ring);
}

/* ---------------------------------------------------------------------
   (17) Modal header close (X) affordance. Anchored top-right of the
   modal card; reuses each modal's existing cancel/Escape handler via
   data-modal-dismiss + the cancel button it clicks. Flat, token-driven,
   matches the .settings-panel-close affordance.
   --------------------------------------------------------------------- */
.modal-card {
    position: relative;
}

.modal-close-x {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.85rem;
    height: 1.85rem;
    padding: 0;
    border: 0.5px solid transparent;
    border-radius: var(--radius-control, 8px);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
}

.modal-close-x:hover,
.modal-close-x:focus-visible {
    border-color: var(--border);
    background: var(--surface-muted);
    color: var(--text);
    outline: none;
}

.modal-close-x:focus-visible {
    box-shadow: var(--focus-ring);
}

.modal-close-x .icon {
    width: 17px;
    height: 17px;
}

/* Keep the heading clear of the absolute X so long titles don't overlap it. */
.modal-card > .modal-close-x + h2 {
    padding-right: 2rem;
}

/* =====================================================================
   15. BRAND TYPOGRAPHY + LOGO LOCKUP (Dot.Cy brand)
   Loads after everything (and after the QC FIX LAYER) so the display /
   body font assignment wins the cascade. One system font stack for body and
   headings (spec Dot.Cy Brand Theme section 7.3); headings differ by weight only. Numeric/data stays tabular (handled
   elsewhere). Nothing here drops a font below 12px.
   ===================================================================== */
body {
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
.brand,
.brand-word,
.page-title,
.dashboard-stat dd {
    font-family: var(--font-display);
    letter-spacing: -0.02em;
}

/* ---- Logo lockup (_Brand partial) ----
   Theme-aware Dev-Tracker logo. The light variant (dark ink, for light
   backgrounds) and the dark variant (light ink, for dark backgrounds) are
   swapped via the [data-theme] attribute set on <html>. */
.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text);
}

.brand:hover,
.brand:focus-visible {
    color: var(--text);
    text-decoration: none;
}

.brand-logo {
    height: 30px;
    width: auto;
    display: block;
}

/* Light variant shows by default; the dark variant takes over under [data-theme="dark"]. */
.brand-logo-dark {
    display: none;
}

[data-theme="dark"] .brand-logo-light {
    display: none;
}

[data-theme="dark"] .brand-logo-dark {
    display: block;
}

/* The split-screen login brand panel is always the Dot.Cy orange fill, so it uses the
   larger lockup and always shows the ink-lettered (light-theme) logo there, whatever the
   active theme: light letters on orange would fail contrast (spec Dot.Cy Brand Theme D4). */
.login-brand-panel .brand-logo {
    height: 44px;
}

.login-brand-panel .brand-logo-light {
    display: block;
}

.login-brand-panel .brand-logo-dark {
    display: none;
}

/* =====================================================================
   16. FLAGSHIP - Wave 2 shared components (additive, loads last)
   ---------------------------------------------------------------------
   Calm Concept C surface kit the list + detail markup agents apply on
   top of existing structure. Nothing here renames or removes existing
   classes; new classes wrap / sit alongside current markup. Flat: only
   focus rings + a soft popout shadow (in dark) beyond the modal shadow.
   Tokens only. Sentence case. 0.5px borders. Space Grotesk for display
   lines, Inter for everything else.
   ===================================================================== */

/* ---------------------------------------------------------------------
   16.1 AVATAR - calm initials circle
   Overrides the earlier section-10 avatar so the DEFAULT look is the
   neutral muted-surface variant (calm), with .avatar-accent opting in
   to the orange tint. Sizes: base 26px, -sm 22px (list rows),
   -lg 32px (detail). These rules win over section 10 by load order.
   --------------------------------------------------------------------- */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-pill);
    background: var(--surface-muted);
    color: var(--text);
    border: 0.5px solid var(--border);
    font-family: var(--font-sans);
    font-size: 0.6875rem;       /* 11px on the 26px base */
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    text-decoration: none;
    overflow: hidden;
    user-select: none;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
}

/* List-row avatar - 22px. */
.avatar-sm {
    width: 22px;
    height: 22px;
    font-size: 0.625rem;        /* 10px */
}

/* Detail avatar - 32px. */
.avatar-lg {
    width: 32px;
    height: 32px;
    font-size: 0.8125rem;       /* 13px */
}

/* Accent-tinted opt-in (e.g. current user, owner highlight). */
.avatar-accent {
    background: var(--accent-subtle);
    color: var(--accent-text);
    border-color: var(--accent-subtle);
}

html[data-theme="dark"] .avatar-accent {
    color: var(--accent-text-hover);
}

/* Overlapping avatars (e.g. participants). The ring uses --surface so
   stacked avatars read as separated on any surface. */
.avatar-stack {
    display: inline-flex;
    align-items: center;
    flex-direction: row;
    padding-left: 0.35rem;
}

.avatar-stack > .avatar {
    margin-left: -0.35rem;
    box-shadow: 0 0 0 1.5px var(--surface);
}

.avatar-stack > .avatar:first-child {
    margin-left: 0;
}

/* Trailing "+N more" counter chip in a stack. */
.avatar-stack > .avatar-more {
    background: var(--surface-alt);
    color: var(--muted);
    font-size: 0.625rem;
}

/* ---------------------------------------------------------------------
   16.2 ROW CRAFT - title-first item rows
   Helpers the list agent applies alongside existing cell classes
   (e.g. .items-table-title-cell, .item-mobile-card-title). Strong
   primary title, quiet meta line. Row comfort + hover + focus live on
   the existing table/card rows so behaviour is preserved.
   --------------------------------------------------------------------- */
.item-row-title {
    display: block;
    font-family: var(--font-sans);
    font-size: 0.9375rem;       /* 15px */
    font-weight: 500;
    line-height: 1.35;
    color: var(--text);
    text-decoration: none;
}

.item-row-title:hover,
.item-row-title:focus-visible {
    color: var(--accent-text);
    text-decoration: none;
}

/* Quiet secondary line: code / type / tags / counts. */
.item-row-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
    margin-top: 0.2rem;
    font-family: var(--font-sans);
    font-size: 0.75rem;         /* 12px */
    font-weight: 400;
    line-height: 1.3;
    color: var(--muted);
}

/* Individual meta token + a thin dot separator the agent can drop in. */
.item-row-meta > * {
    display: inline-flex;
    align-items: center;
    min-width: 0;
}

.item-row-meta-sep {
    color: var(--border-strong);
    user-select: none;
}

/* Comfortable row height + clear hover/focus, applied additively to the
   existing desktop rows. Keeps the striped-row treatment intact. */
.data-table tbody tr.item-row-craft > td {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    vertical-align: middle;
}

.data-table tbody tr.item-row-craft:hover {
    background: var(--surface-alt);
}

.data-table tbody tr.item-row-craft:focus-within {
    box-shadow: inset 0 0 0 1.5px var(--accent-line);
    outline: none;
}

/* ---------------------------------------------------------------------
   16.3 INLINE ROW ACTIONS
   Every per-row action is rendered inline in the action bar (no overflow
   menu). The former Wave-2 kebab trigger/popout (.row-kebab*) has been
   removed; sizing for the inline cluster lives with the items list rules
   in site.css (.items-row-controls / .action-bar-inline).
   --------------------------------------------------------------------- */

/* ---------------------------------------------------------------------
   16.4 DETAIL WORKSPACE - 2-col main + meta sidebar
   The detail agent wraps the existing main panels and a meta sidebar in
   .item-detail-grid. Single column under 992px; main + ~300px sidebar
   at/above 992px. .item-meta-card styles a sidebar card with label/value
   rows (mirrors the existing .item-details-summary-card vocabulary).
   --------------------------------------------------------------------- */
.item-detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    align-items: start;
}

@media (min-width: 992px) {
    .item-detail-grid {
        grid-template-columns: minmax(0, 1fr) 300px;
        gap: 1.25rem;
    }

    /* Sidebar sticks below the topbar while the main column scrolls. */
    .item-detail-grid > .item-detail-aside {
        position: sticky;
        top: calc(var(--topbar-height) + 1rem);
    }
}

.item-detail-grid > .item-detail-main {
    min-width: 0;       /* allow inner content to shrink, no overflow */
}

.item-detail-aside {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

/* Sidebar meta card: flat surface, 0.5px border, label/value rows. */
.item-meta-card {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
}

.item-meta-card-title {
    margin: 0 0 0.6rem;
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

/* Label/value rows. Works as a <dl> or a stack of .item-meta-row. */
.item-meta-card dl,
.item-meta-rows {
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(0, 1fr);
    gap: 0.45rem 0.75rem;
    margin: 0;
}

.item-meta-row {
    display: contents;
}

.item-meta-card dt,
.item-meta-label {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--muted);
    align-self: start;
}

.item-meta-card dd,
.item-meta-value {
    margin: 0;
    min-width: 0;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text);
    word-break: break-word;
}

/* Full-width row (e.g. tag list, owner avatar+name) spans both columns. */
.item-meta-card .item-meta-row-wide,
.item-meta-card dd.item-meta-row-wide {
    grid-column: 1 / -1;
}

.item-meta-value-owner {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

/* ---------------------------------------------------------------------
   16.5 EMPTY STATE - polished, reusable across screens
   Enhances the bare .empty-state (defined earlier / in site.css) with a
   centred soft-circle icon, display title, muted subline, and a CTA row.
   .empty-state alone still renders as the dashed card; these child
   helpers light up when the agent adds the richer structure. (The list's
   .list-empty-state in list-enhancements.css keeps its own look.)
   --------------------------------------------------------------------- */
.empty-state.empty-state-flagship {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 2.5rem 1.5rem;
    border-style: solid;
    border-width: 0.5px;
    background: var(--surface);
}

.empty-state-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin-bottom: 0.25rem;
    border-radius: var(--radius-pill);
    background: var(--surface-muted);
    color: var(--muted);
}

.empty-state-icon .icon,
.empty-state-icon svg {
    width: 22px;
    height: 22px;
}

/* Accent-tinted icon variant. */
.empty-state-icon.empty-state-icon-accent {
    background: var(--accent-subtle);
    color: var(--accent-text);
}

.empty-state-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--text);
}

.empty-state-subline {
    margin: 0;
    max-width: 42ch;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--muted);
}

.empty-state-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* ---------------------------------------------------------------------
   16.6 DASHBOARD HELPERS - sparkline container + tighter KPI grouping
   Optional helpers for dashboard tiles. Flat, token-driven. The existing
   .dashboard-stat tiles keep their look; these add a sparkline slot and
   a denser KPI cluster.
   --------------------------------------------------------------------- */
.stat-spark {
    display: block;
    width: 100%;
    height: 28px;
    margin-top: 0.4rem;
    color: var(--accent-text);       /* sparkline stroke via currentColor */
    overflow: hidden;
}

.stat-spark svg,
.stat-spark canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.stat-spark-accent-2 {
    color: var(--accent-2);
}

/* Tighter KPI cluster: small label, large value, optional delta. */
.kpi-group {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.kpi-group-label {
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.kpi-group-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 500;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.kpi-group-delta {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.kpi-group-delta.is-up {
    color: var(--status-resolved-accent);
}

.kpi-group-delta.is-down {
    color: var(--status-canceled-accent);
}

/* ---------------------------------------------------------------------
   16.7 DASHBOARD POLISH - grouped KPI sections + tile/chart hierarchy
   Additive: wraps the existing .dashboard-stat-grid tiles into labelled
   visual groups, equalises tile sizing, and tightens the chart cards so
   they read calmly in both themes. Nothing here renames or removes any
   existing class, id, canvas, or data hook. Flat, token-driven.
   --------------------------------------------------------------------- */

/* Each KPI group: a quiet label + the existing stat grid underneath. */
.dashboard-kpi-section {
    margin: 0 0 1.25rem;
}

.dashboard-kpi-section-label {
    margin: 0 0 0.55rem;
}

/* The grid inside a section drops its own bottom margin (the section owns
   spacing now) so groups sit at an even rhythm. */
.dashboard-kpi-section > .dashboard-stat-grid {
    margin-bottom: 0;
}

/* Consistent tile sizing: align contents to the bottom so the big number
   sits on a shared baseline regardless of label length. */
.dashboard-kpi-section .dashboard-stat {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 4.75rem;
    gap: 0.35rem;
}

/* Labels read as quiet captions; values are the display-font hero number
   (the font itself is set in the BRAND TYPOGRAPHY block above). */
.dashboard-kpi-section .dashboard-stat dt {
    color: var(--muted);
    text-transform: uppercase;
}

.dashboard-kpi-section .dashboard-stat dd {
    font-size: 1.6rem;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

/* Plain (non-status-tinted) tiles get a calm surface so the tinted status
   tiles stand out as the meaningful signal. */
.dashboard-kpi-section .dashboard-stat:not([class*="dashboard-stat-"]) {
    background: var(--surface-alt);
}

/* Stronger hover affordance for the clickable tiles - hairline accent
   ring that works on every tinted surface and in dark mode. */
.dashboard-kpi-section .dashboard-stat:has(.dashboard-stat-link:hover) {
    border-color: var(--accent-line);
    background-image: linear-gradient(color-mix(in srgb, var(--accent) 7%, transparent), color-mix(in srgb, var(--accent) 7%, transparent));
}

html[data-theme="dark"] .dashboard-kpi-section .dashboard-stat:has(.dashboard-stat-link:hover) {
    background-image: linear-gradient(color-mix(in srgb, var(--accent) 14%, transparent), color-mix(in srgb, var(--accent) 14%, transparent));
}

/* Chart cards: flat hairline cards, even internal rhythm, calm headers. */
.dashboard-chart-card {
    border: 0.5px solid var(--border);
    box-shadow: none;
}

.dashboard-chart-card > h2,
.dashboard-chart-card-header h2 {
    font-size: 0.95rem;
    font-weight: 500;
}

/* Chart empty lines: centred, calm, consistent across every card so the
   grid never collapses to a thin row when a chart has no data. */
.dashboard-chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 8rem;
    margin: 0;
    padding: 0 1rem;
    text-align: center;
    font-size: 0.8125rem;
    line-height: 1.45;
}

/* On narrow screens collapse tiles to a tidy two-up rather than cramped
   six-up (keeps the existing 3-up / 2-up breakpoints in site.css intact;
   this only guards the new min-height from squashing). */
@media (max-width: 560px) {
    .dashboard-kpi-section .dashboard-stat {
        min-height: 4.25rem;
    }

    .dashboard-kpi-section .dashboard-stat dd {
        font-size: 1.4rem;
    }
}

/* ---------------------------------------------------------------------
   16.8 EMPTY-COLUMN HINT - kanban "drag items in" placeholder
   The placeholder markup lives in every .kanban-column-body. It is NOT a
   .kanban-card, so it never affects the card count or the drag/drop
   append logic. It only shows when the dropzone holds no cards, and the
   :has() rule hides it the instant a card lands. Flat, token-driven.
   --------------------------------------------------------------------- */
.kanban-column-empty {
    margin: 0;
    padding: 1.1rem 0.85rem;
    border: 0.5px dashed var(--border);
    border-radius: var(--radius);
    text-align: center;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--muted);
}

/* Hide the hint as soon as the column has at least one real card. */
.kanban-column-body:has(.kanban-card) .kanban-column-empty {
    display: none;
}

/* Lift the dashed prompt subtly while a card is being dragged over an
   empty column, so the drop target reads clearly. */
.kanban-column.is-drop-target .kanban-column-empty {
    border-color: var(--accent-line);
    color: var(--accent-text);
}

/* ---------------------------------------------------------------------
   17. ITEM LIST WIRING (Wave 2 craft applied to Views/Items/Index)
   Additive glue between the Wave 2 vocabulary (section 16) and the
   existing item-list markup. No overrides of existing behaviour; only
   the new wrappers introduced by the list agent are styled here.
   --------------------------------------------------------------------- */

/* Owner cell: avatar + the existing inline owner <select> form sit on one
   calm row. The form/select keep all their behaviour; the avatar is purely
   presentational and derives initials from the owner display name. */
.item-owner-cell {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}

.item-owner-cell .inline-form {
    min-width: 0;
}

/* Unassigned placeholder reads as a quiet, empty seat. */
.item-owner-avatar-empty {
    color: var(--muted);
    background: var(--surface-alt);
    border-style: dashed;
}

/* Mobile owner label pairs the avatar with the "Owner" caption. */
.item-mobile-owner-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

/* Meta-line tokens introduced on the title cell / mobile card: attachment
   count and the relocated inline-links list. They inherit the quiet
   .item-row-meta type; these rules just keep icons + chips aligned. */
.item-row-meta-attach {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    white-space: nowrap;
}

.item-row-meta-attach .icon,
.item-row-meta-attach svg {
    width: 13px;
    height: 13px;
}

/* The links partial brings its own block layout; inside the quiet meta line
   keep it inline and compact so it reads as one row of metadata. */
.item-row-meta-links {
    min-width: 0;
}

.item-row-meta-links .items-table-title-links {
    margin: 0;
}

/* Craft action bar: all per-row actions are visible inline. Keep the cluster
   tight in the controls column; it wraps to a second line before it would ever
   overflow the column or overlap the ID / title cells. Stateful tints for the
   approval + favorite buttons are preserved here so the inline icons read the
   same as they did in the former menu. */
.action-bar-craft {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
}

.action-bar-inline {
    flex-wrap: wrap;
}

.action-bar-inline .item-approval-button.is-approved {
    color: var(--status-resolved-accent);
}

.action-bar-inline .item-favorite-button.is-favorite {
    color: var(--accent-2);
}

/* =====================================================================
   17. ITEM DETAIL WORKSPACE (additive, loads last)
   ---------------------------------------------------------------------
   Detail-specific polish applied on top of the shared FLAGSHIP kit
   (section 16) and the existing .item-details-* structure. Nothing here
   renames or removes existing classes; new classes wrap / sit alongside
   the current markup. Flat: focus rings only. Tokens only. 0.5px borders.
   Sentence case. Space Grotesk for display lines, Inter for body.
   ===================================================================== */

/* ---------------------------------------------------------------------
   17.1 DELETE ICON BUTTON - resting danger affordance
   The detail header keeps the existing .icon-button.icon-button-danger
   delete control. Earlier rules only tint it on hover; give it a calm
   resting danger border + faint tint so it reads as destructive at rest
   without shouting. Hover/focus deepen it.
   --------------------------------------------------------------------- */
.icon-button.icon-button-danger {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 38%, var(--border));
    background: color-mix(in srgb, var(--danger) 6%, var(--surface));
}

.icon-button.icon-button-danger:hover:not(:disabled),
.icon-button.icon-button-danger:focus-visible {
    color: var(--on-accent);
    background: var(--danger);
    border-color: var(--danger);
}

html[data-theme="dark"] .icon-button.icon-button-danger {
    background: color-mix(in srgb, var(--danger) 16%, var(--bg));
    border-color: color-mix(in srgb, var(--danger) 50%, var(--border-strong));
}

/* ---------------------------------------------------------------------
   17.2 STRONG HEADER - identity stack + owner avatar block
   .item-detail-header-flagship wraps the existing .page-header markup.
   Code (quiet, tabular) sits above a Space Grotesk title; chips and the
   owner avatar line sit below. Action buttons keep their existing column.
   --------------------------------------------------------------------- */
.item-detail-header-identity .item-details-id {
    margin: 0 0 0.15rem;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
}

.item-detail-header-flagship h1 {
    font-family: var(--font-display);
    letter-spacing: -0.015em;
    line-height: 1.2;
}

.item-detail-header-identity .item-details-badges {
    margin-top: 0.55rem;
}

.item-detail-header-owner {
    margin-top: 0.7rem;
}

.item-detail-header-owner-text {
    display: inline-flex;
    flex-direction: column;
    gap: 0.05rem;
    line-height: 1.2;
}

.item-detail-header-owner-label {
    font-size: 0.6875rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.item-detail-header-owner-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

/* ---------------------------------------------------------------------
   17.3 META SIDEBAR - card + nested read-only panels
   The aside hosts the .item-meta-card plus a couple of read-only
   <details> panels (AI processing, effort) and optional linked / similar
   cards. Tighten their rhythm so they read as a quiet column.
   --------------------------------------------------------------------- */
.item-detail-meta-card .item-meta-value .badge,
.item-detail-meta-card .item-meta-value .approve-pill {
    vertical-align: middle;
}

.item-detail-aside-panel > .item-details-panel-body {
    padding-top: 0.5rem;
}

.item-detail-aside .item-links-readonly-list,
.item-detail-aside .similar-items-list {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.8125rem;
}

.item-detail-aside .item-links-readonly-list li,
.item-detail-aside .similar-items-list li {
    margin-bottom: 0.4rem;
    line-height: 1.4;
}

/* ---------------------------------------------------------------------
   17.4 ACTIVITY FEED - avatar gutter + clean entries
   _ActivityThreadEntry now renders an .activity-feed-avatar in a left
   gutter with an .activity-feed-body beside it. We keep the existing
   .activity-entry surface (section 12) and lay an avatar + body grid on
   top. Reply / edit / delete / question hooks are untouched.
   --------------------------------------------------------------------- */
.activity-feed.activity-timeline-user {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Avatar gutter on every feed entry (top-level + nested replies). Padding,
   surface, and the reply indent stay with the existing card / reply rules
   so nothing the base stylesheet sets is clobbered. */
.activity-entry.activity-feed-entry {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0 0.7rem;
    align-items: start;
}

.activity-feed-avatar {
    grid-column: 1;
    grid-row: 1;
    margin-top: 0.1rem;
}

.activity-feed-body {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
}

/* Nested replies span both columns so they sit below the body; the base
   .activity-replies rule keeps its indent + left border. */
.activity-feed-entry > .activity-replies {
    grid-column: 1 / -1;
    grid-row: 2;
}

.activity-feed-body .activity-entry-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

.activity-feed-body .activity-entry-summary {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.35;
}

.activity-feed-body .activity-entry-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.6rem;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--muted);
}

.activity-feed-body .activity-entry-actor {
    font-weight: 500;
    color: var(--text);
}

.activity-feed-body .activity-time {
    color: var(--muted);
    cursor: default;
}

/* The reply badge stays compact and quiet inside the heading line. */
.activity-feed-body .activity-reply-badge {
    align-self: center;
}

/* ---------------------------------------------------------------------
   17.5 EMPTY STATES - flagship empty cards inside main-column panels
   Activity / test cases / attachments panels render the shared
   .empty-state.empty-state-flagship structure. Keep them flush inside
   the panel body so they don't read as a card-in-a-card.
   --------------------------------------------------------------------- */
.item-details-panel-body > .empty-state-flagship {
    margin: 0;
    padding: 2rem 1.25rem;
}

/* =====================================================================
   18. WORK ITEM FORM (Create / Edit, shared via _FormFields)
   A sectioned two-pane workspace. The outer <form class="item-form">
   chrome is neutralized so the inner .wi-section cards carry the surface
   treatment. Every original field / id / hook is preserved; this layer
   only governs grouping, spacing, and the action bar.
   ===================================================================== */

/* Neutralize the form's own card chrome - sections become the cards. */
.item-form:has(.wi-form-layout) {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
}

/* Only show the red summary box when there are real errors. The asp-validation-summary
   tag helper always renders an inner <ul> placeholder, so the div is never :empty -
   keying off the .validation-summary-errors class (added only when errors exist) avoids
   a permanent empty red box on every form. */
.wi-validation-summary.validation-summary-errors {
    border: 0.5px solid var(--status-canceled-border);
    background: var(--status-canceled-bg);
    color: var(--status-canceled-text);
    border-radius: var(--radius-control);
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
}

/* Two-pane grid: roomy main column + fixed-feel meta sidebar. */
.wi-form-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 1.25rem;
    align-items: start;
}

.wi-main,
.wi-meta {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0;
}

.wi-meta {
    position: sticky;
    top: calc(var(--topbar-height) + 1rem);
}

/* Section cards - flat, 0.5px borders, token surface. */
.wi-section {
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: none;
}

html[data-theme="dark"] .wi-section {
    background: var(--surface);
    border-color: var(--border);
}

.wi-section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    margin-bottom: 1rem;
}

.wi-section-head h2 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--text);
}

.wi-section-head h3 {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 500;
    margin: 0 0 0.5rem;
    color: var(--text);
}

.wi-section-hint {
    margin: 0;
    font-size: 0.85rem;
    flex-basis: 100%;
}

/* Section body stacks fields in a single readable column. .span-2 is a
   no-op here (single column), so the original markup is honoured. */
.wi-section-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.wi-section-body > .form-grid {
    margin: 0;
}

/* Title gets prominence. */
.wi-title-input {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    padding: 0.7rem 0.85rem;
}

/* Overview: title spans full width, type sits beneath at intrinsic width. */
.wi-overview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Read-only project context row in the sidebar. */
.wi-readonly-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted);
}

.wi-project-value {
    margin: 0;
    font-weight: 500;
    color: var(--text);
    background: var(--surface-alt);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-control);
    padding: 0.5rem 0.7rem;
}

/* Attachment panel re-cast as a section card: drop the legacy top rule. */
.wi-section.attachment-panel {
    margin-top: 0;
    padding-top: 1.25rem;
    border-top: 0.5px solid var(--border);
}

/* Collapsible "More context" group. */
.wi-more-context {
    padding: 0;
    overflow: hidden;
}

.wi-more-context > .wi-section-body {
    padding: 0 1.25rem 1.25rem;
}

.wi-more-summary {
    list-style: none;
    cursor: pointer;
    margin: 0;
    padding: 1.25rem;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    user-select: none;
}

.wi-more-summary::-webkit-details-marker {
    display: none;
}

.wi-more-summary:hover h2 {
    color: var(--accent-text);
}

.wi-more-chevron {
    width: 0.5rem;
    height: 0.5rem;
    border-right: 1.5px solid var(--muted);
    border-bottom: 1.5px solid var(--muted);
    transform: rotate(45deg);
    transition: transform 0.15s ease;
    flex: 0 0 auto;
    margin-right: 0.15rem;
}

.wi-more-context[open] .wi-more-chevron {
    transform: rotate(-135deg);
}

.wi-more-summary:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius);
}

/* Action bar: sticky footer, brand-forward primary, AI affordance left. */
.item-form:has(.wi-form-layout) .form-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin-top: 1.25rem;
    padding: 0.85rem 1.1rem;
    background: var(--surface);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    align-items: center;
    gap: 0.6rem;
}

.item-form:has(.wi-form-layout) .form-actions #ai-enhance-button {
    margin-right: auto;
}

/* Make the markdown editors feel roomy in the main column. */
.wi-main .EasyMDEContainer {
    border-radius: var(--radius-control);
}

/* ---------------------------------------------------------------------
   18.1 WORK ITEM FORM - responsive collapse to a single column
   --------------------------------------------------------------------- */
@media (max-width: 1080px) {
    .wi-form-layout {
        grid-template-columns: 1fr;
    }

    .wi-meta {
        position: static;
        top: auto;
    }
}

@media (max-width: 720px) {
    .wi-overview-grid {
        grid-template-columns: 1fr;
    }

    .wi-section {
        padding: 1rem;
    }

    .wi-more-summary {
        padding: 1rem;
    }

    .wi-more-context > .wi-section-body {
        padding: 0 1rem 1rem;
    }

    .item-form:has(.wi-form-layout) .form-actions {
        flex-wrap: wrap;
    }

    .item-form:has(.wi-form-layout) .form-actions #ai-enhance-button {
        margin-right: 0;
        flex: 1 1 100%;
        justify-content: center;
    }
}

/* ---------------------------------------------------------------------
   18. DASHBOARD VIEWS - named dashboards + switcher
   Three named dashboards (Overview / Delivery / Quality) sit behind a
   segmented tab control. Every panel reuses the existing dashboard tile
   and chart-card vocabulary; only the switcher chrome, the panel show/
   hide, and the two new panel-specific layouts are defined here. Flat,
   token-driven, sentence case, themed for light and dark by inheriting
   the same tokens the rest of the dashboard reads.
   --------------------------------------------------------------------- */

/* Segmented tab control: a single hairline-bordered pill row. The active
   tab gets the orange accent fill so the current view reads instantly. */
.dashboard-switcher {
    display: inline-flex;
    align-items: stretch;
    gap: 0.25rem;
    margin: 0 0 1.25rem;
    padding: 0.25rem;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface-alt);
}

.dashboard-switcher-tab {
    appearance: none;
    border: 0;
    margin: 0;
    padding: 0.4rem 1.1rem;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--muted);
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    line-height: 1.2;
    cursor: pointer;
    transition: color 0.12s ease, background-color 0.12s ease;
}

.dashboard-switcher-tab:hover {
    color: var(--text);
}

.dashboard-switcher-tab.is-active {
    background: var(--accent);
    color: var(--on-accent);
}

.dashboard-switcher-tab:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Hidden panels collapse entirely; the [hidden] attribute also keeps the
   off-screen canvases from being measured before their panel is shown. */
.dashboard-panel[hidden] {
    display: none;
}

/* OVERVIEW: status doughnut beside the recent-activity feed. The chart is
   the focal column; the activity feed flows to its right and scrolls. */
.dashboard-overview-grid {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.dashboard-overview-grid .dashboard-chart-card-distribution .dashboard-chart-wrap {
    height: 18rem;
}

.dashboard-activity-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.dashboard-activity-card > h2 {
    font-size: 0.95rem;
    font-weight: 500;
    margin: 0 0 0.75rem;
}

.dashboard-activity-card .dashboard-activity-timeline {
    margin: 0;
    max-height: 24rem;
    overflow-y: auto;
}

/* DELIVERY: the created-vs-resolved flow chart leads on a wider column,
   the owner workload sits beside it. */
.dashboard-trends-grid-delivery {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
}

.dashboard-trends-grid-delivery .dashboard-chart-card-flow .dashboard-chart-wrap {
    height: 15rem;
}

/* The aging-open tile borrows the quiet ink accent to read as a watch metric
   without alarming like the critical (red) tile. */
.dashboard-kpi-section .dashboard-stat-aging dd {
    color: var(--accent-2-hover);
}

/* QUALITY: an even three-up of bug lenses (type, priority, category). */
.dashboard-charts-grid-quality {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1080px) {
    .dashboard-overview-grid,
    .dashboard-trends-grid-delivery {
        grid-template-columns: 1fr;
    }

    .dashboard-charts-grid-quality {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-activity-card .dashboard-activity-timeline {
        max-height: none;
    }
}

@media (max-width: 640px) {
    .dashboard-switcher {
        display: flex;
        width: 100%;
    }

    .dashboard-switcher-tab {
        flex: 1 1 0;
        padding: 0.45rem 0.5rem;
        text-align: center;
    }

    .dashboard-charts-grid-quality {
        grid-template-columns: 1fr;
    }
}

/* =====================================================================
   ACTIVITY HISTORY MODAL - Outlook-style vertical split
   ---------------------------------------------------------------------
   Loaded after site.css, so these win over the activity-browser-* rules
   in site.css. The modal card is a fixed-height flex column: a fixed
   header, a fixed ribbon (toolbar), then a flex body. The body itself
   never scrolls - only the list pane (top, larger share) and the detail
   preview pane (bottom) scroll, giving exactly one scroll region each
   and none on the card. Dot.Cy tokens, the system font on headings,
   flat surfaces, 0.5px borders, sentence case. Light + dark.
   ===================================================================== */

/* Card: fixed-height flex column. No outer scroll - the body flexes and
   only the two inner panes scroll. */
.activity-browser-modal-card {
    display: flex;
    flex-direction: column;
    width: min(96vw, 1500px);
    height: min(92vh, 1100px);
    max-height: calc(100vh - 1.5rem);
    overflow: hidden;
    border: 0.5px solid var(--border);
    box-shadow: var(--shadow);
}

/* Header (fixed). Compact so the panes - especially the preview - get height. */
.activity-browser-modal-header {
    flex: 0 0 auto;
    margin-bottom: 0;
    padding: 0 0 0.45rem;
    border-bottom: 0.5px solid var(--border);
}

.activity-browser-modal-heading h2 {
    font-family: var(--font-display);
    font-weight: 500;
}

/* The work-item code in the subtitle is now the link to the item
   (replacing the removed "Open item" button). */
.activity-browser-subtitle-link {
    font-weight: 500;
    color: var(--accent-text);
    text-decoration: none;
}

.activity-browser-subtitle-link:hover,
.activity-browser-subtitle-link:focus-visible {
    color: var(--accent-text-hover);
    text-decoration: underline;
}

.activity-browser-subtitle-sep {
    color: var(--text-muted);
}

/* Ribbon / toolbar (fixed) under the header. */
.activity-browser-header-toolbar {
    flex: 0 0 auto;
    margin: 0.4rem 0;
    padding: 0.4rem 0.7rem;
    background: var(--surface-alt);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-control);
}

.activity-browser-toolbar-label {
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.activity-browser-result-count {
    color: var(--text-muted);
}

/* Body (flex:1, min-height:0). Must NOT scroll - it only hosts the
   split, which carries the two scrolling panes. */
.activity-browser-modal-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding-right: 0;
}

/* Split fills the body; remove the site.css min-height that fought the
   fixed card height. */
.activity-browser-split {
    flex: 1 1 auto;
    min-height: 0;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-control);
    overflow: hidden;
    background: var(--surface);
}

/* Two stacked panes: the preview (detail) gets the larger share (~60%) so the
   reading area is roomy; the activity list takes the rest, with a clear divider
   between them. */
.activity-browser-panels {
    display: grid;
    grid-template-rows: minmax(0, 40fr) minmax(0, 60fr);
    grid-template-columns: 1fr;
    min-height: 0;
    height: 100%;
}

.activity-browser-list-pane {
    border-bottom: 0.5px solid var(--border-strong);
    background: var(--surface);
}

.activity-browser-detail-pane {
    background: var(--surface-alt);
}

/* Pane headers: quiet, sentence case, display face. Compact to give panes height. */
.activity-browser-pane-header {
    padding: 0.3rem 0.9rem;
    border-bottom: 0.5px solid var(--border);
    background: var(--surface-alt);
}

.activity-browser-pane-header h3 {
    font-family: var(--font-display);
    font-weight: 500;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.8rem;
}

/* The only two scroll regions inside the body. */
.activity-browser-list-scroll,
.activity-browser-detail-scroll {
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    overscroll-behavior: contain;
}

/* Sub-surfaces keep 0.5px separators in both themes. */
.activity-browser-table-head-wrap {
    border-bottom: 0.5px solid var(--border);
    background: var(--surface-alt);
}

.activity-browser-detail-pane .activity-browser-detail-header h4 {
    font-family: var(--font-display);
    font-weight: 500;
}

/* Created (work item) row stays tinted via accent-2, the quiet ink highlight. */
.activity-browser-created-row-wrap {
    border-top: 0.5px solid var(--accent-2);
    background: var(--accent-2-subtle);
}

.activity-browser-row-created {
    background: var(--accent-2-subtle) !important;
}

/* The summary cell is a one-line inline preview; strip the block .md-preview
   padding (set later in the cascade) so activity rows stay short. */
.activity-browser-summary-preview {
    padding: 0;
}

/* Narrow screens: the 5-column fixed-width activity table cannot fit the card
   and was being clipped. Drop the separate sort header, re-flow each row as a
   flex line (summary fills + ellipsizes, actions beside it), and hide the
   secondary When / Type / From columns. Full detail of the selected activity
   shows in the preview pane below. */
@media (max-width: 600px) {
    .activity-browser-table-head-wrap {
        display: none;
    }

    .activity-browser-table,
    .activity-browser-table tbody {
        display: block;
    }

    .activity-browser-table tr {
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .activity-browser-table td {
        display: block;
    }

    /* Higher specificity than `.activity-browser-table td` above so these
       secondary columns are actually hidden (not re-shown as blocks). */
    .activity-browser-table td.activity-browser-when,
    .activity-browser-table td.activity-browser-type,
    .activity-browser-table td.activity-browser-from {
        display: none;
    }

    .activity-browser-summary {
        flex: 1 1 auto;
        min-width: 0;
    }

    .activity-browser-actions {
        flex: 0 0 auto;
    }
}

.activity-browser-row-created:hover {
    background: color-mix(in srgb, var(--accent-2) 18%, var(--surface)) !important;
}

.activity-browser-row-created.is-selected {
    background: color-mix(in srgb, var(--accent-2) 26%, var(--surface)) !important;
}

.activity-browser-item-snapshot .activity-browser-detail-header h4 {
    color: var(--accent-2-hover);
}

/* Selection / hover use the orange accent. */
.activity-browser-row:hover {
    background: var(--accent-subtle);
}

.activity-browser-row.is-selected {
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

@media (max-width: 720px) {
    .activity-browser-modal-card {
        width: calc(100vw - 1rem);
        height: calc(100vh - 1rem);
    }
}
