/* ══════════════════════════════════════════════════════════════════
   e-Baja v2 — Override de marca sobre Tabler.
   Verde corporativo #309b7b (heredado del legacy).
   Adaptado del brand.css de RutaBus / Check to Drive, podado a lo
   estrictamente necesario para arrancar (login + layout base). El
   resto de estilos (dashboards, listados, hero…) se irán añadiendo
   a medida que se monten las pantallas.
   ══════════════════════════════════════════════════════════════════ */

:root {
    --eb-green:         #309b7b;
    --eb-green-dark:    #26805f;
    --eb-green-darker:  #1c634a;
    --eb-green-light:   #7ec9b1;
    --eb-green-50:      #e8f5ef;
    --eb-green-100:     #c8e8d9;
    --eb-charcoal:      #1a1a1a;
    --eb-charcoal-2:    #2a2a2a;

    /* Overrides Tabler */
    --tblr-primary:         var(--eb-green);
    --tblr-primary-rgb:     48, 155, 123;
    --tblr-primary-darken:  var(--eb-green-dark);
    --tblr-primary-lt:      var(--eb-green-50);

    --tblr-link-color:        var(--eb-green-dark);
    --tblr-link-hover-color:  var(--eb-green-darker);

    --tblr-success:      #309b7b;
    --tblr-success-rgb:  48, 155, 123;

    --tblr-border-color: #e6ecf2;
    --tblr-body-bg:      #f7faf9;
    --tblr-card-bg:      #ffffff;
}

/* Botones y enlaces primarios */
.btn-primary,
.btn.bg-primary,
.bg-primary {
    background-color: var(--eb-green) !important;
    border-color: var(--eb-green) !important;
    color: #fff !important;
}
.btn-primary:hover,
.btn.bg-primary:hover {
    background-color: var(--eb-green-dark) !important;
    border-color: var(--eb-green-dark) !important;
}
.btn-outline-primary {
    color: var(--eb-green-dark) !important;
    border-color: var(--eb-green) !important;
}
.btn-outline-primary:hover {
    background-color: var(--eb-green) !important;
    color: #fff !important;
}

.text-primary,
a.text-primary {
    color: var(--eb-green-dark) !important;
}

/* Sidebar Tabler */
.navbar-vertical.navbar-dark,
.navbar-vertical {
    background: #042335;
    color: #d4d4d8;
}
.navbar-vertical .navbar-brand {
    color: #fff !important;
    font-weight: 700;
    letter-spacing: -0.3px;
}
.navbar-vertical .nav-link {
    color: rgba(255, 255, 255, .72);
}
.navbar-vertical .nav-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, .04);
}
.navbar-vertical .nav-link.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(48, 155, 123, .18) 0%, rgba(48, 155, 123, 0) 100%);
    border-left: 3px solid var(--eb-green);
}
.navbar-vertical .nav-link .nav-link-icon {
    color: var(--eb-green-light);
}

/* Top bar */
.navbar.bg-white {
    border-bottom: 1px solid var(--tblr-border-color);
}

/* Cards con sombra suave */
.card {
    border: 1px solid var(--tblr-border-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--tblr-border-color);
}

/* Tabla con cabecera limpia */
.table > :not(caption) > * > * {
    padding: .75rem 1rem;
}
.table thead th {
    background: #fafbfc;
    color: var(--eb-charcoal);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--tblr-border-color);
}

/* Badges */
.badge.bg-success,
.bg-success {
    background-color: var(--tblr-success) !important;
}
.badge.bg-primary-lt {
    background: var(--eb-green-50);
    color: var(--eb-green-darker);
}

/* Page header */
.page-header {
    border-bottom: 1px solid var(--tblr-border-color);
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
}
.page-pretitle {
    color: var(--eb-green-dark);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.6px;
    font-weight: 700;
}

/* ══════════════════════════════════════════════════════════════════
   Capa de acceso (login / reset / registro) — Material 3 adaptado
   a la marca e-Baja. Paleta tomada del propio logotipo:
     "e"    → degradado #007992 → #00AF67 (teal → verde)
     "baja" → degradado #58A0AA → #4F7D98 (azul-gris)
   Los tokens --md-sys-color-* viven aquí, aislados del resto de la
   app (que sigue sobre Tabler). Si en el futuro migramos más
   pantallas a este sistema, mover a la raíz de :root y referenciar
   desde los componentes correspondientes.
   ══════════════════════════════════════════════════════════════════ */

/* Tokens Material 3 compartidos entre capa de acceso y panel. Los componentes
   los leen desde :root, de modo que .eb-auth-page y .eb-app-page comparten
   paleta, elevaciones, formas y gradiente del logo. */
:root {
    --md-sys-color-primary:                #00af67;
    --md-sys-color-on-primary:             #ffffff;
    --md-sys-color-primary-container:      #9ff2c6;
    --md-sys-color-on-primary-container:   #002112;
    --md-sys-color-secondary:              #007992;
    --md-sys-color-on-secondary:           #ffffff;
    --md-sys-color-secondary-container:    #b0ecff;
    --md-sys-color-on-secondary-container: #001f29;
    --md-sys-color-tertiary:               #4f7d98;
    --md-sys-color-on-tertiary:            #ffffff;
    --md-sys-color-tertiary-container:     #cfe5f5;
    --md-sys-color-on-tertiary-container:  #071e2b;

    --md-sys-color-surface:                #fbfdf9;
    --md-sys-color-surface-container-lowest:#ffffff;
    --md-sys-color-surface-container-low:  #f3f5f1;
    --md-sys-color-surface-container:      #edefeb;
    --md-sys-color-surface-container-high: #e7e9e5;
    --md-sys-color-surface-container-highest:#e2e4e0;

    --md-sys-color-on-surface:             #191c1a;
    --md-sys-color-on-surface-variant:     #404942;
    --md-sys-color-outline:                #707974;
    --md-sys-color-outline-variant:        #c0c9c2;

    --md-elevation-1: 0 1px 2px rgba(0,0,0,.06), 0 1px 3px 1px rgba(0,0,0,.08);
    --md-elevation-2: 0 1px 2px rgba(0,0,0,.06), 0 2px 6px 2px rgba(0,0,0,.08);
    --md-elevation-3: 0 1px 3px rgba(0,0,0,.08), 0 4px 8px 3px rgba(0,0,0,.10);

    --md-shape-sm:   8px;
    --md-shape-md:   12px;
    --md-shape-lg:   16px;
    --md-shape-xl:   28px;
    --md-shape-full: 999px;

    --md-font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', Roboto, sans-serif;

    /* Gradiente del logotipo, reutilizable */
    --eb-grad-angle: 65deg;
    --eb-grad-stops: #007992 0%, #00af67 100%;

    color-scheme: light;
}

