/* ============ Tokens ============ */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #e8efff;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --cps: #2563eb;      --cps-soft: #e5edff;
  --ext: #0e7490;      --ext-soft: #e0f4f8;
  --aux: #7c3aed;      --aux-soft: #efe8fe;
  --weekend: #f1f5f9;
  --festivo: #fde2e2;
  --puente: #ede9fe;
  --puente-strong: #7c3aed;
  --today: #fef9c3;
  --sidebar: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-muted: #64748b;
  --sidebar-active: #1e293b;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .18);
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #131c2e;
    --surface-2: #182236;
    --border: #243049;
    --border-strong: #334260;
    --text: #e5ecf6;
    --text-2: #c6d1e1;
    --muted: #8a9ab3;
    --primary: #4f86f7;
    --primary-hover: #6b99f8;
    --primary-soft: #1b2a4a;
    --danger: #f06363;
    --danger-soft: #3a1c22;
    --ok: #4ade80;
    --ok-soft: #14301f;
    --cps: #6b99f8;      --cps-soft: #1b2a4a;
    --ext: #38bdd8;      --ext-soft: #11303a;
    --aux: #a78bfa;      --aux-soft: #2a2148;
    --weekend: #172033;
    --festivo: #3b1d24;
    --puente: #251d42;
    --puente-strong: #8b5cf6;
    --today: #3a3514;
    --sidebar: #080d19;
    --sidebar-active: #172033;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0; }
