/* PLAN.md 7.1 (SPEC.md §16): app shell theming. Light/dark via CSS custom
   properties keyed off [data-theme] (set by wwwroot/js/theme.js — see its
   own comment for why this is JS interop rather than pure Blazor), plus a
   configurable --accent custom property the org's admin sets (Phase 7.5's
   branding endpoint, wired at startup via OrgBrandingService). Logical
   properties (margin-inline-start, not margin-left) throughout so the RTL
   scaffolding SPEC.md §16 asks for actually works once a right-to-left
   culture exists, not just in principle.

   Audit finding ("premium/2026, not 2000"): visual pass across the whole
   sheet — refined color palette (softer neutrals instead of flat grays),
   card surfaces on shadow rather than heavy borders, a real type scale,
   consistent radius/shadow tokens, table/nav polish, smoother transitions.
   Every existing class name and custom property is unchanged — this is a
   styling pass, not a markup rewrite, so every .razor file that already
   references .btn/.campaign-table/.stat-card/etc. needed zero changes. */

:root {
    --accent: #1b6ec2;
    --bg: #ffffff;
    --bg-elevated: #f8f9fb;
    --bg-sunken: #f1f2f5;
    --text: #14171f;
    --text-muted: #6b7280;
    --border: #e4e6eb;
    --border-strong: #d4d7de;
    --danger: #c0293d;
    --success: #1f8a4c;
    --warning: #9a6b00;

    --radius-sm: 0.4rem;
    --radius-md: 0.65rem;
    --radius-lg: 0.9rem;
    --shadow-sm: 0 1px 2px rgba(20, 23, 31, 0.05);
    --shadow-md: 0 4px 12px rgba(20, 23, 31, 0.06), 0 1px 2px rgba(20, 23, 31, 0.04);
    --shadow-focus: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);

    /* Dashboard chart palette (PLAN.md 7.3 redesign, refined to match the
       reference "RLYT" screenshots the org owner supplied): stat-card icon
       badges use a small set of distinct pastel accent hues (one per
       card), while the donut ("traffic by channel") uses --chart-blue-N,
       a monochrome blue ramp from dark to light — that's what the
       reference actually does (its stat icons are multi-hue, its donut
       segments are all blue shades). Theme-independent since these color a
       dataset series, not app chrome. */
    --chart-1: #2563eb;
    --chart-2: #7c3aed;
    --chart-3: #0d9488;
    --chart-4: #ea580c;
    --chart-5: #64748b;

    --chart-blue-1: #1e3a8a;
    --chart-blue-2: #2563eb;
    --chart-blue-3: #3b82f6;
    --chart-blue-4: #60a5fa;
    --chart-blue-5: #93c5fd;
    --chart-blue-6: #bfdbfe;
    --chart-blue-other: #94a3b8;

    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

:root[data-theme="dark"] {
    --bg: #0e1015;
    --bg-elevated: #16191f;
    --bg-sunken: #1c1f27;
    --text: #eceef3;
    --text-muted: #8b93a3;
    --border: #262b34;
    --border-strong: #333944;
    --danger: #e5697d;
    --success: #4cc985;
    --warning: #e0b04d;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-focus: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

h1, h2, h3 {
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.25;
}

h1 {
    font-size: 1.5rem;
}

h2 {
    font-size: 1.05rem;
    margin-block: 0 0.9rem;
}

a {
    color: var(--accent-text, var(--accent));
}

h1:focus {
    outline: none;
}

/* PLAN.md 7.7: visually hidden until keyboard-focused, matching the
   standard "skip to main content" pattern — lets a keyboard user bypass
   the sidebar nav on every page load without a sighted user ever seeing it. */
.skip-link {
    position: absolute;
    inset-inline-start: -999px;
    top: auto;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    z-index: 1001;
}

.skip-link:focus {
    inset-inline-start: 0.5rem;
    top: 0.5rem;
    inline-size: auto;
    block-size: auto;
    padding: 0.5rem 1rem;
    background: var(--bg);
    border: 2px solid var(--accent);
    border-radius: var(--radius-sm);
    color: var(--text);
}

button, input, select {
    font: inherit;
    color: inherit;
}

input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--accent);
    inline-size: 1rem;
    block-size: 1rem;
}

