/* ==========================================================================
   PANEL DE ADMINISTRACIÓN — HOJA DE ESTILOS
   --------------------------------------------------------------------------
   Los colores NO están escritos aquí: se inyectan como variables CSS desde
   Ajustes → Apariencia (véase app/Views/layouts/app.php). Esta hoja solo
   define la estructura, la tipografía y el comportamiento adaptable.

   Puntos de ruptura verificados:
   320 · 360 · 375 · 390 · 414 · 480 · 576 · 768 · 820 · 900 · 1024 · 1080
   1280 · 1440 · 1600 · 1920+
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Reinicio y variables de estructura
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --sidebar-w: 268px;
    --sidebar-w-compact: 76px;
    --header-h: 64px;
    --gap: 20px;
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .18);
    --shadow: 0 8px 26px -12px rgba(0, 0, 0, .45);
    --shadow-lg: 0 28px 70px -28px rgba(0, 0, 0, .7);
    --transition: .22s cubic-bezier(.4, 0, .2, 1);
    --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
    --ok: #3E9C6D;
    --warn: #D9A03C;
    --danger: #C7524A;
    --info: #4A79C7;
}

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

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Evita cualquier desbordamiento horizontal en móvil */
    overflow-x: hidden;
}

img,
svg,
video {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary);
}

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
}

p {
    margin: 0 0 12px;
}

p:last-child {
    margin-bottom: 0;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 22px 0;
}

code, kbd, pre {
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Consolas, 'Liberation Mono', monospace;
    font-size: .88em;
}

code {
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 6px;
    color: var(--primary-light);
    word-break: break-word;
}

pre {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    overflow-x: auto;
    margin: 0;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--muted);
    white-space: pre-wrap;
    word-break: break-word;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

::selection {
    background: var(--primary);
    color: #fff;
}

/* Barras de desplazamiento discretas */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

*::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 99px;
}

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

.skip-link {
    position: absolute;
    left: -9999px;
    top: 8px;
    z-index: 1000;
    background: var(--primary);
    color: #fff;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.skip-link:focus {
    left: 8px;
    color: #fff;
}

/* --------------------------------------------------------------------------
   2. Estructura general
   -------------------------------------------------------------------------- */
.layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.main {
    flex: 1 1 auto;
    min-width: 0; /* imprescindible para que las tablas no desborden el flex */
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-w);
    transition: margin-left var(--transition);
}

.content {
    flex: 1 1 auto;
    padding: clamp(16px, 2.4vw, 30px);
    max-width: 1560px;
    width: 100%;
    margin: 0 auto;
}

/* --------------------------------------------------------------------------
   3. Barra lateral
   -------------------------------------------------------------------------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 60;
    transition: transform var(--transition);
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 16px 18px;
    min-height: var(--header-h);
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}

.sidebar__logo {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    object-fit: cover;
    background: var(--surface-2);
    flex: 0 0 auto;
}

.sidebar__logo--fallback {
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: .5px;
}

.sidebar__names {
    min-width: 0;
    flex: 1 1 auto;
}

.sidebar__title {
    font-family: var(--font-display);
    font-size: 16.5px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
    /* El nombre del restaurante es dinámico: puede ser muy largo */
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar__subtitle {
    font-size: 11px;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--muted);
    display: block;
}

.sidebar__close {
    display: none;
    background: none;
    border: 0;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    flex: 0 0 auto;
}

.sidebar__close:hover {
    color: var(--text);
    background: var(--surface-2);
}

.sidebar__nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px 12px 20px;
    -webkit-overflow-scrolling: touch;
}

.nav-group {
    margin-bottom: 6px;
}

.nav-group__label {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 14px 12px 7px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    position: relative;
}

.nav-link i {
    width: 18px;
    text-align: center;
    font-size: 14.5px;
    flex: 0 0 auto;
}

.nav-link span {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-link:hover {
    background: var(--surface-2);
    color: var(--text);
}

.nav-link.is-active {
    background: var(--primary-soft);
    color: var(--primary-light);
    font-weight: 600;
}

.nav-link.is-active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    border-radius: 0 3px 3px 0;
    background: var(--primary);
}

.nav-badge {
    flex: 0 0 auto;
    min-width: 21px;
    height: 21px;
    padding: 0 6px;
    border-radius: 99px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.sidebar__footer {
    flex: 0 0 auto;
    padding: 12px 14px 16px;
    border-top: 1px solid var(--border);
    font-size: 11.5px;
    color: var(--muted);
}

.sidebar__footer strong {
    color: var(--text);
    font-weight: 600;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .58);
    backdrop-filter: blur(2px);
    z-index: 55;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
}

/* --------------------------------------------------------------------------
   4. Cabecera
   -------------------------------------------------------------------------- */
.header {
    position: sticky;
    top: 0;
    z-index: 40;
    min-height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px clamp(14px, 2.2vw, 26px);
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.header__burger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 17px;
    cursor: pointer;
    flex: 0 0 auto;
    transition: background var(--transition);
}

.header__burger:hover {
    background: var(--border);
}

.header__title {
    flex: 1 1 auto;
    min-width: 0;
}

