/* ============================================================
   SpendVision admin console

   Implements the pinned brand system in DESIGN.md — warm cream
   canvas, deep coffee ink, ONE saturated orange accent, Inter
   doing two jobs by weight, 12px radius on every card and button,
   and depth from cream-on-cream surface contrast rather than
   shadows.

   Two deliberate additions to the token ladder, both darker steps
   of hues the system already owns (not new accents):

     --primary-deep (#c93d00)  brand orange is 3.27:1 on cream —
                               fine for marks and display type, but
                               below AA for small text. Small orange
                               text uses this 5.02:1 step instead.
     small metadata text uses  --body (#605d52, 6.54:1) rather than
                               --body-mid (#939084, 3.17:1), which
                               is kept for large/decorative labels.

   The console has no dark mode: the brand is explicitly a warm
   cream canvas, and DESIGN.md defines no dark surfaces to derive
   one from.
   ============================================================ */

/* ---------- Self-hosted type (mirrors the landing page) ---------- */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/fonts/inter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/fonts/inter-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ============================================================
   Tokens
   ============================================================ */
.admin {
    /* Surface & ink — DESIGN.md Colors */
    --canvas: #fffefb;
    --canvas-soft: #f8f4f0;
    --ink: #201515;
    --ink-soft: #2f2a26;
    --ink-mid: #36342e;
    --body: #605d52;
    --body-mid: #939084;
    --mute: #c5c0b1;
    --primary: #ff4f00;
    --primary-hover: #e64700;
    --primary-deep: #c93d00; /* AA-safe orange for small text */
    --on-primary: #fffefb;

    /* Hairlines derived from ink so every border keeps the warm temperature. */
    --hairline: rgba(32, 21, 21, 0.10);
    --hairline-strong: rgba(32, 21, 21, 0.18);
    --primary-tint: rgba(255, 79, 0, 0.09);
    --primary-edge: rgba(255, 79, 0, 0.26);

    --font: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

    /* Type scale — DESIGN.md Typography > Hierarchy */
    --fs-micro: 12px;
    --fs-caption: 14px;
    --fs-body-sm: 16px;
    --fs-body-md: 18px;
    --fs-body-lg: 20px;
    --fs-display-sub-sm: 24px;
    --fs-display-md: 32px;

    /* Spacing — 4px base */
    --sp-xxs: 2px;
    --sp-xs: 4px;
    --sp-sm: 8px;
    --sp-md: 12px;
    --sp-lg: 16px;
    --sp-xl: 24px;
    --sp-2xl: 32px;
    --sp-3xl: 48px;
    --sp-4xl: 64px;

    /* Shape — one radius family: 12px cards/buttons, 6px small shapes, pill for badges */
    --r-sm: 6px;
    --r-md: 12px;
    --r-pill: 9999px;

    --sidebar-w: 264px;
    --topbar-h: 68px;

    font-family: var(--font);
    color: var(--ink);
    background: var(--canvas);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

/* Every figure in the console aligns in its column. */
.admin .mono,
.admin .a-stat-value,
.admin .a-table td,
.admin .a-money,
.admin time {
    font-variant-numeric: tabular-nums;
}

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

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

.admin ::selection {
    background: var(--primary);
    color: var(--on-primary);
}

/* Focus rings belong on things you can actually operate. Scoped to interactive
   elements rather than a bare `*:focus-visible`, because Routes.razor's
   <FocusOnNavigate Selector="h1" /> focuses the page heading on every navigation
   so screen readers announce it — and Blazor stamps tabindex="-1" on the heading
   to make that possible. A blanket rule painted an orange ring around the <h1>
   of every page, which reads as a rendering bug rather than an affordance.

   Text inputs and selects are absent on purpose: .a-input:focus / .a-select:focus
   already give them an orange border plus a tint shadow, so an outline on top
   would be a third concentric ring. Checkboxes have no such treatment, so they
   keep the outline. */
.admin a:focus-visible,
.admin button:focus-visible,
.admin summary:focus-visible,
.admin [role="button"]:focus-visible,
.admin [contenteditable]:focus-visible,
.admin input[type="checkbox"]:focus-visible,
.admin input[type="radio"]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

/* Belt and braces: the programmatic heading focus is for assistive tech only and
   must never show a ring, whatever else matches later. */
.admin h1:focus,
.admin h1:focus-visible,
.admin [tabindex="-1"]:focus,
.admin [tabindex="-1"]:focus-visible {
    outline: none;
}

.admin-boot {
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
    color: #605d52;
    padding: 64px;
    text-align: center;
}

/* ============================================================
   Shell: dark ink sidebar + cream content
   ------------------------------------------------------------
   The sidebar uses --ink-soft, which DESIGN.md designates for
   "dark-fill surfaces". It gives the console a spine of its own
   and makes the cream working area read as the bright focus.
   ============================================================ */
.a-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.a-side {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--ink-soft);
    color: var(--canvas-soft);
    padding: var(--sp-xl) var(--sp-lg);
    overflow-y: auto;
}

