/* ============================================================================
   Reservador CEM Les Vernedes — Sistema de diseño
   Mobile-first, accesible (WCAG 2.1 AA), sin dependencias externas.
   ============================================================================ */

/* --- Tokens ---------------------------------------------------------------- */
:root {
    /* Paleta — moderna, contraste AA garantizado */
    --c-bg: #f6f7fb;
    --c-surface: #ffffff;
    --c-surface-alt: #f9fafb;
    --c-border: #e5e7eb;
    --c-border-strong: #d1d5db;
    --c-text: #0f172a;
    --c-muted: #64748b;
    --c-muted-strong: #475569;

    --c-brand: #0d9488;          /* teal-600 */
    --c-brand-strong: #0f766e;   /* teal-700 */
    --c-brand-soft: #ccfbf1;     /* teal-100 */
    --c-brand-fg: #ffffff;

    --c-accent: #4f46e5;         /* indigo-600 (links, foco) */

    --c-success: #047857;
    --c-success-bg: #d1fae5;
    --c-warning: #b45309;
    --c-warning-bg: #fef3c7;
    --c-danger: #b91c1c;
    --c-danger-bg: #fee2e2;
    --c-info: #1d4ed8;
    --c-info-bg: #dbeafe;

    /* Espaciado (escala 4/8/12/16/24/32/48) */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 20px;
    --s-6: 24px;
    --s-8: 32px;
    --s-10: 40px;
    --s-12: 48px;

    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-pill: 999px;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, .08), 0 2px 6px -1px rgba(15, 23, 42, .05);
    --shadow-lg: 0 12px 32px -4px rgba(15, 23, 42, .12), 0 4px 10px -2px rgba(15, 23, 42, .06);

    /* Tipografía */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Helvetica Neue', 'Inter', Arial, system-ui, sans-serif;
    --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Monaco, monospace;

    /* Layout */
    --container: 560px;
    --header-h: 64px;
    --bottom-nav-h: 64px;

    --transition: 180ms ease;
}

@media (prefers-color-scheme: dark) {
    :root {
        --c-bg: #0b1120;
        --c-surface: #111827;
        --c-surface-alt: #1f2937;
        --c-border: #1f2937;
        --c-border-strong: #374151;
        --c-text: #f1f5f9;
        --c-muted: #94a3b8;
        --c-muted-strong: #cbd5e1;

        --c-brand: #2dd4bf;
        --c-brand-strong: #14b8a6;
        --c-brand-soft: #134e4a;
        --c-brand-fg: #042f2e;

        --c-accent: #818cf8;

        --c-success: #34d399;
        --c-success-bg: #064e3b;
        --c-warning: #fbbf24;
        --c-warning-bg: #78350f;
        --c-danger: #f87171;
        --c-danger-bg: #7f1d1d;
        --c-info: #60a5fa;
        --c-info-bg: #1e3a8a;

        --shadow-xs: 0 1px 2px rgba(0, 0, 0, .35);
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
        --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, .4);
        --shadow-lg: 0 12px 32px -4px rgba(0, 0, 0, .5);
    }
}

/* --- Reset minimal --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.55;
    color: var(--c-text);
    background: var(--c-bg);
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }
input, button, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a {
    color: var(--c-accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: color var(--transition);
}
a:hover { color: var(--c-brand-strong); }

h1, h2, h3, h4 { line-height: 1.25; font-weight: 700; letter-spacing: -.015em; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.05rem; margin-top: var(--s-2); }
h3 { font-size: .95rem; }
@media (min-width: 768px) {
    h1 { font-size: 1.85rem; }
    h2 { font-size: 1.3rem; }
    h3 { font-size: 1.05rem; }
}

p { color: var(--c-muted-strong); }

:focus { outline: none; }
:focus-visible {
    outline: 3px solid var(--c-accent);
    outline-offset: 2px;
    border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition: none !important;
        animation: none !important;
        scroll-behavior: auto !important;
    }
}

/* --- Accesibilidad --------------------------------------------------------- */
.skip-link {
    position: absolute;
    left: var(--s-3);
    top: -100px;
    background: var(--c-brand);
    color: var(--c-brand-fg);
    padding: var(--s-2) var(--s-4);
    border-radius: var(--r-sm);
    font-weight: 600;
    z-index: 100;
    transition: top var(--transition);
}
.skip-link:focus {
    top: var(--s-3);
    color: var(--c-brand-fg);
    text-decoration: none;
}

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* --- Layout principal ------------------------------------------------------ */
.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding-left: var(--s-4);
    padding-right: var(--s-4);
}
@media (min-width: 768px) {
    .container { padding-left: var(--s-8); padding-right: var(--s-8); }
}

