/* Mockarty Cloud — embedded design system.
 * Tokens imported from internal/designsystem/css/tokens.css.
 * The same tokens power the on-prem admin, so any visual retune
 * there propagates here automatically on next rebuild.
 *
 * Dark mode is class-based (.light / .dark on <html>) — the
 * main admin app uses the same pattern. prefers-color-scheme
 * would force a user with a system dark preference into dark
 * mode even when they explicitly chose light; the class-based
 * model lets the toggle in the user menu override the system.
 *
 * a11y notes (this stylesheet is read top-to-bottom):
 *   - Focus rings use --focus-ring (3px accent halo). Visible
 *     only on :focus-visible, never on click.
 *   - Color-mix tints are used for status backgrounds; they
 *     work in both themes without separate dark variants.
 *   - prefers-reduced-motion disables the few transitions.
 */

/* ---------- Theme application ----------
 * The .light / .dark classes on <html> are added by app.js
 * (theme toggle + cookie persistence). Default to the user's
 * system preference if no explicit choice has been persisted.
 * The cascade order is:
 *   1. .light / .dark (explicit) — wins
 *   2. prefers-color-scheme: dark (system) — fallback
 *   3. :root defaults — light
 */

:root, .light, html:not(.dark) {
    /* The full token set is defined in tokens.css above; this
     * file consumes them. We re-declare nothing — tokens are
     * the single source of truth. */
}

html.boot-pending body {
    visibility: hidden;
}

/* ---------- Cloud-local accent CHIP tokens ----------
 * The shared --accent-light tint is intentionally faint (a soft selection
 * wash). For an accent BADGE/active-pill, accent-coloured TEXT on that faint
 * tint failed WCAG AA in light (2.98:1). These cloud-scoped variables give the
 * accent chip a readable recipe in BOTH themes WITHOUT mutating the shared
 * tokens: a slightly deeper accent-tinted background, and a text tone derived
 * from the accent — darkened toward black in light (AA on the tint), kept as the
 * bright accent in dark (already ~6.5:1 on the dark base). Derived from
 * --accent-color via color-mix, so a brand-accent change still propagates.
 */
.light, html:not(.dark) {
    --cw-chip-bg: color-mix(in srgb, var(--accent-color) 18%, var(--bg-primary));
    /* Deep accent (accent-hover toward black) — 6.6:1 on the chip tint. A
       lighter accent on this pale tint only reached ~4:1 (the tint is bluish,
       so luminance separation needs a genuinely deep text). */
    --cw-chip-text: color-mix(in srgb, var(--accent-hover) 70%, #000);

    /* ── Cloud craft tokens (light) — all derived from brand tokens ──────────
       These are the cloud cabinet's visual-craft layer: the values the
       shared design-system tokens don't pin (the page's ambient backdrop, the
       elevated console surfaces, the hairline weights, the segmented-nav fill,
       the hero mesh). Every value is derived via color-mix from --accent-color
       / --bg-* so a brand or theme retune still propagates. Nothing here
       changes the MEANING of a shared token. */
    --cw-page-bg: var(--bg-secondary);
    /* App shell surface: cards/header sit a touch above the page so the
       console reads as layered, not flat. */
    --cw-surface: var(--bg-primary);
    --cw-surface-sunken: color-mix(in srgb, var(--bg-secondary) 70%, var(--bg-tertiary));
    /* A hairline a shade softer than the hard --border-color, for interior
       row dividers where the full border would read too heavy. */
    --cw-hairline: color-mix(in srgb, var(--border-color) 60%, transparent);
    /* Segmented nav track + the active pill fill. */
    --cw-seg-track: color-mix(in srgb, var(--bg-tertiary) 55%, var(--bg-secondary));
    --cw-seg-active: var(--bg-primary);
    /* Hero — the auth split panel. A confident accent wash + the request/
       response mesh strokes. */
    --cw-hero-bg: linear-gradient(155deg,
        color-mix(in srgb, var(--accent-color) 13%, var(--bg-primary)) 0%,
        color-mix(in srgb, var(--accent-color) 5%, var(--bg-secondary)) 55%,
        var(--bg-secondary) 100%);
    --cw-hero-stroke: color-mix(in srgb, var(--accent-color) 30%, transparent);
    --cw-hero-stroke-strong: color-mix(in srgb, var(--accent-color) 55%, transparent);
    --cw-hero-text: var(--text-secondary);
    --cw-hero-method: var(--accent-hover);
    --cw-hero-ok: var(--success-text);
    /* Card top-accent rail (signature on primary cards). */
    --cw-rail: linear-gradient(90deg, var(--accent-color), color-mix(in srgb, var(--accent-color) 40%, var(--accent-purple)));
}
.dark {
    --cw-chip-bg: color-mix(in srgb, var(--accent-color) 18%, var(--bg-primary));
    --cw-chip-text: var(--accent-color);

    /* ── Cloud craft tokens (dark) ── */
    --cw-page-bg: var(--bg-primary);
    --cw-surface: var(--bg-secondary);
    --cw-surface-sunken: color-mix(in srgb, var(--bg-primary) 60%, var(--bg-tertiary));
    --cw-hairline: color-mix(in srgb, var(--border-color) 70%, transparent);
    --cw-seg-track: color-mix(in srgb, var(--bg-tertiary) 60%, var(--bg-primary));
    --cw-seg-active: var(--bg-tertiary);
    --cw-hero-bg: linear-gradient(155deg,
        color-mix(in srgb, var(--accent-color) 16%, var(--bg-secondary)) 0%,
        color-mix(in srgb, var(--accent-color) 6%, var(--bg-primary)) 55%,
        var(--bg-primary) 100%);
    --cw-hero-stroke: color-mix(in srgb, var(--accent-color) 32%, transparent);
    --cw-hero-stroke-strong: color-mix(in srgb, var(--accent-color) 60%, transparent);
    --cw-hero-text: var(--text-secondary);
    --cw-hero-method: var(--accent-color);
    --cw-hero-ok: var(--success-text);
    --cw-rail: linear-gradient(90deg, var(--accent-color), color-mix(in srgb, var(--accent-color) 45%, var(--accent-purple)));
}

html:not(.light):not(.dark) {
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    html:not(.light):not(.dark) {
        color-scheme: dark;
    }
}

/* ---------- Base / reset ---------- */

* { box-sizing: border-box; }

/* The `hidden` attribute must always win. Author element rules like
   `button { display: inline-flex }` (below) out-specify the UA `[hidden]`
   rule, so a `<button hidden>` (forgot-password in signup, the gated operator
   tab, the cancel/reactivate sub-buttons) would stay visible. This restores
   the intended behaviour for every hidden element in one place. */
[hidden] { display: none !important; }

html { zoom: var(--ui-scale, 1); }

body {
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: var(--font-base);
    background: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    line-height: 1.5;
    min-height: var(--vh100);
}

a {
    color: var(--accent-color);
    text-decoration: none;
}
a:hover { text-decoration: underline; }
a:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ---------- Skip-link (a11y) ----------
 * The first interactive element on every page. Pressing Tab on
 * load jumps focus here; pressing Enter scrolls the user past
 * the navigation. Hidden by default, revealed on focus.
 */

/* Visually hidden but accessible to screen readers — used for icon-only
 * buttons (notif bell, theme switcher) so the visible emoji is paired
 * with an accessible name. */
.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;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    padding: var(--space-3) var(--space-4);
    background: var(--accent-color);
    color: var(--accent-contrast);
    font-weight: var(--font-weight-semibold);
    z-index: var(--z-toast, 100000);
    border-radius: 0 0 var(--radius-md) 0;
}
.skip-link:focus {
    left: 0;
    outline: 2px solid var(--accent-contrast);
    outline-offset: -2px;
}

/* ---------- App shell (auth + dashboard) ---------- */

body.auth-page {
    /* The colour is declared separately from the gradients on purpose: the
       `background` shorthand resets background-color to transparent, and the
       body's box here is shorter than the viewport, so the strip below it fell
       through to the browser canvas as a visible seam (measured: section.auth
       ends at 837px in a 900px viewport). A body background-COLOUR propagates
       to the canvas and paints the whole page; the gradients keep sitting on
       top of it. This is the first screen a beta user sees. */
    background-color: var(--bg-primary);
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -10%, color-mix(in srgb, var(--accent-color) 12%, transparent) 0%, transparent 70%),
        linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    /* The gradient tile is the body's box, which is shorter than the viewport
       here — with the default `repeat` it started over below the box and the
       page showed a lighter band from y=837 down (visible on the very first
       screen a beta user sees). no-repeat lets the background-COLOUR fill the
       rest instead of a second copy of the gradient's top. */
    background-repeat: no-repeat;
    min-height: 100vh;
    display: flex;
}
body.auth-page > main {
    width: 100%;
    min-width: 0;
}

body.dashboard-page {
    background: var(--cw-page-bg);
    min-height: 100vh;
}

main .dashboard {
    padding: 0 var(--space-5);
    margin: var(--space-6) auto;
    /* Owner 2026-09-02: «правая рабочая область на всю правую ширину, чтобы
       влезало всё лучше». The fixed left rail stays ~216px and the content
       column takes the rest. Safe now that the operator console is grouped into
       sub-tabs — only one group renders at a time, so the wide money/risk
       panels no longer stack their intrinsic widths into one canvas (that was
       what forced the old 1120 cap). The cap keeps text panels readable on an
       ultrawide display. */
    max-width: 1400px;
}

/* ---------- Auth split (hero + card) — the signature surface ---------- */
/* [hidden] must win over the display rules below (the app toggles screens via
   the hidden attribute). Without this guard the more-specific `main .auth`
   display:flex overrides [hidden]'s display:none and the auth screen leaks
   under the dashboard. */
main .auth[hidden], main .dashboard[hidden], .sec[hidden] { display: none !important; }

main .auth {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: clamp(var(--space-5), 7vh, var(--space-8)) var(--space-4);
    min-height: 100vh;
}
.auth-split {
    width: 100%;
    max-width: 940px;
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-4);
    overflow: hidden;
    min-height: min(680px, calc(100dvh - var(--space-8) - var(--space-8)));
}

/* Control-plane rail: a real product topology, not a mock-editor preview. */
.auth-hero {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    padding: var(--space-8) var(--space-6);
    background: var(--cw-hero-bg);
    border-right: 1px solid var(--border-color);
    overflow: hidden;
}
.auth-hero::before {
    /* Soft grid texture behind the wireframe — the "blueprint" of the API. */
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--cw-hairline) 1px, transparent 1px),
        linear-gradient(90deg, var(--cw-hairline) 1px, transparent 1px);
    background-size: 28px 28px;
    -webkit-mask-image: radial-gradient(ellipse 70% 60% at 60% 30%, #000 0%, transparent 75%);
    mask-image: radial-gradient(ellipse 70% 60% at 60% 30%, #000 0%, transparent 75%);
    opacity: 0.5;
    pointer-events: none;
}
.auth-hero > * { position: relative; z-index: 1; }
.auth-hero-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-md);
    font-weight: var(--font-weight-bold);
    letter-spacing: -0.01em;
    color: var(--text-primary);
}
.auth-hero-brand svg { width: 24px; height: 24px; color: var(--accent-color); }
/* Brand mosaic logo carries its own colours; size by height, width auto
   to preserve the 168:130 aspect. */
.auth-hero-brand svg.brand-logo { width: auto; height: 30px; }
.auth-hero-copy h2 {
    margin: 0 0 var(--space-3);
    font-size: var(--font-2xl);
    line-height: 1.15;
    font-weight: var(--font-weight-bold);
    letter-spacing: -0.025em;
    color: var(--text-primary);
}
.auth-hero-copy .auth-eyebrow {
    margin: 0 0 var(--space-2);
    color: var(--accent-hover);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.auth-hero-copy p {
    margin: 0;
    max-width: 34ch;
    font-size: var(--font-base);
    line-height: 1.55;
    color: var(--cw-hero-text);
}
.topology-mark {
    width: var(--control-h);
    height: var(--control-h);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--cw-hero-stroke-strong);
    border-radius: var(--radius-md);
    background: var(--cw-surface);
    color: var(--accent-hover);
    font-family: var(--font-mono);
    font-size: var(--font-sm);
    font-weight: var(--font-weight-bold);
}

main .auth .auth-card {
    background: var(--bg-primary);
    padding: var(--space-8) var(--space-6) var(--space-6);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-width: 0;
}

@media (max-width: 860px) {
    .auth-split { grid-template-columns: minmax(0, 1fr); max-width: calc(var(--control-h) * 14); min-height: 0; }
    .auth-hero {
        gap: var(--space-3);
        padding: var(--space-4) var(--space-5);
        border-right: 0;
        border-bottom: 1px solid var(--border-color);
    }
    .auth-hero-copy { display: none; }
    main .auth .auth-card { padding: var(--space-6) var(--space-5); }
}
.auth-preferences {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
}
main .auth h1 {
    margin: 0 0 var(--space-1);
    font-size: var(--font-2xl);
    font-weight: var(--font-weight-bold);
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
main .auth #twofaSignInForm h2 {
    margin: 0 0 var(--space-2);
    color: var(--text-primary);
    font-size: var(--font-lg);
    font-weight: var(--font-weight-semibold);
}
main .auth #twofaSignInForm > .hint {
    margin: 0 0 var(--space-4);
    color: var(--text-muted);
    font-size: var(--font-sm);
    line-height: 1.5;
}
main .auth .lead {
    color: var(--text-muted);
    margin: 0 0 var(--space-5);
    font-size: var(--font-base);
    line-height: 1.5;
}
main .auth .auth-footer {
    margin-top: auto;
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: var(--font-xs);
    color: var(--text-muted);
}
main .auth .auth-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: var(--font-weight-medium);
}
main .auth .auth-footer a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

/* Keep sign-in and its legal links visible on laptop-height windows without
   shrinking controls or clipping longer registration/error states. */
@media (min-width: 861px) and (max-height: 800px) {
    main .auth { padding: var(--space-3) var(--space-4); }
    main .auth .auth-card { padding: var(--space-4) var(--space-6); }
    main .auth .auth-preferences { margin-bottom: var(--space-2); }
    main .auth .lead { margin-bottom: var(--space-3); }
}

/* ---------- Form fields inside the auth card ---------- */
main .auth .form-field {
    margin-bottom: var(--space-4);
}
main .auth .form-field > span {
    display: block;
    font-size: var(--font-sm);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}
main .auth .form-field input {
    display: block;
    width: 100%;
    padding: 0 var(--control-pad-x, 14px);
    height: 44px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: var(--font-base);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
main .auth .form-field input::placeholder {
    color: var(--text-muted);
}
main .auth .form-field input:hover {
    border-color: var(--text-muted);
}
main .auth .form-field input:focus-visible {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: var(--focus-ring);
}
main .auth input:-webkit-autofill,
main .auth input:-webkit-autofill:hover,
main .auth input:-webkit-autofill:focus,
main .auth input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-primary) inset;
    -webkit-text-fill-color: var(--text-primary);
    caret-color: var(--text-primary);
    transition: background-color 9999s ease-in-out 0s;
}
main .auth .form-field .hint {
    display: block;
    margin-top: var(--space-1);
    font-size: var(--font-xs);
    color: var(--text-muted);
}
main .auth .form-submit {
    margin-top: var(--space-5);
}
main .auth .form-submit button {
    width: 100%;
    height: 46px;
    font-size: var(--font-base);
    font-weight: var(--font-weight-semibold);
    background: var(--accent-color);
    color: var(--accent-contrast);
    border: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition-fast), box-shadow var(--transition-fast);
}
main .auth .form-submit button:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: var(--shadow-3);
}
main .auth .form-submit button:active:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(1px);
}
main .auth .form-submit button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
main .auth .form-submit .secondary-row {
    margin-top: var(--space-3);
    text-align: center;
}
main .auth .form-submit .secondary-row .link-btn {
    background: transparent;
    border: 0;
    color: var(--accent-color);
    font: inherit;
    font-size: var(--font-sm);
    cursor: pointer;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-xs);
}
main .auth .form-submit .secondary-row .link-btn:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.auth-state {
    display: grid;
    gap: var(--space-3);
    margin-top: 0;
    padding: var(--space-5);
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: var(--space-1) solid var(--accent-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-1);
}
.auth-state.pending { border-left-color: var(--warning-color); }
.auth-state.success { border-left-color: var(--success-color); }
.auth-state.error { border-left-color: var(--danger-color); }
.auth-state:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}
.auth-state-kicker {
    color: var(--text-secondary);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.auth-state h2,
.auth-state p { margin: 0; }
.auth-state h2 {
    color: var(--text-primary);
    font-size: var(--font-xl);
    line-height: 1.25;
}
.auth-state p {
    color: var(--text-secondary);
    line-height: 1.6;
}
.auth-state button { justify-self: start; }

.invite-landing-dialog { width: min(32rem, calc(100vw - 2 * var(--space-4))); }
/* Shown non-modally to a visitor who still has to sign in, so the auth form
   behind stays usable. A non-modal <dialog> is laid out in normal flow, which
   would drop it at the top-left of the page; pin it where the modal sits so the
   two states look the same. */
.invite-landing-dialog:not(:modal) {
    position: fixed;
    inset: auto auto var(--space-5) var(--space-5);
    margin: 0;
    z-index: 60;
}
@media (max-width: 640px) {
    .invite-landing-dialog:not(:modal) {
        inset: auto var(--space-4) var(--space-4) var(--space-4);
        width: auto;
    }
}
.invite-landing-details { display: grid; gap: var(--space-3); margin: var(--space-4) 0; }
.invite-landing-details > div { display: grid; grid-template-columns: minmax(7rem, 0.45fr) 1fr; gap: var(--space-3); }
.invite-landing-details dt { color: var(--text-secondary); }
.invite-landing-details dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 520px) {
    .invite-landing-details > div { grid-template-columns: minmax(0, 1fr); gap: var(--space-1); }
}

