/* ==========================================================================
   Turnos Vitacoria — estilos
   Sistema simple: tokens de color/espacio arriba, componentes abajo.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #f8f9f7;
  --surface-3: #eff1ed;
  --line: #e3e6e1;
  --line-soft: #eef0ec;
  --text: #16201a;
  --muted: #5f6963;
  --faint: #9aa29d;

  --primary: #1f4d3a;
  --primary-hover: #173d2e;
  --primary-soft: #e8f1ec;
  --on-primary: #ffffff;
  --focus: rgba(31, 77, 58, .28);

  --gold: #b08a45;
  --gold-soft: #f7efdd;
  --gold-text: #6b5120;

  --danger: #c2412d;
  --danger-soft: #fdeeeb;
  --danger-text: #a3301f;
  --warn-soft: #fcf3dd;
  --warn-text: #865f10;
  --ok: #1f7a4d;
  --ok-soft: #e6f4ec;
  --ok-text: #1a6640;
  --info-soft: #eceffc;
  --info-line: #6574c4;
  --info-text: #2d3a8c;

  /* Cambios de rutina en la vista semanal */
  --cambio: #f6e7c4;
  --cambio-borde: #d9b46a;
  --cambio-texto: #5a4316;
  --intercambio: #e4e8fb;
  --intercambio-borde: #8e9ae0;
  --intercambio-texto: #28337f;
  --rutina: #ffffff;
  --rutina-borde: #e3e6e1;

  /* Franjas del día */
  --fr-manana: #e9b949;
  --fr-tarde: #df8a5b;
  --fr-noche: #6271b8;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --sombra-1: 0 1px 2px rgba(16, 24, 20, .05);
  --sombra-2: 0 1px 2px rgba(16, 24, 20, .04), 0 6px 20px -6px rgba(16, 24, 20, .10);
  --sombra-3: 0 24px 60px -12px rgba(16, 24, 20, .35);
  --fuente: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0e1311;
    --surface: #151b18;
    --surface-2: #1a221e;
    --surface-3: #212a25;
    --line: #2a3530;
    --line-soft: #222c27;
    --text: #e7ece9;
    --muted: #a1aca6;
    --faint: #6d7873;
    --primary: #6cc39a;
    --primary-hover: #84d2ad;
    --primary-soft: #1d3329;
    --on-primary: #0b1a13;
    --focus: rgba(108, 195, 154, .35);
    --gold: #d6b06a;
    --gold-soft: #2d2617;
    --gold-text: #e8cf98;
    --danger: #ef7a66;
    --danger-soft: #3a1d18;
    --danger-text: #f6a395;
    --warn-soft: #33290f;
    --warn-text: #ecc76c;
    --ok: #6cc39a;
    --ok-soft: #173126;
    --ok-text: #8fd6b3;
    --info-soft: #20254a;
    --info-line: #8e9ae0;
    --info-text: #bcc4f5;
    --cambio: #3b3019;
    --cambio-borde: #8a6d32;
    --cambio-texto: #f0d9a3;
    --intercambio: #252c55;
    --intercambio-borde: #5d6bc0;
    --intercambio-texto: #cdd3fa;
    --rutina: #1c2420;
    --rutina-borde: #2f3a34;
    --sombra-1: 0 1px 2px rgba(0, 0, 0, .3);
    --sombra-2: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -8px rgba(0, 0, 0, .5);
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 14.5px/1.5 var(--fuente);
  font-feature-settings: "cv11", "ss01";
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.015em; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
h4 { font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
b, strong { font-weight: 600; }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
pre { background: #0f1512; color: #dfe7e2; padding: 14px 16px; border-radius: var(--r); overflow-x: auto; font-size: 12.5px; line-height: 1.55; }
[hidden] { display: none !important; }
::selection { background: var(--primary-soft); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  font: inherit; font-weight: 500; font-size: 13.5px;
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap; box-shadow: var(--sombra-1);
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--line) 60%, var(--text) 20%); }
.btn:focus-visible, .btn-link:focus-visible, .tira-dia:focus-visible, .chip-semana:focus-visible, .pt-cab:focus-visible, .pm-dia:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.btn.primario { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.primario:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.peligro { color: var(--danger-text); }
.btn.peligro:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn.chico { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-link { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 6px 10px; border-radius: var(--r-sm); }
.btn-link:hover { background: var(--surface-3); }

/* ---------- Formularios ---------- */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.form .fila { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 11px; width: 100%;
  height: 38px; transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 9px 11px; min-height: 80px; }
select { padding-right: 30px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a948e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--line) 50%, var(--muted)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; flex: none; }
input[type=color] { padding: 3px; cursor: pointer; }
label.check { display: flex; align-items: center; gap: 9px; color: var(--text); font-size: 14px; font-weight: 400; }
.dias { display: flex; flex-wrap: wrap; gap: 6px; }
.dias label { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font-weight: 400; }
.acciones { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 6px; }

/* ---------- Mensajes ---------- */
.msg { padding: 11px 14px; border-radius: var(--r-sm); font-size: 13.5px; border: 1px solid transparent; }
.msg.error { background: var(--danger-soft); color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 20%, transparent); }
.msg.ok { background: var(--ok-soft); color: var(--ok-text); border-color: color-mix(in srgb, var(--ok) 20%, transparent); }
.msg.aviso { background: var(--warn-soft); color: var(--warn-text); border-color: color-mix(in srgb, var(--gold) 25%, transparent); }

