/* ── Design Tokens — EndoTrace ───────────────────────────────────────────────
   Reference: Tailwind emerald-500 for the accent
   Typography: Inter (self-hosted)
──────────────────────────────────────────────────────────────────────────── */

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/inter-400.woff2') format('woff2');
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../fonts/inter-500.woff2') format('woff2');
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('../fonts/inter-600.woff2') format('woff2');
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/inter-700.woff2') format('woff2');
}

:root {
    /* Colores — Dark mode (default)
       S23 token realignment — paleta alineada con docs/handoff/kpicard-reference-dark.png.
       Dark shell es más neutro (menos azulado). Accent pasa de emerald a teal-400 para
       igualar el mockup. README:45-49 del handoff es la fuente de verdad de la paleta. */
    --et-bg:          #0b0d10;
    --et-surface:     #16181d;
    --et-surface-2:   #1c1f25;
    --et-surface-3:   #20242b;   /* inputs, search-pill bg */
    --et-accent:      #2dd4bf;   /* teal-400 */
    --et-accent-hover:#14b8a6;   /* teal-500 */
    --et-accent-active:#0d9488;  /* teal-600 */
    --et-on-accent:   #FFFFFF;
    --et-text:        #E8EAED;
    --et-text-muted:  #8b9199;
    --et-text-subtle: #5c626a;   /* timestamps, placeholders */
    --et-border:      #2d343d;
    --et-border-strong:#3a424d;  /* hover / selected */

    /* Colores — Light mode (crema cálido per reference) */
    --et-bg-light:           #fafaf8;
    --et-surface-light:      #FFFFFF;
    --et-surface-2-light:    #f4f4f1;
    --et-surface-3-light:    #eceae5;
    --et-text-light:         #18181b;
    --et-text-muted-light:   #71717a;
    --et-text-subtle-light:  #a1a1aa;
    --et-border-light:       #e7e5e0;
    --et-border-strong-light:#d4d4d0;

    /* Radios */
    --et-radius-card:   12px;
    --et-radius-btn:    8px;
    --et-radius-input:  8px;
    --et-radius-lg:     16px;    /* hero containers */
    --et-radius-full:   9999px;  /* pills, avatars */

    /* Status (S23 — alineado con reference paleta). Red/amber plenos, success emerald. */
    --et-status-success: #10b981;   /* emerald-500 */
    --et-status-error:   #ef4444;   /* red-500 */
    --et-status-warning: #f59e0b;   /* amber-500 */
    --et-status-info:    #60a5fa;   /* blue-400 */

    /* Chart palette (4+1 buckets, aging/segments) — reference rows 2-6 */
    --et-chart-1: #2dd4bf;   /* teal */
    --et-chart-2: #f59e0b;   /* amber */
    --et-chart-3: #ef4444;   /* red */
    --et-chart-4: #60a5fa;   /* blue */
    --et-chart-5: #a78bfa;   /* violet (reserve) */

    /* Pill-button radius (S23 — CTA "Nueva orden" en reference). */
    --et-radius-btn-pill: 14px;

    /* Status — soft backgrounds (T-02, from KpiCard PoC).
       --et-warning-bg / --et-error-bg are retained above as legacy aliases; new
       consumers should prefer the -soft variants. Dark-mode alpha = 12%. */
    --et-status-success-soft: color-mix(in srgb, var(--et-status-success) 12%, transparent);
    --et-status-info-soft:    color-mix(in srgb, var(--et-status-info) 12%, transparent);
    --et-status-warning-soft: color-mix(in srgb, var(--et-status-warning) 12%, transparent);
    --et-status-error-soft:   color-mix(in srgb, var(--et-status-error) 12%, transparent);

    /* Status — soft text (T-03). Mixes the status/accent hue with muted text
       so labels stay legible at low contrast backgrounds. */
    --et-status-success-text-soft: color-mix(in srgb, var(--et-status-success) 72%, var(--et-text-muted) 28%);
    --et-status-info-text-soft:    color-mix(in srgb, var(--et-status-info) 72%, var(--et-text-muted) 28%);
    --et-status-warning-text-soft: color-mix(in srgb, var(--et-status-warning) 72%, var(--et-text-muted) 28%);
    --et-status-error-text-soft:   color-mix(in srgb, var(--et-status-error) 72%, var(--et-text-muted) 28%);
    --et-accent-text-soft:         color-mix(in srgb, var(--et-accent) 72%, var(--et-text-muted) 28%);

    /* Shadows / Elevation */
    --et-shadow-card:  0 2px 8px rgba(0, 0, 0, 0.3); /* legacy — valor propio, NO alias de --et-elevation-2 */
    --et-elevation-0:  none;
    --et-elevation-1:  0 1px 2px rgba(0, 0, 0, 0.2);
    --et-elevation-2:  0 2px 4px rgba(0, 0, 0, 0.25);
    --et-elevation-4:  0 4px 8px rgba(0, 0, 0, 0.3);
    --et-elevation-8:  0 8px 16px rgba(0, 0, 0, 0.4);
    --et-elevation-12: 0 12px 24px rgba(0, 0, 0, 0.5);
    --et-elevation-16: 0 16px 48px rgba(0, 0, 0, 0.6);
    --et-modal-edge:   0 0 2px 0 rgba(255, 255, 255, 0.15), 0 12px 48px -4px rgba(0, 0, 0, 0.7), 0 0 100px -10px rgba(0, 0, 0, 0.5);

    /* Typography */
    --et-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Spacing scale (4px base) */
    --et-space-1:  0.25rem;   /* 4px */
    --et-space-2:  0.5rem;    /* 8px */
    --et-space-3:  0.75rem;   /* 12px */
    --et-space-4:  1rem;      /* 16px */
    --et-space-5:  1.25rem;   /* 20px (T-01, KpiCard header gap) */
    --et-space-6:  1.5rem;    /* 24px */
    --et-space-8:  2rem;      /* 32px */
    --et-space-12: 3rem;      /* 48px */

    /* Spacing semantic aliases (S01) */
    --et-spacing-xs:   var(--et-space-1);   /* 4px */
    --et-spacing-sm:   var(--et-space-2);   /* 8px */
    --et-spacing-md:   var(--et-space-3);   /* 12px */
    --et-spacing-base: var(--et-space-4);   /* 16px */
    --et-spacing-lg:   var(--et-space-6);   /* 24px */
    --et-spacing-xl:   var(--et-space-8);   /* 32px */
    --et-spacing-xxl:  var(--et-space-12);  /* 48px */

    /* Typography scale */
    --et-text-xs:   0.75rem;   /* 12px */
    --et-text-sm:   0.8125rem; /* 13px */
    --et-text-base: 0.875rem;  /* 14px */
    --et-text-lg:   1rem;      /* 16px */
    --et-text-xl:   1.25rem;   /* 20px */
    --et-text-2xl:  1.5rem;    /* 24px — page titles */
    --et-text-3xl:  2rem;      /* 32px — display */

    /* Z-index scale */
    --et-z-header:   1000;
    --et-z-overlay:  1050;
    --et-z-sidebar:  1100;
    --et-z-dialog:   1300;
    --et-z-snackbar: 1400;

    /* Notification shell tokens (accessible notification system). */
    --et-notification-border: color-mix(in srgb, var(--et-border-strong) 70%, transparent);
    --et-notification-backdrop: color-mix(in srgb, var(--et-bg) 86%, transparent);
    --et-notification-shadow: color-mix(in srgb, var(--et-bg) 70%, transparent);
    --et-notification-muted-panel: color-mix(in srgb, var(--et-surface-3) 74%, transparent);
    --et-notification-modal-max: 520px;
    --et-notification-priority-max: 680px;
    --et-notification-decision-max: 580px;
    --et-notification-quick-max: 560px;

    /* Overlay / hover (light-mode safe) */
    --et-hover-overlay: rgba(255, 255, 255, 0.05);
    --et-badge-overlay: rgba(255, 255, 255, 0.08);

    /* Missing radius */
    --et-radius-sm: 4px;

    /* Semantic surface tokens (S23 — teal rebased). */
    --et-error-bg:          rgba(239, 68, 68, 0.1);
    --et-accent-subtle:     rgba(45, 212, 191, 0.08);
    --et-accent-tag:        rgba(45, 212, 191, 0.12);
    --et-accent-tag-light:  rgba(45, 212, 191, 0.05);
    --et-warning-bg:        rgba(245, 158, 11, 0.1);
    --et-overlay:           rgba(0, 0, 0, 0.4);

    /* Motion (S01) */
    --et-motion-fast:     120ms;
    --et-motion-normal:   200ms;
    --et-motion-slow:     320ms;
    --et-motion-lift:     -1px;  /* T-08, translateY on hover lift */
    --et-motion-skeleton: 1.4s;  /* T-09, shimmer loop duration */
    --et-ease-standard:   cubic-bezier(0.4, 0, 0.2, 1);

    /* Focus ring (S01 + S23 teal rebase). */
    --et-focus-ring:       0 0 0 3px rgba(45, 212, 191, 0.25);
    --et-focus-ring-width: 3px;

    /* Stroke widths (T-04, SVG). Unitless — stroke-width accepts raw numbers. */
    --et-stroke-fine:    1.6;
    --et-stroke-regular: 1.7;
    --et-stroke-bold:    2.4;

    /* Card sizing (T-05). Minimum heights to avoid layout jitter when skeletons
       swap into real content. */
    --et-card-min-h-default: 160px;
    --et-card-min-h-dense:   132px;

    /* Typography tracking (T-06). Negative tightens display numerals; positive
       widens eyebrows / all-caps labels. */
    --et-tracking-tight:  -0.02em;
    --et-tracking-normal: 0;
    --et-tracking-wide:   0.04em;

    /* Charts (T-07). Area fill opacity under sparkline strokes. */
    --et-chart-area-alpha: 0.2;

    /* Color mixing ratios (T-10). Generic overlay/tint alphas plus the
       badge-text-soft split used by KpiCard. Named specifically so they do not
       collide with future chart/status mix alphas. */
    --et-mix-overlay:              10%;
    --et-mix-tint:                 30%;
    --et-badge-text-mix-primary:   72%;
    --et-badge-text-mix-secondary: 28%;

    /* ── S10d tokens — consumed by dashboard-role.css ────────────────────────
       Added as part of S10d remediation (CRITICAL-2). These close the 10-token
       gap discovered by FMEA validator; every new var is either a semantic
       alias over an existing primitive or a spec-mandated constant. */

    /* Card sizing — minimum width for auto-fill grid columns in vendor dashboard.
       Matches the existing --et-dash-card-min default used by S10c admin grid. */
    --et-size-card-min: 280px;

    /* Dashboard grid — KPI row minimum column width and gap (S10g unification).
       --et-size-kpi-row-min drives the 4-column responsive KPI row via auto-fill.
       --et-dash-gap is the canonical gap across every .et-dashboard-grid instance. */
    --et-size-kpi-row-min: 240px;
    --et-dash-gap: var(--et-space-6);

    /* Radius semantic alias — pill-shaped chips/badges. Aliases --et-radius-full. */
    --et-radius-pill: var(--et-radius-full);

    /* Line-height scale — small copy (chips, badges). Tight for single-line labels. */
    --et-line-sm: 1.25;

    /* Transition preset — composed duration+easing for chip hover/toggle feedback. */
    --et-transition-fast: var(--et-motion-fast) var(--et-ease-standard);

    /* Font-weight semantic aliases (matches Inter webfont variants already loaded). */
    --et-font-semibold: 600;
    --et-font-bold:     700;

    /* Border tint — subtler divider for dense tables where var(--et-border) reads
       too heavy. 50% alpha mix toward surface keeps rows legible at small sizes. */
    --et-border-subtle: color-mix(in srgb, var(--et-border) 50%, transparent);

    /* Disabled-state opacity. Constant at 0.5 across UI controls (WCAG AA-aware
       when combined with tint/label contrast). */
    --et-opacity-disabled: 0.5;

    /* Heading size aliases — map to MudBlazor Typo.h5 / Typo.h6 equivalents
       used by pre-S10d Dashboard.razor vendor block (replaced by .et-value-accent). */
    --et-text-h5: 1.25rem;   /* 20px */
    --et-text-h6: 1rem;      /*  16px */

    /* Color on top of var(--et-accent) — emerald-500 background → white text.
       Named CSS color (not hex) to keep ET0002 parity with the other 10 new tokens. */
    --et-on-accent: white;
}