/* Audit finding ("premium/2026, not 2000"): plain state text (Active,
   Paused, Deactivated, ...) scattered across four different tables read as
   flat and dated next to everything else's new card/shadow treatment —
   pill badges are the standard modern-SaaS convention for exactly this
   ("at a glance" status), and the dot + tinted-background + colored-text
   combination reads clearly in both themes without needing per-status
   icons. */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.badge::before {
    content: "";
    inline-size: 0.4rem;
    block-size: 0.4rem;
    flex-shrink: 0;
    border-radius: 999px;
    background: currentColor;
}

.badge-success {
    background: color-mix(in srgb, var(--success) 15%, transparent);
    color: var(--success);
}

.badge-muted {
    background: var(--bg-sunken);
    color: var(--text-muted);
}

.badge-warning {
    background: color-mix(in srgb, var(--warning) 18%, transparent);
    color: var(--warning);
}

.badge-danger {
    background: color-mix(in srgb, var(--danger) 15%, transparent);
    color: var(--danger);
}

/* Consistent "title + primary actions" row at the top of a page, instead
   of every page inventing its own spacing between <h1> and the buttons
   underneath it. */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-block-end: 1.5rem;
}

.page-header h1 {
    margin: 0;
}

.page-subtitle {
    margin: 0.2rem 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.page-header .btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.95rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg);
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover:not(:disabled) {
    background: var(--bg-elevated);
    border-color: var(--text-muted);
}

/* Audit finding: several actions across the dashboard (Edit, bulk QR
   download, CSV export, ...) are <a class="btn"> rather than <button
   class="btn"> — they navigate/download rather than run a click handler.
   The browser's own UA stylesheet styles links via an :any-link-family
   pseudo-class, which outranks a single plain class selector like .btn on
   specificity, so those anchors kept their default underline and link
   color despite already having .btn's box/border/background — reading as
   a mix of "real buttons" and "underlined text in a box" side by side
   instead of one consistent control. This second, more specific rule
   forces every .btn to look identical regardless of the tag it's on. */
a.btn {
    color: var(--text);
    text-decoration: none;
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-foreground, #fff);
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(1.07);
    border-color: var(--accent);
}

a.btn-primary {
    color: var(--accent-foreground, #fff);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-block-end: 1rem;
}

.field label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Audit finding: required form fields ([Required] on the model) had no
   visible cue at all — a user only learned a field was mandatory after
   submitting and getting a validation error back. aria-hidden since the
   input's own aria-required (set alongside this in markup) is what
   actually announces it to assistive tech; this asterisk is a sighted-user
   affordance only. */
.required-indicator {
    color: var(--danger);
    margin-inline-start: 0.15rem;
}

.field input,
.field textarea,
.field select {
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.field textarea {
    resize: vertical;
}

.field input:focus-visible,
.field textarea:focus-visible,
.field select:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--shadow-focus);
}