.a-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 var(--sp-sm) var(--sp-xl);
}

.a-brand-logo {
    width: 30px;
    height: 30px;
    border-radius: var(--r-sm);
    flex: none;
}

.a-brand-name {
    font-size: var(--fs-body-md);
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--canvas);
}

.a-brand-name .accent {
    color: var(--primary);
}

.a-brand-tag {
    display: block;
    font-size: var(--fs-micro);
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--body-mid);
    margin-top: 1px;
}

.a-nav {
    display: flex;
    flex-direction: column;
    gap: var(--sp-xxs);
}

.a-nav-group {
    font-size: var(--fs-micro);
    font-weight: 700;
    letter-spacing: 0.9px;
    text-transform: uppercase;
    color: var(--mute);
    padding: var(--sp-lg) var(--sp-sm) var(--sp-sm);
}

.a-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px var(--sp-sm);
    border-radius: var(--r-sm);
    font-size: var(--fs-body-sm);
    font-weight: 500;
    color: var(--mute);
    transition: background 140ms ease, color 140ms ease;
}

.a-nav-link svg {
    width: 18px;
    height: 18px;
    flex: none;
    opacity: 0.85;
}

.a-nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--canvas);
}

/* Active nav: the accent appears as MARKS (the icon and a left rule) while the
   label itself stays cream. Brand orange measures 4.30:1 against this dark
   surface — fine for a mark, below AA for 16px text — so the text never carries
   it. Four signals say "you are here": rule, icon colour, tint, weight. */
.a-nav-link.active {
    position: relative;
    background: rgba(255, 79, 0, 0.14);
    color: var(--canvas);
    font-weight: 600;
}

.a-nav-link.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    border-radius: var(--r-pill);
    background: var(--primary);
}

.a-nav-link.active svg {
    opacity: 1;
    color: var(--primary);
}

.a-side-foot {
    margin-top: auto;
    padding-top: var(--sp-xl);
}

.a-side-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px var(--sp-sm);
    border-radius: var(--r-sm);
    background: rgba(255, 255, 255, 0.05);
}

.a-side-user-meta {
    min-width: 0;
    flex: 1;
}

.a-side-user-name {
    display: block;
    font-size: var(--fs-caption);
    font-weight: 600;
    color: var(--canvas);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.a-side-user-role {
    display: block;
    font-size: var(--fs-micro);
    color: var(--body-mid);
}

/* Sits inside the user row as a compact icon button, not a full-width bar.
   Signing out is the least-used control in the console, so it gets the least
   visual weight — no border, no fill, no label taking a row of its own. The
   label lives in title/aria-label instead. */
.a-signout {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex: none;
    padding: 0;
    border: none;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--mute);
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease;
}

.a-signout svg {
    width: 16px;
    height: 16px;
}

.a-signout:hover {
    background: rgba(255, 255, 255, 0.10);
    color: var(--canvas);
}

/* ---------- Main column ---------- */
.a-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.a-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: var(--sp-lg);
    padding: var(--sp-md) var(--sp-2xl);
    background: rgba(255, 254, 251, 0.86);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--hairline);
}

