/* ============================================================================
   Hythe Tickets — the Hythe app family light theme (brand 2.0 ch8; Hythe Projects / Bid Desk)
   Deep Ocean chrome (#191D2D), light canvas, white cards, deep-teal links and focus.
   The brand teal (#00EAD0) is used ONLY on navy: it fails contrast on white.
   Charts use the validated data palette (--d-*), never the brand palette.
   ============================================================================ */

:root {
    /* Brand chrome: the app family (brand 2.0 ch8, Hythe Projects / Bid Desk tokens, D0-4) */
    --navy: #191D2D;            /* Deep Ocean: chrome + the primary action */
    --navy-2: #283655;          /* Shoreline: chrome-active, chrome edges */
    --navy-deep: #283655;       /* primary-action hover (ch8) */
    --accent: #00EAD0;          /* brand teal: ON NAVY ONLY, one per screen */
    --accent-hover: #3ff2dd;
    --chrome: #191D2D;
    --chrome-line: #2E3550;     /* dividers on dark, decorative */
    --chrome-ink: #FFFFFF;
    --chrome-ink-2: #C3C9D3;
    --chrome-ink-3: #9AA3B1;
    --ease-standard: cubic-bezier(0.2, 0, 0, 1);

    /* Surfaces & ink */
    --canvas: #F5F6F8;
    --surface: #FFFFFF;
    --surface-2: #F1F2F6;       /* row hover */
    --surface-3: #ECEEF3;       /* recessed lane, wells */
    --border: #E3E6ED;          /* hairline: decorative only, never a control edge */
    --border-strong: #7F8699;   /* control edge (3.6:1, was 1.47:1, R-88) */
    --text: #191D2D;            /* headings, key figures */
    --text-2: #4A5268;          /* body */
    --text-3: #61687E;          /* meta, labels: >= 4.5:1 on every surface */
    --text-4: #8A92A6;          /* placeholder / disabled ONLY, never content (R-88) */
    --focus: #007465;           /* deep teal focus ring (5.7:1); brand teal on chrome */
    --link: #007465;            /* links, refs, selected */

    /* Data palette — validated (dataviz validate_palette.js, light, surface #fff):
       blue/teal-green/amber pass all-pairs; grey is de-emphasis ("Other"), not a slot. */
    --d-blue: #2E5F9E;
    --d-teal: #00897B;
    --d-amber: #C8842A;
    --d-red: #C62828;
    --d-other: #8E95A3;         /* ch8 other-grey (was 2.58:1, R-88) */
    --grid: #eaecf0;
    --axis: #d0d5dd;

    /* Semantic pills (text always clears 4.5:1 on its tint) */
    --good-bg: #ecfdf3;   --good-fg: #067647;   --good-bd: #abefc6;
    --bad-bg: #fef3f2;    --bad-fg: #b42318;    --bad-bd: #fecdca;
    --warn-bg: #fffaeb;   --warn-fg: #b54708;   --warn-bd: #fedf89;
    --info-bg: #eff4fb;   --info-fg: #2E5F9E;   --info-bd: #c7d7ee;
    --navy-bg: #EEF0F4;   --navy-fg: #191D2D;   --navy-bd: #E3E6ED;
    --neutral-bg: #EEF0F4; --neutral-fg: #4A5268; --neutral-bd: #E3E6ED;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-hover: 0 4px 12px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
    --shadow-pop: 0 16px 32px -8px rgba(16, 24, 40, 0.18), 0 4px 8px -4px rgba(16, 24, 40, 0.06);

    --nav-h: 60px;
    --nav-h-mobile: 52px;
    --mnav-h: 64px;
    --gutter: 24px;

    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    background: var(--canvas);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

.hidden { display: none !important; }
.muted { color: var(--text-3); font-weight: 400; }
.tnum { font-variant-numeric: tabular-nums; }
.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;
}

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.nav :focus-visible, .mobile-nav :focus-visible { outline-color: var(--accent); }

/* ============================================================================
   Top bar — navy chrome
   ============================================================================ */

.nav {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--nav-h);
    background: var(--navy);
    color: #fff;
    z-index: 100;
    box-shadow: inset 0 -1px 0 var(--navy-2);
}

.nav-inner {
    max-width: 1200px;
    height: 100%;
    margin: 0 auto;
    padding: 0 var(--gutter);
    display: flex;
    align-items: center;
    gap: 28px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    flex-shrink: 0;
}

/* Dark-background logo variant sits directly on navy chrome, no chip */
.logo-dark { height: 24px; width: auto; display: block; }
.logo-dark-lg { height: 34px; }

.nav-product {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #fff;
    padding-left: 12px;
    border-left: 1px solid rgba(255, 255, 255, 0.18);
}

.nav-links {
    display: flex;
    align-items: stretch;
    gap: 4px;
    flex: 1;
    height: 100%;
}

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0 12px;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.15s ease;
}

.nav-link:hover { color: #fff; }

.nav-link.active { color: #fff; }

.nav-link.active::after {
    content: '';
    position: absolute;
    left: 12px; right: 12px; bottom: 2px;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--accent);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.nav-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.16);
    margin: 0 4px;
}

.nav-user-name {
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.88);
}

.nav-cta { text-decoration: none; }

/* ============================================================================
   Avatars
   ============================================================================ */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--navy-bg);
    color: var(--navy);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }
.avatar-inverse { background: var(--navy-2); color: #fff; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12); }
.avatar-empty { background: var(--surface-3); color: var(--text-3); }

/* ============================================================================
   Mobile bottom nav — navy, with the raised "New" action
   ============================================================================ */

.mobile-nav {
    position: fixed;
    inset: auto 0 0 0;
    height: var(--mnav-h);
    background: var(--navy);
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    padding: 0 4px;
    z-index: 100;
    box-shadow: 0 -1px 0 var(--navy-2), 0 -8px 24px -12px rgba(16, 24, 40, 0.35);
}

.mobile-nav-item {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 56px;
    color: rgba(255, 255, 255, 0.62);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease;
}

.mobile-nav-item.active { color: #fff; }

.mobile-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 28px;
    height: 3px;
    margin-left: -14px;
    border-radius: 0 0 3px 3px;
    background: var(--accent);
}

.mobile-nav-cta { color: #fff; }
.mobile-nav-cta.active::before { display: none; }

.mobile-nav-cta .fab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin-top: -22px;
    border-radius: 50%;
    background: #fff;
    color: var(--navy);
    box-shadow: 0 0 0 4px var(--navy), 0 6px 16px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease;
}

.mobile-nav-cta:active .fab { transform: scale(0.94); }

/* ============================================================================
   Page shell
   ============================================================================ */

#main-content {
    padding-top: var(--nav-h);
    min-height: 100vh;
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px var(--gutter) 48px;
    animation: pageIn 0.25s ease-out both;
}

.page-list { max-width: 960px; }
.page-narrow { max-width: 760px; }
.page-detail { max-width: 1120px; }

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--text);
}

.page-sub {
    margin-top: 4px;
    font-size: 14px;
    color: var(--text-3);
}

.scope-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-2);
    white-space: nowrap;
}

.scope-pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--d-teal);
}

/* ============================================================================
   Cards — one style for stats, charts, lists, forms
   ============================================================================ */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    min-width: 0;
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 18px 20px 0;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.005em;
}

.card-sub {
    margin-top: 2px;
    font-size: 13px;
    color: var(--text-3);
}

.card-body { padding: 16px 20px 20px; }

.card-link {
    background: none;
    border: none;
    padding: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--link);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.card-link:hover { text-decoration: underline; }