.app-main {
    padding-top: var(--s-4);
    padding-bottom: calc(var(--bottom-nav-h) + var(--s-6));  /* sitio para bottom nav móvil */
}
@media (min-width: 768px) {
    .app-main { padding-top: var(--s-8); padding-bottom: var(--s-12); }
}

.app-footer {
    padding: var(--s-6) 0;
    color: var(--c-muted);
    font-size: .85rem;
    text-align: center;
    /* En móvil dejamos hueco para que la bottom-nav no la tape */
    margin-bottom: var(--bottom-nav-h);
}
@media (min-width: 768px) {
    .app-footer { margin-bottom: 0; }
}

/* --- Header / topbar ------------------------------------------------------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    backdrop-filter: saturate(160%) blur(8px);
    -webkit-backdrop-filter: saturate(160%) blur(8px);
}
.app-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    height: var(--header-h);
    min-width: 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    font-weight: 700;
    color: var(--c-text);
    text-decoration: none;
    font-size: 1.05rem;
    letter-spacing: -.01em;
    min-width: 0;            /* permite que el texto se contraiga */
    flex: 1 1 auto;
    overflow: hidden;
}
.brand:hover { color: var(--c-brand-strong); }
.brand__text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
/* .brand__mark sigue usándose en el hero-card del login (login.html). */
.brand__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    border-radius: var(--r-sm);
    background: linear-gradient(135deg, var(--c-brand) 0%, var(--c-brand-strong) 100%);
    color: white;
    font-weight: 800;
    font-size: 1rem;
    flex-shrink: 0;
}

/* Pestañas de navegación dentro de la cabecera (sustituyen al antiguo
   "brand" textual). En desktop se muestran como pastillas horizontales;
   en móvil la navegación principal está en el bottom-nav. */
.header-tabs {
    display: flex;
    align-items: center;
    gap: var(--s-1);
    flex: 1 1 auto;
    min-width: 0;
}
.header-tabs a {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-4);
    border-radius: var(--r-sm);
    color: var(--c-muted-strong);
    text-decoration: none;
    font-weight: 500;
    font-size: .95rem;
    transition: background var(--transition), color var(--transition);
}
.header-tabs a:hover {
    background: var(--c-surface-alt);
    color: var(--c-text);
}
.header-tabs a[aria-current="page"] {
    background: var(--c-brand-soft);
    color: var(--c-brand-strong);
}

/* Acciones de cabecera (idiomas + usuario + salir) */
.header-actions {
    display: inline-flex;
    align-items: center;
    gap: var(--s-3);
    flex-shrink: 0;
}

/* Usuario: avatar + email plano (sin dropdown; el logout ya es visible). */
.user-info {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    max-width: 220px;
    color: var(--c-muted-strong);
    font-size: .85rem;
    font-weight: 500;
    min-width: 0;
}

/* Botones icon-only de la cabecera (ajustes, salir…). */
.header-iconbtn {
    flex-shrink: 0;
    padding: 6px;
    min-height: 32px;
    min-width: 32px;
}
.header-iconbtn[aria-current="page"] {
    border-color: var(--c-brand);
    color: var(--c-brand-strong);
}

/* --- Avatar + email del usuario (usado en .user-info de la cabecera) ------ */
.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--c-brand) 0%, var(--c-brand-strong) 100%);
    color: white;
    font-weight: 700;
    font-size: .85rem;
    flex-shrink: 0;
    text-transform: uppercase;
}

