/*
 * global.esur Studio — design system
 * Visual reference: brand site (globalesur.com)
 *   + M3 color roles (dark scheme)
 *   + product register: Restrained strategy
 *
 * Theme sentence:
 *   Internal CRM operator opening the dashboard on a large monitor,
 *   during a business meeting or after hours. Needs clarity and data
 *   density. Not a marketing surface. Not playful. Confident and direct.
 *
 * Color strategy: Restrained.
 *   Brand accents (magenta, yellow, green) appear as state indicators
 *   and in identity marks only. Buttons are neutral. Surfaces are dark
 *   tinted neutrals. Nothing fights the data.
 */

/* ─── Design tokens ──────────────────────────────────────────── */

:root {
    /* Surfaces — M3 dark scheme, surface container hierarchy */
    --surface:                   oklch(15% 0.006 280);
    --surface-container-low:     oklch(17% 0.006 280);
    --surface-container:         oklch(20% 0.006 280);
    --surface-container-high:    oklch(23% 0.007 280);
    --surface-container-highest: oklch(26% 0.007 280);

    /* On-surface — M3 text roles */
    --on-surface:       oklch(95% 0.005 280);
    --on-surface-var:   oklch(75% 0.006 280);
    --on-surface-low:   oklch(55% 0.005 280);
    --outline:          oklch(100% 0 0 / 0.16);
    --outline-variant:  oklch(100% 0 0 / 0.08);

    /* Brand accents — identity only, not for button fills */
    --brand-magenta:  oklch(65% 0.22 330);
    --brand-blue:     oklch(62% 0.18 250);
    --brand-yellow:   oklch(88% 0.18 115);

    /* M3 semantic */
    --error:    oklch(65% 0.20 25);
    --on-error: oklch(98% 0 0);
    --success:  oklch(66% 0.17 150);
    --warning:  oklch(72% 0.16 70);

    /* M3 button roles — neutral, no brand fill */
    --btn-filled-bg:       oklch(90% 0.004 280);
    --btn-filled-fg:       oklch(11% 0.005 280);
    --btn-tonal-bg:        oklch(22% 0.007 280);
    --btn-tonal-fg:        oklch(82% 0.005 280);
    --btn-outlined-border: oklch(100% 0 0 / 0.18);
    --btn-outlined-fg:     oklch(72% 0.005 280);

    /* M3 shapes */
    --shape-xs:   4px;
    --shape-sm:   6px;
    --shape-md:   10px;
    --shape-lg:   16px;
    --shape-xl:   24px;
    --shape-full: 100px;

    /* Typography */
    --font-sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI',
                 Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'Geist Mono', ui-monospace, SFMono-Regular,
                 Consolas, 'Liberation Mono', Menlo, monospace;

    /* M3 type scale */
    --type-label-sm:  11px;
    --type-label-md:  12px;
    --type-label-lg:  13.5px;
    --type-body-sm:   13px;
    --type-body-md:   14px;
    --type-body-lg:   15px;
    --type-title-sm:  14px;
    --type-title-md:  16px;
    --type-title-lg:  20px;
    --type-headline:  24px;

    /* Spacing — 4px base grid */
    --sp-1:  4px;
    --sp-2:  8px;
    --sp-3:  12px;
    --sp-4:  16px;
    --sp-5:  20px;
    --sp-6:  24px;
    --sp-8:  32px;
    --sp-10: 40px;
    --sp-12: 48px;

    /* Easing */
    --ease-standard: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-emphasis: cubic-bezier(0.2, 0, 0, 1);
    --ease-decel:    cubic-bezier(0, 0, 0, 1);

    /* M3 state layers */
    --state-hover:   oklch(100% 0 0 / 0.08);
    --state-pressed: oklch(100% 0 0 / 0.12);
    --state-focused: oklch(100% 0 0 / 0.12);

    /* Layout */
    --sidebar-w: 240px;

    /* ── Backward-compatibility aliases ─────────────────────────
     * Legacy tokens used in Dashboard.razor + Settings.razor
     * <style> blocks. Mapped to M3 equivalents.              */

    /* Surfaces */
    --bg-primary:    var(--surface);
    --bg-secondary:  var(--surface-container);
    --bg-surface:    var(--surface-container-low);
    --bg-hover:      var(--surface-container-high);

    /* Text */
    --text-primary:   var(--on-surface);
    --text-secondary: var(--on-surface-var);
    --text-muted:     var(--on-surface-low);

    /* Borders */
    --border-color:       var(--outline);
    --border-color-focus: var(--brand-blue);

    /* Brand accents (old names) */
    --accent-magenta: var(--brand-magenta);
    --accent-blue:    var(--brand-blue);
    --accent-yellow:  var(--brand-yellow);

    /* Semantic (old names) */
    --danger:  var(--error);
    --danger-on: var(--on-error);

    /* Shapes (old names) */
    --radius-xs: var(--shape-xs);
    --radius-sm: var(--shape-sm);
    --radius-md: var(--shape-md);
    --radius-lg: var(--shape-lg);
    --radius-xl: var(--shape-xl);

    /* Spacing (old names) */
    --space-1:  var(--sp-1);
    --space-2:  var(--sp-2);
    --space-3:  var(--sp-3);
    --space-4:  var(--sp-4);
    --space-5:  var(--sp-5);
    --space-6:  var(--sp-6);
    --space-8:  var(--sp-8);
    --space-10: var(--sp-10);
    --space-12: var(--sp-12);

    /* Transition shorthand */
    --transition: 0.15s var(--ease-standard);

    /* Gradient brand (old names) */
    --gradient-brand-h: linear-gradient(
        90deg,
        var(--brand-magenta) 0%,
        var(--brand-blue) 55%,
        var(--brand-yellow) 100%
    );
}