.section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 40px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn-primary { background: var(--navy); color: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.1); }
.btn-primary:hover { background: var(--navy-deep); }

/* On navy chrome: a solid Shoreline action, so brand teal stays the one active marker. */
.btn-chrome { background: var(--navy-2); color: #fff; border-color: rgba(255, 255, 255, 0.16); }
.btn-chrome:hover { filter: brightness(1.15); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05); }
.btn-secondary:hover { background: var(--surface-2); }

.btn-ghost { background: transparent; color: var(--text-2); font-weight: 500; }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-ghost-inverse { background: transparent; color: rgba(255, 255, 255, 0.8); font-weight: 500; border-color: rgba(255, 255, 255, 0.2); }
.btn-ghost-inverse:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

.btn-success { background: #067647; color: #fff; }
.btn-success:hover { background: #055d38; }

.btn-warning { background: var(--surface); color: var(--warn-fg); border-color: var(--warn-bd); }
.btn-warning:hover { background: var(--warn-bg); }

.btn-danger { background: var(--surface); color: var(--bad-fg); border-color: var(--bad-bd); }
.btn-danger:hover { background: var(--bad-bg); }

.btn-danger-outline { background: var(--surface); color: var(--bad-fg); border-color: var(--border-strong); }
.btn-danger-outline:hover { background: var(--bad-bg); border-color: var(--bad-bd); }

.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn-xs { height: 28px; padding: 0 10px; font-size: 12px; border-radius: var(--radius-xs); }
.btn-full { width: 100%; }

/* ============================================================================
   Form controls
   ============================================================================ */

.input,
.select,
.login-form input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 15px;
    color: var(--text);
    outline: none;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea.input {
    height: auto;
    min-height: 120px;
    padding: 10px 12px;
    line-height: 1.55;
    resize: vertical;
}

.input::placeholder,
.login-form input::placeholder,
textarea::placeholder { color: var(--text-4); }

.input:focus,
.select:focus,
.login-form input:focus,
.search-field:focus-within {
    border-color: var(--focus);
    box-shadow: 0 0 0 3px rgba(0, 116, 101, 0.16);
}

.select {
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    padding-right: 36px;
    text-overflow: ellipsis;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.select-inline { width: auto; height: 34px; font-size: 13px; }

.form-card { padding: 4px 0 0; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
    padding: 0 24px;
}

.form-row .form-group { padding-left: 0; padding-right: 0; }

.form-group { padding: 18px 24px 0; }

.form-group > label,
.field-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
}

.optional { font-weight: 400; color: var(--text-3); }
.field-hint { margin: 6px 0 0; font-size: 12.5px; line-height: 1.45; color: var(--text-3); }
.field-hint-danger { color: var(--bad-fg); }

.form-actions {
    padding: 24px;
    margin-top: 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius) var(--radius);
}

.form-actions .alert { margin: 12px 0 0; }

.file-input { display: none; }

.file-upload-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

/* beats `.form-group > label { display: block }` */
.form-group > .file-upload-label { display: flex; margin-bottom: 0; font-size: 14px; font-weight: 400; color: var(--text-2); }
.file-upload-label svg { color: var(--text-3); flex-shrink: 0; }
.file-upload-label strong { color: var(--link); font-weight: 600; }
.file-upload-label .muted { display: block; font-size: 12px; }
.file-upload-label:hover { border-color: var(--link); background: var(--info-bg); }

.file-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.file-preview:empty { display: none; }
.file-preview-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.file-preview-item img {
    width: 64px; height: 64px; object-fit: cover;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.file-preview-name {
    max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 11px; color: var(--text-3);
}

/* ============================================================================
   Pills / badges — status, urgency, SLA, roles
   ============================================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    border: 1px solid var(--neutral-bd);
    background: var(--neutral-bg);
    color: var(--neutral-fg);
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
}

.badge svg { flex-shrink: 0; }
.badge-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge-info, .badge-new, .badge-open, .badge-medium, .badge-channel-email
    { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-bd); }
.badge-navy, .badge-in_progress, .badge-role-lead, .badge-lead
    { background: var(--navy-bg); color: var(--navy-fg); border-color: var(--navy-bd); }
.badge-good, .badge-done, .badge-sla-ok, .badge-channel-push
    { background: var(--good-bg); color: var(--good-fg); border-color: var(--good-bd); }
.badge-warn, .badge-more_info, .badge-high, .badge-sla-warning
    { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-bd); }
.badge-bad, .badge-blocked, .badge-critical, .badge-sla-breached
    { background: var(--bad-bg); color: var(--bad-fg); border-color: var(--bad-bd); }
.badge-neutral, .badge-closed, .badge-rejected, .badge-low, .badge-role-user, .badge-archived, .badge-action
    { background: var(--neutral-bg); color: var(--neutral-fg); border-color: var(--neutral-bd); }
.badge-role-admin { background: var(--navy); color: #fff; border-color: var(--navy); }
.badge-channel-teams { background: #eef0fb; color: #4b4f9c; border-color: #d6d8f3; }

/* SLA countdown chip (list rows + detail) — icon + words, never colour alone */
.sla-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-3);
    white-space: nowrap;
}

.sla-chip.sla-warning { color: var(--warn-fg); }
.sla-chip.sla-breached { color: var(--bad-fg); font-weight: 600; }

/* ============================================================================
   Dashboard
   ============================================================================ */

.dash {
    display: grid;
    gap: 16px;
    transition: opacity 0.2s ease;
}

.dash.is-refreshing { opacity: 0.55; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.kpi {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 18px 20px;
}

.kpi-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
}

.kpi-main {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    min-height: 40px;
}

.kpi-value {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 32px;
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.1;
    color: var(--text);
}

.kpi-value .kpi-unit { margin-left: -5px; font-size: 18px; font-weight: 500; color: var(--text-3); letter-spacing: 0; }
.kpi-value .kpi-icon { color: var(--bad-fg); }
.kpi-value.is-empty { color: var(--text-3); }

.kpi-foot {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 8px;
    min-height: 22px;
    font-size: 12px;
    color: var(--text-3);
}

.spark { flex-shrink: 0; margin-bottom: 4px; }

.delta {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.delta-good { background: var(--good-bg); color: var(--good-fg); }
.delta-bad { background: var(--bad-bg); color: var(--bad-fg); }
.delta-neutral { background: var(--neutral-bg); color: var(--neutral-fg); }

.dash-row {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

/* Legend — line keys mirror the chart's lines */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
}

.legend-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 13px;
    color: var(--text-2);
}

.legend-key {
    align-self: center;
    width: 14px;
    height: 3px;
    border-radius: 2px;
    background: currentColor;
}

.legend-item strong { font-size: 15px; font-weight: 600; color: var(--text); }

.key-created { color: var(--d-blue); }
.key-resolved { color: var(--d-teal); }

/* Trend chart */
.chart {
    position: relative;
    margin-top: 12px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y;
}

.chart svg { width: 100%; overflow: visible; }
.chart svg:focus { outline: none; }
.chart svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 4px; }

.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .base-line { stroke: var(--axis); stroke-width: 1; }
.chart .tick { font-size: 12px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
.chart .end-label { font-size: 12px; font-weight: 500; fill: var(--text-2); }
.chart .series-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .s-created { stroke: var(--d-blue); }
.chart .s-resolved { stroke: var(--d-teal); }
.chart .dot-created { fill: var(--d-blue); stroke: var(--surface); stroke-width: 2; }
.chart .dot-resolved { fill: var(--d-teal); stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--text-4); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }

.chart-tip {
    position: absolute;
    top: 0;
    left: 0;
    min-width: 132px;
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-pop);
    font-size: 12px;
    pointer-events: none;
    z-index: 5;
}