/* ---------- Login ---------- */
.pantalla-login {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background:
    radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--gold) 14%, transparent), transparent 60%),
    var(--bg);
}
.caja-login { width: 100%; max-width: 400px; background: var(--surface); padding: 36px 32px 32px; border-radius: var(--r-lg); border: 1px solid var(--line); box-shadow: var(--sombra-2); }
.caja-login h1 { font-size: 24px; display: flex; align-items: center; gap: 10px; }
.caja-login h1::before, .marca::before {
  content: ""; flex: none; width: 30px; height: 30px; border-radius: 9px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='17' rx='3'/%3E%3Cpath d='M3 9h18M8 2v4M16 2v4'/%3E%3Cpath d='m9 15 2 2 4-4'/%3E%3C/svg%3E") center / 17px no-repeat,
    linear-gradient(135deg, #2a6a50, #1f4d3a);
}
.caja-login h1 span, .marca span { color: var(--muted); font-weight: 500; }
.caja-login .sub { color: var(--muted); margin: 6px 0 24px; font-size: 14px; }
.caja-login .btn.primario { height: 40px; margin-top: 4px; }

/* ---------- Barra superior ---------- */
.barra {
  display: flex; align-items: center; gap: 20px;
  height: 60px; padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.marca { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.marca::before { width: 28px; height: 28px; border-radius: 8px; background-size: 15px, auto; }
#nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
#nav::-webkit-scrollbar { display: none; }
#nav a { color: var(--muted); text-decoration: none; padding: 7px 12px; border-radius: var(--r-sm); font-size: 13.5px; font-weight: 500; white-space: nowrap; transition: background .15s, color .15s; }
#nav a:hover { color: var(--text); background: var(--surface-3); }
#nav a.activo { color: var(--primary); background: var(--primary-soft); }
.usuario { display: flex; gap: 2px; font-size: 13.5px; color: var(--muted); align-items: center; }
#btn-cuenta { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; }
#btn-cuenta::before { content: ""; width: 26px; height: 26px; border-radius: 50%; background: var(--primary-soft)
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231f4d3a' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21c1.5-4 4.5-6 8-6s6.5 2 8 6'/%3E%3C/svg%3E") center / 15px no-repeat; }

/* ---------- Diseño general ---------- */
.contenido { max-width: 1400px; margin: 0 auto; padding: 28px 24px 48px; }
.cabecera { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 20px; }
.cabecera h2 { display: flex; align-items: center; }
.cabecera .herr { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ayuda { color: var(--muted); font-size: 13px; max-width: 75ch; }
.vacio { color: var(--faint); text-align: center; padding: 32px; }
.inactivo { opacity: .5; }

/* ---------- Tarjetas y tablas ---------- */
.tarjeta { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--sombra-1); }
.grilla-tarjetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; }
.tabla-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); box-shadow: var(--sombra-1); }
table.lista { width: 100%; border-collapse: collapse; background: var(--surface); }
.tarjeta table.lista, .bloque table.lista { border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; border-collapse: separate; border-spacing: 0; }
table.lista th, table.lista td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; vertical-align: middle; }
table.lista th { background: var(--surface-2); font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
table.lista tbody tr { transition: background .12s; }
table.lista tbody tr:hover { background: var(--surface-2); }
table.lista tr:last-child td { border-bottom: 0; }
table.lista td.num, table.lista th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.lista td a { color: var(--text); }
table.lista td a:hover { color: var(--primary); }
.chip { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--surface-3); color: var(--muted); margin: 1px 3px 1px 0; }
.chip.titular { background: var(--primary-soft); color: var(--primary); }
.chip.franquero { background: var(--gold-soft); color: var(--gold-text); }
.chip.apoyo { background: var(--info-soft); color: var(--info-text); }
.chip.admin { background: var(--primary); color: var(--on-primary); }