@media (max-width: 720px) {
    main .dashboard { margin: var(--space-4) auto; padding: 0 var(--space-4); max-width: 100%; }
}

/* ---------- Auth mode toggle (signin / signup) ----------
 * A segmented control (not an underline tab strip): two equal halves in a
 * sunken track with a raised active pill — the same segmented-nav language as
 * the dashboard's .section-tabs, so the auth screen reads as the same product.
 * Sits full-width above the form. */
.tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-1);
    padding: var(--space-1);
    margin-bottom: var(--space-5);
    background: var(--cw-seg-track);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}
.tab {
    background: transparent;
    border: 0;
    height: var(--btn-h-md);
    padding: 0 var(--space-3);
    cursor: pointer;
    /* --text-secondary (not muted): muted falls below WCAG AA on the segmented
       track; --text-secondary clears it while reading quieter than the active
       pill. */
    color: var(--text-secondary);
    font-size: var(--font-sm);
    font-weight: var(--font-weight-medium);
    font-family: inherit;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}
.tab:hover:not(.active) {
    color: var(--text-primary);
    background: var(--hover-overlay);
}
.tab.active {
    color: var(--accent-hover);
    background: var(--cw-seg-active);
    box-shadow: var(--shadow-1);
    font-weight: var(--font-weight-semibold);
}
.tab:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* ---------- Forms ---------- */

form label {
    display: block;
    margin: var(--space-3) 0;
    font-size: var(--font-sm);
    color: var(--text-muted);
}
form label input,
form label textarea,
form label select,
.inline-form input,
.inline-form select,
.inline-form textarea,
.space-rename-form input,
#twofaBox input,
#twofaBox label input {
    display: block;
    width: 100%;
    margin-top: var(--space-1);
    padding: 0 var(--control-pad-x);
    height: var(--control-h);
    line-height: normal;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    font: inherit;
    font-size: var(--control-font);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
/* ---------- Collapsible settings groups ----------
 * «Безопасность и аккаунт» was one flat 3275px column of 31 controls separated
 * only by headings: name, password, email, SAML, SCIM, sign-in methods, 2FA,
 * sessions, appeals, privacy, terms, account deletion. Everything shouted at
 * once, so nothing was easy to find — and the two things a person actually
 * comes here for (password, two-factor) sat in the middle of enterprise
 * directory sync they will never use.
 *
 * The groups carry the meaning: what you change often stays open, what is
 * specialised or irreversible starts closed. Native <details> so the keyboard,
 * screen readers and browser find-in-page all work without a line of JS.
 */
.settings-group {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md, 10px);
    background: var(--bg-secondary);
    margin: var(--space-4) 0;
    overflow: hidden;
}

.settings-group > summary {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "title chevron" "hint chevron";
    align-items: center;
    gap: 0 var(--space-3);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.settings-group > summary::-webkit-details-marker { display: none; }

.settings-group > summary:hover { background: var(--bg-hover, var(--bg-tertiary, transparent)); }

.settings-group > summary:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-md, 10px);
}

.settings-group-title {
    grid-area: title;
    font-size: var(--font-md, 1rem);
    font-weight: 600;
    color: var(--text-primary);
}

.settings-group-hint {
    grid-area: hint;
    font-size: var(--font-xs);
    color: var(--text-muted);
}

.settings-group-chevron {
    grid-area: chevron;
    width: 12px;
    height: 8px;
    color: var(--text-muted);
    transition: transform var(--transition-fast);
}

.settings-group[open] > summary .settings-group-chevron { transform: rotate(180deg); }

.settings-group-body {
    padding: 0 var(--space-4) var(--space-4);
    border-top: 1px solid var(--border-color);
    padding-top: var(--space-4);
}

/* Inside a group the old h3 separators are redundant with the group title, so
 * they step back to a quiet label rather than competing with it. */
.settings-group-body > h3.sub {
    font-size: var(--font-sm);
    color: var(--text-muted);
    text-transform: none;
    margin-top: var(--space-4);
}

.settings-group-body > h3.sub:first-child { margin-top: 0; }

/* The danger group keeps its warning colour on the summary so it reads as
 * dangerous while closed — that is the state it spends its life in. */
/* The group TITLE is text, so it takes --danger-text: the token exists
   because --danger-color #ef4444 on white is 3.77:1 and fails AA for text
   (see tokens.css). Measured 3.6:1 on «Опасная зона» — the label on the
   most destructive area of the account. Dark theme maps --danger-text to
   the same #f87171 it already used, so nothing changes there. */
.settings-group[data-group="danger"] > summary .settings-group-title { color: var(--danger-text, var(--danger-color, #ef4444)); }

/* ---------- Dropdowns ----------
 * A <select> that no rule reached kept Chrome's own control: grey
 * rgb(59,59,59) fill, square corners, a 17px box next to our 36px inputs, and
 * Arial instead of the app face. Thirteen of them sat in filter toolbars —
 * beside our own fields, which is exactly where the mismatch reads as broken
 * rather than plain. Measured 2026-09-04 on the live cabinet.
 *
 * Every select in the app now wears the same shape as an input, plus the one
 * thing an input must NOT have: a chevron, so the control still announces that
 * it opens. The chevron is an inline data URI (no CDN — the product ships
 * air-gapped) and it is drawn twice so its ink follows the theme.
 */
select {
    appearance: none;
    -webkit-appearance: none;
    display: block;
    width: 100%;
    padding: 0 calc(var(--control-pad-x) + 18px) 0 var(--control-pad-x);
    height: var(--control-h);
    line-height: normal;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    font: inherit;
    font-size: var(--control-font);
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--control-pad-x) center;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

html.dark select,
.dark select {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%237e9abb' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
    html:not(.light) select {
        background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5l5-5' stroke='%237e9abb' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    }
}

select:hover { border-color: var(--border-strong, var(--accent-color)); }

select:focus-visible {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: var(--focus-ring);
}

select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* A select that sits inline in a toolbar sizes to its content instead of
 * stretching the row. */
.toolbar select,
.filters select,
.panel-actions select,
select.inline {
    display: inline-block;
    width: auto;
    min-width: 9rem;
}

form label input:focus-visible,
#twofaBox input:focus-visible,
.inline-form input:focus-visible,
.inline-form select:focus-visible,
.space-rename-form input:focus-visible,
.inline-form textarea:focus-visible {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: var(--focus-ring);
}
form label .hint {
    display: block;
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* ---------- Buttons ---------- */

button, .btn {
    font: inherit;
    font-weight: var(--font-weight-semibold);
    padding: 0 var(--btn-pad-x-md);
    height: var(--btn-h-md);
    border-radius: var(--control-radius);
    cursor: pointer;
    border: 1px solid transparent;
    background: var(--accent-color);
    color: var(--accent-contrast);
    transition: background var(--transition-fast), border-color var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    white-space: nowrap;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button:focus-visible, .btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}
button:disabled, .btn:disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }

button.secondary, .btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-color);
}
button.secondary:hover, .btn-secondary:hover {
    background: var(--bg-secondary);
    border-color: var(--text-muted);
}

button.danger, .btn-danger {
    /* Fixed deep red (not var(--danger-color)) so the conventional white text
       passes WCAG AA in BOTH themes — dark-theme --danger-color #f87171 gave
       white text only 2.77:1. Mirrors .btn-danger in the on-prem design system. */
    background: #dc2626; /* ui-lint-ok: solid danger fill, white text needs AA in both themes */
    color: #ffffff; /* ui-lint-ok: on-fill text for the fixed danger red */
    border-color: transparent;
}
button.danger:hover, .btn-danger:hover {
    background: #b91c1c; /* ui-lint-ok: darker danger fill on hover, keeps white AA */
}

button.small, .btn-sm { height: var(--btn-h-sm); padding: 0 var(--btn-pad-x-sm); font-size: var(--font-sm); }

/* ---------- Alerts / errors ---------- */

.error, [role="alert"] {
    color: var(--danger-text, var(--danger-color));
    background: var(--danger-bg);
    border: 1px solid color-mix(in srgb, var(--danger-color) 30%, transparent);
    padding: var(--space-3);
    border-radius: var(--control-radius);
    margin-top: var(--space-3);
    font-size: var(--font-sm);
}
[role="status"] {
    color: var(--success-text);
    background: var(--success-bg);
    border: 1px solid color-mix(in srgb, var(--success-color) 30%, transparent);
    padding: var(--space-3);
    border-radius: var(--control-radius);
    margin-top: var(--space-3);
    font-size: var(--font-sm);
}

.identity-resend { margin-top: var(--space-2); }
.session-revoke { justify-self: end; }

@media (max-width: 900px) {
    .session-revoke { justify-self: stretch; width: 100%; }
}

/* ---------- Dashboard ---------- */

main .dashboard > header {
    position: sticky;
    top: 0;
    z-index: var(--z-raised);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 calc(-1 * var(--space-5)) var(--space-5);
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    background: color-mix(in srgb, var(--cw-page-bg) 88%, transparent);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
    backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--border-color);
}
main .dashboard h1 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-xl);
    font-weight: var(--font-weight-bold);
    letter-spacing: -0.02em;
}
main .dashboard h1 svg.brand-logo { width: auto; height: 26px; flex-shrink: 0; }
@media (max-width: 720px) {
    main .dashboard > header {
        position: static;
        margin: 0 calc(-1 * var(--space-4)) var(--space-4);
        padding: var(--space-3) var(--space-4);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}
.user-menu {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}
.cabinet-nav-toggle { display: none; }
.cabinet-identity {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: var(--space-2);
    min-width: 0;
}
.cabinet-identity strong {
    min-width: 0;
    overflow: hidden;
    color: var(--text-primary);
    font-size: var(--font-sm);
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cabinet-identity .user-email {
    grid-column: 1 / -1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cabinet-identity .role-pill {
    grid-column: 2;
    grid-row: 1;
}
.user-email {
    color: var(--text-secondary);
    font-size: var(--font-sm);
    font-weight: var(--font-weight-medium);
}

.card {
    position: relative;
    background: var(--cw-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
    padding: var(--space-6);
    margin-bottom: var(--space-4);
}
/* Signature accent rail on the top edge of every section card — ties the
   surface to the brand without colouring the whole card. */
.card::before {
    content: "";
    position: absolute;
    top: 0;
    left: var(--radius-lg);
    right: var(--radius-lg);
    height: 2px;
    background: var(--cw-rail);
    border-radius: var(--radius-pill);
    opacity: 0.85;
}
.card > h2:first-child,
.card > h2 {
    margin: 0 0 var(--space-5);
    padding-top: var(--space-1);
    /* Confident section title — the page-level heading for each surface.
       Reads as primary, not a tiny eyebrow; the .sub eyebrows below carry the
       quieter uppercase treatment. */
    font-size: var(--font-lg);
    color: var(--text-primary);
    letter-spacing: -0.015em;
    font-weight: var(--font-weight-bold);
}

.ws-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-2);
}
.ws-name { font-size: var(--font-md); font-weight: var(--font-weight-semibold); }
.workspace-switcher { color: var(--text-secondary); font-size: var(--font-sm); }
.workspace-switcher-actions { display: flex; gap: var(--space-1); margin-top: var(--space-1); flex-wrap: wrap; }
.workspace-switcher-actions button { width: auto; }
.workspace-switcher-actions button[aria-pressed="true"] { border-color: var(--accent-color); color: var(--accent-color); }
.space-rename-form {
    display: grid;
    grid-template-columns: minmax(10rem, 1fr) auto;
    align-items: end;
    gap: var(--space-2);
    margin-top: var(--space-4);
    max-width: 34rem;
}
.space-rename-form label { grid-column: 1 / -1; color: var(--text-muted); font-size: var(--font-sm); }
.space-rename-form input { min-width: 0; }
.space-rename-form button { width: auto; white-space: nowrap; }
.space-rename-form .form-result { grid-column: 1 / -1; margin: 0; }

@media (max-width: 640px) {
    .space-rename-form { grid-template-columns: minmax(0, 1fr); max-width: none; }
    .space-rename-form button { width: 100%; }
}
.space-usage { margin-top: var(--space-3); color: var(--text-secondary); font-size: var(--font-sm); }
.ws-meta {
    color: var(--text-muted);
    font-size: var(--font-sm);
    display: flex;
    gap: var(--space-3);
    align-items: center;
    margin-top: var(--space-1);
    flex-wrap: wrap;
}

.badge {
    /* Accent chip: AA-readable accent recipe in both themes (see --cw-chip-*). */
    background: var(--cw-chip-bg);
    color: var(--cw-chip-text);
    padding: var(--badge-pad-y) var(--badge-pad-x);
    border-radius: var(--badge-radius);
    font-size: var(--badge-font);
    font-weight: var(--badge-weight);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge.small { font-size: var(--font-xs); padding: 0 var(--space-2); }
.badge.ok { background: var(--success-bg); color: var(--success-text); }
.badge.warn { background: color-mix(in srgb, var(--warning-color) 22%, transparent); color: var(--warning-text); }
.badge.danger { background: var(--danger-bg); color: var(--danger-text, var(--danger-color)); }

.ws-slug { font-family: var(--font-mono); font-size: var(--font-sm); color: var(--text-secondary); }

/* ---------- Quota ---------- */

.quota-list { display: flex; flex-direction: column; gap: var(--space-2); }
.quota-row {
    display: grid;
    grid-template-columns: 200px 1fr 90px;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--font-sm);
}
@media (max-width: 720px) {
    .quota-row { grid-template-columns: 1fr 90px; }
    .quota-row .quota-bar { grid-column: 1 / -1; order: 3; }
}
.quota-label { color: var(--text-primary); }
.quota-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: var(--radius-pill);
    overflow: hidden;
}
.quota-fill {
    height: 100%;
    background: var(--success-color);
    transition: width var(--transition-base);
}
.quota-row.warn .quota-fill { background: var(--warning-color); }
.quota-row.danger .quota-fill { background: var(--danger-color); }
.quota-numbers { color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }
/* The number on an exhausted quota is the one the person MUST read, and it was
   painted with the fill hue: --danger-color is 3.76:1 on the light card, under
   AA. --danger-text is the ink token that exists for exactly this (the bar
   itself keeps the fill colour — a bar is not text). */
.quota-row.danger .quota-numbers { color: var(--danger-text); font-weight: var(--font-weight-semibold); }

/* ---------- Product balances ---------- */

.wallet-heading,
.wallet-statement-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: var(--space-4);
    margin-top: var(--space-5);
}
.wallet-heading .sub,
.wallet-statement-heading .sub { margin-bottom: var(--space-1); }
.wallet-heading .hint,
.wallet-statement-heading .hint { margin: 0; }
.wallet-separation {
    flex: 0 0 auto;
    padding: var(--space-1) var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    background: var(--cw-surface-sunken);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-semibold);
    letter-spacing: .04em;
    text-transform: uppercase;
}
.wallet-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-3);
    margin-top: var(--space-3);
}
.wallet-card {
    position: relative;
    min-width: 0;
    overflow: hidden;
    padding: var(--space-5);
    border: 1px solid var(--border-color);
    border-top-width: 3px;
    border-radius: var(--radius-lg);
    background: linear-gradient(145deg, var(--cw-surface), var(--cw-surface-sunken));
}
.wallet-card::after {
    position: absolute;
    width: 7rem;
    height: 7rem;
    right: -3.5rem;
    top: -3.5rem;
    border-radius: 50%;
    background: color-mix(in srgb, currentColor 8%, transparent);
    content: "";
    pointer-events: none;
}
.wallet-box { border-top-color: var(--accent-color); color: var(--accent-color); }
.wallet-ai { border-top-color: var(--success-color); color: var(--success-color); }
.wallet-iu { border-top-color: var(--warning-color); color: var(--warning-color); }
.wallet-card-kicker {
    display: block;
    color: var(--text-secondary);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-semibold);
    letter-spacing: .06em;
    text-transform: uppercase;
}
.wallet-card h4 {
    margin: var(--space-1) 0 var(--space-4);
    color: var(--text-primary);
    font-size: var(--font-lg);
}
.wallet-card strong {
    display: block;
    overflow: hidden;
    color: var(--text-primary);
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    text-overflow: ellipsis;
}
.wallet-card p {
    margin: var(--space-3) 0 0;
    color: var(--text-secondary);
    font-size: var(--font-sm);
}
.wallet-statement {
    margin: var(--space-5) 0;
    padding: var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--cw-surface-sunken);
}
.wallet-statement-heading { margin-top: 0; }
.wallet-statement-controls {
    display: grid;
    grid-template-columns: auto minmax(10rem, 1fr) auto;
    align-items: center;
    gap: var(--space-2);
}
.wallet-statement-controls label {
    color: var(--text-secondary);
    font-size: var(--font-sm);
}
.wallet-statement-list { display: grid; gap: var(--space-2); margin-top: var(--space-4); }
.wallet-statement-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    background: var(--cw-surface);
}
.wallet-statement-row > div { display: grid; gap: var(--space-1); }
.wallet-statement-row span { color: var(--text-muted); font-size: var(--font-xs); }
.wallet-statement-row p {
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--font-sm);
    font-variant-numeric: tabular-nums;
    text-align: right;
}
@media (max-width: 760px) {
    .wallet-grid { grid-template-columns: minmax(0, 1fr); }
    .wallet-heading,
    .wallet-statement-heading { align-items: stretch; flex-direction: column; }
    .wallet-separation { align-self: start; }
    .wallet-statement-controls { grid-template-columns: minmax(0, 1fr); }
    .wallet-statement-row { grid-template-columns: minmax(0, 1fr); }
    .wallet-statement-row p { text-align: left; }
}