/* ── Dark theme runtime authority (MudBlazor token sync) ───────────────────
   html[data-theme] is the visual source of truth because theme.js sets it before
   Blazor hydrates. MudThemeProvider can briefly or permanently disagree when
   server/client theme resolution diverges, so both explicit themes pin the Mud
   CSS variables at the html level. Without this, dark shells can inherit light
   Mud tokens: white labels and black icons on dark inputs. */
html[data-theme="dark"] {
    --mud-palette-text-primary:               rgba(232, 234, 237, 1);
    --mud-palette-text-secondary:             rgba(156, 163, 175, 1);
    --mud-palette-text-disabled:              rgba(255, 255, 255, 0.38);
    --mud-palette-action-default:             rgba(232, 234, 237, 0.74);
    --mud-palette-action-default-hover:       rgba(255, 255, 255, 0.08);
    --mud-palette-action-disabled:            rgba(255, 255, 255, 0.26);
    --mud-palette-action-disabled-background: rgba(255, 255, 255, 0.12);
    --mud-palette-surface:                    rgba(28, 30, 38, 1);
    --mud-palette-background:                 rgba(15, 17, 23, 1);
    --mud-palette-background-gray:            rgba(22, 24, 29, 1);
    --mud-palette-appbar-background:          rgba(28, 30, 38, 1);
    --mud-palette-lines-default:              rgba(255, 255, 255, 0.12);
    --mud-palette-lines-inputs:               rgba(156, 163, 175, 1);
    --mud-palette-table-lines:                rgba(255, 255, 255, 0.12);
    --mud-palette-table-striped:              rgba(255, 255, 255, 0.02);
    --mud-palette-table-hover:                rgba(255, 255, 255, 0.04);
    --mud-palette-divider:                    rgba(255, 255, 255, 0.12);
    --mud-palette-divider-light:              rgba(255, 255, 255, 0.8);
    --mud-palette-skeleton:                   rgba(255, 255, 255, 0.11);
    --mud-native-html-color-scheme:           dark;
}

