/* =========================================================================
   Synths — Design System (shell foundation)
   Dark-first. Editorial typography. Cinematic sensibility.
   Referências estéticas: Apple, Linear, Stripe, Vercel.
   ========================================================================= */

/* Self-hosted variable fonts (subset: latin + latin-ext, weight axis only).
   Files in wwwroot/fonts/, immutable cache via service worker. */

@font-face {
    font-family: "Outfit";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/outfit-latin-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Outfit";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/outfit-latin-ext-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: "Newsreader";
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url("../fonts/newsreader-latin-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Newsreader";
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url("../fonts/newsreader-latin-ext-wght-normal.woff2") format("woff2-variations");
    unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: "Newsreader";
    font-style: italic;
    font-weight: 200 800;
    font-display: swap;
    src: url("../fonts/newsreader-latin-wght-italic.woff2") format("woff2-variations");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Newsreader";
    font-style: italic;
    font-weight: 200 800;
    font-display: swap;
    src: url("../fonts/newsreader-latin-ext-wght-italic.woff2") format("woff2-variations");
    unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/ibm-plex-mono-latin-ext-400-normal.woff2") format("woff2");
    unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/ibm-plex-mono-latin-ext-500-normal.woff2") format("woff2");
    unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    color-scheme: dark;

    /* Surfaces (warm near-black — editorial dark) */
    --surface-0: #0a0908;
    --surface-1: #14110d;
    --surface-2: #1a1713;
    --surface-raised: #1c1913;
    --surface-inset: #0f0d0b;
    --surface-canvas: #050403;

    /* Borders (alpha on primary text for theme-parity) */
    --border-faint: rgba(231, 230, 225, 0.06);
    --border-subtle: rgba(231, 230, 225, 0.09);
    --border: rgba(231, 230, 225, 0.14);
    --border-strong: rgba(231, 230, 225, 0.22);

    /* Text */
    --text-primary: #e7e6e1;
    --text-secondary: #afaa9b;
    --text-tertiary: #6f6a61;
    --text-muted: #5c574f;

    /* Signature */
    --accent: #eb1e23;
    --accent-hover: #f0353a;
    --accent-dim: rgba(235, 30, 35, 0.14);
    --text-on-accent: #ece7e1;
    --danger: #eb1e23;
    --danger-soft: #f05862;
    --success: #7ecb8f;
    --success-bright: #3bd68a;
    --warning: #d9c27e;
    --warning-strong: #f3a45a;

    /* Color channels — consumed as rgba(var(--x-rgb), a) wherever a tint or a
       hairline needs its own alpha. They exist so those overlays invert with the
       theme: an rgba() literal baked into a component stays dark-tuned forever,
       which is exactly what kept a light theme out of reach. */
    --accent-rgb: 235, 30, 35;
    --ink-rgb: 244, 241, 234;
    --shadow-rgb: 0, 0, 0;
    --success-rgb: 126, 203, 143;
    --success-bright-rgb: 59, 214, 138;
    --danger-soft-rgb: 240, 88, 98;
    --warning-strong-rgb: 243, 164, 90;

    /* Translucent surfaces — sticky chrome and the scrims behind overlays */
    --surface-sticky: rgba(10, 9, 8, 0.72);
    --surface-bar: rgba(17, 17, 20, 0.82);
    --scrim: rgba(6, 6, 8, 0.72);
    --scrim-soft: rgba(6, 6, 8, 0.6);
    --scrim-media: rgba(6, 6, 8, 0.62);

    /* Elevation — geometry travels with the token because these same shadows
       were duplicated verbatim across seven components, and light needs both a
       different color and a shallower spread. */
    --shadow-raised: 0 20px 60px -30px rgba(0, 0, 0, 0.5);
    --shadow-panel: 0 20px 60px -20px rgba(0, 0, 0, 0.5);
    --shadow-overlay: 0 40px 120px -40px rgba(0, 0, 0, 0.8);
    --shadow-sheet: -40px 0 120px -40px rgba(0, 0, 0, 0.75);

    /* Typography */
    --font-sans: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-display: "Newsreader", ui-serif, Georgia, "Times New Roman", serif;
    --font-mono: "IBM Plex Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;

    /* Type scale (1.250 — minor third) */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;
    --text-3xl: 2.25rem;
    --text-4xl: 3rem;
    --text-5xl: 4.25rem;
    --text-6xl: 6rem;

    /* Line-heights */
    --leading-tight: 1.08;
    --leading-snug: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.65;

    /* Space */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-7: 1.75rem;
    --space-8: 2rem;
    --space-9: 2.25rem;
    --space-10: 2.5rem;
    --space-11: 2.75rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-24: 6rem;

    /* Radii */
    --radius-sm: 4px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    /* Motion */
    --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --duration-fast: 120ms;
    --duration: 200ms;
    --duration-slow: 360ms;
}

/* Light theme --------------------------------------------------------------
   Dark stays the default: it is the design the product was drawn in, and it is
   what renders when JavaScript is disabled or the stored preference is absent.
   Light is an override on [data-theme="light"], set on <html> by the inline
   boot script in index.html before first paint.

   Only what actually changes is redefined here — type scale, spacing, radii and
   motion are theme-agnostic and stay in :root. The mirror is warm on purpose:
   the dark theme is a warm near-black, so light is a warm off-white rather than
   a clinical #fff, and the ink is a warm near-black rather than pure black. */

:root[data-theme="light"] {
    color-scheme: light;

    --surface-0: #faf8f4;
    --surface-1: #ffffff;
    --surface-2: #f2efe8;
    --surface-raised: #ffffff;
    --surface-inset: #efece4;
    --surface-canvas: #ffffff;

    --border-faint: rgba(26, 23, 16, 0.06);
    --border-subtle: rgba(26, 23, 16, 0.10);
    --border: rgba(26, 23, 16, 0.16);
    --border-strong: rgba(26, 23, 16, 0.26);

    --text-primary: #1a1710;
    --text-secondary: #55504a;
    --text-tertiary: #7b7469;
    --text-muted: #99928a;

    /* The accent goes one step deeper than the brand #eb1e23. That red reaches
       only 4.43:1 on this background — under the 4.5:1 that body text needs —
       and it is used as link-hover color, so it has to carry text. #d81b20
       reads at 5.1:1 and stays the same red at a glance. */
    --accent: #d81b20;
    --accent-hover: #b8151a;
    --accent-dim: rgba(216, 27, 32, 0.10);
    --text-on-accent: #fffaf8;
    --danger: #c4161b;
    --danger-soft: #b8322c;
    --success: #2f7d4a;
    --success-bright: #1f8f54;
    --warning: #806014;
    --warning-strong: #a8620e;

    --accent-rgb: 216, 27, 32;
    --ink-rgb: 26, 23, 16;
    --shadow-rgb: 26, 23, 16;
    --success-rgb: 47, 125, 74;
    --success-bright-rgb: 31, 143, 84;
    --danger-soft-rgb: 184, 50, 44;
    --warning-strong-rgb: 168, 98, 14;

    --surface-sticky: rgba(250, 248, 244, 0.80);
    --surface-bar: rgba(255, 255, 255, 0.88);
    --scrim: rgba(26, 23, 16, 0.44);
    --scrim-soft: rgba(26, 23, 16, 0.32);

    /* Stays dark: this one sits over photography, where the text above it is
       white in both themes. Inverting it would make that text unreadable. */
    --scrim-media: rgba(6, 6, 8, 0.62);

    --shadow-raised: 0 12px 32px -20px rgba(26, 23, 16, 0.20);
    --shadow-panel: 0 16px 40px -18px rgba(26, 23, 16, 0.18);
    --shadow-overlay: 0 32px 80px -32px rgba(26, 23, 16, 0.30);
    --shadow-sheet: -28px 0 80px -36px rgba(26, 23, 16, 0.24);
}

/* Reset -------------------------------------------------------------------- */

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

html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--surface-0);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    font-feature-settings: "liga", "kern";
    letter-spacing: -0.005em;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 500;
    letter-spacing: -0.022em;
    line-height: var(--leading-tight);
    color: var(--text-primary);
}