/* ---------- Empty state ---------- */

.empty {
    color: var(--text-secondary);
    font-size: var(--font-sm);
    padding: var(--space-6) var(--space-4);
    text-align: center;
    background: var(--cw-surface-sunken);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    line-height: 1.5;
}

.state-panel {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin: var(--space-3) 0;
    padding: var(--space-3) var(--space-4);
    color: var(--text-secondary);
    background: var(--cw-surface-sunken);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--font-sm);
    line-height: 1.5;
}
.state-panel[hidden] { display: none; }
.state-panel.error { color: var(--danger-text, var(--danger-color)); border-color: var(--danger-color); background: var(--danger-bg); }
.state-panel.warning { color: var(--warning-text); border-color: var(--warning-color); background: color-mix(in srgb, var(--warning-color) 12%, var(--bg-primary)); }
.state-panel.success { color: var(--success-text); border-color: var(--success-color); background: var(--success-bg); }
.state-panel .secondary { flex: 0 0 auto; margin-left: auto; }

[data-permission-denied="true"] {
    opacity: 0.72;
}
[data-permission-denied="true"]::after {
    content: attr(data-permission-message);
    display: block;
    width: 100%;
    margin-top: var(--space-2);
    color: var(--text-muted);
    font-size: var(--font-xs);
}

@media (max-width: 720px) {
    .state-panel { flex-direction: column; }
    .state-panel .secondary { margin-left: 0; width: 100%; }
}

/* ---------- Billing ---------- */

.billing-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
}
.plan-label { color: var(--text-muted); font-size: var(--font-sm); }
.plan-value { font-size: var(--font-xl); font-weight: var(--font-weight-semibold); text-transform: capitalize; }
.payment-history {
    margin-top: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}
.payment-row {
    display: grid;
    grid-template-columns: minmax(90px, 1fr) 96px 110px 140px minmax(120px, 1fr) auto;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    font-size: var(--font-sm);
}
@media (max-width: 720px) {
    .payment-row { grid-template-columns: minmax(0, 1fr); gap: var(--space-1); }
}
.payment-plan { font-weight: var(--font-weight-semibold); text-transform: capitalize; }
.payment-amount { font-variant-numeric: tabular-nums; }
.payment-status {
    padding: 2px var(--space-2);
    border-radius: var(--radius-pill);
    font-size: var(--font-xs);
    text-align: center;
    text-transform: uppercase;
    background: var(--border-color);
    /* AA: muted on the --border-color chip is ~3.2:1 in light; --text-secondary clears it. */
    color: var(--text-secondary);
}
.payment-status.status-succeeded { background: var(--success-bg); color: var(--success-text); }
.payment-status.status-canceled,
.payment-status.status-rejected,
.payment-status.status-operator_required { background: var(--danger-bg); color: var(--danger-text, var(--danger-color)); }
.payment-status.status-reserved,
.payment-status.status-dispatching,
.payment-status.status-unknown,
.payment-status.status-accepted { background: color-mix(in srgb, var(--warning-color) 22%, transparent); color: var(--warning-text); }
.payment-ext { color: var(--text-muted); font-family: var(--font-mono); font-size: var(--font-xs); word-break: break-all; }
.payment-date { color: var(--text-secondary); font-variant-numeric: tabular-nums; font-size: var(--font-sm); }
.payment-actions { display: flex; justify-content: flex-end; }
.payment-actions .secondary { min-height: var(--control-h-sm); white-space: nowrap; }

/* ---------- Getting started checklist (Overview) ---------- */
.getting-started { margin: var(--space-5) 0 var(--space-4); }
.getting-started-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: var(--space-2);
}
.getting-started-step {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    min-width: 0;
}
.getting-started-step[data-done="true"] { background: var(--success-bg); border-color: color-mix(in srgb, var(--success-color) 40%, var(--border-color)); }
.getting-started-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--space-6);
    height: var(--space-6);
    border-radius: 50%;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-bold);
    flex: 0 0 auto;
}
.getting-started-step[data-done="true"] .getting-started-mark { background: var(--bg-primary); border-color: var(--success-color); color: var(--success-text); }
.getting-started-body { min-width: 0; }
.getting-started-body strong { display: block; color: var(--text-primary); overflow-wrap: anywhere; }
.getting-started-body span { display: block; color: var(--text-secondary); font-size: var(--font-sm); overflow-wrap: anywhere; }
.getting-started-step button { width: auto; max-width: 100%; min-width: 0; min-height: var(--btn-h-sm); height: auto; padding: var(--space-1) var(--btn-pad-x-sm); font-size: var(--font-sm); line-height: var(--line-height-normal); text-align: center; white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 640px) {
    .getting-started-step { grid-template-columns: auto minmax(0, 1fr); }
    .getting-started-step button { grid-column: 2; justify-self: start; text-align: left; }
}

/* ---------- Operator console: collapsible panels ---------- */
.op-panel-toolbar { display: flex; gap: var(--space-2); justify-content: flex-end; margin: 0 0 var(--space-3); }
.op-panel-toolbar button { width: auto; }
.op-panel-heading { display: flex; align-items: center; gap: var(--space-2); }
.op-panel-toggle {
    width: var(--space-6);
    height: var(--space-6);
    min-height: 0;
    padding: 0;
    flex: 0 0 auto;
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: var(--font-md);
    line-height: 1;
}
.op-panel-toggle:hover { color: var(--text-primary); background: var(--hover-overlay); }
.op-panel.op-panel-collapsed { padding-bottom: var(--space-3); }
.op-panel.op-panel-collapsed .op-panel-body { display: none; }
.op-panel.op-panel-collapsed .section-heading { margin-bottom: 0; }
.op-panel.op-panel-collapsed .hint { display: none; }

/* ---------- Cabinet shell + grouped navigation ---------- */

.cabinet-shell {
    display: grid;
    grid-template-columns: calc(var(--control-h) * 6) minmax(0, 1fr);
    align-items: start;
    gap: var(--space-5);
}
.cabinet-content { min-width: 0; }

.section-tabs {
    position: sticky;
    top: var(--space-4);
    display: grid;
    gap: var(--space-4);
    max-height: calc(var(--vh100) - var(--space-8));
    padding: var(--space-3);
    background: var(--cw-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-1);
    overflow-y: auto;
    scrollbar-width: thin;
}
.nav-group,
.nav-group-items { display: grid; gap: var(--space-1); }
.nav-group-label {
    padding: 0 var(--space-2);
    color: var(--text-secondary);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.section-tab {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    padding: var(--space-2) var(--space-3);
    min-height: var(--btn-h-sm);
    height: auto;
    border-radius: var(--control-radius);
    cursor: pointer;
    /* --text-secondary (not muted): muted is 4.35:1 on the light segmented
       track — just below WCAG AA. --text-secondary clears it while still
       reading as quieter than the active pill. */
    color: var(--text-secondary);
    font-size: var(--font-sm);
    font-weight: var(--font-weight-medium);
    font-family: inherit;
    justify-content: flex-start;
    text-align: left;
    white-space: normal;
    transition: color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}
.section-tab:hover:not(.active) { color: var(--text-primary); background: var(--hover-overlay); }
.section-tab.active {
    color: var(--accent-hover);
    background: var(--cw-seg-active);
    border-color: var(--cw-hero-stroke);
    box-shadow: var(--shadow-1);
    font-weight: var(--font-weight-semibold);
}
.section-tab:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.cabinet-nav-backdrop { display: none; }

/* ---------- Control Trace ----------
 * This is an authority surface, not a decorative topology diagram. Every
 * colour is paired with explicit text and data-state so stale/unavailable
 * authority is understandable without colour perception.
 */
.section-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
}
/* The text block yields room to the badge on the same line; the badge only
 * drops below it when the line is genuinely too narrow. */
.section-heading > :first-child { flex: 1 1 24rem; min-width: 0; }
.section-heading > .authority-badge { margin-left: auto; }
.section-heading-placeholder {
    margin-bottom: var(--space-4);
}
.section-heading > div {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}
/* Badges next to a heading must never squeeze the heading into a one-letter
   column: they keep a short label, wrap if needed and never exceed a third
   of the row. Long state text belongs to the state panel below. */
.section-heading > .authority-badge,
.section-heading > .status-pill {
    flex: 0 0 auto;
    max-width: 100%;
    white-space: nowrap;
    text-align: right;
}
.section-heading h2 { margin: 0 0 var(--space-1); }
.section-kicker {
    margin: 0 0 var(--space-1);
    color: var(--accent-hover);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.authority-badge {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    width: fit-content;
    max-width: 100%;
    white-space: nowrap;
    min-height: var(--space-6);
    padding: 0 var(--space-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    background: var(--cw-surface-sunken);
    color: var(--text-secondary);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
}
.authority-badge.verified {
    border-color: color-mix(in srgb, var(--success-color) 48%, var(--border-color));
    background: var(--success-bg);
    color: var(--success-text);
}
.authority-badge.recovery,
.authority-badge.reconciling {
    border-color: color-mix(in srgb, var(--warning-color) 50%, var(--border-color));
    background: color-mix(in srgb, var(--warning-color) 16%, var(--cw-surface));
    color: var(--warning-text);
}
.authority-badge.denied {
    border-color: color-mix(in srgb, var(--danger-color) 50%, var(--border-color));
    background: var(--danger-bg);
    /* The light danger text on its own tint sits at 4.1:1; darken the ink
       for the badge so the pill clears AA in both themes (dark theme's
       --danger-text is already bright on a dark tint). */
    color: color-mix(in srgb, var(--danger-text, var(--danger-color)) 82%, var(--text-primary));
}
.control-trace {
    display: grid;
    gap: var(--space-4);
    padding: var(--space-4);
    margin-bottom: var(--space-5);
    border: 1px solid color-mix(in srgb, var(--accent-color) 28%, var(--border-color));
    border-radius: var(--radius-lg);
    background:
        linear-gradient(145deg, color-mix(in srgb, var(--accent-color) 5%, transparent), transparent 54%),
        var(--cw-surface-sunken);
}
.control-trace-path {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: stretch;
    gap: var(--space-2);
    padding: 0;
    margin: 0;
    list-style: none;
}
.trace-node {
    position: relative;
    display: grid;
    align-content: start;
    gap: var(--space-1);
    min-width: 0;
    padding: var(--space-3);
    border: 1px solid var(--border-color);
    border-top-width: 3px;
    border-radius: var(--control-radius);
    background: var(--cw-surface);
}
.trace-node[data-trace-state="verified"] { border-top-color: var(--success-color); }
.trace-node[data-trace-state="reconciling"] { border-top-color: var(--warning-color); }
.trace-node[data-trace-state="denied"] { border-top-color: var(--danger-color); }
.trace-node[data-trace-state="stale"],
.trace-node[data-trace-state="unavailable"] { border-top-color: var(--text-muted); }
.trace-node-kicker {
    color: var(--text-secondary);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.trace-node strong {
    overflow: hidden;
    color: var(--text-primary);
    font-size: var(--font-md);
    text-overflow: ellipsis;
    white-space: nowrap;
}
.trace-node strong + span {
    color: var(--text-secondary);
    font-size: var(--font-xs);
    line-height: var(--line-height-normal);
}
.trace-connector {
    display: grid;
    place-items: center;
    color: var(--accent-hover);
    font-size: var(--font-lg);
    font-weight: var(--font-weight-bold);
}
.control-authority-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2);
    margin: 0;
}
.control-authority-grid > div {
    min-width: 0;
    padding: var(--space-3);
    border: 1px solid var(--cw-hairline);
    border-radius: var(--control-radius);
    background: var(--cw-surface);
}
.control-authority-grid dt {
    margin-bottom: var(--space-1);
    color: var(--text-secondary);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
}
.control-authority-grid dd {
    margin: 0;
    color: var(--text-primary);
    font-size: var(--font-sm);
    line-height: var(--line-height-normal);
    overflow-wrap: anywhere;
}
.runtime-location-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(calc(var(--control-h) * 4), 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}
.runtime-location {
    min-width: 0;
    padding: var(--space-4);
    border: 1px solid var(--border-color);
    border-top-width: 3px;
    border-radius: var(--radius-lg);
    background: var(--cw-surface-sunken);
}
.runtime-location.verified { border-top-color: var(--success-color); }
.runtime-location.reconciling { border-top-color: var(--warning-color); }
.runtime-location.denied { border-top-color: var(--danger-color); }
.runtime-location.unavailable,
.runtime-location.stale { border-top-color: var(--text-muted); }
.runtime-location h3 { margin: var(--space-3) 0 var(--space-1); }
.runtime-location p {
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--font-sm);
    line-height: var(--line-height-normal);
}
.shared-projects {
    margin-top: var(--space-5);
    padding-top: var(--space-5);
    border-top: 1px solid var(--border-color);
}
.shared-project-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
    align-items: start;
    margin: var(--space-4) 0;
}
.shared-project-form .btn-row { grid-column: 1 / -1; }
.shared-project-list { display: grid; gap: var(--space-3); }
.shared-project-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--cw-surface-sunken);
}
.shared-project-card h4 { margin: 0 0 var(--space-1); overflow-wrap: anywhere; }
.shared-project-card .project-meta { color: var(--text-secondary); font-size: var(--font-sm); }

@media (max-width: 760px) {
    .control-trace-path { grid-template-columns: minmax(0, 1fr); }
    /* Rotate the arrow glyph, not the whole row: a rotated 280px-wide row
       became a 280px-tall box overlapping the nodes above and below it. */
    .trace-connector { min-height: var(--space-4); }
    .trace-connector span { display: inline-block; transform: rotate(90deg); }
    .control-authority-grid,
    .runtime-location-grid { grid-template-columns: minmax(0, 1fr); }
    .shared-project-form,
    .shared-project-card { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 480px) {
    .section-heading { align-items: stretch; flex-direction: column; }
    /* In the column layout the row basis (24rem) becomes a HEIGHT: every
       heading grew ~170px of empty space above its card on a phone. */
    .section-heading > :first-child { flex-basis: auto; }
    .section-heading .authority-badge { white-space: normal; }
    .control-trace { padding: var(--space-3); }
}

@media (max-width: 900px) {
    .cabinet-shell { display: block; }
    .cabinet-nav-toggle { display: inline-flex; flex: 0 0 auto; }
    .section-tabs {
        position: fixed;
        z-index: var(--z-modal);
        inset: 0 auto 0 0;
        width: min(calc(var(--control-h) * 8), 86vw);
        max-height: none;
        border-width: 0 1px 0 0;
        border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
        box-shadow: var(--shadow-5);
        transform: translateX(-105%);
        transition: transform var(--transition-base);
    }
    .section-tabs.open { transform: translateX(0); }
    .cabinet-nav-backdrop {
        position: fixed;
        z-index: calc(var(--z-modal) - 1);
        inset: 0;
        display: block;
        width: 100%;
        height: 100%;
        padding: 0;
        background: color-mix(in srgb, var(--text-primary) 38%, transparent);
        border: 0;
        border-radius: 0;
    }
    body.cabinet-nav-open { overflow: hidden; }
}

.sec h3.sub {
    font-size: var(--font-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    /* AA: --text-muted is 4.35:1 on white (below 4.5). --text-secondary is the
       readable de-emphasised tone for these sub-section eyebrows. */
    color: var(--text-secondary);
    margin: var(--space-5) 0 var(--space-2);
    font-weight: var(--font-weight-semibold);
}
.row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-5);
}
@media (max-width: 900px) {
    .row { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Team ---------- */

/* Shared row hover — lists of mocks/members/links/tokens read as interactive
   rows that lift on hover. Centralised so every list feels the same. */
.member-row, .instance-card, .token-row, .webhook-row, .audit-row {
    transition: border-color var(--transition-fast), background var(--transition-fast);
}
.member-row:hover, .instance-card:hover,
.token-row:hover, .webhook-row:hover {
    border-color: color-mix(in srgb, var(--accent-color) 40%, var(--border-color));
    background: var(--cw-surface-sunken);
}

.member-list { display: flex; flex-direction: column; gap: var(--space-2); }
.member-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    gap: var(--space-3);
    /* A member row grows with the actions its viewer may take: on a Space with
       a second member the remove/role controls appear and pushed the page 42px
       past a 375px screen. The row wraps instead — the actions drop under the
       name rather than dragging the whole document sideways. */
    flex-wrap: wrap;
}
.member-info { min-width: 0; flex: 1; }
.member-name { font-weight: var(--font-weight-semibold); font-size: var(--font-sm); }
.member-email { color: var(--text-muted); font-size: var(--font-xs); }
.member-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    /* No flex-shrink:0 here: pinning the group at max-content is what pushed
       the page sideways. It shrinks and wraps its buttons instead, so a narrow
       screen gets a taller member row rather than a horizontally scrolling
       document. */
    flex-wrap: wrap;
    min-width: 0;
}