.eb-auth-page,
.eb-auth-page *,
.eb-auth-page *::before,
.eb-auth-page *::after,
.eb-app-page,
.eb-app-page *,
.eb-app-page *::before,
.eb-app-page *::after {
    box-sizing: border-box;
}

/* El atributo [hidden] del HTML viene con `display:none` del user-agent,
   pero las clases con display: grid/flex específicos lo sobrescriben por
   especificidad. Reafirmamos con !important para que ocultar/mostrar un
   elemento desde JS (`el.hidden = true/false`) sea siempre fiable. */
[hidden] { display: none !important; }

.eb-auth-page {
    margin: 0;
    min-height: 100vh;
    font-family: var(--md-font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--md-sys-color-on-surface);
    background: var(--md-sys-color-surface);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Decisión de producto (2026-10-17): la capa de acceso va SIEMPRE en claro,
   por coherencia con el panel autenticado (Tabler claro) y porque el sello
   DGT es un gráfico institucional pensado para fondo claro. Si en el futuro
   migramos el panel a Material 3 con dark completo, restaurar aquí el
   bloque `@media (prefers-color-scheme: dark)` con los tokens oscuros. */

/* Ambient radial del fondo — mimic del gradiente del logo */
.eb-auth-page::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 70% 55% at 8% 0%,  color-mix(in srgb, #007992 12%, transparent) 0%, transparent 70%),
        radial-gradient(ellipse 55% 60% at 100% 100%, color-mix(in srgb, #00af67 11%, transparent) 0%, transparent 65%);
    pointer-events: none;
    z-index: 0;
}

/* ── Shell: logo → card → DGT → footer, columna centrada ───────── */

.eb-auth-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: grid;
    grid-template-rows: 1fr auto;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.eb-auth-shell main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-block: 32px;
}
.eb-auth-stack {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Logo e-Baja sobre la card */
.eb-brand-above {
    margin: 0 0 8px;
    display: flex;
    justify-content: center;
}
.eb-brand-above img {
    display: block;
    height: 76px;
    width: auto;
}

/* ── Card ──────────────────────────────────────────────────────── */

.eb-auth-card {
    background: var(--md-sys-color-surface-container-lowest);
    border-radius: var(--md-shape-xl);
    padding: 32px;
    box-shadow: var(--md-elevation-2);
    display: flex;
    flex-direction: column;
    gap: 20px;
    color: var(--md-sys-color-on-surface);
    width: 100%;
}
.eb-auth-headline {
    font-size: 26px;
    line-height: 1.15;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--md-sys-color-on-surface);
    text-wrap: balance;
    margin: 0 0 4px;
}
.eb-flash {
    padding: 12px 14px;
    border-radius: var(--md-shape-md);
    font-size: 13px;
    font-weight: 500;
}
.eb-flash--error   { background: #ffe5e3; color: #ba1a1a; }
.eb-flash--success { background: #d5f3e2; color: #006c4f; }

/* ── Outlined text field con leading icon + check de validación ── */

.eb-field { position: relative; }
.eb-field input {
    width: 100%;
    height: 56px;
    padding: 0 16px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-shape-md);
    background: transparent;
    color: var(--md-sys-color-on-surface);
    font: inherit;
    font-size: 16px;
    box-sizing: border-box;
    transition: border-color 160ms ease, border-width 160ms ease, padding 160ms ease;
    outline: none;
}
.eb-field.has-leading  input { padding-left: 48px; }
.eb-field.has-trailing input { padding-right: 48px; }
.eb-field input:hover { border-color: var(--md-sys-color-on-surface); }
.eb-field input:focus {
    border-color: var(--md-sys-color-primary);
    border-width: 2px;
    padding: 0 15px;
}
.eb-field.has-leading  input:focus { padding-left: 47px; }
.eb-field.has-trailing input:focus { padding-right: 47px; }

.eb-field label {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    padding: 0 4px;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 16px;
    background: var(--md-sys-color-surface-container-lowest);
    pointer-events: none;
    transition: all 160ms cubic-bezier(0.4, 0, 0.2, 1);
}
.eb-field.has-leading label { left: 44px; }
.eb-field input:focus + label,
.eb-field input:not(:placeholder-shown) + label,
.eb-field input:-webkit-autofill + label {
    top: 0;
    left: 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--md-sys-color-primary);
}
.eb-field input:not(:focus):not(:placeholder-shown) + label,
.eb-field input:-webkit-autofill:not(:focus) + label {
    color: var(--md-sys-color-on-surface-variant);
}
/* Select, textarea y fecha siempre muestran contenido: etiqueta siempre arriba. */
.eb-field select + label,
.eb-field textarea + label,
.eb-field input[type="date"] + label {
    top: 0;
    left: 12px;
    font-size: 12px;
    font-weight: 500;
}
.eb-field select:focus + label,
.eb-field textarea:focus + label,
.eb-field input[type="date"]:focus + label {
    color: var(--md-sys-color-primary);
}

/* Chrome/Edge pintan los inputs autofilled con un fondo azul propio que rompe
   la paleta Material 3. Con `box-shadow` inset de 1000px igualamos el fondo
   del campo (surface-container-lowest). `-webkit-text-fill-color` fija el
   color del texto porque autofill ignora `color`. La `transition` larga
   evita el flash azul inicial que Chrome aplica antes de aceptar el override. */
.eb-field input:-webkit-autofill,
.eb-field input:-webkit-autofill:hover,
.eb-field input:-webkit-autofill:focus,
.eb-field input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--md-sys-color-on-surface);
    -webkit-box-shadow: 0 0 0 1000px var(--md-sys-color-surface-container-lowest) inset;
    caret-color: var(--md-sys-color-on-surface);
    transition: background-color 100000s ease-in-out 0s;
}