p { margin: 0; }

a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color var(--duration) var(--ease-out);
}

a:hover { color: var(--accent); }

button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

::selection {
    background: var(--accent);
    color: var(--surface-0);
}

/* Ambient background: subtle radial vignette behind everything ------------- */

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    background:
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(var(--accent-rgb), 0.04), transparent 60%),
        radial-gradient(ellipse 60% 40% at 50% 100%, rgba(var(--accent-rgb), 0.02), transparent 60%);
}

/* Blazor error UI — override template defaults ---------------------------- */

#blazor-error-ui {
    color-scheme: dark;
    background: var(--surface-raised);
    color: var(--text-primary);
    border-top: 1px solid var(--border);
    bottom: 0;
    left: 0;
    right: 0;
    box-sizing: border-box;
    display: none;
    padding: var(--space-4) var(--space-6);
    position: fixed;
    z-index: 1000;
    font-size: var(--text-sm);
    box-shadow: 0 -10px 40px -10px rgba(var(--shadow-rgb), 0.6);
}

#blazor-error-ui .reload {
    color: var(--accent);
    margin-left: var(--space-4);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    transition: color var(--duration) var(--ease-out);
}

#blazor-error-ui .dismiss:hover { color: var(--text-primary); }

.blazor-error-boundary {
    background: var(--surface-raised);
    color: var(--danger);
    padding: var(--space-6);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: var(--text-sm);
}