/* ── Light theme runtime override (S02) ─────────────────────────────────────
   Activated by js/theme.js setting <html data-theme="light">.
   Reassigns the core color tokens to their *-light counterparts so every
   existing rule consuming var(--et-bg), var(--et-surface), etc. picks up the
   light palette without changes. Status / accent / motion / elevation tokens
   remain cross-mode per Constitution §Palette. */
html[data-theme="light"] {
    --et-bg:         var(--et-bg-light);
    --et-surface:    var(--et-surface-light);
    --et-surface-2:  var(--et-surface-2-light);
    --et-text:       var(--et-text-light);
    --et-text-muted: var(--et-text-muted-light);
    --et-border:     var(--et-border-light);
    --et-hover-overlay: rgba(0, 0, 0, 0.04);
    --et-badge-overlay: rgba(0, 0, 0, 0.06);

    /* Status soft backgrounds at 8% alpha for legibility on light surfaces. */
    --et-status-success-soft: color-mix(in srgb, var(--et-status-success) 8%, transparent);
    --et-status-info-soft:    color-mix(in srgb, var(--et-status-info) 8%, transparent);
    --et-status-warning-soft: color-mix(in srgb, var(--et-status-warning) 8%, transparent);
    --et-status-error-soft:   color-mix(in srgb, var(--et-status-error) 8%, transparent);

    /* MudBlazor palette overrides — applied at <html> level so they win over
       MudThemeProvider's :root dark output. Values come from PaletteLight in
       Components/EndoTraceTheme.cs plus MudBlazor's computed light defaults
       (extracted once from IsDarkMode="false" render, 2026-04-20).

       Why here (not via MudThemeProvider parameter): EndoLayout is rendered in
       static SSR mode (pages declare @rendermode InteractiveServer, layouts
       don't), so IThemeService.InitializeAsync never fires from OnAfterRender.
       Theme state lives in localStorage + the data-theme attribute on <html>,
       set pre-hydration by wwwroot/js/theme.js (FOUC-free). S12c may promote
       the layout to interactive; this block remains correct regardless. */
    --mud-palette-text-primary:               rgba(26, 26, 46, 1);
    --mud-palette-text-secondary:             rgba(107, 114, 128, 1);
    --mud-palette-text-disabled:              rgba(0, 0, 0, 0.38);
    --mud-palette-action-default:             rgba(0, 0, 0, 0.54);
    --mud-palette-action-default-hover:       rgba(0, 0, 0, 0.06);
    --mud-palette-action-disabled:            rgba(0, 0, 0, 0.26);
    --mud-palette-action-disabled-background: rgba(0, 0, 0, 0.12);
    --mud-palette-surface:                    rgba(255, 255, 255, 1);
    --mud-palette-background:                 rgba(248, 249, 250, 1);
    --mud-palette-background-gray:            rgba(245, 245, 245, 1);
    --mud-palette-appbar-background:          rgba(255, 255, 255, 1);
    --mud-palette-lines-default:              rgba(0, 0, 0, 0.12);
    --mud-palette-lines-inputs:               rgba(189, 189, 189, 1);
    --mud-palette-table-lines:                rgba(224, 224, 224, 1);
    --mud-palette-table-striped:              rgba(0, 0, 0, 0.02);
    --mud-palette-table-hover:                rgba(0, 0, 0, 0.04);
    --mud-palette-divider:                    rgba(224, 224, 224, 1);
    --mud-palette-divider-light:              rgba(0, 0, 0, 0.8);
    --mud-palette-skeleton:                   rgba(0, 0, 0, 0.11);
    --mud-palette-black:                      rgba(39, 44, 52, 1);
    --mud-native-html-color-scheme:           light;
}

