/*
THESIS: Un mostrador, no un panel de control. Cada pantalla responde primero "¿quién es y en qué estado está?"
  y deja la acción principal a un toque; rechaza el admin genérico azul de tarjetas iguales.
OWN-WORLD: Superficie clara de trabajo (piso de gimnasio bajo luz blanca) con barra carbón #1E1F24;
  el verde neón Energym #4BFF00 solo marca la acción que cobra o confirma y el estado ACTIVO;
  cian Energym oscurecido #00728A para enlaces y foco. Montserrat para títulos de marca, Barlow
  para datos y tablas con números tabulares. Bordes 1px cálidos, radios 10/14, sombras suaves con offset.
STORY: Recepción busca al socio, ve su estado y saldo de inmediato, elige qué cobra, ve el total
  (y su equivalente en Bs.) y confirma. El dueño revisa tablas densas y legibles.
FIRST VIEWPORT (registrar pago): buscador grande arriba; al elegir socio, a la izquierda su ficha
  con estado y saldo, a la derecha el cobro en tres pasos y un resumen fijo con el botón neón.
FORM: identidad Energym fijada por el cliente (sin ronda de conceptos: dirección fijada por el brief).
FINISH: unreviewed and undocumented is unfinished; this build ends with the finish review, the verdict, DESIGN.md, and every shipping raster carrying its provenance
*/

:root {
    --em-ink: #18181C;
    --em-ink-2: #3D3D44;
    --em-ink-3: #62626A;
    --em-bg: #F1F1EE;
    --em-surface: #FFFFFF;
    --em-surface-2: #F7F7F5;
    --em-line: #E1E1DD;
    --em-line-strong: #CACAC5;

    --em-chrome: #1E1F24;
    --em-chrome-2: #2A2B31;
    --em-chrome-line: #3A3B42;
    --em-chrome-ink: #F4F4F1;
    --em-chrome-ink-2: #B4B5BC;

    --em-volt: #4BFF00;
    --em-volt-hover: #63FF26;
    --em-volt-ink: #0E2600;
    --em-volt-deep: #236F00;
    --em-volt-wash: #EFFFE6;

    --em-cyan: #00E6FF;
    --em-cyan-deep: #00728A;
    --em-cyan-wash: #E6FBFE;

    --em-amber-ink: #8A4B00;
    --em-amber-wash: #FFF3DC;
    --em-red: #C2261C;
    --em-red-ink: #A3201A;
    --em-red-wash: #FDECEA;

    --em-radius-sm: 8px;
    --em-radius: 10px;
    --em-radius-lg: 14px;
    --em-shadow-sm: 0 1px 2px rgba(24, 24, 28, 0.06);
    --em-shadow: 0 1px 2px rgba(24, 24, 28, 0.05), 0 10px 24px -14px rgba(24, 24, 28, 0.22);
    --em-shadow-lg: 0 2px 4px rgba(24, 24, 28, 0.06), 0 24px 48px -20px rgba(24, 24, 28, 0.32);
    --em-ring: 0 0 0 3px rgba(0, 230, 255, 0.42);

    --em-font-ui: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --em-font-brand: "Montserrat", "Barlow", system-ui, sans-serif;
    --em-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }

/* El atributo hidden siempre gana sobre display de los componentes */
[hidden] { display: none !important; }

body {
    background: var(--em-bg);
    color: var(--em-ink);
    font-family: var(--em-font-ui);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, .em-brand-font {
    font-family: var(--em-font-brand);
    letter-spacing: -0.01em;
    text-wrap: balance;
}

::selection { background: var(--em-volt); color: var(--em-volt-ink); }

:focus-visible {
    outline: 2px solid var(--em-cyan-deep);
    outline-offset: 2px;
}

input, select, textarea, button { font-family: inherit; }
input, textarea { caret-color: var(--em-cyan-deep); }

* { scrollbar-width: thin; scrollbar-color: var(--em-line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--em-line-strong); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

a { text-underline-offset: 3px; }

.em-num, .em-money, table td, table th { font-variant-numeric: tabular-nums; }

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

/* ---------- Barra de navegación ---------- */
.energym-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--em-chrome);
    color: var(--em-chrome-ink);
    box-shadow: 0 1px 0 var(--em-chrome-line), 0 8px 20px -14px rgba(0, 0, 0, 0.6);
}