.blazor-error-boundary::after { content: "Ocorreu um erro neste bloco."; }

/* Initial loading splash (before Blazor boots) ---------------------------- */

#app-loader {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: var(--surface-0);
    z-index: 9999;
    animation: app-loader-in 240ms var(--ease-out) both;
}

#app-loader .wordmark {
    font-family: var(--font-display);
    font-weight: 300;
    font-style: italic;
    font-size: var(--text-3xl);
    letter-spacing: -0.03em;
    color: var(--text-primary);
    opacity: 0;
    animation: app-loader-wordmark 900ms var(--ease-out) 120ms forwards;
}

#app-loader .wordmark::after {
    content: "·";
    display: inline-block;
    margin-left: 0.25em;
    color: var(--accent);
    animation: app-loader-pulse 1.4s var(--ease-in-out) infinite;
}

@keyframes app-loader-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes app-loader-wordmark {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes app-loader-pulse {
    0%, 100% { opacity: 0.3; }
    50%      { opacity: 1; }
}

/* Accessibility ----------------------------------------------------------- */

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* O <FocusOnNavigate Selector="h1"> do Blazor move o foco para o titulo a cada
   navegacao -- e util para leitor de tela, que assim anuncia a pagina nova. Para
   chegar la ele faz `if (!el.hasAttribute('tabindex')) el.tabIndex = -1`, e o
   resultado visivel era o titulo circulado de vermelho ao abrir /login.

   tabindex="-1" significa "so focavel por programa": ninguem alcanca este
   elemento pelo Tab, entao esconder o anel nao tira pista de navegacao de
   ninguem. A regra fica restrita a esses elementos de proposito -- suprimir o
   anel de forma ampla quebraria a navegacao por teclado. */
[tabindex="-1"]:focus,
[tabindex="-1"]:focus-visible {
    outline: none;
}

@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;
    }
}

/* Print — used by the report PDF export ("Save as PDF" via the system dialog).
   Strips the chrome and forces a light theme so the output prints cleanly on
   paper or PDF. Only the .report-prose article and its trailing meta survive. */