.chart-tip-date { font-weight: 600; color: var(--text); margin-bottom: 4px; }

.chart-tip-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-3);
    line-height: 1.7;
}

.chart-tip-row .legend-key { width: 10px; }
.chart-tip-row strong { color: var(--text); font-weight: 600; min-width: 16px; font-variant-numeric: tabular-nums; }

.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 190px;
    margin-top: 12px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-3);
    font-size: 13px;
}

/* Table view twin of the chart */
.table-toggle { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }

.table-toggle summary {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--link);
    cursor: pointer;
    list-style: none;
}

.table-toggle summary::-webkit-details-marker { display: none; }
.table-toggle summary::before { content: '▸'; font-size: 11px; transition: transform 0.15s ease; }
.table-toggle[open] summary::before { transform: rotate(90deg); }

.table-scroll { max-height: 260px; overflow-y: auto; margin-top: 8px; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    position: sticky;
    top: 0;
    background: var(--surface-2);
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-3);
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

.data-table td { padding: 7px 10px; border-bottom: 1px solid var(--grid); color: var(--text-2); }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Category share: one 100% bar + a list */
.share-bar {
    display: flex;
    gap: 2px;
    height: 8px;
    margin: 4px 0 14px;
}

.share-seg { min-width: 4px; }
.share-seg:first-child { border-radius: 4px 0 0 4px; }
.share-seg:last-child { border-radius: 0 4px 4px 0; }
.share-seg:only-child { border-radius: 4px; }

.c1 { background: var(--d-blue); }
.c2 { background: var(--d-teal); }
.c3 { background: var(--d-amber); }
.c-other { background: var(--d-other); }

.cat-list { list-style: none; }

.cat-row {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto 44px;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-top: 1px solid var(--grid);
    font-size: 14px;
}

.cat-row:first-child { border-top: none; }
.cat-dot { width: 8px; height: 8px; border-radius: 50%; }
.cat-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count { font-weight: 600; font-variant-numeric: tabular-nums; }
.cat-pct { text-align: right; color: var(--text-3); font-size: 13px; font-variant-numeric: tabular-nums; }

/* Row lists inside cards (needs attention, workload, recent) */
.row-list { list-style: none; }

.row-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-top: 1px solid var(--grid);
    text-decoration: none;
    color: inherit;
}

.row-list-flush .row-item { padding-left: 0; padding-right: 0; }

a.row-item, .row-item[data-action] { cursor: pointer; transition: background-color 0.12s ease; }
a.row-item:hover, .row-item[data-action]:hover { background: var(--surface-2); }

.row-main { display: block; flex: 1; min-width: 0; }

.row-title {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 8px;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-3);
}

.row-side { flex-shrink: 0; text-align: right; }

.ref {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
}

.sep::before { content: '·'; color: var(--text-4); }

.work-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-top: 1px solid var(--grid);
}

.work-row:first-child { border-top: none; }
.work-count { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.work-count.is-zero { color: var(--text-3); font-weight: 500; }
.work-sub { margin-top: 12px; padding-top: 6px; border-top: 1px solid var(--border); }
.work-sub .work-row { border-top: none; padding: 6px 0; }
.work-label { font-size: 14px; color: var(--text-2); }

.card-empty {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px;
    margin: 16px 20px 20px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 14px;
}

.card-empty svg { color: var(--good-fg); flex-shrink: 0; }

/* Skeleton for the first paint only (refetches hold the old render instead) */
.skel {
    background: linear-gradient(90deg, var(--surface-3) 0%, #eceff3 50%, var(--surface-3) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border-radius: 6px;
}

.skel-kpi { height: 116px; }
.skel-card { height: 320px; }

/* ============================================================================
   Ticket lists — search, status chips, rows
   ============================================================================ */

.list-toolbar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.search-field {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 44px;
    padding: 0 14px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    color: var(--text-3);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-field input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: none;
    outline: none;
    background: transparent;
    font-size: 15px;
    color: var(--text);
}

.search-field input::-webkit-search-cancel-button { cursor: pointer; }

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    height: 32px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.chip:hover { border-color: var(--text-4); color: var(--text); }
.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }

.ticket-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.ticket-list:empty { display: none; }

.ticket-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px 14px 20px;
    border-top: 1px solid var(--grid);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background-color 0.12s ease;
    -webkit-tap-highlight-color: transparent;
}

.ticket-card:first-child { border-top: none; }
.ticket-card:hover { background: var(--surface-2); }
.ticket-card:active { background: var(--surface-3); }

.tc-main { flex: 1; min-width: 0; }

.tc-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.tc-head .badge { flex-shrink: 0; margin-top: -2px; }

/* One line: the category truncates rather than pushing the age onto a second line */
.tc-top {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    font-size: 12px;
    color: var(--text-3);
}

.tc-top > * { flex-shrink: 0; }
.tc-top > .tc-cat { flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.tc-subject {
    margin: 3px 0 8px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.tc-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
}

.assignee {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-2);
    min-width: 0;
}

.assignee.is-unassigned { color: var(--text-3); font-style: italic; }

.ticket-card > .chevron { flex-shrink: 0; color: var(--text-4); }

.queue-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 24px 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
}

.queue-heading:first-child { margin-top: 0; }

.count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text-2);
    font-size: 12px;
    font-weight: 600;
}

/* ============================================================================
   Ticket detail
   ============================================================================ */

.detail-topbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: -8px 0 14px -10px;
}

.back-btn { gap: 4px; }

.ref-chip {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-areas:
        "head side"
        "desc side"
        "comments side";
    grid-template-rows: auto auto 1fr;
    gap: 16px;
    align-items: start;
}

.detail-head { grid-area: head; padding: 22px 24px; }
.detail-side { grid-area: side; }
.detail-desc { grid-area: desc; }
.detail-comments { grid-area: comments; }

.detail-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.3;
    color: var(--text);
    overflow-wrap: anywhere;
}

.pill-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.action-bar {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.status-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.assign-field {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
}

.meta-list { padding: 4px 20px 8px; }

.meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 11px 0;
    border-top: 1px solid var(--grid);
    font-size: 14px;
}

.meta-row:first-child { border-top: none; }
.meta-row dt { color: var(--text-3); flex-shrink: 0; }
.meta-row dd { color: var(--text); font-weight: 500; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.meta-row dd .assignee { font-size: 14px; color: var(--text); }

.ticket-description {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 15px;
    line-height: 1.65;
    color: var(--text);
}

.desc-block + .desc-block { margin-top: 20px; }
.desc-block .section-label { margin-bottom: 8px; }

.callout {
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.callout-good { background: var(--good-bg); border-color: var(--good-bd); }
.callout-good .section-label { color: var(--good-fg); }
.callout .ticket-description { font-size: 14px; }

.attachment-grid { display: flex; flex-wrap: wrap; gap: 8px; }

.attachment-thumb {
    width: 88px;
    height: 88px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: zoom-in;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.attachment-thumb:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }

/* Comment thread */
.thread {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px 20px 4px;
}

.thread-empty { padding: 8px 20px 4px; color: var(--text-3); font-size: 14px; }

.msg { display: flex; gap: 10px; align-items: flex-start; max-width: 100%; }
.msg-own { flex-direction: row-reverse; }

.msg-body { min-width: 0; max-width: min(560px, 85%); }
.msg-own .msg-body { display: flex; flex-direction: column; align-items: flex-end; }

.msg-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
    font-size: 12px;
    color: var(--text-3);
}

.msg-author { font-weight: 600; color: var(--text-2); }

.bubble {
    padding: 10px 14px;
    border-radius: 4px 14px 14px 14px;
    background: var(--surface-3);
    color: var(--text);
    font-size: 14px;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.msg-own .bubble { background: var(--info-bg); border-radius: 14px 4px 14px 14px; }
.msg-internal .bubble { background: var(--warn-bg); border: 1px dashed var(--warn-bd); }
.msg .attachment-grid { margin-top: 8px; }

.comment-form {
    position: relative;
    margin: 12px 20px 20px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.comment-form:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(0, 116, 101, 0.16); }

.comment-form textarea {
    display: block;
    width: 100%;
    min-height: 64px;
    padding: 12px 14px 4px;
    border: none;
    outline: none;
    resize: vertical;
    background: transparent;
    font-size: 14px;
    line-height: 1.5;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.comment-form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px 8px 8px;
}

.comment-form .file-preview { padding: 0 12px 12px; margin-top: 0; }

/* Who reads this reply (R-93); the internal toggle shows only for the desk */
.composer-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    padding: 4px 14px 0;
    font-size: 12.5px;
    color: var(--text-3);
}
.composer-audience { flex: 1 1 200px; margin: 0; }
.internal-toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-weight: 500; cursor: pointer; }
.comment-form.is-internal { border-color: var(--warn-bd); background: var(--warn-bg); }