/* ── Reusable page classes ──────────────────────────────────────────────── */
.et-page-header {
    margin-bottom: var(--et-space-6);
}

.et-page-header h1 {
    color: var(--et-text);
    font-size: var(--et-text-2xl);
    font-weight: 600;
    margin: 0 0 var(--et-space-1);
}

.et-page-subtitle {
    color: var(--et-text-muted);
    font-size: var(--et-text-base);
    margin: 0;
}

.et-empty-state {
    text-align: center;
    padding: var(--et-space-8) var(--et-space-4);
}

.et-empty-state-icon {
    color: var(--et-text-muted);
    opacity: 0.5;
    margin-bottom: var(--et-space-3);
}

.et-empty-state-title {
    color: var(--et-text);
    margin-bottom: var(--et-space-1);
}

.et-empty-state-description {
    color: var(--et-text-muted);
}

.et-status-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: var(--et-radius-sm);
    font-size: var(--et-text-xs);
    font-weight: 500;
}

.et-status-badge--accent {
    background: rgba(45, 212, 191, 0.1);
    color: var(--et-accent);
}

.et-status-badge--warning {
    color: var(--et-status-warning);
    font-weight: 500;
}

.et-status-badge--error {
    color: var(--et-status-error);
    font-weight: 600;
}

/* ── Reset and base ───────────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Only NON-interactive elements lose focus ring.
   div and span can be interactive in Blazor, so we leave them out. */