.eb-field-icon {
    position: absolute;
    top: 50%;
    width: 20px;
    height: 20px;
    transform: translateY(-50%);
    color: var(--md-sys-color-on-surface-variant);
    pointer-events: none;
}
.eb-field-icon-leading  { left: 16px; }
.eb-field-icon-trailing { right: 14px; width: 22px; height: 22px; }

.eb-field input:focus ~ .eb-field-icon-leading { color: var(--md-sys-color-primary); }

.eb-field-check {
    color: var(--md-sys-color-primary);
    opacity: 0;
    transform: translateY(-50%) scale(0.6);
    transition: opacity 180ms ease, transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.eb-field-check circle { fill: currentColor; }
.eb-field.is-valid .eb-field-check {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

/* ── Supporting row (remember + forgot) ───────────────────────── */

.eb-supporting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-inline: 4px;
    margin-top: -4px;
}
.eb-row-remember {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--md-sys-color-on-surface);
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}
.eb-row-remember input {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--md-sys-color-on-surface-variant);
    border-radius: 3px;
    display: inline-grid;
    place-content: center;
    cursor: pointer;
    transition: all 120ms ease;
    flex-shrink: 0;
}
.eb-row-remember input:checked {
    background: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}
.eb-row-remember input:checked::after {
    content: '';
    width: 10px;
    height: 10px;
    background: var(--md-sys-color-on-primary);
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

/* ── Texto y errores de las pantallas de acceso (alta, recuperar) ── */

.eb-auth-text {
    margin: 0;
    color: var(--md-sys-color-on-surface-variant);
    line-height: 1.5;
}
.eb-auth-text strong { color: var(--md-sys-color-on-surface); }
.eb-auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.eb-field.has-error input { border-color: #ba1a1a; }
.eb-field-error {
    margin: 6px 4px 0;
    font-size: 12px;
    font-weight: 500;
    color: #ba1a1a;
}
.eb-auth-alt {
    margin: 0;
    text-align: center;
    font-size: 14px;
    color: var(--md-sys-color-on-surface-variant);
}
/* Textos legales (/condiciones, /privacidad, /encargo-tratamiento). */
.eb-legal {
    max-width: 760px;
    margin: 0 auto;
    padding-block: 32px 48px;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.eb-legal-logo img { display: block; height: 56px; width: auto; }
.eb-legal-doc {
    background: var(--md-sys-color-surface-container-lowest);
    color: var(--md-sys-color-on-surface);
    border-radius: var(--md-shape-xl);
    box-shadow: var(--md-elevation-2);
    padding: clamp(20px, 5vw, 40px);
    line-height: 1.6;
    min-width: 0;
    overflow-wrap: anywhere;
}
.eb-legal-doc h1 { font-size: 26px; line-height: 1.2; margin: 0 0 16px; text-wrap: balance; }
.eb-legal-doc h2 { font-size: 18px; margin: 28px 0 8px; }
.eb-legal-doc h3 { font-size: 15px; margin: 20px 0 6px; }
.eb-legal-doc table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; }
.eb-legal-doc th, .eb-legal-doc td { border: 1px solid var(--md-sys-color-outline-variant, #c0c9c1); padding: 6px 10px; text-align: left; vertical-align: top; }
.eb-legal-doc .legal-meta { font-size: 13px; color: var(--md-sys-color-on-surface-variant); }
.eb-legal-version { margin: 24px 0 0; font-size: 12px; color: var(--md-sys-color-on-surface-variant); }

/* Campo trampa para bots: fuera de la vista y del orden de tabulación. */
.eb-hp {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* ── Text button (links tipo "¿Olvidaste la contraseña?") ──────── */

.eb-text-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 12px;
    border: none;
    border-radius: var(--md-shape-full);
    background: transparent;
    color: var(--md-sys-color-primary);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    transition: background-color 120ms ease;
}
.eb-text-button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--md-sys-color-primary);
    opacity: 0;
    transition: opacity 120ms ease;
}
.eb-text-button:hover::before { opacity: 0.08; }
.eb-text-button:focus-visible::before { opacity: 0.12; }

/* ── CTA primario con gradiente del logo ──────────────────────── */

.eb-filled-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 56px;
    padding: 0 24px;
    border: none;
    border-radius: var(--md-shape-full);
    background: linear-gradient(var(--eb-grad-angle), var(--eb-grad-stops));
    color: #ffffff;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.1px;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 2px 8px color-mix(in srgb, #007992 25%, transparent),
                0 1px 2px rgba(0,0,0,.08);
    transition: box-shadow 180ms ease, transform 160ms ease;
}
.eb-filled-button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: #ffffff;
    opacity: 0;
    transition: opacity 120ms ease;
}
.eb-filled-button:hover {
    box-shadow: 0 4px 14px color-mix(in srgb, #007992 32%, transparent),
                0 2px 4px rgba(0,0,0,.08);
}
.eb-filled-button:hover::before { opacity: 0.08; }
.eb-filled-button:focus-visible::before { opacity: 0.12; }
.eb-filled-button:active::before { opacity: 0.16; }
.eb-filled-button:active { transform: translateY(1px); }
.eb-filled-button .arrow { transition: transform 160ms ease; }
.eb-filled-button:hover .arrow { transform: translateX(3px); }

/* ── DGT trust mark ───────────────────────────────────────────── */

.eb-dgt-mark {
    margin: 4px 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.eb-dgt-mark img {
    display: block;
    height: 44px;
    width: auto;
    max-width: 100%;
    opacity: 0.92;
}
.eb-dgt-mark figcaption {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: var(--md-sys-color-on-surface-variant);
    text-align: center;
}

/* ── Footer legal ─────────────────────────────────────────────── */

.eb-auth-shell footer {
    padding-block: 24px;
    text-align: center;
    color: var(--md-sys-color-on-surface-variant);
    font-size: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 24px;
    justify-content: center;
    max-width: 1200px;
    margin-inline: auto;
}
.eb-auth-shell footer a {
    color: var(--md-sys-color-on-surface-variant);
    text-decoration: none;
}
.eb-auth-shell footer a:hover {
    color: var(--md-sys-color-primary);
    text-decoration: underline;
}

/* ── Responsive ───────────────────────────────────────────────── */

@media (max-width: 520px) {
    .eb-auth-card { padding: 24px; }
    .eb-auth-headline { font-size: 24px; }
    .eb-brand-above img { height: 52px; }
    .eb-dgt-mark img { height: 38px; }
}

/* ══════════════════════════════════════════════════════════════════
   Panel autenticado (super admin de Proconn + user del tenant) —
   Material 3 continuando la línea de la capa de acceso. Comparte los
   tokens de :root. El layout es un shell con drawer a la izquierda +
   app bar + contenido. Rediseño del 2026-10-17 (sustituye a Tabler
   en los layouts app.php y tenant.php). Mockup aprobado:
   https://claude.ai/artifact/AvHo1sWncHEkjx23Bb9puB
   ══════════════════════════════════════════════════════════════════ */

.eb-app-page {
    margin: 0;
    min-height: 100vh;
    font-family: var(--md-font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--md-sys-color-on-surface);
    background: var(--md-sys-color-surface);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Banner de impersonación (super admin "entrando como" un tenant). */
.eb-impersonation-banner {
    background: linear-gradient(65deg, var(--md-sys-color-tertiary) 0%, #58a0aa 100%);
    color: #fff;
    padding: 12px max(16px, env(safe-area-inset-left, 0px)) 12px max(16px, env(safe-area-inset-right, 0px));
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-size: 13px;
    flex-wrap: wrap;
}
/* Aviso fijo de las empresas de pruebas (sandbox de integradores). */
.eb-pruebas-banner {
    background: #fff4d6;
    color: #6b4e00;
    padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
    font-size: 13px;
    text-align: center;
    line-height: 1.4;
}
.eb-impersonation-banner svg { flex-shrink: 0; }
.eb-impersonation-banner strong { font-weight: 600; }
.eb-impersonation-banner form { margin: 0; }
.eb-impersonation-banner button {
    background: rgba(255,255,255,.18);
    border: 1px solid rgba(255,255,255,.38);
    color: #fff;
    padding: 5px 14px;
    border-radius: var(--md-shape-full);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background 120ms ease;
}
.eb-impersonation-banner button:hover { background: rgba(255,255,255,.28); }

/* Shell = drawer + columna de contenido. */
.eb-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}
.eb-shell > .eb-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
/* Hamburger + backdrop para el drawer en móvil. Visibles solo en < 900px. */
.eb-nav-hamburger {
    display: none;
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: var(--md-sys-color-on-surface);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    transition: background 120ms ease;
    flex-shrink: 0;
}
.eb-nav-hamburger:hover { background: var(--md-sys-color-surface-container); }
.eb-nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 240ms ease;
    z-index: 100;
}

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

    /* El drawer pasa a overlay fijo que entra por la izquierda al abrir. */
    .eb-shell > .eb-nav {
        display: flex;
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: min(300px, 85vw);
        z-index: 101;
        transform: translateX(-100%);
        transition: transform 240ms cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: var(--md-elevation-3);
        padding-top: max(20px, env(safe-area-inset-top, 0px));
    }
    .eb-app-page.nav-open .eb-shell > .eb-nav { transform: translateX(0); }

    .eb-nav-hamburger { display: inline-flex; }
    .eb-nav-backdrop  { display: block; }
    .eb-app-page.nav-open .eb-nav-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    /* Evita el scroll del body cuando el drawer está abierto */
    .eb-app-page.nav-open { overflow: hidden; }
}

/* Navigation drawer. */
.eb-nav {
    background: var(--md-sys-color-surface-container-low);
    border-right: 1px solid var(--md-sys-color-outline-variant);
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.eb-nav-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 12px 24px;
    text-decoration: none;
    color: var(--md-sys-color-on-surface);
}
.eb-nav-brand img {
    display: block;
    width: 90%;
    max-width: 240px;
    height: auto;
}

.eb-nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--md-sys-color-on-surface-variant);
    padding: 16px 16px 4px;
    margin: 0;
}