.header__title h1 {
    font-size: clamp(16px, 2.1vw, 20px);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header__title p {
    margin: 1px 0 0;
    font-size: 12.5px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header__brand-mobile {
    display: none;
    align-items: center;
    gap: 9px;
    min-width: 0;
    flex: 1 1 auto;
}

.header__brand-mobile img,
.header__brand-mobile .sidebar__logo--fallback {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    flex: 0 0 auto;
}

.header__brand-mobile span {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.icon-btn {
    position: relative;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 15.5px;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

.icon-btn:hover {
    background: var(--border);
    color: var(--text);
}

.icon-btn__dot {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 99px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 2px solid var(--surface);
}

/* Menú de usuario y campana */
.dropdown {
    position: relative;
}

.dropdown__toggle {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 5px 11px 5px 5px;
    border: 1px solid var(--border);
    border-radius: 99px;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    font-size: 13.5px;
    transition: background var(--transition);
}

.dropdown__toggle:hover {
    background: var(--border);
}

.avatar {
    width: 31px;
    height: 31px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 12.5px;
    font-weight: 700;
    flex: 0 0 auto;
    text-transform: uppercase;
}

.dropdown__name {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.dropdown__menu {
    position: absolute;
    top: calc(100% + 9px);
    right: 0;
    min-width: 250px;
    max-width: calc(100vw - 24px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 7px;
    z-index: 70;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
}

.dropdown.is-open .dropdown__menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown__menu--wide {
    min-width: 330px;
}

.dropdown__header {
    padding: 11px 13px 9px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 5px;
}

.dropdown__header strong {
    display: block;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown__header small {
    color: var(--muted);
    font-size: 12px;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown__item {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 10px 13px;
    border: 0;
    border-radius: 9px;
    background: none;
    color: var(--text);
    font-family: inherit;
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition);
}

.dropdown__item i {
    width: 16px;
    text-align: center;
    color: var(--muted);
    flex: 0 0 auto;
}

.dropdown__item:hover {
    background: var(--surface-2);
    color: var(--text);
}

.dropdown__item--danger {
    color: var(--danger);
}

.dropdown__item--danger i {
    color: var(--danger);
}

.dropdown__divider {
    height: 1px;
    background: var(--border);
    margin: 5px 0;
}

/* Lista de notificaciones del desplegable */
.notif-list {
    max-height: min(58vh, 420px);
    overflow-y: auto;
    margin: 0 -2px;
}

.notif {
    display: flex;
    gap: 11px;
    padding: 11px 12px;
    border-radius: 10px;
    transition: background var(--transition);
}

.notif:hover {
    background: var(--surface-2);
}

.notif.is-unread {
    background: var(--primary-softer);
}

.notif__icon {
    width: 33px;
    height: 33px;
    border-radius: 10px;
    background: var(--surface-2);
    display: grid;
    place-items: center;
    font-size: 14px;
    flex: 0 0 auto;
}

.notif__body {
    min-width: 0;
    flex: 1 1 auto;
}

.notif__title {
    font-size: 13.5px;
    font-weight: 600;
    margin: 0 0 2px;
    color: var(--text);
}

.notif__text {
    font-size: 12.5px;
    color: var(--muted);
    margin: 0;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.notif__time {
    font-size: 11px;
    color: var(--muted);
    margin-top: 3px;
    display: block;
}

/* --------------------------------------------------------------------------
   5. Tarjetas y bloques
   -------------------------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: var(--gap);
    margin-bottom: var(--gap);
}

.card + .card {
    margin-top: var(--gap);
    margin-bottom: var(--gap);
}

.card__head {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 16px clamp(14px, 2vw, 22px);
    border-bottom: 1px solid var(--border);
}

.card__head-text {
    flex: 1 1 260px;
    min-width: 0;
}

.card__head h2 {
    font-size: 15.5px;
    font-weight: 600;
}

.card__head p {
    margin: 3px 0 0;
    font-size: 12.8px;
    color: var(--muted);
    line-height: 1.55;
}

.card__head-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 0 0 auto;
}

.card__body {
    padding: clamp(14px, 2vw, 22px);
}

.card__body--flush {
    padding: 0;
}

.card__foot {
    padding: 14px clamp(14px, 2vw, 22px);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    background: var(--surface-2);
}

.card__foot--end {
    justify-content: flex-end;
}

/* Rejillas reutilizables */
.grid {
    display: grid;
    gap: var(--gap);
    margin-top: 10px;
    margin-bottom: 10px;
}

.grid--stats {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.grid--2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid--3 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid--main {
    grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr);
    align-items: start;
}

/* Tarjetas de estadística */
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 17px 18px;
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 0;
}

.stat__icon {
    width: 46px;
    height: 46px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    font-size: 18px;
    flex: 0 0 auto;
    background: var(--primary-soft);
    color: var(--primary-light);
}

.stat__icon--ok {
    background: rgba(62, 156, 109, .16);
    color: var(--ok);
}

.stat__icon--warn {
    background: rgba(217, 160, 60, .16);
    color: var(--warn);
}

.stat__icon--danger {
    background: rgba(199, 82, 74, .16);
    color: var(--danger);
}

.stat__icon--info {
    background: rgba(74, 121, 199, .16);
    color: var(--info);
}

.stat__body {
    min-width: 0;
}

.stat__value {
    font-size: clamp(22px, 3vw, 27px);
    font-weight: 700;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.stat__label {
    font-size: 12.3px;
    color: var(--muted);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Barra de ocupación */
.meter {
    height: 9px;
    border-radius: 99px;
    background: var(--surface-2);
    overflow: hidden;
    border: 1px solid var(--border);
}

.meter__fill {
    height: 100%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--primary-light), var(--primary));
    transition: width .5s ease;
}

.meter__fill--warn {
    background: linear-gradient(90deg, #E0B356, var(--warn));
}

.meter__fill--danger {
    background: linear-gradient(90deg, #D8756D, var(--danger));
}

/* --------------------------------------------------------------------------
   6. Botones
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--button);
    color: #fff;
    font-family: inherit;
    font-size: 13.8px;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
    transition: filter var(--transition), background var(--transition), border-color var(--transition), transform var(--transition);
    white-space: nowrap;
    text-align: center;
}

.btn:hover:not(:disabled) {
    filter: brightness(1.1);
    color: #fff;
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn:disabled,
.btn.is-loading {
    opacity: .6;
    cursor: not-allowed;
}

.btn i {
    font-size: 13px;
}

.btn--ghost {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text);
}

.btn--ghost:hover:not(:disabled) {
    background: var(--border);
    color: var(--text);
    filter: none;
}

.btn--outline {
    background: transparent;
    border-color: var(--primary);
    color: var(--primary-light);
}

.btn--outline:hover:not(:disabled) {
    background: var(--primary-softer);
    color: var(--primary-light);
    filter: none;
}

.btn--ok {
    background: var(--ok);
}

.btn--danger {
    background: var(--danger);
}

.btn--warn {
    background: var(--warn);
    color: #1c1b19;
}

.btn--warn:hover:not(:disabled) {
    color: #1c1b19;
}

.btn--sm {
    padding: 7px 13px;
    font-size: 12.6px;
    border-radius: 9px;
}

.btn--lg {
    padding: 13px 26px;
    font-size: 15px;
}

.btn--block {
    width: 100%;
}

.btn--icon {
    padding: 9px 11px;
}

.btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.btn-row--end {
    justify-content: flex-end;
}

/* --------------------------------------------------------------------------
   7. Formularios
   -------------------------------------------------------------------------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 17px 18px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field--full {
    grid-column: 1 / -1;
}

.field > label,
.field__label {
    font-size: 12.8px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

.field > label i,
.field__label i {
    color: var(--primary-light);
    font-size: 12px;
}

.field__optional {
    color: var(--muted);
    font-weight: 400;
    font-size: 11.5px;
}

.field__hint {
    font-size: 11.8px;
    color: var(--muted);
    line-height: 1.55;
}

.field__error {
    font-size: 12px;
    color: var(--danger);
    font-weight: 500;
}

input[type='text'],
input[type='email'],
input[type='tel'],
input[type='url'],
input[type='number'],
input[type='password'],
input[type='date'],
input[type='time'],
input[type='search'],
input[type='color'],
select,
textarea {
    width: 100%;
    min-width: 0;
    padding: 10px 13px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    /* Evita el zoom automático en iOS: 16px es el mínimo seguro */
    -webkit-appearance: none;
    appearance: none;
}

input[type='color'] {
    padding: 4px;
    height: 42px;
    cursor: pointer;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%239a978f' d='M1.4 0 6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    padding-right: 36px;
    cursor: pointer;
}

textarea {
    resize: vertical;
    min-height: 88px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

input::placeholder,
textarea::placeholder {
    color: var(--muted);
    opacity: .72;
}

input:disabled,
select:disabled,
textarea:disabled {
    opacity: .6;
    cursor: not-allowed;
}

input[type='date'],
input[type='time'] {
    color-scheme: dark;
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea {
    border-color: var(--danger);
}

/* Grupo con botón adjunto */
.input-group {
    display: flex;
    gap: 8px;
    align-items: stretch;
    flex-wrap: wrap;
}

.input-group > input,
.input-group > select {
    flex: 1 1 190px;
    min-width: 0;
}

.input-group > .btn {
    flex: 0 0 auto;
}

/* Casillas e interruptores */
.check {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    cursor: pointer;
    padding: 4px 0;
}

.check input[type='checkbox'],
.check input[type='radio'] {
    width: 19px;
    height: 19px;
    margin: 1px 0 0;
    flex: 0 0 auto;
    accent-color: var(--primary);
    cursor: pointer;
}

.check__text {
    min-width: 0;
}

.check__text strong {
    display: block;
    font-size: 13.6px;
    font-weight: 600;
}

.check__text small {
    display: block;
    font-size: 11.8px;
    color: var(--muted);
    line-height: 1.55;
    margin-top: 1px;
}

.switch {
    display: flex;
    align-items: center;
    gap: 13px;
    cursor: pointer;
    padding: 3px 0;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.switch__track {
    width: 46px;
    height: 26px;
    border-radius: 99px;
    background: var(--border-strong);
    position: relative;
    flex: 0 0 auto;
    transition: background var(--transition);
}

.switch__track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    transition: transform var(--transition);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

.switch input:checked + .switch__track {
    background: var(--primary);
}

.switch input:checked + .switch__track::after {
    transform: translateX(20px);
}

.switch input:focus-visible + .switch__track {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.switch__label {
    min-width: 0;
}

.switch__label strong {
    display: block;
    font-size: 13.6px;
    font-weight: 600;
}

.switch__label small {
    display: block;
    font-size: 11.8px;
    color: var(--muted);
    line-height: 1.55;
}

/* Subida de imágenes con vista previa */
.upload {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.upload__preview {
    width: 92px;
    height: 92px;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border-strong);
    background: var(--surface-2);
    display: grid;
    place-items: center;
    overflow: hidden;
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 20px;
}

.upload__preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
}

.upload__controls {
    flex: 1 1 210px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

input[type='file'] {
    width: 100%;
    font-size: 13px;
    color: var(--muted);
    padding: 8px;
    border: 1px dashed var(--border-strong);
    border-radius: 10px;
    background: var(--input-bg);
    cursor: pointer;
}

input[type='file']::file-selector-button {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 7px 13px;
    border-radius: 8px;
    margin-right: 11px;
    font-family: inherit;
    font-size: 12.6px;
    cursor: pointer;
}

/* Selector de color con muestra */
.color-field {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-field input[type='color'] {
    width: 52px;
    flex: 0 0 auto;
}

.color-field input[type='text'] {
    flex: 1 1 100px;
    min-width: 0;
    font-family: ui-monospace, monospace;
    text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   8. Tablas
   -------------------------------------------------------------------------- */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.6px;
}

.table th,
.table td {
    padding: 12px 14px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-size: 11.3px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-2);
    white-space: nowrap;
}

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

.table tbody tr:hover {
    background: var(--surface-2);
}

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

.table__actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.table td.is-numeric {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.table__main {
    font-weight: 600;
    color: var(--text);
}

.table__sub {
    font-size: 12px;
    color: var(--muted);
    display: block;
    margin-top: 1px;
    overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   9. Etiquetas de estado
   -------------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border-radius: 99px;
    font-size: 11.8px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    border: 1px solid transparent;
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
}

.badge--pendiente {
    background: rgba(217, 160, 60, .15);
    color: var(--warn);
    border-color: rgba(217, 160, 60, .32);
}

.badge--confirmada {
    background: rgba(62, 156, 109, .15);
    color: var(--ok);
    border-color: rgba(62, 156, 109, .32);
}

.badge--cancelada {
    background: rgba(199, 82, 74, .15);
    color: var(--danger);
    border-color: rgba(199, 82, 74, .32);
}

.badge--completada {
    background: rgba(74, 121, 199, .15);
    color: var(--info);
    border-color: rgba(74, 121, 199, .32);
}

.badge--no_presentado {
    background: rgba(154, 151, 143, .18);
    color: var(--muted);
    border-color: var(--border-strong);
}

.badge--neutral {
    background: var(--surface-2);
    color: var(--muted);
    border-color: var(--border);
}

.badge--neutral::before {
    display: none;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 11.8px;
    color: var(--muted);
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   10. Avisos
   -------------------------------------------------------------------------- */
.alert {
    display: flex;
    gap: 12px;
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 13.4px;
    line-height: 1.6;
    margin-bottom: var(--gap);
    align-items: flex-start;
}

.alert i {
    font-size: 15px;
    margin-top: 2px;
    flex: 0 0 auto;
}

.alert__body {
    min-width: 0;
    flex: 1 1 auto;
    overflow-wrap: anywhere;
}

.alert__body strong {
    display: block;
    margin-bottom: 2px;
}

.alert--success {
    border-color: rgba(62, 156, 109, .40);
    background: rgba(62, 156, 109, .11);
    color: var(--text);
}

.alert--success i {
    color: var(--ok);
}

.alert--error {
    border-color: rgba(199, 82, 74, .40);
    background: rgba(199, 82, 74, .11);
}

.alert--error i {
    color: var(--danger);
}

.alert--warning {
    border-color: rgba(217, 160, 60, .40);
    background: rgba(217, 160, 60, .11);
}

.alert--warning i {
    color: var(--warn);
}

.alert--info {
    border-color: rgba(74, 121, 199, .40);
    background: rgba(74, 121, 199, .11);
}

.alert--info i {
    color: var(--info);
}

.alert__close {
    background: none;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    font-size: 15px;
    padding: 0 2px;
    flex: 0 0 auto;
}

/* Notificaciones flotantes */
.toasts {
    position: fixed;
    top: 14px;
    right: 14px;
    left: 14px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 9px;
    pointer-events: none;
    align-items: flex-end;
}

.toast {
    pointer-events: auto;
    max-width: 420px;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 12px 15px;
    display: flex;
    gap: 11px;
    align-items: flex-start;
    font-size: 13.4px;
    animation: toast-in .28s cubic-bezier(.34, 1.4, .64, 1) both;
}

.toast--success {
    border-left-color: var(--ok);
}

.toast--error {
    border-left-color: var(--danger);
}

.toast--warning {
    border-left-color: var(--warn);
}

.toast__body {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* --------------------------------------------------------------------------
   11. Ventanas modales
   -------------------------------------------------------------------------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 150;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, .62);
    backdrop-filter: blur(3px);
    overflow-y: auto;
}

.modal.is-open {
    display: flex;
}

.modal__dialog {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 540px;
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    margin: auto;
    animation: modal-in .24s cubic-bezier(.34, 1.3, .64, 1) both;
}

.modal__dialog--wide {
    max-width: 860px;
}

.modal__head {
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    gap: 14px;
    flex: 0 0 auto;
}

.modal__head h3 {
    font-size: 16px;
    flex: 1 1 auto;
    min-width: 0;
}

.modal__head p {
    margin: 3px 0 0;
    font-size: 12.8px;
    color: var(--muted);
}

.modal__close {
    background: none;
    border: 0;
    color: var(--muted);
    font-size: 19px;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 7px;
    flex: 0 0 auto;
}

.modal__close:hover {
    color: var(--text);
    background: var(--surface-2);
}

.modal__body {
    padding: 20px 22px;
    overflow-y: auto;
    flex: 1 1 auto;
}

.modal__foot {
    padding: 15px 22px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
    flex: 0 0 auto;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(14px) scale(.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* --------------------------------------------------------------------------
   12. Filtros y paginación
   -------------------------------------------------------------------------- */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
    gap: 12px;
    align-items: end;
}

.filters__actions {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
}

.pagination {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.pagination a,
.pagination span {
    min-width: 38px;
    height: 38px;
    padding: 0 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 13.2px;
    font-weight: 500;
}

.pagination a:hover {
    background: var(--border);
    color: var(--text);
}

.pagination .is-current {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}

.pagination .is-disabled {
    opacity: .4;
    cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   13. Calendario
   -------------------------------------------------------------------------- */
.calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
}

.calendar__dow {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 6px 0;
}

.calendar__day {
    position: relative;
    min-height: 84px;
    padding: 7px 8px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-2);
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--text);
    transition: border-color var(--transition), background var(--transition);
    overflow: hidden;
}

.calendar__day:hover {
    border-color: var(--primary);
    color: var(--text);
}

.calendar__day--empty {
    background: transparent;
    border-color: transparent;
    pointer-events: none;
}

.calendar__day--closed {
    background: repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(154, 151, 143, .08) 5px, rgba(154, 151, 143, .08) 10px);
}

.calendar__day--today {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary) inset;
}

.calendar__num {
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.calendar__day--today .calendar__num {
    color: var(--primary-light);
}

.calendar__meta {
    font-size: 10.8px;
    color: var(--muted);
    line-height: 1.4;
}

.calendar__dots {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    margin-top: auto;
}

.calendar__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
}

.calendar__dot--pendiente {
    background: var(--warn);
}

.calendar__dot--confirmada {
    background: var(--ok);
}

/* Cronología del día */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.timeline__item {
    display: flex;
    gap: 14px;
    padding: 13px 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border-left: 3px solid var(--primary);
    align-items: flex-start;
}

.timeline__item--pendiente {
    border-left-color: var(--warn);
}

.timeline__item--confirmada {
    border-left-color: var(--ok);
}

.timeline__item--cancelada {
    border-left-color: var(--danger);
    opacity: .62;
}

.timeline__time {
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    flex: 0 0 52px;
}

.timeline__body {
    flex: 1 1 auto;
    min-width: 0;
}

.timeline__title {
    font-size: 13.8px;
    font-weight: 600;
    margin: 0 0 2px;
    overflow-wrap: anywhere;
}

.timeline__meta {
    font-size: 12.2px;
    color: var(--muted);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   14. Ajustes: navegación por secciones
   -------------------------------------------------------------------------- */
.settings-layout {
    display: grid;
    grid-template-columns: 244px minmax(0, 1fr);
    gap: var(--gap);
    align-items: start;
}

.settings-nav {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    position: sticky;
    top: calc(var(--header-h) + 16px);
    max-height: calc(100vh - var(--header-h) - 32px);
    overflow-y: auto;
}

.settings-nav__group {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 12px 12px 6px;
}

.settings-nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 9px;
    color: var(--muted);
    font-size: 13.4px;
    font-weight: 500;
}

.settings-nav a i {
    width: 16px;
    text-align: center;
    font-size: 13px;
    flex: 0 0 auto;
}

.settings-nav a span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-nav a:hover {
    background: var(--surface-2);
    color: var(--text);
}

.settings-nav a.is-active {
    background: var(--primary-soft);
    color: var(--primary-light);
    font-weight: 600;
}

/* Selector desplegable de sección para pantallas pequeñas */
.settings-select {
    display: none;
    margin-bottom: var(--gap);
}

/* Cuadrícula de accesos de Ajustes */
.settings-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
    gap: 14px;
}

.settings-card {
    display: flex;
    gap: 13px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--transition), transform var(--transition);
    align-items: flex-start;
}

.settings-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    color: var(--text);
}

.settings-card__icon {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: var(--primary-soft);
    color: var(--primary-light);
    font-size: 16px;
    flex: 0 0 auto;
}

.settings-card__body {
    min-width: 0;
}

.settings-card__body strong {
    display: block;
    font-size: 14px;
    margin-bottom: 2px;
}

.settings-card__body small {
    display: block;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.5;
}

/* Estado de las integraciones */
.status-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.status-row:last-child {
    border-bottom: 0;
}

.status-row__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: 0 0 auto;
    background: var(--muted);
}

.status-row__dot--ok {
    background: var(--ok);
    box-shadow: 0 0 0 3px rgba(62, 156, 109, .22);
}

.status-row__dot--off {
    background: var(--warn);
    box-shadow: 0 0 0 3px rgba(217, 160, 60, .22);
}

.status-row__body {
    flex: 1 1 220px;
    min-width: 0;
}

.status-row__body strong {
    display: block;
    font-size: 13.6px;
}

.status-row__body small {
    display: block;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.55;
    overflow-wrap: anywhere;
}

/* Lista de definición para datos técnicos */
.datalist {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 13px 20px;
}

.datalist__item {
    min-width: 0;
}

.datalist__label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    margin-bottom: 2px;
}

.datalist__value {
    font-size: 13.8px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

/* Tabla de horarios semanales */
.hours-day {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    overflow: hidden;
}

.hours-day__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 15px;
    background: var(--surface-2);
    flex-wrap: wrap;
}

.hours-day__name {
    font-size: 14px;
    font-weight: 600;
    flex: 1 1 auto;
    min-width: 90px;
}

.hours-day__body {
    padding: 12px 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.shift-row {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)) auto;
    gap: 9px;
    align-items: end;
}

.shift-row__labels {
    display: none;
}

/* Etiquetas de variables de plantilla */
.var-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.var-tag {
    font-family: ui-monospace, monospace;
    font-size: 11.6px;
    padding: 4px 9px;
    border-radius: 7px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--primary-light);
    cursor: pointer;
    transition: border-color var(--transition);
}

.var-tag:hover {
    border-color: var(--primary);
}

/* Estado vacío */
.empty {
    text-align: center;
    padding: clamp(30px, 6vw, 54px) 20px;
}

.empty__icon {
    width: 62px;
    height: 62px;
    border-radius: 18px;
    margin: 0 auto 16px;
    display: grid;
    place-items: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 23px;
}

.empty h3 {
    font-size: 16px;
    margin-bottom: 7px;
}

.empty p {
    color: var(--muted);
    font-size: 13.6px;
    max-width: 430px;
    margin: 0 auto 20px;
    line-height: 1.65;
}

/* --------------------------------------------------------------------------
   15. Autenticación e instalador
   -------------------------------------------------------------------------- */
.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px 16px;
    position: relative;
    overflow: hidden;
}

.auth__glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: .17;
    pointer-events: none;
    background: var(--primary);
}

.auth__glow--a {
    width: 420px;
    height: 420px;
    top: -140px;
    left: -110px;
}

.auth__glow--b {
    width: 360px;
    height: 360px;
    bottom: -150px;
    right: -90px;
}

.auth__card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 428px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: clamp(24px, 5vw, 40px);
    box-shadow: var(--shadow-lg);
}

.auth__brand {
    text-align: center;
    margin-bottom: 26px;
}

.auth__logo {
    width: 66px;
    height: 66px;
    border-radius: 19px;
    margin: 0 auto 15px;
    object-fit: cover;
    background: var(--surface-2);
}

.auth__logo--fallback {
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: #fff;
    font-size: 25px;
    font-weight: 700;
}

.auth__brand h1 {
    font-family: var(--font-display);
    font-size: clamp(21px, 4.5vw, 26px);
    margin-bottom: 5px;
    overflow-wrap: anywhere;
}

.auth__brand p {
    color: var(--muted);
    font-size: 13.4px;
    margin: 0;
}

.auth__footer {
    text-align: center;
    margin-top: 22px;
    font-size: 12px;
    color: var(--muted);
}

.password-wrap {
    position: relative;
}

.password-wrap input {
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    background: none;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    padding: 7px 9px;
    font-size: 14px;
    border-radius: 7px;
}

.password-toggle:hover {
    color: var(--text);
}

/* Pasos del instalador */
.steps {
    display: flex;
    gap: 6px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.steps__item {
    flex: 1 1 74px;
    text-align: center;
    font-size: 11.4px;
    color: var(--muted);
    padding-top: 10px;
    border-top: 3px solid var(--border);
    min-width: 0;
}

.steps__item.is-active {
    color: var(--primary-light);
    border-top-color: var(--primary);
    font-weight: 600;
}

.steps__item.is-done {
    color: var(--ok);
    border-top-color: var(--ok);
}

.req-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.req {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13.4px;
    flex-wrap: wrap;
}

.req:last-child {
    border-bottom: 0;
}

.req__icon {
    width: 22px;
    text-align: center;
    flex: 0 0 auto;
}

.req__icon--ok {
    color: var(--ok);
}

.req__icon--warn {
    color: var(--warn);
}

.req__icon--err {
    color: var(--danger);
}

.req__name {
    flex: 1 1 190px;
    min-width: 0;
}

.req__name small {
    display: block;
    font-size: 11.6px;
    color: var(--muted);
    line-height: 1.5;
}

.req__value {
    font-size: 12.4px;
    color: var(--muted);
    font-family: ui-monospace, monospace;
    flex: 0 0 auto;
}

/* --------------------------------------------------------------------------
   16. Indicador de conexión (PWA)
   -------------------------------------------------------------------------- */
.offline-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 190;
    background: var(--warn);
    color: #1c1b19;
    text-align: center;
    padding: 10px 16px;
    font-size: 13.2px;
    font-weight: 600;
    transform: translateY(100%);
    transition: transform var(--transition);
}

body.is-offline .offline-bar {
    transform: translateY(0);
}

body.is-offline .btn[data-requires-online],
body.is-offline button[type='submit'] {
    opacity: .5;
    pointer-events: none;
}

.install-prompt {
    display: none;
    align-items: center;
    gap: 13px;
    padding: 14px 16px;
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    background: var(--primary-softer);
    margin-bottom: var(--gap);
    flex-wrap: wrap;
}

.install-prompt.is-visible {
    display: flex;
}

/* --------------------------------------------------------------------------
   17. Utilidades
   -------------------------------------------------------------------------- */
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 8px !important; }
.mt-2 { margin-top: 16px !important; }
.mt-3 { margin-top: 24px !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 8px !important; }
.mb-2 { margin-bottom: 16px !important; }
.mb-3 { margin-bottom: 24px !important; }