/* ---------- Encabezado del calendario ---------- */
.mes-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mes-nav h2 { min-width: 190px; text-align: center; text-transform: capitalize; font-size: 20px; }
.mes-nav h2.titulo-semana { font-size: 17px; min-width: 0; text-transform: none; padding: 0 6px; }
.mes-nav h3 { font-size: 16px; }
.mes-nav > .btn:not(.chico) { width: 36px; padding: 0; font-size: 18px; line-height: 1; }
.mes-nav input[type=date] { height: 36px; width: auto; }
.selector-vista { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-3); border-radius: 10px; }
.selector-vista .btn { box-shadow: none; border-color: transparent; background: transparent; color: var(--muted); height: 30px; }
.selector-vista .btn:hover { color: var(--text); background: transparent; }
.selector-vista .btn.activo { background: var(--surface); color: var(--text); box-shadow: var(--sombra-1), 0 0 0 1px var(--line); }

/* Tira de días del mes */
.tira-dias { display: flex; gap: 4px; overflow-x: auto; padding: 2px 2px 12px; margin-bottom: 6px; scrollbar-width: thin; }
.tira-dia { position: relative; flex: 1 0 38px; min-width: 38px; padding: 5px 0 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--text); font-variant-numeric: tabular-nums; transition: background .12s, border-color .12s; }
.tira-dia:hover { border-color: var(--primary); }
.tira-dia small { display: block; font-size: 10.5px; font-weight: 500; color: var(--faint); text-transform: uppercase; letter-spacing: .03em; }
.tira-dia.finde { background: var(--surface-2); }
.tira-dia.feriado small { color: var(--danger); }
.tira-dia.activo { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.tira-dia.activo small { color: color-mix(in srgb, var(--on-primary) 75%, transparent); }
.tira-dia .punto { position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); }