.user-email {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
/* En pantallas estrechas ocultamos el email; el avatar identifica visualmente */
@media (max-width: 539px) {
    .user-email { display: none; }
}

/* Selector de idioma: tres cajitas tipo segmented control (CA ES EN) */
.lang-switcher {
    display: inline-flex;
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    background: var(--c-surface);
    overflow: hidden;
}
.lang-switcher__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    padding: 6px 10px;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .02em;
    color: var(--c-muted-strong);
    text-decoration: none;
    border-left: 1px solid var(--c-border);
    transition: background var(--transition), color var(--transition);
}
.lang-switcher__item:first-child { border-left: 0; }
.lang-switcher__item:hover { background: var(--c-surface-alt); color: var(--c-text); }
.lang-switcher__item.is-active {
    background: var(--c-brand);
    color: #fff;
    cursor: default;
}
.lang-switcher__item.is-active:hover { background: var(--c-brand); color: #fff; }

/* Botón estilo enlace (logout en cabecera) */
.link-button {
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: var(--s-2) var(--s-4);
    border-radius: var(--r-sm);
    color: var(--c-muted-strong);
    font-weight: 500;
}
.link-button:hover { background: var(--c-surface-alt); color: var(--c-text); }

.inline-form { display: inline; margin: 0; }

/* --- Bottom nav móvil ------------------------------------------------------ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-h);
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    display: flex;
    z-index: 50;
    box-shadow: 0 -4px 16px -4px rgba(15, 23, 42, .08);
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a, .bottom-nav .link-button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--c-muted);
    font-size: .68rem;
    font-weight: 500;
    padding: var(--s-2) 2px;
    border-radius: 0;
    background: transparent;
    border: 0;
    transition: color var(--transition);
    line-height: 1.1;
    text-align: center;
    min-width: 0;
}
.bottom-nav a span, .bottom-nav .link-button span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    display: block;
}
.bottom-nav a svg, .bottom-nav .link-button svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}
.bottom-nav a:hover, .bottom-nav .link-button:hover { color: var(--c-text); background: transparent; }
.bottom-nav a[aria-current="page"] {
    color: var(--c-brand-strong);
}
.bottom-nav a[aria-current="page"]::before {
    content: "";
    position: absolute;
    top: 0;
    width: 28px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--c-brand);
}
@media (min-width: 768px) {
    .bottom-nav { display: none; }
}

/* --- Cards / superficies --------------------------------------------------- */
.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    padding: var(--s-4);
}
.card + .card { margin-top: var(--s-4); }
.card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--s-3);
    margin-bottom: var(--s-3);
}
.card__title { font-size: .95rem; font-weight: 700; color: var(--c-text); margin: 0; }
.card__subtitle { color: var(--c-muted); font-size: .82rem; margin-top: 2px; }

@media (min-width: 768px) {
    .card {
        padding: var(--s-8);
        border-radius: var(--r-lg);
        box-shadow: var(--shadow-xs);
    }
    .card + .card { margin-top: var(--s-5); }
    .card__title { font-size: 1.05rem; }
    .card__header { margin-bottom: var(--s-4); }
}

/* Hero (login) */
.hero-card {
    max-width: 440px;
    margin: 8vh auto 0;
    background: var(--c-surface);
    border-radius: var(--r-lg);
    padding: var(--s-8) var(--s-6);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--c-border);
}
@media (min-width: 768px) {
    .hero-card { padding: var(--s-10) var(--s-8); margin-top: 12vh; }
}
.hero-card__brand {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    margin-bottom: var(--s-6);
}
.hero-card__brand .brand__mark { width: 44px; height: 44px; font-size: 1.2rem; border-radius: var(--r-md); }
.hero-card__brand h1 {
    font-size: 1.4rem;
    margin: 0;
    line-height: 1.2;
}
.hero-card__tagline { color: var(--c-muted); font-size: .9rem; margin-top: 2px; }

/* --- Page header ----------------------------------------------------------- */
.page-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: var(--s-4);
}
.page-header h1 { margin: 0; }
.page-header p { color: var(--c-muted); margin: 0; max-width: 65ch; font-size: .85rem; }