@media print {
    :root {
        color-scheme: light;
    }

    body {
        background: #ffffff !important;
        color: #1a1a1a !important;
        overflow: visible !important;
        font-family: "Newsreader", "Georgia", "Times New Roman", serif !important;
        font-size: 11pt !important;
        line-height: 1.55 !important;
    }

    body::before { display: none !important; }

    .app-shell {
        display: block !important;
        min-height: 0 !important;
    }

    .sidebar,
    .app-shell-topbar,
    .toast-host,
    .dialog-scrim,
    .report-head,
    .report-toolbar,
    .report-empty,
    .report-progress,
    .report-error,
    .report-initial,
    .report-foot,
    #blazor-error-ui,
    #app-loader {
        display: none !important;
    }

    .app-shell-content,
    .app-shell-main,
    .report-page {
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        background: #ffffff !important;
    }

    .report-prose {
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        color: #1a1a1a !important;
        font-family: "Newsreader", "Georgia", "Times New Roman", serif !important;
        font-size: 11.5pt !important;
        line-height: 1.55 !important;
    }

    .report-prose h1,
    .report-prose h2,
    .report-prose h3,
    .report-prose h4 {
        color: #111 !important;
        page-break-after: avoid;
    }

    .report-prose h1 {
        font-size: 24pt !important;
        font-weight: 400 !important;
        margin: 0 0 14pt !important;
        padding-bottom: 8pt !important;
        border-bottom: 0.5pt solid #d0d0d0 !important;
    }

    .report-prose h2 {
        font-size: 16pt !important;
        font-weight: 500 !important;
        margin: 22pt 0 10pt !important;
        border-bottom: 0.5pt solid #e0e0e0 !important;
        padding-bottom: 4pt !important;
    }

    .report-prose h3 {
        font-size: 13pt !important;
        font-weight: 600 !important;
        margin: 18pt 0 8pt !important;
    }

    .report-prose h4 {
        font-size: 10.5pt !important;
        font-weight: 600 !important;
        text-transform: uppercase !important;
        letter-spacing: 0.06em !important;
        color: #555 !important;
        margin: 14pt 0 6pt !important;
    }

    .report-prose p {
        orphans: 2;
        widows: 2;
        page-break-inside: avoid;
    }

    .report-prose blockquote {
        border-left: 2pt solid #888 !important;
        color: #333 !important;
        font-style: italic !important;
        font-family: "Newsreader", "Georgia", serif !important;
        font-size: 11pt !important;
        page-break-inside: avoid;
        margin: 12pt 0 !important;
        padding: 4pt 14pt !important;
    }

    .report-prose code {
        background: #f4f4f4 !important;
        color: #1a1a1a !important;
        font-size: 10pt !important;
    }

    .report-prose pre {
        background: #f4f4f4 !important;
        border: 0.5pt solid #d0d0d0 !important;
        page-break-inside: avoid;
    }

    .report-prose ul,
    .report-prose ol {
        page-break-inside: avoid;
    }

    .report-prose table {
        page-break-inside: avoid;
    }

    .report-prose a {
        color: #1a1a1a !important;
        text-decoration: underline !important;
    }

    @page {
        size: A4;
        margin: 2.5cm 2.2cm 2.5cm 2.2cm;
    }
}

/* Form primitives ========================================================= */
/* .input / .input-num / .textarea / .select sao classes do design system, nao
   do componente. Metade das telas monta o campo na mao — parse proprio no
   @onchange, sufixo de unidade, data-* do paste em grade — e so aplica a classe.
   Enquanto as regras viviam em Input/Textarea/Select.razor.css o CSS isolation
   as prendia ao componente que as declarava ([b-xxxxx] no seletor), e todo campo
   montado na mao caia no render padrao do browser: fundo cinza de sistema, borda
   de sistema, nada do tema. Aqui elas valem em qualquer marcacao — os
   componentes de UI seguem usando exatamente os mesmos nomes. */

.input {
    appearance: none;
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.4;
    letter-spacing: -0.005em;
    transition:
        border-color var(--duration) var(--ease-out),
        background-color var(--duration) var(--ease-out),
        box-shadow var(--duration) var(--ease-out);
}

.input::placeholder { color: var(--text-muted); }

.input:hover:not(:focus):not([aria-invalid="true"]) {
    border-color: var(--border);
}

.input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface-2);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.input[aria-invalid="true"] {
    border-color: var(--danger);
}

.input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.input-num {
    font-variant-numeric: tabular-nums;
    text-align: right;
    padding-right: var(--space-3);
}

.input[type="number"] {
    -moz-appearance: textfield;
}

.input[type="number"]::-webkit-outer-spin-button,
.input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text-primary);
    -webkit-box-shadow: 0 0 0 1000px var(--surface-1) inset;
    caret-color: var(--text-primary);
}

.textarea {
    appearance: none;
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    letter-spacing: -0.005em;
    resize: vertical;
    min-height: 6rem;
    transition:
        border-color var(--duration) var(--ease-out),
        background-color var(--duration) var(--ease-out),
        box-shadow var(--duration) var(--ease-out);
}

.textarea::placeholder { color: var(--text-muted); }

.textarea:hover:not(:focus):not([aria-invalid="true"]) {
    border-color: var(--border);
}

.textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface-2);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.textarea[aria-invalid="true"] {
    border-color: var(--danger);
}

.textarea:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    padding: var(--space-3) var(--space-8) var(--space-3) var(--space-4);
    background-color: var(--surface-1);
    background-image:
        linear-gradient(45deg, transparent 50%, var(--text-tertiary) 50%),
        linear-gradient(135deg, var(--text-tertiary) 50%, transparent 50%);
    background-position:
        calc(100% - 1.1rem) 50%,
        calc(100% - 0.7rem) 50%;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.4;
    letter-spacing: -0.005em;
    cursor: pointer;
    transition:
        border-color var(--duration) var(--ease-out),
        background-color var(--duration) var(--ease-out),
        box-shadow var(--duration) var(--ease-out);
}