.a-topbar-titles {
    min-width: 0;
    flex: 1;
}

.a-eyebrow {
    display: block;
    font-size: var(--fs-caption);
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--body);
    margin-bottom: 3px;
}

.a-page-title {
    margin: 0;
    font-size: var(--fs-display-sub-sm);
    font-weight: 600;
    letter-spacing: -0.6px;
    line-height: 1.2;
    color: var(--ink);
}

.a-topbar-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    flex: none;
}

.a-content {
    padding: var(--sp-xl) var(--sp-2xl) var(--sp-4xl);
    max-width: 1440px;
    width: 100%;
}

.a-lede {
    max-width: 68ch;
    margin: 0 0 var(--sp-xl);
    font-size: var(--fs-body-sm);
    color: var(--body);
}

/* Mobile nav toggle — hidden until the sidebar collapses. */
.a-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex: none;
    border: 1px solid var(--hairline-strong);
    border-radius: var(--r-sm);
    background: var(--canvas);
    color: var(--ink);
    cursor: pointer;
}

.a-nav-toggle svg {
    width: 20px;
    height: 20px;
}

/* ============================================================
   Cards & sections
   ============================================================ */
.a-card {
    background: var(--canvas-soft);
    border-radius: var(--r-md);
    padding: var(--sp-xl);
}

/* Hairline variant — Level 1 depth, for things that need an edge
   rather than a fill (forms over a cream section, pricing chrome). */
.a-card-outline {
    background: var(--canvas);
    border: 1px solid var(--hairline-strong);
}

.a-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-lg);
    margin-bottom: var(--sp-lg);
}

.a-card-title {
    margin: 0;
    font-size: var(--fs-body-md);
    font-weight: 600;
    letter-spacing: -0.3px;
}

.a-card-sub {
    margin: 3px 0 0;
    font-size: var(--fs-caption);
    color: var(--body);
}

.a-section {
    margin-bottom: var(--sp-xl);
}

.a-grid {
    display: grid;
    gap: var(--sp-lg);
}

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

/* Charts get more room than the side panel beside them. */
.a-grid-split {
    grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
}

/* ============================================================
   Stat tiles
   ------------------------------------------------------------
   A headline figure is not a chart: it's a hero number with a
   label and, where a comparison exists, one delta line.
   ============================================================ */
.a-stat {
    background: var(--canvas-soft);
    border-radius: var(--r-md);
    padding: var(--sp-lg) var(--sp-xl);
    display: flex;
    flex-direction: column;
    gap: var(--sp-sm);
    min-width: 0;
}

.a-stat-top {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
}

.a-stat-icon {
    width: 30px;
    height: 30px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: var(--r-pill);
    background: rgba(32, 21, 21, 0.06);
    color: var(--ink-mid);
}

.a-stat-icon svg {
    width: 15px;
    height: 15px;
}

/* One tile per screen may carry the accent — the figure that matters most. */
.a-stat-accent .a-stat-icon {
    background: var(--primary-tint);
    color: var(--primary-deep);
}

.a-stat-label {
    font-size: var(--fs-caption);
    font-weight: 500;
    color: var(--body);
    min-width: 0;
}

.a-stat-value {
    font-size: var(--fs-display-md);
    font-weight: 500;
    line-height: 1.05;
    letter-spacing: -0.5px;
    color: var(--ink);
}

.a-stat-value .a-unit {
    font-size: var(--fs-body-sm);
    font-weight: 500;
    color: var(--body);
    letter-spacing: 0;
}

.a-stat-foot {
    font-size: var(--fs-caption);
    color: var(--body);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* Deltas carry a glyph as well as weight, so direction never rests on color. */
.a-delta {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-weight: 600;
    color: var(--ink-mid);
}

.a-delta-down {
    color: var(--primary-deep);
}

.a-delta svg {
    width: 12px;
    height: 12px;
}

/* ============================================================
   Buttons — 12px radius, never a pill
   ============================================================ */
.a-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-family: var(--font);
    font-size: var(--fs-caption);
    font-weight: 600;
    line-height: 1;
    padding: 10px var(--sp-lg);
    border-radius: var(--r-md);
    border: 1px solid transparent;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    white-space: nowrap;
    transition: transform 140ms var(--ease-out), background 140ms ease,
                border-color 140ms ease, box-shadow 140ms ease, color 140ms ease;
}