/* ─── Material Web custom properties ─────────────────────────── */
/* Override M3 web component tokens to match our dark theme */

:root {
    --md-sys-color-surface:          oklch(8.5% 0.006 280);
    --md-sys-color-on-surface:       oklch(90% 0.005 280);
    --md-sys-color-surface-variant:  oklch(14% 0.006 280);
    --md-sys-color-outline:          oklch(100% 0 0 / 0.12);
    --md-sys-color-primary:          var(--brand-magenta);
    --md-sys-color-on-primary:       oklch(98% 0.003 330);
    --md-ref-typeface-plain:         'Geist', sans-serif;
    --md-ref-typeface-brand:         'Geist', sans-serif;
}

/* M3 text field component theming */
md-outlined-text-field {
    --md-outlined-text-field-container-shape: var(--shape-sm);
    --md-outlined-text-field-label-text-color: var(--on-surface-var);
    --md-outlined-text-field-input-text-color: var(--on-surface);
    --md-outlined-text-field-outline-color: var(--outline);
    --md-outlined-text-field-hover-outline-color: var(--btn-outlined-border);
    --md-outlined-text-field-focus-outline-color: var(--brand-blue);
    --md-outlined-text-field-caret-color: var(--brand-blue);
    width: 100%;
    font-family: var(--font-sans);
}

/* ─── Reset ──────────────────────────────────────────────────── */

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

html, body {
    margin: 0;
    padding: 0;
    background: var(--surface);
    color: var(--on-surface);
    font-family: var(--font-sans);
    font-size: var(--type-body-md);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s var(--ease-standard);
}

h1, h2, h3, h4 {
    margin: 0 0 var(--sp-4);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.015em;
}

/* ─── App shell ──────────────────────────────────────────────── */

.app-container {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface-container-low);
    border-right: 1px solid var(--outline-variant);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 300ms var(--ease-emphasis);
}

.sidebar-header {
    padding: var(--sp-6);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--outline-variant);
}

.sidebar-logo {
    height: 40px;
    width: auto;
}

.sidebar-nav {
    flex: 1;
    padding: var(--sp-3);
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

/* M3 Navigation Rail / Drawer item */
.nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 10px var(--sp-4);
    border-radius: var(--shape-sm);
    color: var(--on-surface-var);
    font-size: var(--type-label-lg);
    font-weight: 500;
    text-decoration: none;
    position: relative;
    transition:
        background-color 0.15s var(--ease-standard),
        color 0.15s var(--ease-standard);
}

@media (hover: hover) and (pointer: fine) {
    .nav-item:hover {
        background: var(--state-hover);
        color: var(--on-surface);
    }
}

