/* Reserva de salones · Ateneo Mercantil de Valencia
   Colores del logotipo: azul acero (--brand) y azul noche (--brand-dark); se pueden cambiar en
   Administración › Ajustes. Franjas: mañana (ámbar), tarde (azul acero), día completo (azul noche). */

:root {
  --brand: #4B6D94;
  --brand-dark: #1A3749;
  --brand-ink: #3D5E85;
  --brand-soft: color-mix(in srgb, var(--brand) 10%, transparent);
  --bg: #F3F5F9;
  --surface: #FFFFFF;
  --surface-2: #F7F9FC;
  --ink: #17212B;
  --muted: #5E6B7A;
  --line: #E1E7EF;
  --line-strong: #CBD5E1;
  --fr-m: #E3A03A;
  --fr-m-soft: #FCF1DE;
  --fr-t: var(--brand);
  --fr-t-soft: #E6EDF6;
  --fr-d: var(--brand-dark);
  --fr-d-soft: #DDE5EE;
  --ok: #2E8B57;
  --warn: #B7791F;
  --err: #C0392B;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-2: 0 8px 24px -6px rgba(16, 32, 56, .16), 0 2px 6px rgba(16, 32, 56, .06);
  --shadow-3: 0 24px 64px -12px rgba(10, 25, 45, .35);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --topbar-h: 64px;
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand-ink: #9DBCE0;
    --bg: #0B131B;
    --surface: #121E2A;
    --surface-2: #172636;
    --ink: #E5ECF4;
    --muted: #93A3B5;
    --line: #22344A;
    --line-strong: #2E4560;
    --fr-m: #E9AE52;
    --fr-m-soft: #3A2D17;
    --fr-t: #6F93BF;
    --fr-t-soft: #1C2E44;
    --fr-d: #9DBCE0;
    --fr-d-soft: #223448;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-2: 0 10px 30px -8px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand-ink: #9DBCE0;
  --bg: #0B131B;
  --surface: #121E2A;
  --surface-2: #172636;
  --ink: #E5ECF4;
  --muted: #93A3B5;
  --line: #22344A;
  --line-strong: #2E4560;
  --fr-m: #E9AE52;
  --fr-m-soft: #3A2D17;
  --fr-t: #6F93BF;
  --fr-t-soft: #1C2E44;
  --fr-d: #9DBCE0;
  --fr-d-soft: #223448;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 10px 30px -8px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; min-height: 100vh;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.015em; }
a { color: var(--brand-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .86em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); }
.eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--brand-ink); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 0%, var(--surface)); }
.ellipsis { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Pantalla de carga ---------------------------------------------------------------------- */
#splash {
  position: fixed; inset: 0; z-index: 9999; display: grid; place-content: center; justify-items: center; gap: 28px;
  background: radial-gradient(1200px 600px at 20% 10%, #2B5172, var(--brand-dark));
  transition: opacity .45s var(--ease), visibility .45s;
}
#splash img { width: 96px; animation: breathe 1.6s var(--ease) infinite alternate; }
#splash .splash-bar { width: 120px; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .15); overflow: hidden; position: relative; }
#splash .splash-bar::after { content: ""; position: absolute; inset: 0; width: 40%; background: #fff; border-radius: 3px; animation: slidebar 1.1s var(--ease) infinite; }
#splash.gone { opacity: 0; visibility: hidden; }
@keyframes breathe { from { transform: scale(.94); opacity: .75; } to { transform: scale(1.03); opacity: 1; } }
@keyframes slidebar { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* --- Botones -------------------------------------------------------------------------------- */
.btn {
  position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .6rem 1.05rem; border-radius: 11px; border: 1px solid transparent; font-weight: 600; font-size: .92rem;
  cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none;
  transition: transform .18s var(--ease), box-shadow .25s var(--ease), background .2s, border-color .2s, color .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 70%, var(--brand-dark))); color: #fff; box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--brand) 70%, transparent); }
.btn-primary:hover { box-shadow: 0 10px 22px -8px color-mix(in srgb, var(--brand) 85%, transparent); transform: translateY(-1px); }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand-ink); background: var(--brand-soft); }
.btn-danger { background: var(--err); color: #fff; }
.btn-sm { padding: .4rem .75rem; font-size: .84rem; border-radius: 9px; }
.btn-lg { padding: .8rem 1.3rem; font-size: 1rem; border-radius: 13px; }
.btn-block { width: 100%; }
.btn.is-busy { color: transparent !important; pointer-events: none; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor;
  border-color: rgba(255, 255, 255, .9) rgba(255, 255, 255, .9) transparent transparent; animation: spin .7s linear infinite;
}
.btn-ghost.is-busy::after { border-color: var(--brand) var(--brand) transparent transparent; }
.btn-icon {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0; background: none;
  color: var(--muted); cursor: pointer; transition: background .2s, color .2s, transform .15s; font-size: 1.05rem;
}
.btn-icon:hover { background: var(--brand-soft); color: var(--brand-ink); }
.btn-icon:active { transform: scale(.92); }
.btn-icon.danger:hover { background: color-mix(in srgb, var(--err) 12%, transparent); color: var(--err); }
.btn-round {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); cursor: pointer; transition: all .2s var(--ease);
}
.btn-round:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-ink); transform: scale(1.06); }
.btn-round:disabled { opacity: .4; cursor: default; }
.ink {
  position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; pointer-events: none;
  background: currentColor; opacity: .25; animation: ink .6s var(--ease) forwards;
}
@keyframes ink { to { transform: scale(40); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Acceso ---------------------------------------------------------------------------------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; position: relative; overflow: hidden; }
.login-bg { position: fixed; inset: 0; background: linear-gradient(160deg, var(--brand-dark), #24496A 55%, var(--brand)); z-index: -1; }
.orb { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; animation: float 16s ease-in-out infinite alternate; }
.o1 { width: 420px; height: 420px; background: #6E95C2; top: -120px; left: -80px; }
.o2 { width: 360px; height: 360px; background: #E3A03A; bottom: -140px; right: -60px; opacity: .28; animation-duration: 20s; }
.o3 { width: 260px; height: 260px; background: #9DBCE0; top: 40%; left: 60%; opacity: .3; animation-duration: 24s; }
@keyframes float { to { transform: translate(60px, 40px) scale(1.12); } }
.login-watermark { position: absolute; right: -80px; bottom: -80px; width: 460px; opacity: .06; transform: rotate(-12deg); }
.login-card {
  width: min(420px, 100%); padding: 36px 32px 30px; border-radius: 22px; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(18px) saturate(1.3); -webkit-backdrop-filter: blur(18px) saturate(1.3); box-shadow: var(--shadow-3);
  border: 1px solid color-mix(in srgb, #fff 30%, transparent); animation: rise .7s var(--ease) both;
}
.login.leaving .login-card { animation: leave .38s var(--ease) forwards; }
@keyframes rise { from { opacity: 0; transform: translateY(24px) scale(.98); } }
@keyframes leave { to { opacity: 0; transform: translateY(-16px) scale(.98); } }
.login-logo { width: 100%; max-width: 300px; display: block; margin: 0 auto 22px; }
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-light { display: none; } :root:not([data-theme="light"]) .logo-dark { display: block; } }
.login-card h1 { font-size: 1.45rem; text-align: center; }
.login-card > p { text-align: center; margin: .4rem 0 1.4rem; font-size: .92rem; }
.login-form { display: grid; gap: 14px; }
.login-foot { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; color: rgba(255, 255, 255, .6); font-size: .78rem; margin: 0; padding: 0 16px; }
.shake { animation: shake .45s var(--ease); }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* --- Formularios ---------------------------------------------------------------------------- */
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > span { font-size: .82rem; font-weight: 600; color: var(--muted); }
.field > span em { color: var(--err); font-style: normal; }
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]), select, textarea {
  width: 100%; padding: .65rem .8rem; border-radius: 11px; border: 1px solid var(--line-strong); background: var(--surface);
  transition: border-color .2s, box-shadow .2s, background .2s; min-height: 44px;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
textarea.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .85rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
input:disabled { opacity: .65; }
input[type="color"] { width: 64px; height: 44px; padding: 4px; border-radius: 11px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; }
.input-group { position: relative; }
.input-group input { padding-right: 46px; }
.input-addon { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.input-row { display: flex; gap: 8px; flex-wrap: wrap; }
.input-row input { flex: 1 1 220px; }
.check { display: flex; align-items: center; gap: 10px; font-size: .9rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.help { color: var(--muted); font-size: .8rem; }
.form-error { color: var(--err); font-size: .88rem; min-height: 1px; }
.form-error:empty { display: none; }
.warn { color: var(--warn); font-size: .88rem; background: color-mix(in srgb, var(--warn) 10%, transparent); padding: .55rem .75rem; border-radius: 10px; margin: .5rem 0; }
.ok-text { color: var(--ok); font-size: .88rem; margin: .5rem 0; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full, .form-grid .switch-field { grid-column: 1 / -1; }
.grid-2-tight { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.switch-field { position: relative; display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.switch-field input { position: absolute; opacity: 0; pointer-events: none; }
.switch-field > span:last-child { display: grid; gap: 2px; }
.switch-field small { color: var(--muted); font-size: .8rem; }
.switch-field.inline { align-items: center; font-size: .88rem; }
.switch { flex: none; width: 44px; height: 26px; border-radius: 26px; background: var(--line-strong); position: relative; transition: background .25s var(--ease); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .3s var(--spring); }
.switch-field input:checked + .switch { background: var(--brand); }
.switch-field input:checked + .switch::after { transform: translateX(18px); }
.switch-field input:focus-visible + .switch { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }

.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.check-list.compact { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.check-card {
  display: flex; align-items: center; gap: 10px; padding: .6rem .75rem; border-radius: 11px; border: 1px solid var(--line);
  cursor: pointer; transition: border-color .2s, background .2s, transform .15s; font-size: .9rem;
}
.check-card:hover { border-color: var(--c, var(--brand)); }
.check-card:active { transform: scale(.98); }
.check-card input { accent-color: var(--c, var(--brand)); width: 17px; height: 17px; }
.check-card:has(input:checked) { background: color-mix(in srgb, var(--c, var(--brand)) 9%, transparent); border-color: color-mix(in srgb, var(--c, var(--brand)) 50%, transparent); }
.row-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.day-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.day-picker label { position: relative; cursor: pointer; }
.day-picker input { position: absolute; opacity: 0; }
.day-picker span { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-strong); font-weight: 600; transition: all .2s var(--ease); }
.day-picker input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; transform: scale(1.05); }
.day-picker input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); }

/* --- Cáscara ---------------------------------------------------------------------------------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 50; color: #fff; padding-top: env(safe-area-inset-top);
  background: linear-gradient(100deg, var(--brand-dark), color-mix(in srgb, var(--brand-dark) 70%, var(--brand)));
  transition: box-shadow .3s var(--ease), background .3s;
}
.topbar.scrolled { box-shadow: 0 10px 30px -12px rgba(10, 25, 45, .55); background: color-mix(in srgb, var(--brand-dark) 92%, transparent); backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4); }
.topbar-inner { max-width: 1440px; margin: 0 auto; height: var(--topbar-h); display: flex; align-items: center; gap: 20px; padding: 0 20px; }
.brand { display: flex; align-items: center; gap: 14px; color: #fff; text-decoration: none; min-width: 0; flex: none; }
.brand-logo { height: 34px; width: auto; }
.brand-seal { display: none; height: 36px; width: 36px; }
.brand-sep { width: 1px; height: 28px; background: rgba(255, 255, 255, .25); }
.brand-title { font-weight: 600; font-size: .95rem; white-space: nowrap; letter-spacing: .01em; opacity: .95; }
.topnav { position: relative; display: flex; gap: 2px; margin-left: auto; padding: 4px; border-radius: 13px; background: rgba(255, 255, 255, .08); }
.topnav .tab { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; padding: .5rem .9rem; border-radius: 10px; color: rgba(255, 255, 255, .78); text-decoration: none; font-weight: 600; font-size: .9rem; transition: color .25s; overflow: hidden; }
.topnav .tab:hover { color: #fff; }
.topnav .tab.active { color: var(--brand-dark); }
.tab-indicator { position: absolute; top: 4px; bottom: 4px; left: 0; border-radius: 10px; background: #fff; box-shadow: 0 4px 14px -4px rgba(0, 0, 0, .35); transition: transform .45s var(--spring), width .45s var(--spring), opacity .2s; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.topbar .btn-icon { color: rgba(255, 255, 255, .8); }
.topbar .btn-icon:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.user-box { position: relative; }
.avatar-btn { display: flex; align-items: center; gap: 9px; padding: 4px 10px 4px 4px; border-radius: 30px; border: 1px solid rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .06); color: #fff; cursor: pointer; transition: background .2s; }
.avatar-btn:hover { background: rgba(255, 255, 255, .14); }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #E3A03A, #D0812A); color: #fff; font-weight: 700; font-size: .8rem; }
.avatar-name { font-size: .88rem; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-btn .chev { font-size: .7rem; transition: transform .3s var(--ease); }
.user-box.open .chev { transform: rotate(180deg); }
.menu {
  position: absolute; right: 0; top: calc(100% + 10px); width: 260px; padding: 8px; border-radius: 16px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); box-shadow: var(--shadow-3); opacity: 0; visibility: hidden; transform: translateY(-8px) scale(.97); transform-origin: top right;
  transition: opacity .2s var(--ease), transform .3s var(--spring), visibility .2s;
}
.user-box.open .menu { opacity: 1; visibility: visible; transform: none; }
.menu-head { display: grid; gap: 2px; padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-head span { font-size: .82rem; color: var(--muted); }
.menu-head .badge { justify-self: start; margin-top: 6px; }
.menu a, .menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: .6rem .75rem; border: 0; border-radius: 10px; background: none; color: var(--ink); text-decoration: none; cursor: pointer; font-size: .92rem; text-align: left; }
.menu a:hover, .menu button:hover { background: var(--brand-soft); color: var(--brand-ink); }
.badge-soft { font-size: .72rem; font-weight: 700; padding: .2rem .55rem; border-radius: 20px; background: var(--brand-soft); color: var(--brand-ink); }

.view { flex: 1; width: 100%; max-width: 1440px; margin: 0 auto; padding: 24px 20px 40px; outline: none; }
.foot { text-align: center; color: var(--muted); font-size: .78rem; padding: 18px 16px 24px; }
.bottombar { display: none; }

::view-transition-old(root) { animation: vt-out .22s var(--ease) both; }
::view-transition-new(root) { animation: vt-in .38s var(--ease) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 1.7rem; margin-top: 2px; }
.page-head p { margin: .35rem 0 0; max-width: 680px; }
.page-actions, .cal-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); padding: 20px; }
.card-title { display: flex; align-items: center; gap: 10px; font-size: 1.02rem; font-weight: 700; margin-bottom: 16px; }
.card-title .bi { color: var(--brand-ink); }
.card-title .pill { margin-left: auto; }
.form-card { animation: rise .5s var(--ease) both; }
.form-card + .form-card { margin-top: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.grid-2 > .form-card + .form-card { margin-top: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.role-card { display: flex; gap: 16px; align-items: center; grid-column: 1 / -1; }
.role-card h3 { font-size: 1.2rem; margin: 2px 0 4px; }
.role-card p { margin: 0; }
.role-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; font-size: 1.5rem; flex: none; }

/* Entradas escalonadas */
.stagger > *, .mx-row, .mo-cell, tbody tr, .ag-day, .request, .event, .day-item { animation: rise .55s var(--ease) both; animation-delay: calc(var(--i, 0) * 32ms); }
.stagger > *:nth-child(2) { animation-delay: 60ms; } .stagger > *:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4) { animation-delay: 180ms; } .stagger > *:nth-child(5) { animation-delay: 240ms; }
.mo-cell { animation-delay: calc(var(--i, 0) * 8ms); }
.enter-right { animation: from-right .45s var(--ease) both; }
.enter-left { animation: from-left .45s var(--ease) both; }
.enter-fade { animation: rise .4s var(--ease) both; }
@keyframes from-right { from { opacity: 0; transform: translateX(40px); } }
@keyframes from-left { from { opacity: 0; transform: translateX(-40px); } }

/* --- Calendario ------------------------------------------------------------------------------ */
.cal-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.period-title { font-size: 1.55rem; margin-left: 10px; font-weight: 700; }
.period-title.pop { animation: pop .45s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(6px); filter: blur(3px); } }
.search { position: relative; display: flex; align-items: center; }
.search .bi { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 36px !important; width: 220px; min-height: 38px !important; border-radius: 10px !important; }
.count:not(:empty) { font-size: .72rem; padding: .05rem .45rem; border-radius: 10px; background: var(--brand); color: #fff; }

.seg { position: relative; display: inline-flex; padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 7px; padding: .45rem .85rem; border: 0; background: none; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: .86rem; color: var(--muted); transition: color .25s; overflow: hidden; }
.seg button.on { color: var(--ink); }
.seg-thumb { position: absolute; top: 4px; bottom: 4px; left: 4px; border-radius: 9px; background: var(--surface); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); transition: transform .45s var(--spring), width .45s var(--spring); }
.seg-wide { display: flex; width: max-content; max-width: 100%; overflow-x: auto; margin-bottom: 16px; scrollbar-width: none; }
.seg-wide button.on { background: var(--surface); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }

.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: 0 0 14px; font-size: .82rem; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 7px; }
.lg i { width: 22px; height: 10px; border-radius: 5px; }
.lg-M i { background: var(--fr-m); } .lg-T i { background: var(--fr-t); } .lg-D i { background: var(--fr-d); }
.lg-free i { border: 1.5px dashed var(--line-strong); }
.legend-note { margin-left: auto; display: inline-flex; gap: 6px; align-items: center; }

.cal-body { position: relative; transition: opacity .25s; }
.cal-body.is-loading { opacity: .55; pointer-events: none; }
.skeleton { display: grid; gap: 10px; }
.sk-row { height: 64px; border-radius: 12px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 40%, var(--surface) 80%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite, rise .4s var(--ease) both; animation-delay: 0s, calc(var(--i) * 60ms); border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Matriz salas × días */
.matrix-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); overflow: hidden; }
.matrix-scroll { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
.matrix { min-width: 860px; }
.mx-row { display: grid; grid-template-columns: minmax(190px, 1.35fr) repeat(7, minmax(92px, 1fr)); border-bottom: 1px solid var(--line); }
.mx-row:last-child { border-bottom: 0; }
.mx-head { position: sticky; top: 0; z-index: 3; background: var(--surface-2); animation: none; }
.mx-sala { position: sticky; left: 0; z-index: 2; display: flex; align-items: center; gap: 11px; padding: 12px 14px; background: var(--surface); border-right: 1px solid var(--line); min-width: 0; }
.mx-corner { background: var(--surface-2); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.mx-sala-text { display: grid; min-width: 0; }
.mx-sala-text strong { font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mx-sala-text small { font-size: .74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mx-day { display: grid; justify-items: center; padding: 8px 4px; gap: 0; }
.mx-day .wd { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.mx-day .dn { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-weight: 700; font-size: 1.05rem; }
.mx-day.is-today .dn { background: var(--brand); color: #fff; box-shadow: 0 4px 12px -3px color-mix(in srgb, var(--brand) 70%, transparent); }
.mx-day.is-weekend .wd { color: color-mix(in srgb, var(--fr-m) 80%, var(--muted)); }
.mx-cell { display: grid; grid-template-rows: 1fr 1fr; gap: 4px; padding: 6px 5px; border-left: 1px solid var(--line); min-height: 76px; }
.mx-cell.is-today { background: color-mix(in srgb, var(--brand) 5%, transparent); }
.mx-cell.is-weekend { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.mx-row:not(.mx-head):hover .mx-sala, .mx-row:not(.mx-head):hover .mx-cell { background-color: color-mix(in srgb, var(--brand) 3.5%, var(--surface)); }

.slot { position: relative; display: flex; align-items: center; gap: 5px; min-width: 0; min-height: 30px; padding: 0 8px; border-radius: 8px; border: 0; font-size: .74rem; font-weight: 600; text-align: left; overflow: hidden; }
.slot.free { border: 1.5px dashed color-mix(in srgb, var(--line-strong) 70%, transparent); background: transparent; }
.slot.busy { cursor: pointer; color: #fff; transition: transform .2s var(--spring), box-shadow .25s var(--ease), filter .2s; animation: slot-in .5s var(--spring) both; }
.slot.busy:hover { transform: translateY(-2px) scale(1.03); z-index: 1; box-shadow: 0 8px 18px -8px rgba(0, 0, 0, .45); }
.slot.busy:active { transform: scale(.97); }
@keyframes slot-in { from { opacity: 0; transform: scale(.7); } }
.slot-M.busy { background: linear-gradient(135deg, var(--fr-m), color-mix(in srgb, var(--fr-m) 80%, #B66A12)); color: #3B2507; }
.slot-T.busy { background: linear-gradient(135deg, var(--fr-t), color-mix(in srgb, var(--fr-t) 75%, var(--brand-dark))); }
.slot-D { grid-row: 1 / span 2; }
.slot-D.busy { background: linear-gradient(160deg, var(--brand-dark), color-mix(in srgb, var(--brand-dark) 70%, var(--brand))); color: #fff; align-items: flex-start; padding-top: 8px; }
:root[data-theme="dark"] :is(.slot-D.busy, .lg-D i, .mini-slot.fr-D) { background: linear-gradient(160deg, #35618B, #23486A); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) :is(.slot-D.busy, .lg-D i, .mini-slot.fr-D) { background: linear-gradient(160deg, #35618B, #23486A); } }
.slot-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-D .slot-text { white-space: normal; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; line-height: 1.25; }
.slot-lock { font-size: .7rem; opacity: .85; }
.slot-time { font-size: .66rem; opacity: .8; font-variant-numeric: tabular-nums; }
.slot-more { font-size: .64rem; padding: 0 5px; border-radius: 6px; background: rgba(255, 255, 255, .25); }

/* Mes */
.month { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); overflow: hidden; }
.mo-head { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.mo-wd { padding: 10px; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); text-align: center; }
.mo-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.mo-cell {
  position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 4px; min-height: 124px; padding: 8px; min-width: 0;
  border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); text-align: left; cursor: pointer;
  transition: background .2s, box-shadow .25s var(--ease);
}
.mo-cell:nth-child(7n) { border-right: 0; }
.mo-cell:hover { background: color-mix(in srgb, var(--brand) 4%, var(--surface)); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--brand) 35%, transparent); z-index: 1; }
.mo-cell.is-out { background: var(--surface-2); }
.mo-cell.is-out .mo-num, .mo-cell.is-out .mo-chips { opacity: .45; }
.mo-num { align-self: flex-start; display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 4px; border-radius: 14px; font-weight: 700; font-size: .9rem; }
.mo-cell.is-today .mo-num { background: var(--brand); color: #fff; }
.mo-chips { display: grid; gap: 3px; min-width: 0; }
.mo-chip { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 2px 6px 2px 4px; border-radius: 6px; font-size: .72rem; background: var(--surface-2); }
.mo-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.mo-chip span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mo-chip b { font-size: .64rem; padding: 0 5px; border-radius: 5px; color: #fff; }
.mo-chip.fr-M b { background: var(--fr-m); color: #3B2507; } .mo-chip.fr-T b { background: var(--fr-t); } .mo-chip.fr-D b { background: var(--fr-d); }
:root[data-theme="dark"] .mo-chip.fr-D b { color: #0B131B; }
.mo-more { font-size: .7rem; color: var(--muted); font-weight: 600; padding-left: 4px; }
.mo-dots { display: none; }
.mo-meter { position: absolute; left: 8px; right: 8px; bottom: 6px; height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.mo-meter::after { content: ""; position: absolute; inset: 0; width: var(--p); border-radius: 3px; background: linear-gradient(90deg, var(--fr-m), var(--fr-t)); animation: grow .8s var(--ease) both; }
@keyframes grow { from { width: 0; } }

/* Hoja / ventana */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px;
  background: rgba(8, 18, 30, 0); backdrop-filter: blur(0); -webkit-backdrop-filter: blur(0); transition: background .3s var(--ease), backdrop-filter .3s;
}
.sheet-backdrop.open { background: rgba(8, 18, 30, .45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.sheet {
  width: min(560px, 100%); max-height: min(88vh, 900px); display: flex; flex-direction: column; background: var(--surface); border-radius: 22px;
  box-shadow: var(--shadow-3); border: 1px solid var(--line); opacity: 0; transform: translateY(24px) scale(.96);
  transition: opacity .28s var(--ease), transform .45s var(--spring);
}
.sheet-sm { width: min(420px, 100%); } .sheet-lg { width: min(780px, 100%); }
.sheet-backdrop.open .sheet { opacity: 1; transform: none; }
.sheet-backdrop.closing .sheet { opacity: 0; transform: translateY(16px) scale(.98); transition-duration: .22s; }
.sheet-grip { display: none; }
.sheet-head { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 14px 22px; border-bottom: 1px solid var(--line); }
.sheet-head[style*="--accent"]::before { content: ""; position: absolute; left: 0; top: 18px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
.sheet-head-text { flex: 1; min-width: 0; }
.sheet-title { font-size: 1.2rem; }
.sheet-sub { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.sheet-sub:empty { display: none; }
.sheet-body { padding: 18px 22px 22px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
.sheet-body.swap > * { animation: from-right .38s var(--ease) both; }
.confirm-text { margin: 0 0 6px; }

/* Ficha del bloqueo */
.detail { display: grid; gap: 16px; }
.detail-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.fr-badge { display: inline-flex; align-items: center; gap: 6px; padding: .3rem .7rem; border-radius: 20px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.fr-M { background: var(--fr-m-soft); color: color-mix(in srgb, var(--fr-m) 60%, #4A2D05); }
.fr-T { background: var(--fr-t-soft); color: var(--brand-ink); }
.fr-D { background: var(--fr-d-soft); color: var(--fr-d); }
.fr-free { background: color-mix(in srgb, var(--ok) 12%, transparent); color: var(--ok); }
:root[data-theme="dark"] .fr-M { color: var(--fr-m); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .fr-M { color: var(--fr-m); } }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: .3rem .7rem; border-radius: 20px; font-size: .8rem; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.timeline { padding: 6px 0 2px; }
.tl-bar { position: relative; height: 34px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.tl-half { position: absolute; top: 0; bottom: 0; }
.tl-half.busy.tl-m { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--fr-m) 30%, transparent) 0 8px, color-mix(in srgb, var(--fr-m) 18%, transparent) 8px 16px); animation: fadein .6s var(--ease) both; }
.tl-half.busy.tl-t { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--fr-t) 30%, transparent) 0 8px, color-mix(in srgb, var(--fr-t) 16%, transparent) 8px 16px); animation: fadein .6s var(--ease) .1s both; }
.tl-ev { position: absolute; top: 7px; bottom: 7px; border-radius: 6px; background: var(--brand-dark); box-shadow: 0 2px 8px -2px rgba(0, 0, 0, .4); transform-origin: left; animation: grow-x .7s var(--ease) both; animation-delay: calc(.15s + var(--i) * 80ms); min-width: 4px; }
:root[data-theme="dark"] .tl-ev { background: #9DBCE0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tl-ev { background: #9DBCE0; } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes fadein { from { opacity: 0; } }
.tl-cut { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--ink); opacity: .35; }
.tl-scale { position: relative; height: 18px; font-size: .7rem; color: var(--muted); }
.tl-scale span { position: absolute; transform: translateX(-50%); top: 3px; font-variant-numeric: tabular-nums; }
.tl-cut-label { font-weight: 700; color: var(--ink); top: 3px; }
.tl-scale span:not(.tl-cut-label) { opacity: .75; }
.events { display: grid; gap: 8px; }
.event { display: flex; gap: 14px; align-items: stretch; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); border-left: 4px solid var(--c); }
.event-time { display: grid; align-content: center; text-align: center; min-width: 52px; font-variant-numeric: tabular-nums; }
.event-time strong { font-size: 1.05rem; }
.event-time span { font-size: .8rem; color: var(--muted); }
.event-main { display: grid; gap: 4px; align-content: center; }
.event-main small { color: var(--muted); font-size: .8rem; }
.locked { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.locked p { margin: .3rem 0 0; color: var(--muted); font-size: .9rem; }
.locked-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; font-size: 1.15rem; animation: wobble 1s var(--spring) .2s both; }
@keyframes wobble { 0% { transform: scale(.5) rotate(-20deg); opacity: 0; } 60% { transform: scale(1.08) rotate(6deg); opacity: 1; } }

.request-form { display: grid; gap: 14px; }
.request-target { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--c) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); }
.request-target .bi { font-size: 1.3rem; color: var(--c); }
.request-target div { display: grid; }
.request-target small { color: var(--muted); }
.success { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 18px 0 6px; }
.success p { margin: 0 0 10px; max-width: 360px; }
.success-check svg { width: 84px; height: 84px; }
.success-check circle { stroke: var(--ok); stroke-width: 3; stroke-dasharray: 152; stroke-dashoffset: 152; animation: draw .7s var(--ease) forwards; }
.success-check path { stroke: var(--ok); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .45s var(--ease) .55s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.day-list { display: grid; gap: 8px; }
.day-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.day-item.is-free { background: var(--surface-2); opacity: .8; }
.day-item-main { flex: 1; display: grid; min-width: 0; }
.day-item-main small { color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-item-slots { display: flex; gap: 6px; }
.mini-slot { border: 0; padding: .35rem .6rem; border-radius: 8px; font-size: .74rem; font-weight: 700; cursor: pointer; transition: transform .2s var(--spring); }
.mini-slot:not(:disabled):hover { transform: translateY(-2px); }
.mini-slot.fr-M { background: var(--fr-m); color: #3B2507; } .mini-slot.fr-T { background: var(--fr-t); color: #fff; } .mini-slot.fr-D { background: var(--brand-dark); color: #fff; }
.mini-slot.fr-free { background: transparent; border: 1.5px dashed var(--line-strong); color: var(--muted); cursor: default; }

/* Agenda */
.agenda { display: grid; gap: 14px; margin-bottom: 16px; }
.ag-day { display: grid; grid-template-columns: 74px 1fr; gap: 14px; }
.ag-date { position: sticky; top: calc(var(--topbar-h) + 12px); align-self: start; display: grid; justify-items: center; padding: 10px 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.ag-date.is-today { background: var(--brand); border-color: var(--brand); color: #fff; }
.ag-dn { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.ag-wd, .ag-mo { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .75; }
.ag-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.ag-item { display: grid; gap: 8px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); border-left: 4px solid var(--c); background: var(--surface); text-align: left; cursor: pointer; box-shadow: var(--shadow-1); transition: transform .25s var(--spring), box-shadow .25s var(--ease); }
.ag-item:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.ag-item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ag-events { display: grid; gap: 3px; font-size: .84rem; color: var(--muted); }
.ag-events b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* --- Avisos ------------------------------------------------------------------------------------ */
#toasts { position: fixed; z-index: 400; right: 20px; bottom: 20px; display: grid; gap: 10px; justify-items: end; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 420px; padding: .8rem 1rem; border-radius: 14px; color: #fff; background: #1E2C3A; box-shadow: var(--shadow-3); font-size: .9rem; cursor: pointer; animation: toast-in .5s var(--spring) both; }
.toast-ok .bi { color: #6BD69B; } .toast-error .bi { color: #FF8E80; } .toast-info .bi { color: #9DBCE0; }
.toast.out { animation: toast-out .3s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(20px) scale(.9); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }

.loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 40px; color: var(--muted); }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
.empty { display: grid; justify-items: center; text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--brand-soft); color: var(--brand-ink); font-size: 1.7rem; margin-bottom: 12px; animation: wobble .9s var(--spring) both; }
.empty h3 { color: var(--ink); font-size: 1.05rem; }
.empty p { margin: .3rem 0 0; }

/* --- Administración --------------------------------------------------------------------------- */
.admin { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 26px; align-items: start; }
.admin-nav { position: sticky; top: calc(var(--topbar-h) + 20px); display: grid; gap: 2px; padding: 8px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.admin-nav a { position: relative; display: flex; align-items: center; gap: 11px; padding: .6rem .8rem; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .9rem; transition: background .2s, color .2s, padding .25s var(--ease); }
.admin-nav a:hover { background: var(--surface-2); color: var(--ink); padding-left: 1rem; }
.admin-nav a.active { background: var(--brand-soft); color: var(--brand-ink); }
.admin-nav a.active::before { content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--brand); animation: grow-y .35s var(--spring); }
@keyframes grow-y { from { transform: scaleY(0); } }
.admin-content { min-width: 0; }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { position: relative; overflow: hidden; display: grid; gap: 2px; padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); color: var(--ink); text-decoration: none; transition: transform .3s var(--spring), box-shadow .3s; }
.kpi:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 100px; height: 100px; border-radius: 50%; background: var(--brand-soft); }
.kpi-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; margin-bottom: 10px; position: relative; z-index: 1; }
.kpi-n { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-t { font-size: .82rem; color: var(--muted); }
.status-card p { margin: 0 0 12px; font-size: .9rem; }
.link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .88rem; text-decoration: none; }
.link .bi { transition: transform .25s var(--ease); }
.link:hover .bi { transform: translateX(4px); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--brand) 3.5%, transparent); }
.table tr.clickable { cursor: pointer; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .t-actions { text-align: right; white-space: nowrap; width: 1%; }
.table.compact td { padding: 6px 10px; font-size: .84rem; }
.cell-main { display: grid; gap: 1px; }
.cell-main > .dot { display: none; }
.cell-main small { color: var(--muted); font-size: .8rem; }
.cell-main:has(> .dot) { grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; }
.cell-main:has(> .dot) > .dot { display: inline-block; grid-row: span 2; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: .18rem .6rem; border-radius: 20px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.pill.sm { font-size: .66rem; margin-left: 6px; vertical-align: middle; }
.pill-ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.pill-warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.pill-err { background: color-mix(in srgb, var(--err) 14%, transparent); color: var(--err); }
.pill-info { background: var(--brand-soft); color: var(--brand-ink); }
.pill-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

.filters { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; padding: 14px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 4px; font-size: .88rem; }
.pager-btns { display: flex; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; }

.dropzone { display: grid; justify-items: center; gap: 6px; padding: 34px 20px; border-radius: 16px; border: 2px dashed var(--line-strong); text-align: center; cursor: pointer; transition: all .25s var(--ease); margin-bottom: 16px; }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone.over { transform: scale(1.01); }
.dropzone small { color: var(--muted); }
.drop-icon { font-size: 2.2rem; color: var(--brand-ink); transition: transform .35s var(--spring); }
.dropzone:hover .drop-icon, .dropzone.over .drop-icon { transform: translateY(-6px); }
.drop-name { margin-top: 8px; font-size: .85rem; font-weight: 600; padding: .25rem .7rem; border-radius: 20px; background: var(--surface-2); }
.dropzone.has-file { border-style: solid; border-color: var(--ok); }
.dropzone.has-file .drop-name { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.import-result { margin-top: 16px; }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.stat { display: grid; padding: 12px; border-radius: 12px; background: var(--surface-2); text-align: center; }
.stat strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .76rem; color: var(--muted); }
.stat.ok strong { color: var(--ok); } .stat.info strong { color: var(--brand-ink); } .stat.warn strong { color: var(--warn); } .stat.err strong { color: var(--err); }
.messages { margin: 14px 0 0; padding-left: 18px; font-size: .86rem; color: var(--muted); max-height: 240px; overflow: auto; }
details summary { cursor: pointer; font-weight: 600; margin-top: 12px; }
.markers { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.markers summary { margin: 0; }
.markers dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 12px 0 0; font-size: .86rem; }
.markers dd { margin: 0; color: var(--muted); }
.test-mail { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.path-check-box { margin-top: 12px; }
.files { margin: 6px 0 0; padding-left: 18px; font-size: .84rem; }

.requests { display: grid; gap: 12px; }
.request header, .request footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.request header .fr-badge { margin-left: 4px; }
.request-msg { white-space: pre-wrap; margin: 12px 0; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.request footer { font-size: .84rem; }
.request.done { opacity: .6; }
.request { transition: opacity .3s; }

/* --- Móvil y tableta ----------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .admin { grid-template-columns: 1fr; gap: 16px; }
  .admin-nav { position: static; display: flex; overflow-x: auto; scrollbar-width: none; padding: 6px; }
  .admin-nav a { flex: none; }
  .admin-nav a:hover { padding-left: .8rem; }
  .admin-nav a.active::before { left: 10px; right: 10px; top: auto; bottom: -6px; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  :root { --topbar-h: 56px; }
  .topnav, .avatar-name, .avatar-btn .chev, .brand-title, .brand-sep { display: none; }
  .topbar-actions { margin-left: auto; }
  .brand-logo { height: 30px; }
  .view { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
  .foot { display: none; }
  .bottombar {
    position: fixed; z-index: 60; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); display: flex; justify-content: space-around;
    padding: 6px; border-radius: 22px; background: color-mix(in srgb, var(--surface) 86%, transparent); border: 1px solid var(--line);
    backdrop-filter: blur(18px) saturate(1.5); -webkit-backdrop-filter: blur(18px) saturate(1.5); box-shadow: var(--shadow-3);
    animation: rise .5s var(--ease) both;
  }
  .bottombar .tab { position: relative; flex: 1; display: grid; justify-items: center; gap: 2px; padding: 7px 4px; border-radius: 16px; color: var(--muted); text-decoration: none; font-size: .68rem; font-weight: 700; overflow: hidden; transition: color .25s; }
  .bottombar .tab .bi { font-size: 1.25rem; transition: transform .35s var(--spring); }
  .bottombar .tab.active { color: var(--brand-ink); background: var(--brand-soft); }
  .bottombar .tab.active .bi { transform: translateY(-2px) scale(1.12); }
  .page-head h1 { font-size: 1.4rem; }
  .period-title { font-size: 1.2rem; margin-left: 4px; }
  .cal-toolbar { gap: 10px; }
  .cal-tools { width: 100%; }
  .cal-tools .search { flex: 1; }
  .cal-tools .search input { width: 100%; }
  .seg button span { display: none; }
  .legend { gap: 6px 12px; font-size: .76rem; }
  .legend-note { margin-left: 0; width: 100%; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:last-child { grid-column: 1 / -1; }
  .filters { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hide-xs { display: none; }
  .matrix { min-width: 0; }
  .mx-row { grid-template-columns: 104px repeat(7, 116px); width: max-content; }
  .mx-cell { min-height: 84px; }
  .mx-sala { padding: 8px 10px; gap: 7px; }
  .mx-sala .dot { width: 8px; height: 8px; }
  .mx-sala-text strong { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: .84rem; line-height: 1.2; }
  .mx-sala-text small { display: none; }
  .slot { padding: 0 6px; }
  .mo-cell { min-height: 74px; padding: 6px 4px; align-items: center; }
  .mo-num { align-self: center; font-size: .85rem; }
  .mo-chips { display: none; }
  .mo-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; }
  .mo-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
  .mo-dots i.fr-D { box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 2.5px var(--c); }
  .mo-wd { padding: 8px 2px; font-size: .66rem; letter-spacing: .02em; }
  .ag-day { grid-template-columns: 56px 1fr; gap: 10px; }
  .ag-dn { font-size: 1.3rem; }
  .ag-items { grid-template-columns: 1fr; }
  .sheet-backdrop { place-items: end stretch; padding: 0; }
  .sheet, .sheet-sm, .sheet-lg { width: 100%; max-height: 92vh; max-height: 92dvh; border-radius: 24px 24px 0 0; transform: translateY(100%); padding-bottom: env(safe-area-inset-bottom); }
  .sheet-backdrop.closing .sheet { transform: translateY(100%); }
  .sheet-grip { display: block; width: 44px; height: 5px; border-radius: 5px; background: var(--line-strong); margin: 10px auto 0; cursor: grab; touch-action: none; padding: 8px 0; background-clip: content-box; height: 21px; }
  .sheet-head { padding-top: 8px; }
  #toasts { left: 12px; right: 12px; bottom: calc(96px + env(safe-area-inset-bottom)); justify-items: stretch; }
  .toast { max-width: none; }
  /* Tablas como tarjetas */
  .table-wrap { background: none; border: 0; box-shadow: none; overflow: visible; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tbody { display: grid; gap: 10px; }
  .table tr { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow-1); }
  .table td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table td[data-label]::before { content: attr(data-label); font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: left; }
  .table td:first-child { text-align: left; justify-content: flex-start; font-size: 1rem; }
  .table td:first-child::before { display: none; }
  .table .t-actions { width: auto; justify-content: flex-end; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; }
  .table .num { text-align: right; }
  .table.compact tr { padding: 6px 10px; }
  .ellipsis { max-width: 60vw; }
}

@media (max-width: 420px) {
  .brand-logo { display: none; }
  .brand-seal { display: block; }
  .grid-2-tight, .filters { grid-template-columns: 1fr; }
  .login-card { padding: 28px 20px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media print {
  .topbar, .bottombar, .cal-tools, .cal-nav .btn-round, .cal-nav .btn, .foot { display: none !important; }
  body { background: #fff; }
  .matrix-wrap, .month { box-shadow: none; }
}

/* --- Acceso de usuarios y app móvil ------------------------------------------------------------ */
.stack { display: grid; gap: 18px; align-content: start; }
.stack > .form-card + .form-card { margin-top: 0; }
.grow { margin-right: auto; align-self: center; }
.users-list { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); max-height: 46vh; overflow: auto; padding: 2px; }
.user-check { align-items: center; }
.user-check .cell-main { flex: 1; min-width: 0; }
.user-check .cell-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.send-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.send-results li { display: flex; gap: 8px; align-items: baseline; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: .9rem; }
.send-results li.ok .bi { color: var(--ok); } .send-results li.err .bi { color: var(--err); }
.apk-info { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 16px; }
.apk-info > div { flex: 1; display: grid; min-width: 0; }
.apk-info small { color: var(--muted); }
.apk-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(135deg, #3DDC84, #2BA866); color: #fff; font-size: 1.2rem; flex: none; }
.links { display: grid; gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.links > div { display: grid; min-width: 0; }
.links small { color: var(--muted); font-size: .78rem; }
.links a { overflow-wrap: anywhere; font-size: .9rem; }
.ios-card p { margin: 0 0 12px; }