.role-pill {
    padding: 2px var(--space-2);
    border-radius: var(--radius-pill);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    background: var(--border-color);
    /* AA: --text-secondary reads on the --border-color chip; muted fails (~3.2:1). */
    color: var(--text-secondary);
}
.role-pill.role-owner { background: var(--cw-chip-bg); color: var(--cw-chip-text); }
.role-pill.role-admin { background: color-mix(in srgb, var(--warning-color) 22%, transparent); color: var(--warning-text); }
.role-pill.role-editor { background: var(--success-bg); color: var(--success-text); }
.role-pill.role-viewer { background: var(--border-color); color: var(--text-secondary); }
.role-pill.role-billing_manager { background: var(--cw-chip-bg); color: var(--cw-chip-text); }

/* ---------- Inline forms (invite, instance) ---------- */

.inline-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    background: var(--cw-surface-sunken);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-5);
}
.inline-form label { font-size: var(--font-sm); color: var(--text-muted); }
.inline-form textarea,
form label textarea {
    min-height: 80px;
    height: auto;
    padding: var(--space-2) var(--control-pad-x);
    line-height: 1.5;
    resize: vertical;
}
.form-result {
    margin: var(--space-2) 0 0;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--control-radius);
    font-size: var(--font-sm);
    word-break: break-all;
}
.form-result.success { color: var(--success-text); background: var(--success-bg); }
.form-result.error { color: var(--danger-text, var(--danger-color)); background: var(--danger-bg); }

/* ---------- Shared row actions (invoices, etc.) ---------- */

.link-actions { display: flex; align-items: center; gap: var(--space-1); flex-shrink: 0; }

/* ---------- Instances ---------- */

.instance-list { display: flex; flex-direction: column; gap: var(--space-3); }
.instance-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}
.shared-node-card { border-left: 3px solid var(--accent-color); margin-bottom: var(--space-3); }
.shared-node-card .hint { margin: 0; }
.instance-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}
.instance-name { font-weight: var(--font-weight-semibold); color: var(--text-primary); }
.instance-meta { display: flex; align-items: center; gap: var(--space-2); font-size: var(--font-sm); }
.instance-url {
    font-family: var(--font-mono);
    font-size: var(--font-sm);
    color: var(--accent-color);
    word-break: break-all;
}
.instance-url a:hover { text-decoration: underline; }
.instance-error {
    font-size: var(--font-xs);
    color: var(--danger-text, var(--danger-color));
    background: var(--danger-bg);
    border-radius: var(--control-radius);
    padding: var(--space-1) var(--space-2);
    word-break: break-word;
}
.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.badge.mono { font-family: var(--font-mono); }
.btn-row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.status-pill {
    font-size: var(--font-xs);
    font-weight: var(--font-weight-semibold);
    padding: 2px var(--space-2);
    border-radius: var(--radius-pill);
    background: var(--border-color);
    color: var(--text-secondary);
    white-space: nowrap;
}
.status-pill.ok { background: var(--success-bg); color: var(--success-text); }
.status-pill.err { background: var(--danger-bg); color: var(--danger-text, var(--danger-color)); }
.status-pill.pending { background: color-mix(in srgb, var(--warning-color) 22%, transparent); color: var(--warning-text); }

/* ---------- Audit log ---------- */

.audit-list { display: flex; flex-direction: column; gap: var(--space-1); }
.audit-row {
    display: grid;
    grid-template-columns: minmax(0, 180px) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 130px);
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-2) var(--space-3);
    overflow-wrap: anywhere;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    font-size: var(--font-sm);
    font-family: var(--font-mono);
}
@media (max-width: 900px) {
    .audit-row { grid-template-columns: minmax(0, 1fr); }
}
.audit-time { color: var(--text-muted); font-size: var(--font-xs); }
.audit-action { color: var(--accent-hover); font-weight: var(--font-weight-semibold); }
.audit-target { color: var(--text-primary); }
.audit-actor { color: var(--text-muted); }
.refund-incident-id { min-width: 0; overflow-wrap: anywhere; }
.refund-copy { margin-top: var(--space-1); padding: 3px var(--space-2); font-size: var(--font-xs); }
.dispute-console-tools { display: flex; flex-wrap: wrap; align-items: end; gap: var(--space-2); min-width: 0; }
.dispute-console-tools label { margin: 0; min-width: 0; }
.dispute-console-tools > * { min-width: 0; max-width: 100%; }
.dispute-console-tools select, .dispute-console-tools input { max-width: 100%; min-width: 0; }
.dispute-ledger { display: grid; gap: var(--space-2); }
.dispute-row {
    display: grid;
    grid-template-columns: minmax(220px, 1.2fr) minmax(220px, 1fr) auto;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-3);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--warning-color);
    border-radius: var(--control-radius);
    background: var(--bg-primary);
}
.dispute-row.status-accepted { border-left-color: var(--danger-color); }
.dispute-row.status-rejected, .dispute-row.status-closed { border-left-color: var(--success-color); }
.dispute-row.status-approved { border-left-color: var(--success-color); }
.dispute-row.status-canceled { border-left-color: var(--text-muted); }
.dispute-row.status-evidence_pending { border-left-color: var(--accent-color); }
.dispute-row-main, .dispute-row-authority { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-width: 0; }
.dispute-row-authority { color: var(--text-muted); font-size: var(--font-xs); }
.dispute-row-actions { display: flex; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap; }
.reconciliation-run { display: grid; gap: var(--space-3); margin-bottom: var(--space-3); color: var(--text-muted); font-size: var(--font-sm); }
.reconciliation-run-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.reconciliation-rail { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--border-color); border-radius: var(--control-radius); overflow: hidden; background: var(--bg-primary); }
.reconciliation-track { display: grid; gap: var(--space-1); min-width: 0; padding: var(--space-3); border-left: 3px solid var(--success-color); }
.reconciliation-track + .reconciliation-track { border-top: 0; border-left-width: 1px; border-left-color: var(--border-color); }
.reconciliation-track span { color: var(--text-muted); font-size: var(--font-xs); text-transform: uppercase; letter-spacing: 0.08em; }
.reconciliation-track strong { color: var(--text-primary); overflow-wrap: anywhere; }
.reconciliation-track.has-findings { border-left-color: var(--danger-color); background: var(--danger-bg); }
.reconciliation-row { grid-template-columns: minmax(260px, 1.35fr) minmax(260px, 1fr); }
.reconciliation-row.status-resolved { border-left-color: var(--success-color); opacity: .82; }
/* Two different operations (propose a credit, repair a subscription) read as
 * a sequence, not as two cards fighting for one row: each form is its own
 * step with its fields in a 2-up grid and its action spanning the row. */
.money-authority-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); margin-bottom: var(--space-4); }
.money-authority-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); align-content: start; min-width: 0; padding: var(--space-4); border: 1px solid var(--border-color); border-radius: var(--control-radius); background: var(--bg-primary); }
.money-authority-form h4 { grid-column: 1 / -1; margin: 0; color: var(--text-primary); }
.money-authority-form > * { min-width: 0; }
.money-authority-form > button { max-width: 100%; height: auto; min-height: var(--btn-h-md); padding-top: var(--space-1); padding-bottom: var(--space-1); white-space: normal; text-align: center; }
.money-authority-grid, .money-authority-form { min-width: 0; max-width: 100%; }
.money-authority-form input, .money-authority-form select { width: 100%; min-width: 0; }
.money-authority-form > button, .money-authority-form > .form-result { grid-column: 1 / -1; justify-self: start; }
@media (max-width: 900px) {
    .dispute-row { grid-template-columns: minmax(0, 1fr); }
    .dispute-row-actions { justify-content: flex-start; }
    .dispute-console-tools { align-items: stretch; flex-direction: column; }
    .money-authority-form { grid-template-columns: minmax(0, 1fr); }
    .reconciliation-rail { grid-template-columns: minmax(0, 1fr); }
    .reconciliation-track + .reconciliation-track { border-top: 1px solid var(--border-color); border-left-width: 3px; }
}
.audit-chain-status { font-size: var(--font-xs); padding: 2px var(--space-2); border-radius: var(--radius-pill); }
.audit-chain-status.ok { background: var(--success-bg); color: var(--success-text); }
.audit-chain-status.broken { background: var(--danger-bg); color: var(--danger-text, var(--danger-color)); }

/* Identity gateway rack: the operator is changing the three external doors
   into one Cloud account. The quiet signal trace gives this security-critical
   surface a recognizable control-plane identity without turning it into a
   dashboard of decorative charts. */
.identity-gateway-panel {
    margin: var(--space-5) 0 var(--space-6);
    padding: var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--cw-surface) 92%, var(--accent-color) 8%);
}
.identity-gateway-heading { margin-bottom: var(--space-4); }
.identity-gateway-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-3);
}
.platform-settings-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); min-width: 0; }
.platform-settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); width: 100%; min-width: 0; }
.platform-settings-grid label { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-1); min-width: 0; color: var(--text-secondary); font-size: var(--font-sm); }
.platform-settings-grid input { width: 100%; min-width: 0; }
.platform-settings-grid .platform-settings-wide { grid-column: 1 / -1; }
.platform-settings-grid .identity-gateway-toggle { align-self: end; display: flex; }
.provider-pool-create { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); min-width: 0; margin-bottom: var(--space-4); padding: var(--space-4); border: 1px solid var(--border-color); border-radius: var(--control-radius); background: var(--bg-primary); }
.provider-pool-form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); width: 100%; min-width: 0; }
/* An explicit minmax(0, 1fr) track: an implicit `auto` track sizes to the
 * control's intrinsic width and the label then overflows its grid cell. */
.provider-pool-form-grid label { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: var(--space-1); min-width: 0; color: var(--text-secondary); font-size: var(--font-sm); }
.provider-pool-form-grid input, .provider-pool-form-grid select { width: 100%; min-width: 0; }
.provider-pool-form-grid .provider-pool-capabilities { grid-column: span 3; }
.provider-pool-form-grid .identity-gateway-toggle { align-self: end; display: flex; }
.provider-pool-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.provider-pool-card { display: grid; gap: var(--space-3); min-width: 0; padding: var(--space-4); border: 1px solid var(--border-color); border-radius: var(--control-radius); background: var(--bg-primary); box-shadow: var(--shadow-1); }
.provider-pool-card-head, .provider-pool-card-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; }
.provider-pool-card-head h4 { margin: 0; overflow-wrap: anywhere; }
.provider-pool-card-meta { display: flex; flex-wrap: wrap; gap: var(--space-2); color: var(--text-muted); font-size: var(--font-xs); }
.provider-bootstrap-reveal { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); padding: var(--space-3); border: 1px solid var(--warning-color); border-radius: var(--control-radius); background: var(--warning-bg); color: var(--warning-text); }
.provider-bootstrap-reveal[hidden] { display: none; }
.instance-bootstrap { flex-wrap: wrap; margin-top: var(--space-3); }
.instance-bootstrap-body { min-width: 0; flex: 1 1 18rem; }
.instance-bootstrap-body strong { display: block; color: var(--text-primary); }
.instance-bootstrap-body .hint { margin: var(--space-1) 0 var(--space-2); }
.instance-bootstrap-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: var(--space-2); margin: 0; }
.instance-bootstrap-grid dt { color: var(--text-muted); font-size: var(--font-xs); text-transform: uppercase; letter-spacing: 0.06em; }
.instance-bootstrap-grid dd { margin: var(--space-1) 0 0; }
.instance-bootstrap-grid code { display: block; padding: var(--space-1) var(--space-2); border-radius: var(--control-radius); background: var(--bg-primary); color: var(--text-primary); font-family: var(--font-mono); overflow-wrap: anywhere; user-select: all; }
.instance-bootstrap .btn-row { flex: 0 0 auto; align-self: flex-end; }
.instance-bootstrap .btn-row button { width: auto; }
.provider-bootstrap-reveal code { display: block; margin-top: var(--space-2); color: var(--text-primary); overflow-wrap: anywhere; user-select: all; }
.identity-gateway-card {
    --provider-accent: var(--accent-color);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    min-width: 0;
    padding: var(--space-4);
    border: 1px solid color-mix(in srgb, var(--provider-accent) 32%, var(--border-color));
    border-radius: var(--control-radius);
    background: var(--bg-primary);
    box-shadow: var(--shadow-1);
    overflow: hidden;
}
.identity-gateway-card.provider-yandex { --provider-accent: var(--danger-color); }
.identity-gateway-card.provider-vk { --provider-accent: var(--accent-color); }
.identity-gateway-card.provider-github { --provider-accent: var(--text-secondary); }
.identity-gateway-card.provider-google { --provider-accent: var(--warning-color); }
.identity-gateway-card.provider-gitlab { --provider-accent: var(--success-color); }
.identity-gateway-card.provider-smtp { --provider-accent: var(--success-text); }
.identity-gateway-card.provider-yookassa { --provider-accent: var(--accent-color); }
.identity-gateway-card.provider-stripe { --provider-accent: var(--text-secondary); }
.identity-gateway-card.provider-atol { --provider-accent: var(--warning-text); }
.identity-gateway-trace {
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: color-mix(in srgb, var(--provider-accent) 22%, transparent);
}
.identity-gateway-trace span {
    display: block;
    width: 38%;
    height: 100%;
    background: var(--provider-accent);
}
.identity-gateway-card-head,
.identity-gateway-actions,
.identity-gateway-meta,
.identity-gateway-toggle {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    min-width: 0;
}
/* Provider cards sit in a narrow grid column: every row wraps and every cell
 * breaks long tokens instead of widening the operator console. */