h1, h2, h3, h4, h5, h6, p, section, article, main {
    outline: none;
}

/* ── Focus-visible para inputs SSR (Login, ForgotPassword, ResetPassword) ─── */
.et-input:focus-visible {
    outline: none;
    border-color: var(--et-accent) !important;
    box-shadow: var(--et-focus-ring);
}

.et-input:focus:not(:focus-visible) {
    outline: none;
}

/* ── Skip to main content link (S08a — accessibility) ───────────────────── */
.et-skip-link {
    position: absolute;
    top: -9999px;
    left: 0;
    z-index: var(--et-z-overlay);
    padding: var(--et-spacing-sm) var(--et-spacing-base);
    background: var(--et-bg);
    color: var(--et-text);
    border: 2px solid rgba(45, 212, 191, 0.6);
    border-radius: var(--et-radius-sm);
    font-size: var(--et-text-base);
    font-weight: 500;
    text-decoration: none;
}

.et-skip-link:focus {
    top: 0;
    box-shadow: var(--et-focus-ring);
}

html {
    height: 100dvh;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--et-font);
    background-color: var(--et-bg);
    color: var(--et-text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

body {
    overscroll-behavior: none;
}

/* ── Custom scrollbar (dark) ────────────────────────────────────────────────*/
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--et-bg); }
::-webkit-scrollbar-thumb { background: var(--et-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--et-text-muted); }

/* ── Welcome page ──────────────────────────────────────────────────────────*/
.welcome-container {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.welcome-container h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--et-text);
    margin-bottom: 0.5rem;
}

.welcome-container p {
    color: var(--et-text-muted);
    font-size: 1rem;
    margin-bottom: 2rem;
}

.welcome-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    background-color: rgba(45, 212, 191, 0.1);
    border: 1px solid rgba(45, 212, 191, 0.25);
    border-radius: 50px;
    color: var(--et-accent);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}

.welcome-container .accent-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--et-accent);
    flex-shrink: 0;
}

.welcome-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 2rem;
    background-color: var(--et-accent);
    color: var(--et-on-accent);
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
    transition: background-color 0.15s, transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 0 0 0 rgba(45, 212, 191, 0);
}