.a-btn svg {
    width: 15px;
    height: 15px;
    flex: none;
}

.a-btn:active {
    transform: scale(0.975);
}

.a-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.a-btn-primary {
    background: var(--primary);
    color: var(--on-primary);
}

/* The one place a shadow is allowed — DESIGN.md's Contrast-Not-Shadow rule. */
.a-btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 8px 20px rgba(255, 79, 0, 0.24);
}

.a-btn-secondary {
    background: var(--ink);
    color: var(--on-primary);
}

.a-btn-secondary:hover:not(:disabled) {
    background: var(--ink-soft);
}

.a-btn-ghost {
    background: var(--canvas);
    border-color: var(--hairline-strong);
    color: var(--ink);
}

.a-btn-ghost:hover:not(:disabled) {
    background: var(--canvas-soft);
    border-color: var(--ink);
}

/* Destructive actions borrow the accent — DESIGN.md has no red, and orange
   already means "this is the one thing to notice". */
.a-btn-danger {
    background: var(--canvas);
    border-color: var(--primary-edge);
    color: var(--primary-deep);
}

.a-btn-danger:hover:not(:disabled) {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
}

.a-btn-sm {
    padding: 7px var(--sp-md);
    font-size: var(--fs-micro);
}

.a-btn-icon {
    padding: 8px;
    width: 34px;
    height: 34px;
}

.a-btn-icon svg {
    width: 16px;
    height: 16px;
}

.a-btn-row {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    flex-wrap: wrap;
}

/* ============================================================
   Badges — the one pill shape in the system
   ------------------------------------------------------------
   Status never rests on color alone: each badge carries a dot
   AND its label text.
   ============================================================ */
.a-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--r-pill);
    font-size: var(--fs-micro);
    font-weight: 700;
    letter-spacing: 0.04em;
    white-space: nowrap;
    background: rgba(32, 21, 21, 0.06);
    color: var(--ink-mid);
    border: 1px solid transparent;
}

.a-badge-dot {
    width: 5px;
    height: 5px;
    border-radius: var(--r-pill);
    background: currentColor;
    flex: none;
}

/* Live / healthy: full ink weight. Confidence reads as solidity here. */
.a-badge-live {
    background: rgba(32, 21, 21, 0.09);
    color: var(--ink);
}

/* Needs attention: the accent, used sparingly. */
.a-badge-attention {
    background: var(--primary-tint);
    color: var(--primary-deep);
    border-color: var(--primary-edge);
}

/* Dormant / ended: recessive. */
.a-badge-quiet {
    background: transparent;
    color: var(--body);
    border-color: var(--hairline-strong);
}

.a-badge-outline {
    background: transparent;
    color: var(--ink-mid);
    border-color: var(--hairline-strong);
}

/* ============================================================
   Avatars
   ============================================================ */
.a-avatar {
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: var(--r-pill);
    display: grid;
    place-items: center;
    background: rgba(32, 21, 21, 0.08);
    color: var(--ink);
    font-size: var(--fs-micro);
    font-weight: 700;
    letter-spacing: 0.02em;
    overflow: hidden;
}

.a-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.a-avatar-sm {
    width: 26px;
    height: 26px;
    font-size: var(--fs-micro);
}

.a-avatar-lg {
    width: 56px;
    height: 56px;
    font-size: var(--fs-body-md);
}

.a-avatar-admin {
    background: var(--primary-tint);
    color: var(--primary-deep);
}

/* ============================================================
   Tables
   ============================================================ */
.a-table-wrap {
    background: var(--canvas-soft);
    border-radius: var(--r-md);
    overflow: hidden;
}

/* Wide tables scroll inside their own container so the page body never does. */
.a-table-scroll {
    overflow-x: auto;
}