.select:hover:not(:focus):not(:disabled) {
    border-color: var(--border);
}

.select:focus {
    outline: none;
    border-color: var(--accent);
    background-color: var(--surface-2);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.select option {
    background: var(--surface-2);
    color: var(--text-primary);
}

/* Placeholder pages (Fase 12) ============================================ */

.placeholder {
    max-width: 680px;
    display: grid;
    gap: var(--space-4);
    padding: var(--space-8) 0;
}

.placeholder-eyebrow {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    margin: 0;
}

.placeholder-title {
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(var(--text-3xl), 4vw, var(--text-4xl));
    line-height: var(--leading-tight);
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin: 0;
}

.placeholder-title em {
    font-style: italic;
    color: var(--text-secondary);
}

.placeholder-lede {
    color: var(--text-secondary);
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    margin: 0;
}

.placeholder-lede code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    color: var(--text-primary);
    padding: 2px 6px;
    background: var(--surface-2);
    border: 1px solid var(--border-faint);
    border-radius: 4px;
}

/* Admin pages (Fase 13, Fase 14, Fase 15) ================================== */

.admin-clients,
.admin-users,
.admin-members,
.admin-audiences {
    display: flex;
    flex-direction: column;
    gap: var(--space-7);
    padding: 0 0 var(--space-6);
}

.admin-clients-head,
.admin-users-head,
.admin-members-head,
.admin-audiences-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-6);
    flex-wrap: wrap;
}

.admin-clients-head .eyebrow,
.admin-users-head .eyebrow,
.admin-members-head .eyebrow,
.admin-audiences-head .eyebrow,
.dashboard-head .eyebrow,
.jobs-head .eyebrow,
.runs-head .eyebrow {
    margin: 0 0 var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
}

