/* ============================================================
   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; }
.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;
}

/* 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; }