.a-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-caption);
    min-width: 720px;
}

.a-table thead th {
    text-align: left;
    padding: var(--sp-md) var(--sp-lg);
    font-size: var(--fs-micro);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--body);
    background: rgba(32, 21, 21, 0.035);
    border-bottom: 1px solid var(--hairline);
    white-space: nowrap;
}

.a-table tbody td {
    padding: var(--sp-md) var(--sp-lg);
    border-bottom: 1px solid var(--hairline);
    color: var(--ink-mid);
    vertical-align: middle;
}

.a-table tbody tr:last-child td {
    border-bottom: none;
}

.a-table tbody tr {
    transition: background 120ms ease;
}

.a-table tbody tr:hover {
    background: rgba(32, 21, 21, 0.03);
}

.a-table .a-num {
    text-align: right;
}

.a-table .a-actions {
    text-align: right;
    white-space: nowrap;
}

.a-cell-primary {
    font-weight: 600;
    color: var(--ink);
}

.a-cell-sub {
    display: block;
    font-size: var(--fs-micro);
    color: var(--body);
    margin-top: 1px;
}

.a-cell-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.a-cell-user-meta {
    min-width: 0;
}

.a-row-link:hover .a-cell-primary {
    color: var(--primary-deep);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.a-row-disabled {
    opacity: 0.55;
}

/* ============================================================
   Filter bar — one row above the data, per interaction spec
   ============================================================ */
.a-filters {
    display: flex;
    align-items: flex-end;
    gap: var(--sp-md);
    flex-wrap: wrap;
    margin-bottom: var(--sp-lg);
}

.a-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.a-field-grow {
    flex: 1;
    min-width: 220px;
}

.a-label {
    font-size: var(--fs-micro);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--body);
}

.a-input,
.a-select {
    font-family: var(--font);
    font-size: var(--fs-caption);
    color: var(--ink);
    background: var(--canvas);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--r-sm);
    padding: 9px var(--sp-md);
    min-height: 38px;
    width: 100%;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

.a-input::placeholder {
    color: var(--body-mid);
}

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

.a-input:disabled,
.a-select:disabled {
    background: var(--canvas-soft);
    color: var(--body);
    cursor: not-allowed;
}

.a-select {
    appearance: none;
    padding-right: var(--sp-2xl);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23605d52' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--sp-md) center;
    background-size: 14px;
}

.a-search {
    position: relative;
}

.a-search .a-input {
    padding-left: 36px;
}

.a-search svg {
    position: absolute;
    left: var(--sp-md);
    top: 50%;
    transform: translateY(-50%);
    width: 15px;
    height: 15px;
    color: var(--body-mid);
    pointer-events: none;
}

.a-help {
    font-size: var(--fs-micro);
    color: var(--body);
    margin-top: 3px;
}

.a-check {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-sm);
    font-size: var(--fs-caption);
    color: var(--ink-mid);
    cursor: pointer;
}

.a-check input {
    width: 17px;
    height: 17px;
    margin: 1px 0 0;
    accent-color: var(--primary);
    flex: none;
    cursor: pointer;
}

/* ============================================================
   Pager
   ============================================================ */
.a-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-lg);
    flex-wrap: wrap;
    padding: var(--sp-md) var(--sp-lg);
    border-top: 1px solid var(--hairline);
    font-size: var(--fs-caption);
    color: var(--body);
}

.a-pager-controls {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
}

.a-pager-page {
    font-weight: 600;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   Empty & loading states
   ============================================================ */
.a-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--sp-sm);
    padding: var(--sp-4xl) var(--sp-xl);
    color: var(--body);
}

.a-empty-icon {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: var(--r-pill);
    background: rgba(32, 21, 21, 0.05);
    color: var(--body-mid);
    margin-bottom: var(--sp-xs);
}

.a-empty-icon svg {
    width: 22px;
    height: 22px;
}

.a-empty-title {
    font-size: var(--fs-body-md);
    font-weight: 600;
    color: var(--ink);
}

.a-empty-text {
    font-size: var(--fs-caption);
    max-width: 46ch;
}