.field.field-inline,
.field-inline {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.inline-label {
    margin: 0;
}

.error-message {
    color: var(--danger);
    font-size: 0.88rem;
}

/* Audit finding: EditForm/DataAnnotationsValidator was already used on
   Login.razor but nothing styled the .validation-message elements it
   renders, and no page had a ValidationSummary — so client-side
   validation feedback existed in the framework but not visibly on
   screen. */
.validation-message {
    display: block;
    color: var(--danger);
    font-size: 0.83rem;
    margin-block-start: 0.2rem;
}

.validation-errors {
    color: var(--danger);
    font-size: 0.88rem;
    margin: 0 0 1rem;
    padding-inline-start: 1.2rem;
}

/* Shell layout */
.page {
    display: flex;
    min-height: 100vh;
}

/* Audit finding ("I like this" — reference dashboard has a dark-navy
   sidebar regardless of the rest of the app's theme): scoped custom
   properties on .sidebar itself, not read from :root/[data-theme], so the
   sidebar stays the same dark surface whether the app-wide toggle
   (ThemeService, top-row button) is set to light or dark. Everything below
   reads --sidebar-* instead of the app-wide --bg/--text tokens. */
.sidebar {
    --sidebar-bg: #0a0c10;
    --sidebar-bg-elevated: #15171d;
    --sidebar-border: #1e2028;
    --sidebar-text: #9aa1b3;
    --sidebar-text-strong: #f4f5f8;

    inline-size: 15rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg);
    border-inline-end: 1px solid var(--sidebar-border);
    padding: 1.25rem 0.9rem;
    color: var(--sidebar-text);
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding-block-end: 1.1rem;
    margin-block-end: 1.1rem;
    border-block-end: 1px solid var(--sidebar-border);
    color: var(--sidebar-text-strong);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.sidebar .brand img {
    block-size: 1.75rem;
    inline-size: auto;
    border-radius: 0.3rem;
}

.brand-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    inline-size: 1.75rem;
    block-size: 1.75rem;
    border-radius: 0.45rem;
    background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 65%, #000));
    color: var(--accent-foreground, #fff);
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* Real single-signal health widget (SystemStatusService -> the API's own
   /health endpoint) — see MainLayout's own comment on why this isn't the
   reference's fabricated per-service checklist. Pushed to the bottom of
   the sidebar via margin-block-start: auto now that .sidebar is a flex
   column. */
.sidebar-status {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-block-start: auto;
    padding: 0.75rem 0.85rem;
    border-radius: var(--radius-md);
    background: var(--sidebar-bg-elevated);
    border: 1px solid var(--sidebar-border);
    color: var(--sidebar-text-strong);
    font-size: 0.82rem;
    font-weight: 600;
}

.status-dot {
    inline-size: 0.55rem;
    block-size: 0.55rem;
    border-radius: 999px;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 20%, transparent);
}

.status-dot-ok {
    background: var(--success);
    color: var(--success);
}

.status-dot-down {
    background: var(--danger);
    color: var(--danger);
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    margin-block-end: 0.25rem;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.nav-icon {
    inline-size: 1.1rem;
    block-size: 1.1rem;
    flex-shrink: 0;
}

.nav-icon svg {
    inline-size: 100%;
    block-size: 100%;
}

.sidebar nav a:hover {
    background: var(--sidebar-bg-elevated);
    color: var(--sidebar-text-strong);
}

.sidebar nav a.active {
    background: var(--accent);
    color: var(--accent-foreground, #fff);
    font-weight: 600;
}

.main-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-inline-size: 0;
}

.top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.75rem;
    border-block-end: 1px solid var(--border);
    background: var(--bg);
}

.top-row .signed-in-as {
    color: var(--text-muted);
    font-size: 0.88rem;
}

.top-row-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

/* Reference dashboard's top-bar search field, wired to a real campaign
   name search (Campaigns.razor's existing filter, via ?search=) rather
   than being purely decorative — see MainLayout's own comment. */
.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    max-inline-size: 26rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background: var(--bg-elevated);
    color: var(--text-muted);
}

.search-box svg {
    inline-size: 1rem;
    block-size: 1rem;
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    min-inline-size: 0;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.88rem;
}

.search-box input:focus-visible {
    outline: none;
}

.search-box kbd {
    flex-shrink: 0;
    padding: 0.1rem 0.4rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-family: inherit;
}

/* Audit finding (reference dashboard's top-bar user chip): a bare "Signed
   in as {email}" text line read flat next to the rest of the redesign.
   Initials-only avatar — no external avatar/gravatar service, since CSP is
   self-src-only and no such service exists in this app's data model
   anyway (UserDisplay.Initials derives purely from the real email). Now a
   <summary> (see .avatar-menu below) rather than a plain div, so it also
   works as the avatar-dropdown's trigger. */
.user-menu {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    cursor: pointer;
    list-style: none;
}

.user-menu::-webkit-details-marker {
    display: none;
}