.file-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 10px;
    border-radius: var(--radius-xs);
    color: var(--text-3);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.file-upload-btn:hover { background: var(--surface-3); color: var(--text); }

/* @Mention autocomplete */
.mention-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    margin-bottom: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-pop);
    z-index: 50;
}

.mention-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
}

.mention-item:hover, .mention-item.active { background: var(--surface-2); }
.mention-item-name { font-size: 14px; font-weight: 500; }

.mention {
    padding: 0 4px;
    border-radius: 4px;
    background: #E3F5F1;
    color: var(--link);
    font-weight: 500;
}

/* ============================================================================
   Login
   ============================================================================ */

/* T9: brand 2.0 HIGH IMPACT, reproduced from Hythe Projects' sign-in (bae-projects
   src/app/(auth)/login/sign-in.tsx): Deep Ocean ground, the fleet photograph behind a navy
   scrim that deepens from the left (from the bottom on a phone), the WhiteOutline lockup,
   chrome ink, and ONE brand-teal action. Navy paints first; the photo never holds the page. */
.page-login {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    max-width: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: var(--chrome);
    color: var(--chrome-ink);
    animation: none;
}

#main-content:has(> #page-login:not(.hidden)) { padding-top: 0; padding-bottom: 0; }

.login-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 45% 18%;
}

.login-scrim {
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, rgb(25 29 45 / 0.97) 0%, rgb(25 29 45 / 0.9) 48%, rgb(25 29 45 / 0.2) 80%, rgb(25 29 45 / 0.05) 100%);
}

.login-inner {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 24px;
    padding: max(32px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
             max(32px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.login-logo { width: auto; height: 32px; align-self: flex-start; }

.login-panel {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding-top: 40vh;
}

.login-heading { display: flex; flex-direction: column; gap: 12px; }

.login-title {
    font-family: 'IBM Plex Sans Condensed', var(--font);
    font-size: 34px;
    line-height: 38px;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    color: var(--chrome-ink);
}

.login-sub { font-size: 15px; line-height: 24px; color: var(--chrome-ink-2); }
.login-status { font-size: 15px; line-height: 24px; color: var(--chrome-ink-2); }
.login-panel .alert { margin: 0; }

.btn-impact {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 44px;
    padding: 0 20px;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: var(--chrome);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: filter 100ms var(--ease-standard), transform 100ms var(--ease-standard);
}
.btn-impact:hover { filter: brightness(1.1); }
.btn-impact:active { transform: scale(0.98); }
.btn-impact:disabled { cursor: default; filter: saturate(0.6); }

/* The quiet divider that opens the email / mobile path. */
.login-alt-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--chrome-ink-2);
    font-size: 13px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
}
.login-alt-toggle::before,
.login-alt-toggle::after { content: ''; flex: 1 1 24px; height: 1px; background: var(--chrome-line); }
.login-alt-toggle:hover { color: var(--chrome-ink); text-decoration: underline; text-underline-offset: 3px; }

.login-credit { font-size: 12px; line-height: 16px; color: var(--chrome-ink-3); }

/* The silent attempt shows only "Signing you in..." (in the button's own grid cell, with the
   button and divider holding their space unseen, so the fallback moves nothing); the button and
   divider appear when it fails; with no SSO config the email / mobile card is simply open. */
.login-sso { display: grid; }
.login-sso > * { grid-area: 1 / 1; }
.login-sso-wait { align-self: center; }
.page-login[data-sso="trying"] .login-sso-btn,
.page-login[data-sso="trying"] .login-alt-toggle,
.page-login:not([data-sso="trying"]) .login-sso-wait { visibility: hidden; }
.page-login[data-sso="off"] .login-sso,
.page-login[data-sso="off"] .login-alt-toggle { display: none; }

.page-login :focus-visible { outline-color: var(--accent); }
.login-card :focus-visible { outline-color: var(--focus); }

@media (min-width: 641px) {
    .login-scrim {
        background: linear-gradient(90deg, rgb(25 29 45 / 0.9) 0%, rgb(25 29 45 / 0.7) 30%, rgb(25 29 45 / 0.15) 58%, rgb(25 29 45 / 0) 80%);
    }
    .login-inner { padding: 40px 48px; }
    .login-logo { height: 36px; }
    .login-panel { padding-top: 0; }
    .login-title { font-size: 44px; line-height: 48px; }
}
@media (min-width: 1024px) { .login-inner { padding: 40px 80px; } }
@media (prefers-reduced-motion: reduce) { .btn-impact { transition: none; } .btn-impact:active { transform: none; } }

.login-card {
    width: 100%;
    background: var(--surface);
    color: var(--text);
    border-radius: 10px;
    box-shadow: var(--shadow-pop);
    overflow: hidden;
}

.login-body { padding: 24px; }

.login-tabs {
    display: flex;
    gap: 2px;
    padding: 3px;
    margin-bottom: 20px;
    background: var(--surface-3);
    border-radius: var(--radius-sm);
}

.login-tab {
    flex: 1;
    height: 34px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-3);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.login-tab.active {
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08), 0 0 0 1px rgba(16, 24, 40, 0.04);
}

.login-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
}

.login-form input { height: 44px; margin-bottom: 16px; }
.login-form .btn { height: 44px; }
.code-input { text-align: center; letter-spacing: 0.4em; font-size: 20px !important; font-weight: 600; }

#login-step-sms .btn-ghost { margin-top: 8px; }

.login-message { text-align: center; padding: 4px 0; }

.login-message-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--good-bg);
    color: var(--d-teal);
}

.login-message h2 { margin: 14px 0 6px; font-size: 18px; font-weight: 600; }
.login-message p { margin-bottom: 16px; font-size: 14px; color: var(--text-2); line-height: 1.55; }

/* ============================================================================
   Empty / loading / alerts
   ============================================================================ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-3);
}

.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--text); }
.empty-state p { font-size: 14px; }

.empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--text-3);
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 28px;
    color: var(--text-3);
    font-size: 14px;
}

.loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--border);
    border-top-color: var(--navy);
    animation: spin 0.7s linear infinite;
}

.alert {
    padding: 12px 14px;
    margin: 12px 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 14px;
}

.alert-error { background: var(--bad-bg); color: var(--bad-fg); border-color: var(--bad-bd); }
.alert-success { background: var(--good-bg); color: var(--good-fg); border-color: var(--good-bd); }

/* ============================================================================
   Profile
   ============================================================================ */