.eb-nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-radius: var(--md-shape-full);
    color: var(--md-sys-color-on-surface);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: background 120ms ease, color 120ms ease;
    position: relative;
}
.eb-nav-item:hover { background: rgba(0,175,103,.07); }
.eb-nav-item.active {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    font-weight: 600;
}
.eb-nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.eb-nav-item .eb-nav-badge {
    margin-left: auto;
    background: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface-variant);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--md-shape-full);
}
.eb-nav-item.active .eb-nav-badge {
    background: rgba(0,33,18,.12);
    color: var(--md-sys-color-on-primary-container);
}

.eb-nav-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}
.eb-user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--md-shape-md);
    color: var(--md-sys-color-on-surface);
    text-decoration: none;
    transition: background 120ms ease;
    background: transparent;
    border: 0;
    width: 100%;
    text-align: left;
    font: inherit;
    cursor: pointer;
}
.eb-user-chip:hover { background: var(--md-sys-color-surface-container); }
.eb-user-chip.active { background: var(--md-sys-color-surface-container-high); }
.eb-user-chip .eb-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(var(--eb-grad-angle), var(--eb-grad-stops));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}
.eb-user-chip .eb-user-name { font-weight: 600; font-size: 13px; line-height: 1.2; display: block; }
.eb-user-chip .eb-user-mail { font-size: 11px; color: var(--md-sys-color-on-surface-variant); display: block; }