.energym-nav { max-width: 1320px; margin: 0 auto; padding: 0 1rem; }

.energym-nav-row {
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.energym-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--em-chrome-ink);
    text-decoration: none;
    margin-right: 0.5rem;
    flex: 0 0 auto;
}

.energym-brand img { width: 34px; height: 34px; object-fit: contain; }

.energym-brand span {
    font-family: var(--em-font-brand);
    font-weight: 800;
    font-size: 1.02rem;
    letter-spacing: 0.04em;
}

.energym-brand span b { color: var(--em-volt); font-weight: 800; }

.energym-desktop-menu { display: none; align-items: center; gap: 0.15rem; flex: 1 1 auto; }

.energym-link,
.energym-menu-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0 0.8rem;
    border: 0;
    border-radius: var(--em-radius-sm);
    background: transparent;
    color: var(--em-chrome-ink-2);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.16s var(--em-ease), color 0.16s var(--em-ease);
}

.energym-link:hover,
.energym-menu-button:hover,
.energym-menu-button[aria-expanded="true"] {
    background: var(--em-chrome-2);
    color: var(--em-chrome-ink);
}

.energym-link.is-active,
.energym-dropdown.is-active > .energym-menu-button { color: var(--em-chrome-ink); }

.energym-link.is-active::after,
.energym-dropdown.is-active > .energym-menu-button::after {
    content: "";
    position: absolute;
    left: 0.8rem;
    right: 0.8rem;
    bottom: 4px;
    height: 2px;
    border-radius: 2px;
    background: var(--em-volt);
}

.energym-link svg, .energym-menu-button svg, .energym-mobile-toggle svg { width: 18px; height: 18px; flex: 0 0 auto; }
.energym-chevron { width: 16px !important; height: 16px !important; transition: transform 0.16s var(--em-ease); }
.energym-menu-button[aria-expanded="true"] .energym-chevron { transform: rotate(180deg); }

.energym-dropdown { position: relative; }

.energym-dropdown-panel {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    min-width: 240px;
    padding: 0.4rem;
    border: 1px solid var(--em-line);
    border-radius: var(--em-radius-lg);
    background: var(--em-surface);
    box-shadow: var(--em-shadow-lg);
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.14s var(--em-ease), transform 0.14s var(--em-ease);
}

.energym-dropdown.is-open .energym-dropdown-panel { opacity: 1; transform: translateY(0); pointer-events: auto; }

.energym-dropdown-panel a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 42px;
    padding: 0 0.75rem;
    border-radius: var(--em-radius-sm);
    color: var(--em-ink-2);
    font-weight: 600;
    text-decoration: none;
}

.energym-dropdown-panel a:hover { background: var(--em-surface-2); color: var(--em-ink); }
.energym-dropdown-panel a.is-active { background: var(--em-volt-wash); color: var(--em-volt-deep); }

.energym-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }

.energym-user {
    display: none;
    align-items: center;
    gap: 0.55rem;
    padding: 0.25rem 0.75rem 0.25rem 0.3rem;
    border-radius: 999px;
    background: var(--em-chrome-2);
    color: var(--em-chrome-ink);
    font-weight: 600;
    font-size: 0.92rem;
    max-width: 200px;
}

.energym-user span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.energym-avatar {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background: var(--em-volt);
    color: var(--em-volt-ink);
    font-family: var(--em-font-brand);
    font-weight: 800;
    font-size: 0.85rem;
    flex: 0 0 auto;
}

.energym-logout,
.energym-mobile-toggle {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--em-chrome-line);
    border-radius: var(--em-radius);
    background: transparent;
    color: var(--em-chrome-ink-2);
    cursor: pointer;
    transition: background-color 0.16s var(--em-ease), color 0.16s var(--em-ease), border-color 0.16s var(--em-ease);
}