/* Active — M3 "indicator" */
.nav-item.active {
    background: oklch(65% 0.22 330 / 0.12);   /* brand-magenta/12% state layer */
    color: var(--on-surface);
}

/* 3px accent left edge — hairline, not a side-stripe (absolute ban) */
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 var(--shape-xs) var(--shape-xs) 0;
    background: var(--brand-magenta);
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
}

.nav-icon svg { width: 100%; height: 100%; stroke-width: 1.75; }

.nav-item-disabled {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 10px var(--sp-4);
    border-radius: var(--shape-sm);
    color: var(--on-surface-low);
    font-size: var(--type-label-lg);
    font-weight: 500;
    cursor: not-allowed;
    user-select: none;
}

.nav-badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--on-surface-low);
    border: 1px solid var(--outline);
    padding: 2px 7px;
    border-radius: var(--shape-full);
}

.sidebar-footer {
    padding: var(--sp-4) var(--sp-6);
    border-top: 1px solid var(--outline-variant);
    font-size: 11px;
    color: var(--on-surface-low);
    line-height: 1.6;
}

/* ─── Main content ───────────────────────────────────────────── */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-left: var(--sidebar-w);
}

.topbar {
    height: 60px;
    border-bottom: 1px solid var(--outline-variant);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--sp-8);
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface);
}

/* Brand gradient hairline — identity mark, purposeful */
.topbar::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(
        90deg,
        var(--brand-magenta) 0%,
        var(--brand-blue) 55%,
        var(--brand-yellow) 100%
    );
    opacity: 0.85;
}

.topbar-title {
    font-size: var(--type-title-sm);
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.01em;
}

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