/* Leyenda */
.leyenda { display: flex; gap: 8px 16px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--muted); margin: 4px 0 16px; }
.leyenda > span { display: inline-flex; align-items: center; gap: 6px; }
.leyenda > span:last-child { flex-basis: 100%; color: var(--faint); }
.leyenda b { font-weight: 500; color: var(--text); }
.leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.ley-persona { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; padding: 2px 8px 2px 6px; border-radius: 99px; transition: background .12s; color: var(--text); }
.ley-persona:hover { background: var(--surface-3); }
.ley-persona i { width: 10px; height: 10px; border-radius: 50%; }
.ley-personas { display: inline-flex; flex-wrap: wrap; gap: 2px 4px; padding-left: 12px; border-left: 1px solid var(--line); }
.ley-sep { margin-left: 4px; }
.ley-cubre { width: 16px !important; background: repeating-linear-gradient(135deg, #7b847e 0 3px, #b9c0bb 3px 6px); }
.ley-rutina, .ley-cambio, .ley-falta, .ley-intercambio { width: 16px !important; height: 12px !important; border-radius: 4px !important; }
.ley-rutina { background: var(--rutina); border: 1px solid var(--rutina-borde); }
.ley-cambio { background: var(--cambio); border: 1px solid var(--cambio-borde); }
.ley-intercambio { background: var(--intercambio); border: 1px solid var(--intercambio-borde); }
.ley-falta { background: var(--danger-soft); border: 1px dashed var(--danger); }
.punto-persona { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; flex: none; }
.punto-persona.grande { width: 14px; height: 14px; margin-right: 12px; vertical-align: 2px; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 0%, var(--surface-3)); }

/* Alertas */
.alertas { margin-bottom: 14px; border-radius: var(--r); border: 1px solid transparent; overflow: hidden; }
.alertas summary { cursor: pointer; font-weight: 500; font-size: 13.5px; padding: 11px 14px 11px 40px; position: relative; list-style: none; }
.alertas summary::-webkit-details-marker { display: none; }
.alertas summary::before { content: ""; position: absolute; left: 14px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); background: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat; }
.alertas.con { background: var(--danger-soft); color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 18%, transparent);
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z'/%3E%3Cpath d='M12 9v4M12 17h.01'/%3E%3C/svg%3E"); }
.alertas.sin { background: var(--ok-soft); color: var(--ok-text); border-color: color-mix(in srgb, var(--ok) 18%, transparent);
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m8 12 3 3 5-6'/%3E%3C/svg%3E"); }
.alertas.sin summary { cursor: default; }
.alertas ul { margin: 0; padding: 4px 8px 10px; list-style: none; max-height: 260px; overflow: auto; display: grid; gap: 4px; }
.alertas li { padding: 7px 12px; font-size: 13px; border-radius: var(--r-sm); background: var(--surface); color: var(--text); border-left: 3px solid var(--danger); }
.alertas li.aviso { border-left-color: var(--gold); }
.alertas li b { font-weight: 600; }
.alertas li[style*="cursor"]:hover { background: var(--surface-2); }

/* Navegación entre semanas */
.nav-semanas { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sombra-1); }
.chips-semanas { display: flex; gap: 4px; order: 4; flex-basis: 100%; justify-content: center; flex-wrap: wrap; }
.chip-semana { font: inherit; font-size: 12.5px; font-weight: 500; height: 30px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; white-space: nowrap; transition: .12s; }
.chip-semana:hover { color: var(--text); border-color: color-mix(in srgb, var(--line) 50%, var(--muted)); }
.chip-semana.actual { border-color: var(--primary); color: var(--primary); }
.chip-semana.activo { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.nav-semanas .btn.activo { background: var(--primary-soft); color: var(--primary); border-color: transparent; box-shadow: none; }

/* ---------- Vista por horas (días apilados) ---------- */
#dias { display: grid; gap: 12px; }
#dias.vista-simple { display: block; }
.dia-horas { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px 12px; box-shadow: var(--sombra-1); scroll-margin-top: 80px; transition: box-shadow .2s, border-color .2s; }
.dia-horas.finde { background: linear-gradient(var(--surface-2), var(--surface-2)); }
.dia-horas.activo { border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus), var(--sombra-1); }
.dia-horas header { display: flex; gap: 6px 12px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; }
.dia-horas header > b { font-size: 15px; font-weight: 600; }
.dia-horas header .feriado { color: var(--danger-text); background: var(--danger-soft); font-size: 11px; font-weight: 500; padding: 1px 8px; border-radius: 99px; }
.dia-horas header .dia-info { display: inline-flex; flex-wrap: wrap; gap: 2px 14px; font-size: 12.5px; color: var(--muted); margin: 0; }
.dia-horas header .dia-info b { color: var(--text); font-weight: 500; }
.dia-horas header .dia-info a { color: inherit; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.dia-horas header .dia-info a:hover { color: var(--primary); text-decoration-color: currentColor; }
.chip-alerta { font-size: 11.5px; font-weight: 500; background: var(--danger-soft); color: var(--danger-text); border-radius: 99px; padding: 1px 8px; }
.dia-info { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--muted); }