@media (min-width: 768px) {
    .page-header { margin-bottom: var(--s-8); gap: var(--s-1); }
    .page-header p { font-size: 1rem; }
}

/* --- Formularios ---------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: var(--s-3); }
@media (min-width: 768px) { .form { gap: var(--s-4); } }
.form-row {
    display: grid;
    gap: var(--s-4);
}
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
/* Si las etiquetas tienen distinta longitud y una envuelve a 2 líneas en
   móvil, los inputs se desalinean. Empujamos cada input al fondo de su
   celda para que queden a la misma altura. */
.form-row .field { justify-content: flex-end; }
@media (min-width: 640px) {
    .form-row.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field > .label {
    font-weight: 600;
    font-size: .92rem;
    color: var(--c-text);
}
.field .help {
    font-size: .82rem;
    color: var(--c-muted);
    margin-top: 2px;
}

.input, .select, .textarea {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    background: var(--c-surface);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--r-sm);
    padding: 10px 12px;
    font-size: .95rem;
    color: var(--c-text);
    min-height: 44px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
@media (min-width: 768px) {
    .input, .select, .textarea { padding: 12px 14px; font-size: 1rem; }
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--c-muted); }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--c-brand);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, .25);
}
.input::placeholder,
.textarea::placeholder { color: var(--c-muted); opacity: .45; font-style: italic; }
/* Agrandar el icono de reloj/calendario nativo del input type=time/date.
   Sólo Chromium/WebKit lo permite; Firefox no expone el pseudo-elemento. */
.input[type="time"]::-webkit-calendar-picker-indicator,
.input[type="date"]::-webkit-calendar-picker-indicator {
    width: 22px;
    height: 22px;
    padding: 4px;
    cursor: pointer;
    opacity: .85;
}
.input[type="time"]::-webkit-calendar-picker-indicator:hover,
.input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}
.select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

/* Checkbox bonito */
.checkbox {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    cursor: pointer;
    font-weight: 500;
    color: var(--c-text);
    user-select: none;
    padding: var(--s-1) 0;
    min-height: 44px;
}
.checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--c-brand);
    cursor: pointer;
}

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    padding: 12px 20px;
    min-height: 44px;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: .95rem;
    text-decoration: none;
    transition: background var(--transition), border-color var(--transition),
                color var(--transition), transform var(--transition);
    cursor: pointer;
    line-height: 1;
    white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: .35;
    filter: grayscale(.85);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
    pointer-events: none;
}
.btn-primary {
    background: var(--c-brand);
    color: var(--c-brand-fg);
    box-shadow: var(--shadow-xs);
}
.btn-primary:hover { background: var(--c-brand-strong); color: var(--c-brand-fg); }
.btn-secondary {
    background: var(--c-surface);
    color: var(--c-text);
    border-color: var(--c-border-strong);
}
.btn-secondary:hover { background: var(--c-surface-alt); border-color: var(--c-muted); color: var(--c-text); }
.btn-danger {
    background: var(--c-surface);
    color: var(--c-danger);
    border-color: var(--c-danger);
}
.btn-danger:hover { background: var(--c-danger-bg); color: var(--c-danger); }
.btn-ghost {
    background: transparent;
    color: var(--c-muted-strong);
    border-color: transparent;
    padding: 8px 12px;
    min-height: 36px;
}
.btn-ghost:hover { background: var(--c-surface-alt); color: var(--c-text); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; min-height: 32px; font-size: .85rem; border-radius: 6px; }

/* --- Mensajes flash -------------------------------------------------------- */
/* Banner "Añadir a inicio" (PWA). Aparece pegado abajo, dismiss persistente. */
.a2hs-banner {
    position: fixed;
    left: var(--s-3);
    right: var(--s-3);
    bottom: var(--s-3);
    z-index: 1000;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
    padding: var(--s-3) var(--s-4);
    display: flex;
    align-items: center;
    gap: var(--s-3);
    flex-wrap: wrap;
}
.a2hs-banner__text { flex: 1 1 200px; font-size: .92rem; }
.a2hs-banner__actions { display: flex; gap: var(--s-2); align-items: center; }