/* App bar superior. */
.eb-appbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px max(24px, env(safe-area-inset-right, 0px)) 12px max(24px, env(safe-area-inset-left, 0px));
}
.eb-appbar h1 {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0;
    color: var(--md-sys-color-on-surface);
    text-wrap: balance;
}
.eb-appbar .eb-appbar-subtitle {
    font-size: 13px;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 2px;
}
.eb-appbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Botones. */
.eb-icon-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 120ms ease;
    text-decoration: none;
}
.eb-icon-btn:hover { background: var(--md-sys-color-surface-container); }
.eb-icon-btn.sm { width: 32px; height: 32px; }

.eb-filled-btn,
a.eb-filled-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(var(--eb-grad-angle), var(--eb-grad-stops));
    color: #fff;
    border: 0;
    border-radius: var(--md-shape-full);
    font: inherit;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: box-shadow 160ms ease, transform 160ms ease;
    white-space: nowrap;
}
.eb-filled-btn:hover {
    box-shadow: 0 4px 14px color-mix(in srgb, var(--md-sys-color-secondary) 32%, transparent),
                0 2px 4px rgba(0,0,0,.08);
}
.eb-filled-btn.danger {
    background: linear-gradient(65deg, #b3261e 0%, #c62828 100%);
}

.eb-outlined-btn,
a.eb-outlined-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    background: transparent;
    color: var(--md-sys-color-primary);
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-shape-full);
    font: inherit;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: background 120ms ease;
}
.eb-outlined-btn:hover { background: rgba(0,175,103,.07); }
.eb-outlined-btn.danger {
    color: #b3261e;
    border-color: color-mix(in srgb, #b3261e 50%, transparent);
}
.eb-outlined-btn.danger:hover { background: rgba(179,38,30,.07); }

.eb-text-btn,
a.eb-text-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent;
    color: var(--md-sys-color-primary);
    border: 0;
    border-radius: var(--md-shape-full);
    font: inherit;
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
}
.eb-text-btn:hover { background: rgba(0,175,103,.08); }

/* Contenido. */
.eb-main {
    padding: 12px max(24px, env(safe-area-inset-right, 0px)) 48px max(24px, env(safe-area-inset-left, 0px));
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0;
}
@media (max-width: 600px) {
    .eb-appbar h1 { font-size: 22px; }
    .eb-appbar { padding-block: 16px 8px; }
    .eb-section-body,
    .eb-section-header { padding-left: 16px; padding-right: 16px; }
    .eb-section-header { flex-wrap: wrap; }
    .eb-section-header .eb-filled-btn,
    .eb-section-header .eb-outlined-btn,
    .eb-section-header .eb-text-btn { flex-shrink: 0; }
    /* En móvil, el botón "Guardar cambios" ocupa todo el ancho para
       ser accesible al pulgar y no quedarse arrinconado. */
    .eb-main form > div:last-child > .eb-filled-btn,
    .eb-main form > div:last-child > .eb-outlined-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Hero card (bienvenida tenant). */
.eb-hero {
    background: var(--md-sys-color-surface-container-lowest);
    border-radius: var(--md-shape-xl);
    padding: 28px;
    box-shadow: var(--md-elevation-1);
    display: flex;
    gap: 24px;
    align-items: center;
    position: relative;
    overflow: hidden;
}
.eb-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 90% at 100% 0%, color-mix(in srgb, var(--md-sys-color-primary) 10%, transparent) 0%, transparent 70%),
        radial-gradient(ellipse 50% 80% at 0% 100%, color-mix(in srgb, var(--md-sys-color-secondary) 8%, transparent) 0%, transparent 65%);
    pointer-events: none;
}
.eb-hero > * { position: relative; }
.eb-hero-avatar {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: linear-gradient(var(--eb-grad-angle), var(--eb-grad-stops));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 600;
    flex-shrink: 0;
}
.eb-hero-text { flex: 1; min-width: 0; }
.eb-hero-text h2 { margin: 0 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.eb-hero-text p { margin: 0; color: var(--md-sys-color-on-surface-variant); }
@media (max-width: 600px) {
    .eb-hero { padding: 20px; gap: 16px; }
    .eb-hero-avatar { width: 52px; height: 52px; font-size: 22px; }
    .eb-hero-text h2 { font-size: 18px; }
}

/* Métricas (grid tonal). */
.eb-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.eb-metric {
    background: var(--md-sys-color-surface-container-low);
    border-radius: var(--md-shape-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.eb-metric .eb-metric-label {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--md-sys-color-on-surface-variant);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.eb-metric .eb-metric-label svg { width: 14px; height: 14px; }
.eb-metric .eb-metric-value {
    font-size: 36px;
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--md-sys-color-on-surface);
}
.eb-metric .eb-metric-sub {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
}
.eb-metric.featured {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}
.eb-metric.featured .eb-metric-label,
.eb-metric.featured .eb-metric-sub { color: color-mix(in srgb, var(--md-sys-color-on-primary-container) 75%, transparent); }
.eb-metric.featured .eb-metric-value { color: var(--md-sys-color-on-primary-container); }

/* Section card con header + body/tabla. */
.eb-section {
    background: var(--md-sys-color-surface-container-lowest);
    border-radius: var(--md-shape-xl);
    box-shadow: var(--md-elevation-1);
    overflow: hidden;
}
.eb-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
}
.eb-section-header h2 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0;
}
.eb-section-header .eb-section-sub {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 2px;
}
.eb-section-body { padding: 20px 24px 24px; }
.eb-section.danger { border: 1px solid color-mix(in srgb, #b3261e 25%, transparent); }
.eb-section.danger .eb-section-header h2 { color: #b3261e; }

/* Tabla. */
.eb-table-wrap { overflow-x: auto; border-radius: var(--md-shape-md); }
.eb-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 580px;
}
.eb-table th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--md-sys-color-on-surface-variant);
    padding: 12px 20px;
    text-align: left;
    background: var(--md-sys-color-surface-container);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    position: sticky;
    top: 0;
    z-index: 1;
    white-space: nowrap;
}
.eb-table th:first-child { padding-left: 24px; }
.eb-table th:last-child  { padding-right: 24px; text-align: right; }
.eb-table td {
    padding: 14px 20px;
    font-size: 14px;
    color: var(--md-sys-color-on-surface);
    vertical-align: middle;
    border-bottom: 1px solid color-mix(in srgb, var(--md-sys-color-outline-variant) 60%, transparent);
}
.eb-table td:first-child { padding-left: 24px; }
.eb-table td:last-child  { padding-right: 24px; text-align: right; }
.eb-table tbody tr:nth-child(even) td  { background: color-mix(in srgb, var(--md-sys-color-surface-container) 45%, transparent); }
.eb-table tbody tr:hover td            { background: color-mix(in srgb, var(--md-sys-color-primary) 7%, var(--md-sys-color-surface)); }
.eb-table tbody tr:last-child td       { border-bottom: 0; }
.eb-table td.num                       { font-variant-numeric: tabular-nums; color: var(--md-sys-color-on-surface-variant); }
.eb-table td.num-id                    { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--md-sys-color-on-surface-variant); }
.eb-table td.hint                      { color: var(--md-sys-color-on-surface-variant); font-size: 12px; }

