/* ==========================================================================
   PEMAGA Building — Sistema visual del panel privado
   Grafito + ámbar, tema CLARO, tipografía Inter (cifras tabulares para datos).
   Diseño de gestión: denso pero respirado, jerarquía clara, sombras sutiles.

   ÍNDICE
   0. Tokens (:root)            5. Tablas (.table-wrap / table.data)
   1. Reset + base              6. Formularios (.form-grid / .field)
   2. Shell (sidebar/topbar)    7. Botones (.btn--*)
   3. Cabeceras (.page-head)    8. Badges + estados vacíos + pager
   4. Toolbar + KPIs + cards    9. Módulos / Licitaciones / Login / Responsive
   ========================================================================== */

/* ==========================================================================
   0. TOKENS
   ========================================================================== */
:root {
  /* --- Marca (espejo de tokens.css) --- */
  --navy:        #3A3B40;
  --navy-deep:   #25262A;
  --navy-soft:   #54565B;
  --gold:        #E0A42E;
  --gold-light:  #F0C45D;
  --gold-deep:   #B07C18;

  --cream:       #F6F4F0;
  --cream-2:     #EEEBE4;
  --concrete:    #E4E0D8;
  --steel:       #86878C;
  --charcoal:    #26272B;
  --ink:         #1A1B1E;
  --paper:       #FFFFFF;
  --line:        rgba(58, 59, 64, 0.14);
  --line-strong: rgba(58, 59, 64, 0.26);

  --ok:     #2E7D4F;
  --warn:   #B07C18;
  --danger: #B23A3A;
  --info:   #2476B0;

  /* Superficies funcionales derivadas */
  --surface:        #FFFFFF;
  --surface-2:      #FAF9F6;
  --surface-sunken: #F2F0EA;
  --hover-row:      rgba(224, 164, 46, 0.06);

  /* Tipografía de trabajo: una sola familia limpia (Inter) con números tabulares. */
  --font-display: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-body:    'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-mono:    ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;

  /* Escala de espaciado (base 4px) */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;

  --radius-s: 6px;
  --radius:   10px;
  --radius-l: 16px;

  /* Sombras sutiles, calibradas para tema claro (no “floten” las cards) */
  --shadow-xs: 0 1px 2px rgba(26, 27, 30, 0.05);
  --shadow:    0 1px 2px rgba(26, 27, 30, 0.05), 0 6px 18px -10px rgba(26, 27, 30, 0.14);
  --shadow-lg: 0 2px 4px rgba(26, 27, 30, 0.06), 0 22px 48px -20px rgba(26, 27, 30, 0.30);
  --ring:      0 0 0 3px rgba(224, 164, 46, 0.20);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-s: 0.18s;

  --sidebar-w: 256px;
  --topbar-h:  64px;
  --content-max: 1360px;
}

* { box-sizing: border-box; }

/* ==========================================================================
   1. RESET + BASE
   ========================================================================== */
html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--charcoal);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--navy); text-decoration: none; transition: color var(--dur-s) var(--ease); }
a:hover { color: var(--gold-deep); }

img, svg { max-width: 100%; }

::selection { background: rgba(224, 164, 46, 0.28); }

/* Números/códigos: misma familia, solo cifras tabulares alineadas. */
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0; }
.mono--big { font-size: 1.3rem; color: var(--navy); font-weight: 600; }

.eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--gold-deep);
  margin-bottom: 0.35rem;
}

.muted-sm { font-size: 0.78rem; color: var(--steel); }
.neg, td.num.neg { color: var(--danger); }
.pos { color: var(--ok); }

/* ==========================================================================
   2. SHELL — sidebar + topbar + contenido
   ========================================================================== */
.panel-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  background: var(--navy-deep);
  color: #E8EAF2;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 40;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1.25rem 1.25rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar__brand .logo {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #fff;
  line-height: 1.05;
}
.sidebar__brand .logo b { color: var(--gold-light); font-weight: 600; }
.sidebar__brand .grupo {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(224, 164, 46, 0.85);
  margin-top: 0.3rem;
}