.welcome-cta:hover {
    background-color: var(--et-accent-hover);
    color: var(--et-on-accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(45, 212, 191, 0.35);
}

.welcome-cta:focus-visible {
    outline: 2px solid var(--et-accent);
    outline-offset: 4px;
    border-radius: 50px;
}

.welcome-cta:active {
    transform: translateY(0);
    box-shadow: none;
}

/* ── Clickable identifier — used in grid TemplateColumns for QuickView triggers ── */
/* Applied via MudLink OnClick (no Href). No underline by design decision. */
.clickable-identifier {
    color: var(--et-accent);
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.clickable-identifier:hover {
    opacity: 0.85;
    text-decoration: none;
}

/* ── Product image drop zone ─────────────────────────── */
.product-image-dropzone {
    width: 100%;
    max-width: 180px;
    min-height: 180px;
    border: 2px dashed var(--et-border);
    border-radius: var(--et-radius-card);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    background: var(--et-surface);
    transition: border-color 150ms ease, background 150ms ease;
}

.product-image-dropzone.drag-over {
    border-color: var(--et-accent);
    background: rgba(45, 212, 191, 0.08);
}

.product-image-dropzone:focus-visible {
    outline: 2px solid var(--et-accent);
    outline-offset: 2px;
}

/* ── Modal edge definition — hybrid Apple/Samsung ambient glow ── */
.mud-dialog {
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: var(--et-modal-edge);
}

/* ── Confirmation dialogs use the approved notification visual shell ─────── */
/* !important required: MudBlazor applies width/overflow chrome on .mud-dialog. */
.mud-dialog.et-confirm-dialog-shell {
    width: min(var(--et-notification-decision-max), calc(100vw - 32px)) !important;
    max-width: min(var(--et-notification-decision-max), calc(100vw - 32px)) !important;
    overflow: visible !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.mud-dialog.et-confirm-dialog-shell .mud-dialog-content {
    overflow: visible !important;
    padding: 0 !important;
    background: transparent !important;
}

/* ── Edit-mode chip (detail ↔ edit toggle in dialogs) ──────────────────── */
.et-edit-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: var(--et-text-sm);
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}
.et-edit-chip--readonly {
    background: var(--et-accent-subtle);
    color: var(--et-accent);
}
.et-edit-chip--editing {
    background: var(--et-accent-subtle);
    color: var(--et-accent);
}

/* ── Clickable name in data grids ──────────────────────────────────────── */
.et-name-link {
    color: var(--et-accent) !important;
    font-weight: 500;
    cursor: pointer;
}

/* ── Dialog disabled fields: keep text legible (not grayed out) ─────────── */
.mud-dialog .mud-input-control.mud-disabled .mud-input-slot,
.mud-dialog .mud-input-control.mud-disabled .mud-input-adornment-text {
    color: var(--et-text) !important;
    -webkit-text-fill-color: var(--et-text) !important;
}

/* ── DataGrid horizontal scroll wrapper ─────────────────────────────────── */
/* Wraps every MudDataGrid to contain horizontal overflow within its container */
.et-grid-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Touch target utility — WCAG AA 44px minimum ────────────────────────── */
/* Applied selectively — NOT globally to all buttons */
.et-touch-target {
    min-height: 44px;
    min-width: 44px;
}

/* ── Dialog fullscreen on mobile (< 600px) ──────────────────────────────── */
/* MudBlazor auto-applies .mud-dialog-width-lg/md/sm based on MaxWidth option.  */
/* !important required: MudBlazor sets max-width as inline style on .mud-dialog. */
/* Scoped inside @media so desktop rendering is completely unaffected.           */
@media (max-width: 600px) {
    .mud-dialog-width-lg,
    .mud-dialog-width-md,
    .mud-dialog-width-sm {
        width: 100vw !important;
        max-width: 100vw !important;
        max-height: 100dvh !important;
        height: 100dvh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        border: none !important;
    }

    .mud-dialog-width-lg .mud-dialog-content,
    .mud-dialog-width-md .mud-dialog-content,
    .mud-dialog-width-sm .mud-dialog-content {
        padding: 8px 12px !important;
    }

    .mud-dialog-width-lg .mud-dialog-title,
    .mud-dialog-width-md .mud-dialog-title,
    .mud-dialog-width-sm .mud-dialog-title {
        padding: 12px 12px 8px !important;
    }
}

/* ── StandardGrid toolbar — §14.11 global standard ── */
.standard-grid__toolbar {
    display: flex !important;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.standard-grid__toolbar > .mud-input-control {
    margin: 0 !important;
    min-width: 160px;
    max-width: 400px;
    flex: 1 1 200px;
}

.standard-grid__toolbar > .mud-select {
    margin: 0 !important;
    min-width: 100px;
    max-width: 180px;
    flex: 0 1 auto;
}

/* Force all controls in toolbar to same height */
.standard-grid__toolbar > .mud-input-control,
.standard-grid__toolbar > .mud-select {
    height: auto;
    max-height: 56px;
}

/* Date filter inputs — fixed width, no flex grow */
.standard-grid__toolbar .et-date-filter {
    min-width: 150px;
    max-width: 180px;
    flex: 0 0 auto !important;
}

/* Date picker popover calendar — full natural width */
.et-date-picker-popover {
    min-width: 320px !important;
}

/* ── S23 Product dialog layout helpers ────────────────────────────────────── */
.et-product-image-col {
    flex-shrink: 1;
    min-width: 180px;
    width: 100%;
    max-width: 180px;
}
.et-product-form-col {
    flex: 1;
    min-width: 0;
}
.et-product-sku-regenerate {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.et-product-prices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--et-spacing-base);
    align-items: start;
}

.et-enterprise-label-profile-card,
.et-recipe-net-content-card {
    min-height: auto;
}

.et-enterprise-label-profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--et-spacing-base);
    align-items: start;
}