.topbar-user {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.topbar-user-name {
    font-size: var(--type-label-lg);
    font-weight: 500;
}

.topbar-logout {
    font-size: 12px;
    color: var(--on-surface-low);
    border-bottom: 1px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.topbar-logout:hover {
    color: var(--on-surface);
    border-color: var(--on-surface-low);
}

.page-content {
    padding: var(--sp-8);
    flex: 1;
    overflow-y: auto;
}

/* ─── Button system ─────────────────────────────────────────────
 *
 * M3 button variants — dark scheme, Restrained strategy.
 * Brand accent colors do NOT fill buttons. They live in
 * nav indicators, focus rings, data viz, and status chips.
 *
 * Hierarchy:
 *   filled   → highest emphasis. Neutral white pill.
 *   tonal    → mid emphasis. Slightly elevated surface.
 *   outlined → low emphasis. Transparent with border.
 *   text     → lowest. No bg, no border.
 *   danger   → destructive confirmation only.
 *
 * Emil polish applied on all:
 *   - scale(0.97) on :active
 *   - hover gated by pointer media query
 *   - transition: specific props only, no 'all'
 *   - :focus-visible ring
 * ────────────────────────────────────────────────────────────── */

/* Shared base */
.btn-filled,
.btn-tonal,
.btn-outlined,
.btn-text,
.btn-danger,
.btn-danger-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    border-radius: var(--shape-full);   /* M3 pill */
    font-family: var(--font-sans);
    font-size: var(--type-label-lg);
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    text-decoration: none;
    position: relative;
    outline: none;
    white-space: nowrap;
}

/* Active press — Emil scale(0.97) */
.btn-filled:active,
.btn-tonal:active,
.btn-outlined:active,
.btn-text:active,
.btn-danger:active { transform: scale(0.97); }

/* Focus ring — brand accent on keyboard nav */
.btn-filled:focus-visible,
.btn-tonal:focus-visible,
.btn-outlined:focus-visible,
.btn-text:focus-visible {
    outline: 2px solid var(--brand-blue);
    outline-offset: 3px;
}

/* Disabled — M3: 38% opacity */
.btn-filled:disabled,
.btn-tonal:disabled,
.btn-outlined:disabled,
.btn-text:disabled {
    opacity: 0.38;
    pointer-events: none;
}

/* ── Filled — highest emphasis ──────────────────────────────── */
/*
 * White-toned pill on dark surface. Reads as primary action
 * without requiring brand color in the fill.
 * On the global.esur brand site, the "Iniciar sesión" pill
 * is exactly this: white + dark text. Borrowed verbatim.
 */
.btn-filled {
    background: var(--btn-filled-bg);
    color:  var(--btn-filled-fg);
    border: none;
    padding: 10px var(--sp-6);
    box-shadow:
        0 1px 2px oklch(0% 0 0 / 0.4),
        inset 0 1px 0 oklch(100% 0 0 / 0.15);
    transition:
        transform      160ms var(--ease-standard),
        box-shadow     160ms var(--ease-standard),
        background     120ms var(--ease-standard);
}

@media (hover: hover) and (pointer: fine) {
    .btn-filled:hover {
        background: oklch(95% 0.004 280);
        box-shadow:
            0 3px 10px oklch(0% 0 0 / 0.35),
            inset 0 1px 0 oklch(100% 0 0 / 0.2);
    }
}

/* ── Tonal — mid emphasis ───────────────────────────────────── */
/*
 * M3 "filled tonal": surface-container background, on-surface text.
 * Use for: Agregar, secondary actions where a filled exists nearby.
 */
.btn-tonal {
    background: var(--btn-tonal-bg);
    color: var(--btn-tonal-fg);
    border: 1px solid var(--outline);
    padding: 9px var(--sp-5);
    transition:
        transform          160ms var(--ease-standard),
        background-color   120ms var(--ease-standard),
        border-color       120ms var(--ease-standard);
}

@media (hover: hover) and (pointer: fine) {
    .btn-tonal:hover {
        background: var(--surface-container-highest);
        border-color: oklch(100% 0 0 / 0.16);
    }
}

/* ── Outlined — low emphasis ────────────────────────────────── */
/*
 * M3 "outlined button": transparent + border.
 * Use for: Cancelar, Volver, Configuración, filtros inactivos.
 */
.btn-outlined {
    background: transparent;
    color: var(--on-surface-var);
    border: 1px solid var(--btn-outlined-border);
    padding: 9px var(--sp-5);
    transition:
        transform          160ms var(--ease-standard),
        background-color   120ms var(--ease-standard),
        color              120ms var(--ease-standard),
        border-color       120ms var(--ease-standard);
}

@media (hover: hover) and (pointer: fine) {
    .btn-outlined:hover {
        background: var(--state-hover);
        color: var(--on-surface);
        border-color: oklch(100% 0 0 / 0.22);
    }
}

/* ── Text — lowest emphasis ─────────────────────────────────── */
.btn-text {
    background: transparent;
    color: var(--on-surface-var);
    border: none;
    padding: 8px var(--sp-4);
    transition:
        transform          160ms var(--ease-standard),
        background-color   120ms var(--ease-standard),
        color              120ms var(--ease-standard);
}

@media (hover: hover) and (pointer: fine) {
    .btn-text:hover {
        background: var(--state-hover);
        color: var(--on-surface);
    }
}

/* ── Danger — destructive confirm only ─────────────────────── */
.btn-danger {
    background: var(--error);
    color: var(--on-error);
    border: none;
    padding: 10px var(--sp-6);
    box-shadow: 0 1px 2px oklch(0% 0 0 / 0.4);
    transition:
        transform          160ms var(--ease-standard),
        background-color   120ms var(--ease-standard);
}

.btn-danger:active { transform: scale(0.97); }

.btn-danger:focus-visible {
    outline: 2px solid var(--error);
    outline-offset: 3px;
}

@media (hover: hover) and (pointer: fine) {
    .btn-danger:hover {
        background: oklch(68% 0.20 25);
        box-shadow: 0 3px 10px oklch(65% 0.20 25 / 0.35);
    }
}

/* ── Danger icon — tonal, inline delete ────────────────────── */
.btn-danger-icon {
    background: oklch(65% 0.20 25 / 0.1);
    color: var(--error);
    border: 1px solid transparent;
    width: 34px;
    height: 34px;
    border-radius: var(--shape-sm);
    flex-shrink: 0;
    transition:
        transform          160ms var(--ease-standard),
        background-color   120ms var(--ease-standard),
        color              120ms var(--ease-standard),
        border-color       120ms var(--ease-standard);
}

.btn-danger-icon:active { transform: scale(0.9); }

.btn-danger-icon:focus-visible {
    outline: 2px solid var(--error);
    outline-offset: 3px;
}

@media (hover: hover) and (pointer: fine) {
    .btn-danger-icon:hover {
        background: var(--error);
        color: var(--on-error);
        border-color: var(--error);
    }
}

/* ─── Backward compatibility aliases ─────────────────────────── */
/* Map old class names → new system so existing Razor doesn't break */
.btn-primary        { @apply-from: .btn-filled; }
.btn-secondary      { @apply-from: .btn-tonal; }
.btn-ghost          { @apply-from: .btn-outlined; }
.btn-danger-confirm { @apply-from: .btn-danger; }

/* Since @apply-from doesn't exist in vanilla CSS, copy the rules explicitly: */

.btn-primary {
    display: inline-flex; align-items: center; justify-content: center;
    gap: var(--sp-2); border-radius: var(--shape-full);
    font-family: var(--font-sans); font-size: var(--type-label-lg);
    font-weight: 600; letter-spacing: 0.01em; cursor: pointer;
    text-decoration: none; position: relative; outline: none;
    white-space: nowrap;
    background: var(--btn-filled-bg); color: var(--btn-filled-fg); border: none;
    padding: 10px var(--sp-6);
    box-shadow: 0 1px 2px oklch(0% 0 0 / 0.4), inset 0 1px 0 oklch(100% 0 0 / 0.15);
    transition: transform 160ms var(--ease-standard), box-shadow 160ms var(--ease-standard), background 120ms var(--ease-standard);
}
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.38; pointer-events: none; }
.btn-primary:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
    .btn-primary:hover {
        background: oklch(95% 0.004 280);
        box-shadow: 0 3px 10px oklch(0% 0 0 / 0.35), inset 0 1px 0 oklch(100% 0 0 / 0.2);
        color: var(--btn-filled-fg);
    }
}