.carril { display: grid; grid-template-columns: 116px 1fr; gap: 10px; align-items: start; }
.carril + .carril { margin-top: 3px; }
.carril-tit { font-weight: 600; font-size: 13px; padding-top: 4px; }
.carril-tit small { display: block; font-weight: 400; color: var(--faint); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.marcas { position: relative; height: 18px; }
.marcas span { position: absolute; transform: translateX(-50%); font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.marcas span:first-child { transform: none; }
.marcas span.ultima { transform: translateX(-100%); }
.pista { position: relative; border-radius: var(--r-sm); min-height: 30px; background: var(--surface-2); }
.dia-horas.finde .pista { background: var(--surface); }
.pista::before { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background-image: linear-gradient(90deg, var(--line-soft) 1px, transparent 1px); background-size: var(--paso, 4.1667%) 100%; }
.pista .marco { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--primary) 6%, transparent); border-left: 1.5px solid color-mix(in srgb, var(--primary) 35%, transparent); border-right: 1.5px solid color-mix(in srgb, var(--primary) 35%, transparent); }
.pista .barra {
  position: absolute; z-index: 1; display: block; height: 22px; line-height: 22px; padding: 0 8px;
  border-radius: 6px; background: var(--pc, var(--primary)) !important; color: #fff;
  font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
  gap: 0; flex-wrap: nowrap; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none;
}
.pista .barra:not(.normal) { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.2) 0 6px, transparent 6px 12px) !important; }
.pista .barra small { opacity: .85; }
.pista .barra .nom-link { cursor: pointer; font-weight: 600; }
.pista .barra .nom-link:hover { text-decoration: underline; text-underline-offset: 2px; }
.pista .barra.con-alerta { outline: 2px solid var(--danger); outline-offset: 1px; }
.pista .barra.sigue { border-top-right-radius: 0; border-bottom-right-radius: 0; padding-right: 18px; }
.pista .barra.sigue::after { content: "→"; position: absolute; right: 5px; top: 0; opacity: .85; }
.pista .hueco { position: absolute; height: 22px; border-radius: 6px; background: var(--danger-soft); border: 1px dashed var(--danger); color: var(--danger-text); font-size: 11.5px; font-weight: 500; line-height: 20px; padding: 0 8px; white-space: nowrap; overflow: hidden; }
.editable .pista, .editable .pista .barra, .editable .pista .hueco { cursor: pointer; }
.editable .pista .barra:hover { filter: brightness(1.08); }