.energym-logout:hover { background: var(--em-red); border-color: var(--em-red); color: #fff; }
.energym-mobile-toggle:hover, .energym-mobile-toggle[aria-expanded="true"] { background: var(--em-chrome-2); color: var(--em-chrome-ink); }
.energym-logout svg { width: 19px; height: 19px; }

.energym-mobile-menu {
    display: none;
    padding: 0.5rem 0 1rem;
    border-top: 1px solid var(--em-chrome-line);
}

.energym-mobile-menu.is-open { display: grid; gap: 0.15rem; }

.energym-mobile-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; padding: 0.5rem 0 0.75rem; }

.energym-mobile-quick a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 48px;
    border-radius: var(--em-radius);
    background: var(--em-chrome-2);
    color: var(--em-chrome-ink);
    font-weight: 700;
    text-decoration: none;
}

.energym-mobile-quick a.is-primary { background: var(--em-volt); color: var(--em-volt-ink); }
.energym-mobile-quick svg { width: 18px; height: 18px; }

.energym-mobile-link,
.energym-mobile-group .energym-menu-button,
.energym-mobile-submenu a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 46px;
    padding: 0 0.75rem;
    border: 0;
    border-radius: var(--em-radius-sm);
    background: transparent;
    color: var(--em-chrome-ink);
    font: inherit;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.energym-mobile-link:hover, .energym-mobile-submenu a:hover { background: var(--em-chrome-2); }
.energym-mobile-link.is-active, .energym-mobile-submenu a.is-active { color: var(--em-volt); }

.energym-mobile-submenu { display: none; padding-left: 0.75rem; }
.energym-mobile-submenu a { color: var(--em-chrome-ink-2); font-weight: 500; }
.energym-mobile-group.is-open .energym-mobile-submenu { display: grid; }
.energym-mobile-group.is-open .energym-chevron { transform: rotate(180deg); }

.energym-mobile-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid var(--em-chrome-line);
    color: var(--em-chrome-ink-2);
    font-weight: 600;
}

@media (min-width: 1024px) {
    .energym-desktop-menu { display: flex; }
    .energym-mobile-toggle { display: none; }
    .energym-user { display: inline-flex; }
    .energym-mobile-menu, .energym-mobile-menu.is-open { display: none; }
}

/* ---------- Estructura de página ---------- */
.em-page { width: 100%; max-width: 1320px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.em-page--narrow { max-width: 1100px; }

.em-page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
    margin-bottom: 1.25rem;
}

.em-page-title {
    font-family: var(--em-font-brand);
    font-size: clamp(1.45rem, 1.1rem + 1.2vw, 1.9rem);
    font-weight: 800;
    line-height: 1.15;
    color: var(--em-ink);
    margin: 0;
}

.em-page-sub { margin: 0.3rem 0 0; color: var(--em-ink-3); font-size: 1rem; max-width: 60ch; }

.em-panel {
    background: var(--em-surface);
    border: 1px solid var(--em-line);
    border-radius: var(--em-radius-lg);
    box-shadow: var(--em-shadow);
}

.em-panel-pad { padding: 1.25rem; }
@media (min-width: 768px) { .em-panel-pad { padding: 1.5rem; } }

.em-section-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 1rem;
    font-family: var(--em-font-brand);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--em-ink);
}

.em-step {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: var(--em-chrome);
    color: var(--em-volt);
    font-family: var(--em-font-ui);
    font-size: 0.85rem;
    font-weight: 700;
    flex: 0 0 auto;
}

.em-divider { height: 1px; background: var(--em-line); border: 0; margin: 1.5rem 0; }

.em-footer {
    margin-top: auto;
    padding: 1.1rem 1rem;
    background: var(--em-chrome);
    color: var(--em-chrome-ink-2);
    text-align: center;
    font-size: 0.9rem;
}

/* ---------- Formularios ---------- */
.em-field { display: grid; gap: 0.4rem; }
.em-field + .em-field { margin-top: 0; }

.em-label { font-weight: 600; font-size: 0.95rem; color: var(--em-ink-2); }
.em-label .em-optional { font-weight: 500; color: var(--em-ink-3); }