.identity-gateway-card-head > *, .identity-gateway-actions > *, .identity-gateway-meta > *,
.identity-gateway-field, .identity-gateway-field > *, .identity-gateway-secret { min-width: 0; overflow-wrap: anywhere; }
.identity-gateway-actions button { max-width: 100%; white-space: normal; }
.identity-gateway-card-head h4 { margin: 2px 0 0; font-size: var(--font-md); }
.identity-provider-key {
    /* The per-provider accent tints the CARD BORDER, which carries no contrast
       requirement. The key is text and must stay legible: the yandex accent
       (--danger-color) reads 3.76:1 on the card, below AA. Every future
       provider colour would need the same check, so the label takes a text
       token once and the border keeps the provider identity. */
    color: var(--text-secondary);
    font: var(--font-weight-semibold) var(--font-xs)/1 var(--font-mono);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.identity-gateway-meta {
    justify-content: flex-start;
    flex-wrap: wrap;
    color: var(--text-muted);
    font: var(--font-xs)/1.4 var(--font-mono);
}
.identity-gateway-meta span + span::before { content: "·"; margin-right: var(--space-2); }
.identity-gateway-field { display: grid; gap: var(--space-1); color: var(--text-secondary); font-size: var(--font-sm); }
.identity-gateway-field input { width: 100%; font-family: var(--font-mono); }
.identity-gateway-field .field-note { color: var(--text-muted); font-size: var(--font-xs); font-family: var(--font-base); }
.identity-gateway-secret { min-height: 24px; white-space: normal; overflow-wrap: anywhere; }
.identity-gateway-secret .status-pill { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.identity-gateway-toggle { justify-content: flex-start; color: var(--text-primary); font-size: var(--font-sm); }
.identity-gateway-toggle input { width: auto; min-width: var(--space-4); flex: 0 0 auto; }
.identity-gateway-toggle span { min-width: 0; overflow-wrap: anywhere; }
.identity-gateway-actions { margin-top: auto; align-items: flex-start; }
.identity-gateway-actions button { width: auto; }
.identity-gateway-actions .form-result { margin: 0; font-size: var(--font-xs); }
.identity-gateway-note { margin: var(--space-3) 0 0; color: var(--text-muted); font-size: var(--font-xs); }
.connector-control-panel { margin-top: var(--space-5); }
.connector-control-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.connector-control-card { min-height: 100%; }
.connector-control-card.provider-smtp { grid-column: 1 / -1; }
.connector-control-card.provider-atol { grid-column: 1 / -1; }
.connector-fields, .connector-secret-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.connector-fields, .connector-fields > *, .connector-field-group > *, .connector-secret-fields > * { min-width: 0; }
/* Text fields fill their grid cell; a checkbox must NOT. This rule sits after
 * .identity-gateway-toggle input { width: auto } and has the same specificity,
 * so an unqualified `input` here stretched the "implicit TLS" checkbox to the
 * full 440px cell — a giant box next to its own label. */
.connector-fields input:not([type="checkbox"]):not([type="radio"]),
.connector-fields select,
.connector-field-group input:not([type="checkbox"]):not([type="radio"]),
.connector-field-group select,
.connector-secret-fields input:not([type="checkbox"]):not([type="radio"]) { width: 100%; min-width: 0; }
.connector-secret-fields { padding: var(--space-3); border: 1px dashed var(--border-color); border-radius: var(--radius-md); background: color-mix(in srgb, var(--cw-surface) 94%, var(--provider-accent) 6%); }
.connector-secret-heading { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); min-width: 0; }
.connector-secret-fields, .connector-secret-heading > *, .connector-secret-note { min-width: 0; overflow-wrap: anywhere; }
.connector-secret-note { margin: 0; color: var(--text-muted); font-size: var(--font-xs); }
.connector-field-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    min-width: 0;
    padding: var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--cw-surface) 97%, var(--provider-accent) 3%);
}
.connector-field-group h5 {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--provider-accent);
    font: var(--font-weight-semibold) var(--font-xs)/1.3 var(--font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.connector-field-group-contour { grid-column: 1 / -1; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.connector-flags, .connector-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.connector-actions { justify-content: flex-start; }

/* Admission ledger: a quiet incident queue paired with the exact decision
   trace. The coloured rail carries severity without turning the operator
   console into a generic KPI dashboard. */
.risk-console {
    margin: var(--space-5) 0 var(--space-6);
    padding: var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--cw-surface) 94%, var(--warning-color) 6%);
}
.risk-console-heading { align-items: end; margin-bottom: var(--space-4); }
.risk-console-tools { display: flex; align-items: end; gap: var(--space-2); }
.risk-filter-label {
    display: grid;
    gap: var(--space-1);
    color: var(--text-muted);
    font-size: var(--font-xs);
}
.risk-filter-label select { min-width: 10rem; }
.risk-console-tools button { width: auto; }
.risk-console-grid {
    display: grid;
    grid-template-columns: minmax(18rem, 0.82fr) minmax(0, 1.45fr);
    min-height: 28rem;
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    background: var(--bg-primary);
    box-shadow: var(--shadow-1);
    overflow: hidden;
}
.risk-case-ledger {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    max-height: 46rem;
    padding: var(--space-2);
    overflow-y: auto;
    scrollbar-gutter: stable;
    border-right: 1px solid var(--border-color);
    background: var(--bg-secondary);
}
.risk-case-row {
    --risk-severity: var(--warning-color);
    display: grid;
    grid-template-columns: var(--space-2) minmax(0, 1fr) auto;
    gap: var(--space-2);
    align-items: stretch;
    width: 100%;
    padding: var(--space-3);
    color: var(--text-primary);
    text-align: left;
    border: 1px solid transparent;
    border-radius: var(--control-radius);
    background: transparent;
    box-shadow: none;
}
.risk-case-row:hover { background: var(--bg-primary); border-color: var(--border-color); transform: none; }
.risk-case-row:focus-visible { box-shadow: var(--focus-ring); }
.risk-case-row.selected {
    border-color: color-mix(in srgb, var(--risk-severity) 58%, var(--border-color));
    background: var(--bg-primary);
    box-shadow: var(--shadow-1);
}
.risk-ledger-more {
    flex: 0 0 auto;
    width: 100%;
    margin-top: var(--space-1);
    border-style: dashed;
}
.severity-low { --risk-severity: var(--success-color); }
.severity-medium { --risk-severity: var(--warning-color); }
.severity-high, .severity-critical { --risk-severity: var(--danger-color); }
.risk-case-rail { display: flex; justify-content: center; padding-block: var(--space-1); }
.risk-case-rail span { width: 3px; height: 100%; min-height: var(--space-6); border-radius: var(--radius-pill); background: var(--risk-severity); }
.risk-case-main, .risk-case-meta { display: flex; flex-direction: column; min-width: 0; }
.risk-case-main { gap: var(--space-1); }
.risk-case-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--font-sm); }
.risk-case-signal {
    color: var(--text-muted);
    font: var(--font-weight-semibold) var(--font-xs)/1.2 var(--font-mono);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.risk-case-time { color: var(--text-muted); font-size: var(--font-xs); }
.risk-case-meta { align-items: end; justify-content: space-between; gap: var(--space-2); }
.risk-case-meta code, .risk-detail-state code { color: var(--text-muted); font-size: var(--font-xs); }
.risk-status {
    display: inline-flex;
    align-items: center;
    width: max-content;
    padding: 2px var(--space-2);
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    font: var(--font-weight-semibold) var(--font-xs)/1.4 var(--font-mono);
}
.risk-status.open, .risk-status.active { color: var(--danger-text); background: var(--danger-bg); }
.risk-status.review { color: var(--warning-text); background: var(--warning-bg); }
.risk-status.resolved, .risk-status.released { color: var(--success-text); background: var(--success-bg); }
.risk-case-detail {
    min-width: 0;
    max-height: 46rem;
    padding: var(--space-5);
    overflow-y: auto;
    scrollbar-gutter: stable;
    outline: none;
}
.risk-detail-empty, .risk-ledger-empty {
    display: grid;
    place-items: center;
    align-content: center;
    gap: var(--space-3);
    min-height: 100%;
    padding: var(--space-6);
    color: var(--text-muted);
    text-align: center;
}
.risk-detail-mark, .risk-ledger-pulse {
    display: block;
    width: var(--space-4);
    height: var(--space-4);
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: var(--radius-pill);
}
.risk-ledger-pulse { border-color: var(--success-color); background: var(--success-bg); }
.risk-detail-header { --risk-severity: var(--warning-color); display: flex; justify-content: space-between; gap: var(--space-4); padding-bottom: var(--space-4); border-bottom: 3px solid var(--risk-severity); }
.risk-detail-header h4 { margin: var(--space-1) 0 0; font-size: var(--font-lg); }
.risk-detail-state { display: flex; flex-direction: column; align-items: end; justify-content: space-between; gap: var(--space-2); }
.risk-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); margin: var(--space-4) 0; }
.risk-facts div { min-width: 0; padding: var(--space-2); border: 1px solid var(--border-color); border-radius: var(--control-radius); background: var(--bg-secondary); }
.risk-facts dt { color: var(--text-muted); font-size: var(--font-xs); overflow-wrap: anywhere; }
.risk-facts dd { margin: var(--space-1) 0 0; overflow-wrap: anywhere; color: var(--text-primary); font-size: var(--font-sm); font-weight: var(--font-weight-semibold); }
.risk-detail-section { margin-top: var(--space-5); }
.risk-detail-section h5 { margin: 0 0 var(--space-2); color: var(--text-secondary); font-size: var(--font-sm); }
.risk-enforcement {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--success-color);
    border-radius: var(--control-radius);
    background: var(--bg-secondary);
}
.risk-enforcement.active { border-left-color: var(--danger-color); }
.risk-enforcement > div { display: grid; gap: var(--space-1); min-width: 0; }
.risk-enforcement > div > span:last-child { color: var(--text-secondary); font-size: var(--font-xs); }
.risk-enforcement-kind { color: var(--text-secondary); font: var(--font-xs)/1.2 var(--font-mono); text-transform: uppercase; }
.risk-enforcement button { flex: 0 0 auto; width: auto; }
.risk-trace { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.risk-trace-event { position: relative; display: grid; grid-template-columns: var(--space-4) minmax(0, 1fr); gap: var(--space-2); min-width: 0; padding-bottom: var(--space-4); }
.risk-trace-event::before { content: ""; position: absolute; top: var(--space-3); bottom: 0; left: calc(var(--space-2) - 1px); width: 2px; background: var(--border-color); }
.risk-trace-event:last-child::before { display: none; }
.risk-trace-dot { z-index: 1; width: var(--space-3); height: var(--space-3); margin-top: var(--space-1); border: 3px solid var(--bg-primary); border-radius: var(--radius-pill); background: var(--accent-color); box-shadow: 0 0 0 1px var(--border-color); }
.risk-trace-head { display: flex; justify-content: space-between; gap: var(--space-3); }
.risk-trace-head time { color: var(--text-muted); font-size: var(--font-xs); }
.risk-trace-event p { margin: var(--space-1) 0; color: var(--text-secondary); font-size: var(--font-sm); }
.risk-evidence { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.risk-evidence span { padding: 2px var(--space-2); border-radius: var(--radius-pill); color: var(--text-muted); background: var(--bg-tertiary); font: var(--font-xs)/1.4 var(--font-mono); }
.risk-evidence b { color: var(--text-secondary); }

.linked-identities-panel {
    margin: var(--space-4) 0 var(--space-6);
    padding: var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--cw-surface) 94%, var(--accent-color) 6%);
}
.security-review-center {
    margin: var(--space-6) 0;
    padding: var(--space-4);
    border: 1px solid color-mix(in srgb, var(--warning-color) 35%, var(--border-color));
    border-radius: var(--radius-lg);
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--warning-color) 7%, transparent), transparent 62%),
        var(--cw-surface-sunken);
}
.customer-risk-list { display: grid; gap: var(--space-2); }
.customer-risk-case {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
    padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    background: var(--bg-primary);
    box-shadow: var(--shadow-1);
    overflow: hidden;
}
.customer-risk-rail {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--space-2);
    background: var(--accent-color);
}
.customer-risk-case[data-review-status="action_required"] .customer-risk-rail { background: var(--danger-color); }
.customer-risk-case[data-review-status="resolved"] .customer-risk-rail { background: var(--success-color); }
.customer-risk-main { min-width: 0; }
.customer-risk-reference { display: grid; gap: 2px; }
.customer-risk-reference span,
.customer-risk-main time,
.customer-risk-appeal-state { color: var(--text-muted); font-size: var(--font-xs); }
.customer-risk-reference code {
    color: var(--text-primary);
    font: var(--font-xs)/1.5 var(--font-mono);
    overflow-wrap: anywhere;
    user-select: all;
}
.customer-risk-main time { display: block; margin-top: var(--space-1); }
.customer-risk-state { display: grid; justify-items: start; gap: var(--space-1); }
.customer-risk-action button { width: auto; white-space: nowrap; }
.customer-risk-empty {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px dashed var(--border-color);
    border-radius: var(--control-radius);
    background: var(--bg-primary);
}
.customer-risk-empty-mark {
    display: grid;
    place-items: center;
    flex: 0 0 var(--space-6);
    width: var(--space-6);
    height: var(--space-6);
    border-radius: var(--radius-pill);
    background: var(--success-bg);
    color: var(--success-text);
    font-weight: var(--font-weight-bold);
}
.customer-risk-empty strong { display: block; font-size: var(--font-sm); }
.customer-risk-empty p { margin: 2px 0 0; color: var(--text-secondary); font-size: var(--font-xs); }
.risk-appeal-dialog { max-width: var(--modal-w-md); }
.risk-appeal-dialog form { display: grid; gap: var(--space-3); margin: 0; }
.risk-appeal-dialog h3 { margin: 0; }
.risk-appeal-reference { margin: 0; color: var(--text-secondary); font-size: var(--font-sm); }
.risk-appeal-reference code { display: block; margin-top: var(--space-1); color: var(--text-primary); overflow-wrap: anywhere; user-select: all; }
#riskAppealCompose { display: grid; gap: var(--space-2); }
#riskAppealCompose label { font-size: var(--font-sm); font-weight: var(--font-weight-semibold); }
#riskAppealCompose textarea { width: 100%; resize: vertical; }
.risk-appeal-history { display: grid; gap: var(--space-2); padding: var(--space-3); border: 1px solid var(--border-color); border-radius: var(--control-radius); background: var(--bg-secondary); }
.risk-appeal-history div { min-width: 0; }
.risk-appeal-history span { display: block; color: var(--text-muted); font-size: var(--font-xs); }
.risk-appeal-history p { margin: var(--space-1) 0 0; color: var(--text-primary); font-size: var(--font-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.risk-appeal-history strong { color: var(--text-primary); font-size: var(--font-sm); }
.privacy-center {
    margin: var(--space-6) 0;
    padding: var(--space-4);
    border: 1px solid color-mix(in srgb, var(--accent-color) 30%, var(--border-color));
    border-radius: var(--radius-lg);
    background:
        linear-gradient(145deg, color-mix(in srgb, var(--accent-color) 7%, transparent), transparent 58%),
        var(--cw-surface-sunken);
}
.privacy-purpose-list { display: grid; gap: var(--space-2); }
.privacy-purpose {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-2) var(--space-4);
    padding: var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    background: var(--bg-primary);
}
.privacy-purpose-main { min-width: 0; }
.privacy-purpose-main strong { display: block; margin-bottom: 2px; font-size: var(--font-sm); }
.privacy-purpose-main p { margin: 0; color: var(--text-secondary); font-size: var(--font-xs); }
.privacy-purpose-meta { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-2); }
.privacy-purpose-meta span {
    padding: 2px var(--space-2);
    border-radius: var(--radius-pill);
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font: var(--font-xs)/1.4 var(--font-mono);
}
.privacy-toggle { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-secondary); font-size: var(--font-xs); }
.privacy-toggle input { width: auto; min-width: var(--space-4); min-height: var(--space-4); accent-color: var(--accent-color); }
.privacy-required {
    width: fit-content;
    padding: 3px var(--space-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-semibold);
}
.privacy-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-color);
}
.privacy-actions strong, .privacy-actions span { display: block; }
.privacy-actions strong { font-size: var(--font-sm); }
.privacy-actions span { margin-top: 2px; color: var(--text-secondary); font-size: var(--font-xs); }
.privacy-actions button { flex: 0 0 auto; width: auto; }
.privacy-correction {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 1fr);
    align-items: end;
    gap: var(--space-4);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-color);
}
.privacy-correction label, .privacy-correction span { display: block; }
.privacy-correction label { font-size: var(--font-sm); font-weight: var(--font-weight-semibold); }
.privacy-correction span { margin-top: 2px; color: var(--text-secondary); font-size: var(--font-xs); }
.privacy-correction-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2); }
.privacy-correction-control button { width: auto; white-space: nowrap; }
.privacy-request-heading { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border-color); }
.privacy-request-heading strong, .privacy-request-heading span { display: block; }
.privacy-request-heading strong { font-size: var(--font-sm); }
.privacy-request-heading span { margin-top: 2px; color: var(--text-secondary); font-size: var(--font-xs); }
.privacy-request-list { display: grid; gap: var(--space-2); margin-top: var(--space-3); }
.privacy-request {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-1) var(--space-3);
    padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    background: var(--bg-primary);
}
.privacy-request::before {
    content: '';
    position: absolute;
    top: var(--space-3);
    bottom: var(--space-3);
    left: var(--space-2);
    width: 3px;
    border-radius: var(--radius-pill);
    background: var(--border-color);
}
.privacy-request[data-status="completed"]::before { background: var(--success-color); }
.privacy-request[data-status="blocked"]::before,
.privacy-request[data-status="failed"]::before { background: var(--danger-color); }
.privacy-request[data-status="queued"]::before,
.privacy-request[data-status="processing"]::before { background: var(--accent-color); }
.privacy-request strong { font-size: var(--font-sm); }
.privacy-request time { display: block; color: var(--text-muted); font: var(--font-xs)/1.4 var(--font-mono); }
.privacy-request-detail { grid-column: 1 / -1; color: var(--text-secondary); font-size: var(--font-xs); }
.privacy-request-status {
    align-self: start;
    padding: 2px var(--space-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-semibold);
}
.linked-identities-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-3);
}
.linked-identity-card {
    --provider-accent: var(--accent-color);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    min-width: 0;
    padding: var(--space-3);
    border: 1px solid color-mix(in srgb, var(--provider-accent) 28%, var(--border-color));
    border-left: 3px solid var(--provider-accent);
    border-radius: var(--control-radius);
    background: var(--bg-primary);
}
.linked-identity-card.provider-yandex { --provider-accent: var(--danger-color); }
.linked-identity-card.provider-vk { --provider-accent: var(--accent-color); }
.linked-identity-card.provider-github { --provider-accent: var(--text-secondary); }
.linked-identity-card.provider-google { --provider-accent: var(--warning-color); }
.linked-identity-card.provider-gitlab { --provider-accent: var(--success-color); }
.linked-identity-card h4 { margin: 0; font-size: var(--font-sm); }
.linked-identity-card .linked-identity-state { color: var(--text-muted); font-size: var(--font-xs); }
.linked-identity-card button { grid-column: 2; grid-row: 1 / span 2; width: auto; }
.linked-identity-card button.secondary { color: var(--danger-text, var(--danger-color)); }
@media (max-width: 1120px) {
    .identity-gateway-grid, .linked-identities-grid, .platform-settings-grid, .connector-control-grid { grid-template-columns: minmax(0, 1fr); }
    .connector-control-card.provider-smtp, .connector-control-card.provider-atol { grid-column: auto; }
    .platform-settings-grid .platform-settings-wide { grid-column: auto; }
    .connector-field-group-contour { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .risk-console-grid { grid-template-columns: minmax(0, 1fr); }
    .risk-case-ledger { max-height: 22rem; border-right: 0; border-bottom: 1px solid var(--border-color); }
    .risk-case-detail { max-height: none; }
    .risk-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .identity-gateway-panel, .linked-identities-panel, .security-review-center, .risk-console { padding: var(--space-3); }
    .identity-gateway-card-head, .identity-gateway-actions { align-items: stretch; flex-direction: column; }
    .identity-gateway-actions button { width: 100%; }
	.connector-fields, .connector-secret-fields, .connector-field-group { grid-template-columns: minmax(0, 1fr); }
	.connector-secret-heading { grid-column: auto; align-items: flex-start; flex-direction: column; }
	.connector-field-group h5, .connector-field-group-contour { grid-column: auto; }
	.linked-identity-card { grid-template-columns: minmax(0, 1fr); }
    .linked-identity-card button { grid-column: 1; grid-row: auto; width: 100%; }
    .customer-risk-case { grid-template-columns: minmax(0, 1fr); align-items: stretch; }
    .customer-risk-action button { width: 100%; }
    .privacy-purpose { grid-template-columns: minmax(0, 1fr); }
    .privacy-toggle, .privacy-required { justify-self: start; }
    .privacy-actions { align-items: stretch; flex-direction: column; }
    .privacy-actions button { width: 100%; }
    .privacy-correction { grid-template-columns: minmax(0, 1fr); }
    .privacy-correction-control { grid-template-columns: minmax(0, 1fr); }
    .privacy-correction-control button { width: 100%; }
    .privacy-request { grid-template-columns: minmax(0, 1fr); }
    .privacy-request-status { justify-self: start; }
    .risk-console-heading, .risk-console-tools, .risk-detail-header, .risk-enforcement, .risk-trace-head { align-items: stretch; flex-direction: column; }
    .risk-console-tools button, .risk-filter-label select, .risk-enforcement button { width: 100%; }
    .risk-case-detail { padding: var(--space-3); }
    .risk-detail-state { align-items: start; }
    .risk-facts { grid-template-columns: minmax(0, 1fr); }
}

/* Abuse-report queue (operator console). Mirrors the
   .audit-row pattern with a child row for description
   + an action button row underneath. */
.audit-row-sub {
    grid-template-columns: minmax(0, 1fr);
    background: var(--bg-secondary, var(--bg-primary));
    color: var(--text-muted);
    font-family: var(--font-base, var(--font-mono));
    font-style: italic;
    border-style: dashed;
}
.abuse-actions {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    padding: var(--space-1) var(--space-3);
    border: 1px dashed var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--control-radius) var(--control-radius);
    background: var(--bg-secondary, var(--bg-primary));
}
.sub-sub {
    margin: var(--space-3) 0 var(--space-1);
    font-size: var(--font-sm);
    /* AA: uppercase label → --text-secondary (muted fails 4.5 on white). */
    color: var(--text-secondary);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
/* Filter row above the abuse list. Three compact
   controls + a reset button on a single line; wraps
   to a second line on narrow viewports. */
.abuse-filter-row {
    display: flex;
    gap: var(--space-3);
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: var(--space-2);
    padding: var(--space-2);
    background: var(--bg-secondary, var(--bg-primary));
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
}
.abuse-filter-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    font-size: var(--font-sm);
    /* AA: filter labels need --text-secondary (muted is 4.35 on white). */
    color: var(--text-secondary);
}
.abuse-filter-field-grow { flex: 1 1 200px; min-width: 160px; }
.abuse-filter-field select,
.abuse-filter-field input {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    padding: var(--space-1) var(--space-2);
    font-size: var(--font-sm);
}
/* "Load more" button row at the bottom of the closed
   list. Centered + small — the operator clicks it to
   walk the historical queue without a page-reload. */