/* Skeletons breathe rather than sweep — no shimmer gradient. */
.a-skeleton {
    border-radius: var(--r-sm);
    background: rgba(32, 21, 21, 0.07);
    animation: a-pulse 1.5s ease-in-out infinite;
}

@keyframes a-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

.a-skeleton-tile {
    height: 116px;
    border-radius: var(--r-md);
}

.a-skeleton-row {
    height: 52px;
    margin-bottom: 2px;
}

/* ============================================================
   Toast
   ============================================================ */
.a-toasts {
    position: fixed;
    right: var(--sp-xl);
    bottom: var(--sp-xl);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: var(--sp-sm);
    width: min(400px, calc(100vw - 2 * var(--sp-xl)));
}

.a-toast {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-md);
    padding: var(--sp-md) var(--sp-lg);
    border-radius: var(--r-md);
    background: var(--ink);
    color: var(--canvas-soft);
    font-size: var(--fs-caption);
    animation: a-toast-in 260ms var(--ease-out);
}

.a-toast-error {
    background: var(--primary-deep);
    color: var(--on-primary);
}

.a-toast svg {
    width: 17px;
    height: 17px;
    flex: none;
    margin-top: 1px;
}

.a-toast-text {
    flex: 1;
    min-width: 0;
}

.a-toast-close {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    padding: 0;
    font-size: var(--fs-body-sm);
    line-height: 1;
}

.a-toast-close:hover {
    opacity: 1;
}

@keyframes a-toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .a-toast { animation: none; }
    .a-skeleton { animation: none; }
    .admin * { transition-duration: 1ms !important; }
}

/* ============================================================
   Modal
   ============================================================ */
.a-modal-scrim {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(32, 21, 21, 0.42);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-xl);
    animation: a-fade-in 160ms ease;
}

.a-modal {
    background: var(--canvas);
    border-radius: var(--r-md);
    width: min(560px, 100%);
    max-height: calc(100vh - 2 * var(--sp-xl));
    display: flex;
    flex-direction: column;
    animation: a-modal-in 220ms var(--ease-out);
}

.a-modal-wide {
    width: min(720px, 100%);
}

.a-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-lg);
    padding: var(--sp-xl) var(--sp-xl) var(--sp-md);
}

.a-modal-title {
    margin: 0;
    font-size: var(--fs-display-sub-sm);
    font-weight: 600;
    letter-spacing: -0.6px;
}

.a-modal-sub {
    margin: var(--sp-xs) 0 0;
    font-size: var(--fs-caption);
    color: var(--body);
}

.a-modal-body {
    padding: 0 var(--sp-xl) var(--sp-lg);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--sp-lg);
}

.a-modal-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-sm);
    padding: var(--sp-lg) var(--sp-xl) var(--sp-xl);
    border-top: 1px solid var(--hairline);
}

.a-modal-close {
    background: none;
    border: none;
    color: var(--body);
    cursor: pointer;
    padding: var(--sp-xs);
    line-height: 1;
    border-radius: var(--r-sm);
}

.a-modal-close:hover {
    color: var(--ink);
    background: var(--canvas-soft);
}

.a-modal-close svg {
    width: 18px;
    height: 18px;
}