.profile-card { overflow: hidden; }

.profile-head {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px;
}

.profile-name { font-size: 18px; font-weight: 600; }
.profile-role { margin-top: 4px; }

.profile-actions {
    display: grid;
    gap: 10px;
    padding: 20px 24px 24px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
}

/* ============================================================================
   Admin
   ============================================================================ */

.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.admin-tab {
    position: relative;
    height: 40px;
    padding: 0 12px;
    border: none;
    background: none;
    color: var(--text-3);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--navy); font-weight: 600; }

.admin-tab.active::after {
    content: '';
    position: absolute;
    left: 8px; right: 8px; bottom: -1px;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: var(--navy);
}

.admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.admin-toolbar .search-field { flex: 1 1 260px; }

.admin-toggle {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--surface-3);
    border-radius: var(--radius-sm);
}

.toggle-btn {
    height: 34px;
    padding: 0 14px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-3);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.toggle-btn.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08); }

.admin-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.admin-list:empty { display: none; }

.admin-user-card {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 12px;
    padding: 12px 20px;
    border-top: 1px solid var(--grid);
    cursor: pointer;
    transition: background-color 0.12s ease;
}

.admin-user-card:first-child { border-top: none; }
.admin-user-card:hover { background: var(--surface-2); }

.user-card-main { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-name { font-size: 14px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-card-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 12px;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-3);
    min-width: 0;
}

.user-card-detail span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.user-card-badges { display: flex; gap: 6px; }

.admin-detail-back { margin: 0 0 8px -10px; }

.admin-detail-card { padding: 20px 24px; }
.admin-detail-card h2 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.admin-detail-card .section-label { display: block; margin: 20px 0 8px; }

/* Label/value grid (admin user detail) */
.ticket-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 24px;
}

.ticket-detail-grid > div { padding: 12px 0; border-top: 1px solid var(--grid); min-width: 0; }

.detail-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-3);
}

.detail-value { margin-top: 4px; font-size: 14px; color: var(--text); overflow-wrap: anywhere; }

.admin-routing-badges { display: flex; flex-wrap: wrap; gap: 6px; }

.activity-row-mini {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    padding: 8px 0;
    border-top: 1px solid var(--grid);
    font-size: 13px;
}

.activity-action { font-weight: 600; color: var(--text); }
.activity-val { color: var(--text-2); }

/* Routing accordion */
.routing-list { display: grid; gap: 10px; }

.routing-category {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.routing-category-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.12s ease;
}

.routing-category-header:hover { background: var(--surface-2); }

.routing-cat-name { flex: 1; font-size: 15px; font-weight: 600; }
.routing-member-count { font-size: 13px; color: var(--text-3); }

.routing-chevron {
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-4);
    border-bottom: 2px solid var(--text-4);
    transform: rotate(45deg) translate(-2px, -2px);
    transition: transform 0.2s ease;
}

.routing-category.open .routing-chevron { transform: rotate(-135deg) translate(-2px, -2px); }
.routing-category-body { display: none; border-top: 1px solid var(--border); }
.routing-category.open .routing-category-body { display: block; }

.routing-member {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    padding: 10px 20px;
    border-top: 1px solid var(--grid);
}

.routing-member:first-child { border-top: none; }
.member-name { flex: 1; min-width: 120px; font-size: 14px; }
.member-actions { display: flex; gap: 6px; }
.routing-add { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.routing-category-body .empty-state { padding: 20px; }

/* Activity */
.activity-item { padding: 12px 20px; border-top: 1px solid var(--grid); }
.activity-item:first-child { border-top: none; }
.activity-item-header { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.activity-type { font-size: 14px; font-weight: 600; }
.activity-ref { font-size: 12px; font-weight: 600; color: var(--link); font-variant-numeric: tabular-nums; }
.activity-time { margin-left: auto; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.activity-item-detail { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 13px; color: var(--text-3); }
.activity-user { color: var(--text-2); }
.activity-change { font-variant-numeric: tabular-nums; }

/* Pagination */
.admin-pagination { padding: 12px 0; }
.admin-pagination:empty { display: none; }
.page-btns { display: flex; align-items: center; justify-content: center; gap: 12px; }
.page-info { font-size: 13px; color: var(--text-3); }

/* Billing */
.billing-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px 32px;
    padding: 20px 24px;
    margin-bottom: 16px;
}

.billing-total-value { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; color: var(--text); }
.billing-total-label { order: -1; }
.billing-total-card { display: flex; flex-direction: column; gap: 4px; }
.billing-breakdown { display: flex; gap: 32px; }
.billing-mini-stat { display: flex; flex-direction: column; gap: 2px; }
.billing-mini-value { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.billing-mini-label, .billing-total-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); }

.billing-section { margin-bottom: 16px; }
.billing-section h3 { padding: 16px 20px 4px; font-size: 15px; font-weight: 600; }
.billing-table { padding: 0 20px 8px; }

.billing-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 16px;
    padding: 10px 0;
    border-top: 1px solid var(--grid);
}

.billing-row:first-child { border-top: none; }
.billing-row-service { font-size: 14px; font-weight: 500; }
.billing-row-cost { grid-column: 2; grid-row: 1; text-align: right; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.billing-row-note { grid-column: 1 / -1; font-size: 12px; color: var(--text-3); }

.billing-usage-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    margin: 12px 20px 20px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.billing-usage-item { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--surface); }
.billing-usage-value { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.billing-usage-label { order: -1; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); }

/* ============================================================================
   Lightbox
   ============================================================================ */

.lightbox {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(16, 24, 40, 0.92);
    z-index: 9999;
    animation: fadeIn 0.2s ease;
}

.lightbox img { max-width: 92%; max-height: 88%; border-radius: var(--radius-sm); object-fit: contain; }

.lightbox-close {
    position: absolute;
    top: 12px;
    right: 16px;
    padding: 8px;
    border: none;
    background: none;
    color: #fff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
}

/* ============================================================================
   Choice dialog (choose() in app.js): explicit buttons, Esc / Cancel = nothing
   ============================================================================ */

.choice-dialog {
    margin: auto;                     /* the reset zeroes margins; keep the dialog centred */
    width: min(420px, calc(100vw - 32px));
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-pop);
}
.choice-dialog::backdrop { background: rgba(16, 24, 40, 0.45); }
.choice-dialog p { margin: 0 0 16px; line-height: 1.5; }
.choice-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

/* ============================================================================
   iOS "Add to Home Screen" install banner
   ============================================================================ */

.ios-install-banner {
    position: fixed;
    left: 12px;
    right: 12px;
    /* Sits above the mobile bottom nav bar so the two never overlap (see max-width:768px). */
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 90;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-left: 3px solid var(--navy);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
    font-size: 13px;
}

.ios-install-banner svg { display: inline-block; vertical-align: -2px; color: var(--text-2); }