.abuse-load-more-row {
    display: flex;
    justify-content: center;
    padding: var(--space-2) 0;
}

/* ---------- Theme / language switcher ---------- */

.theme-switcher, .lang-switcher {
    display: inline-flex;
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    background: var(--bg-primary);
    overflow: hidden;
}
.theme-switcher button, .lang-switcher button {
    background: transparent;
    color: var(--text-muted);
    border: 0;
    border-radius: 0;
    height: var(--btn-h-sm);
    padding: 0 var(--space-3);
    font-size: var(--font-sm);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
}
.theme-switcher button[aria-pressed="true"], .lang-switcher button[aria-pressed="true"] {
    /* Active segment: same AA-readable accent chip recipe as .badge. */
    background: var(--cw-chip-bg);
    color: var(--cw-chip-text);
    font-weight: var(--font-weight-semibold);
}
.theme-switcher button:hover:not([aria-pressed="true"]),
.lang-switcher button:hover:not([aria-pressed="true"]) {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ---------- Toast / live region (a11y) ----------
 * The screen-reader announcement lives in a polite live region
 * (aria-live=polite) so AT users hear status changes without
 * stealing focus.
 */
.toast-region {
    position: fixed;
    top: var(--space-4);
    right: var(--space-4);
    z-index: var(--z-toast, 100000);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-sm);
    box-shadow: var(--shadow-3);
    max-width: 360px;
    animation: toast-in 0.18s ease-out;
}
.toast.success { border-left: 3px solid var(--success-color); }
.toast.error { border-left: 3px solid var(--danger-color); }
@keyframes toast-in {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ---------- Operator console inner card ---------- */

.card-inner {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-3);
}
.card-inner .health-cell {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: var(--space-1);
    padding: var(--space-3);
    background: var(--bg-secondary);
    border-radius: var(--control-radius);
    border: 1px solid var(--border-color);
}
.card-inner .health-label {
    font-size: var(--font-xs);
    /* AA: uppercase metric labels need --text-secondary (muted is 4.35 on white). */
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: var(--font-weight-semibold);
    overflow-wrap: anywhere;
}
.card-inner .health-value {
    font-size: var(--font-md);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.card-inner .health-value.ok { color: var(--success-text); }
.card-inner .health-value.bad { color: var(--danger-text, var(--danger-color)); }

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================================
   Notifications bell + dropdown
   ============================================================ */
.user-menu {
    position: relative; /* anchor for the dropdown */
}

.icon-btn {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--control-radius);
    width: var(--btn-h-sm);
    height: var(--btn-h-sm);
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: var(--font-md);
    line-height: 1;
}
.icon-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.icon-btn[aria-expanded="true"] {
    background: var(--bg-secondary);
}

.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 var(--space-1);
    border-radius: var(--radius-pill);
    /* Fixed deep red so the white count passes AA in both themes
       (dark --danger-color #f87171 + white = 2.77). */
    background: #dc2626; /* ui-lint-ok: solid count badge, white text needs AA in both themes */
    color: #ffffff; /* ui-lint-ok: on-fill text for the count badge */
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    font-weight: var(--font-weight-semibold);
    pointer-events: none;
}

.notif-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    width: min(360px, 90vw);
    max-height: 70vh;
    overflow-y: auto;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-3);
    z-index: var(--z-dropdown);
}
.notif-dropdown[hidden] { display: none; }

.notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
}
.notif-header h3 {
    margin: 0;
    font-size: var(--font-sm);
}

.notif-list {
    padding: var(--space-1);
}
.notif-item {
    padding: var(--space-3);
    border-radius: var(--control-radius);
    cursor: default;
    margin: 2px 0;
}
.notif-item:hover {
    background: var(--bg-secondary);
}
.notif-item.unread {
    background: var(--accent-primary-subtle);
}
.notif-title {
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-sm);
    margin-bottom: 2px;
}
.notif-body {
    font-size: var(--font-sm);
    color: var(--text-secondary);
}
.notif-time {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}
.notif-link {
    color: var(--accent-hover);
    text-decoration: none;
}
.notif-link:hover { text-decoration: underline; }

/* ============================================================
   Subscription + Invoices
   ============================================================ */
.plan-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
}
.plan-label {
    font-size: var(--font-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    /* AA: --text-secondary (muted is 4.35 on white). */
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}
.plan-value {
    font-size: var(--font-xl);
    font-weight: var(--font-weight-bold);
    text-transform: capitalize;
}
.plan-meta {
    font-size: var(--font-xs);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}
.plan-actions {
    display: flex;
    gap: var(--space-2);
}

.plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}
.checkout-renewal-consent {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    margin: 0 0 var(--space-4);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    cursor: pointer;
}
.checkout-renewal-consent input {
    width: auto;
    margin-top: 0.2rem;
}
.checkout-renewal-consent span {
    display: grid;
    gap: var(--space-1);
}
.checkout-renewal-consent strong { font-size: var(--font-sm); }
.checkout-renewal-consent small { color: var(--text-secondary); }
.checkout-renewal-consent:has(input:focus-visible) {
    outline: none;
    box-shadow: var(--focus-ring);
}
.plan-card {
    min-width: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.plan-card.current {
    border-color: var(--accent-color);
    border-width: 2px;
}
.plan-card h4 {
    margin: 0;
    font-size: var(--font-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.plan-card .price {
    font-size: var(--font-lg);
    font-weight: var(--font-weight-bold);
    overflow-wrap: anywhere;
}
.plan-card .note {
    font-size: var(--font-xs);
    color: var(--text-secondary);
}
/* What the plan adds over the current one. It sits above the buttons because
   it is the reason to press them, and it wraps rather than truncating: a
   clipped "Wiki, tasks and mess…" is exactly the information the card exists
   to give. */
.plan-card-gains {
    color: var(--text-primary);
    font-size: var(--font-xs);
    line-height: 1.4;
    margin: var(--space-2) 0;
}
.plan-card-actions { display: grid; gap: var(--space-2); margin-top: auto; min-width: 0; }
.plan-card-actions > * { min-width: 0; }
.plan-card-actions button, .plan-card-actions .btn { height: auto; min-height: var(--btn-h); padding-top: var(--space-2); padding-bottom: var(--space-2); white-space: normal; line-height: var(--line-height-normal); text-align: center; }
.plan-card button {
    margin-top: 0;
    width: 100%;
    height: auto;
    min-height: var(--btn-h);
    padding-block: var(--space-2);
    text-align: center;
    white-space: normal;
}

@media (max-width: 560px) {
    .plan-summary { align-items: stretch; flex-direction: column; }
    .plan-actions { flex-wrap: wrap; }
    .plan-actions button { height: auto; min-height: var(--btn-h-sm); white-space: normal; }
    .plan-grid { grid-template-columns: minmax(0, 1fr); }
}

.invoice-list {
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    overflow: hidden;
}
.invoice-row {
    width: 100%;
    /* The row is a <button>; the global control height (36px) would pin it
       and its three stacked grid rows on narrow screens overlapped each other
       (live 375px, 2026-09-05). Content sets the height. */
    height: auto;
    min-height: 0;
    margin: 0;
    color: inherit;
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: 0;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr auto;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    font-size: var(--font-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.invoice-row:hover {
    background: var(--bg-secondary);
}
.invoice-row:focus-visible {
    position: relative;
    z-index: 1;
    outline: none;
    box-shadow: var(--focus-ring);
}
.invoice-row:last-child { border-bottom: 0; }
.invoice-row .inv-num { font-weight: var(--font-weight-semibold); }
.invoice-row .inv-amount { font-variant-numeric: tabular-nums; }
.invoice-row .inv-chevron { justify-self: end; }
.invoice-row .inv-status {
    font-size: var(--font-xs);
    padding: var(--badge-pad-y) var(--badge-pad-x);
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    display: inline-block;
    text-align: center;
}
@media (max-width: 560px) {
    .invoice-row {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "number status"
            "period period"
            "amount chevron";
        gap: var(--space-2) var(--space-3);
    }
    .invoice-row .inv-num { grid-area: number; }
    .invoice-row .inv-period { grid-area: period; color: var(--text-secondary); }
    .invoice-row .inv-amount { grid-area: amount; }
    .invoice-row .inv-status { grid-area: status; }
    .invoice-row .inv-chevron { grid-area: chevron; }
}
/* Invoice status pills reuse the semantic, theme-aware status tokens. The
   previous version hardcoded light-only hex AND used a dead `[data-theme="dark"]`
   selector (the app toggles theme via .light/.dark classes on <html>, never a
   data-theme attribute) — so the dark overrides never applied and dark mode
   showed light-tuned text. Tokens handle both themes in one declaration. */
.inv-status-paid { background: var(--success-bg); color: var(--success-text); }
.inv-status-open { background: var(--warning-bg); color: var(--warning-text); }
.inv-status-void,
.inv-status-draft { background: var(--bg-tertiary); color: var(--text-muted); }
.inv-status-uncollectible { background: var(--danger-bg); color: var(--danger-text, var(--danger-color)); }

/* ============================================================
   API Tokens
   ============================================================ */
.token-list, .webhook-list {
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    overflow: hidden;
    margin-top: var(--space-3);
}
.token-row, .webhook-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr auto;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    font-size: var(--font-sm);
}
.token-row:last-child, .webhook-row:last-child { border-bottom: 0; }
.webhook-row > span:first-child small {
    display: block;
    margin-top: var(--space-1);
    color: var(--text-muted);
    overflow-wrap: anywhere;
}
.webhook-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    justify-content: flex-end;
}
.webhook-deliveries-panel {
    grid-column: 1 / -1;
    border-top: 1px solid var(--border-color);
    padding-top: var(--space-2);
}
.webhook-delivery-row {
    display: grid;
    grid-template-columns: minmax(10rem, 1fr) minmax(8rem, auto) minmax(8rem, auto);
    gap: var(--space-3);
    padding: var(--space-2) 0;
    color: var(--text-secondary);
}
.webhook-delivery-row code { color: var(--text-primary); }
@media (max-width: 900px) {
    .webhook-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .webhook-actions { justify-content: flex-start; }
}
@media (max-width: 1100px) {
    .provider-pool-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .provider-pool-form-grid .provider-pool-capabilities { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
    .provider-pool-form-grid, .provider-pool-grid { grid-template-columns: minmax(0, 1fr); }
    .provider-pool-form-grid .provider-pool-capabilities { grid-column: auto; }
    .provider-bootstrap-reveal { align-items: stretch; flex-direction: column; }
}
@media (max-width: 560px) {
    .webhook-row, .webhook-delivery-row { grid-template-columns: minmax(0, 1fr); }
}
.token-prefix {
    font-family: var(--font-mono);
    background: var(--bg-secondary);
    padding: 2px var(--space-2);
    border-radius: var(--radius-xs);
    font-size: var(--font-xs);
}

.created-token-display {
    background: var(--bg-secondary);
    padding: var(--space-3);
    border-radius: var(--control-radius);
    margin: var(--space-2) 0;
    font-family: var(--font-mono);
    font-size: var(--font-xs);
    word-break: break-all;
}

/* Enterprise SCIM provisioning panel (Team section). Set off from the invite
   list above it with a top border so it reads as a distinct capability. */
.scim-panel {
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-color);
}
.scim-status {
    margin: var(--space-2) 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}
.scim-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    font-size: var(--font-sm);
}
.scim-key {
    color: var(--text-secondary);
    min-width: 8.5rem;
}
.scim-val {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: var(--font-xs);
    word-break: break-all;
}
.saml-field {
    display: block;
    margin: var(--space-2) 0;
}
.saml-field span {
    display: block;
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}
.saml-field textarea {
    width: 100%;
    font-family: var(--font-mono);
    font-size: var(--font-xs);
    resize: vertical;
}
.saml-check {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-sm);
    margin: var(--space-2) 0;
}

.events-fs {
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    padding: var(--space-2) var(--space-3);
    margin: 0;
}
.events-fs legend {
    font-size: var(--font-xs);
    padding: 0 var(--space-1);
    color: var(--text-secondary);
}
.events-fs label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    margin: 2px var(--space-2) 2px 0;
    font-size: var(--font-xs);
}

/* ============================================================
   Profile
   ============================================================ */
.danger-zone {
    /* --danger-text is AA on both theme surfaces (light #dc2626 / dark #f87171);
       --danger-color is tuned for fills, not small heading text. */
    color: var(--danger-text, var(--danger-color));
}
/* #sec-profile button.danger inherits the global button.danger recipe
   (fixed #dc2626 fill + white text, AA in both themes) — no override needed. */