@keyframes a-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes a-modal-in {
    from { opacity: 0; transform: translateY(12px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* A callout inside a modal, for the consequence of a destructive action. */
.a-notice {
    display: flex;
    gap: var(--sp-md);
    padding: var(--sp-md) var(--sp-lg);
    border-radius: var(--r-sm);
    background: var(--primary-tint);
    border: 1px solid var(--primary-edge);
    font-size: var(--fs-caption);
    color: var(--ink-mid);
}

.a-notice svg {
    width: 17px;
    height: 17px;
    flex: none;
    color: var(--primary-deep);
    margin-top: 1px;
}

.a-notice-quiet {
    background: var(--canvas-soft);
    border-color: var(--hairline);
}

.a-notice-quiet svg {
    color: var(--body);
}

/* ============================================================
   Charts
   ------------------------------------------------------------
   Identity is carried by direct labels, never by hue: with one
   accent available, colouring categories would be unreadable.
   Colour therefore encodes only magnitude (single ink hue) and
   status (the accent = needs attention).
   ============================================================ */
.a-chart {
    width: 100%;
    overflow: visible;
    display: block;
}

.a-chart-grid line {
    stroke: rgba(32, 21, 21, 0.09);
    stroke-width: 1;
}

.a-chart-axis text {
    font-family: var(--font);
    font-size: var(--fs-micro);
    font-variant-numeric: tabular-nums;
    fill: var(--body);
}

.a-chart-area {
    fill: url(#aChartFade);
}

.a-chart-line {
    fill: none;
    stroke: var(--primary);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.a-chart-dot {
    fill: var(--primary);
    stroke: var(--canvas-soft);
    stroke-width: 2;
}

/* Hover target is larger than the mark it activates. */
.a-chart-hit {
    fill: transparent;
    cursor: pointer;
}

/* Hover only — the hit rects are not focusable, so there is no :focus-visible
   state to style here. */
.a-chart-hit:hover + .a-chart-hover {
    opacity: 1;
}

.a-chart-hover {
    opacity: 0;
    pointer-events: none;
    transition: opacity 120ms ease;
}

.a-chart-hover-line {
    stroke: var(--ink);
    stroke-width: 1;
    stroke-dasharray: 3 3;
}

.a-chart-tip-box {
    fill: var(--ink);
    rx: 6;
}

.a-chart-tip-text {
    font-family: var(--font);
    font-size: var(--fs-micro);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    fill: var(--canvas-soft);
}

.a-chart-bar {
    fill: var(--ink);
    transition: fill 120ms ease;
}

.a-chart-bar-track {
    fill: rgba(32, 21, 21, 0.07);
}

.a-chart-bar-accent {
    fill: var(--primary);
}

.a-chart-empty {
    display: grid;
    place-items: center;
    min-height: 180px;
    font-size: var(--fs-caption);
    color: var(--body);
}

/* ---------- Horizontal labelled bars (plan mix, status mix) ---------- */
.a-bars {
    display: flex;
    flex-direction: column;
    gap: var(--sp-md);
}

.a-bar-row {
    display: grid;
    gap: 5px;
}

.a-bar-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--sp-md);
    font-size: var(--fs-caption);
}

.a-bar-name {
    font-weight: 600;
    color: var(--ink);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.a-bar-value {
    color: var(--body);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.a-bar-track {
    height: 8px;
    border-radius: var(--r-sm);
    background: rgba(32, 21, 21, 0.07);
    overflow: hidden;
}

/* No width transition here, deliberately. The bar's width arrives in the
   server-rendered HTML, and CSS transitions don't fire on a property's initial
   value — so it animated nothing while still putting a layout property on the
   compositor's critical path. transform: scaleX() would animate cheaply but
   squashes the 6px radius on the data end (a bar at 30% would render its corner
   ~20px wide), and that rounded end is part of the mark spec. */
.a-bar-fill {
    height: 100%;
    border-radius: var(--r-sm);
    background: var(--ink);
    min-width: 3px;
}

.a-bar-fill-accent {
    background: var(--primary);
}

/* ---------- Definition list, for detail panels ---------- */
.a-dl {
    display: grid;
    gap: var(--sp-md);
    margin: 0;
}

.a-dl-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--sp-lg);
    font-size: var(--fs-caption);
}

.a-dl-key {
    color: var(--body);
    flex: none;
}

.a-dl-val {
    color: var(--ink);
    font-weight: 600;
    text-align: right;
    min-width: 0;
    font-variant-numeric: tabular-nums;
}

/* ---------- Timeline-ish activity list ---------- */
.a-list {
    display: flex;
    flex-direction: column;
}

.a-list-item {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    padding: var(--sp-md) 0;
    border-bottom: 1px solid var(--hairline);
    font-size: var(--fs-caption);
}

.a-list-item:last-child {
    border-bottom: none;
}

.a-list-main {
    flex: 1;
    min-width: 0;
}

.a-list-title {
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.a-list-sub {
    font-size: var(--fs-micro);
    color: var(--body);
}

.a-list-end {
    flex: none;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--ink-mid);
    font-weight: 600;
}

/* ============================================================
   Login & denied pages
   ============================================================ */
.a-auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--sp-xl);
    background: var(--canvas);
}

.a-auth-card {
    width: min(440px, 100%);
    background: var(--canvas);
    border: 1px solid var(--hairline-strong);
    border-radius: var(--r-md);
    padding: var(--sp-3xl) var(--sp-2xl);
    text-align: center;
}

.a-auth-logo {
    width: 46px;
    height: 46px;
    border-radius: var(--r-sm);
    margin: 0 auto var(--sp-lg);
    display: block;
}

.a-auth-title {
    margin: 0 0 var(--sp-sm);
    font-size: var(--fs-display-sub-sm);
    font-weight: 600;
    letter-spacing: -0.6px;
}

.a-auth-title .accent {
    color: var(--primary);
}

.a-auth-text {
    margin: 0 auto var(--sp-xl);
    font-size: var(--fs-body-sm);
    color: var(--body);
    max-width: 34ch;
}

.a-auth-gsi {
    display: flex;
    justify-content: center;
    min-height: 44px;
}

.a-auth-error {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-sm);
    text-align: left;
    padding: var(--sp-md) var(--sp-lg);
    margin-bottom: var(--sp-lg);
    border-radius: var(--r-sm);
    background: var(--primary-tint);
    border: 1px solid var(--primary-edge);
    font-size: var(--fs-caption);
    color: var(--ink-mid);
}