.sidebar__nav {
  padding: 0.85rem 0.6rem;
  flex: 1;
  overflow-y: auto;
}
.sidebar__nav .nav-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(232, 234, 242, 0.38);
  padding: 0.95rem 0.7rem 0.4rem;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-s);
  color: rgba(232, 234, 242, 0.82);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background var(--dur-s) var(--ease), color var(--dur-s) var(--ease);
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.is-active {
  background: rgba(224, 164, 46, 0.16);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--gold-light);
}
.nav-item .ico { width: 18px; height: 18px; flex: 0 0 18px; opacity: 0.9; }

.sidebar__foot {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  color: rgba(232, 234, 242, 0.45);
  line-height: 1.6;
}

/* --- Main column --- */
.main { display: flex; flex-direction: column; min-width: 0; }

/* --- Topbar --- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.75rem;
  background: rgba(246, 244, 240, 0.86);
  backdrop-filter: blur(12px) saturate(135%);
  -webkit-backdrop-filter: blur(12px) saturate(135%);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar__left { display: flex; align-items: center; gap: 0.85rem; min-width: 0; }
.topbar__title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar__user { display: flex; align-items: center; gap: 0.85rem; }
.user-chip { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.user-chip .nombre { font-weight: 600; font-size: 0.88rem; }
.user-chip .rol {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--steel);
}
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--gold-light);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  flex: 0 0 36px;
}

/* Botón de menú móvil (oculto en escritorio) */
.nav-toggle {
  display: none;
  width: 40px; height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--navy);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.nav-toggle svg { width: 20px; height: 20px; }
.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 27, 30, 0.42);
  z-index: 35;
}

/* --- Contenido --- */
.content {
  padding: 1.75rem 1.75rem 3.5rem;
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

/* ==========================================================================
   3. CABECERAS DE PÁGINA
   .page-header (canónica) y .page-head / .page-head--row (legado, mismo estilo)
   ========================================================================== */
.page-header,
.page-head {
  margin-bottom: 1.6rem;
}
.page-header__main { min-width: 0; }
.page-header h1, .page-head h1 {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 1.25rem + 1vw, 2rem);
  font-weight: 600;
  color: var(--navy);
  margin: 0.1rem 0 0.3rem;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.page-header p, .page-head p {
  color: var(--steel);
  margin: 0;
  max-width: 68ch;
  font-size: 0.92rem;
}

/* Variante con acciones a la derecha */
.page-header,
.page-head--row,
.module-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  flex-wrap: wrap;
}
/* .page-head simple (sin --row) vuelve a bloque */
.page-head:not(.page-head--row) { display: block; }

.page-header__actions,
.head-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.page-header__actions form,
.head-actions form { margin: 0; }

/* ==========================================================================
   4. TOOLBAR + KPIs + CARDS
   ========================================================================== */

/* --- Toolbar: filtros (izq) + acción primaria (der) --- */
.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.85rem 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1.4rem;
  padding: 0.95rem 1.05rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.filters {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex: 1;
}
.filters .btn { white-space: nowrap; }

/* Campo en línea (compacto, dentro de toolbar) */
.field--inline { gap: 0.3rem; }
.field--inline label {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--steel);
  font-weight: 600;
}
.field--inline input,
.field--inline select {
  padding: 0.48rem 0.7rem;
  font-size: 0.88rem;
  min-width: 150px;
}
.field--inline input[type="search"] { min-width: 220px; }

/* --- KPI / stat cards (.stat-grid + .stat) ; alias económico (.econ + .econ__card) --- */
.stat-grid,
.econ {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.6rem;
}
.stat-grid--3,
.econ--3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stat-grid--4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.stat,
.econ__card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--navy);
  border-radius: var(--radius);
  padding: 1.05rem 1.2rem 1.1rem;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--dur-s) var(--ease), border-color var(--dur-s) var(--ease);
}
.stat:hover,
.econ__card:hover { box-shadow: var(--shadow); }
.stat.is-pos,  .econ__card.is-pos { border-top-color: var(--ok); }
.stat.is-neg,  .econ__card.is-neg { border-top-color: var(--danger); }
.stat.is-warn, .econ__card.is-warn { border-top-color: var(--gold); }