.btn-secondary {
    display: inline-flex; align-items: center; justify-content: center;
    gap: var(--sp-2); border-radius: var(--shape-full);
    font-family: var(--font-sans); font-size: var(--type-label-lg);
    font-weight: 600; letter-spacing: 0.01em; cursor: pointer;
    text-decoration: none; position: relative; outline: none;
    white-space: nowrap;
    background: var(--btn-tonal-bg); color: var(--btn-tonal-fg);
    border: 1px solid var(--outline); padding: 9px var(--sp-5);
    transition: transform 160ms var(--ease-standard), background-color 120ms var(--ease-standard), border-color 120ms var(--ease-standard);
}
.btn-secondary:active { transform: scale(0.97); }
.btn-secondary:disabled { opacity: 0.38; pointer-events: none; }
.btn-secondary:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
    .btn-secondary:hover { background: var(--surface-container-highest); border-color: oklch(100% 0 0 / 0.16); }
}

.btn-ghost {
    display: inline-flex; align-items: center; justify-content: center;
    gap: var(--sp-2); border-radius: var(--shape-full);
    font-family: var(--font-sans); font-size: var(--type-label-lg);
    font-weight: 500; letter-spacing: 0.01em; cursor: pointer;
    text-decoration: none; position: relative; outline: none;
    white-space: nowrap;
    background: transparent; color: var(--on-surface-var);
    border: 1px solid var(--btn-outlined-border); padding: 9px var(--sp-5);
    transition: transform 160ms var(--ease-standard), background-color 120ms var(--ease-standard), color 120ms var(--ease-standard), border-color 120ms var(--ease-standard);
}
.btn-ghost:active { transform: scale(0.97); }
.btn-ghost:disabled { opacity: 0.38; pointer-events: none; }
.btn-ghost:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
    .btn-ghost:hover { background: var(--state-hover); color: var(--on-surface); border-color: oklch(100% 0 0 / 0.22); }
}