/* Fila clickeable: añade <a class="row-link" href="…"> dentro de cualquier
   <td> y toda la fila (o la card, en móvil) actúa como enlace a la ficha.
   Las acciones icónicas de la última columna quedan sobre el overlay con
   z-index mayor para seguir siendo clicables de forma independiente. */
.eb-table tr                         { position: relative; }
.eb-table .row-link {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    text-indent: -9999px;
    border-radius: inherit;
}
.eb-table .row-link:focus-visible {
    outline: 2px solid var(--md-sys-color-primary);
    outline-offset: -2px;
    border-radius: 6px;
}
.eb-table tr:has(.row-link)          { cursor: pointer; }
.eb-table .eb-row-actions,
.eb-table .eb-row-actions *          { position: relative; z-index: 2; }

/* Celda compuesta "tenant" con avatar + nombre + slug */
.eb-tenant-cell        { display: flex; align-items: center; gap: 12px; min-width: 0; }
.eb-tenant-cell-info   { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.eb-tenant-cell-name   { font-weight: 600; color: var(--md-sys-color-on-surface); font-size: 14px; letter-spacing: -0.01em; }
.eb-tenant-cell-slug   {
    font-family: ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, monospace;
    font-size: 11px;
    color: var(--md-sys-color-on-surface-variant);
}
.eb-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600; letter-spacing: 0.02em;
    background: color-mix(in srgb, var(--md-sys-color-primary) 15%, var(--md-sys-color-surface));
    color: var(--md-sys-color-primary);
    flex-shrink: 0;
}

/* ─── Tablas en móvil: cada fila se re-renderiza como card apilada ─────
   Para que una celda muestre su etiqueta en móvil, añade data-label="…"
   al <td>. Las celdas sin data-label (p.ej. la celda compuesta "tenant"
   o la columna de acciones) se renderizan sin etiqueta, a ancho completo.
   Para ocultar una celda en móvil, añade clase "hide-mobile" al <td> y
   al <th> correspondiente. */
@media (max-width: 720px) {
    .eb-table-wrap { overflow-x: visible; border-radius: 0; padding: 12px 24px 20px; }
    .eb-table      { min-width: 0; display: block; }
    .eb-table thead { display: none; }
    .eb-table tbody, .eb-table tr { display: block; width: 100%; }
    .eb-table tr {
        background: transparent;
        border: 0;
        border-top: 1px solid var(--md-sys-color-outline-variant);
        border-radius: 0;
        padding: 16px 0;
        margin: 0;
    }
    .eb-table tr:first-child { border-top: 0; padding-top: 4px; }
    .eb-table tr:last-child  { padding-bottom: 4px; }
    .eb-table tbody tr:hover td,
    .eb-table tbody tr:nth-child(even) td { background: transparent; }
    .eb-table td {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        gap: 10px;
        padding: 6px 0;
        border: 0;
        text-align: left;
    }
    .eb-table td:first-child,
    .eb-table td:last-child { padding-left: 0; padding-right: 0; }
    .eb-table td:last-child { justify-content: flex-end; margin-top: 4px; }
    .eb-table td[data-label]::before {
        content: attr(data-label) ":";
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: .06em;
        color: var(--md-sys-color-on-surface-variant);
        font-weight: 600;
        flex-shrink: 0;
        min-width: 80px;
    }
    /* La celda "tenant" (avatar+nombre+slug) ocupa el ancho completo arriba */
    .eb-table td.cell-primary { padding-top: 0; padding-bottom: 10px; }
    .eb-table .hide-mobile { display: none; }
}
.eb-table td code,
.eb-mono {
    font-family: ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, monospace;
    font-size: 12px;
    background: var(--md-sys-color-surface-container);
    padding: 2px 8px;
    border-radius: var(--md-shape-sm);
    color: var(--md-sys-color-on-surface-variant);
}