.a-auth-error svg {
    width: 17px;
    height: 17px;
    flex: none;
    color: var(--primary-deep);
    margin-top: 1px;
}

.a-auth-note {
    margin: var(--sp-xl) 0 0;
    padding-top: var(--sp-lg);
    border-top: 1px solid var(--hairline);
    font-size: var(--fs-micro);
    color: var(--body);
}

.a-auth-foot {
    margin-top: var(--sp-lg);
    font-size: var(--fs-caption);
}

.a-auth-foot a {
    color: var(--primary-deep);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ============================================================
   Utilities
   ============================================================ */
.a-muted { color: var(--body); }
.a-strong { font-weight: 600; color: var(--ink); }
.a-accent { color: var(--primary-deep); }
.a-nowrap { white-space: nowrap; }
.a-right { text-align: right; }
.a-mt-lg { margin-top: var(--sp-lg); }
.a-mt-xl { margin-top: var(--sp-xl); }
.a-mb-0 { margin-bottom: 0; }

.a-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.a-inline-form {
    display: flex;
    align-items: flex-end;
    gap: var(--sp-sm);
    flex-wrap: wrap;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1200px) {
    .a-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .a-grid-split { grid-template-columns: minmax(0, 1fr); }
}

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

    .a-side {
        position: fixed;
        inset: 0 auto 0 0;
        width: var(--sidebar-w);
        z-index: 60;
        transform: translateX(-100%);
        transition: transform 240ms var(--ease-out);
    }

    .a-side.open { transform: translateX(0); }

    .a-nav-toggle { display: inline-flex; }

    .a-side-scrim {
        position: fixed;
        inset: 0;
        z-index: 50;
        background: rgba(32, 21, 21, 0.4);
    }

    .a-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .a-content { padding: var(--sp-lg) var(--sp-lg) var(--sp-4xl); }
    .a-topbar { padding: var(--sp-md) var(--sp-lg); }
}

@media (max-width: 720px) {
    .a-grid-4,
    .a-grid-3,
    .a-grid-2 { grid-template-columns: minmax(0, 1fr); }

    .a-page-title { font-size: var(--fs-body-lg); }
    .a-stat-value { font-size: var(--fs-display-sub-sm); }
    .a-card { padding: var(--sp-lg); }
    .a-filters > .a-field { width: 100%; }
    .a-toasts { right: var(--sp-md); left: var(--sp-md); bottom: var(--sp-md); width: auto; }
}