/* ============================================================
   API tester (mini-Postman)
   ============================================================
   Two-column layout for method + URL. Header rows repeat; the
   "Add header" button clones an empty row. Response panel is a
   stack: status pill → collapsible headers → body pre. The
   status pill uses semantic colors (2xx=success, 3xx=info,
   4xx=warn, 5xx=danger) so the result is readable at a glance.
*/
#sec-api-tester .at-row {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: var(--space-3);
}
@media (max-width: 720px) {
    #sec-api-tester .at-row { grid-template-columns: minmax(0, 1fr); }
}
#sec-api-tester .at-headers-fs {
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    padding: var(--space-3);
    margin: 0;
    background: var(--bg-secondary);
}
#sec-api-tester .at-headers-fs legend {
    font-size: var(--font-sm);
    padding: 0 var(--space-2);
    color: var(--text-muted);
}
#sec-api-tester .at-hdr-row {
    display: grid;
    grid-template-columns: minmax(140px, 1fr) 2fr auto;
    gap: var(--space-2);
    align-items: center;
    margin-bottom: var(--space-2);
}
#sec-api-tester .at-hdr-row input {
    width: 100%;
    height: var(--btn-h-sm);
    padding: 0 var(--control-pad-x);
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    font: inherit;
    font-size: var(--font-sm);
}
#sec-api-tester .at-hdr-row input:focus-visible {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: var(--focus-ring);
}
#sec-api-tester .at-hdr-del {
    width: var(--btn-h-sm);
    height: var(--btn-h-sm);
    padding: 0;
    font-size: var(--font-md);
}
#sec-api-tester .at-response {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    padding: var(--space-3);
    margin-bottom: var(--space-3);
}
#sec-api-tester .at-status {
    display: flex;
    align-items: baseline;
    gap: var(--space-3);
    flex-wrap: wrap;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--control-radius);
    font-family: var(--font-mono);
    font-size: var(--font-sm);
    margin-bottom: var(--space-3);
}
#sec-api-tester .at-status.status-2xx {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid color-mix(in srgb, var(--success-color) 30%, transparent);
}
#sec-api-tester .at-status.status-3xx {
    background: var(--info-bg);
    color: var(--info-text);
    border: 1px solid color-mix(in srgb, var(--info-color) 30%, transparent);
}
#sec-api-tester .at-status.status-4xx {
    background: color-mix(in srgb, var(--warning-color) 22%, transparent);
    color: var(--warning-text);
    border: 1px solid color-mix(in srgb, var(--warning-color) 35%, transparent);
}
#sec-api-tester .at-status.status-5xx,
#sec-api-tester .at-status.status-info {
    background: var(--danger-bg);
    color: var(--danger-text, var(--danger-color));
    border: 1px solid color-mix(in srgb, var(--danger-color) 30%, transparent);
}
#sec-api-tester .at-status-code {
    font-weight: var(--font-weight-bold);
    font-size: var(--font-md);
}
#sec-api-tester .at-status-text {
    color: inherit;
    opacity: 0.85;
}
#sec-api-tester .at-elapsed {
    margin-left: auto;
    color: var(--text-muted);
    font-size: var(--font-xs);
}
#sec-api-tester .at-truncated {
    color: var(--warning-text);
    font-size: var(--font-xs);
    margin-bottom: var(--space-2);
}
#sec-api-tester .at-headers-details {
    margin-bottom: var(--space-3);
}
#sec-api-tester .at-headers-details summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: var(--font-sm);
    user-select: none;
}
#sec-api-tester .at-headers-list {
    margin-top: var(--space-2);
    background: var(--bg-secondary);
    border-radius: var(--control-radius);
    padding: var(--space-2);
    max-height: 220px;
    overflow: auto;
}
#sec-api-tester .at-headers-list .at-hdr-row {
    grid-template-columns: minmax(120px, 1fr) 2fr;
    font-family: var(--font-mono);
    font-size: var(--font-xs);
    margin-bottom: 0;
    padding: 2px 0;
}
#sec-api-tester .at-headers-list .at-hdr-key {
    color: var(--accent-color);
    word-break: break-all;
}
#sec-api-tester .at-headers-list .at-hdr-val {
    color: var(--text-primary);
    word-break: break-all;
}
#sec-api-tester .at-sub {
    font-size: var(--font-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0 0 var(--space-2);
    font-weight: var(--font-weight-semibold);
}
#sec-api-tester .at-body {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    padding: var(--space-3);
    font-family: var(--font-mono);
    font-size: var(--font-sm);
    color: var(--text-primary);
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 360px;
    overflow: auto;
}
#sec-api-tester .at-history-head {
    display: flex;
    justify-content: flex-end;
    margin-bottom: var(--space-2);
}
#sec-api-tester .at-history {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}
#sec-api-tester .at-hist-row {
    display: grid;
    grid-template-columns: 70px 1fr 60px 160px;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    font-size: var(--font-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
}
#sec-api-tester .at-hist-row:hover {
    background: var(--bg-secondary);
}
#sec-api-tester .at-hist-method {
    font-family: var(--font-mono);
    font-weight: var(--font-weight-bold);
    font-size: var(--font-xs);
    text-align: center;
    padding: 2px var(--space-2);
    border-radius: var(--badge-tag-radius);
    text-transform: uppercase;
}
#sec-api-tester .at-hist-method.GET { background: var(--success-bg); color: var(--success-text); }
#sec-api-tester .at-hist-method.POST { background: var(--accent-light); color: var(--accent-color); }
#sec-api-tester .at-hist-method.PUT { background: color-mix(in srgb, var(--warning-color) 22%, transparent); color: var(--warning-text); }
#sec-api-tester .at-hist-method.DELETE { background: var(--danger-bg); color: var(--danger-text, var(--danger-color)); }
#sec-api-tester .at-hist-method.PATCH { background: var(--border-color); color: var(--text-secondary); }
#sec-api-tester .at-hist-url {
    font-family: var(--font-mono);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
#sec-api-tester .at-hist-status {
    font-family: var(--font-mono);
    font-weight: var(--font-weight-bold);
    font-size: var(--font-xs);
    text-align: center;
    padding: 2px var(--space-2);
    border-radius: var(--badge-tag-radius);
}
#sec-api-tester .at-hist-status.status-2xx { background: var(--success-bg); color: var(--success-text); }
#sec-api-tester .at-hist-status.status-3xx { background: var(--info-bg); color: var(--info-text); }
#sec-api-tester .at-hist-status.status-4xx { background: color-mix(in srgb, var(--warning-color) 22%, transparent); color: var(--warning-text); }
#sec-api-tester .at-hist-status.status-5xx { background: var(--danger-bg); color: var(--danger-text, var(--danger-color)); }
#sec-api-tester .at-hist-status.status-info { background: var(--bg-secondary); color: var(--text-muted); }
#sec-api-tester .at-hist-time {
    color: var(--text-muted);
    font-size: var(--font-xs);
    font-family: var(--font-mono);
}
@media (max-width: 720px) {
    #sec-api-tester .at-hist-row {
        grid-template-columns: 70px 1fr;
    }
    #sec-api-tester .at-hist-status,
    #sec-api-tester .at-hist-time { grid-column: 1 / -1; }
}

.modal-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-modal);
    padding: var(--space-5);
    max-width: 500px;
    width: 90vw;
    background: var(--bg-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-4);
}
.modal-card::backdrop {
    background: rgba(15, 23, 42, 0.5); /* ui-lint-ok: dialog backdrop scrim, theme-independent dim */
    backdrop-filter: blur(2px);
}

/* ---------- Themed confirm / prompt dialog ----------
 * Native <dialog> built by app.js cwConfirm/cwPrompt — replaces the OS
 * alert/confirm/prompt with a themed, accessible card (Esc cancels, Enter
 * confirms, focus moves inside). Reuses the .modal-card shell. */
.cw-confirm-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    margin: 0;
}
.cw-confirm-msg {
    margin: 0;
    font-size: var(--font-base);
    color: var(--text-primary);
    line-height: 1.5;
}
.cw-confirm-input {
    width: 100%;
    height: var(--control-h);
    padding: 0 var(--control-pad-x);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    font: inherit;
    font-size: var(--control-font);
}
.cw-confirm-input:focus-visible {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: var(--focus-ring);
}
.cw-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.link-btn {
    background: transparent;
    border: 0;
    padding: var(--space-1) var(--space-2);
    /* --accent-hover (#1a73d4) = 4.72:1 on white vs --accent-color's 3.28 —
       a text link needs the AA-passing tone. Dark theme --accent-hover #2d8cf0
       reads fine on the dark surface. */
    color: var(--accent-hover);
    cursor: pointer;
    font-size: var(--font-sm);
    text-decoration: underline;
}
.link-btn:hover { color: var(--accent-color); }

.tos-checkbox {
    display: block;
    font-size: var(--font-sm);
}
.tos-checkbox .checkbox-row {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    align-items: start;
    gap: var(--space-2);
    color: var(--text-secondary);
    line-height: 1.5;
    cursor: pointer;
}
.tos-checkbox input {
    width: 18px;
    height: 18px;
    margin: 0.15em 0 0;
    accent-color: var(--accent-color);
}

.created-secret-display {
    background: var(--bg-secondary);
    padding: var(--space-3);
    border-radius: var(--control-radius);
    margin: var(--space-2) 0;
    font-family: var(--font-mono);
    font-size: var(--font-xs);
    word-break: break-all;
}

/* Touch ergonomics (owner sign-off 2026-06-19): on mobile the header controls
   reach the 44px tap-target ideal (WCAG 2.5.5). Desktop keeps the main app's
   compact density via --btn-h-sm. */
@media (max-width: 720px) {
    .icon-btn {
        width: 44px;
        height: 44px;
    }
    .theme-switcher button,
    .lang-switcher button,
    .section-tab,
    .cabinet-nav-toggle,
    #signOutBtn {
        min-height: 44px;
    }
    .cabinet-identity {
        flex: 1 0 100%;
        order: -1;
    }
}


/* Social sign-in (OAuth) — Яндекс/VK/GitHub buttons on the auth screen. */
.oauth-row { margin-top: 18px; }
.oauth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    margin: 8px 0 12px;
}
.oauth-divider::before,
.oauth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-color);
}
.oauth-divider span { padding: 0 12px; }
.oauth-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); }
.oauth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 calc(45px / var(--ui-scale, 1));
    width: calc(45px / var(--ui-scale, 1));
    height: calc(45px / var(--ui-scale, 1));
    box-sizing: border-box;
    text-align: center;
    padding: var(--space-2);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md, 8px);
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.oauth-btn:hover { background: var(--bg-tertiary); border-color: var(--accent-color); }
.oauth-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.oauth-btn svg { width: 24px; height: 24px; fill: currentColor; }

/* 2FA enroll: secret + backup codes readability (tokened, both themes). */
#twofaSecret {
    display: inline-block;
    padding: var(--space-1) var(--space-2);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm, 6px);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.05em;
    color: var(--text-primary);
    user-select: all;
}
#twofaBackupCodes {
    margin: var(--space-2) 0 0;
    padding: var(--space-2);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm, 6px);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-all;
    user-select: all;
}

/* Rewards + support: one coherent customer-care surface. */
.reward-heading,
.support-heading { align-items: center; }
.reward-summary,
.analytics-pulse {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-3);
}
/* The empty state spans the whole pulse: in a narrow side panel a single
 * 1/3 cell cannot hold its sentence and pushed the panel wider than the page. */
.analytics-pulse .empty { grid-column: 1 / -1; min-width: 0; white-space: normal; }
.section-heading.compact-heading { flex-wrap: wrap; }
/* Wrap-safety for every text cell of the cabinet: a long unbroken token (an
 * identifier, a URL, an untranslated key) must wrap inside its cell instead
 * of widening the page — the 375px check in the browser suite guards it. */
.control-trace dt, .control-trace dd, .trace-node strong + span,
.hint, .empty, .section-kicker,
.provider-pool-form-grid label > span, .platform-settings-grid label > span,
.getting-started-step, .getting-started-list,
#sec-operator .audit-row > *, #sec-operator .audit-row-sub > *,
#sec-operator .section-heading > * { min-width: 0; overflow-wrap: anywhere; }
#sec-operator .section-heading { flex-wrap: wrap; }
#sec-operator .section-heading > * { max-width: 100%; }
#sec-operator label > span { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 640px) {
    #sec-operator .btn-row { display: flex; flex-wrap: wrap; }
    #sec-operator .btn-row button, #sec-operator .inline-form button { max-width: 100%; height: auto; min-height: var(--btn-h-md); padding-top: var(--space-1); padding-bottom: var(--space-1); white-space: normal; }
}
#sec-operator .audit-row .status-pill, #sec-operator .audit-row time { max-width: 100%; white-space: normal; }
.reward-summary article,
.analytics-pulse article {
    display: grid;
    gap: var(--space-2);
    min-width: 0;
    padding: var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--cw-surface-sunken);
}
.reward-summary span,
.analytics-pulse span {
    color: var(--text-secondary);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-semibold);
    overflow-wrap: anywhere;
    text-transform: uppercase;
}
.reward-summary strong,
.analytics-pulse strong {
    color: var(--text-primary);
    font-size: var(--font-xl);
    font-variant-numeric: tabular-nums;
}
.analytics-pulse .analytics-total { grid-column: 1 / -1; background: var(--cw-surface-raised, var(--bg-secondary)); }
.analytics-bar {
    display: block;
    height: 4px;
    width: var(--analytics-share, 0%);
    max-width: 100%;
    border-radius: var(--radius-full, 999px);
    background: var(--accent-color);
}
.analytics-window {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    font-size: var(--font-sm);
    color: var(--text-secondary);
}
.analytics-window button {
    padding: var(--space-1) var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full, 999px);
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    cursor: pointer;
}
/* The border keeps the accent hue; the label routes through --accent-text,
 * which exists for exactly this (accent-as-ink is 4.25:1 on white, under AA). */
.analytics-window button[aria-pressed="true"] { border-color: var(--accent-color); color: var(--accent-text); font-weight: var(--font-weight-semibold); }
.analytics-window button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
/* The daily table scrolls inside its own box: without min-width:0 on the grid
 * column the panel grew to the table's intrinsic width and pushed the page
 * past 375px. */
.operator-product-grid > *, .analytics-pulse-panel { min-width: 0; max-width: 100%; }
.analytics-daily { margin-top: var(--space-4); min-width: 0; max-width: 100%; }
.analytics-daily .table-scroll { overflow-x: auto; max-width: 100%; min-width: 0; }
.analytics-daily-table { width: 100%; border-collapse: collapse; font-size: var(--font-sm); font-variant-numeric: tabular-nums; }
.analytics-daily-table th, .analytics-daily-table td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-color); text-align: right; white-space: nowrap; }
.analytics-daily-table th[scope="row"], .analytics-daily-table thead th:first-child { text-align: left; color: var(--text-secondary); font-weight: var(--font-weight-semibold); }
.analytics-daily-table thead th { color: var(--text-secondary); font-size: var(--font-xs); text-transform: uppercase; }
.analytics-daily-table td.analytics-zero { color: var(--text-tertiary, var(--text-secondary)); }
.reward-redeem {
    display: grid;
    grid-template-columns: minmax(14rem, 1fr) minmax(7rem, 0.35fr) auto;
    align-items: end;
    gap: var(--space-3);
    margin: var(--space-5) 0;
    padding: var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--cw-surface);
    box-shadow: var(--shadow-1);
}
.reward-redeem .form-result { grid-column: 1 / -1; }
.reward-history,
.support-case-list,
.support-messages { display: grid; gap: var(--space-2); }
.reward-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--cw-surface);
}
.reward-row > div { display: grid; gap: var(--space-1); min-width: 0; }
.reward-row span { color: var(--text-secondary); font-size: var(--font-xs); }
.support-desk,
.operator-product-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
    align-items: start;
}
.support-case-form,
.support-thread {
    display: grid;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--cw-surface-sunken);
}
.support-case-form { margin-bottom: var(--space-4); }
.support-case-form h3,
.support-thread h3 { margin: 0; }
.support-form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
}
.support-case-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--cw-surface);
    color: var(--text-primary);
    text-align: left;
}
.support-case-row:hover,
.support-case-row:focus-visible { border-color: var(--accent-color); }
.support-case-row.overdue { border-color: var(--danger-color); }
.support-case-row > span { display: grid; gap: var(--space-1); min-width: 0; }
.support-case-row > span:last-child { justify-items: end; text-align: right; }
.support-case-row small { color: var(--text-secondary); overflow-wrap: anywhere; }
.support-status {
    display: inline-flex;
    width: fit-content;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-pill);
    background: var(--accent-light);
    color: var(--accent-hover);
    font-size: var(--font-xs);
    font-weight: var(--font-weight-semibold);
}
.support-status[data-status="resolved"],
.support-status[data-status="credited"] { background: var(--success-bg); color: var(--success-text); }
.support-status[data-status="waiting_customer"] { background: var(--warning-bg); color: var(--warning-text); }
.support-status[data-status="closed"],
.support-status[data-status="clawed_back"] { background: var(--bg-tertiary); color: var(--text-secondary); }
.support-thread { position: sticky; top: var(--space-4); }
.support-thread > header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
}
.support-message {
    padding: var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--cw-surface);
}
.support-message[data-visibility="internal"] { border-style: dashed; background: var(--warning-bg); }
.support-message > div {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    color: var(--text-secondary);
    font-size: var(--font-xs);
}
.support-message p { margin: var(--space-2) 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.support-attachments {
    display: grid;
    gap: var(--space-1);
    margin: var(--space-3) 0 0;
    padding: 0;
    list-style: none;
}
.support-attachments a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
}
.support-attachments a:hover,
.support-attachments a:focus-visible { border-color: var(--accent-color); }
.support-attachments span { min-width: 0; overflow-wrap: anywhere; }
.support-attachments small { flex: 0 0 auto; color: var(--text-secondary); }
.support-reply-form { display: grid; gap: var(--space-3); }
.support-attachment-picker { display: grid; gap: var(--space-1); }
.support-attachment-picker small { color: var(--text-secondary); }
.support-operator-controls {
    display: grid;
    grid-template-columns: auto minmax(10rem, 1fr) auto;
    gap: var(--space-2);
}
.support-internal-toggle { display: flex; align-items: center; gap: var(--space-2); }
.support-internal-toggle input { width: auto; }
.support-access {
    display: grid;
    gap: var(--space-3);
    padding: var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
}
.support-access h4,
.support-access p { margin: 0; }
.support-access > div:first-child { display: grid; gap: var(--space-1); }
.support-access > div:first-child p { color: var(--text-secondary); font-size: var(--font-size-sm); }
.support-access-list { display: grid; gap: var(--space-2); }
.support-access-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
}
.support-access-row > div { display: grid; gap: var(--space-1); min-width: 0; }
.support-access-row > div:last-child { display: flex; grid-auto-flow: column; gap: var(--space-2); }
.support-access-row span { color: var(--text-secondary); font-size: var(--font-size-sm); overflow-wrap: anywhere; }
.support-access-proposal { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.support-access-proposal h4,
.support-access-proposal button,
.support-access-proposal .form-result { grid-column: 1 / -1; }
.support-access-assignee { grid-column: 1 / -1; color: var(--text-secondary); font-size: var(--font-size-sm); }
.support-access-history { display: grid; gap: var(--space-2); }
.support-access-history h5 { margin: 0; }
.support-access-history ol { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.support-access-history li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2); padding-block: var(--space-2); border-top: 1px solid var(--border-color); }
.support-access-history li span { color: var(--text-secondary); font-size: var(--font-size-sm); }
.operator-product-pulse { margin: var(--space-5) 0; }
.operator-product-grid { grid-template-columns: minmax(0, 1fr); }
.operator-thread { position: static; margin-top: var(--space-3); }
.analytics-pulse { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 960px) {
    .support-desk,
    .operator-product-grid { grid-template-columns: minmax(0, 1fr); }
    .support-thread { position: static; }
}