.flash-bag { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-5); transition: opacity .3s ease, transform .3s ease; }
.flash-bag.is-dismissing { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.flash {
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r-sm);
    font-weight: 500;
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: var(--s-2);
    box-shadow: var(--shadow-xs);
    background: var(--c-surface);
}
.flash-success { color: var(--c-success); border-color: var(--c-success); background: var(--c-success-bg); }
.flash-error   { color: var(--c-danger);  border-color: var(--c-danger);  background: var(--c-danger-bg); }
.flash-info    { color: var(--c-info);    border-color: var(--c-info);    background: var(--c-info-bg); }

/* --- Aviso destacado ------------------------------------------------------ */
.alert-card {
    background: var(--c-warning-bg);
    border: 1px solid var(--c-warning);
    border-radius: var(--r-lg);
    padding: var(--s-5);
    color: var(--c-warning);
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    margin-bottom: var(--s-5);
}
.alert-card__title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--c-warning);
    display: flex;
    align-items: center;
    gap: var(--s-2);
}
.alert-card p { color: var(--c-warning); margin: 0; }
@media (min-width: 640px) {
    .alert-card { flex-direction: row; align-items: center; justify-content: space-between; }
    .alert-card__body { flex: 1; }
}

/* --- Estados (badges) ---------------------------------------------------- */
.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--r-pill);
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}
.status::before {
    content: "";
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.status-pending { color: var(--c-info);    background: var(--c-info-bg); }
.status-success { color: var(--c-success); background: var(--c-success-bg); }
.status-failed  { color: var(--c-warning); background: var(--c-warning-bg); }
.status-error   { color: var(--c-danger);  background: var(--c-danger-bg); }
.status-cancelled { color: var(--c-danger); background: var(--c-danger-bg); }

/* --- Tablas (responsive: cards en móvil) ---------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .92rem;
}
.data-table th, .data-table td {
    text-align: left;
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--c-border);
    vertical-align: middle;
}
.data-table th {
    font-size: .78rem;
    font-weight: 600;
    color: var(--c-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--c-surface-alt);
    border-bottom: 1px solid var(--c-border-strong);
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--c-surface-alt); }

/* En móvil, cada fila se muestra como tarjeta apilada */
@media (max-width: 639px) {
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr {
        background: var(--c-surface);
        border: 1px solid var(--c-border);
        border-radius: var(--r-md);
        padding: var(--s-3) var(--s-4);
        margin-bottom: var(--s-3);
        box-shadow: var(--shadow-xs);
    }
    .data-table tbody tr:hover { background: var(--c-surface); }
    .data-table td {
        border: 0;
        padding: var(--s-1) 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: var(--s-3);
    }
    .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--c-muted);
        font-size: .8rem;
        text-transform: uppercase;
        letter-spacing: .04em;
    }
    .data-table td > * { text-align: right; }
}

/* "Sucesos en tiempo real": card destacada arriba con feed de eventos del día. */
.live-card { margin-bottom: var(--s-5); }
.live-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.live-item {
    display: grid;
    grid-template-columns: minmax(120px, max-content) 1fr auto;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-2) var(--s-3);
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    background: var(--c-surface);
}
.live-item__activity { color: var(--c-text); font-weight: 500; word-break: break-word; }
.live-item__activity small { color: var(--c-muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.live-item__action { margin: 0; }
.live-empty { color: var(--c-muted); font-style: italic; margin: 0; }
@media (max-width: 639px) {
    .live-item {
        grid-template-columns: 1fr;
        gap: var(--s-1);
    }
}

/* "Últimos intentos de reserva": forzamos el modo cards (apiladas) en TODOS
   los breakpoints. Cada fila se renderiza como una tarjeta con etiqueta a la
   izquierda y valor a la derecha. En desktop ponemos las cards en grid de
   2 columnas para aprovechar el ancho. */
.data-table--attempts thead { display: none; }
.data-table--attempts,
.data-table--attempts tbody,
.data-table--attempts tr,
.data-table--attempts td { display: block; width: 100%; }
.data-table--attempts tr {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-4);
    margin-bottom: var(--s-3);
    box-shadow: var(--shadow-xs);
}
.data-table--attempts tbody tr:hover { background: var(--c-surface); }
.data-table--attempts td {
    border: 0;
    padding: var(--s-1) 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s-3);
    min-width: 0;
}
.data-table--attempts td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--c-muted);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    flex: 0 0 auto;
}
.data-table--attempts td > * {
    text-align: right;
    min-width: 0;
}
.data-table--attempts td .expandable {
    flex: 1 1 auto;
    min-width: 0;
}
.data-table--attempts td .expandable__text {
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* --- Lista de horarios / próximas reservas (cards) ------------------------- */
.schedule-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
}