input, select, textarea, button { font: inherit; color: inherit; }
.ico { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.cap::first-letter { text-transform: uppercase; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-width: 0; }
.pad { padding: 16px; }
[hidden] { display: none !important; }

/* ============ Botones y formularios ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(.92); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-sm .ico { width: 16px; height: 16px; }
.btn-block { width: 100%; height: 42px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-sm);
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn-sm { width: 26px; height: 26px; }
.icon-btn-sm .ico { width: 16px; height: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 550; color: var(--text-2); }
input:not([type=checkbox]):not([type=color]), select, textarea {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 8px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--text-2); }
input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); cursor: pointer; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.input-group { display: flex; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-4 { grid-template-columns: repeat(4, 1fr); }
.span-2 { grid-column: span 2; }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px; }

/* ============ Acceso ============ */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 1fr) 1.2fr; }
.auth-side {
  background: linear-gradient(160deg, #0f172a 0%, #1e3a8a 100%); color: #e2e8f0;
  padding: 48px; display: flex; flex-direction: column; justify-content: center; gap: 20px;
}
.auth-claim { font-size: 20px; line-height: 1.4; color: #fff; max-width: 380px; font-weight: 500; }
.auth-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 12px; color: #cbd5e1; }
.auth-list li { display: flex; gap: 10px; align-items: center; }
.auth-list .ico { color: #93c5fd; }
.auth-main { display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; }
.auth-card h1 { font-size: 26px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; color: #fff; }
.brand .ico { width: 30px; height: 30px; padding: 6px; background: var(--primary); color: #fff; border-radius: 8px; }
.brand-lg { font-size: 20px; }
.brand-lg .ico { width: 40px; height: 40px; padding: 8px; }

/* ============ Layout ============ */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex: none; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px; z-index: 40;
}
.sidebar .brand { padding: 4px 8px 18px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--sidebar-text); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--sidebar-active); color: #fff; }
.nav a.active { background: var(--sidebar-active); color: #fff; }
.nav a.active .ico { color: #60a5fa; }
.nav-sub { display: flex; flex-direction: column; margin: 2px 0 4px 20px; padding-left: 10px; border-left: 1px solid #1e293b; }
.nav-sub a { padding: 6px 10px; font-size: 13px; color: var(--sidebar-muted); }
.nav-sub a.active { color: #fff; background: transparent; }
.nav-sub a.active::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #60a5fa; margin-left: -19px; margin-right: 7px; }
.nav-sep { margin: 16px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--sidebar-muted); }
.sidebar-foot { display: flex; align-items: center; gap: 4px; border-top: 1px solid #1e293b; padding-top: 12px; }
.sidebar-foot .icon-btn { color: var(--sidebar-muted); }
.sidebar-foot .icon-btn:hover { background: var(--sidebar-active); color: #fff; }
.me { flex: 1; display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 8px; color: var(--sidebar-text); text-decoration: none !important; min-width: 0; }
.me:hover, .me.active { background: var(--sidebar-active); }
.me-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.me-text b { color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--sidebar-muted); font-size: 12px; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.scrim { display: none; }
.main { flex: 1; }
.page { max-width: 1280px; margin: 0 auto; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 20px; }
.page-wide { max-width: none; }
.page-narrow { max-width: 640px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.back .ico { width: 16px; height: 16px; }

.loading { display: grid; place-items: center; padding: 80px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Tarjetas ============ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card-flush { padding: 0; gap: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-head h2 .ico { color: var(--muted); }
.error-card { color: var(--danger); }
.link { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; font-weight: 550; }
.link .ico { width: 15px; height: 15px; }
.section { display: flex; flex-direction: column; gap: 12px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }
.mini-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; }

/* KPIs */
.kpis { display: grid; gap: 14px; }
.kpis-4 { grid-template-columns: repeat(4, 1fr); }
.kpis-3 { grid-template-columns: repeat(3, 1fr); }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; color: var(--text); text-decoration: none !important; position: relative; overflow: hidden;
}
.kpi-flat { }
.kpis-flat .kpi { box-shadow: none; background: var(--surface-2); padding: 12px 14px; }
.kpi-link:hover { border-color: var(--border-strong); }
.kpi-cps { border-top: 3px solid var(--cps); }
.kpi-exterior { border-top: 3px solid var(--ext); }
.kpi-auxiliar { border-top: 3px solid var(--aux); }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 550; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpis-flat .kpi-value { font-size: 20px; }
.kpi-sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; font-weight: 650; }
.delta .ico { width: 14px; height: 14px; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }

/* Badges / estados */
.badge { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 650; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.badge-cps { background: var(--cps-soft); color: var(--cps); border-color: transparent; }
.badge-exterior { background: var(--ext-soft); color: var(--ext); border-color: transparent; }
.badge-auxiliar { background: var(--aux-soft); color: var(--aux); border-color: transparent; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-ok { color: var(--ok); }
.status-off { color: var(--danger); }
.role { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.role-admin { background: var(--primary-soft); color: var(--primary); }
.role-editor { background: var(--ok-soft); color: var(--ok); }
.role-lector { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.role-help { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; font-size: 13px; }
.role-help div { display: flex; flex-direction: column; }

.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; background: var(--primary); color: #fff; font-weight: 650; font-size: 12px; }
.avatar-cps { background: var(--cps-soft); color: var(--cps); }
.avatar-exterior { background: var(--ext-soft); color: var(--ext); }
.avatar-auxiliar { background: var(--aux-soft); color: var(--aux); }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.avatar-xl { width: 128px; height: 128px; font-size: 42px; box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--border); }
.avatar { overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.person { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.person-btn { border: 0; background: transparent; padding: 2px 6px 2px 2px; margin: -2px 0 -2px -2px; border-radius: 99px; cursor: pointer; text-align: left; }
.person-btn b { transition: color .15s; }
.person-btn:hover b { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.person-btn:hover .avatar { box-shadow: 0 0 0 2px var(--primary); }
.danger-text { color: var(--danger) !important; }

/* Ficha del empleado */
.ficha { display: flex; flex-direction: column; gap: 20px; }
.ficha-head { display: flex; gap: 24px; align-items: center; padding: 20px; margin: -20px -20px 0; background: linear-gradient(135deg, var(--primary-soft), transparent 70%); border-bottom: 1px solid var(--border); }
.ficha-baja .ficha-head { background: linear-gradient(135deg, var(--danger-soft), transparent 70%); }
.ficha-photo { display: flex; flex-direction: column; align-items: center; gap: 10px; flex: none; }
.ficha-photo-actions { display: flex; gap: 4px; }
.ficha-id { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ficha-id h2 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.ficha-puesto { font-size: 16px; color: var(--text-2); }
.ficha-tags { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ficha-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ficha-stats > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.ficha-stats span { font-size: 12px; color: var(--muted); }
.ficha-stats b { font-size: 20px; font-variant-numeric: tabular-nums; }
.ficha-horas { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--border); padding-top: 16px; }
.ficha-horas-head { display: flex; justify-content: space-between; align-items: center; }
.ficha-horas-head h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ficha-horas-head .stepper b { font-size: 14px; min-width: 44px; }
.txt-pos { color: var(--primary); }
.txt-neg { color: var(--danger); }
.ficha-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; margin: 0; }
.ficha-dato dt { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; margin-bottom: 2px; }
.ficha-dato dd { margin: 0; font-size: 15px; word-break: break-word; }
.ficha-notas { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border); padding-top: 16px; }
.ficha-notas h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.notas { white-space: pre-wrap; font-size: 15px; line-height: 1.6; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; max-height: 320px; overflow-y: auto; }
.photo-field { display: flex; align-items: center; gap: 16px; }
.photo-field-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.person-lg { gap: 14px; }

/* Listas y ranking */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list > li + li { border-top: 1px solid var(--border); }
.list-link { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 4px; color: var(--text); text-decoration: none !important; }
.list-link:hover { background: var(--surface-2); }
.list-link .muted { display: inline-flex; align-items: center; gap: 4px; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; }
.list-compact { max-height: 320px; overflow-y: auto; }
.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.rank li { display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; column-gap: 10px; row-gap: 5px; align-items: center; }
.rank-tight li { grid-template-columns: 1fr auto; }
.rank-n { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--muted); }
.rank-name { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-weight: 550; }
.rank-name small { width: 100%; font-weight: 400; }
.rank-val { font-weight: 650; font-variant-numeric: tabular-nums; }
.rank-bar { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.rank li:not(:has(.rank-n)) .rank-bar { grid-column: 1 / -1; }
.rank-n ~ .rank-bar { grid-column: 2 / -1; }
.rank-bar span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }

.shift-chip { display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 5px; border-radius: 5px; background: var(--c); color: #fff; font-size: 11px; font-weight: 700; flex: none; }

.empty { text-align: center; padding: 28px 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); }
.empty-title { font-weight: 650; color: var(--text-2); }

/* Gráfico */
.bar-chart { position: relative; }
.bar-chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.grid-line { stroke: var(--border); stroke-width: 1; }
.axis-line { stroke: var(--border-strong); stroke-width: 1; }
.axis-label { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.bar { fill: var(--primary); opacity: .55; transition: opacity .15s; }
.bar-current { opacity: 1; }
.bar-hit { fill: transparent; }
.bar-g.hover .bar { opacity: 1; }
.bar-g.hover .bar-hit { fill: var(--surface-2); }
.chart-tip {
  position: absolute; transform: translate(-50%, calc(-100% - 12px)); pointer-events: none;
  background: var(--text); color: var(--surface); padding: 6px 10px; border-radius: 6px; font-size: 12px;
  display: flex; flex-direction: column; white-space: nowrap; box-shadow: var(--shadow-lg);
}

/* ============ Tablas ============ */
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot th { background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; color: var(--text); font-size: 13px; text-transform: none; }
.table th.num { text-align: right; }
.table-tight th, .table-tight td { padding: 7px 10px; }
.table-tight input:not([type=color]) { height: 32px; }
.table-foot { padding: 10px 16px; font-size: 12px; border-top: 1px solid var(--border); }
.row-actions { text-align: right; white-space: nowrap; width: 1%; }
.in-code { width: 70px !important; text-transform: uppercase; }
.in-num { width: 80px !important; }

/* ============ Barra de herramientas ============ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tab { padding: 10px 14px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none !important; display: inline-flex; gap: 8px; align-items: center; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count:not(:empty) { font-size: 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 0 7px; color: var(--muted); }
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.search { position: relative; flex: 1; max-width: 420px; min-width: 200px; }
.search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search input { padding-left: 34px !important; }
.search-sm { max-width: 220px; min-width: 140px; }
.search-sm input { height: 30px !important; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 550; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper b { font-size: 16px; min-width: 60px; text-align: center; }
.month-label { min-width: 150px !important; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters select { width: auto; min-width: 190px; }

/* ============ Cuadrantes: listado ============ */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.q-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; align-items: center; padding-right: 8px; }
.q-card:hover { border-color: var(--border-strong); }
.q-card-main { flex: 1; display: flex; gap: 12px; align-items: center; padding: 16px; color: var(--text); text-decoration: none !important; min-width: 0; }
.q-card-main h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-card-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.q-card-actions { display: flex; }

.picker { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.picker-bar { display: flex; gap: 8px; padding: 8px; background: var(--surface-2); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.picker-list { max-height: 260px; overflow-y: auto; }
.picker-item { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.picker-item:last-child { border-bottom: 0; }
.picker-item:hover { background: var(--surface-2); }
.picker-item input { width: 16px; height: 16px; accent-color: var(--primary); }
.fieldset { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.fieldset legend { font-size: 13px; font-weight: 550; color: var(--text-2); padding: 0 4px; }
.cob-grid { display: grid; grid-template-columns: 1fr 110px 110px; gap: 8px 10px; align-items: center; font-size: 13px; }
.cob-grid b { font-size: 12px; color: var(--muted); text-align: center; }
.turnos-table td { padding: 5px 6px; }
.in-time { width: 105px !important; }
.in-check { width: 16px; height: 16px; accent-color: var(--primary); }
.t-aus [name=cobertura] { opacity: .35; pointer-events: none; }
.in-puesto { width: 120px !important; }
.in-grupo { width: 105px !important; }
.in-pl { width: 118px !important; }
.t-aus [name=puesto], .t-aus [name=inicio], .t-aus [name=fin], .t-aus [name=horas] { opacity: .35; pointer-events: none; }
.t-new td { background: var(--surface-2); border-top: 1px dashed var(--border-strong); }
.cursos { display: flex; flex-direction: column; gap: 6px; }
.curso { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; background: var(--ok-soft); border-radius: var(--radius-sm); padding: 8px 12px; }
.curso input { width: auto !important; height: 30px !important; }
.cal-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.dot-fest { background: var(--danger); }
.dot-puente { background: var(--puente-strong); }
.picker-bar-pl { align-items: center; }
.pl-btn .pl-count { font-size: 11px; opacity: .7; font-weight: 500; }
.pl-btn.on.pl-btn-cps { background: var(--cps-soft); border-color: var(--cps); color: var(--cps); }
.pl-btn.on.pl-btn-exterior { background: var(--ext-soft); border-color: var(--ext); color: var(--ext); }
.pl-btn.on.pl-btn-auxiliar { background: var(--aux-soft); border-color: var(--aux); color: var(--aux); }
.picker-group { padding: 6px 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1; }
.nowrap { white-space: nowrap; }
.turno-new { display: grid; grid-template-columns: 80px 1fr 50px 90px auto; gap: 8px; align-items: center; padding-top: 8px; border-top: 1px dashed var(--border); }
.turno-new input { height: 34px !important; }
.confirm-text { font-size: 15px; color: var(--text-2); }

/* ============ Cuadrantes: editor ============ */
.palette { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.pal-group { display: grid; grid-template-columns: 120px 1fr; gap: 10px; align-items: center; }
.pal-group-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.pal-group-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.pal-btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px 0 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-weight: 550; color: var(--text-2); }
.pal-btn .shift-chip { min-width: 28px; height: 26px; font-size: 12px; }
.pal-txt { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.pal-txt b { font-size: 13px; font-variant-numeric: tabular-nums; }
.pal-txt small { font-size: 11px; color: var(--muted); font-weight: 500; }
.pal-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.cell-info { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 26px; }
.ci-label { color: var(--muted); font-weight: 600; }
.q-legend-top { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; font-size: 12px; color: var(--text-2); margin-top: -8px; }
.q-legend-top > span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border-strong); }
.sw-we { background: var(--weekend); }
.sw-fest { background: var(--festivo); }
.esc-pill { display: inline-grid; place-items: center; min-width: 18px; height: 16px; padding: 0 3px; border-radius: 4px; font-size: 9px; font-weight: 800; letter-spacing: .02em; }
.esc-f { background: var(--danger); color: #fff; }
.esc-p { background: var(--puente-strong); color: #fff; }
.pal-btn:hover { border-color: var(--border-strong); }
.pal-btn.active { border-color: var(--c, var(--text)); box-shadow: 0 0 0 2px var(--c, var(--text)); color: var(--text); }
.pal-btn[data-tool=erase] { padding-left: 10px; }
.hint { font-size: 12px; color: var(--muted); margin-top: -10px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.save-state { font-size: 12px; color: var(--muted); margin-right: 6px; }
.save-state.ok { color: var(--ok); }
.save-state.pending { color: var(--warn); }
.save-state.err { color: var(--danger); }

.q-scroll { overflow: auto; max-height: calc(100vh - 40px); }
.q-table { border-collapse: separate; border-spacing: 0; font-size: 12px; user-select: none; }
.q-table th, .q-table td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.q-table thead th { position: sticky; top: 0; z-index: 3; background: var(--surface-2); }
.q-table tfoot td, .q-table tfoot th { background: var(--surface-2); color: var(--muted); font-weight: 600; text-align: center; height: 26px; }
.q-table tfoot tr:first-child td, .q-table tfoot tr:first-child th { border-top: 2px solid var(--border-strong); }
.q-table .foot-total td, .q-table .foot-total th { color: var(--text); }
.q-name { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; min-width: 200px; max-width: 240px; padding: 0 6px 0 12px; font-weight: 500; }
thead .q-name { z-index: 4; background: var(--surface-2); font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 650; }
.q-table tfoot .q-name { background: var(--surface-2); text-align: left; font-weight: 550; color: var(--text-2); }
.q-table tfoot .q-name .shift-chip { margin-right: 4px; }
.q-name-in { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.q-emp { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; padding: 5px 0; font-size: 13px; }
.q-emp small { color: var(--muted); font-weight: 400; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-day { width: 34px; min-width: 34px; padding: 4px 0; text-align: center; font-weight: 600; cursor: default; }
.q-day .dn { display: block; font-size: 13px; color: var(--text); }
.q-day .dw { display: block; font-size: 10px; color: var(--muted); font-weight: 500; }
.q-day.fest .dn { color: var(--danger); }
.q-cell { width: 34px; min-width: 34px; height: 36px; text-align: center; font-weight: 700; color: #fff; cursor: cell; background: var(--surface); }
.q-cell.puente, .q-table thead .puente { background: var(--puente); }
.q-day.puente .dn { color: var(--puente-strong); }
.q-cell.we, .q-table thead .we { background: var(--weekend); }
.q-cell.fest, .q-table thead .fest { background: var(--festivo); }
.q-table thead tr:first-child th { height: 40px; }
.q-table .esc-row th { top: 40px; height: 22px; padding: 0; text-align: center; }
.q-tot.pos { color: var(--primary); }
.q-tot.neg { color: var(--danger); }
.foot-cob td { font-size: 13px; }
.cob-ok { color: var(--ok); font-weight: 800; }
.cob-val { display: inline-block; min-width: 26px; padding: 1px 4px; border-radius: 5px; font-weight: 700; font-size: 12px; font-variant-numeric: tabular-nums; cursor: help; }
.cob-green { background: var(--ok-soft); color: var(--ok); }
.cob-yellow { background: #fde68a; color: #854d0e; }
.cob-yellow-txt { color: #ca8a04; font-size: 11px; }
.cob-red { background: var(--danger); color: #fff; }
.cob-neutral { background: var(--surface-2); color: var(--text-2); }
.cob-red-txt { color: var(--danger); font-size: 11px; }
.cob-bad { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--danger); color: #fff; font-weight: 800; font-size: 11px; cursor: help; }
.cob-ok-txt { color: var(--ok); font-size: 11px; }
.cob-bad-txt { color: var(--danger); font-size: 11px; }
.q-legend { display: flex; flex-wrap: wrap; gap: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; font-size: 13px; }
.q-legend-col { display: flex; flex-direction: column; gap: 5px; }
.q-legend-col h4 { margin: 0 0 2px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.q-legend-col .shift-chip { min-width: 28px; }
.q-day.today { box-shadow: inset 0 -3px 0 var(--primary); }
.q-cell.today { box-shadow: inset 2px 0 0 var(--primary), inset -2px 0 0 var(--primary); }
.q-cell.filled { background: var(--c); box-shadow: inset 0 0 0 2px var(--surface); border-radius: 0; }
.q-cell:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
.q-tot { min-width: 56px; text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; background: var(--surface-2); color: var(--text); padding: 0 6px; }
thead .q-tot { font-size: 11px; text-transform: uppercase; color: var(--muted); }

.dropdown { position: absolute; z-index: 200; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 4px; min-width: 260px; display: flex; flex-direction: column; }
.dropdown button { text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 6px; cursor: pointer; color: var(--text-2); }
.dropdown button:hover { background: var(--surface-2); color: var(--text); }
.dropdown button.danger { color: var(--danger); }
.dropdown hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* ============ Facturación ============ */
.fact-layout { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-head { padding: 10px; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); text-align: center; }
.cal-cell {
  min-height: 104px; border: 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  background: var(--surface); padding: 8px; text-align: left; display: flex; flex-direction: column; gap: 4px; cursor: pointer; position: relative; min-width: 0;
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:hover { background: var(--primary-soft); }
.cal-cell.we { background: var(--weekend); }
.cal-cell.we:hover { background: var(--primary-soft); }
.cal-empty { cursor: default; background: var(--surface-2); }
.cal-empty:hover { background: var(--surface-2); }
.cal-day { font-weight: 650; font-size: 13px; color: var(--text-2); }
.cal-cell.today .cal-day { background: var(--primary); color: #fff; border-radius: 99px; width: 24px; height: 24px; display: grid; place-items: center; margin: -3px 0 0 -3px; }
.cal-sum { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum-short { display: none; }
.cal-meter { height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.cal-meter span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.cal-people { display: flex; gap: 2px; margin-top: auto; flex-wrap: wrap; }
.mini-av { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 9px; font-weight: 700; }
.mini-more { font-size: 11px; color: var(--muted); align-self: center; margin-left: 2px; }
.cal-add { opacity: 0; color: var(--primary); margin: auto; transition: opacity .15s; }
.cal-cell:hover .cal-add { opacity: 1; }
.day-form { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.day-form-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ============ Modal ============ */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: grid; place-items: center; padding: 16px; z-index: 100; animation: fade .15s; }
.modal { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: pop .18s; }
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 1040px; }
.modal-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

/* ============ Toasts ============ */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 300; }
.toast { background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; max-width: 380px; animation: pop .2s; transition: opacity .3s, transform .3s; border-left: 4px solid var(--ok); }
.toast-error { border-left-color: var(--danger); }
.toast.out { opacity: 0; transform: translateX(20px); }

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  .grid-2, .fact-layout { grid-template-columns: 1fr; }
  .kpis-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 28px 20px; }
  .auth-list, .auth-claim { display: none; }
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar.open + .scrim { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 30; }
  .topbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--sidebar); position: sticky; top: 0; z-index: 20; }
  .topbar .icon-btn { color: #fff; }
  .brand-sm { font-size: 14px; }
  .brand-sm .ico { width: 26px; height: 26px; padding: 5px; }
  .page { padding: 20px 16px 40px; }
  .kpis-3 { grid-template-columns: 1fr; }
  .form-grid, .form-grid-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .role-help { grid-template-columns: 1fr; }
  .ficha-head { flex-direction: column; text-align: center; }
  .ficha-tags { justify-content: center; }
  .ficha-stats, .ficha-grid { grid-template-columns: 1fr; }
  .ficha-grid .span-2 { grid-column: auto; }
  .cal-cell { min-height: 72px; padding: 5px; }
  .cal-sum { font-size: 11px; }
  .sum-full { display: none; }
  .sum-short { display: inline; }
  .cal-people { display: none; }
  .q-name { min-width: 140px; }
  .turno-new { grid-template-columns: 70px 1fr 50px; }
  .pal-group { grid-template-columns: 1fr; gap: 4px; }
  .cob-grid { grid-template-columns: 1fr 70px 70px; }
  .search { max-width: none; }
}
@media (max-width: 480px) {
  .kpis-4 { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 20px; }
  .cal-head { padding: 6px 0; font-size: 10px; }
  .filters select { min-width: 0; flex: 1; }
}

/* ============ Impresión ============ */
/* La impresión está en print.css */
.print-only { display: none; }
.q-cell.code-long { font-size: 9px; letter-spacing: -.02em; }