.ios-install-banner-close {
    margin-left: auto;
    padding: 4px 8px;
    border: none;
    background: none;
    color: var(--text-3);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

/* ============================================================================
   Responsive
   ============================================================================ */

@media (min-width: 769px) {
    .mobile-nav { display: none; }
}

@media (max-width: 1100px) {
    .nav-user-name { display: none; }
}

@media (max-width: 1023px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-row { grid-template-columns: minmax(0, 1fr); }
    .detail-grid {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "head" "side" "desc" "comments";
        grid-template-rows: auto;
    }
}

@media (max-width: 768px) {
    :root { --gutter: 16px; }

    /* Phones: the navy top bar becomes a brand strip; navigation lives in the bottom bar */
    .nav { height: var(--nav-h-mobile); }
    .nav-links, .nav-user { display: none; }
    .nav-inner { justify-content: space-between; }
    .logo-dark { height: 20px; }
    .mobile-nav { display: flex; }

    #main-content {
        padding-top: var(--nav-h-mobile);
        padding-bottom: calc(var(--mnav-h) + env(safe-area-inset-bottom, 0px));
    }

    .page { padding: 20px var(--gutter) 32px; }
    .page-header { margin-bottom: 16px; align-items: flex-start; flex-wrap: wrap; }
    .page-header h1 { font-size: 22px; }
    .page-sub { font-size: 13px; }

    .kpi-grid { gap: 10px; }
    .kpi { padding: 14px; gap: 4px; }
    .kpi-value { font-size: 26px; }
    .kpi-value .kpi-unit { font-size: 15px; }
    .kpi-label { font-size: 10.5px; letter-spacing: 0.05em; }
    .kpi-foot { font-size: 11.5px; }
    .spark { width: 56px; }

    .dash, .dash-row { gap: 12px; }
    .card-head { padding: 16px 16px 0; }
    .card-body { padding: 14px 16px 16px; }
    .row-item { padding: 12px 16px; }
    .row-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
    .att-item {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-areas: "badge side" "main main";
        gap: 8px 10px;
    }
    .att-item > .badge { grid-area: badge; justify-self: start; }
    .att-item > .row-side { grid-area: side; justify-self: end; }
    .att-item > .row-main { grid-area: main; }
    .card-empty { margin: 14px 16px 16px; }

    /* Status chips: one swipeable line instead of three wrapped rows */
    .chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        margin: 0 calc(-1 * var(--gutter));
        padding: 0 var(--gutter) 2px;
        scrollbar-width: none;
        -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
        mask-image: linear-gradient(90deg, #000 85%, transparent);
    }
    .chips::-webkit-scrollbar { display: none; }
    .chip { flex-shrink: 0; }

    .ticket-card { padding: 14px 12px 14px 16px; gap: 8px; }
    .tc-subject { font-size: 15px; }

    .detail-head { padding: 18px 16px; }
    .detail-title { font-size: 19px; }
    .detail-topbar { margin: -4px 0 10px -8px; }
    .meta-list { padding: 2px 16px 6px; }
    .thread { padding: 14px 16px 4px; }
    .comment-form { margin: 12px 16px 16px; }
    .msg-body { max-width: 88%; }

    .form-row { grid-template-columns: minmax(0, 1fr); padding: 0 16px; }
    .form-group { padding: 16px 16px 0; }
    .form-actions { padding: 16px; }

    .ticket-detail-grid { grid-template-columns: minmax(0, 1fr); }
    .admin-detail-card { padding: 16px; }
    .admin-user-card { padding: 12px 16px; grid-template-columns: 32px minmax(0, 1fr); }
    .user-card-badges { grid-column: 2; }
    .routing-category-header, .routing-member, .routing-add, .activity-item { padding-left: 16px; padding-right: 16px; }
    .billing-usage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 12px 16px 16px; }
    .billing-summary { padding: 16px; }
    .billing-section h3 { padding: 14px 16px 4px; }
    .billing-table { padding: 0 16px 8px; }

    /* Clear the mobile bottom nav bar so the install banner doesn't overlap it */
    .ios-install-banner {
        bottom: calc(var(--mnav-h) + 12px + env(safe-area-inset-bottom, 0px));
    }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-nav {
        height: calc(var(--mnav-h) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ============================================================================
   Motion
   ============================================================================ */

@keyframes pageIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(12px) scale(0.99); }
    to   { opacity: 1; transform: none; }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Thin, quiet scrollbars on desktop */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(16, 24, 40, 0.14); border-radius: 4px; }

/* ============================================================================
   B-ADMIN: toasts, the status sheet, the owner line, People, Routing, Desks & SLA,
   All tickets. Same tokens as everything above; no new colours.
   ============================================================================ */