.et-readiness-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--et-space-3);
    margin-top: var(--et-space-3);
}

.et-readiness-fact {
    border: 1px solid var(--et-border);
    border-radius: var(--et-radius-card);
    padding: var(--et-space-3);
    background: var(--et-surface-2);
    display: flex;
    flex-direction: column;
    gap: var(--et-space-1);
    min-width: 0;
}

.et-readiness-fact--wide {
    grid-column: 1 / -1;
}

.et-readiness-label {
    color: var(--et-text-muted);
    font-size: var(--et-text-xs);
    font-weight: 600;
    letter-spacing: var(--et-tracking-wide);
    text-transform: uppercase;
}

.et-readiness-value {
    color: var(--et-text);
    font-size: var(--et-text-sm);
    overflow-wrap: anywhere;
}

.et-readiness-blockers {
    margin: var(--et-space-3) 0 0;
    padding-left: var(--et-space-5);
    color: var(--et-text-muted);
    font-size: var(--et-text-sm);
}

.et-label-readiness-summary {
    margin-top: var(--et-space-3);
    border: 1px solid var(--et-border);
    border-radius: var(--et-radius-card);
    padding: var(--et-space-3);
    display: flex;
    flex-direction: column;
    gap: var(--et-space-2);
}

.et-label-readiness-summary__header {
    display: flex;
    justify-content: space-between;
    gap: var(--et-space-3);
    align-items: center;
}

.et-label-readiness-summary__title {
    color: var(--et-text);
    font-size: var(--et-text-sm);
    font-weight: 600;
}

.et-label-readiness-summary__status {
    color: var(--et-text-muted);
    font-size: var(--et-text-xs);
    font-weight: 600;
    letter-spacing: var(--et-tracking-wide);
    text-transform: uppercase;
}

.et-label-readiness-summary__body {
    color: var(--et-text-muted);
    font-size: var(--et-text-sm);
    display: flex;
    flex-wrap: wrap;
    gap: var(--et-space-2) var(--et-space-4);
}

.et-label-readiness-summary__missing {
    color: var(--et-text);
    font-size: var(--et-text-sm);
}

@media (max-width: 599px) {
    .standard-grid__toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .standard-grid__toolbar > .mud-input-control,
    .standard-grid__toolbar > .mud-select {
        min-width: 100%;
        max-width: 100%;
    }
    .standard-grid__toolbar .et-date-filter {
        min-width: 100%;
        max-width: 100%;
    }

    :is(.et-sales-orders-panel, .et-deliveries-panel, .et-invoices-panel, .et-third-party-panel) .standard-grid__toolbar .mud-input-control,
    :is(.et-sales-orders-panel, .et-deliveries-panel, .et-invoices-panel, .et-third-party-panel) .standard-grid__toolbar .mud-select,
    :is(.et-sales-orders-panel, .et-deliveries-panel, .et-invoices-panel, .et-third-party-panel) .standard-grid__toolbar .standard-grid__scope,
    :is(.et-sales-orders-panel, .et-deliveries-panel, .et-invoices-panel, .et-third-party-panel) .standard-grid__toolbar .mud-picker,
    :is(.et-sales-orders-panel, .et-deliveries-panel, .et-invoices-panel, .et-third-party-panel) .standard-grid__toolbar .et-input {
        min-width: 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        flex: 1 1 100% !important;
        align-self: stretch !important;
    }
    :is(.et-sales-orders-panel, .et-deliveries-panel, .et-invoices-panel, .et-third-party-panel) .standard-grid__toolbar .et-date-filter {
        min-width: 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        flex: 1 1 100% !important;
        align-self: stretch !important;
    }

    :is(.et-sales-orders-panel, .et-deliveries-panel, .et-invoices-panel, .et-third-party-panel) .standard-grid__command-actions > *,
    :is(.et-sales-orders-panel, .et-deliveries-panel, .et-invoices-panel, .et-third-party-panel) .standard-grid__command-actions .mud-button-root {
        width: 100%;
    }
}