/* Chips de estado. */
.eb-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--md-shape-full);
    font-size: 12px;
    font-weight: 500;
}
.eb-chip-dot { width: 6px; height: 6px; border-radius: 50%; }
.eb-chip.active   { background: #cff4c6; color: #0b4019; }
.eb-chip.active   .eb-chip-dot { background: #138847; }
.eb-chip.demo     { background: #fff2bf; color: #4a3800; }
.eb-chip.demo     .eb-chip-dot { background: #c69100; }
.eb-chip.inactive { background: #ffd9d8; color: #410002; }
.eb-chip.inactive .eb-chip-dot { background: #b3261e; }

.eb-kind-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--md-shape-full);
    background: rgba(79,125,152,.14);
    color: #1e3a4f;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.eb-row-actions { display: inline-flex; gap: 4px; }

/* Flashes dentro del panel (reutilizan los tokens). */
.eb-flash {
    padding: 12px 16px;
    border-radius: var(--md-shape-md);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.eb-flash--error   { background: #ffd9d8; color: #410002; }
.eb-flash--success { background: #cff4c6; color: #0b4019; }
.eb-flash--info    { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }

/* Grid de módulos (vista tenant home: "Qué puedes hacer"). */
.eb-module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}
.eb-module {
    background: var(--md-sys-color-surface-container-lowest);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-shape-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 160ms ease, border-color 160ms ease, transform 160ms ease;
}
.eb-module:hover {
    box-shadow: var(--md-elevation-2);
    border-color: var(--md-sys-color-outline);
    transform: translateY(-1px);
}
.eb-module-icon {
    width: 44px; height: 44px;
    border-radius: var(--md-shape-md);
    background: color-mix(in srgb, var(--md-sys-color-primary) 14%, transparent);
    color: var(--md-sys-color-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.eb-module.secondary .eb-module-icon { background: color-mix(in srgb, var(--md-sys-color-secondary) 14%, transparent); color: var(--md-sys-color-secondary); }
.eb-module.tertiary  .eb-module-icon { background: color-mix(in srgb, var(--md-sys-color-tertiary)  14%, transparent); color: var(--md-sys-color-tertiary); }
.eb-module h3 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.eb-module p  { margin: 0; font-size: 13px; color: var(--md-sys-color-on-surface-variant); }
.eb-module .eb-soon {
    display: inline-flex;
    align-items: center;
    margin-top: auto;
    padding: 3px 10px;
    border-radius: var(--md-shape-full);
    background: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface-variant);
    font-size: 11px;
    font-weight: 500;
    align-self: flex-start;
}

/* Section título simple (sin card). */
.eb-section-title {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--md-sys-color-on-surface-variant);
}

/* Outlined text field (reutiliza .eb-field del login para los formularios
   del panel). Añadimos un pequeño wrapper con label-column + help text. */
.eb-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.eb-form-help {
    font-size: 12px;
    color: var(--md-sys-color-on-surface-variant);
    padding: 2px 4px 0;
}
.eb-form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    margin-top: 8px;
    padding-top: 20px;
}

.eb-field textarea,
.eb-field select {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-shape-md);
    background: var(--md-sys-color-surface-container-lowest);
    color: var(--md-sys-color-on-surface);
    font: inherit;
    font-size: 15px;
    transition: border-color 160ms ease;
    outline: none;
    box-sizing: border-box;
}
.eb-field textarea:focus,
.eb-field select:focus {
    border-color: var(--md-sys-color-primary);
    border-width: 2px;
    padding: 13px 15px;
}
/* El select mide lo mismo que un input (56px) para que alineen en la misma fila. */
.eb-field select { height: 56px; padding-top: 0; padding-bottom: 0; }
.eb-field select:focus { padding-top: 0; padding-bottom: 0; }
.eb-field.row-check {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 4px;
    flex-wrap: nowrap;
}
.eb-field.row-check input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px !important;
    height: 20px !important;
    min-width: 20px;
    padding: 0;
    border: 2px solid var(--md-sys-color-on-surface-variant);
    border-radius: 4px;
    background: var(--md-sys-color-surface-container-lowest);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 120ms ease, border-color 120ms ease;
    flex-shrink: 0;
    position: relative;
}
.eb-field.row-check input[type="checkbox"]:checked {
    background: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}
.eb-field.row-check input[type="checkbox"]:checked::after {
    content: '';
    width: 10px; height: 10px;
    background: var(--md-sys-color-on-primary);
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
.eb-field.row-check label { font-size: 14px; color: var(--md-sys-color-on-surface); cursor: pointer; }

/* Switch M3 (thumb que se desliza por una pista). Reemplaza al checkbox
   cuadrado tradicional cuando queremos un control de "sí/no" vistoso.
   El input nativo queda oculto para accesibilidad pero fuera del flujo. */
.eb-switch {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    padding: 8px 4px;
    user-select: none;
    flex-wrap: wrap;
    max-width: 100%;
}
.eb-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px; height: 1px;
    margin: 0;
}
.eb-switch-track {
    position: relative;
    width: 52px;
    height: 32px;
    background: var(--md-sys-color-surface-container-highest);
    border: 2px solid var(--md-sys-color-outline);
    border-radius: var(--md-shape-full);
    flex-shrink: 0;
    transition: background 180ms ease, border-color 180ms ease;
}
.eb-switch-thumb {
    position: absolute;
    top: 50%;
    left: 4px;
    width: 16px;
    height: 16px;
    background: var(--md-sys-color-outline);
    border-radius: 50%;
    transform: translateY(-50%);
    transition: left 220ms cubic-bezier(0.4, 0, 0.2, 1),
                width 220ms cubic-bezier(0.4, 0, 0.2, 1),
                height 220ms cubic-bezier(0.4, 0, 0.2, 1),
                background 180ms ease;
}
.eb-switch input:checked + .eb-switch-track {
    background: var(--md-sys-color-primary);
    border-color: var(--md-sys-color-primary);
}
.eb-switch input:checked + .eb-switch-track .eb-switch-thumb {
    width: 22px;
    height: 22px;
    left: 24px;
    background: var(--md-sys-color-on-primary);
}
.eb-switch input:focus-visible + .eb-switch-track {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-sys-color-primary) 25%, transparent);
}
.eb-switch-label {
    font-size: 14px;
    color: var(--md-sys-color-on-surface);
    line-height: 1.3;
    min-width: 0;
    flex: 1 1 auto;
}

/* Utilidades de grid responsive para formularios. Colapsan a 1 columna en
   pantallas estrechas para que los labels flotantes no se recorten. */
.eb-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
.eb-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}
.eb-grid-cp {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 12px;
}
.eb-grid-prefijo-sufijo {
    display: grid;
    grid-template-columns: 1fr 110px 1fr;
    gap: 12px;
    align-items: start;
}
@media (max-width: 760px) {
    .eb-grid-2,
    .eb-grid-3,
    .eb-grid-cp,
    .eb-grid-prefijo-sufijo { grid-template-columns: 1fr; }
}

/* Modal (dialog nativo con showModal). */
.eb-dialog {
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    padding: 0;
    border: 0;
    border-radius: var(--md-shape-xl);
    background: var(--md-sys-color-surface-container-lowest);
    color: var(--md-sys-color-on-surface);
    box-shadow: var(--md-elevation-2);
}
.eb-dialog[open] { display: flex; flex-direction: column; }
.eb-dialog::backdrop { background: rgba(0, 0, 0, .4); }
.eb-dialog [hidden] { display: none !important; }
.eb-dialog-head { display: flex; align-items: center; gap: 12px; padding: 20px 16px 8px 24px; }
.eb-dialog-head h2 { flex: 1; margin: 0; font-size: 18px; font-weight: 600; }
.eb-dialog-close {
    display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
    border: 0; border-radius: 50%; background: transparent; color: var(--md-sys-color-on-surface-variant); cursor: pointer;
}
.eb-dialog-close:hover { background: var(--md-sys-color-surface-container); }
.eb-dialog-close svg { width: 20px; height: 20px; }
.eb-dialog-body { padding: 8px 24px 16px; overflow: auto; }
.eb-dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 24px 20px; }