/* Toast (one at a time; role=status live region) */
.toast-region {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    z-index: 60; width: min(560px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
    display: flex; align-items: center; gap: 12px; pointer-events: auto;
    padding: 10px 10px 10px 16px; border-radius: var(--radius-sm);
    background: var(--navy); color: var(--chrome-ink); box-shadow: var(--shadow-pop);
    animation: fadeIn 0.15s ease-out both;
}
.toast-bad { background: var(--bad-fg); }
.toast-text { flex: 1; font-size: 14px; line-height: 1.4; }
.toast-undo {
    height: 32px; padding: 0 12px; border-radius: var(--radius-xs); border: 1px solid var(--accent);
    background: transparent; color: var(--accent); font-weight: 600; cursor: pointer;
}
.toast-bad .toast-undo { border-color: #fff; color: #fff; }
.toast-undo:hover { background: rgba(0, 234, 208, 0.12); }
.toast-close { width: 32px; height: 32px; border: none; background: transparent; color: var(--chrome-ink-2); font-size: 20px; cursor: pointer; border-radius: var(--radius-xs); }
.toast-bad .toast-close { color: #fff; }
.toast :focus-visible { outline-color: var(--accent); }
.toast-bad :focus-visible { outline-color: #fff; }

/* In-page note sheet for status changes (R-61) */
.sheet {
    margin-top: 14px; padding: 14px 16px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong); background: var(--surface-2);
}
.sheet-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.sheet-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.sheet textarea { width: 100%; resize: vertical; min-height: 84px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.field-error { margin-top: 6px; font-size: 13px; color: var(--bad-fg); }

/* Ticket header: owner chip + desk lead line (R-04) */
.owner-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 12px; font-size: 13px; color: var(--text-2); }
.owner-chip { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; background: var(--navy-bg); color: var(--navy-fg); font-weight: 600; border: 1px solid var(--navy-bd); }
.owner-chip.is-unowned { background: var(--bad-bg); color: var(--bad-fg); border-color: var(--bad-bd); }

/* Dashboard counts that open All tickets (R-05) */
.kpi-link, .cat-link, .work-link { cursor: pointer; text-decoration: none; color: inherit; }
.kpi-link:hover { box-shadow: var(--shadow-hover); }
.cat-link:hover .cat-name, .work-link:hover .work-label { text-decoration: underline; }

/* Admin tabs are real tabs now (R-85); one line, scrolling sideways on a phone */
.admin-tabs { overflow-x: auto; scrollbar-width: none; }
.admin-tab { white-space: nowrap; flex-shrink: 0; }
.admin-tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.admin-section { margin-bottom: 16px; }
.admin-section .card-head { align-items: flex-start; }
.inline-form { padding: 16px 20px; margin: 0 0 12px; }
.admin-section .inline-form { margin: 0; border-top: 1px solid var(--border); }
.inline-form-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.inline-form .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }

/* People */
.sync-strip {
    display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 14px; margin-bottom: 12px;
    border-radius: var(--radius-sm); background: var(--surface-3); font-size: 13px; color: var(--text-2);
}
.strip-bad { color: var(--bad-fg); font-weight: 600; }
.person-row {
    display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center;
    width: 100%; padding: 12px 20px; border: none; border-top: 1px solid var(--border);
    background: var(--surface); text-align: left; cursor: pointer;
}
.person-row:first-child { border-top: none; }
.person-row:hover { background: var(--surface-2); }
.person-row.is-off .person-name { color: var(--text-3); }
.person-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.person-name { font-weight: 600; font-size: 14px; }
.person-meta { font-size: 12.5px; color: var(--text-3); overflow-wrap: anywhere; }
.person-desks { display: flex; flex-wrap: wrap; gap: 4px; }
.person-badges { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; align-items: center; }
.person-head { display: flex; gap: 14px; align-items: center; margin: 8px 0 12px; }
.person-head h2 { margin: 0 0 2px; }
.person-head .person-badges { justify-content: flex-start; margin-top: 6px; }
.person-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.badge-level-superadmin { background: var(--navy); color: #fff; border-color: var(--navy); }
.badge-level-admin { background: var(--navy-bg); color: var(--navy-fg); border-color: var(--border-strong); }
.badge-level-requester { background: var(--neutral-bg); color: var(--neutral-fg); border-color: var(--neutral-bd); }
.chip-desk {
    display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px;
    font-size: 12px; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border);
}
.chip-lead { background: var(--navy-bg); color: var(--navy-fg); border-color: var(--border-strong); font-weight: 600; }
.chip-manager { background: var(--info-bg); color: var(--info-fg); border-color: var(--info-bd); }
.chip-x { border: none; background: transparent; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; min-width: 24px; min-height: 24px; }
.reassign-all { display: grid; gap: 12px; }
.reassign-desk { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.reassign-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.reassign-tickets { list-style: none; margin-top: 8px; display: grid; gap: 4px; font-size: 13px; color: var(--text-2); }
.reassign-tickets a { color: var(--link); font-weight: 500; }
.reassign-all > .btn { justify-self: start; }
.admin-log td { vertical-align: top; }

/* Routing: desks on the left, the person picker on the right; nothing collapses (R-17) */
.routing-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.routing-picker { position: sticky; top: calc(var(--nav-h) + 12px); padding: 16px; display: grid; gap: 8px; }
.routing-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.routing-hint { font-size: 13px; color: var(--text-3); }
#routing-desks { display: grid; gap: 10px; }
.desk-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-card); }
.desk-card.is-selected { border-color: var(--focus); box-shadow: 0 0 0 2px rgba(0, 116, 101, 0.18); }
.desk-card.is-retired { opacity: 0.75; }
.desk-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 12px 16px; }
.desk-check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 32px; }
.desk-check input, .member-row input, .pick-row input, .all-row input { width: 18px; height: 18px; accent-color: var(--focus); flex-shrink: 0; }
.desk-name { font-size: 15px; font-weight: 600; }
.desk-chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.chip-flag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 4px; font-size: 11.5px; font-weight: 600; background: var(--neutral-bg); color: var(--neutral-fg); }
.chip-sensitive { background: var(--warn-bg); color: var(--warn-fg); }
.chip-bad { background: var(--bad-fg); color: #fff; }
.desk-stats { flex-basis: 100%; font-size: 12.5px; color: var(--text-3); }
.stat-bad { color: var(--bad-fg); font-weight: 600; }
.stat-warn { color: var(--warn-fg); font-weight: 600; }
.handover { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 16px 10px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--warn-fg); font-size: 13px; }
.member-list { list-style: none; border-top: 1px solid var(--border); }
.member-row { display: grid; grid-template-columns: 18px 28px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 16px; border-top: 1px solid var(--grid); }
.member-row:first-child { border-top: none; }
.member-row.is-left .member-name { text-decoration: line-through; color: var(--text-3); }
.member-name { font-size: 13.5px; min-width: 0; overflow-wrap: anywhere; }
.member-load { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.member-empty { padding: 10px 16px; font-size: 13px; color: var(--text-3); }
.lead-toggle {
    height: 28px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 600; cursor: pointer;
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-3);
}
.lead-toggle[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.desk-managers { padding: 8px 16px 12px; font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border-top: 1px solid var(--grid); }
.picker-target { font-size: 13px; color: var(--text-2); }
.pick-group { display: grid; gap: 2px; margin-top: 4px; }
.pick-title { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); margin: 6px 0 2px; }
.pick-row { display: grid; grid-template-columns: 18px minmax(0, 1fr); column-gap: 10px; align-items: center; padding: 6px 4px; border-radius: var(--radius-xs); cursor: pointer; min-height: 40px; }
.pick-row:hover { background: var(--surface-2); }
.pick-name { font-size: 13.5px; font-weight: 500; }
.pick-meta { grid-column: 2; font-size: 12px; color: var(--text-3); }
.pick-empty { font-size: 13px; }
.picker-chosen { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12.5px; min-height: 8px; }
.picker-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

/* Desks & SLA */
.desk-table .input-cell { height: 34px; padding: 4px 8px; font-size: 13.5px; width: 100%; min-width: 120px; }
.desk-table tr.is-retired .input-cell { color: var(--text-3); }
.desk-table td { vertical-align: middle; }
.recipient-list { list-style: none; display: grid; gap: 6px; margin: 8px 0; }
.recipient-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13.5px; }
.recipient-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.recipient-add .input { flex: 1 1 220px; }

/* All tickets, grouped by owner (R-01/R-02/R-03) */
.all-filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; margin-bottom: 14px; }
.filter-field { display: grid; gap: 4px; font-size: 12px; font-weight: 500; color: var(--text-3); }
.bulk-bar {
    position: sticky; top: calc(var(--nav-h) + 8px); z-index: 5; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px;
    padding: 10px 14px; margin-bottom: 12px; border-radius: var(--radius-sm); background: var(--surface);
    border: 1px solid var(--border-strong); box-shadow: var(--shadow-hover);
}
.all-list { display: grid; gap: 12px; }
.owner-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-card); }
.owner-group.is-unowned { border-color: var(--bad-bd); border-left: 4px solid var(--bad-fg); }
.owner-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 14px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.owner-name { font-size: 15px; font-weight: 600; margin: 0; }
.owner-group.is-unowned .owner-name { color: var(--bad-fg); }
.owner-counts { display: flex; gap: 12px; font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.all-rows { list-style: none; }
.all-row { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 16px; border-top: 1px solid var(--grid); }
.all-row:first-child { border-top: none; }
.all-link { display: flex; gap: 8px; min-width: 0; text-decoration: none; color: var(--text); }
.all-link:hover .all-subject { text-decoration: underline; }
.all-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.all-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; font-size: 12px; }

@media (max-width: 1023px) {
    .routing-layout { grid-template-columns: 1fr; }
    .routing-picker { position: static; order: -1; }
}

@media (max-width: 768px) {
    .toast-region { bottom: calc(var(--mnav-h) + 12px + env(safe-area-inset-bottom, 0px)); }
    .person-row { grid-template-columns: 32px minmax(0, 1fr); padding: 12px 16px; }
    .person-row .person-badges { grid-column: 2; justify-content: flex-start; }
    .inline-form .form-row { grid-template-columns: 1fr; }
    .member-row { grid-template-columns: 18px minmax(0, 1fr) auto; }
    .member-row .avatar, .member-row .member-load { display: none; }
    .all-row { grid-template-columns: 18px minmax(0, 1fr); }
    .all-meta { grid-column: 2; justify-content: flex-start; }
    .all-subject { white-space: normal; }
    .bulk-bar { top: calc(var(--nav-h-mobile) + 8px); }
}


/* ============================================================================
   B-MI: the MI layer. Colours come from js/charts.js (the Bid Desk chart rules);
   here only layout and type. Chart text is 12 px at least.
   ============================================================================ */

.scope-label { font-size: 12px; font-weight: 500; color: var(--text-3); white-space: nowrap; }