/* === Dashboard grid (S10g unification) === */
/* Single canonical grid for every dashboard composite (admin, owner, vendor,
   jefe-de-almacén, dev preview). Replaces the previous trio (.et-dashboard-grid
   + .et-dash-admin-grid + .et-dash-owner__kpis + .et-dash-role-grid).
   - 4-column KPI row via auto-fill on --et-size-kpi-row-min.
   - Gap and alignment via --et-dash-gap (S10d tokens).
   - Span utilities (--span-2, --span-3, --span-full) for wide cells like
     tables/breakdown sections. */

.et-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--et-size-kpi-row-min), 1fr));
    gap: var(--et-dash-gap);
    align-items: stretch;
}

.et-dashboard-grid--2col {
    grid-template-columns: repeat(2, 1fr);
}

.et-dashboard-grid--3col {
    grid-template-columns: repeat(3, 1fr);
}

.et-dashboard-grid__item--span-2 { grid-column: span 2; }
.et-dashboard-grid__item--span-3 { grid-column: span 3; }
.et-dashboard-grid__item--span-full { grid-column: 1 / -1; }

@media (max-width: 767px) {
    .et-dashboard-grid,
    .et-dashboard-grid--2col,
    .et-dashboard-grid--3col {
        grid-template-columns: 1fr;
    }

    .et-dashboard-grid__item--span-2,
    .et-dashboard-grid__item--span-3 {
        grid-column: span 1;
    }
}

/* Dashboard widget body styles + dev preview helpers live in
   css/dashboard-widgets.css (sidecar). Load order: app.css -> dashboard-role.css
   -> dashboard-widgets.css (see Components/App.razor). */

/* ── Layout helpers (generic spacing/alignment) ─────────────────────────── */
/* Small, composable utilities consumed across composites that would
   otherwise require inline styles. Stick to tokens only (no raw values). */
.et-stack-lg     { margin-top: var(--et-space-6); }
.et-flex-row-md  { display: flex; gap: var(--et-space-4); align-items: center; }
.et-flex-center  { display: flex; justify-content: center; padding: var(--et-space-12); }
.et-col-narrow   { max-width: 400px; }
.et-text-right   { text-align: right; }
.et-text-success { color: var(--et-status-success); }
.et-text-error   { color: var(--et-status-error); }
.et-text-warning { color: var(--et-status-warning); }

/* Generic numeric cell (tables outside the dashboard .et-invoices-table scope).
   Pairs with .td--numeric defined in dashboard-role.css for invoice tables.
   Covers th/td AND span children used inside MudDataGrid CellTemplates
   (span gets display:block so the right-alignment fills the cell width). */
td.td--numeric,
th.td--numeric { text-align: right; font-variant-numeric: tabular-nums; }
span.td--numeric { display: block; text-align: right; font-variant-numeric: tabular-nums; }

/* Semibold emphasis for balance/total cells (stackable with .td--numeric). */
.td--balance-plain { font-weight: var(--et-font-semibold); }

/* Hot invoice payment action: intentionally danger/amber-soft, not success-green,
   so it stands apart from current/success semantics in Payments and AR tables. */
.et-pay-action-cell {
    --et-pay-action-slot-width: 3.5rem;

    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: var(--et-pay-action-slot-width);
    min-height: 2rem;
}

.et-pay-action-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--et-pay-action-slot-width);
    min-width: var(--et-pay-action-slot-width);
    min-height: 2rem;
    color: var(--et-text-muted);
    line-height: 1;
}

.et-pay-action-cell .et-invoice-pay-action {
    width: var(--et-pay-action-slot-width);
    min-width: var(--et-pay-action-slot-width);
}

.et-invoice-pay-action {
    padding-inline: var(--et-space-3);
    border: 1px solid transparent;
    background: var(--et-status-success);
    color: #fff;
    font-weight: var(--et-font-semibold);
    line-height: 1;
    box-shadow: none;
}

.et-invoice-pay-action:hover,
.et-invoice-pay-action:focus-visible {
    filter: brightness(1.04);
    box-shadow: var(--et-focus-ring);
}

/* Table scroll — vertical cap. Pairs with .et-table-scroll (horizontal) so a
   wrapper can opt into a capped, vertically-scrollable viewport for tall
   MudSimpleTable content. */
.et-table-scroll--capped { max-height: 520px; overflow-y: auto; }

/* Totals / summary row for MudSimpleTable tfoot (reports). */
.et-table-totals-row { font-weight: var(--et-font-bold); border-top: 2px solid var(--et-border); }