/* Avatar-triggered dropdown (Account settings / Sign out) — a native
   <details>/<summary> element needs no click-outside-to-close JS of its
   own; the trade-off (it only closes again via another click on the
   summary, not a click elsewhere) is an acceptable one for a two-item
   menu. */
.avatar-menu {
    position: relative;
}

.dropdown-panel {
    position: absolute;
    inset-inline-end: 0;
    top: calc(100% + 0.4rem);
    min-inline-size: 11rem;
    display: flex;
    flex-direction: column;
    padding: 0.35rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 10;
}

.dropdown-item {
    display: block;
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius-sm);
    border: none;
    background: none;
    color: var(--text);
    font-size: 0.88rem;
    text-align: start;
    text-decoration: none;
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--bg-elevated);
}

.avatar {
    inline-size: 2rem;
    block-size: 2rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-foreground, #fff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.user-meta .user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    max-inline-size: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-meta .user-role {
    font-size: 0.74rem;
    color: var(--text-muted);
}

/* Audit finding (visual match to the reference dashboard): the reference
   uses the full remaining viewport width next to its sidebar — no
   artificial content cap — so stat cards/charts spread out across wide
   monitors instead of clustering in a centered column. Removed the old
   72rem cap to match. */
.content {
    flex: 1;
    padding: 1.75rem;
}

.centered-auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
    background: var(--bg-sunken);
}

.auth-card {
    inline-size: min(24rem, 100%);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2.25rem;
}

.auth-card .brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    justify-content: center;
    margin-block-end: 1.5rem;
    font-weight: 600;
}

.auth-card .brand img {
    block-size: 2rem;
    inline-size: auto;
    border-radius: 0.35rem;
}

.auth-card h1 {
    font-size: 1.2rem;
    text-align: center;
    margin-block: 0 1.5rem;
}

.setup-step-indicator {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.83rem;
    margin-block-start: -1rem;
    margin-block-end: 1.25rem;
}

.setup-channel-list {
    list-style: none;
    margin: 0 0 1.5rem;
    padding: 0;
    display: grid;
    gap: 0.4rem;
}

.setup-channel-list li {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
}

.field small {
    display: block;
    color: var(--text-muted);
    margin-block-start: 0.3rem;
}

/* Framework chrome */
#blazor-error-ui {
    /* Audit finding: this banner deliberately stays a light warning strip
       in both themes (color-scheme: light only already pins that), but
       with no explicit `color` it inherited body's var(--text) — near-
       white in dark mode, unreadable against lightyellow. Pinned
       alongside the background it's actually meant to be read against,
       not left to the app theme it's intentionally opting out of. */
    color: #1a1d23;
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    inset-inline-start: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    inset-inline-end: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    padding: 1rem;
    color: #fff;
    background: var(--danger);
    border-radius: var(--radius-sm);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

.initial-loading {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-progress {
    width: 4rem;
    height: 4rem;
}

.loading-progress circle {
    fill: none;
    stroke: var(--border);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

/* Audit finding: colored (magenta/pink) inline-code text visually clashed
   with an admin-configured accent color landing in a similar hue (a real
   branding combination reported live) — two different pinks sitting next
   to each other read as uncoordinated rather than intentional. Restyled
   as a neutral background pill (the common convention for inline code —
   GitHub, most docs sites) instead of colored text: it can't clash with
   *any* accent color since it never uses one, and reuses --bg-elevated/
   --text, both already verified for contrast in both themes. */
code {
    background: var(--bg-sunken);
    color: var(--text);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.85em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Campaign list (PLAN.md 7.2) */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    margin-block-end: 1.25rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.filter-bar .field {
    margin-block-end: 0;
}

.filter-bar select,
.filter-bar input[type="date"] {
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--bg);
    color: var(--text);
}

.status-checkboxes {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.status-checkboxes label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.88rem;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
}

.campaign-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.campaign-table th,
.campaign-table td {
    text-align: start;
    padding: 0.75rem 1rem;
    border-block-end: 1px solid var(--border);
}

.campaign-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--bg-elevated);
}

.campaign-table tbody tr {
    transition: background-color 0.1s ease;
}