.kpi-grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-def { font-size: 12px; line-height: 1.35; color: var(--text-3); border-top: 1px solid var(--grid); padding-top: 6px; margin-top: 2px; }
.kpi-foot strong { color: var(--text); font-variant-numeric: tabular-nums; }
.kpi-link { cursor: pointer; }
.mi-toggle {
    margin-left: auto; padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
    font: inherit; font-size: 12px; font-weight: 500; color: var(--link); cursor: pointer;
}
.mi-toggle:hover { background: var(--surface-2); }

/* Act now */
.act-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
.act-group { min-width: 0; border-left: 1px solid var(--grid); }
.act-group:first-child { border-left: 0; }
.act-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 14px 20px 8px; }
.act-title { font-size: 14px; font-weight: 600; color: var(--text); }
.act-count { margin-left: 6px; font-variant-numeric: tabular-nums; color: var(--text-3); }
.act-count.is-hot { color: var(--bad-fg); }
.act-more { font-size: 12px; font-weight: 400; color: var(--text-3); }
.card-link.inline { display: inline; padding: 0; background: none; border: 0; font: inherit; }
.owner-none { color: var(--bad-fg); font-weight: 600; }
.urg { font-weight: 500; }
.urg-critical { color: var(--bad-fg); }

/* Table + CSV twin */
.mi-data { position: relative; }
.mi-data .mi-csv { position: absolute; right: 0; top: 10px; font-size: 13px; background: none; border: 0; padding: 0; font-family: inherit; }
.mi-sub { margin: 18px 0 8px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.mi-note { margin: 8px 0 0; font-size: 12px; color: var(--text-3); }

/* Owner / desk league */
.mi-lg-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(40px, 1fr) repeat(3, 56px) 64px; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--grid); font-size: 14px; }
.mi-league.has-unowned .mi-lg-row { grid-template-columns: minmax(0, 1.4fr) minmax(40px, 1fr) repeat(4, 56px) 64px; }
.mi-lg-head { border-top: 0; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.mi-lg-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.mi-lg-bar { height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.mi-lg-bar span { display: block; height: 100%; border-radius: 4px; }
.mi-lg-row.is-unowned .mi-lg-name { color: var(--bad-fg); font-weight: 700; }
.mi-col { text-align: right; font-variant-numeric: tabular-nums; }
.mi-n.is-zero { color: var(--text-3); }
.mi-n.is-warn { color: var(--warn-fg); font-weight: 600; }
.mi-n.is-bad { color: var(--bad-fg); font-weight: 600; }
.mi-old { color: var(--text-3); font-size: 13px; }
button.mi-cellbtn, button.mi-namebtn, button.mi-chip, button.mi-bar-row {
    font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; text-align: inherit; cursor: pointer;
}
button.mi-namebtn { color: inherit; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.mi-cellbtn:hover, button.mi-namebtn:hover { text-decoration: underline; }
button.mi-cellbtn, button.mi-namebtn, button.mi-chip, button.mi-bar-row, .mi-cell { min-height: 24px; }
:is(button.mi-cellbtn, button.mi-namebtn, button.mi-chip, button.mi-bar-row, .mi-cell):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.mi-link:hover .mi-bar-name { text-decoration: underline; }

/* Bars (age bands, time in status) */
.mi-bar-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; padding: 7px 0; font-size: 14px; }
.mi-bar-name { color: var(--text-2); }
.mi-bar-track { display: block; height: 14px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.mi-bar { display: block; height: 100%; border-radius: 4px; }
.mi-bar-val { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; min-width: 40px; }
.mi-bar-n { font-weight: 400; color: var(--text-3); font-size: 12px; }

/* Funnel */
.mi-fun-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) 44px; align-items: center; gap: 10px; margin-bottom: 4px; }
.mi-fun-name { font-size: 14px; color: var(--text-2); }
.mi-fun-track { height: 28px; background: var(--surface-3); border-radius: 6px; overflow: hidden; }
.mi-fun-bar { height: 100%; display: flex; align-items: center; padding-left: 10px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; border-radius: 6px; min-width: 28px; }
.mi-fun-meta { text-align: right; font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.mi-fun-drop { grid-column: 2 / 4; font-size: 12px; color: var(--text-3); margin: -2px 0 6px; }

/* Deadlines calendar */
.mi-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.mi-chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; color: var(--text-2); background: var(--surface); }
.mi-chip.is-bad { border-color: var(--bad-bd); background: var(--bad-bg); color: var(--bad-fg); }
.mi-week { display: grid; grid-template-columns: 84px minmax(0, 1fr); align-items: center; gap: 8px; margin-bottom: 4px; }
.mi-wk { font-size: 12px; color: var(--text-3); text-align: left; }
.mi-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.mi-dn { font-size: 12px; color: var(--text-3); text-align: center; }
.mi-cell { height: 32px; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 6px; font: inherit; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
button.mi-cell { cursor: pointer; }
button.mi-cell:hover { box-shadow: inset 0 0 0 2px var(--navy); }
.mi-cell.is-past { background: repeating-linear-gradient(45deg, var(--surface-3), var(--surface-3) 4px, var(--surface) 4px, var(--surface) 8px); }
.mi-key { display: flex; align-items: center; gap: 3px; margin-top: 8px; font-size: 12px; color: var(--text-3); justify-content: flex-end; }
.mi-key i { width: 16px; height: 10px; border-radius: 2px; display: inline-block; }

@media (min-width: 1024px) and (max-width: 1280px) {
    .act-groups { grid-template-columns: 1fr; }
    .act-group { border-left: 0; border-top: 1px solid var(--grid); }
    .act-group:first-child { border-top: 0; }
}
@media (max-width: 1023px) {
    .kpi-grid-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .act-groups { grid-template-columns: 1fr; }
    .act-group { border-left: 0; border-top: 1px solid var(--grid); }
    .act-group:first-child { border-top: 0; }
}
@media (max-width: 768px) {
    .act-head { padding: 12px 16px 6px; }
    .mi-lg-row, .mi-league.has-unowned .mi-lg-row { grid-template-columns: minmax(0, 1fr) repeat(3, 38px); gap: 6px; }
    .mi-league.has-unowned .mi-lg-row { grid-template-columns: minmax(0, 1fr) repeat(4, 34px); }
    .mi-league.has-unowned .mi-col:last-child { display: none; }
    .mi-lg-bar, .mi-old, .mi-lg-head .mi-col:last-child { display: none; }
    .mi-bar-row { grid-template-columns: 92px minmax(0, 1fr) auto; }
    .mi-fun-row { grid-template-columns: 82px minmax(0, 1fr) 38px; }
    .mi-week { grid-template-columns: 62px minmax(0, 1fr); }
    .mi-cell { height: 30px; }
    .mi-data .mi-csv { top: 8px; }
}

button.cat-row { width: 100%; background: none; border: 0; border-top: 1px solid var(--grid); font: inherit; color: inherit; text-align: left; cursor: pointer; border-radius: 0; }
button.cat-row:hover .cat-name { text-decoration: underline; }
li > button.cat-row { padding: 8px 0; }
.mi-league.has-unowned .mi-lg-row { grid-template-columns: minmax(0, 1fr) repeat(4, 72px) 60px; }
.mi-league.has-unowned .mi-lg-bar { display: none; }
@media (max-width: 768px) {
    .mi-league.has-unowned .mi-lg-row { grid-template-columns: minmax(0, 1fr) repeat(4, 38px); }
}
@media (max-width: 768px) {
    .mi-league.has-unowned .mi-lg-row { grid-template-columns: minmax(0, 1fr) repeat(4, 58px); gap: 2px; }
    .mi-lg-head { text-transform: none; letter-spacing: 0; }
}
.dash-row.dash-row-1 { grid-template-columns: minmax(0, 1fr); }