.stat__label,
.econ__label {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--steel);
  font-weight: 600;
}
.stat__val,
.econ__val {
  font-variant-numeric: tabular-nums;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--navy);
  margin: 0.4rem 0 0.25rem;
  line-height: 1.05;
  letter-spacing: -0.01em;
}
.stat.is-neg .stat__val,
.econ__card.is-neg .econ__val { color: var(--danger); }
.stat.is-pos .stat__val,
.econ__card.is-pos .econ__val { color: var(--ok); }
.stat__sub,
.econ__sub { font-size: 0.74rem; color: var(--steel); }

/* --- Cards de navegación (dashboard) --- */
.card-grid,
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.05rem;
}
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.3rem 1.35rem 1.15rem;
  box-shadow: var(--shadow-xs);
  transition: transform var(--dur-s) var(--ease), box-shadow var(--dur-s) var(--ease),
              border-color var(--dur-s) var(--ease);
  display: flex;
  flex-direction: column;
  min-height: 168px;
  color: var(--charcoal);
}
a.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--line-strong);
  color: var(--charcoal);
}
.card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.7rem;
}
.card__ico {
  width: 42px; height: 42px;
  border-radius: var(--radius-s);
  display: grid; place-items: center;
  background: var(--cream-2);
  color: var(--navy);
}
.card__ico svg { width: 22px; height: 22px; }
.card__count {
  font-variant-numeric: tabular-nums;
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1;
}
.card h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
  color: var(--charcoal);
}
.card p { color: var(--steel); font-size: 0.88rem; margin: 0; flex: 1; }
.card__foot {
  margin-top: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.card__link {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gold-deep);
}
.card__link::after { content: ' →'; }

/* --- Panel-box: sección con cabecera (fichas, detalles) --- */
.panel-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 1.35rem 1.45rem;
  margin-bottom: 1.4rem;
}
.panel-box__head { margin-bottom: 1.05rem; }
.panel-box__head--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.panel-box__head h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--navy);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.panel-box .table-wrap { box-shadow: none; border-radius: var(--radius-s); }

/* --- Rejilla de dos columnas --- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.3rem;
  margin-bottom: 1.4rem;
  align-items: start;
}
.grid-2--wide { grid-template-columns: 1.7fr 1fr; }
@media (max-width: 1000px) { .grid-2, .grid-2--wide { grid-template-columns: 1fr; } }

/* --- Lista clave/valor --- */
.kv {
  display: grid;
  grid-template-columns: minmax(120px, max-content) 1fr;
  gap: 0.6rem 1.2rem;
  margin: 0;
}
.kv dt {
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--steel);
  font-weight: 600;
  align-self: center;
}
.kv dd { margin: 0; color: var(--charcoal); }

.desc {
  margin-top: 1.05rem;
  padding-top: 1.05rem;
  border-top: 1px solid var(--line);
  color: var(--charcoal);
  white-space: pre-line;
  font-size: 0.92rem;
}

/* --- Listas de documentos / gasto por obra --- */
.doc-list, .gasto-list { list-style: none; margin: 0; padding: 0; }
.doc-list li, .gasto-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}
.doc-list li:last-child, .gasto-list li:last-child { border-bottom: none; }
.doc-meta { font-size: 0.72rem; color: var(--steel); }
.gasto-obra { display: flex; flex-direction: column; gap: 0.1rem; }
.gasto-vals { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; justify-content: flex-end; }

/* ==========================================================================
   5. TABLAS
   ========================================================================== */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow-xs);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 560px;
}
table.data thead th {
  text-align: left;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--steel);
  padding: 0.7rem 1rem;
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
table.data thead th.num,
table.data thead th[style*="right"] { text-align: right; }
table.data tbody td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background var(--dur-s) var(--ease); }
table.data tbody tr:hover { background: var(--hover-row); }
table.data td.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
table.data td.code {
  font-variant-numeric: tabular-nums;
  color: var(--navy);
  font-weight: 600;
}
table.data td strong { font-weight: 600; }

/* ==========================================================================
   6. FORMULARIOS
   ========================================================================== */