/* Esquema de un documento del vehículo (partials/esquema_documento): casillas con su
   código, barras grises en lugar de datos y en verde las casillas que interesan. */
.eb-esquema {
    --eb-esq-linea: color-mix(in srgb, var(--md-sys-color-secondary) 22%, transparent);
    display: flex; flex-direction: column; gap: 8px; padding: 12px; font-size: 12px;
    border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--md-shape-md);
    background: color-mix(in srgb, #d8f3e4 55%, var(--md-sys-color-surface-container-lowest));
}
.eb-esquema-cols { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 8px; align-items: start; }
.eb-esquema-col, .eb-esquema-caja {
    min-width: 0; border: 1px solid color-mix(in srgb, var(--md-sys-color-secondary) 35%, transparent);
    border-radius: 4px; background: var(--md-sys-color-surface-container-lowest);
}
.eb-esquema-col { display: flex; flex-direction: column; }
.eb-esquema-fila {
    display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; gap: 8px; min-height: 22px;
    padding: 1px 8px 1px 0; color: var(--md-sys-color-on-surface-variant); border-bottom: 1px solid var(--eb-esq-linea);
}
.eb-esquema-fila:last-child { border-bottom: 0; }
.eb-esquema-fila b {
    align-self: stretch; display: grid; place-items: center; font-weight: 500; font-size: 11px;
    color: var(--md-sys-color-secondary); border-right: 1px solid var(--eb-esq-linea);
}
.eb-esquema.sin-codigos .eb-esquema-fila { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
.eb-esquema.sin-codigos .eb-esquema-fila b { place-items: center start; padding-left: 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.eb-esquema-valor { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eb-esquema-barra { display: block; height: 8px; border-radius: 4px; background: var(--md-sys-color-outline-variant); opacity: .6; }
.eb-esquema-obs {
    padding: 6px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--md-sys-color-on-surface-variant); border-top: 1px solid color-mix(in srgb, var(--md-sys-color-secondary) 35%, transparent);
}
.eb-esquema-cajas { display: flex; gap: 8px; }
.eb-esquema-caja { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 5px 8px 7px; }
.eb-esquema-caja small { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--md-sys-color-secondary); }
.eb-esquema .clave { background: color-mix(in srgb, var(--md-sys-color-primary) 12%, var(--md-sys-color-surface-container-lowest)); color: var(--md-sys-color-on-surface); }
.eb-esquema .clave b, .eb-esquema .clave small { color: var(--md-sys-color-primary); }
.eb-esquema-marco { width: 100%; overflow: hidden; }
.eb-esquema-marco > .eb-esquema { box-sizing: border-box; transform-origin: top left; }
.eb-esquema-leyenda { display: none; margin: 0; padding: 0; list-style: none; font-size: 14px; }
.eb-esquema-leyenda li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--md-sys-color-outline-variant); }
.eb-esquema-leyenda li:last-child { border-bottom: 0; }
.eb-esquema-leyenda b { flex: none; min-width: 64px; color: var(--md-sys-color-primary); font-weight: 600; }
@media (max-width: 600px) { .eb-esquema-leyenda { display: block; } }

/* ── Ayuda de campo: icono «?» al final del campo + tooltip (views/partials/ayuda.php) ── */
.eb-ayuda-btn {
    position: absolute;
    top: 8px;
    right: 6px;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: var(--md-shape-full);
    background: transparent;
    color: var(--md-sys-color-on-surface-variant);
    cursor: pointer;
    transition: background-color 160ms ease, color 160ms ease;
}
.eb-ayuda-btn svg { width: 22px; height: 22px; }
.eb-ayuda-btn:hover { background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-primary); }
.eb-ayuda-btn:focus-visible { outline: 2px solid var(--md-sys-color-primary); outline-offset: 1px; }
.eb-ayuda-btn:has(+ .eb-ayuda:popover-open) { color: var(--md-sys-color-primary); }
.eb-field.has-trailing select { padding-right: 48px; }
.eb-field.has-trailing textarea { padding-right: 48px; }

.eb-ayuda {
    position: fixed;
    inset: auto;
    margin: 0;
    width: min(340px, calc(100vw - 32px));
    padding: 14px 16px;
    border: 1px solid var(--md-sys-color-outline-variant, var(--md-sys-color-outline));
    border-radius: var(--md-shape-md);
    background: var(--md-sys-color-surface-container-lowest);
    color: var(--md-sys-color-on-surface);
    box-shadow: var(--md-elevation-3);
    font-size: 14px;
    line-height: 1.5;
}
.eb-ayuda strong { display: block; margin-bottom: 4px; color: var(--md-sys-color-primary); font-size: 14px; }
.eb-ayuda p { margin: 0; }
.eb-ayuda:popover-open { animation: eb-ayuda-in 140ms ease-out; }
@keyframes eb-ayuda-in { from { opacity: 0; transform: translateY(-4px); } }
.eb-ayuda a { display: inline-block; margin-top: 8px; font-weight: 600; color: var(--md-sys-color-primary); }