.btn-danger-confirm {
    display: inline-flex; align-items: center; justify-content: center;
    gap: var(--sp-2); border-radius: var(--shape-full);
    font-family: var(--font-sans); font-size: var(--type-label-lg);
    font-weight: 600; letter-spacing: 0.01em; cursor: pointer;
    text-decoration: none; position: relative; outline: none;
    white-space: nowrap;
    background: var(--error); color: var(--on-error); border: none;
    padding: 10px var(--sp-6); box-shadow: 0 1px 2px oklch(0% 0 0 / 0.4);
    transition: transform 160ms var(--ease-standard), background-color 120ms var(--ease-standard);
}
.btn-danger-confirm:active { transform: scale(0.97); }
.btn-danger-confirm:focus-visible { outline: 2px solid var(--error); outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
    .btn-danger-confirm:hover { background: oklch(68% 0.20 25); }
}

/* ─── M3 Outlined text fields (CSS-only, floating label) ─────── */

.field {
    position: relative;
    width: 100%;
}

.field-input {
    display: block;
    width: 100%;
    background: transparent;
    border: 1px solid var(--outline);
    border-radius: var(--shape-sm);
    color: var(--on-surface);
    font-family: var(--font-sans);
    font-size: var(--type-body-md);
    padding: 16px 14px 8px;
    outline: none;
    transition:
        border-color 0.15s var(--ease-standard),
        box-shadow   0.15s var(--ease-standard);
    appearance: none;
}

.field-input::placeholder { color: transparent; }

.field-input:focus {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 2px oklch(62% 0.18 250 / 0.2);
}

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

.field-label {
    position: absolute;
    left: 12px;
    top: 14px;
    font-size: var(--type-body-md);
    color: var(--on-surface-var);
    pointer-events: none;
    transform-origin: left top;
    transition:
        transform 0.15s var(--ease-standard),
        color     0.15s var(--ease-standard),
        font-size 0.15s var(--ease-standard);
    background: var(--surface-container-low);
    padding: 0 2px;
}

/* Float up when focused or filled */
.field-input:focus ~ .field-label,
.field-input:not(:placeholder-shown) ~ .field-label {
    transform: translateY(-22px) scale(0.75);
    color: var(--brand-blue);
}

.field-input:not(:focus):not(:placeholder-shown) ~ .field-label {
    color: var(--on-surface-var);
}

/* Password type eye icon slot */
.field-suffix {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--on-surface-low);
    display: flex;
    align-items: center;
}

/* Select field */
select.field-input {
    padding-right: 36px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23717180' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    cursor: pointer;
}

/* Legacy input class — backward compat */
.premium-input {
    display: block;
    width: 100%;
    background: oklch(0% 0 0 / 0.2);
    border: 1px solid var(--outline);
    border-radius: var(--shape-sm);
    color: var(--on-surface);
    font-family: var(--font-sans);
    font-size: var(--type-body-md);
    padding: 9px 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
    flex: 1;
    min-width: 0;
}

.premium-input:focus {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px oklch(62% 0.18 250 / 0.15);
}

.premium-input::placeholder { color: var(--on-surface-low); }

select.premium-input {
    padding-right: 36px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23717180' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    cursor: pointer;
}

.form-label {
    display: block;
    font-size: var(--type-label-sm);
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--on-surface-var);
    margin-bottom: var(--sp-2);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

/* ─── Cards ──────────────────────────────────────────────────── */

.card {
    background: var(--surface-container);
    border: 1px solid var(--outline-variant);
    border-radius: var(--shape-lg);
    padding: var(--sp-6);
}

/* ─── Skeleton loaders ───────────────────────────────────────── */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--surface-container) 25%,
        var(--surface-container-high) 50%,
        var(--surface-container) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--shape-sm);
}

@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Error / empty states ────────────────────────────────────── */

.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-4);
    padding: var(--sp-12) var(--sp-8);
    text-align: center;
}

.error-state-icon    { width: 44px; height: 44px; color: var(--error); opacity: 0.8; }
.error-state-title   { font-size: var(--type-title-md); font-weight: 600; margin: 0; }
.error-state-message { font-size: var(--type-body-sm); color: var(--on-surface-var); max-width: 380px; margin: 0; line-height: 1.6; }

/* ─── Blazor error UI ────────────────────────────────────────── */

#blazor-error-ui {
    display: none;
    background: var(--error);
    color: var(--on-error);
    position: fixed;
    bottom: 0; left: 0; right: 0;
    padding: var(--sp-4) var(--sp-8);
    text-align: center;
    z-index: 9999;
    font-size: var(--type-body-md);
}