.form-grid { display: grid; gap: 1.05rem; max-width: 640px; }
.form-grid--wide { max-width: 880px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.05rem;
}
.form-row--3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 720px) { .form-row, .form-row--3 { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field label {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--charcoal);
  font-weight: 600;
}
.field .field__help,
.field-help { font-size: 0.74rem; color: var(--steel); font-weight: 400; text-transform: none; letter-spacing: 0; }

.field input,
.field select,
.field textarea {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  color: var(--charcoal);
  transition: border-color var(--dur-s) var(--ease), box-shadow var(--dur-s) var(--ease);
  width: 100%;
}
.field textarea { resize: vertical; min-height: 88px; line-height: 1.5; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: var(--ring);
}
.field input::placeholder { color: var(--steel); }
.field input[readonly],
.field input:read-only {
  background: var(--cream-2);
  color: var(--steel);
  cursor: not-allowed;
  border-style: dashed;
}
.field input[type="file"] {
  padding: 0.5rem;
  background: var(--surface-2);
  cursor: pointer;
}
.field input[type="date"] { min-height: 2.55rem; }

.form-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 0.6rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}
/* Formularios compactos (toolbar, login) no muestran el separador superior. */
.filters .form-actions,
.login .form-actions { border-top: none; padding-top: 0; }
/* Acciones alineadas a la izquierda (subformularios embebidos). */
.form-actions--left { justify-content: flex-start; }

/* --- Personal / Organización: extensiones de formulario (mismo sistema) --- */
/* Encabezado de sección dentro de un form-grid largo. */
.form-section {
  font-family: var(--font-body);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--steel);
  font-weight: 700;
  margin: 0.6rem 0 -0.2rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--line);
}
.form-section__tag {
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
}
/* Fila de 4 columnas (subida de documentos, altas inline). */
.form-row--4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 1.05rem; }
@media (max-width: 900px) { .form-row--4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .form-row--4 { grid-template-columns: 1fr; } }
/* Campo con casilla de verificación (activo/inactivo). */
.field--check { flex-direction: row; align-items: center; gap: 0.55rem; }
.field--check label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
}
.field--check input { width: auto; }
/* Campo partido en dos sub-inputs (ciudad/provincia, alta/baja). */
.field--split { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.field--split > div { display: flex; flex-direction: column; gap: 0.4rem; }
/* Campo cuyo control se alinea abajo (botón junto a selects). */
.field--end { justify-content: flex-end; }
/* Subformulario embebido en una panel-box (alta de miembro/documento). */
.form-inline-upload {
  max-width: none;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

/* --- Organigrama: centros / departamentos / equipos --- */
.org-centro { margin-bottom: 1.1rem; }
.org-depto {
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 0.8rem 0.95rem;
  margin-top: 0.85rem;
  background: var(--surface-2, var(--cream-2));
}
.org-depto__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.org-equipos {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.org-equipos li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  padding: 0.35rem 0;
  border-top: 1px dashed var(--line);
}
.org-equipos li:first-child { border-top: none; }

/* ==========================================================================
   7. BOTONES
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-family: var(--font-body);
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius-s);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
  transition: background var(--dur-s) var(--ease), border-color var(--dur-s) var(--ease),
              color var(--dur-s) var(--ease), transform var(--dur-s) var(--ease),
              box-shadow var(--dur-s) var(--ease);
}
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* Primary = ámbar (acción principal del panel) */
.btn--primary { background: var(--gold); color: var(--navy-deep); border-color: var(--gold); }
.btn--primary:hover { background: var(--gold-light); border-color: var(--gold-light); color: var(--navy-deep); }

/* Gold = alias de primary, mantenido por compatibilidad de vistas */
.btn--gold { background: var(--gold); color: var(--navy-deep); border-color: var(--gold); }
.btn--gold:hover { background: var(--gold-light); border-color: var(--gold-light); color: var(--navy-deep); }

/* Secondary = grafito sólido */
.btn--secondary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn--secondary:hover { background: var(--navy-soft); border-color: var(--navy-soft); color: #fff; }

/* Ghost = contorno (acción secundaria/terciaria) */
.btn--ghost { background: var(--surface); border-color: var(--line-strong); color: var(--navy); }
.btn--ghost:hover { border-color: var(--navy); background: var(--surface-2); }

/* Danger */
.btn--danger { background: var(--surface); color: var(--danger); border-color: rgba(178, 58, 58, 0.4); }
.btn--danger:hover { border-color: var(--danger); background: rgba(178, 58, 58, 0.07); color: var(--danger); }

/* Tamaños */
.btn--sm, .btn--xs { padding: 0.42rem 0.8rem; font-size: 0.76rem; }
.btn--block { width: 100%; }

/* ==========================================================================
   8. BADGES + ESTADOS VACÍOS + PAGER + ALERTAS
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid currentColor;
  line-height: 1.45;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge--ok     { color: var(--ok);     background: rgba(46, 125, 79, 0.08); }
.badge--warn   { color: var(--warn);   background: rgba(176, 124, 24, 0.10); }
.badge--danger { color: var(--danger); background: rgba(178, 58, 58, 0.08); }
.badge--info   { color: var(--info);   background: rgba(36, 118, 176, 0.08); }
.badge--muted  { color: var(--steel);  background: rgba(134, 135, 140, 0.10); }

/* --- Estados vacíos --- */
/* .empty-state (canónica, con icono/acción) y .empty / .empty--sm (legado) */
.empty-state,
.empty {
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--steel);
}
.empty-state__ico {
  width: 48px; height: 48px;
  margin: 0 auto 0.9rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface-sunken);
  color: var(--navy);
}
.empty-state__ico svg { width: 24px; height: 24px; }
.empty-state__title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--charcoal);
  margin: 0 0 0.3rem;
}
.empty-state__sub { font-size: 0.88rem; color: var(--steel); margin: 0 0 1.1rem; max-width: 44ch; margin-inline: auto; }
.empty--sm { padding: 1.25rem; font-size: 0.88rem; }