.em-hint { font-size: 0.88rem; color: var(--em-ink-3); }
.em-error-text { font-size: 0.88rem; color: var(--em-red-ink); font-weight: 600; }

.em-input,
.em-select,
.em-textarea {
    width: 100%;
    min-height: 46px;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--em-line-strong);
    border-radius: var(--em-radius);
    background: var(--em-surface);
    color: var(--em-ink);
    font-size: 1rem;
    line-height: 1.35;
    transition: border-color 0.14s var(--em-ease), box-shadow 0.14s var(--em-ease), background-color 0.14s var(--em-ease);
}

.em-textarea { min-height: 84px; resize: vertical; }

.em-select {
    appearance: none;
    padding-right: 2.5rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2362626A'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    background-size: 18px;
}

.em-input::placeholder, .em-textarea::placeholder { color: #8A8A91; }

.em-input:hover, .em-select:hover, .em-textarea:hover { border-color: #A9A9A4; }

.em-input:focus, .em-select:focus, .em-textarea:focus {
    outline: none;
    border-color: var(--em-cyan-deep);
    box-shadow: var(--em-ring);
}

.em-input[aria-invalid="true"], .em-select[aria-invalid="true"] { border-color: var(--em-red); }
.em-input[readonly] { background: var(--em-surface-2); }

.em-input-icon { position: relative; }
.em-input-icon > svg {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    width: 20px;
    height: 20px;
    transform: translateY(-50%);
    color: var(--em-ink-3);
    pointer-events: none;
}
.em-input-icon > .em-input { padding-left: 2.6rem; }

.em-input-prefix { position: relative; }
.em-input-prefix > span {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--em-ink-3);
    font-weight: 600;
    pointer-events: none;
}
.em-input-prefix > .em-input { padding-left: 1.85rem; }

.em-input--xl { min-height: 56px; font-size: 1.1rem; }
.em-input--money { font-size: 1.35rem; font-weight: 700; min-height: 56px; }

.em-grid-2 { display: grid; gap: 1rem; }
@media (min-width: 640px) { .em-grid-2 { grid-template-columns: 1fr 1fr; } }

/* Opciones en mosaico (tipo de pago, método) */
.em-seg { display: grid; gap: 0.5rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .em-seg--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 640px) { .em-seg--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.em-seg input { position: absolute; opacity: 0; pointer-events: none; }

.em-seg label {
    position: relative;
    display: grid;
    gap: 0.15rem;
    align-content: center;
    min-height: 64px;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--em-line-strong);
    border-radius: var(--em-radius);
    background: var(--em-surface);
    cursor: pointer;
    transition: border-color 0.14s var(--em-ease), background-color 0.14s var(--em-ease), box-shadow 0.14s var(--em-ease);
}

.em-seg label strong { font-weight: 700; color: var(--em-ink); font-size: 1rem; }
.em-seg label small { font-size: 0.85rem; color: var(--em-ink-3); line-height: 1.25; }
.em-seg label:hover { border-color: #A9A9A4; background: var(--em-surface-2); }

.em-seg input:checked + label {
    border-color: var(--em-chrome);
    background: var(--em-chrome);
    box-shadow: inset 0 -3px 0 var(--em-volt);
}
.em-seg input:checked + label strong { color: #fff; }
.em-seg input:checked + label small { color: var(--em-chrome-ink-2); }
.em-seg input:focus-visible + label { box-shadow: var(--em-ring); }
.em-seg input:disabled + label { opacity: 0.45; cursor: not-allowed; }

.em-seg--compact label { min-height: 48px; text-align: center; justify-content: center; }

/* Zona para subir archivos */
.em-drop {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-height: 64px;
    padding: 0.75rem 1rem;
    border: 1px dashed var(--em-line-strong);
    border-radius: var(--em-radius);
    background: var(--em-surface-2);
    color: var(--em-ink-2);
    cursor: pointer;
    transition: border-color 0.14s var(--em-ease), background-color 0.14s var(--em-ease);
}
.em-drop:hover, .em-drop.is-over { border-color: var(--em-cyan-deep); background: var(--em-cyan-wash); }
.em-drop svg { width: 24px; height: 24px; color: var(--em-cyan-deep); flex: 0 0 auto; }
.em-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.em-drop strong { display: block; font-weight: 700; color: var(--em-ink); }
.em-drop span { font-size: 0.88rem; color: var(--em-ink-3); }

/* ---------- Botones ---------- */
.em-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 46px;
    padding: 0 1.15rem;
    border: 1px solid transparent;
    border-radius: var(--em-radius);
    font: inherit;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.14s var(--em-ease), border-color 0.14s var(--em-ease), color 0.14s var(--em-ease), box-shadow 0.14s var(--em-ease), transform 0.1s var(--em-ease);
}

.em-btn:active:not(:disabled) { transform: translateY(1px); }
.em-btn svg { width: 19px; height: 19px; flex: 0 0 auto; }
.em-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.em-btn-primary { background: var(--em-volt); color: var(--em-volt-ink); box-shadow: 0 1px 0 rgba(14, 38, 0, 0.25), 0 6px 16px -8px rgba(46, 140, 0, 0.55); }
.em-btn-primary:hover:not(:disabled) { background: var(--em-volt-hover); }

.em-btn-dark { background: var(--em-chrome); color: #fff; }
.em-btn-dark:hover:not(:disabled) { background: var(--em-chrome-2); }

.em-btn-secondary { background: var(--em-surface); color: var(--em-ink); border-color: var(--em-line-strong); }
.em-btn-secondary:hover:not(:disabled) { background: var(--em-surface-2); border-color: #A9A9A4; }

.em-btn-ghost { background: transparent; color: var(--em-cyan-deep); padding: 0 0.6rem; }
.em-btn-ghost:hover:not(:disabled) { background: var(--em-cyan-wash); }

.em-btn-danger { background: var(--em-surface); color: var(--em-red-ink); border-color: #F0C2BE; }
.em-btn-danger:hover:not(:disabled) { background: var(--em-red); color: #fff; border-color: var(--em-red); }

.em-btn-lg { min-height: 56px; font-size: 1.1rem; padding: 0 1.5rem; }
.em-btn-block { width: 100%; }

.em-spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid currentColor;
    border-right-color: transparent;
    border-radius: 999px;
    animation: em-spin 0.7s linear infinite;
}
@keyframes em-spin { to { transform: rotate(360deg); } }

/* ---------- Estados del socio ---------- */
.em-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.65rem 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
    background: var(--em-surface-2);
    color: var(--em-ink-2);
}
.em-status::before { content: ""; width: 8px; height: 8px; border-radius: 999px; background: currentColor; }
.em-status--activo { background: var(--em-volt-wash); color: var(--em-volt-deep); }
.em-status--activo::before { background: var(--em-volt); box-shadow: 0 0 0 2px #C9F7B0; }
.em-status--inactivo { background: var(--em-amber-wash); color: var(--em-amber-ink); }
.em-status--suspendido { background: var(--em-red-wash); color: var(--em-red-ink); }
.em-status--por-activar { background: var(--em-cyan-wash); color: var(--em-cyan-deep); }
.em-status--lg { font-size: 0.95rem; padding: 0.35rem 0.85rem 0.35rem 0.7rem; }

/* ---------- Avisos ---------- */
.em-alert {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.85rem 1rem;
    border-radius: var(--em-radius);
    border: 1px solid var(--em-line);
    background: var(--em-surface);
    font-weight: 500;
}
.em-alert svg { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 1px; }
.em-alert--ok { background: var(--em-volt-wash); border-color: #C9F7B0; color: var(--em-volt-deep); }
.em-alert--error { background: var(--em-red-wash); border-color: #F5C9C5; color: var(--em-red-ink); }
.em-alert--info { background: var(--em-cyan-wash); border-color: #B5ECF5; color: #00576A; }
.em-alert--warn { background: var(--em-amber-wash); border-color: #F6DDA8; color: var(--em-amber-ink); }

/* ---------- Tablas (todas las tablas del sistema usan estas clases) ---------- */
.table-shell {
    overflow: hidden;
    border: 1px solid var(--em-line);
    border-radius: var(--em-radius-lg);
    background: var(--em-surface);
    box-shadow: var(--em-shadow);
}

.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.modern-table { width: 100%; min-width: 720px; border-collapse: separate; border-spacing: 0; font-size: 0.95rem; }

.modern-table thead { background: var(--em-surface-2); }

.modern-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 0.75rem 1rem;
    background: var(--em-surface-2);
    border-bottom: 1px solid var(--em-line);
    color: var(--em-ink-3);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.modern-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid #ECECE8;
    color: var(--em-ink-2);
    vertical-align: middle;
}

.modern-table tbody tr { transition: background-color 0.12s var(--em-ease); }
.modern-table tbody tr:nth-child(even) { background: transparent; }
.modern-table tbody tr:hover { background: #F7FBF4; }
.modern-table tbody tr:last-child td { border-bottom: 0; }
.modern-table td:first-child { color: var(--em-ink); font-weight: 600; }
.modern-table td.numeric, .modern-table th.numeric { text-align: right; }
.modern-table td.center, .modern-table th.center { text-align: center; }

.table-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--em-line);
    background: var(--em-surface);
    color: var(--em-ink-3);
    font-size: 0.92rem;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 40px;
    min-width: 40px;
    padding: 0 0.85rem;
    border: 1px solid var(--em-line-strong);
    border-radius: var(--em-radius-sm);
    background: var(--em-surface);
    color: var(--em-ink);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.14s var(--em-ease), border-color 0.14s var(--em-ease);
}
.pagination-btn:hover:not(:disabled) { background: var(--em-surface-2); border-color: #A9A9A4; }
.pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.table-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 36px;
    padding: 0 0.75rem;
    border: 1px solid var(--em-line-strong);
    border-radius: var(--em-radius-sm);
    background: var(--em-surface);
    color: var(--em-ink);
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.14s var(--em-ease), border-color 0.14s var(--em-ease), color 0.14s var(--em-ease);
}
.table-action:hover { background: var(--em-surface-2); border-color: #A9A9A4; }
.table-action-primary { color: var(--em-cyan-deep); border-color: #B5ECF5; background: var(--em-cyan-wash); }
.table-action-primary:hover { background: var(--em-cyan-deep); border-color: var(--em-cyan-deep); color: #fff; }
.table-action-success { color: var(--em-volt-deep); border-color: #C9F7B0; background: var(--em-volt-wash); }
.table-action-success:hover { background: var(--em-volt); border-color: var(--em-volt); color: var(--em-volt-ink); }
.table-action-danger { color: var(--em-red-ink); border-color: #F0C2BE; }
.table-action-danger:hover { background: var(--em-red); border-color: var(--em-red); color: #fff; }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: currentColor; }
.status-pill-success { background: var(--em-volt-wash); color: var(--em-volt-deep); }
.status-pill-success::before { background: var(--em-volt); }
.status-pill-muted { background: var(--em-surface-2); color: var(--em-ink-3); }
.status-pill-warning { background: var(--em-amber-wash); color: var(--em-amber-ink); }
.status-pill-danger { background: var(--em-red-wash); color: var(--em-red-ink); }

.em-empty { padding: 2.5rem 1rem; text-align: center; color: var(--em-ink-3); }

@media (max-width: 767px) {
    .table-shell { border-radius: var(--em-radius); }
    .modern-table { font-size: 0.92rem; }
    .modern-table th, .modern-table td { padding: 0.7rem 0.75rem; }
    .table-toolbar { flex-direction: column; align-items: stretch; text-align: center; }
    .table-toolbar > * { justify-content: center; }
}

/* ---------- Carga ---------- */
.loader {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(255, 255, 255, 0.25);
    border-top-color: var(--em-volt);
    border-radius: 50%;
    animation: em-spin 0.8s linear infinite;
}

.overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(24, 24, 28, 0.55);
}

/* SweetAlert2 con la identidad Energym */
.swal2-popup { border-radius: var(--em-radius-lg) !important; font-family: var(--em-font-ui) !important; }
.swal2-title { font-family: var(--em-font-brand) !important; color: var(--em-ink) !important; }
.swal2-styled.swal2-confirm { background: var(--em-chrome) !important; border-radius: var(--em-radius) !important; font-weight: 700 !important; }
.swal2-styled.swal2-cancel { background: var(--em-surface) !important; color: var(--em-ink) !important; border: 1px solid var(--em-line-strong) !important; border-radius: var(--em-radius) !important; font-weight: 700 !important; }
.swal2-styled:focus { box-shadow: var(--em-ring) !important; }
.status-pill-info { background: var(--em-cyan-wash); color: var(--em-cyan-deep); }

/* ---------- Pantallas de consulta (listados, reportes, configuración) ---------- */
.em-page-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.em-back {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.6rem;
    color: var(--em-cyan-deep);
    font-weight: 600;
    text-decoration: none;
}
.em-back:hover { text-decoration: underline; }
.em-back svg { width: 18px; height: 18px; }

/* Filtros en fila: cada uno es un em-field */
.em-filters {
    display: grid;
    gap: 0.9rem 1rem;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    align-items: end;
    padding: 1rem;
    margin-bottom: 1rem;
}
.em-filters > * { min-width: 0; }
.em-filters .em-input { min-width: 0; }
.em-filters input[type="date"] { padding-left: 0.6rem; padding-right: 0.5rem; }
.em-filters .em-field--wide { grid-column: span 2; }
@media (max-width: 299px) { .em-filters .em-field--wide { grid-column: auto; } }
@media (min-width: 768px) { .em-filters { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); padding: 1.1rem 1.25rem; } }

/* Indicadores */
.em-stats { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.em-stat { display: grid; gap: 0.2rem; align-content: start; padding: 1.1rem 1.25rem; }
.em-stat-label { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; color: var(--em-ink-3); font-weight: 600; font-size: 0.95rem; }
.em-stat-value { font-family: var(--em-font-brand); font-weight: 800; font-size: 2rem; line-height: 1.1; color: var(--em-ink); font-variant-numeric: tabular-nums; }
.em-stat-meta { color: var(--em-ink-3); font-size: 0.9rem; }
.em-stat-meta strong { color: var(--em-ink-2); }

/* Bloque carbón para la cifra principal de una vista */
.em-hero {
    background: var(--em-chrome);
    color: var(--em-chrome-ink);
    border-radius: var(--em-radius-lg);
    box-shadow: var(--em-shadow-lg);
    padding: 1.25rem;
}
@media (min-width: 768px) { .em-hero { padding: 1.5rem 1.75rem; } }
.em-hero .em-stat-label { color: var(--em-chrome-ink-2); }
.em-hero .em-stat-value { color: var(--em-volt); font-size: clamp(2.2rem, 1.6rem + 2vw, 3rem); }
.em-hero .em-stat-meta { color: var(--em-chrome-ink-2); }
.em-hero .em-stat-meta strong { color: var(--em-chrome-ink); }

/* Botón cuadrado solo con icono */
.em-icon-btn {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border: 1px solid var(--em-line-strong);
    border-radius: var(--em-radius-sm);
    background: var(--em-surface);
    color: var(--em-ink-2);
    cursor: pointer;
    transition: background-color 0.14s var(--em-ease), border-color 0.14s var(--em-ease);
}
.em-icon-btn:hover { background: var(--em-surface-2); border-color: #A9A9A4; }
.em-icon-btn svg { width: 19px; height: 19px; }
.em-hero .em-icon-btn { background: transparent; border-color: var(--em-chrome-line); color: var(--em-chrome-ink-2); }
.em-hero .em-icon-btn:hover { background: var(--em-chrome-2); color: var(--em-chrome-ink); }

/* Montos con signo */
.em-pos { color: var(--em-volt-deep); font-weight: 700; }
.em-neg { color: var(--em-red-ink); font-weight: 700; }
.em-muted { color: var(--em-ink-3); }

/* Pares etiqueta / valor (fichas y detalles) */
.em-dl { display: grid; gap: 0; margin: 0; }
.em-dl > div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid #ECECE8; }
.em-dl > div:last-child { border-bottom: 0; }
.em-dl dt { color: var(--em-ink-3); font-weight: 500; }
.em-dl dd { margin: 0; color: var(--em-ink); font-weight: 600; text-align: right; overflow-wrap: anywhere; }

/* Casilla de verificación con texto de ayuda */
.em-check {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--em-line-strong);
    border-radius: var(--em-radius);
    background: var(--em-surface);
    cursor: pointer;
}
.em-check:hover { background: var(--em-surface-2); }
.em-check input { width: 20px; height: 20px; margin-top: 0.1rem; accent-color: var(--em-chrome); flex: 0 0 auto; }
.em-check strong { display: block; color: var(--em-ink); }
.em-check span { color: var(--em-ink-3); font-size: 0.9rem; }

/* Barra de acciones al pie de un formulario */
.em-form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.6rem; }
@media (max-width: 559px) { .em-form-actions { flex-direction: column-reverse; } .em-form-actions .em-btn { width: 100%; } }

/* Paginador al pie de una tabla */
.em-pager { display: flex; align-items: center; gap: 0.5rem; }
.em-pager .em-select { min-height: 40px; width: auto; padding-top: 0.3rem; padding-bottom: 0.3rem; }
.em-pager-info { color: var(--em-ink-3); font-size: 0.92rem; }

/* Diálogo nativo (<dialog>) */
.em-dialog {
    width: min(560px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    padding: 0;
    border: 1px solid var(--em-line);
    border-radius: var(--em-radius-lg);
    background: var(--em-surface);
    color: var(--em-ink);
    box-shadow: var(--em-shadow-lg);
}
.em-dialog--wide { width: min(960px, calc(100vw - 2rem)); }
.em-dialog::backdrop { background: rgba(24, 24, 28, 0.55); }
.em-dialog-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem 0.9rem 1.25rem;
    border-bottom: 1px solid var(--em-line);
    background: var(--em-surface);
}
.em-dialog-head h2 { margin: 0; font-size: 1.15rem; font-weight: 800; }
.em-dialog-body { padding: 1.25rem; }
.em-dialog-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.6rem; padding: 0 1.25rem 1.25rem; }
.em-dialog-media { display: block; max-width: 100%; max-height: 72vh; margin: 0 auto; border-radius: var(--em-radius); }

/* Tablas que se vuelven tarjetas en el celular.
   Cada td recibe data-label con el texto de su encabezado (header.php lo hace solo). */
@media (max-width: 639px) {
    .modern-table--stack { min-width: 0; }
    .modern-table--stack thead { display: none; }
    .modern-table--stack tbody tr { display: grid; gap: 0.15rem; padding: 0.8rem 0.9rem; border-bottom: 1px solid var(--em-line); }
    .modern-table--stack tbody tr:last-child { border-bottom: 0; }
    .modern-table--stack tbody td { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.2rem 0; border: 0; text-align: right; }
    .modern-table--stack tbody td.numeric, .modern-table--stack tbody td.center { text-align: right; }
    .modern-table--stack tbody td[data-label]::before { content: attr(data-label); color: var(--em-ink-3); font-size: 0.85rem; font-weight: 600; text-align: left; flex: 0 0 auto; }
    .modern-table--stack tbody td.em-cell-title { justify-content: flex-start; text-align: left; font-size: 1.02rem; padding-bottom: 0.25rem; }
    .modern-table--stack tbody td.em-cell-title::before { display: none; }
    .modern-table--stack tbody td.em-cell-actions { justify-content: flex-start; flex-wrap: wrap; padding-top: 0.5rem; }
    .modern-table--stack tbody td.em-cell-actions::before { display: none; }
    .modern-table--stack tbody td[colspan] { display: block; text-align: center; }
    .modern-table--stack tbody td[colspan]::before { display: none; }
    .modern-table--stack tbody td:empty { display: none; }
}

/* Celda con nombre y dato secundario */
.em-cell-sub { display: block; color: var(--em-ink-3); font-size: 0.85rem; font-weight: 500; }
.em-table-actions { display: inline-flex; flex-wrap: wrap; gap: 0.4rem; }
