/* ============================================================
   Planillas HC — hoja de estilos
   Consola de operaciones: superficie clara, tipografía tabular,
   color por línea e indicadores de cambio (alta/baja/modificado).
   ============================================================ */

:root {
  --ink:        #0f141b;   /* barra superior */
  --ink-soft:   #1b2635;
  --surface:    #eef1f5;   /* fondo de trabajo */
  --panel:      #ffffff;
  --line:       #e2e7ee;   /* filetes */
  --text:       #1c2532;
  --muted:      #667487;
  --accent:     #3a54bf;   /* interacción */
  --accent-ink: #2c40a0;

  --alta:  #1f8a55;
  --alta-bg:  #e6f4ec;
  --baja:  #c23a2f;
  --baja-bg:  #fbe9e7;
  --mod:   #a97400;
  --mod-bg:   #f7efdc;
  --flat:  #6a7482;
  --flat-bg:  #eceff3;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 45, .05), 0 6px 20px rgba(20, 30, 45, .05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #0a0e14; --ink-soft:#121a26; --surface:#0f141b; --panel:#161d28;
    --line:#26303e; --text:#e7ecf3; --muted:#93a0b3; --accent:#7d92f5; --accent-ink:#9fb0ff;
    --alta:#5bc48c; --alta-bg:#12271d; --baja:#e08379; --baja-bg:#2a1512;
    --mod:#d8ab4e; --mod-bg:#2a2311; --flat:#8a95a5; --flat-bg:#1b232f;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--surface);
  font-size: 15px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

h1, h2 { font-family: "Space Grotesk", "Inter", sans-serif; letter-spacing: -0.01em; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Barra superior ---------- */
.topbar { background: var(--ink); color: #eaf0f8; position: sticky; top: 0; z-index: 20; }
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 24px;
  height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
  font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 15px;
  background: var(--accent); color: #fff; width: 34px; height: 34px;
  display: grid; place-items: center; border-radius: 8px; letter-spacing: .02em;
}
.brand-text { font-weight: 600; font-size: 15px; color: #dfe7f2; }

.mainnav { display: flex; align-items: center; gap: 4px; }
.mainnav a {
  color: #b9c4d4; padding: 8px 14px; border-radius: 8px; font-weight: 500; font-size: 14px;
}
.mainnav a:hover { color: #fff; background: rgba(255,255,255,.06); text-decoration: none; }
.mainnav a.is-active { color: #fff; background: rgba(255,255,255,.10); }
.mainnav .nav-cta { background: var(--accent); color: #fff; }
.mainnav .nav-cta:hover { background: var(--accent-ink); }

/* ---------- Pestañas de línea ---------- */
.linetabs { background: var(--ink-soft); border-bottom: 1px solid rgba(255,255,255,.05); }
.linetabs-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 24px;
  display: flex; gap: 6px; overflow-x: auto;
}
.linetab {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  color: #aeb9c9; padding: 11px 14px; font-size: 13.5px; font-weight: 500;
  border-bottom: 2px solid transparent;
}
.linetab:hover { color: #fff; text-decoration: none; }
.linetab.is-active { color: #fff; border-bottom-color: currentColor; }
.linetab .dot { width: 9px; height: 9px; border-radius: 50%; }
.linetab-sub { color: #7f8da0; font-size: 12px; font-weight: 400; }

/* ---------- Estructura de página ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 32px 24px 64px; }

.pagehead { margin-bottom: 22px; }
.pagehead h1 { margin: 0 0 4px; font-size: 26px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.lede { margin: 0; color: var(--muted); font-size: 14.5px; }

.pagehead-linea { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.linea-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--linea, var(--accent)); display: inline-block; }
.pagehead-stats { display: flex; gap: 26px; }
.stat { text-align: right; }
.stat-num { display: block; font-family: "Space Grotesk", sans-serif; font-size: 28px; font-weight: 600; line-height: 1; }
.stat-lbl { font-size: 12px; color: var(--muted); }

/* ---------- Tarjetas del panel ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; margin-bottom: 40px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; position: relative; overflow: hidden;
}
.card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--linea); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-linea { font-family: "Space Grotesk", sans-serif; font-weight: 600; font-size: 16px; }
.card-empresa { color: var(--muted); font-size: 12.5px; text-align: right; }

.card-hc { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.hc-num { font-family: "Space Grotesk", sans-serif; font-size: 46px; font-weight: 700; line-height: .9; }
.hc-lbl { color: var(--muted); font-size: 13px; }
.delta { flex-basis: 100%; font-size: 12.5px; font-weight: 500; margin-top: 2px; }
.delta.up { color: var(--alta); }
.delta.down { color: var(--baja); }
.delta.flat { color: var(--flat); }

.card-meta { display: flex; gap: 26px; margin: 0 0 16px; }
.card-meta dt { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.card-meta dd { margin: 0; font-weight: 600; font-size: 15px; }
.card-link { font-weight: 500; font-size: 14px; }
.card-vacio { color: var(--muted); }
.card-vacio p { margin: 0 0 12px; }

/* ---------- Feed de cambios ---------- */
.feed-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.feed-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.seemore { font-size: 13.5px; }
.feedlist { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.feeditem { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-top: 1px solid var(--line); font-size: 14px; }
.feeditem:first-child { border-top: none; }
.feed-name { font-weight: 500; }
.feed-linea { font-weight: 600; font-size: 12px; }
.feed-detalle { color: var(--muted); font-size: 13px; }
.feed-fecha { margin-left: auto; color: var(--muted); font-size: 12.5px; }

/* ---------- Barra de herramientas / filtros ---------- */
.toolbar {
  display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 500; }
.field-grow { flex: 1 1 220px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }

select, input[type="search"], input[type="date"], input[type="file"], input[type="text"], input[type="password"] {
  font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px;
}
input[type="search"]:focus, select:focus, input[type="date"]:focus, input[type="text"]:focus, input[type="password"]:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}

.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 14px;
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  padding: 9px 16px; border-radius: 8px;
}
.btn:hover { background: var(--accent-ink); border-color: var(--accent-ink); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.btn-ghost:hover { background: var(--panel); border-color: var(--accent); }

.legend { font-size: 13px; color: var(--muted); margin: 0 0 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- Tabla ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid thead th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px;
  padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0;
}
.grid tbody td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid tbody tr:last-child td { border-bottom: none; }
.grid tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.grid .num { text-align: right; }
.tnum { font-variant-numeric: tabular-nums; }
.cell-name { font-weight: 600; }
.row-cesado { color: var(--muted); }
.row-cesado .cell-name { font-weight: 500; }

.estado { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.estado-activo { background: var(--alta-bg); color: var(--alta); }
.estado-cesado { background: var(--flat-bg); color: var(--flat); }
.grid-empty { color: var(--muted); text-align: center; padding: 28px; }

.tablefoot { color: var(--muted); font-size: 13px; margin-top: 12px; }

/* etiquetas de cambio dentro de la tabla */
.chg { display: inline-block; font-size: 12px; color: var(--muted); margin-left: 6px; }
.chg-none { color: var(--line); }

/* ---------- Etiquetas de tipo de cambio ---------- */
.tag { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag-alta { background: var(--alta-bg); color: var(--alta); }
.tag-baja { background: var(--baja-bg); color: var(--baja); }
.tag-modificado { background: var(--mod-bg); color: var(--mod); }
.tag-flat { background: var(--flat-bg); color: var(--flat); }

/* ---------- Cargar ---------- */
.cargar-cols { display: grid; grid-template-columns: minmax(0, 360px) 1fr; gap: 28px; align-items: start; }
.upload {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px;
}
.upload .field > span { font-size: 13px; }
.guia { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.guia h2 { margin: 0 0 12px; font-size: 16px; }
.guia ol { margin: 0; padding-left: 20px; color: var(--text); }
.guia li { margin-bottom: 9px; font-size: 14px; }

/* ---------- Cambios / línea de tiempo ---------- */
.chips { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.chip {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 13.5px; font-weight: 500;
}
.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 22px 30px; }
.tl-dot { position: absolute; left: 0; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--linea); border: 3px solid var(--surface); }
.tl-body { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tl-top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.tl-linea { font-family: "Space Grotesk", sans-serif; font-weight: 600; }
.tl-fecha { color: var(--muted); font-size: 13px; }
.tl-conteo { margin: 0 0 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.tl-inicial { margin: 0 0 8px; color: var(--muted); font-size: 13.5px; }
.tl-link { font-size: 13.5px; font-weight: 500; }

/* ---------- Detalle de snapshot ---------- */
.pagehead-actions { display: flex; gap: 10px; }
.diff-summary { display: flex; gap: 26px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow); margin-bottom: 24px; }
.sumcell { color: var(--muted); font-size: 14px; }
.sumcell strong { font-family: "Space Grotesk", sans-serif; font-size: 22px; color: var(--text); margin-right: 4px; }

.diffgroup { margin-bottom: 26px; }
.diffgroup h2 { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; margin: 0 0 12px; color: var(--muted); }
.difflist { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.difflist li { padding: 11px 16px; border-top: 1px solid var(--line); display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; }
.difflist li:first-child { border-top: none; }
.df-name { font-weight: 600; min-width: 220px; }
.df-changes { display: flex; gap: 14px; flex-wrap: wrap; }
.df-changes .chg { margin: 0; font-size: 13px; }
.chg-old { color: var(--baja); }
.chg-new { color: var(--alta); font-weight: 600; }

/* ---------- Avisos ---------- */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; font-size: 14px; font-weight: 500; }
.flash-ok { background: var(--alta-bg); color: var(--alta); }
.flash-error { background: var(--baja-bg); color: var(--baja); }
.panel-note { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.panel-note p { margin: 0 0 14px; }
.panel-error { border-left: 4px solid var(--baja); }
.empty { color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 24px; text-align: center; }

/* ---------- Pie ---------- */
.foot { max-width: 1120px; margin: 0 auto; padding: 24px; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--line); }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .cargar-cols { grid-template-columns: 1fr; }
  .pagehead-stats { gap: 18px; }
  .topbar-inner { padding: 0 16px; }
  .page { padding: 22px 16px 48px; }
  .brand-text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* ============================================================
   Autenticación y gestión de usuarios
   ============================================================ */

/* ---------- Barra superior: menú de usuario ---------- */
.topbar-right { display: flex; align-items: center; gap: 14px; }
.usermenu { display: flex; align-items: center; gap: 4px; padding-left: 12px; border-left: 1px solid rgba(255,255,255,.12); }
.usermenu-btn { display: inline-flex; align-items: center; gap: 8px; color: #cdd7e6; padding: 6px 8px; border-radius: 8px; font-size: 13.5px; }
.usermenu-btn:hover, .usermenu-btn.is-active { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 12px;
  font-family: "Space Grotesk", sans-serif;
}
.usermenu-name { font-weight: 500; }
.usermenu-out { color: #9fb0c6; font-size: 13px; padding: 6px 8px; border-radius: 8px; }
.usermenu-out:hover { color: #fff; background: rgba(255,255,255,.06); text-decoration: none; }

/* ---------- Página de login ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; background: var(--ink); padding: 24px; }
.auth-wrap { width: 100%; max-width: 380px; }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: 0 12px 40px rgba(0,0,0,.28); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .brand-mark { width: 40px; height: 40px; font-size: 16px; }
.auth-title { font-family: "Space Grotesk", sans-serif; font-weight: 600; font-size: 16px; color: var(--text); }
.auth-sub { color: var(--muted); font-size: 13px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form .field > span { font-size: 13px; }
.auth-form input { padding: 10px 12px; }
.auth-btn { justify-content: center; margin-top: 4px; padding: 11px 16px; font-size: 15px; }
.auth-foot { text-align: center; color: #6b7890; font-size: 12px; margin-top: 18px; }

/* ---------- Cajas de formulario ---------- */
.panel-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 22px; }
.panel-box.narrow { max-width: 460px; }
.box-title { font-family: "Space Grotesk", sans-serif; font-size: 15px; font-weight: 600; margin: 0 0 14px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 12px 0 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* Formulario de alta de usuario */
.userform { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.userform .field { min-width: 150px; }
.userform .btn { height: 38px; }

/* ---------- Tabla de usuarios ---------- */
.users td, .users th { vertical-align: middle; }
.users .mono { font-family: "Space Grotesk", ui-monospace, monospace; font-weight: 600; }
.users .you { color: var(--muted); font-weight: 500; font-size: 11px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; margin-left: 4px; }
.col-acc { width: 1%; white-space: nowrap; }
.acc-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.reset-form input[type="password"] { width: 130px; padding: 6px 9px; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-danger { color: var(--baja); border-color: var(--line); background: transparent; }
.btn-danger:hover { background: var(--baja-bg); border-color: var(--baja); color: var(--baja); }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.pill-on { background: var(--alta-bg); color: var(--alta); }
.pill-off { background: var(--flat-bg); color: var(--flat); }

@media (max-width: 720px) {
  .usermenu-name { display: none; }
  .acc-row { justify-content: flex-start; }
  .userform .field { flex: 1 1 100%; }
}

/* ============================================================
   Planillas por empresa: cuadrícula tipo Excel, bitácora y
   pantallas del módulo nuevo.
   ============================================================ */

.page-ancha { max-width: none; padding-left: 20px; padding-right: 20px; }

/* ---------- Cabecera de la planilla ---------- */
.pl-head {
  display: flex; gap: 24px; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; margin-bottom: 16px;
}
.pl-head-main { min-width: 260px; flex: 1 1 380px; }
.pl-head h1 {
  margin: 0 0 4px; font-size: 24px; font-weight: 600;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.pl-head .linea-dot { background: var(--empresa, var(--accent)); }
.pl-periodo { font-family: "Inter", sans-serif; font-size: 15px; font-weight: 500; color: var(--muted); }
.pl-meta { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; }
.pl-head-side { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; flex: 0 1 380px; }

.pl-estado {
  border-radius: var(--radius); padding: 10px 14px; font-size: 12.5px;
  border-left: 4px solid var(--flat); background: var(--panel); border: 1px solid var(--line);
  max-width: 380px;
}
.pl-estado strong { display: block; font-size: 13.5px; margin-bottom: 2px; }
.pl-estado span { color: var(--muted); }
.pl-estado-al-dia   { border-left-color: var(--alta); }
.pl-estado-al-dia strong { color: var(--alta); }
.pl-estado-pendiente { border-left-color: var(--mod); background: var(--mod-bg); }
.pl-estado-pendiente strong { color: var(--mod); }
.pl-estado-pendiente span { color: var(--text); }
.pl-estado-cerrada { border-left-color: var(--flat); }

.pl-acciones { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Pestañas de hoja (como las de Excel) ---------- */
.sheettabs {
  display: flex; gap: 2px; overflow-x: auto; margin: 0 0 10px;
  border-bottom: 2px solid var(--line); padding-bottom: 0;
}
.sheettab {
  flex: none; padding: 7px 14px; font-size: 13px; font-weight: 500; color: var(--muted);
  background: var(--flat-bg); border: 1px solid var(--line); border-bottom: none;
  border-radius: 7px 7px 0 0; white-space: nowrap; position: relative; top: 2px;
}
.sheettab:hover { text-decoration: none; color: var(--text); }
.sheettab.is-active {
  background: var(--panel); color: var(--text); font-weight: 600;
  border-bottom: 2px solid var(--panel); box-shadow: 0 -2px 0 var(--accent) inset;
}
.sheettab-tag { font-size: 10.5px; color: var(--muted); margin-left: 5px; text-transform: uppercase; }
.sheettab-toggle { background: transparent; border-color: transparent; color: var(--accent); }

/* ---------- Barra de la cuadrícula ---------- */
.gridbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  flex-wrap: wrap; margin-bottom: 8px; font-size: 13px;
}
.gridbar-info { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; color: var(--muted); }
.gridbar-info strong { color: var(--text); font-size: 14px; }
.gridbar-warn { color: var(--mod); }
.gridbar-right { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.tramos { display: flex; gap: 4px; flex-wrap: wrap; }

.gridnote { color: var(--muted); font-size: 12.5px; margin: 0 0 10px; }

/* Ayuda larga, plegada para no empujar la cuadrícula hacia abajo */
.gridayuda { margin: -4px 0 10px; }
.gridayuda > summary {
  cursor: pointer; color: var(--accent-ink); font-size: 12.5px; font-weight: 600;
  width: fit-content; padding: 2px 0;
}
.gridayuda > summary:hover { text-decoration: underline; }
.gridayuda .gridnote { margin: 6px 0 0; }
.gridnote kbd {
  font-family: inherit; font-size: 11.5px; background: var(--flat-bg); border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 4px; padding: 0 5px;
}

.chip-ej { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 4px; font-weight: 600; }
.chip-ej-edit    { background: #fffbe6; color: #8a6d00; border: 1px solid #f0dda0; }
.chip-ej-calc    { background: var(--flat-bg); color: var(--flat); border: 1px solid var(--line); }
.chip-ej-editada { background: #e8f0ff; color: #2c40a0; border: 1px solid #b9cbf5; }

/* ---------- La cuadrícula ---------- */
.gridwrap {
  overflow: auto; max-height: 72vh;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); box-shadow: var(--shadow);
}
table.xl {
  border-collapse: separate; border-spacing: 0;
  font-size: 12.5px; font-variant-numeric: tabular-nums;
  table-layout: fixed; width: max-content;
}
table.xl th, table.xl td {
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 3px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 420px; vertical-align: middle;
}

/* Encabezados de columna (letras) y de fila (números) */
.xl-colhead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--ink-soft); color: #cdd7e5; text-align: center;
  font-weight: 600; font-size: 11px; letter-spacing: .04em; height: 24px;
}
.xl-corner {
  position: sticky; left: 0; top: 0; z-index: 5 !important;
  background: var(--ink) !important; width: 52px; min-width: 52px;
}
.xl-rowhead {
  position: sticky; left: 0; z-index: 2;
  background: var(--ink-soft); color: #cdd7e5; text-align: right;
  font-weight: 500; font-size: 11px; width: 52px; min-width: 52px;
}

/* Selector por columna y por fila: clic en la letra o en el número */
.xl-colhead th[data-col], .xl-rowhead, .xl-corner {
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
.xl-colhead th[data-col]:hover, .xl-rowhead:hover {
  background: #3d4c60; color: #fff;
}
/* La esquina lleva el triangulito de «toda la hoja», como en Excel */
.xl-corner::after {
  content: ''; display: block; margin-left: auto; width: 0; height: 0;
  border-style: solid; border-width: 0 0 9px 9px;
  border-color: transparent transparent #8fa3bd transparent;
}
.xl-corner:hover::after { border-bottom-color: #fff; }

/* Cabecera de lo que está seleccionado (la fila y la columna del cursor) */
.xl-colhead th.res, .xl-rowhead.res {
  background: #4a5f7a; color: #fff;
}
/* Cuando la columna o la fila está tomada entera */
.xl-colhead th.res-todo {
  background: var(--accent); color: #fff; box-shadow: inset 0 -3px 0 #fff;
}
.xl-rowhead.res-todo {
  background: var(--accent); color: #fff; box-shadow: inset -3px 0 0 #fff;
}

/* Filas de cabecera de la planilla (las congeladas en Excel) */
tr.xl-frozen-row td { background: color-mix(in srgb, var(--accent) 7%, var(--panel)); font-weight: 600; }

.xl-c { color: var(--text); }
.xl-c.num { text-align: right; }
.xl-c.err { color: var(--baja); font-size: 11.5px; }

/* Entrada vs. calculada */
table.xl:not(.sin-resaltado) .xl-c.edit {
  outline: 1px solid rgba(190, 160, 30, .35); outline-offset: -1px; cursor: cell;
}
table.xl:not(.sin-resaltado) .xl-c.edit:hover { background: #fffbe6 !important; }
.xl-c.calc { cursor: help; }
.xl-c.mostrando-formula {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 10.5px;
  color: var(--accent-ink); white-space: nowrap;
}

/* Celdas ya editadas en la web */
.xl-c.editada { box-shadow: inset 0 0 0 2px rgba(58, 84, 191, .45); }
.xl-c.recien-guardada { animation: flash-ok 1.4s ease-out; }
.xl-c.error-guardado { box-shadow: inset 0 0 0 2px var(--baja); }
.xl-c.guardando { opacity: .55; }
.xl-c.editando { padding: 0 !important; }
.xl-c:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

@keyframes flash-ok {
  0%   { background: var(--alta-bg) !important; }
  100% { background: transparent; }
}

.xl-input {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 12.5px;
  border: 2px solid var(--accent); border-radius: 0; padding: 2px 5px;
  background: var(--panel); color: var(--text);
}

.gridfoot {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  flex-wrap: wrap; margin: 10px 0 4px; font-size: 12.5px;
}
.grid-msg { font-weight: 500; min-height: 18px; }
.grid-msg-ok { color: var(--alta); }
.grid-msg-error { color: var(--baja); }
.grid-legend { display: flex; gap: 10px; align-items: center; }

/* ---------- Tarjetas de empresa ---------- */
.card-linea-negocio { color: var(--muted); font-size: 11.5px; }
.card-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }
.card-meta > div { min-width: 70px; }
.card-hc .hc-num { font-size: 30px; }

/* ---------- Chips ---------- */
.chips-lbl { color: var(--muted); font-size: 13px; align-self: center; margin-right: 2px; }
.chips-periodos { margin-bottom: 14px; }
.chips-paginas { margin-top: 16px; }
.chip-sm { padding: 4px 10px; font-size: 12.5px; }
.chip-pend, .tab-pend { color: var(--mod); font-size: 10px; vertical-align: super; }

/* ---------- Etiquetas de la bitácora ---------- */
.tag-cambio { background: var(--mod-bg); color: var(--mod); }
.tag-sesion { background: var(--flat-bg); color: var(--flat); }
.tag-alerta { background: var(--baja-bg); color: var(--baja); }
.tag-salida { background: #e8f0ff; color: #2c40a0; }
.tag-otro   { background: var(--flat-bg); color: var(--flat); }

.section-h2 { font-size: 18px; font-weight: 600; margin: 32px 0 14px; }
.nowrap { white-space: nowrap; }
.muted-note { color: var(--muted); font-size: 12.5px; }
.flash-aviso { background: var(--mod-bg); color: var(--text); border-left: 4px solid var(--mod); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }

/* ---------- Empresas (admin) ---------- */
.color-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; }
input[type="color"] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
input[type="month"] { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; }

@media (max-width: 720px) {
  .pl-head-side { align-items: stretch; flex-basis: 100%; }
  .pl-acciones { justify-content: flex-start; }
  .pl-estado { max-width: none; }
  .gridwrap { max-height: 60vh; }
  .page-ancha { padding-left: 12px; padding-right: 12px; }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chip-ej-edit    { background: #2a2311; color: #d8ab4e; border-color: #4a3d1c; }
  :root:not([data-theme="light"]) .chip-ej-editada { background: #1a2340; color: #9fb0ff; border-color: #2e3d6b; }
  :root:not([data-theme="light"]) .tag-salida      { background: #1a2340; color: #9fb0ff; }
  /* Los colores de relleno vienen del Excel y son claros: se oscurece el
     texto de esas celdas para que siga siendo legible. */
  :root:not([data-theme="light"]) table.xl td[style*="background"] { color: #14181f; }
  :root:not([data-theme="light"]) table.xl:not(.sin-resaltado) .xl-c.edit:hover { background: #fff8d6 !important; }
}

/* Asignación de empresas a un usuario */
.empresas-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; margin: 0; }
.empresas-chk { display: flex; flex-wrap: wrap; gap: 4px 12px; max-width: 320px; }
.empresas-chk .check { font-size: 12.5px; gap: 5px; }

/* Filas que venían ocultas por un autofiltro de Excel */
.xl-fila-filtrada > .xl-rowhead { background: #4a3d1c; color: #d8ab4e; }
.xl-fila-filtrada > td { opacity: .82; }

/* Celdas con fórmula que se acaban de recalcular solas */
.xl-c.recalculada { animation: flash-calc 1.8s ease-out; box-shadow: inset 0 0 0 2px rgba(31,138,85,.5); }
@keyframes flash-calc {
  0%   { background: #d8f3e3 !important; }
  100% { background: transparent; }
}
.pl-estado-editada { border-left-color: var(--accent); }
.pl-estado-editada strong { color: var(--accent-ink); }

/* Fórmulas que leen otros archivos: no se recalculan en la web */
.chip-ej-congelada { background: var(--mod-bg); color: var(--mod); border: 1px solid #e0cf9a; }
.xl-c.congelada { border-bottom: 2px dotted var(--mod) !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chip-ej-congelada { background: #2a2311; color: #d8ab4e; border-color: #4a3d1c; }
}

/* ============================================================
   Cinta de opciones de la hoja (filtro, inmovilizar, zoom, buscar)
   ============================================================ */
.cinta {
  display: flex; flex-wrap: wrap; align-items: stretch; gap: 0;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 6px 10px; box-shadow: var(--shadow);
}
.cinta-g {
  display: flex; flex-direction: column; gap: 3px;
  padding: 0 12px; border-right: 1px solid var(--line);
}
.cinta-g:last-child { border-right: 0; }
.cinta-g-fin { margin-left: auto; }
.cinta-t {
  font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 600;
}
.cinta-btns { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cinta-b {
  display: inline-flex; align-items: center; gap: 5px;
  font: inherit; font-size: 12.5px; line-height: 1;
  padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--panel); color: var(--text); cursor: pointer; white-space: nowrap;
}
.cinta-b:hover { background: var(--flat-bg); text-decoration: none; }
.cinta-b.is-activo { background: var(--accent); border-color: var(--accent); color: #fff; }
.cinta-b.is-activo .cinta-ico { color: #fff; }
.cinta-ico { font-size: 13px; color: var(--accent); }
.cinta-flecha { font-size: 9px; color: var(--muted); }
.cinta-b-ico { padding: 6px 8px; font-weight: 700; }
.cinta-b-zoom { min-width: 54px; justify-content: center; font-variant-numeric: tabular-nums; }
.cinta-zoom { display: inline-flex; gap: 3px; }
.cinta-input {
  font: inherit; font-size: 12.5px; padding: 6px 9px; width: 180px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--panel); color: var(--text);
}
.cinta-info { font-size: 11.5px; color: var(--muted); min-width: 74px; }
.cinta .check { font-size: 12.5px; }

/* Menú desplegable de «Inmovilizar» */
.cinta-menu { position: relative; }
.menu {
  position: absolute; left: 0; top: calc(100% + 5px); z-index: 30;
  min-width: 290px; padding: 5px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 9px; box-shadow: var(--shadow);
}
.menu button {
  display: block; width: 100%; text-align: left;
  font: inherit; font-size: 12.5px; padding: 7px 9px;
  border: 0; border-radius: 6px; background: transparent; color: var(--text); cursor: pointer;
}
.menu button:hover { background: var(--flat-bg); }
.menu-nota { color: var(--muted); font-size: 11px; }

/* Barra de fórmulas */
.barra-formula {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; font-size: 12.5px;
  background: var(--panel); border: 1px solid var(--line); border-top: 0;
}
.bf-ref {
  font: inherit; font-size: 12px; font-weight: 600; text-align: center;
  width: 78px; padding: 4px 6px; color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; background: var(--flat-bg);
}
.bf-fx { color: var(--muted); font-style: italic; font-size: 12px; padding: 0 2px; }
.bf-cont {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text); padding: 3px 6px; border-left: 1px solid var(--line);
}
.bf-cont-formula { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; color: var(--accent-ink); }
.gridbar-filtro { color: var(--accent-ink); font-weight: 600; }
.sel-stats { color: var(--muted); font-variant-numeric: tabular-nums; }

/* La cuadrícula queda pegada a la cinta */
.cinta + .barra-formula + .gridnote { margin-top: 10px; }
.barra-formula + .gridwrap { border-radius: 0 0 var(--radius) var(--radius); border-top: 0; }

/* ---------- Selección de celdas ---------- */
.xl-c.sel {
  outline: 2px solid var(--accent) !important; outline-offset: -2px;
  box-shadow: inset 0 0 0 1px var(--panel);
}
/* La selección se pinta ENCIMA del color que la celda trae del Excel (como en
   Excel), para no perder de vista las zonas amarillas, verdes, etc. */
.xl-c.en-rango {
  background-image: linear-gradient(rgba(58, 84, 191, .17), rgba(58, 84, 191, .17)) !important;
}
.xl-c.hallado { background: #fff1b8 !important; }

/* Copiar una fórmula: el marco de lo copiado, la esquinita y lo que se va a
   rellenar al arrastrarla. */
.xl-c.copiada {
  outline: 2px dashed var(--accent) !important; outline-offset: -2px;
}
.xl-c.tiene-tirador { position: relative; }
.tirador {
  position: absolute; right: 0; bottom: 0; width: 7px; height: 7px;
  background: var(--accent); border: 1px solid #fff; border-radius: 1px;
  cursor: crosshair; z-index: 4;
}
.tirador:hover { transform: scale(1.35); }
body.arrastrando-relleno, body.arrastrando-relleno * { cursor: crosshair !important; }
.xl-c.se-rellena {
  background-image: linear-gradient(rgba(58, 84, 191, .1), rgba(58, 84, 191, .1)) !important;
  box-shadow: inset 0 0 0 1px var(--accent);
}
table.xl.rellenando-espera { opacity: .75; }
.xl-c.hallado-actual { outline: 2px solid var(--mod) !important; outline-offset: -2px; }

/* ---------- Filas escondidas por el filtro de la web ---------- */
tr.fila-oculta { display: none; }

/* ---------- Inmovilizar paneles ---------- */
table.xl td.fz, table.xl th.fz { position: sticky; background-color: var(--panel); }
table.xl .fz-borde-col { border-right: 2px solid var(--accent) !important; }
table.xl .fz-borde-fila { border-bottom: 2px solid var(--accent) !important; }

/* ---------- Flechita de filtro en la fila de títulos ---------- */
.xl-colhead th { position: sticky; }
tr.fila-encabezado > td { box-shadow: inset 0 -2px 0 var(--accent); }
tr.fila-encabezado > .xl-rowhead { background: var(--accent); color: #fff; }
/* El resaltado del selector manda sobre el de la fila de títulos y el de las
   filas que venían filtradas del Excel. */
tr.fila-encabezado > .xl-rowhead.res,
.xl-fila-filtrada > .xl-rowhead.res { background: #4a5f7a; color: #fff; }
tr.fila-encabezado > .xl-rowhead.res-todo,
.xl-fila-filtrada > .xl-rowhead.res-todo {
  background: var(--accent); color: #fff; box-shadow: inset -3px 0 0 #fff;
}
.fbtn {
  float: right; margin: -1px -4px 0 3px;
  font: inherit; font-size: 9px; line-height: 1;
  padding: 2px 3px; cursor: pointer;
  border: 1px solid rgba(20,30,45,.28); border-radius: 3px;
  background: rgba(255,255,255,.82); color: #26303e;
}
.fbtn:hover { background: #fff; border-color: var(--accent); color: var(--accent-ink); }
.fbtn.is-activo { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Panel del filtro ---------- */
.fpanel {
  position: fixed; z-index: 60; width: 272px; padding: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); font-size: 12.5px;
}
.fpanel-titulo {
  font-weight: 700; font-size: 12.5px; margin: 0 2px 7px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fpanel-titulo span { font-weight: 400; color: var(--muted); font-size: 11.5px; }
.fpanel-orden { display: flex; gap: 5px; margin-bottom: 7px; }
.fpanel-orden button {
  flex: 1; font: inherit; font-size: 11.5px; padding: 5px 6px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px; background: var(--flat-bg); color: var(--text);
}
.fpanel-orden button:hover { background: var(--panel); }
.fpanel-buscar {
  width: 100%; font: inherit; font-size: 12px; padding: 5px 7px; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text);
}
.fpanel-todos { display: flex; align-items: center; gap: 6px; padding: 3px 4px; }
.fpanel-lista {
  max-height: 232px; overflow: auto; margin: 4px 0;
  border: 1px solid var(--line); border-radius: 6px; padding: 4px;
}
.fpanel-item {
  display: flex; align-items: center; gap: 6px; padding: 2px 4px; border-radius: 4px;
  cursor: pointer;
}
.fpanel-item:hover { background: var(--flat-bg); }
.fpanel-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fpanel-item[hidden] { display: none; }
.fpanel-nota { color: var(--muted); font-size: 11px; margin: 2px 0 6px; }
.fpanel-pie { display: flex; gap: 6px; justify-content: flex-end; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .xl-c.en-rango {
    background-image: linear-gradient(rgba(125, 146, 245, .22), rgba(125, 146, 245, .22)) !important;
  }
  :root:not([data-theme="light"]) .xl-c.hallado { background: #4a3d1c !important; }
}

@media (max-width: 720px) {
  .cinta-g { border-right: 0; padding: 0 6px; }
  .cinta-input { width: 130px; }
}

/* ---------- Fórmulas escritas desde la web ---------- */
.xl-c.formula-web { box-shadow: inset 0 0 0 1px rgba(31, 138, 85, .55); }
.xl-c.edit-f { cursor: cell; }
.chip-ej-fweb { background: var(--alta-bg); color: var(--alta); border: 1px solid #b6e0c8; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chip-ej-fweb { background: #12271d; color: #5bc48c; border-color: #1f4733; }
}

/* ---------- Pestañas de hoja abajo, como en Excel ---------- */
.sheettabs-abajo {
  margin: 0 0 10px; padding: 0 8px 6px;
  border: 1px solid var(--line); border-top: 0;
  border-bottom-width: 1px;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--flat-bg);
}
/* Las lengüetas cuelgan hacia abajo, como en Excel. */
.sheettabs-abajo .sheettab {
  top: 0; border-radius: 0 0 8px 8px;
  border-top: none; border-bottom: 1px solid var(--line);
}
.sheettabs-abajo .sheettab.is-active {
  background: var(--panel); border-bottom-color: var(--panel);
  box-shadow: inset 0 3px 0 var(--accent);
}
.barra-formula + .gridwrap { border-radius: 0; }

/* ---------- Página de pestaña de datos (vaciar / importar) ---------- */
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 0 0 18px; }
.cols2 .card { margin: 0; }
.cols2 .form { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.cols2 .field { width: 100%; }
.cols2 .field label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.btn-peligro { background: var(--baja); border-color: var(--baja); }
.btn-peligro:hover { background: #a82f26; border-color: #a82f26; }
@media (max-width: 860px) { .cols2 { grid-template-columns: 1fr; } }
.foot-version { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.cinta-chip {
  font-size: 11.5px; font-weight: 600; color: var(--accent-ink);
  background: #e8f0ff; border: 1px solid #b9cbf5; border-radius: 20px; padding: 3px 9px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cinta-chip { background: #1a2340; color: #9fb0ff; border-color: #2e3d6b; }
}

/* ---------- Nombres de rango ---------- */
.cinta-cuenta {
  font-size: 10.5px; font-weight: 700; color: var(--accent-ink);
  background: #e8f0ff; border-radius: 10px; padding: 1px 6px;
}
.cinta-b.is-activo .cinta-cuenta { background: rgba(255,255,255,.25); color: #fff; }
.menu-nombres { min-width: 330px; padding: 10px; }
.mn-crear { border-bottom: 1px solid var(--line); padding-bottom: 9px; margin-bottom: 8px; }
.mn-crear label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; }
.mn-fila { display: flex; gap: 6px; }
.menu .mn-fila input {
  flex: 1; font: inherit; font-size: 12.5px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--text);
  text-transform: uppercase;
}
.mn-lista { max-height: 260px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.mn-item { display: flex; align-items: center; gap: 6px; }
.menu .mn-ir {
  flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  font: inherit; text-align: left; cursor: pointer;
  background: transparent; border: 0; border-radius: 6px; padding: 5px 7px; color: var(--text);
}
.menu .mn-ir:hover { background: var(--flat-bg); }
.mn-ir strong { font-size: 12.5px; }
.mn-ir span { font-size: 11px; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; }
.menu .mn-borrar {
  display: inline-block; width: auto; font: inherit; font-size: 11px; cursor: pointer; color: var(--baja);
  background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px;
}
.menu .mn-borrar:hover { background: var(--baja-bg); border-color: var(--baja); }
.mn-tag { font-size: 10.5px; color: var(--muted); }
.mn-pie { font-size: 11.5px; color: var(--muted); margin: 8px 0 0; border-top: 1px solid var(--line); padding-top: 7px; }
.mn-pie code { font-size: 11px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cinta-cuenta { background: #1a2340; color: #9fb0ff; }
}