/* Formulario "añadir horario" ultra-compacto: [Día ▼] [Actividad ▼] [+] */
.schedule-add {
    display: flex;
    gap: var(--s-2);
    align-items: center;
    margin-bottom: var(--s-3);
}
.schedule-add .select { min-height: 36px; padding: 6px 10px; font-size: .9rem; }
.schedule-add .select:first-of-type { flex: 0 0 auto; width: 9em; }
.schedule-add .select:last-of-type  { flex: 1 1 auto; min-width: 0; }
.schedule-add .btn {
    flex-shrink: 0;
    padding: 6px;
    min-height: 36px;
    min-width: 36px;
}
.schedule-add__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2);
    margin-bottom: var(--s-4);
    color: var(--c-muted);
    font-size: .75rem;
}
.schedule-add__meta .inline-form { margin: 0; }

/* Pastilla compacta: [dot toggle]  [actividad · día hora · fecha]  [✏️] [🗑️] */
.schedule-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    padding: var(--s-2) var(--s-3);
    display: flex;
    align-items: center;
    gap: var(--s-3);
    transition: border-color var(--transition);
}
.schedule-card:hover { border-color: var(--c-border-strong); }
.schedule-card.is-disabled { opacity: .55; }
.schedule-card.is-past { opacity: .6; }

.schedule-card__toggle { margin: 0; flex-shrink: 0; }

/* Switch estilo iOS (compacto) para activar/desactivar el horario. */
.switch {
    display: inline-block;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    line-height: 0;
}
.switch:focus-visible {
    outline: 2px solid var(--c-accent);
    outline-offset: 2px;
    border-radius: 999px;
}
.switch__track {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 20px;
    border-radius: 999px;
    background: var(--c-danger);
    transition: background var(--transition);
    box-shadow: inset 0 1px 2px rgba(0,0,0,.18);
}
.switch__thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.32);
    transition: transform var(--transition);
}
.switch.is-on .switch__track { background: var(--c-success); }
.switch.is-on .switch__thumb { transform: translateX(14px); }

/* Bloque textual de la pastilla (clicable, lleva a /edit). */
.schedule-card__link {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    color: var(--c-text);
    text-decoration: none;
    overflow: hidden;
}
.schedule-card__link:hover .schedule-card__when { color: var(--c-brand-strong); }
.schedule-card__when {
    font-weight: 700;
    font-size: 1.05rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
    word-break: break-word;
}
.schedule-card__activity-sub {
    color: var(--c-muted);
    font-size: .8rem;
    word-break: break-word;
}

.schedule-card__badge { font-size: .75rem; align-self: flex-start; margin-top: 2px; }

.schedule-card__actions {
    display: inline-flex;
    align-items: center;
    gap: var(--s-1);
    flex-shrink: 0;
}

/* Botón cuadrado icon-only reutilizable (también en header-logout). */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--r-sm);
    border: 1px solid var(--c-border);
    background: var(--c-surface);
    color: var(--c-muted-strong);
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.btn-icon:hover {
    background: var(--c-surface-alt);
    color: var(--c-text);
    border-color: var(--c-border-strong);
}
.btn-icon:focus-visible {
    outline: 2px solid var(--c-accent);
    outline-offset: 2px;
}
.btn-icon--danger:hover {
    background: var(--c-danger-bg);
    color: var(--c-danger);
    border-color: var(--c-danger);
}