.resumen-mes { margin-top: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sombra-1); }
.resumen-mes > summary { cursor: pointer; font-weight: 600; padding: 14px 18px; list-style: none; display: flex; align-items: center; gap: 8px; }
.resumen-mes > summary::-webkit-details-marker { display: none; }
.resumen-mes > summary::before { content: "›"; display: inline-block; font-size: 18px; color: var(--muted); transition: transform .15s; }
.resumen-mes[open] > summary::before { transform: rotate(90deg); }
.resumen-mes > .resumen { margin: 0; padding: 0 18px 18px; }
.resumen-mes > .resumen > h3 { display: none; }
.resumen { margin-top: 24px; }
.tabla-resumen .valor-hora { width: 104px; height: 32px; text-align: right; padding: 0 8px; font-variant-numeric: tabular-nums; }
.tabla-resumen td.total-fila, .tabla-resumen .total-general { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tabla-resumen tfoot th { background: var(--surface-2); color: var(--text); font-size: 13.5px; text-transform: none; letter-spacing: 0; font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }

/* ---------- Vista semanal: por turno, una columna por puesto ---------- */
.pt-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); box-shadow: var(--sombra-1); }
.pt { display: grid; grid-template-columns: 132px repeat(7, minmax(160px, 1fr)); min-width: 1250px; }
.pt-esq { position: sticky; left: 0; z-index: 4; background: var(--surface); border-bottom: 1px solid var(--line); }
.pt-cab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 10px 4px; background: var(--surface); color: var(--text); border: 0; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line-soft); font: inherit; cursor: pointer; transition: background .12s; }
.pt-cab:hover { background: var(--surface-2); }
.pt-cab.finde { background: var(--surface-2); }
.pt-dsem { font-size: 11px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.pt-num { font-size: 22px; font-weight: 600; line-height: 1.2; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.pt-feriado { font-size: 10px; font-weight: 500; color: var(--danger-text); background: var(--danger-soft); padding: 0 7px; border-radius: 99px; margin-top: 2px; }
.pt-cab .punto { position: absolute; top: 9px; right: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
.pt-turno { position: sticky; left: 0; z-index: 3; display: flex; flex-direction: column; justify-content: center; gap: 1px; padding: 10px 14px; background: var(--surface); border-top: 1px solid var(--line-soft); box-shadow: inset 3px 0 0 var(--fr, var(--line)); }
.pt-turno.manana { --fr: var(--fr-manana); }
.pt-turno.tarde { --fr: var(--fr-tarde); }
.pt-turno.noche { --fr: var(--fr-noche); }
.pt-turno.francos { --fr: var(--line); background: var(--surface-2); }
.pt-turno b { font-weight: 600; font-size: 14px; }
.pt-turno span { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pt-turno small { font-size: 11.5px; color: var(--faint); }
.pt-celda { position: relative; height: 168px; background: var(--surface); border-top: 1px solid var(--line-soft); border-left: 1px solid var(--line-soft); }
.pt-celda.finde { background: var(--surface-2); }
.pt-celda[data-editar-turno] { cursor: pointer; }
.pt-celda[data-editar-turno]:hover { background: color-mix(in srgb, var(--primary) 4%, var(--surface)); }
.pt-in { position: absolute; inset: 8px 5px; }
.pt-vacio { position: absolute; inset: 0; display: grid; place-items: center; color: var(--faint); }
.pt-b {
  position: absolute; display: flex; flex-direction: column; justify-content: center; gap: 1px; overflow: hidden;
  padding: 6px 8px; border-radius: 8px; line-height: 1.25;
  background: var(--rutina); color: var(--text); border: 1px solid var(--rutina-borde); box-shadow: var(--sombra-1);
  transition: box-shadow .12s, transform .12s;
}
.editable .pt-b:hover { box-shadow: var(--sombra-2); }
.pt-b b { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
/* el color de la persona, como franja a la izquierda (no le quita ancho al nombre) */
.pt-b:not(.hueco) { border-left: 4px solid var(--pc, var(--muted)); padding-left: 7px; }
.pt-b b:hover { text-decoration: underline; text-underline-offset: 2px; }
.pt-b small { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pt-b em { font-style: normal; font-size: 11px; font-weight: 500; line-height: 1.2; overflow-wrap: break-word; }
.pt-b small { white-space: nowrap; }
.pt-b.parcial b { font-size: 12.5px; }
.pt-b.cobertura, .pt-b.reemplazo, .pt-b.refuerzo, .pt-b.extra { background: var(--cambio); border-color: var(--cambio-borde); color: var(--cambio-texto); }
.pt-b.cobertura small, .pt-b.reemplazo small, .pt-b.refuerzo small, .pt-b.extra small { color: var(--cambio-texto); opacity: .85; }
.pt-b.intercambio { background: var(--intercambio); border-color: var(--intercambio-borde); color: var(--intercambio-texto); }
.pt-b.intercambio small { color: var(--intercambio-texto); opacity: .85; }
.pt-b.hueco { background: var(--danger-soft); border: 1px dashed var(--danger); color: var(--danger-text); box-shadow: none; }
.pt-b.hueco b { cursor: default; }
.pt-b.hueco small { color: var(--danger-text); }
.pt-franco { position: relative; display: flex; flex-direction: column; gap: 2px; min-height: 38px; padding: 8px 10px; background: var(--surface-2); border-top: 1px solid var(--line); border-left: 1px solid var(--line-soft); font-size: 12.5px; color: var(--gold-text); font-weight: 500; }
.pt-franco span[data-persona] { cursor: pointer; }
.pt-franco span[data-persona]:hover { text-decoration: underline; }
.pt-franco small { color: var(--intercambio-texto); font-weight: 400; }
.pt-franco .pt-vacio { position: static; color: var(--faint); font-weight: 400; }

/* ---------- Grilla semanal 24 h (vista previa al generar) ---------- */
.semanas { display: grid; grid-template-columns: 1fr; gap: 16px; }
.semana { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--sombra-1); }
.semana-titulo { padding: 10px 14px; font-weight: 600; font-size: 13.5px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.sg-scroll { overflow-x: auto; }
.sg { --h: 22px; display: grid; grid-template-columns: 74px 36px repeat(7, minmax(88px, 1fr)); min-width: 740px; }
.sg-cab { background: var(--surface); color: var(--muted); font-size: 11.5px; text-align: center; padding: 6px 2px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; justify-content: flex-end; }
.sg-cab.sg-dia { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; font-weight: 500; }
.sg-cab.sg-dia .num { display: block; color: var(--text); font-weight: 600; font-size: 16px; text-transform: none; letter-spacing: 0; }
.sg-cab.finde { background: var(--surface-2); }
.sg-cab.fuera { opacity: .35; }
.sg-cab .feriado { display: block; font-size: 10px; color: var(--danger-text); }
.sg-col { position: relative; height: calc(var(--h) * 24); border-right: 1px solid var(--line-soft);
  background-image: linear-gradient(180deg, transparent calc(var(--h) - 1px), var(--line-soft) calc(var(--h) - 1px)); background-size: 100% var(--h); }
.sg-col.fuera { background-color: var(--surface-2); opacity: .6; }
.sg-horas, .sg-turnos { background-color: var(--surface-2); }
.sg-hora { height: var(--h); font-size: 10.5px; color: var(--faint); text-align: center; line-height: 1; padding-top: 3px; font-variant-numeric: tabular-nums; }
.sg-turno { position: absolute; left: 3px; right: 3px; border-radius: 6px; background: color-mix(in srgb, var(--c) 16%, var(--surface)); border-left: 3px solid var(--c); padding: 4px 6px; overflow: hidden; display: flex; flex-direction: column; gap: 1px; }
.sg-turno b { font-weight: 600; font-size: 12px; }
.sg-turno small { font-size: 10.5px; color: var(--muted); }
.sg-marco { position: absolute; left: 0; right: 0; background: color-mix(in srgb, var(--c) 7%, transparent); border-top: 2px solid color-mix(in srgb, var(--c) 45%, transparent); }
.sg-marco.cambio { background: var(--cambio); box-shadow: inset 0 0 0 2px var(--cambio-borde); }
.sg-marco.con-alerta { box-shadow: inset 0 0 0 2px var(--danger); }
.editable .sg-marco, .editable .sg-barra { cursor: pointer; }
.sg-barra { position: absolute; border-radius: 6px; background: var(--primary); color: #fff; overflow: hidden; z-index: 1; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.sg-barra span { writing-mode: vertical-rl; transform: rotate(180deg); display: block; height: 100%; padding: 4px 0; margin: 0 auto; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.15; }
.sg-barra small { opacity: .85; font-size: 10px; }
.sg-barra.cobertura { background: #9a7536; }
.sg-barra.reemplazo { background: #7a3f7a; }
.sg-barra.refuerzo { background: #2f5f8a; }
.sg-barra.intercambio { background: #5a63a8; }
.sg-barra.extra { background: var(--ok); }
.sg-barra.hueco { background: var(--danger-soft); color: var(--danger-text); border: 1.5px dashed var(--danger); box-shadow: none; }
.sg-barra.con-alerta { outline: 2px solid var(--danger); outline-offset: -2px; }
.sg-desc { border-top: 1px solid var(--line); border-right: 1px solid var(--line-soft); padding: 6px 4px; font-size: 12px; color: var(--gold-text); text-align: center; background: var(--surface-2); }
.sg-desc-tit { grid-column: span 2; font-weight: 600; color: var(--text); text-align: left; padding-left: 12px; }
.sg-desc.fuera { opacity: .4; }

/* Celdas de texto que todavía se usan en algunas vistas */
.p { display: block; line-height: 1.25; }
.p + .p { margin-top: 3px; }
.p .nom { font-weight: 500; }
.p .det { display: block; font-size: 11px; color: var(--muted); }
.p.cobertura .nom { color: var(--gold-text); }
.p.reemplazo .nom { color: #7a3f7a; }
.p.refuerzo .nom { color: var(--info-text); }
.p.extra .nom { color: var(--ok-text); }
.falta { color: var(--danger-text); font-weight: 500; font-size: 12px; }

/* ---------- Mes de una persona ---------- */
.pm-resumen { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.pm-resumen div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--sombra-1); }
.pm-resumen b { display: block; font-size: 24px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.pm-resumen span { font-size: 12.5px; color: var(--muted); }
.pm-grilla { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.pm-cab { text-align: center; font-size: 11px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 4px 0; }
.pm-dia { min-height: 100px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 7px 8px; font: inherit; color: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 4px; overflow: hidden; transition: border-color .12s, box-shadow .12s; }
.pm-dia:hover { border-color: var(--primary); box-shadow: var(--sombra-1); }
.pm-dia.vacio { background: transparent; border: 0; cursor: default; box-shadow: none; }
.pm-dia.finde { background: var(--surface-2); }
.pm-dia.hoy { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.pm-num { font-weight: 600; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.pm-num i { font-style: normal; font-size: 10px; font-weight: 500; color: var(--danger-text); }
.pm-turno { border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 12%, var(--surface)); border-radius: 5px; padding: 3px 6px; display: flex; flex-direction: column; font-size: 12px; line-height: 1.3; }
.pm-turno b { font-weight: 600; }
.pm-turno span { font-variant-numeric: tabular-nums; }
.pm-turno small { color: var(--muted); font-size: 11px; }
.pm-estado { font-size: 12px; font-weight: 500; border-radius: 5px; padding: 3px 6px; }
.pm-estado.franco { background: var(--gold-soft); color: var(--gold-text); }
.pm-estado.ciclo { background: var(--primary-soft); color: var(--primary); }
.pm-estado.libre { color: var(--faint); font-weight: 400; padding-left: 0; }

/* ---------- Modal ---------- */
dialog {
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0; width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 40px); box-shadow: var(--sombra-3); background: var(--surface); color: var(--text);
}
dialog[open] { animation: aparecer .18s ease-out; }
@keyframes aparecer { from { opacity: 0; transform: translateY(8px) scale(.98); } }
dialog.ancho { width: min(1320px, calc(100vw - 32px)); }
dialog:has(.miembros) { width: min(860px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 16, 13, .45); backdrop-filter: blur(3px); }
#modal-cuerpo { padding: 24px; }
.modal-cab { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 18px; }
.modal-cab h3 { font-size: 18px; }
.modal-cab .x { width: 32px; height: 32px; padding: 0; font-size: 20px; line-height: 1; color: var(--muted); border-radius: var(--r-sm); }
.bloque { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.bloque h4 { margin: 0 0 10px; }

.miembros { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 6px; }
.miembros li, .miembros-cab { display: grid; grid-template-columns: 1fr 110px 64px 190px 150px auto; gap: 6px; align-items: center; }
.miembros-cab { font-size: 11.5px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.miembros li span { font-size: 13.5px; }
.miembros li input, .miembros li select { height: 34px; }
.horario-propio { display: flex; gap: 4px; }
.horario-propio input { padding: 0 6px; }
.dias-miembro { display: flex; gap: 2px; }
.dia-tog { width: 20px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); font: inherit; font-size: 11px; color: var(--muted); cursor: pointer; }
.dia-tog.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.franja { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.franja input[type=time] { max-width: 120px; }
.franja input[type=number] { max-width: 76px; }

/* ---------- Toast y varios ---------- */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(16px);
  background: #16201a; color: #fff; padding: 10px 18px; border-radius: 10px; box-shadow: var(--sombra-3);
  opacity: 0; transition: .2s; pointer-events: none; z-index: 100; font-size: 13.5px; font-weight: 500; max-width: calc(100vw - 32px);
}
#toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); }
.token-nuevo { word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: #0f1512; color: #8fd6b3; padding: 14px; border-radius: var(--r-sm); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .barra { padding: 0 12px; gap: 10px; }
  .marca { font-size: 0; gap: 0; }
  .usuario #btn-cuenta { font-size: 0; gap: 0; padding: 4px; }
  .contenido { padding: 18px 16px 40px; }
  .grilla-tarjetas { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .mes-nav h2 { min-width: 0; font-size: 18px; }
  .cabecera { align-items: stretch; }
  .cabecera .herr { width: 100%; }
  .carril { grid-template-columns: 74px 1fr; gap: 6px; }
  .chips-semanas { justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; }
  .miembros li { grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
  .miembros li > span:first-child { grid-column: 1 / -1; font-weight: 500; }
  .miembros-cab { display: none; }
  #modal-cuerpo { padding: 18px; }
}
@media (max-width: 520px) {
  .pista .barra small { display: none; }
  .pm-grilla { gap: 3px; }
  .pm-dia { min-height: 72px; padding: 4px; }
  .pm-turno span, .pm-turno small { display: none; }
}

/* ---------- Impresión ---------- */
@media print {
  :root { color-scheme: light; }
  body { background: #fff; font-size: 11px; }
  .barra, .cabecera .herr, .alertas, .leyenda, .resumen, .resumen-mes, .selector-vista, .tira-dias, .nav-semanas, #ver-persona, .no-imprimir { display: none !important; }
  .mes-nav button, .mes-nav input { display: none; }
  .contenido { padding: 0; max-width: none; }
  .dia-horas, .semana, .pt-scroll, .tabla-wrap { box-shadow: none; break-inside: avoid; }
  .pt-scroll, .sg-scroll { overflow: visible; }
  .pt { min-width: 0; }
  .pt-turno, .pt-esq { position: static; }
  .pt-celda { height: 110px; }
  .sg { --h: 15px; min-width: 0; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