#blazor-error-ui a {
    color: var(--on-error);
    font-weight: 700;
    text-decoration: underline;
    margin-left: var(--sp-4);
}

#blazor-error-ui .dismiss {
    position: absolute;
    right: var(--sp-4);
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
}

/* ─── Mobile sidebar toggle ──────────────────────────────────── */

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--on-surface);
    cursor: pointer;
    padding: var(--sp-2);
    border-radius: var(--shape-sm);
    transition: background-color 0.15s;
}

.sidebar-toggle:hover { background: var(--state-hover); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: oklch(0% 0 0 / 0.55);
    z-index: 99;
    backdrop-filter: blur(2px);
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.sidebar-open { transform: translateX(0); box-shadow: 4px 0 24px oklch(0% 0 0 / 0.5); }
    .sidebar-overlay.sidebar-open { display: block; }
    .main-content { margin-left: 0; }
    .topbar { padding: 0 var(--sp-4); }
    .page-content { padding: var(--sp-4); }
    .sidebar-toggle { display: flex; align-items: center; }
}

/* ─── Status / semantic chips ────────────────────────────────── */

.chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--shape-full);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid transparent;
    white-space: nowrap;
}

.chip-success {
    color: var(--success);
    background: oklch(66% 0.17 150 / 0.12);
    border-color: oklch(66% 0.17 150 / 0.25);
}

.chip-error {
    color: var(--error);
    background: oklch(65% 0.20 25 / 0.12);
    border-color: oklch(65% 0.20 25 / 0.25);
}

.chip-neutral {
    color: var(--on-surface-var);
    background: var(--surface-container-high);
    border-color: var(--outline);
}

/* ─── Date filter pills (toggle group) ───────────────────────── */

.filter-group {
    display: flex;
    background: var(--surface-container);
    border-radius: var(--shape-full);
    padding: 3px;
    border: 1px solid var(--outline-variant);
}

.filter-btn {
    background: transparent;
    border: none;
    color: var(--on-surface-var);
    padding: 6px 16px;
    border-radius: var(--shape-full);
    cursor: pointer;
    font-weight: 500;
    font-size: var(--type-label-md);
    font-family: var(--font-sans);
    transition:
        background-color 0.15s var(--ease-standard),
        color 0.15s var(--ease-standard);
    white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
    .filter-btn:hover { color: var(--on-surface); }
}

.filter-btn.active {
    background: var(--surface-container-highest);
    color: var(--on-surface);
    box-shadow: 0 1px 3px oklch(0% 0 0 / 0.25);
}

/* ─── Generic Refactored Patterns ────────────────────────────── */

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    padding: var(--space-2) var(--space-3);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.data-table td {
    padding: 14px var(--space-3);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    font-size: 13.5px;
}

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

.data-table tbody tr {
    transition: background-color var(--transition);
}

.data-table tbody tr:hover {
    background-color: var(--bg-hover);
}

.save-confirmation {
    color: var(--success);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    margin: 0;
}

/* Confirm dialog */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: oklch(0% 0 0 / 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    animation: overlay-in 0.15s var(--ease-out);
}

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

.confirm-dialog {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    max-width: 400px;
    width: 90%;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    box-shadow: 0 24px 48px oklch(0% 0 0 / 0.5);
    animation: dialog-in 0.18s var(--ease-out);
}

@keyframes dialog-in {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.confirm-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.confirm-message {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
}

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

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon .premium-input {
    padding-right: 40px;
    width: 100%;
}

.btn-icon-inside {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
}

.btn-icon-inside:hover {
    color: var(--text-primary);
    background: var(--surface-container-highest);
}

.test-result {
    font-size: 13px;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    margin-top: calc(-1 * var(--space-2));
    margin-bottom: var(--space-2);
    margin-left: var(--space-3);
    margin-right: var(--space-3);
}

.test-result.success {
    color: var(--success);
    background: oklch(66% 0.17 150 / 0.1);
    border: 1px solid oklch(66% 0.17 150 / 0.2);
}

.test-result.error {
    color: var(--error);
    background: oklch(65% 0.20 25 / 0.1);
    border: 1px solid oklch(65% 0.20 25 / 0.2);
}