@media (max-width: 640px) {
    .reward-summary,
    .analytics-pulse,
    .reward-redeem,
    .support-form-row,
    .support-operator-controls { grid-template-columns: minmax(0, 1fr); }
	.support-access-row,
	.support-access-proposal { grid-template-columns: minmax(0, 1fr); }
	.support-access-proposal h4,
	.support-access-proposal button,
	.support-access-proposal .form-result { grid-column: auto; }
    .reward-redeem .form-result { grid-column: auto; }
    .reward-row,
    .support-case-row { grid-template-columns: minmax(0, 1fr); align-items: start; }
    .support-case-row > span:last-child { justify-items: start; text-align: left; }
    .support-thread > header,
    .support-message > div { flex-direction: column; }
}

/* ---------- Field validation (our own voice, never the native bubble) ---------- */
.field-invalid, .inline-form .field-invalid, .space-rename-form .field-invalid {
    border-color: var(--danger-color);
    box-shadow: var(--focus-ring-danger);
}
.field-error {
    display: block;
    margin-top: var(--space-1);
    color: var(--danger-text);
    font-size: var(--font-xs);
    line-height: var(--line-height-normal);
    overflow-wrap: anywhere;
}

/* Workspace switcher: name (with slug when names collide) + role pill */
#workspaceSwitcher button { display: inline-flex; align-items: center; gap: var(--space-2); max-width: 100%; min-width: 0; }
#workspaceSwitcher .ws-switch-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#workspaceSwitcher .ws-switch-role { flex-shrink: 0; padding: 0 var(--space-1); border: 1px solid var(--border-color); border-radius: var(--radius-pill); font-size: var(--font-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); }

/* Narrow screens: a badge may wrap its words rather than widen the page; on
 * wider screens it stays a single pill that the heading places on its own line. */
@media (max-width: 480px) {
    .authority-badge { white-space: normal; overflow-wrap: anywhere; }
}

/* Operator: loyalty campaigns */
.loyalty-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); width: 100%; min-width: 0; }
.loyalty-form-grid label { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-1); min-width: 0; color: var(--text-secondary); font-size: var(--font-sm); }
.loyalty-form-grid label > span { min-width: 0; overflow-wrap: anywhere; }
.loyalty-form-grid input, .loyalty-form-grid select { width: 100%; min-width: 0; }
.loyalty-form-grid .loyalty-span-2 { grid-column: 1 / -1; }
.loyalty-row .btn-row { flex-wrap: wrap; }
@media (max-width: 720px) { .loyalty-form-grid { grid-template-columns: minmax(0, 1fr); } }

/* Commerce catalogue: numbered sequential steps, each a form over its list. */
.commerce-console .commerce-step { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border-color); min-width: 0; }
.commerce-console .commerce-step .section-kicker { display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem; border-radius: var(--radius-full, 999px); background: var(--accent-color); color: var(--accent-contrast); font-weight: var(--font-weight-semibold); margin-bottom: var(--space-1); }
.commerce-list { display: grid; gap: var(--space-2); margin-bottom: var(--space-3); min-width: 0; }
.commerce-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.6fr) auto; gap: var(--space-3); align-items: center; padding: var(--space-2) var(--space-3); border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--cw-surface-sunken); min-width: 0; }
.commerce-row > * { min-width: 0; overflow-wrap: anywhere; }
.commerce-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); width: 100%; min-width: 0; }
.commerce-form-grid label { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-1); min-width: 0; }
.commerce-form-grid input, .commerce-form-grid select, .commerce-form-grid textarea { width: 100%; min-width: 0; }
.commerce-form-grid .commerce-span-2 { grid-column: 1 / -1; }
.commerce-readiness { margin-bottom: var(--space-3); padding: var(--space-4); border: 1px solid var(--border-color); border-radius: var(--radius-lg); background: var(--cw-surface-sunken); min-width: 0; }
.commerce-readiness-head { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; margin-bottom: var(--space-3); color: var(--text-secondary); }
.commerce-checks { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.commerce-checks li { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: baseline; min-width: 0; }
/* Ink, not fill: --success-color / --danger-color are fill hues (2.3:1 as text
 * on the light sunken surface); the *-text tokens are the AA-safe inks. */
.commerce-checks li.missing strong { color: var(--danger-text); }
.commerce-checks li.ok strong { color: var(--success-text); }
.commerce-checks .commerce-mark { font-weight: var(--font-weight-semibold); }
.commerce-checks li.missing .commerce-mark { color: var(--danger-text); }
.commerce-checks li.ok .commerce-mark { color: var(--success-text); }
.commerce-form-grid label > span, .commerce-readiness-form label > span { color: var(--text-primary); min-width: 0; overflow-wrap: anywhere; }
.commerce-readiness-form { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-end; margin-bottom: var(--space-4); }
.commerce-readiness-form label { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-1); min-width: 0; flex: 1 1 8rem; }
.commerce-readiness-form input, .commerce-readiness-form select { width: 100%; min-width: 0; }
.commerce-readiness .status-pill[data-status="ready"] { color: var(--success-text); border-color: var(--success-color); background: var(--success-bg); }
.commerce-console { min-width: 0; max-width: 100%; }
.commerce-console .btn-row { display: flex; flex-wrap: wrap; }
.commerce-console button { max-width: 100%; height: auto; min-height: var(--btn-h-md); padding-top: var(--space-1); padding-bottom: var(--space-1); white-space: normal; }
.commerce-checks li > *, .commerce-readiness-head > *, .commerce-row strong, .commerce-row code { min-width: 0; overflow-wrap: anywhere; }
.commerce-readiness .status-pill[data-status="missing"] { color: var(--danger-text); border-color: var(--danger-color); background: var(--danger-bg); }
@media (max-width: 900px) {
    .commerce-form-grid { grid-template-columns: minmax(0, 1fr); }
    .commerce-row { grid-template-columns: minmax(0, 1fr); }
}

/* Operator console sub-tabs (owner 2026-09-02: the operator canvas was «всё
   одним огромным полотном»). A segmented row grouping the console into
   overview / platform / commerce+money / risk / loyalty, in the same
   segmented-nav language as the sidebar and the auth toggle. Panels of the
   inactive groups are [hidden] by app.js, so the working area shows one
   focused group at a time. */
.op-group-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin: var(--space-4) 0 var(--space-2);
    padding: var(--space-1);
    background: var(--cw-surface-sunken);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}
.op-group-tab {
    flex: 1 1 8rem;
    min-width: 0;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
    padding: var(--space-2) var(--space-3);
    height: auto;
    min-height: var(--btn-h-sm);
    border-radius: var(--control-radius);
    white-space: normal;
    transition: color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}
.op-group-tab:hover:not(.active) { color: var(--text-primary); background: var(--hover-overlay); }
.op-group-tab.active {
    color: var(--accent-hover);
    background: var(--cw-seg-active);
    border-color: var(--cw-hero-stroke);
    box-shadow: var(--shadow-1);
    font-weight: var(--font-weight-semibold);
}
.op-group-tab:focus-visible { outline: none; box-shadow: var(--focus-ring); }
#sec-operator [data-op-group][hidden] { display: none !important; }

/* Customer appeals inside an operator risk case. Same shape as
   .risk-enforcement so the case reads as one ledger; a pending appeal is
   highlighted because it is the one row that needs an operator decision. */
.risk-appeal {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    margin-bottom: var(--space-2);
    padding: var(--space-3);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--border-color);
    border-radius: var(--control-radius);
    background: var(--bg-secondary);
}
.risk-appeal.pending { border-left-color: var(--warning-color); }
.risk-appeal > div { display: grid; gap: var(--space-1); min-width: 0; }
.risk-appeal > div > span:last-child { color: var(--text-secondary); font-size: var(--font-xs); }
.risk-appeal strong { overflow-wrap: anywhere; }
.risk-appeal .btn-row { flex: 0 0 auto; }

/* ============================== SYSTEM ANNOUNCEMENTS ==============================
   One operator message shown to everybody it is addressed to. Colour carries the
   kind, but never carries the meaning alone: each banner also names its kind in
   words, so the difference between "planned work" and "something is broken" does
   not depend on telling amber from red. All four palettes come from the status
   tokens, which are already defined for both themes — nothing is hardcoded here,
   so a theme fix in tokens.css reaches these banners too. */
.announce-region {
    display: grid;
    gap: var(--space-2);
    margin: var(--space-3) var(--space-4) 0;
}
.announce {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: flex-start;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--info-color);
    border-radius: var(--control-radius);
    background: var(--info-bg);
    color: var(--text-primary);
}
.announce-main { flex: 1 1 320px; min-width: 0; display: grid; gap: var(--space-1); }
.announce-kind {
    font-size: var(--font-xs);
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--info-text);
}
.announce-title { font-weight: 600; overflow-wrap: anywhere; }
.announce-body { color: var(--text-secondary); overflow-wrap: anywhere; }
.announce-side { flex: 0 0 auto; display: flex; gap: var(--space-2); align-items: center; }
.announce-link {
    color: var(--info-text);
    font-weight: 600;
    text-decoration: underline;
}
.announce-link:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-xs); }

/* The close button is a quiet control: dismissing is the reader's choice, not
   the thing the banner is asking them to do. */
.announce-dismiss {
    padding: var(--space-1) var(--space-2);
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--font-xs);
    cursor: pointer;
}
.announce-dismiss:hover { background: var(--bg-secondary); color: var(--text-primary); }
.announce-dismiss:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.announce.incident    { border-left-color: var(--danger-color);  background: var(--danger-bg); }
.announce.incident    .announce-kind, .announce.incident .announce-link    { color: var(--danger-text); }
.announce.maintenance { border-left-color: var(--warning-color); background: var(--warning-bg); }
.announce.maintenance .announce-kind, .announce.maintenance .announce-link { color: var(--warning-text); }
.announce.release     { border-left-color: var(--success-color); background: var(--success-bg); }
.announce.release     .announce-kind, .announce.release .announce-link     { color: var(--success-text); }

/* Narrow screens: the link and the close button drop under the text rather than
   squeezing the message into a column two words wide. */
@media (max-width: 640px) {
    .announce-region { margin: var(--space-2) var(--space-3) 0; }
    .announce { padding: var(--space-3); }
    .announce-side { width: 100%; justify-content: flex-start; }
}

/* Legal links under the auth card: always visible, both themes; wraps whole
   links (never mid-phrase) when the card is narrow. */
.auth-legal {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 14px;
    margin: 16px 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.auth-legal a { color: inherit; text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
.auth-legal a:hover, .auth-legal a:focus-visible { color: var(--accent-text); }

/* ---------- Licence keys (Mockarty Desktop period keys) ---------- */
.license-offers { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-3); }
.license-offer {
    display: flex; flex-direction: column; gap: var(--space-2);
    padding: var(--space-4); border: 1px solid var(--border-color); border-radius: var(--radius-md);
    background: var(--bg-secondary);
}
.license-offer .offer-price { font-size: var(--font-lg); font-weight: var(--font-weight-semibold); font-variant-numeric: tabular-nums; }
.license-offer .offer-meta { color: var(--text-secondary); font-size: var(--font-sm); }
.license-offer .offer-features { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.license-offer button { align-self: flex-start; margin-top: auto; }
.license-keys { display: grid; gap: var(--space-2); }
.license-key {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2) var(--space-3);
    padding: var(--space-3) var(--space-4); border: 1px solid var(--border-color); border-radius: var(--radius-md);
    background: var(--bg-primary);
}
.license-key .key-title { font-weight: var(--font-weight-semibold); }
.license-key .key-meta { color: var(--text-secondary); font-size: var(--font-sm); display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); }
.license-key .key-id { font-family: var(--font-mono); font-size: var(--font-xs); color: var(--text-secondary); }
.license-key > .status-pill { align-self: start; justify-self: end; }
.license-key .btn-row { grid-column: 1 / -1; }
.license-key .status-pill.issuing { background: color-mix(in srgb, var(--warning-color) 22%, transparent); color: var(--warning-text); }
.license-key .status-pill.issued { background: var(--success-bg); color: var(--success-text); }
.license-key .status-pill.revoked, .license-key .status-pill.issue_failed, .license-key .status-pill.revoke_failed { background: var(--danger-bg); color: var(--danger-text, var(--danger-color)); }
.license-key .status-pill.revoking { background: color-mix(in srgb, var(--warning-color) 22%, transparent); color: var(--warning-text); }
.dedicated-panel { margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--border-color); }
.dedicated-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-3); margin: var(--space-3) 0 var(--space-4); }
.dedicated-form .dedicated-notes, .dedicated-form .btn-row, .dedicated-form .form-result { grid-column: 1 / -1; }
.dedicated-list { display: grid; gap: var(--space-2); }
.dedicated-request .dedicated-note { margin: var(--space-2) 0 0; color: var(--text-secondary); font-size: var(--font-sm); white-space: pre-wrap; }
.dedicated-request .dedicated-url { margin: var(--space-2) 0 0; font-family: var(--font-mono); font-size: var(--font-sm); word-break: break-all; }
.dedicated-request .status-pill.new, .dedicated-request .status-pill.reviewing, .dedicated-request .status-pill.provisioning { background: color-mix(in srgb, var(--warning-color) 22%, transparent); color: var(--warning-text); }
.dedicated-request .status-pill.ready { background: var(--success-bg); color: var(--success-text); }
.dedicated-request .status-pill.declined { background: var(--danger-bg); color: var(--danger-text, var(--danger-color)); }
.dedicated-request .status-pill.cancelled { background: var(--bg-secondary); color: var(--text-secondary); }
.dedicated-console { margin-top: var(--space-4); }
.license-code {
    margin: 0; padding: var(--space-3); border-radius: var(--radius-sm);
    background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border-color);
    font-family: var(--font-mono); font-size: var(--font-sm); white-space: pre-wrap; word-break: break-all; user-select: all;
}
.license-confirmation { display: grid; gap: var(--space-2); margin-top: var(--space-3); }
.license-devices { display: grid; gap: var(--space-1); margin: var(--space-2) 0 var(--space-3); }
.license-device {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--space-2); align-items: center;
    padding: var(--space-2) var(--space-3); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    font-size: var(--font-sm);
}
.license-device .device-slot { font-family: var(--font-mono); color: var(--text-secondary); }
.license-device .device-lease { color: var(--text-secondary); }
.modal-card.modal-lg { max-width: var(--modal-w-lg, 760px); }
@media (max-width: 480px) {
    .license-key { grid-template-columns: 1fr; }
    .license-device { grid-template-columns: 1fr; }
}