.admin-clients-head .display,
.admin-users-head .display,
.admin-members-head .display,
.admin-audiences-head .display,
.dashboard-head .display,
.jobs-head .display,
.runs-head .display {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 300;
    font-size: clamp(var(--text-3xl), 4vw, var(--text-4xl));
    line-height: var(--leading-tight);
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.admin-clients-head .lede,
.admin-users-head .lede,
.admin-members-head .lede,
.admin-audiences-head .lede,
.dashboard-head .lede,
.jobs-head .lede,
.runs-head .lede {
    margin: var(--space-3) 0 0;
    color: var(--text-secondary);
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    max-width: 56ch;
}

.admin-members-head .lede strong,
.admin-audiences-head .lede strong,
.dashboard-head .lede strong,
.jobs-head .lede strong,
.runs-head .lede strong {
    color: var(--text-primary);
    font-weight: 500;
}

.admin-cell-link {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    text-align: left;
    color: inherit;
    font: inherit;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.admin-cell-link:hover .admin-cell-strong,
.admin-cell-link:focus-visible .admin-cell-strong {
    color: var(--accent);
}

.admin-cell-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

.audience-backlink {
    margin-top: var(--space-3);
    font-size: var(--text-sm);
    display: inline-flex;
    gap: var(--space-2);
    align-items: center;
    flex-wrap: wrap;
}

.audience-backlink a {
    color: var(--text-tertiary);
    text-decoration: none;
    border-bottom: 1px solid var(--border-faint);
    transition: color 120ms ease, border-color 120ms ease;
}

.audience-backlink a:hover,
.audience-backlink a:focus-visible {
    color: var(--accent);
    border-color: var(--accent);
}

.audience-backlink-sep {
    color: var(--text-tertiary);
    opacity: 0.6;
}

.admin-role-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.admin-role-option {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius, 10px);
    cursor: pointer;
    transition: border-color 120ms ease, background 120ms ease;
}

.admin-role-option:hover {
    border-color: var(--border-strong);
}

.admin-role-option:has(input:checked) {
    border-color: var(--accent);
    background: var(--surface-raised);
}

.admin-role-option input[type="radio"] {
    margin-top: 2px;
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.admin-role-option > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-role-title {
    color: var(--text-primary);
    font-weight: 500;
    font-size: var(--text-sm);
}

.admin-role-hint {
    color: var(--text-tertiary);
    font-size: var(--text-xs);
    line-height: var(--leading-relaxed);
}

.admin-field-hint {
    margin: var(--space-2) 0 0;
    color: var(--text-tertiary);
    font-size: var(--text-xs);
    line-height: var(--leading-relaxed);
}

.admin-panel {
    padding: 0;
    overflow: hidden;
}

.admin-panel.admin-panel-error,
.admin-panel.admin-panel-empty {
    padding: var(--space-8);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    align-items: flex-start;
}

.admin-eyebrow {
    margin: 0;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.admin-hint {
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    max-width: 60ch;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.admin-table thead th {
    text-align: left;
    padding: var(--space-5) var(--space-6);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-subtle);
    font-weight: 400;
}

.admin-table tbody td {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-faint);
    vertical-align: middle;
    color: var(--text-secondary);
}

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

.admin-table tbody tr.is-inactive td {
    opacity: 0.55;
}

.admin-cell-strong {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 2px;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.admin-cell-sub {
    color: var(--text-tertiary);
    font-size: var(--text-xs);
    max-width: 48ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-cell-mono {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.admin-self-tag {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    padding: 2px 6px;
    background: var(--surface-2);
    border: 1px solid var(--border-faint);
    border-radius: 4px;
}

.admin-table-actions {
    text-align: right;
    width: 1%;
    white-space: nowrap;
}

.admin-actions {
    display: inline-flex;
    gap: var(--space-2);
    justify-content: flex-end;
    flex-wrap: wrap;
}

.admin-skeleton {
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.admin-skeleton-row {
    display: grid;
    grid-template-columns: 1fr 1fr 180px;
    align-items: center;
    gap: var(--space-5);
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.admin-form-summary {
    background: rgba(240, 88, 98, 0.08);
    border: 1px solid rgba(240, 88, 98, 0.26);
    color: #f05862;
    border-radius: var(--radius, 10px);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
}

.admin-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    margin-top: var(--space-3);
}

.admin-form-actions.admin-form-actions-stretch {
    justify-content: space-between;
}

.admin-confirm {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
}

.admin-confirm p {
    margin: 0;
}

.admin-confirm strong {
    color: var(--text-primary);
    font-weight: 500;
}

.admin-password-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-2);
    align-items: stretch;
}

.admin-checkbox {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.admin-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.admin-credential {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.admin-credential-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding: var(--space-5);
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius, 10px);
}

.admin-credential-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.admin-credential-label {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.admin-credential-value {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--text-primary);
    word-break: break-all;
    padding: var(--space-2) var(--space-3);
    background: var(--surface-raised);
    border: 1px solid var(--border-faint);
    border-radius: 6px;
}

.admin-credential-secret {
    letter-spacing: 0.04em;
}

@media (max-width: 720px) {
    .admin-table thead {
        display: none;
    }

    .admin-table tbody tr {
        display: flex;
        flex-direction: column;
        gap: var(--space-2);
        padding: var(--space-5) var(--space-6);
        border-bottom: 1px solid var(--border-faint);
    }

    .admin-table tbody td {
        padding: 0;
        border-bottom: none;
    }

    .admin-table-actions,
    .admin-actions {
        justify-content: flex-start;
        width: 100%;
        text-align: left;
    }

    .admin-skeleton-row {
        grid-template-columns: 1fr;
    }
}

/* Status pill (used by StatusPill and RunStatusPill) ---------------------- */

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: 2px var(--space-2);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-radius: 999px;
    border: 1px solid var(--border-faint);
    white-space: nowrap;
}

.status-pill-pending {
    color: var(--text-tertiary);
    border-color: var(--border-faint);
}

.status-pill-ongoing {
    color: var(--accent);
    border-color: rgba(235, 30, 35, 0.40);
    background: rgba(235, 30, 35, 0.08);
}

.status-pill-finished {
    color: var(--success);
    border-color: rgba(126, 203, 143, 0.40);
    background: rgba(126, 203, 143, 0.06);
}

.status-pill-error {
    color: var(--danger);
    border-color: rgba(235, 30, 35, 0.40);
    background: rgba(235, 30, 35, 0.06);
}

.status-pill-cancelled {
    color: var(--text-muted);
    border-color: var(--border-faint);
    background: rgba(231, 230, 225, 0.03);
}

.status-pill-draft,
.status-pill-running {
    color: var(--warning);
    border-color: rgba(217, 194, 126, 0.40);
    background: rgba(217, 194, 126, 0.06);
}

.status-pill-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse-dot 1.6s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 0.35; transform: scale(0.9); }
    50%      { opacity: 1; transform: scale(1.1); }
}