/* --- Lista resumen vertical ------------------------------------------------- */
.summary-list { list-style: none; margin: 0; padding: 0; }
.summary-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-3) 0;
    border-bottom: 1px solid var(--c-border);
}
.summary-list li:last-child { border-bottom: 0; }
.summary-list strong { font-weight: 600; color: var(--c-text); }
.summary-list small { color: var(--c-muted); }

/* --- Estados vacíos -------------------------------------------------------- */
.empty-state {
    text-align: center;
    padding: var(--s-10) var(--s-4);
    color: var(--c-muted);
}
.empty-state h3 { color: var(--c-text); margin-bottom: var(--s-2); font-weight: 700; }
.empty-state p { margin-bottom: var(--s-5); }

/* --- Detalles desplegables (admin) ---------------------------------------- */
details.row-actions {
    display: inline-block;
    position: relative;
}
details.row-actions summary {
    list-style: none;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    background: var(--c-surface-alt);
    border: 1px solid var(--c-border);
    font-size: .85rem;
    font-weight: 600;
    color: var(--c-muted-strong);
    user-select: none;
}
details.row-actions summary::-webkit-details-marker { display: none; }
details.row-actions summary:hover { color: var(--c-text); }
details.row-actions[open] > summary {
    border-color: var(--c-brand);
    color: var(--c-brand-strong);
}
.row-actions__menu {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    margin-top: var(--s-2);
    padding: var(--s-3);
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
    min-width: 260px;
    max-width: calc(100vw - var(--s-6));
    position: absolute;
    right: 0;
    z-index: 30;
}
.row-actions__menu .inline-form {
    display: flex;
    gap: var(--s-2);
    align-items: stretch;
    flex-wrap: wrap;
}
.row-actions__menu .inline-form .input { flex: 1 1 120px; min-width: 0; }
.row-actions__menu .input { padding: 8px 10px; min-height: 36px; font-size: .85rem; }

/* En móvil → bottom sheet ocupando ancho completo */
@media (max-width: 639px) {
    details.row-actions[open]::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .45);
        z-index: 99;
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }
    .row-actions__menu {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        margin: 0;
        max-width: 100%;
        min-width: 0;
        border: 0;
        border-top: 1px solid var(--c-border);
        border-radius: var(--r-lg) var(--r-lg) 0 0;
        padding: var(--s-5) var(--s-5)
                 calc(var(--bottom-nav-h) + var(--s-4) + env(safe-area-inset-bottom));
        max-height: 75vh;
        overflow-y: auto;
        box-shadow: 0 -10px 40px rgba(15, 23, 42, .25);
        z-index: 100;
        gap: var(--s-3);
    }
    /* Pequeño "handle" visual estilo iOS */
    .row-actions__menu::before {
        content: "";
        display: block;
        width: 44px;
        height: 4px;
        border-radius: 2px;
        background: var(--c-border-strong);
        margin: 0 auto var(--s-3);
    }
    .row-actions__menu .input,
    .row-actions__menu .btn { min-height: 44px; font-size: 1rem; }
}

/* --- Misc ----------------------------------------------------------------- */
hr {
    border: 0;
    border-top: 1px solid var(--c-border);
    margin: var(--s-6) 0;
}

::selection {
    background: var(--c-brand-soft);
    color: var(--c-text);
}

/* Texto plegable a 2 líneas con botón +/− para expandir/colapsar. */
.expandable {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}
.expandable__text {
    flex: 1 1 auto;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    white-space: normal;
    word-break: break-word;
}
.expandable.is-expanded .expandable__text {
    -webkit-line-clamp: unset;
    line-clamp: unset;
    display: block;
}
.expandable__toggle[hidden] { display: none !important; }
.expandable__toggle {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--c-border);
    background: var(--c-surface);
    color: var(--c-muted-strong);
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}
.expandable__toggle:hover { background: var(--c-surface-alt); color: var(--c-text); }
.expandable__icon {
    position: relative;
    width: 10px;
    height: 10px;
}
.expandable__icon::before,
.expandable__icon::after {
    content: "";
    position: absolute;
    background: currentColor;
}
.expandable__icon::before { left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px; }
.expandable__icon::after  { top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; }
.expandable.is-expanded .expandable__icon::after { display: none; }