.campaign-table tbody tr:hover {
    background: var(--bg-elevated);
}

.campaign-table tbody tr:last-child td {
    border-block-end: none;
}

/* Dashboard home (PLAN.md 7.3) */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: 1rem;
    margin-block: 1.5rem;
}

/* PLAN.md/SPEC.md §5: campaign/channel side-by-side comparison view. */
.compare-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    gap: 1rem;
    margin-block-end: 1.5rem;
}

.compare-slot {
    padding: 1.1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.compare-slot h2 {
    margin-block-start: 0;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 1.15rem 1.25rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

.stat-card-icon {
    inline-size: 2.4rem;
    block-size: 2.4rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card-icon svg {
    inline-size: 1.15rem;
    block-size: 1.15rem;
}

.stat-card-icon-1 { background: color-mix(in srgb, var(--chart-1) 15%, transparent); color: var(--chart-1); }
.stat-card-icon-2 { background: color-mix(in srgb, var(--chart-2) 15%, transparent); color: var(--chart-2); }
.stat-card-icon-3 { background: color-mix(in srgb, var(--chart-3) 18%, transparent); color: var(--chart-3); }
.stat-card-icon-4 { background: color-mix(in srgb, var(--chart-4) 15%, transparent); color: var(--chart-4); }
.stat-card-icon-5 { background: color-mix(in srgb, var(--chart-5) 15%, transparent); color: var(--chart-5); }

.stat-value {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.82rem;
    margin-block-start: 0.15rem;
}

.stat-delta {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.76rem;
    font-weight: 600;
    margin-block-start: 0.35rem;
}

.stat-delta-up {
    color: var(--success);
}

.stat-delta-down {
    color: var(--danger);
}

/* Dashboard home charts row (PLAN.md 7.3 redesign): "Clicks over time"
   line chart alongside "Traffic by channel" donut, matching the reference
   layout's proportions (chart wider than the legend/donut column). Below
   the breakpoint they stack, same reasoning as every other two-column
   section in this file. */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 1.25rem;
    margin-block-end: 1.25rem;
    align-items: stretch;
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    padding: 1.25rem 1.4rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    min-inline-size: 0;
}

.panel-stack {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-inline-size: 0;
}

.panel-row-even {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-block-end: 1.25rem;
}

@media (max-width: 900px) {
    .panel-row-even {
        grid-template-columns: 1fr;
    }
}

.status-panel-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 600;
    margin-block-end: 0.75rem;
}

.chart-card h2 {
    margin-block-start: 0;
}

.line-chart {
    inline-size: 100%;
    block-size: auto;
    overflow: visible;
}

.line-chart-grid {
    stroke: var(--border);
    stroke-width: 1;
}

.line-chart-area {
    fill: color-mix(in srgb, var(--accent) 14%, transparent);
    stroke: none;
}

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

.line-chart-axis-label {
    fill: var(--text-muted);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

.donut-chart-wrap {
    display: flex;
    align-items: center;
    gap: 1.4rem;
    flex-wrap: wrap;
}

.donut-chart-frame {
    position: relative;
    flex-shrink: 0;
}

.donut-chart circle {
    transition: stroke-dasharray 0.2s ease;
}

.donut-chart-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    pointer-events: none;
}

.donut-chart-total {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.donut-chart-total-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.donut-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.55rem;
    flex: 1;
    min-inline-size: 8rem;
}

.donut-legend li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

/* An <svg><circle fill="..."/></svg> in markup, not a CSS div with an
   inline background — same style-src reasoning as MiniBar.razor. */
.donut-legend-dot {
    inline-size: 0.6rem;
    block-size: 0.6rem;
    flex-shrink: 0;
}

.donut-legend-name {
    flex: 1;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.donut-legend-value {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* "Recent activity" feed (real audit-log data, SPEC.md §14: "no separate
   activity feed feature — the audit log already serves this purpose") —
   restyled with per-entry icon bubbles instead of a bare table row, to
   match the reference layout's activity panel. */
.activity-feed {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
}

.activity-feed li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.65rem 0;
    border-block-end: 1px solid var(--border);
}

.activity-feed li:last-child {
    border-block-end: none;
    padding-block-end: 0;
}

.activity-icon {
    inline-size: 2rem;
    block-size: 2rem;
    border-radius: 999px;
    background: var(--bg-sunken);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 700;
}

.activity-body {
    flex: 1;
    min-inline-size: 0;
}

.activity-title {
    font-size: 0.87rem;
    color: var(--text);
}

.activity-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-block-start: 0.1rem;
}

/* Campaign detail (PLAN.md 7.4) */

/* Audit finding: style-src 'self' (Phase 2.9's strict CSP, no
   unsafe-inline/hash mechanism for this SPA's dynamic markup) silently
   blocks any style="width:X%" attribute a Blazor component renders —
   confirmed live (getComputedStyle showed width: none on every one of
   these). Replaced by the MiniBar.razor component, an SVG rect whose
   width is a geometry attribute rather than a CSS property, so it's
   outside style-src's reach — see that file's own comment. */
.mini-bar {
    display: block;
    inline-size: 100%;
    block-size: 0.6rem;
    margin-block-end: 0.3rem;
}

.mini-bar-track {
    fill: var(--bg-sunken);
}

.mini-bar-fill {
    transition: width 0.2s ease;
}

.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-block-end: 1.5rem;
}

.bar-row {
    display: grid;
    grid-template-columns: 8rem 1fr 3rem;
    align-items: center;
    gap: 0.6rem;
}

.bar-label {
    font-size: 0.84rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bar-value {
    font-size: 0.84rem;
    font-weight: 500;
    text-align: end;
}

.hint-ok {
    color: var(--success);
}

.loading-text {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Organization settings (PLAN.md 7.5) */
.settings-section {
    padding: 1.4rem 1.5rem;
    margin-block-end: 1.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.settings-section h2 {
    margin-block-start: 0;
}

/* Audit finding: no responsive rules existed anywhere in this file — the
   sidebar's fixed 15rem width plus every data table's natural width
   combined to overflow a narrow viewport horizontally (confirmed:
   613px of content in a 375px viewport), making the dashboard unusable
   on a phone. Below this breakpoint the sidebar becomes a horizontal nav
   strip above the content instead of a column beside it (only 4 links,
   so this reads better than a hamburger-menu overlay would for a nav
   this small — same reasoning `.field-inline` already applies elsewhere:
   the simplest layout that fits the actual amount of content), and every
   data table scrolls horizontally within itself rather than stretching
   the page. */
@media (max-width: 640px) {
    .page {
        flex-direction: column;
    }

    .sidebar {
        inline-size: 100%;
        border-inline-end: none;
        border-block-end: 1px solid var(--border);
        padding: 0.75rem;
    }

    .sidebar .brand {
        padding-block-end: 0.75rem;
        margin-block-end: 0.75rem;
    }

    .sidebar nav {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .sidebar nav a {
        margin-block-end: 0;
    }

    .top-row {
        flex-wrap: wrap;
        justify-content: flex-start;
        padding: 0.75rem 1rem;
    }

    .search-box {
        max-inline-size: 100%;
        order: 2;
        inline-size: 100%;
    }

    .top-row-actions {
        order: 1;
        margin-inline-start: auto;
    }

    .content {
        padding: 1rem;
    }

    .campaign-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* .field-inline rows (every "add a new X" row — channels, short
       domains, IP allowlist, invites, webhooks) pack 2-3 bare <input>s
       plus a button on one non-wrapping flex line with no width limit on
       the inputs, which is exactly what pushed the page wider than the
       viewport even after the table/sidebar fixes above. */
    .field-inline {
        flex-wrap: wrap;
    }

    .field-inline input,
    .field-inline select {
        flex: 1 1 10rem;
        min-inline-size: 0;
    }

    /* The email/role text next to the avatar is the first thing to give
       up its space once .top-row wraps on a phone-width viewport — the
       avatar alone (already used everywhere else as the compact identity
       affordance) is enough context there. */
    .user-meta {
        display: none;
    }
}