/* --- Pager (paginación consistente) --- */
.pager {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  justify-content: flex-end;
  margin-top: 1.2rem;
  flex-wrap: wrap;
}
.pager a,
.pager span.cur,
.pager .pager__gap {
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.42rem 0.7rem;
  border-radius: var(--radius-s);
  border: 1px solid var(--line-strong);
  color: var(--navy);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  transition: border-color var(--dur-s) var(--ease), background var(--dur-s) var(--ease);
}
.pager span.cur { background: var(--navy); border-color: var(--navy); color: #fff; }
.pager a:hover { border-color: var(--navy); background: var(--surface-2); }
.pager .pager__gap { border: none; background: none; color: var(--steel); padding-inline: 0.3rem; }
.pager .disabled { opacity: 0.4; pointer-events: none; }

/* --- Alertas --- */
.alert {
  border-radius: var(--radius-s);
  padding: 0.8rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 1.1rem;
  border: 1px solid;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.alert--error { background: rgba(178, 58, 58, 0.07); border-color: rgba(178, 58, 58, 0.35); color: #8a2c2c; }
.alert--ok    { background: rgba(46, 125, 79, 0.07); border-color: rgba(46, 125, 79, 0.35); color: #226040; }
.alert--warn  { background: rgba(176, 124, 24, 0.08); border-color: rgba(176, 124, 24, 0.40); color: #7a6418; }
.alert--info  { background: rgba(36, 118, 176, 0.07); border-color: rgba(36, 118, 176, 0.35); color: #1c577f; }

/* ==========================================================================
   9A. MÓDULOS · componentes específicos
   ========================================================================== */

/* Pestañas de filtro (segmented) */
.filter-tabs { display: flex; gap: 0.4rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.filter-tabs a {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--steel);
  background: var(--surface);
  transition: all var(--dur-s) var(--ease);
}
.filter-tabs a.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }
.filter-tabs a:hover { border-color: var(--navy); color: var(--navy); }
.filter-tabs a.is-active:hover { color: #fff; }

/* Barra de compatibilidad (score 0-100) */
.score { display: flex; align-items: center; gap: 0.55rem; min-width: 110px; }
.score__bar { flex: 1; height: 7px; border-radius: 999px; background: var(--concrete); overflow: hidden; }
.score__fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--gold), var(--gold-light)); }
.score__num { font-variant-numeric: tabular-nums; font-size: 0.82rem; font-weight: 600; color: var(--navy); min-width: 2.2ch; text-align: right; }
.score--hi  .score__fill { background: linear-gradient(90deg, var(--ok), #45a06d); }
.score--mid .score__fill { background: linear-gradient(90deg, var(--gold), var(--gold-light)); }
.score--lo  .score__fill { background: linear-gradient(90deg, var(--steel), #aab); }

/* ==========================================================================
   9B. LICITACIONES (estilos antes inline en la vista; trasladados aquí)
   ========================================================================== */
.lic-toolbar {
  display: flex; flex-wrap: wrap; gap: 0.85rem 1.25rem; align-items: flex-end;
  padding: 1rem 1.1rem; margin-bottom: 1.1rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-xs);
}
.lic-toolbar .fld { display: flex; flex-direction: column; gap: 0.3rem; }
.lic-toolbar label {
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--steel); font-weight: 600;
}
.lic-toolbar select,
.lic-toolbar input[type="search"] {
  font: inherit; font-size: 0.86rem; padding: 0.46rem 0.65rem;
  border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink); min-width: 9rem;
  transition: border-color var(--dur-s) var(--ease), box-shadow var(--dur-s) var(--ease);
}
.lic-toolbar select:focus,
.lic-toolbar input[type="search"]:focus { outline: none; border-color: var(--gold); box-shadow: var(--ring); }
.lic-toolbar input[type="search"] { min-width: 13rem; }
.lic-toolbar .fld--search { flex: 1 1 16rem; }
.lic-toolbar .tb-actions { display: flex; gap: 0.5rem; align-items: center; }

.lic-count { font-size: 0.82rem; color: var(--steel); margin: 0.2rem 0 0.9rem; }
.lic-count strong { color: var(--ink); font-variant-numeric: tabular-nums; }

/* Celda principal de la licitación */
.lic-tit { font-weight: 600; color: var(--ink); display: block; line-height: 1.35; }
.lic-meta { font-size: 0.78rem; color: var(--steel); margin-top: 0.25rem; display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.lic-razon { font-size: 0.82rem; color: var(--steel); margin-top: 0.35rem; max-width: 56ch; }
.lic-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.lic-actions form { margin: 0; }
.lic-link { font-size: 0.74rem; font-weight: 600; letter-spacing: 0.02em; }
.lic-link::after { content: ' ↗'; }

.lic-badges { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.4rem; }
.pill {
  display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.66rem;
  font-weight: 600; line-height: 1; padding: 0.26rem 0.5rem; border-radius: 999px;
  border: 1px solid currentColor; letter-spacing: 0.02em; white-space: nowrap;
}
.pill--src   { color: var(--steel); }
.pill--geo   { color: var(--info); }
.pill--pipe  { color: #7a6418; background: rgba(184, 151, 58, 0.10); }
.pill--warnx { color: var(--warn); background: rgba(184, 151, 58, 0.08); }
.pill--urg   { color: var(--danger); background: rgba(178, 58, 58, 0.07); }
.pill--pyme  { color: var(--ok); background: rgba(46, 125, 79, 0.07); }

details.lic-detail { margin-top: 0.5rem; }
details.lic-detail > summary {
  cursor: pointer; font-size: 0.76rem; font-weight: 600; color: var(--navy);
  list-style: none; display: inline-flex; align-items: center; gap: 0.3rem; user-select: none;
}
details.lic-detail > summary::-webkit-details-marker { display: none; }
details.lic-detail > summary::before { content: '▸'; font-size: 0.7rem; transition: transform 0.15s; }
details.lic-detail[open] > summary::before { transform: rotate(90deg); }
details.lic-detail > summary:hover { color: var(--gold-deep); }
.lic-detail__body {
  margin-top: 0.6rem; padding: 0.85rem 1rem; border: 1px solid var(--line);
  border-radius: var(--radius-s); background: var(--surface-2); display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.75rem 1.4rem;
}
.lic-detail__body h5 { margin: 0 0 0.3rem; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--steel); }
.lic-detail__body p, .lic-detail__body li { font-size: 0.82rem; color: var(--ink); margin: 0.15rem 0; }
.lic-detail__body ul { margin: 0.2rem 0 0; padding-left: 1.1rem; }
.lic-detail__body .full { grid-column: 1 / -1; }
.crit { font-size: 0.8rem; display: flex; justify-content: space-between; gap: 0.6rem; padding: 0.25rem 0; border-bottom: 1px dashed var(--line); }
.crit .tag { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.05em; padding: 0.1rem 0.4rem; border-radius: var(--radius-s); }
.crit .tag--auto { color: var(--ok); background: rgba(46, 125, 79, 0.08); }
.crit .tag--juicio { color: var(--warn); background: rgba(184, 151, 58, 0.10); }
.lic-pliegos a { font-family: var(--font-mono); font-size: 0.74rem; display: inline-block; margin-right: 0.7rem; }

.btn--spin[aria-busy="true"] { opacity: 0.7; }

/* ==========================================================================
   9C. LOGIN (pantalla completa, mismo ADN visual que la web)
   ========================================================================== */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--cream);
}
.login__aside {
  background:
    radial-gradient(120% 90% at 0% 0%, rgba(224, 164, 46, 0.18), transparent 55%),
    linear-gradient(160deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #fff;
  padding: 3.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login__aside .logo { font-family: var(--font-display); font-size: 1.9rem; font-weight: 600; color: #fff; }
.login__aside .logo b { color: var(--gold-light); }
.login__aside .claim {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 1.2rem + 2vw, 3rem);
  font-weight: 500;
  line-height: 1.12;
  max-width: 22ch;
}
.login__aside .claim em { color: var(--gold-light); font-style: italic; }
.login__aside .meta { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.05em; color: rgba(255, 255, 255, 0.6); line-height: 1.7; }
.login__main { display: grid; place-items: center; padding: 3rem; }
.login__card { width: 100%; max-width: 380px; }
.login__card h1 { font-family: var(--font-display); font-size: 1.9rem; font-weight: 600; color: var(--navy); margin: 0 0 0.25rem; }
.login__card .sub { color: var(--steel); margin: 0 0 1.75rem; }
.login form { display: grid; gap: 1.05rem; }

/* ==========================================================================
   9D. PÁGINA DE ERROR
   ========================================================================== */
.errbox { max-width: 560px; margin: 6vh auto; text-align: center; padding: 2.5rem; }
.errbox .code { font-family: var(--font-mono); font-size: 3.4rem; color: var(--gold); letter-spacing: 0.04em; }
.errbox h1 { font-family: var(--font-display); font-size: 2rem; color: var(--navy); margin: 0.25rem 0 0.75rem; }
.errbox p { color: var(--steel); }

/* ==========================================================================
   10. RESPONSIVE
   ========================================================================== */

/* Tablet/desktop intermedio: sidebar algo más estrecho */
@media (max-width: 1200px) {
  :root { --sidebar-w: 224px; }
  .content { padding: 1.5rem 1.4rem 3rem; }
}

/* Móvil/tablet: sidebar pasa a off-canvas (deslizable), topbar con botón. */
@media (max-width: 900px) {
  .panel-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 272px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.28s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .panel-shell.nav-open .sidebar { transform: translateX(0); }
  .panel-shell.nav-open .scrim { display: block; }
  .nav-toggle { display: inline-flex; }
  .topbar { padding: 0 1.1rem; }
  .topbar__title { font-size: 1.05rem; }
}

@media (max-width: 640px) {
  .content { padding: 1.25rem 1rem 2.5rem; }
  .login { grid-template-columns: 1fr; }
  .login__aside { display: none; }
  .login__main { padding: 2rem 1.25rem; }
  /* Acciones de cabecera/toolbar a ancho completo y apiladas */
  .page-header__actions, .head-actions { width: 100%; }
  .toolbar { padding: 0.85rem; }
  .filters { width: 100%; }
  .field--inline input,
  .field--inline select,
  .field--inline input[type="search"] { min-width: 0; width: 100%; }
  .field--inline { flex: 1 1 140px; }
  .user-chip { display: none; }
}

/* ==========================================================================
   9F. MÓDULO FICHAJE · panel de control + pantalla de fichar
   ========================================================================== */

/* Marcador obligatorio en labels */
.req { color: var(--gold-deep); font-weight: 700; }

/* Botón XL (acción principal de fichar — pensado para el pulgar en móvil) */
.btn--xl {
  font-size: 1.05rem;
  padding: 1rem 1.2rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Filas con realce en las tablas de fichaje */
tr.row--alert > td { background: rgba(176, 124, 24, 0.06); }
tr.row--muted > td { opacity: 0.55; }
tr.row--muted .badge { opacity: 0.85; }

/* --- Pantalla "Fichar" (móvil-friendly) --- */
.fichar { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 1.1rem; }
.fichar__head { text-align: center; }
.fichar__title { margin: 0.2rem 0 0; }

.fichar__clock {
  text-align: center;
  padding: 1.4rem 1rem;
  background: var(--navy-deep);
  border-radius: var(--radius-l);
  color: #fff;
}
.fichar__time {
  font-size: clamp(2.8rem, 14vw, 4.2rem);
  font-weight: 700;
  line-height: 1;
  color: var(--gold-light);
  font-variant-numeric: tabular-nums;
}
.fichar__date {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.72);
  text-transform: capitalize;
}

.fichar__obra-name { font-size: 1.05rem; font-weight: 600; color: var(--navy); margin: 0.2rem 0; }
.fichar__geo { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }

.fichar__form { display: flex; flex-direction: column; gap: 0.7rem; }

.fichar__timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.fichar__timeline li { display: flex; align-items: center; gap: 0.6rem; }
.fichar__totales {
  display: flex; flex-wrap: wrap; gap: 1rem;
  margin-top: 0.9rem; padding-top: 0.8rem;
  border-top: 1px solid var(--line);
  font-size: 0.82rem; color: var(--steel);
}
.fichar__totales b { color: var(--navy); }

/* --------------------------------------------------------------------------
   ONBOARDING (RRHH) — tarjetas de enlace mágico + QR, filas de copiado.
   Reutiliza tokens del sistema; no introduce colores nuevos.
-------------------------------------------------------------------------- */
.onb-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1rem;
}
.onb-card {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem 1.05rem;
}
.onb-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.85rem;
}

/* Enlace mágico: QR a la izquierda, datos/acciones a la derecha. */
.onb-enlace {
  display: flex;
  gap: 1.1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.onb-enlace__qr {
  width: 168px;
  height: 168px;
  flex: 0 0 168px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 6px;
}
.onb-enlace__qr img,
.onb-enlace__qr canvas { display: block; max-width: 100%; height: auto; }
.onb-enlace__data { flex: 1 1 220px; min-width: 0; }
.onb-enlace__data .field { margin-bottom: 0.6rem; }

/* Fila input + botón de copiar. */
.copyrow { display: flex; gap: 0.45rem; align-items: stretch; }
.copyrow input {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.78rem;
  padding: 0.42rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--surface-2);
  color: var(--charcoal);
}
.copyrow .btn { white-space: nowrap; }

/* Checkbox inline (toolbar "incluir caducadas"). */
.check-inline { display: inline-flex; align-items: center; gap: 0.45rem; font-size: 0.86rem; color: var(--charcoal); cursor: pointer; }
.check-inline input { margin: 0; }

/* Columna de acciones en tablas (alinea a la derecha, sin saltos feos). */
.th-actions, .td-actions { text-align: right; white-space: nowrap; }
.td-actions { display: flex; gap: 0.4rem; justify-content: flex-end; flex-wrap: wrap; }

/* En impresión: el QR y los enlaces deben verse limpios (para repartir en papel). */
@media print {
  .sidebar, .topbar, .toolbar, .page-header__actions, [data-copy] { display: none !important; }
  .onb-card { break-inside: avoid; border-color: #999; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