.text-muted { color: var(--muted) !important; }
.text-ok { color: var(--ok) !important; }
.text-danger { color: var(--danger) !important; }
.text-warn { color: var(--warn) !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-sm { font-size: 12.5px !important; }
.text-xs { font-size: 11.5px !important; }
.fw-600 { font-weight: 600 !important; }
.nowrap { white-space: nowrap !important; }
.break-all { overflow-wrap: anywhere !important; }

.flex { display: flex !important; }
.flex-col { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.items-center { align-items: center !important; }
.justify-between { justify-content: space-between !important; }
.gap-1 { gap: 8px !important; }
.gap-2 { gap: 16px !important; }
.w-full { width: 100% !important; }
.hidden { display: none !important; }

.divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
}

.section-title {
    font-size: 12.4px;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 26px 0 13px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.section-title:first-child {
    margin-top: 0;
}

.spinner {
    display: inline-block;
    width: 15px;
    height: 15px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: -2px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   18. DISEÑO ADAPTABLE
   ========================================================================== */

/* ---- Pantallas muy grandes: 1600px y superiores ---- */
@media (min-width: 1600px) {
    :root {
        --sidebar-w: 284px;
        --gap: 24px;
    }

    body {
        font-size: 15px;
    }
}

/* ---- Portátiles: hasta 1280px ---- */
@media (max-width: 1280px) {
    :root {
        --sidebar-w: 248px;
    }

    .grid--main {
        grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    }
}

/* ---- 1080px: el punto crítico indicado en los requisitos ------------------
   A partir de aquí la barra lateral pasa a ser deslizante y aparece el menú
   hamburguesa; el contenido ocupa todo el ancho disponible.                */
@media (max-width: 1080px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
        width: min(300px, 86vw);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .sidebar__close {
        display: block;
    }

    .main {
        margin-left: 0;
    }

    .header__burger {
        display: inline-flex;
    }

    .header__title {
        display: none;
    }

    .header__brand-mobile {
        display: flex;
    }

    /* La navegación de Ajustes se convierte en un desplegable */
    .settings-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .settings-nav {
        display: none;
    }

    .settings-select {
        display: block;
    }

    .grid--main {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---- Tablet: hasta 900px ---- */
@media (max-width: 900px) {
    :root {
        --gap: 16px;
        --header-h: 60px;
    }

    .content {
        padding: 16px 14px 28px;
    }

    .grid--stats {
        grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
    }

    .stat {
        padding: 14px 15px;
        gap: 12px;
    }

    .stat__icon {
        width: 41px;
        height: 41px;
        font-size: 16px;
    }

    .shift-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .shift-row > .btn {
        grid-column: 1 / -1;
    }
}

/* ---- Móvil grande y tablet vertical: hasta 768px ---- */
@media (max-width: 768px) {
    .card__head {
        padding: 14px 15px;
    }

    .card__head-actions {
        width: 100%;
    }

    .card__head-actions .btn {
        flex: 1 1 auto;
    }

    .form-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 15px;
    }

    .modal__dialog {
        max-width: 100%;
        border-radius: var(--radius);
    }

    .modal__head,
    .modal__body,
    .modal__foot {
        padding-left: 17px;
        padding-right: 17px;
    }

    .modal__foot .btn {
        flex: 1 1 auto;
    }

    /* --------------------------------------------------------------------
       Tablas apiladas: cada fila se convierte en una tarjeta legible.
       Se usa el atributo data-label de cada celda como título.
       -------------------------------------------------------------------- */
    .table--stack thead {
        display: none;
    }

    .table--stack,
    .table--stack tbody,
    .table--stack tr,
    .table--stack td {
        display: block;
        width: 100%;
    }

    .table--stack tr {
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        margin: 0 0 11px;
        padding: 12px 14px;
        background: var(--surface-2);
    }

    .table--stack tr:last-child {
        margin-bottom: 0;
    }

    .table--stack td {
        border: 0;
        padding: 5px 0;
        display: flex;
        gap: 12px;
        align-items: flex-start;
        justify-content: space-between;
        text-align: right;
    }

    .table--stack td::before {
        content: attr(data-label);
        font-size: 11.2px;
        font-weight: 600;
        letter-spacing: .05em;
        text-transform: uppercase;
        color: var(--muted);
        text-align: left;
        flex: 0 0 40%;
        max-width: 40%;
    }

    .table--stack td.is-numeric {
        text-align: right;
    }

    .table--stack td:empty {
        display: none;
    }

    .table--stack .table__actions {
        justify-content: flex-end;
        width: 100%;
    }

    .table--stack .table__sub {
        text-align: right;
    }

    .calendar {
        gap: 4px;
    }

    .calendar__day {
        min-height: 62px;
        padding: 5px 6px;
    }

    .calendar__meta {
        display: none;
    }

    .toasts {
        top: auto;
        bottom: 14px;
        align-items: stretch;
    }

    .toast {
        max-width: none;
    }

    .settings-cards {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

/* ---- Móvil: hasta 576px ---- */
@media (max-width: 576px) {
    :root {
        --gap: 14px;
        --radius: 12px;
        --radius-lg: 16px;
    }

    body {
        font-size: 14px;
    }

    .content {
        padding: 14px 12px 26px;
    }

    .header {
        padding: 9px 12px;
        gap: 9px;
    }

    .dropdown__name {
        display: none;
    }

    .dropdown__toggle {
        padding: 5px;
        border-radius: 50%;
    }

    .dropdown__menu {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        min-width: 0;
        max-width: none;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        border-bottom: 0;
        padding: 10px 10px 18px;
        transform: translateY(100%);
        max-height: 82vh;
        overflow-y: auto;
    }

    .dropdown.is-open .dropdown__menu {
        transform: translateY(0);
    }

    .dropdown__item {
        padding: 13px;
        font-size: 14.5px;
    }

    .grid--stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat {
        flex-direction: column;
        align-items: flex-start;
        gap: 9px;
        padding: 13px;
    }

    .stat__icon {
        width: 36px;
        height: 36px;
        font-size: 14px;
        border-radius: 10px;
    }

    .stat__value {
        font-size: 21px;
    }

    .stat__label {
        white-space: normal;
        font-size: 11.6px;
        line-height: 1.35;
    }

    .filters {
        grid-template-columns: minmax(0, 1fr);
    }

    .filters__actions .btn {
        flex: 1 1 auto;
    }

    .settings-cards {
        grid-template-columns: minmax(0, 1fr);
    }

    .btn-row .btn {
        flex: 1 1 auto;
    }

    .card__foot {
        padding: 13px 15px;
    }

    .card__foot .btn {
        flex: 1 1 auto;
    }

    .shift-row {
        grid-template-columns: minmax(0, 1fr);
    }

    .timeline__item {
        flex-direction: column;
        gap: 6px;
    }

    .timeline__time {
        flex: 0 0 auto;
    }

    .datalist {
        grid-template-columns: minmax(0, 1fr);
    }

    /* En iOS un tamaño menor de 16px provoca zoom automático al enfocar */
    input[type='text'],
    input[type='email'],
    input[type='tel'],
    input[type='url'],
    input[type='number'],
    input[type='password'],
    input[type='date'],
    input[type='time'],
    input[type='search'],
    select,
    textarea {
        font-size: 16px;
    }

    .table--stack td::before {
        flex-basis: 42%;
        max-width: 42%;
    }
}

/* ---- Móvil pequeño: hasta 414px ---- */
@media (max-width: 414px) {
    .calendar {
        gap: 3px;
    }

    .calendar__day {
        min-height: 52px;
        border-radius: 8px;
    }

    .calendar__dow {
        font-size: 9.6px;
        letter-spacing: 0;
    }

    .card__head h2 {
        font-size: 14.6px;
    }
}

/* ---- Móvil mínimo: hasta 360px (incluye 320px) ---- */
@media (max-width: 360px) {
    :root {
        --gap: 12px;
    }

    .content {
        padding: 12px 10px 22px;
    }

    .grid--stats {
        grid-template-columns: minmax(0, 1fr);
    }

    .stat {
        flex-direction: row;
        align-items: center;
    }

    .header__brand-mobile span {
        font-size: 13.6px;
    }

    .icon-btn,
    .header__burger {
        width: 38px;
        height: 38px;
        font-size: 14.5px;
        border-radius: 10px;
    }

    .btn {
        padding: 10px 14px;
        font-size: 13.2px;
    }

    .badge {
        padding: 3px 9px;
        font-size: 11px;
    }

    .calendar__day {
        min-height: 44px;
        padding: 4px;
    }

    .calendar__num {
        font-size: 11.6px;
    }

    .table--stack td {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        gap: 2px;
    }

    .table--stack td::before {
        flex-basis: auto;
        max-width: none;
    }

    .table--stack .table__sub,
    .table--stack td.is-numeric {
        text-align: left;
    }

    .table--stack .table__actions {
        justify-content: flex-start;
    }
}

/* --------------------------------------------------------------------------
   19. Accesibilidad y preferencias del sistema
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (hover: none) {
    /* En pantallas táctiles los objetivos deben ser más grandes */
    .nav-link {
        padding: 12px;
    }

    .dropdown__item {
        padding: 12px 13px;
    }

    .table__actions .btn {
        min-height: 38px;
    }
}

/* Impresión: listados de reservas del día */
@media print {
    .sidebar,
    .header,
    .sidebar-overlay,
    .toasts,
    .offline-bar,
    .card__head-actions,
    .btn,
    .pagination,
    .filters,
    .install-prompt {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }

    .main {
        margin-left: 0;
    }

    .card {
        border-color: #ccc;
        break-inside: avoid;
    }

    .table th {
        background: #f4f4f4;
        color: #000;
    }
}

/* ==========================================================================
   AGENTE DE RESERVAS  (v1.1.0)
   --------------------------------------------------------------------------
   Componentes NUEVOS, añadidos sin tocar nada del diseño anterior. Usan las
   mismas variables de color que inyecta Ajustes → Apariencia, de modo que el
   agente se ve igual que el resto del panel con cualquier tema.
   ========================================================================== */

/* Disposición del simulador: conversación + datos recogidos */
.agent-sim {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: var(--gap);
    align-items: start;
}

.agent-sim__main,
.agent-sim__side {
    margin: 0;
    min-width: 0;
}

.agent-sim__main .card__head h2 i {
    color: var(--primary);
    margin-right: 6px;
}

.agent-sim__state {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.agent-sim__state::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-strong);
    flex: 0 0 auto;
}

.agent-sim__state.is-live::before {
    background: var(--ok);
    box-shadow: 0 0 0 3px rgba(62, 156, 109, .22);
}

.agent-sim__state.is-closed::before {
    background: var(--warn);
}

/* Hilo de la conversación */
.agent-chat {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    min-height: 320px;
    max-height: 52vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    scroll-behavior: smooth;
}

.agent-chat--static {
    max-height: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.agent-chat__hint {
    margin: auto;
    max-width: 420px;
    text-align: center;
    color: var(--muted);
    font-size: 13.5px;
    line-height: 1.7;
}

.agent-chat__hint i {
    font-size: 26px;
    color: var(--border-strong);
    margin-bottom: 10px;
    display: block;
}

.agent-chat__preview {
    margin-top: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border-strong);
    color: var(--text);
    font-style: italic;
}

/* Burbujas */
.agent-msg {
    max-width: min(78%, 560px);
    padding: 11px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    position: relative;
    word-break: break-word;
}

.agent-msg--agente {
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.agent-msg--cliente {
    align-self: flex-end;
    border-bottom-right-radius: 5px;
    border-color: var(--primary-ring);
    background: var(--primary-softer);
}

.agent-msg--sistema {
    align-self: center;
    max-width: 100%;
    text-align: center;
    background: transparent;
    border-style: dashed;
    box-shadow: none;
    color: var(--muted);
    font-size: 12.5px;
}

.agent-msg__who {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 4px;
}

.agent-msg--cliente .agent-msg__who {
    color: var(--primary-light);
}

.agent-msg__text {
    margin: 0;
    font-size: 14px;
    line-height: 1.65;
    white-space: pre-line;
}

.agent-msg__time {
    display: block;
    margin-top: 5px;
    font-size: 11px;
    color: var(--muted);
}

/* Indicador «está escribiendo» */
.agent-msg--typing .agent-msg__text {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    min-height: 20px;
}

.agent-msg--typing .agent-msg__text span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted);
    animation: agent-dot 1.1s infinite ease-in-out;
}

.agent-msg--typing .agent-msg__text span:nth-child(2) {
    animation-delay: .18s;
}

.agent-msg--typing .agent-msg__text span:nth-child(3) {
    animation-delay: .36s;
}

@keyframes agent-dot {
    0%, 60%, 100% { opacity: .25; transform: translateY(0); }
    30%           { opacity: 1;   transform: translateY(-3px); }
}

/* Sugerencias y opciones que devuelve el agente */
.agent-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 18px;
}

.agent-quick:empty {
    display: none;
}

.agent-quick__item {
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    font-size: 12.5px;
    transition: border-color var(--transition), color var(--transition), background var(--transition);
}

.agent-quick__item:hover,
.agent-quick__item:focus-visible {
    border-color: var(--primary);
    color: var(--primary-light);
    background: var(--primary-softer);
}

.agent-quick__label {
    width: 100%;
    margin: 0 0 2px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
}

/* Barra de envío */
.agent-sim__form {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
}

.agent-sim__form input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
}

.agent-sim__form .btn {
    flex: 0 0 auto;
}

/* --------------------------------------------------------------------------
   Adaptación a pantallas pequeñas
   -------------------------------------------------------------------------- */
@media (max-width: 1080px) {
    .agent-sim {
        grid-template-columns: minmax(0, 1fr);
    }

    .agent-sim__side {
        order: -1;
    }
}

@media (max-width: 768px) {
    .agent-chat {
        padding: 14px;
        min-height: 260px;
        max-height: 58vh;
    }

    .agent-msg {
        max-width: 88%;
    }

    .agent-quick {
        padding: 12px 14px;
    }
}

@media (max-width: 576px) {
    .agent-msg {
        max-width: 94%;
        padding: 10px 12px;
    }

    .agent-msg__text {
        font-size: 13.5px;
    }

    .agent-quick__item {
        font-size: 12px;
    }
}

@media (max-width: 414px) {
    .agent-chat {
        padding: 12px;
        gap: 10px;
    }

    .agent-msg {
        max-width: 100%;
    }

    /* En pantallas muy estrechas el botón se queda solo con el icono */
    .agent-sim__send-label {
        display: none;
    }
}

@media (max-width: 360px) {
    .agent-chat {
        min-height: 220px;
    }

    .agent-quick {
        gap: 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .agent-chat {
        scroll-behavior: auto;
    }

    .agent-msg--typing .agent-msg__text span {
        animation: none;
    }
}
