@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Playfair+Display:wght@600;700;800&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  color-scheme: dark;
  /* Paleta institucional Gobierno de Chile: azul dominante, rojo, blanco.
     Tema oscuro por defecto; el claro se activa con [data-theme="light"]. */
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-ui: 'Space Grotesk', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bg: #0a2540;
  --bg-soft: #103257;
  --panel: rgba(255, 255, 255, 0.07);
  --surface: rgba(255, 255, 255, 0.05);
  --border-soft: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.12);
  --panel-border: var(--border);
  --track: rgba(255, 255, 255, 0.1);
  --hover: rgba(255, 255, 255, 0.14);
  --input-bg: rgba(5, 10, 16, 0.35);
  --input-border: rgba(255, 255, 255, 0.16);
  --text: #eef4fb;
  --muted: #aebfd6;
  --accent: #4a90d9;      /* azul claro */
  --accent-2: #0f69c4;    /* azul institucional */
  --ok: #2fb27c;          /* verde estado ok */
  --danger: #e5484d;      /* rojo */
  --warn: #f2b705;        /* ambar */
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  --sidebar-scroll-thumb: rgba(255, 255, 255, 0.86);
  --sidebar-scroll-track: rgba(255, 255, 255, 0.14);
  --shell-gutter: clamp(18px, 2vw, 40px);
  --shell-max: min(1760px, calc(100vw - (var(--shell-gutter) * 2)));
  --shell-pad-top: clamp(20px, 3vh, 32px);
  --shell-pad-bottom: clamp(28px, 4vh, 48px);
}

/* --- Tema claro (paleta servicios publicos: blanco, azul, gris) --- */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2f7;
  --bg-soft: #e5ecf4;
  --panel: #ffffff;
  --surface: #f4f7fb;
  --border-soft: #e4ebf3;
  --border: #d3ddea;
  --panel-border: #dbe3ee;
  --track: #e2e9f2;
  --hover: #e9eff7;
  --input-bg: #ffffff;
  --input-border: #cbd7e6;
  --text: #16273e;
  --muted: #5a6a82;
  --accent: #0f69c4;
  --accent-2: #06437b;
  --shadow: 0 10px 28px rgba(20, 45, 80, 0.10);
  --sidebar-scroll-thumb: #0f69c4;
  --sidebar-scroll-track: #dbe8f6;
}

:root[data-theme="light"] body {
  background:
    radial-gradient(circle at top left, rgba(15, 105, 196, 0.10), transparent 30%),
    radial-gradient(circle at top right, rgba(229, 72, 77, 0.06), transparent 34%),
    linear-gradient(160deg, #f8fafd, #eef2f7 60%, #e7eef6);
}

/* Contraste de textos de estado sobre fondo claro. */
:root[data-theme="light"] .badge { color: #0f69c4; background: rgba(15, 105, 196, 0.12); }
:root[data-theme="light"] .pill.ok { color: #1c7a54; }
:root[data-theme="light"] .pill.warn { color: #9a7400; }
:root[data-theme="light"] .pill.danger { color: #c0343a; }
:root[data-theme="light"] .doc-link,
:root[data-theme="light"] .conv-actions .link-inline,
:root[data-theme="light"] .login-card .link-inline { color: #0f69c4 !important; }
:root[data-theme="light"] .login-overlay {
  background: linear-gradient(160deg, #f8fafd, #eef2f7 60%, #e7eef6);
}
:root[data-theme="light"] .danger-btn,
:root[data-theme="light"] .selected-row .line-remove { color: #c0343a !important; }
:root[data-theme="light"] #btn-logout { color: #c0343a !important; }
:root[data-theme="light"] #btn-theme { color: #0f69c4 !important; }
:root[data-theme="light"] .tag-cot,
:root[data-theme="light"] .badge { color: #0f69c4; }
:root[data-theme="light"] .tag-new { color: #9a7400; }

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 105, 196, 0.22), transparent 30%),
    radial-gradient(circle at top right, rgba(229, 72, 77, 0.12), transparent 34%),
    linear-gradient(150deg, #06182c, #0a2540 55%, #0e2c4d);
}

.shell {
  width: var(--shell-max);
  margin: 0 auto;
  padding: var(--shell-pad-top) 0 var(--shell-pad-bottom);
}

.hero {
  display: grid;
  grid-template-columns: 1.6fr 0.9fr;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
}

.console {
  display: grid;
  grid-template-columns: clamp(250px, 16vw, 320px) minmax(0, 1fr);
  gap: clamp(16px, 1.4vw, 24px);
  align-items: start;
}

.console-sidebar {
  position: sticky;
  top: 18px;
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--sidebar-scroll-thumb) var(--sidebar-scroll-track);
}

.console-sidebar::-webkit-scrollbar {
  width: 12px;
}

.console-sidebar::-webkit-scrollbar-track {
  background: var(--sidebar-scroll-track);
  border-radius: 999px;
}

.console-sidebar::-webkit-scrollbar-thumb {
  background: var(--sidebar-scroll-thumb);
  border: 3px solid var(--sidebar-scroll-track);
  border-radius: 999px;
}

.console-sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.console-main {
  display: grid;
  gap: 20px;
}

.sidebar-head {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
}

.workspace-pick {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 14px;
}

.workspace-pick select,
.toolbar select,
.toolbar input[type="search"],
.pago-file input[type="search"],
.pago-file select,
.form select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  padding: 12px 14px;
}

/* Inputs de busqueda por N de OT: mismo formato que los selects vecinos. */
.toolbar input[type="search"],
.pago-file input[type="search"],
.pago-file select {
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  box-sizing: border-box;
}
.toolbar input[type="search"]:focus,
.pago-file input[type="search"]:focus,
.pago-file select:focus {
  border-color: var(--accent, #4a90d9);
}

.console-nav {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.nav-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 16px;
  cursor: pointer;
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(74, 144, 217, 0.28), rgba(15, 105, 196, 0.28));
  border-color: rgba(74, 144, 217, 0.45);
}

.nav-group {
  margin: 8px 4px 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.75;
  border-top: 1px solid var(--border-soft);
  padding-top: 12px;
}
.nav-group[hidden] { display: none; }

.sidebar-stats {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.mini-stat {
  padding: 14px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}

.mini-stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.sidebar-actions {
  margin-top: 16px;
}

.workspace {
  min-height: 260px;
}

.workspace[hidden] {
  display: none !important;
}

.inicio-only[hidden] {
  display: none !important;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  font-family: var(--font-ui);
}

h1, h2, p { margin-top: 0; }
h1 {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 4.4vw, 4.2rem);
  line-height: 1.02;
  max-width: 18ch;
  margin-bottom: 16px;
  letter-spacing: -0.03em;
}
h2 {
  font-family: var(--font-ui);
  letter-spacing: -0.02em;
}
.lede { max-width: 62ch; color: var(--muted); font-size: 1.05rem; line-height: 1.6; }

.lede-brand {
  display: grid;
  gap: 4px;
  max-width: none;
  color: var(--text);
  line-height: 1.35;
  font-family: var(--font-ui);
  white-space: nowrap;
}

.lede-brand span:first-child {
  font-size: clamp(0.88rem, 1.05vw, 1rem);
  font-weight: 600;
  white-space: nowrap;
}

.lede-brand span:last-child {
  color: var(--accent-2);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero h1 {
  font-family: var(--font-display);
  max-width: none;
  white-space: nowrap;
  font-size: clamp(2.1rem, 3.5vw, 3.7rem);
  margin-bottom: 6px;
}

.hero .lede {
  margin-bottom: 0;
  line-height: 1.42;
}

.hero-card, .panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-card {
  display: grid;
  gap: 16px;
  padding: 24px;
  align-content: start;
}

.label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.label,
.hero-card strong,
.doc-link,
.toolbar button,
.link-btn,
.nav-item,
.nav-group,
.mini-stat span,
.stat span,
.chart-label,
.chart-value,
.eyebrow,
button,
input,
select,
textarea {
  font-family: var(--font-ui);
}
.hero-card strong { font-size: 1.5rem; }

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.hero-metric {
  min-width: 0;
  padding: 12px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}

.hero-metric strong {
  display: block;
  font-size: clamp(0.98rem, 1.05vw, 1.2rem);
  line-height: 1.12;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.panel {
  padding: 22px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.stat {
  padding: 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}

.stat span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.stat strong { font-size: 1.4rem; }

.list, .cards {
  display: grid;
  gap: 12px;
}
.cards-grid {
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  align-items: start;
}

.ot-list-list {
  grid-template-columns: 1fr;
}

.item-list,
.selected-list,
.status-bars {
  display: grid;
  gap: 10px;
}

.item-list {
  max-height: 340px;
  overflow: auto;
  padding-right: 4px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 16px;
}

.toolbar button,
.link-btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--border-soft);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.toolbar button:hover,
.link-btn:hover {
  background: var(--hover);
}

.toolbar button#consult-export {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 600;
}

.toolbar button#consult-export:hover {
  filter: brightness(1.05);
}

.form-block {
  padding: 14px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}

.block-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.list {
  padding-left: 18px;
  color: var(--muted);
}

.item-row,
.selected-row,
.chart-row {
  display: grid;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}

.item-row {
  grid-template-columns: 24px minmax(0, 1fr) auto;
  font-size: 13px;
}

.item-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.item-row.selected {
  border-color: rgba(47, 178, 124, 0.35);
}

.selected-row {
  grid-template-columns: 1.4fr 130px 130px auto;
}

.selected-box {
  display: grid;
  gap: 10px;
}

.selected-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(47, 178, 124, 0.08);
  border: 1px solid rgba(47, 178, 124, 0.22);
}

.selected-main {
  display: grid;
  gap: 4px;
}

.chart-row {
  grid-template-columns: 170px 1fr 42px;
}

.chart-label,
.chart-value {
  color: var(--muted);
  font-size: 14px;
}

.chart-track {
  height: 10px;
  border-radius: 999px;
  background: var(--border-soft);
  overflow: hidden;
}

.chart-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.card {
  padding: 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.badge {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(74, 144, 217, 0.18);
  color: #a9cdf1;
  white-space: nowrap;
}

.card h3 { margin-bottom: 8px; }
.muted { color: var(--muted); }

.ot-progress {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
  margin: 14px 0 10px;
}

.ot-step {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  font-size: 11px;
  line-height: 1.15;
}

.ot-step-mark {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  flex: none;
  font-size: 12px;
  font-weight: 800;
}

.ot-step-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ot-step.done {
  border-color: rgba(47, 178, 124, 0.3);
  background: rgba(47, 178, 124, 0.08);
}

.ot-step.done .ot-step-mark {
  background: rgba(47, 178, 124, 0.18);
  color: #88e0b8;
}

.ot-step.pending {
  opacity: 0.72;
}

.ot-step.pending .ot-step-mark {
  background: rgba(229, 72, 77, 0.12);
  color: #f2a0a2;
}

.ot-step.cancelled {
  border-color: rgba(229, 72, 77, 0.35);
  background: rgba(229, 72, 77, 0.1);
}

.ot-step.cancelled .ot-step-mark {
  background: rgba(229, 72, 77, 0.18);
  color: #f2a0a2;
}

.review-box {
  padding: 14px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  min-height: 64px;
}

.form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.form input, .form textarea, .form button {
  font: inherit;
  border-radius: 14px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  padding: 12px 14px;
}

.form .full { grid-column: 1 / -1; }
.notification-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--input-border);
  border-radius: 14px;
}

.notification-options legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.notification-options label {
  display: flex;
  align-items: center;
  grid-template-columns: none;
  gap: 7px;
}

.notification-options input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.section-head { margin-top: 26px; }
.form button {
  grid-column: 1 / -1;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04111d;
  font-weight: 700;
  border: 0;
}

.compact {
  grid-template-columns: 1fr;
}

.compact button {
  grid-column: auto;
}

@media (min-width: 1500px) {
  .console-main {
    gap: 24px;
  }

  .panel {
    padding: 24px;
  }

  .form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .form .full,
  .form button {
    grid-column: 1 / -1;
  }

  .compact {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1500px) and (max-height: 1120px) {
  .hero {
    margin-bottom: 16px;
  }

  .hero-card,
  .panel {
    border-radius: 20px;
  }

  .panel {
    padding: 20px 22px;
  }

  .nav-item {
    padding: 10px 13px;
    border-radius: 14px;
  }

  .nav-group {
    margin-top: 6px;
    padding-top: 10px;
  }

  .mini-stat {
    padding: 12px 14px;
  }
}

.nested {
  box-shadow: none;
  background: var(--surface);
}

.items-small {
  font-size: 12px;
}

.console-main > .panel {
  margin-bottom: 0;
}

textarea[data-note-for] {
  width: 100%;
  margin-top: 8px;
}

input[data-field],
textarea[data-note-for] {
  border-radius: 12px;
}

/* Nota de revision por OT (fuera de un .form, necesita su propio estilo) */
.rev-nota {
  display: grid;
  gap: 6px;
  margin: 10px 0 2px;
  color: var(--muted);
  font-size: 13px;
}
.rev-nota textarea {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  border-radius: 12px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  padding: 10px 12px;
  resize: vertical;
}

/* --- Saldo del convenio en el formulario --- */
.saldo-strip {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--track);
}
.saldo-strip.alerta { border-color: rgba(255, 209, 102, 0.5); background: rgba(255, 209, 102, 0.08); }
.saldo-strip.bloqueo { border-color: rgba(229, 72, 77, 0.55); background: rgba(229, 72, 77, 0.1); }
.saldo-line { display: flex; justify-content: space-between; align-items: baseline; }
.saldo-line strong { font-size: 1.3rem; }
.saldo-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.saldo-meter {
  height: 8px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}
.saldo-meter-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.saldo-strip.alerta .saldo-meter-fill { background: linear-gradient(135deg, var(--warn), #ff9f45); }
.saldo-strip.bloqueo .saldo-meter-fill { background: linear-gradient(135deg, #e5484d, #b3252a); }

.pill {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  font-weight: 600;
}
.pill.ok { background: rgba(47, 178, 124, 0.16); color: #5fd6a3; }
.pill.warn { background: rgba(242, 183, 5, 0.18); color: var(--warn); }
.pill.danger { background: rgba(229, 72, 77, 0.2); color: #f2a0a2; }
.pill.rojo { background: rgba(229, 72, 77, 0.2); color: #f2a0a2; }
.pill.amarillo { background: rgba(242, 183, 5, 0.18); color: var(--warn); }
.pill.verde { background: rgba(47, 178, 124, 0.16); color: #5fd6a3; }

/* --- Totales en vivo de la OT --- */
.ot-totals {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(47, 178, 124, 0.06);
  border: 1px solid rgba(47, 178, 124, 0.2);
}
.totals-line { display: flex; justify-content: space-between; color: var(--muted); }
.totals-line.total { border-top: 1px solid var(--hover); padding-top: 8px; margin-top: 2px; color: var(--text); }
.totals-line.total strong { font-size: 1.35rem; }

.selected-row { grid-template-columns: minmax(0, 1fr) 96px 130px 130px; column-gap: 16px; }
.selected-row label { min-width: 0; }
.selected-row input[data-field="quantity"] { width: 100%; }
.selected-cell { display: grid; gap: 2px; align-content: center; }
.selected-cell.right { text-align: right; }
.selected-cell strong { font-size: 1rem; }
.selected-line { display: grid; gap: 2px; text-align: right; }
.selected-row .line-remove {
  grid-column: 1 / -1;
  justify-self: end;
  border: 0;
  border-radius: 12px;
  padding: 8px 18px;
  cursor: pointer;
  font-weight: 600;
  background: rgba(229, 72, 77, 0.16);
  color: #f2a0a2;
}
.selected-row .line-remove:hover { background: rgba(229, 72, 77, 0.28); }

/* --- Resumen rapido horizontal --- */
.stats-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.status-bars-wrap {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  column-gap: 16px;
}
@media (max-width: 720px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* --- Convenios y saldos: lista de ancho completo --- */
.convenio-stack,
.report-convenio-stack {
  display: grid;
  gap: 14px;
}

.convenio-card,
.report-convenio-card {
  display: grid;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  box-shadow: 0 8px 28px rgba(10, 20, 40, 0.04);
}

.convenio-card.alerta,
.report-convenio-card.alerta {
  border-color: rgba(242, 183, 5, 0.42);
  background: rgba(242, 183, 5, 0.05);
}

.convenio-card-top,
.report-convenio-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.convenio-card-grid,
.report-convenio-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(96px, 0.9fr));
  gap: 12px;
  align-items: center;
}

.convenio-subrows,
.report-convenio-subrows {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}

.convenio-subrow,
.report-subrow,
.report-convenio-totals {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(96px, 0.9fr));
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 88%, var(--accent) 12%);
}

.convenio-subrow.empty,
.report-subrow.empty {
  background: transparent;
  padding: 6px 2px 0;
}

.conv-subname {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.conv-subname strong {
  font-size: 0.92rem;
}

.sub-arrow {
  color: var(--muted);
  font-size: 0.8rem;
  flex: 0 0 auto;
}

.convenio-card .conv-name,
.report-convenio-title {
  display: grid;
  gap: 2px;
}

.convenio-card .conv-name strong,
.report-convenio-title strong {
  font-size: 1rem;
}

.convenio-card .conv-fig,
.report-convenio-grid .conv-fig,
.convenio-subrow .conv-fig,
.report-subrow .conv-fig,
.report-convenio-totals .conv-fig {
  display: grid;
  gap: 2px;
  text-align: right;
}

.convenio-card .conv-fig span,
.report-convenio-grid .conv-fig span,
.convenio-subrow .conv-fig span,
.report-subrow .conv-fig span,
.report-convenio-totals .conv-fig span {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.convenio-card .conv-fig strong,
.report-convenio-grid .conv-fig strong,
.convenio-subrow .conv-fig strong,
.report-subrow .conv-fig strong,
.report-convenio-totals .conv-fig strong {
  font-size: 0.94rem;
}

.convenio-card .conv-meter-wrap,
.report-convenio-grid .report-meter {
  display: grid;
  gap: 5px;
}

.convenio-card .conv-actions,
.report-convenio-actions {
  display: grid;
  gap: 7px;
  justify-items: end;
  align-content: start;
  white-space: nowrap;
}

.convenio-card .conv-actions .link-inline,
.report-convenio-actions .link-inline {
  background: rgba(74, 144, 217, 0.16) !important;
  color: #a9cdf1 !important;
  border: 0;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.convenio-card .conv-actions .link-inline:hover,
.report-convenio-actions .link-inline:hover {
  background: rgba(74, 144, 217, 0.28) !important;
}

.convenios-table { display: grid; gap: 10px; }
.convenio-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.6fr) 1.2fr repeat(3, minmax(90px, 0.9fr)) 112px;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}
.conv-actions { display: grid; gap: 6px; justify-items: end; }
.conv-actions .link-inline {
  background: rgba(74, 144, 217, 0.16) !important;
  color: #a9cdf1 !important;
  border: 0;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.conv-actions .link-inline:hover { background: rgba(74, 144, 217, 0.28) !important; }
.convenio-row.alerta { border-color: rgba(242, 183, 5, 0.45); background: rgba(242, 183, 5, 0.06); }
.convenio-row .conv-name { display: grid; gap: 2px; }
.convenio-row .conv-name strong { font-size: 0.98rem; }
.convenio-row .conv-fig { display: grid; gap: 2px; text-align: right; }
.convenio-row .conv-fig span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.convenio-row .conv-fig strong { font-size: 0.92rem; }
.convenio-row .conv-meter-wrap { display: grid; gap: 4px; }
.convenio-row .conv-meter-wrap .muted { font-size: 11px; }
.convenio-head-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.6fr) 1.2fr repeat(3, minmax(90px, 0.9fr)) 112px;
  gap: 14px;
  padding: 4px 16px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.convenio-head-row span:nth-child(n+3) { text-align: right; }
@media (max-width: 860px) {
  .convenio-card-top,
  .report-convenio-head {
    flex-direction: column;
  }
  .convenio-card-grid,
  .report-convenio-grid,
  .convenio-subrow,
  .report-subrow,
  .report-convenio-totals {
    grid-template-columns: 1fr 1fr;
  }
  .convenio-card-grid .conv-meter-wrap,
  .report-convenio-grid .report-meter {
    grid-column: 1 / -1;
  }
  .convenio-card .conv-actions,
  .report-convenio-actions {
    justify-items: start;
  }
  .convenio-head-row { display: none; }
  .convenio-row { grid-template-columns: 1fr 1fr; }
  .convenio-row .conv-meter-wrap { grid-column: 1 / -1; }
}

/* --- Informe consolidado de Inicio --- */
.report-stack {
  display: grid;
  gap: 16px;
}

.report-grid {
  display: grid;
  gap: 16px;
}

.report-block {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}

.report-table-wrap {
  overflow-x: auto;
  border-radius: 16px;
}

.report-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

.report-table th,
.report-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}

.report-table thead th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-align: left;
}

.report-table td:nth-child(n+2),
.report-table th:nth-child(n+2) {
  text-align: right;
}

.report-main-row {
  background: color-mix(in srgb, var(--surface) 92%, var(--accent) 8%);
}

.report-main-row.alerta {
  background: color-mix(in srgb, var(--surface) 88%, var(--warn) 12%);
}

.report-subrow td {
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.report-indent {
  padding-left: 28px !important;
}

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

.report-meter {
  display: grid;
  gap: 6px;
}

.report-actions {
  white-space: nowrap;
  display: grid;
  gap: 6px;
  justify-items: end;
}

.report-total-row td {
  background: rgba(255, 255, 255, 0.03);
}

.report-total {
  display: grid;
  gap: 4px;
  justify-items: end;
  text-align: right;
}

.report-total span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.report-total strong {
  font-size: 1.1rem;
}

.report-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.report-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.report-detail-sheet {
  display: grid;
  gap: 14px;
}

.report-detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.report-detail-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--surface) 92%, var(--accent) 8%);
}

.report-detail-card.alerta {
  background: color-mix(in srgb, var(--surface) 88%, var(--warn) 12%);
}

.report-detail-card.focus {
  border-color: rgba(74, 144, 217, 0.5);
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.08);
}

.report-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.report-detail-head h4 {
  margin: 0;
  font-size: 1.05rem;
}

.report-detail-btn {
  padding: 4px 10px !important;
  font-size: 12px;
}

.report-detail-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.report-detail-metrics div {
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  display: grid;
  gap: 4px;
}

.report-detail-metrics span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.report-detail-metrics strong {
  font-size: 0.98rem;
}

.report-detail-otstate {
  display: grid;
  gap: 8px;
}

.detail-state-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}

.detail-state-line span {
  color: var(--muted);
  font-size: 12px;
}

.detail-state-line strong {
  font-size: 12px;
}

.report-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.report-kpi {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--surface) 90%, var(--accent) 10%);
  display: grid;
  gap: 4px;
}

.report-kpi span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.report-kpi strong {
  font-size: 1.35rem;
}

.report-summary-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
  color: var(--text);
}

.report-summary-line strong {
  font-size: 1rem;
}

.report-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-start;
}

.report-chip-group .pill {
  font-size: 11px;
  padding: 4px 8px;
}

/* --- Dashboard ejecutivo de Inicio --- */
.dashboard-shell {
  display: grid;
  gap: 16px;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.9fr);
  gap: 16px;
  align-items: stretch;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--border-soft);
  background: linear-gradient(135deg, color-mix(in srgb, var(--surface) 94%, var(--accent) 6%), var(--surface));
}

.dashboard-eyebrow {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.dashboard-hero-copy h3 {
  margin: 8px 0 10px;
  font-size: clamp(1.6rem, 2.6vw, 2.25rem);
}

.dashboard-hero-copy p {
  margin: 0;
  max-width: 70ch;
  color: var(--muted);
  line-height: 1.55;
}

.dashboard-hero-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.dashboard-hero-panel {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}

.dashboard-hero-stat {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 88%, var(--accent) 12%);
  border: 1px solid var(--border-soft);
}

.dashboard-hero-stat span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dashboard-hero-stat strong {
  font-size: 1.05rem;
}

.dashboard-toolbar-panel {
  padding: 16px;
}

.dashboard-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.dashboard-filter {
  display: grid;
  gap: 6px;
}

.dashboard-filter span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dashboard-filter select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  padding: 12px 14px;
}

.dashboard-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.dashboard-kpi {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--surface) 90%, var(--accent) 10%);
  display: grid;
  gap: 4px;
}

.dashboard-kpi span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dashboard-kpi strong {
  font-size: 1.28rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.dashboard-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}

.dashboard-span-2 {
  grid-column: 1 / -1;
}

.dashboard-insights {
  display: grid;
  gap: 10px;
}

.dashboard-insight {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--surface) 92%, var(--accent) 8%);
}

.dashboard-insight-index {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(74, 144, 217, 0.16);
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 11px;
}

.dashboard-insight p {
  margin: 0;
  color: var(--text);
  line-height: 1.45;
}

.dashboard-bar-list,
.dashboard-chart-list,
.dashboard-subtable {
  display: grid;
  gap: 10px;
}

.dashboard-bar-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--surface) 92%, var(--accent) 8%);
}

.dashboard-bar-card.alerta {
  background: color-mix(in srgb, var(--surface) 86%, var(--warn) 14%);
}

.dashboard-bar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.dashboard-bar-head strong {
  font-size: 1rem;
}

.dashboard-bar-actions {
  display: grid;
  gap: 6px;
  justify-items: end;
}

.dashboard-bar-track,
.dashboard-chart-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(74, 144, 217, 0.12);
  overflow: hidden;
}

.dashboard-bar-fill,
.dashboard-chart-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1a67c7, #7fd5b7);
}

.dashboard-chart-fill.empty {
  background: rgba(74, 144, 217, 0.18);
}

.dashboard-bar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 12px;
  color: var(--muted);
}

.dashboard-chart-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) minmax(0, 2fr) auto;
  gap: 10px;
  align-items: center;
}

.dashboard-chart-label {
  font-size: 0.92rem;
  color: var(--text);
}

.dashboard-chart-value {
  min-width: 28px;
  text-align: right;
  font-weight: 700;
}

.dashboard-empty {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px dashed var(--border-soft);
  color: var(--muted);
}

.dashboard-muted {
  color: var(--muted);
}

.dashboard-subrow,
.dashboard-detail-subrow {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) repeat(4, minmax(90px, 0.7fr));
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--surface) 94%, var(--accent) 6%);
}

.dashboard-subrow-label {
  display: grid;
  gap: 3px;
}

.dashboard-subrow-label strong {
  font-size: 0.95rem;
}

.dashboard-subrow-label span {
  color: var(--muted);
  font-size: 12px;
}

.dashboard-subrow-metric {
  display: grid;
  gap: 3px;
  text-align: right;
}

.dashboard-subrow-metric span {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dashboard-subrow-metric strong {
  font-size: 0.94rem;
}

.dashboard-detail-sheet {
  display: grid;
  gap: 14px;
}

.dashboard-detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.dashboard-detail-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--surface) 92%, var(--accent) 8%);
}

.dashboard-detail-card.alerta {
  background: color-mix(in srgb, var(--surface) 88%, var(--warn) 12%);
}

.dashboard-detail-card.focus {
  border-color: rgba(74, 144, 217, 0.5);
  box-shadow: 0 0 0 2px rgba(74, 144, 217, 0.08);
}

.dashboard-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.dashboard-detail-head h4 {
  margin: 0;
  font-size: 1.05rem;
}

.dashboard-detail-actions {
  display: grid;
  gap: 6px;
  justify-items: end;
}

.dashboard-detail-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.dashboard-detail-metrics div {
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  display: grid;
  gap: 4px;
}

.dashboard-detail-metrics span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.dashboard-detail-metrics strong {
  font-size: 0.98rem;
}

.dashboard-detail-meter {
  display: grid;
  gap: 6px;
}

.dashboard-detail-state {
  display: grid;
  gap: 10px;
}

.dashboard-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(74, 144, 217, 0.12);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.dashboard-bar-card .link-inline,
.dashboard-detail-card .link-inline {
  background: rgba(74, 144, 217, 0.16) !important;
  color: #a9cdf1 !important;
  border: 0;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.dashboard-bar-card .link-inline:hover,
.dashboard-detail-card .link-inline:hover {
  background: rgba(74, 144, 217, 0.28) !important;
}

@media (max-width: 860px) {
  .report-table { min-width: 780px; }
  .report-summary-line { flex-direction: column; align-items: flex-start; }
  .report-detail-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-hero,
  .dashboard-toolbar,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .dashboard-span-2 {
    grid-column: auto;
  }
  .dashboard-detail-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dashboard-subrow,
  .dashboard-detail-subrow {
    grid-template-columns: 1fr 1fr;
  }
  .dashboard-subrow-label {
    grid-column: 1 / -1;
  }
  .dashboard-toolbar-actions {
    justify-content: flex-start;
  }
  .dashboard-chart-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .dashboard-chart-value {
    text-align: left;
  }
}

.danger-btn { background: rgba(229, 72, 77, 0.16) !important; color: #f2a0a2 !important; }
.danger-btn:hover { background: rgba(229, 72, 77, 0.28) !important; }

/* --- Selector de item con boton agregar --- */
.item-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}
.item-picker select,
.item-picker input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
}
.item-picker button {
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 700;
  color: #04111d;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  white-space: nowrap;
}
@media (max-width: 920px) {
  .item-picker { grid-template-columns: 1fr; }
}

input[readonly] { opacity: 0.85; cursor: default; }

/* --- Paneles de info de OT (informe / CRC / pago) --- */
.ot-info {
  padding: 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.info-grid span { display: block; font-size: 11px; }
.info-grid strong { font-size: 0.95rem; }
.info-items { margin-top: 12px; border-top: 1px solid var(--border-soft); padding-top: 10px; }
.info-items ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }

/* --- Checklist del expediente --- */
.checklist { display: grid; gap: 10px; }
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.check-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}
.check-item.pendiente { border-color: rgba(229, 72, 77, 0.4); }
.check-item.cargado { border-color: rgba(47, 178, 124, 0.35); }

.signed-upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.signed-upload {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: color-mix(in srgb, var(--surface) 92%, var(--accent) 8%);
}

.signed-upload-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
  font-size: 13px;
}

.signed-upload input[type="file"] {
  width: 100%;
}

.review-lote-card {
  display: grid;
  gap: 12px;
}

.review-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.review-summary strong {
  color: var(--text);
}

.review-summary .review-total {
  padding: 7px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 78%, var(--accent) 22%);
  border: 1px solid var(--border-soft);
}

.review-trace {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  flex-wrap: wrap;
  gap: 4px;
  padding: 7px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 82%, var(--accent) 18%);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 13px;
}

.review-trace strong {
  color: var(--text);
}

.review-ot-list {
  display: grid;
  gap: 10px;
}

.review-ot-row {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(120px, auto) auto minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 92%, var(--accent) 8%);
  border: 1px solid var(--border-soft);
}

.review-ot-amount {
  display: grid;
  gap: 4px;
  min-width: 120px;
  padding: 8px 10px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 82%, var(--accent) 18%);
  border: 1px solid var(--border-soft);
  text-align: right;
}

.review-ot-amount span {
  color: var(--muted);
  font-size: 11px;
}

.review-ot-amount strong {
  color: var(--text);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.review-ot-meta,
.review-ot-actions {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.review-ot-nota textarea {
  width: 100%;
  min-height: 72px;
  border-radius: 12px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  padding: 10px 12px;
  resize: vertical;
}

.review-ot-actions .link-inline {
  background: rgba(74, 144, 217, 0.16) !important;
  color: #a9cdf1 !important;
  border: 0;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.review-ot-actions .approve-btn {
  background: linear-gradient(135deg, #0f69c4, #06437b) !important;
  color: #ffffff !important;
  box-shadow: 0 8px 18px rgba(6, 67, 123, 0.24);
}

.review-ot-actions .approve-btn:hover {
  filter: brightness(1.05);
}

:root[data-theme="light"] .review-ot-actions .approve-btn {
  background: #06437b !important;
  color: #ffffff !important;
}

.review-ot-actions .danger-btn {
  background: rgba(229, 72, 77, 0.16) !important;
  color: #f2a0a2 !important;
}

.review-ot-actions .danger-btn:hover {
  background: rgba(229, 72, 77, 0.28) !important;
}

.pago-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.pago-file { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.pago-actions button {
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  background: var(--border-soft);
  color: var(--text);
}
.pago-actions button:hover { background: var(--hover); }
#pago-submit:disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.4); }

/* --- Documentos firmados --- */
.firmados-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin: 6px 0 8px;
}
.firmado-item {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid rgba(229, 72, 77, 0.35);
}
.firmado-item.firmado { border-color: rgba(47, 178, 124, 0.4); }
.firmado-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.firmado-head strong { min-width: 0; overflow-wrap: anywhere; }
.firmado-links { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.firmado-upload { display: grid; gap: 4px; min-width: 0; color: var(--muted); font-size: 12px; }
.firmado-upload input {
  font: inherit;
  color: var(--text);
  font-size: 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* --- Previsualizacion de fotos del informe --- */
.fotos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.foto-item {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}
.foto-item img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}
.foto-item input {
  font: inherit;
  font-size: 12px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border-radius: 8px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  padding: 6px 8px;
}

.anexos-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.anexos-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}
.anexos-list .link-btn {
  padding: 4px 12px;
  font-size: 12px;
}

/* --- Solicitudes de mantencion --- */
.proposal-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  display: grid;
  gap: 8px;
}

.solicitudes-list {
  display: grid;
  gap: 14px;
}

.solicitud-card {
  display: grid;
  gap: 12px;
}

.solicitud-badges,
.solicitud-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.solicitud-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  color: var(--muted);
  font-size: 13px;
}

.solicitud-meta strong,
.solicitud-last strong {
  color: var(--text);
}

.solicitud-description {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  white-space: pre-wrap;
}

.solicitud-last {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(74, 144, 217, 0.08);
  border: 1px solid rgba(74, 144, 217, 0.16);
}

.solicitud-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}

.solicitud-evidence,
.solicitud-movements {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.solicitud-evidence-item,
.solicitud-movement {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}

.solicitud-evidence-item img,
.solicitud-movement-photos img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}

.solicitud-movement-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.solicitud-movement-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.solicitud-movement-photos figure {
  margin: 0;
  display: grid;
  gap: 6px;
}

.solicitud-movement-photos figcaption {
  color: var(--muted);
  font-size: 12px;
}

/* --- Gestion de solicitudes --- */
.gestion-page {
  background:
    radial-gradient(circle at 10% 8%, rgba(74, 144, 217, 0.22), transparent 24%),
    radial-gradient(circle at 90% 10%, rgba(47, 178, 124, 0.12), transparent 22%),
    radial-gradient(circle at 78% 92%, rgba(242, 183, 5, 0.10), transparent 18%),
    linear-gradient(160deg, #eef4fb 0%, #edf2f8 48%, #e3ebf5 100%);
}

:root[data-theme="dark"] .gestion-page {
  background:
    radial-gradient(circle at 10% 8%, rgba(74, 144, 217, 0.22), transparent 24%),
    radial-gradient(circle at 90% 10%, rgba(47, 178, 124, 0.12), transparent 22%),
    radial-gradient(circle at 78% 92%, rgba(242, 183, 5, 0.08), transparent 18%),
    linear-gradient(150deg, #071525, #0a2340 52%, #102f50);
}

.gestion-page .shell {
  padding-top: 28px;
}

.gestion-page .hero {
  margin-bottom: 24px;
}

.gestion-page .hero > div:first-child {
  padding-top: 6px;
}

.gestion-page .hero h1 {
  font-size: clamp(2.5rem, 4vw, 4.2rem);
  line-height: 0.96;
  letter-spacing: -0.05em;
  margin: 0 0 10px;
}

.gestion-page .lede {
  max-width: 58ch;
  font-size: 1.03rem;
  line-height: 1.55;
}

.gestion-page .hero-card,
.gestion-page .panel,
.gestion-page .gestion-detail {
  backdrop-filter: blur(20px);
}

.gestion-page .hero-card {
  padding: 22px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: var(--shadow);
}

:root[data-theme="light"] .gestion-page .hero-card {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(15, 105, 196, 0.10);
}

:root[data-theme="dark"] .gestion-page .hero-card {
  background: rgba(9, 18, 30, 0.58);
  border-color: rgba(255, 255, 255, 0.10);
}

.gestion-page .user-chip {
  align-items: flex-start;
  gap: 14px;
}

.gestion-page .user-chip strong {
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.gestion-page .chip-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.gestion-page .hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.gestion-page .hero-metric {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-soft);
}

.gestion-page .hero-metric strong {
  display: block;
  font-size: 1.7rem;
  line-height: 1;
}

.gestion-page .panel {
  padding: 22px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow);
}

:root[data-theme="light"] .gestion-page .panel {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(15, 105, 196, 0.10);
}

:root[data-theme="dark"] .gestion-page .panel {
  background: rgba(9, 18, 30, 0.58);
  border-color: rgba(255, 255, 255, 0.10);
}

.gestion-page .panel-head {
  margin-bottom: 16px;
}

.gestion-page .panel-head h2 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
}

.gestion-page .panel-head .muted {
  max-width: 68ch;
}

.gestion-page .gestion-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
  padding: 16px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--border-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.gestion-page .gestion-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.gestion-page .gestion-toolbar input,
.gestion-page .gestion-toolbar select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
}

.gestion-page .gestion-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.35fr);
  gap: 18px;
  align-items: start;
}

.gestion-page .gestion-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 390px);
  overflow: auto;
  padding-right: 6px;
}

.gestion-page .gestion-item {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.06));
  color: var(--text);
  border-radius: 20px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 8px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.gestion-page .gestion-item::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, rgba(74, 144, 217, 0.75), rgba(47, 178, 124, 0.75));
  opacity: 0;
  transition: opacity 0.18s ease;
}

.gestion-page .gestion-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(10, 28, 48, 0.12);
  border-color: rgba(74, 144, 217, 0.30);
}

.gestion-page .gestion-item:hover::before,
.gestion-page .gestion-item.selected::before {
  opacity: 1;
}

.gestion-page .gestion-item.selected {
  border-color: rgba(74, 144, 217, 0.42);
  background: linear-gradient(135deg, rgba(74, 144, 217, 0.18), rgba(15, 105, 196, 0.08));
  box-shadow: 0 16px 34px rgba(15, 105, 196, 0.16);
}

.gestion-page .gestion-item-head,
.gestion-page .gestion-history-head,
.gestion-page .card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.gestion-page .gestion-item-head strong {
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.gestion-page .gestion-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.gestion-page .gestion-item-meta span {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-soft);
}

.gestion-page .gestion-item .muted:last-child {
  line-height: 1.45;
}

.gestion-page .gestion-panel {
  min-width: 0;
  position: sticky;
  top: 18px;
  align-self: start;
}

.gestion-page .gestion-panel > .card.muted {
  padding: 18px;
  border-radius: 20px;
}

.gestion-page .gestion-detail {
  display: grid;
  gap: 14px;
  padding: 20px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow);
}

:root[data-theme="light"] .gestion-page .gestion-detail {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(15, 105, 196, 0.10);
}

:root[data-theme="dark"] .gestion-page .gestion-detail {
  background: rgba(9, 18, 30, 0.62);
  border-color: rgba(255, 255, 255, 0.10);
}

.gestion-page .card-head {
  align-items: flex-start;
}

.gestion-page .card-head h3 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.gestion-page .card-head .muted {
  font-size: 14px;
}

.gestion-page .gestion-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.gestion-page .gestion-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.gestion-page .gestion-meta span {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-soft);
  line-height: 1.35;
}

.gestion-page .gestion-description {
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border-soft);
  white-space: pre-wrap;
  line-height: 1.6;
  min-height: 96px;
}

.gestion-page .gestion-flow {
  display: grid;
  gap: 16px;
}

.gestion-page .gestion-section {
  padding: 16px 18px 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.gestion-page .gestion-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.gestion-page .gestion-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.gestion-page .gestion-section-head h4 {
  margin: 0;
  font-size: 18px;
  color: var(--text);
}

.gestion-page .gestion-section-head p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.gestion-page .gestion-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.gestion-page .gestion-form label {
  display: grid;
  gap: 6px;
  padding: 12px 13px 13px;
  border-radius: 16px;
  color: var(--muted);
  font-size: 13px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-soft);
}

.gestion-page .gestion-form input,
.gestion-page .gestion-form select,
.gestion-page .gestion-form textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
}

.gestion-page .gestion-form textarea {
  min-height: 108px;
  resize: vertical;
}

.gestion-page .gestion-form .full {
  grid-column: 1 / -1;
}

.gestion-page .gestion-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.gestion-page .gestion-actions button {
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.gestion-page .gestion-actions button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
  border-color: rgba(74, 144, 217, 0.28);
}

.gestion-page .gestion-actions button[data-action="priority"] {
  background: rgba(242, 183, 5, 0.16);
}

.gestion-page .gestion-actions button[data-action="schedule"] {
  background: rgba(74, 144, 217, 0.16);
}

.gestion-page .gestion-actions button[data-action="route"] {
  background: rgba(47, 178, 124, 0.16);
}

.gestion-page .gestion-actions button[data-action="start"] {
  background: rgba(15, 105, 196, 0.20);
}

.gestion-page .gestion-actions button[data-action="close"] {
  background: rgba(229, 72, 77, 0.16);
}

.gestion-page .gestion-actions button[data-action="review"] {
  background: rgba(115, 167, 255, 0.16);
}

.gestion-page .solicitud-details {
  margin-top: 6px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-soft);
  overflow: hidden;
}

.gestion-page .solicitud-details summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  font-weight: 700;
}

.gestion-page .solicitud-details summary::-webkit-details-marker {
  display: none;
}

.gestion-page .solicitud-details summary::after {
  content: "▾";
  color: var(--muted);
  transition: transform 0.18s ease;
}

.gestion-page .solicitud-details[open] summary::after {
  transform: rotate(180deg);
}

.gestion-page .solicitud-details[open] summary {
  border-bottom: 1px solid var(--border-soft);
}

.gestion-page .gestion-history {
  display: grid;
  gap: 12px;
  margin-top: 0;
  padding: 14px 16px 16px;
  max-height: 440px;
  overflow: auto;
}

.gestion-page .gestion-history-item {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-soft);
}

.gestion-page .gestion-history-item .muted {
  line-height: 1.45;
}

.gestion-page .calendar-panel {
  margin-bottom: 18px;
}

.gestion-page .gestion-calendar-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 220px auto;
  gap: 14px;
  margin-bottom: 16px;
  padding: 16px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid var(--border-soft);
  align-items: end;
}

.gestion-page .gestion-calendar-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.gestion-page .gestion-calendar-toolbar input {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
}

.gestion-page .calendar-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
}

.gestion-page .calendar-download {
  width: 100%;
  min-height: 45px;
  border: 1px solid rgba(74, 144, 217, 0.30);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(74, 144, 217, 0.22), rgba(74, 144, 217, 0.14));
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 20px rgba(15, 105, 196, 0.12);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.gestion-page .calendar-download:hover {
  transform: translateY(-1px);
  border-color: rgba(74, 144, 217, 0.42);
  box-shadow: 0 14px 24px rgba(15, 105, 196, 0.16);
}

.gestion-page .calendar-switches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gestion-page .calendar-switches button {
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.gestion-page .calendar-switches button.active {
  background: rgba(74, 144, 217, 0.22);
  border-color: rgba(74, 144, 217, 0.36);
}

.gestion-page .calendar-scope button.active {
  background: rgba(182, 108, 255, 0.18);
  border-color: rgba(182, 108, 255, 0.34);
}

.gestion-page .calendar-switches button[data-calendar-focus="scheduled"].active {
  background: rgba(74, 144, 217, 0.22);
  border-color: rgba(74, 144, 217, 0.36);
  color: var(--text);
}

.gestion-page .calendar-switches button[data-calendar-focus="executed"].active {
  background: rgba(47, 178, 124, 0.18);
  border-color: rgba(47, 178, 124, 0.34);
  color: var(--text);
}

.gestion-page .calendar-switches button:hover {
  transform: translateY(-1px);
  border-color: rgba(74, 144, 217, 0.28);
}

.gestion-page .calendar-focus-chip {
  min-width: 110px;
  padding: 10px 12px;
  border-radius: 18px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 4px;
  align-items: center;
  justify-items: center;
}

.gestion-page .calendar-focus-chip span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gestion-page .calendar-focus-chip strong {
  font-size: 1.25rem;
  line-height: 1;
  letter-spacing: -0.04em;
}

.gestion-page .calendar-focus-chip.focus-scheduled {
  background: rgba(74, 144, 217, 0.12);
  border-color: rgba(74, 144, 217, 0.28);
}

.gestion-page .calendar-focus-chip.focus-executed {
  background: rgba(47, 178, 124, 0.12);
  border-color: rgba(47, 178, 124, 0.28);
}

.gestion-page .calendar-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.gestion-page .calendar-summary-card {
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.06));
  border: 1px solid var(--border-soft);
  display: grid;
  gap: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.gestion-page .calendar-summary-card strong {
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.gestion-page .calendar-host {
  display: grid;
  gap: 14px;
}

.gestion-page .calendar-panel {
  position: relative;
  overflow: hidden;
}

.gestion-page .calendar-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(74, 144, 217, 0.10), transparent 32%),
    radial-gradient(circle at bottom left, rgba(47, 178, 124, 0.08), transparent 28%);
  pointer-events: none;
}

.gestion-page .calendar-panel > * {
  position: relative;
  z-index: 1;
}

.gestion-page .calendar-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.gestion-page .calendar-heading h3 {
  margin: 0;
  font-size: clamp(1.2rem, 1.35vw, 1.5rem);
  letter-spacing: -0.03em;
  font-family: var(--font-display);
}

.gestion-page .calendar-day-detail {
  display: grid;
  gap: 12px;
}

.gestion-page .calendar-day-detail-highlight {
  padding: 2px 0 0;
}

.gestion-page .calendar-grid {
  display: grid;
  gap: 12px;
}

.gestion-page .calendar-week-grid {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.gestion-page .calendar-day-card {
  min-width: 0;
  padding: 14px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.06));
  border: 1px solid var(--border-soft);
  display: grid;
  gap: 10px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.gestion-page .calendar-day-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: transparent;
}

.gestion-page .calendar-day-card.focus-scheduled::before {
  background: linear-gradient(180deg, rgba(74, 144, 217, 0.92), rgba(15, 105, 196, 0.58));
}

.gestion-page .calendar-day-card.focus-executed::before {
  background: linear-gradient(180deg, rgba(47, 178, 124, 0.92), rgba(26, 163, 95, 0.58));
}

.gestion-page .calendar-day-card.focus-scheduled {
  background:
    linear-gradient(180deg, rgba(74, 144, 217, 0.12), rgba(255, 255, 255, 0.06)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
}

.gestion-page .calendar-day-card.focus-executed {
  background:
    linear-gradient(180deg, rgba(47, 178, 124, 0.10), rgba(255, 255, 255, 0.06)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
}

.gestion-page .calendar-day-card.today {
  border-color: rgba(74, 144, 217, 0.34);
  background: linear-gradient(180deg, rgba(15, 105, 196, 0.11), rgba(255, 255, 255, 0.06));
}

.gestion-page .calendar-day-card.selected {
  border-color: rgba(74, 144, 217, 0.72);
  box-shadow: 0 18px 34px rgba(15, 105, 196, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transform: translateY(-1px);
}

.gestion-page .calendar-day-card:hover {
  transform: translateY(-1px);
}

.gestion-page .calendar-day-head,
.gestion-page .calendar-entry-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.gestion-page .calendar-day-head {
  font-family: var(--font-ui);
  font-size: 1rem;
}

.gestion-page .calendar-day-head span,
.gestion-page .calendar-day-cell-head span {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 12px;
}

.gestion-page .calendar-day-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 11px;
  font-style: normal;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.gestion-page .calendar-day-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.gestion-page .calendar-day-counts span {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-soft);
  font-weight: 600;
}

.gestion-page .calendar-day-card.focus-scheduled .calendar-day-counts span:first-child,
.gestion-page .calendar-day-cell.focus-scheduled .calendar-day-cell-head span {
  background: rgba(74, 144, 217, 0.12);
  border-color: rgba(74, 144, 217, 0.24);
}

.gestion-page .calendar-day-card.focus-executed .calendar-day-counts span:first-child,
.gestion-page .calendar-day-cell.focus-executed .calendar-day-cell-head span {
  background: rgba(47, 178, 124, 0.12);
  border-color: rgba(47, 178, 124, 0.24);
}

.gestion-page .calendar-day-list {
  display: grid;
  gap: 8px;
}

.gestion-page .calendar-mini-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 12px;
  display: grid;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  position: relative;
  overflow: hidden;
}

.gestion-page .calendar-mini-card.focus-scheduled {
  background: rgba(74, 144, 217, 0.10);
  border-color: rgba(74, 144, 217, 0.20);
}

.gestion-page .calendar-mini-card.focus-executed {
  background: rgba(47, 178, 124, 0.10);
  border-color: rgba(47, 178, 124, 0.20);
}

.gestion-page .calendar-mini-card.focus-scheduled::before,
.gestion-page .calendar-mini-card.focus-executed::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
}

.gestion-page .calendar-mini-card.focus-scheduled::before {
  background: rgba(74, 144, 217, 0.92);
}

.gestion-page .calendar-mini-card.focus-executed::before {
  background: rgba(47, 178, 124, 0.92);
}

.gestion-page .calendar-mini-card:hover {
  transform: translateY(-1px);
}

.gestion-page .calendar-mini-card strong,
.gestion-page .calendar-day-cell-item strong {
  font-size: 0.95rem;
}

.gestion-page .calendar-mini-card span,
.gestion-page .calendar-day-cell-item span {
  color: var(--muted);
  font-size: 12px;
}

.gestion-page .calendar-empty {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px dashed var(--border-soft);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

.gestion-page .calendar-empty.compact {
  padding: 8px 10px;
  font-size: 12px;
}

.gestion-page .calendar-entry {
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border-soft);
  display: grid;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.gestion-page .calendar-entry::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, rgba(74, 144, 217, 0.92), rgba(15, 105, 196, 0.52));
}

.gestion-page .calendar-entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gestion-page .calendar-entry-meta span {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 12px;
}

.gestion-page .calendar-entry-date {
  color: var(--accent);
  font-weight: 700;
}

.gestion-page .calendar-entry-desc {
  line-height: 1.5;
  color: var(--text);
}

.gestion-page .calendar-month {
  display: grid;
  gap: 10px;
}

.gestion-page .calendar-month-head,
.gestion-page .calendar-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.gestion-page .calendar-month-head span {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-ui);
  font-weight: 700;
}

.gestion-page .calendar-day-cell {
  min-height: 140px;
  border-radius: 22px;
  border: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.06));
  padding: 12px;
  display: grid;
  gap: 8px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.gestion-page .calendar-day-cell::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: transparent;
}

.gestion-page .calendar-day-cell.focus-scheduled::before {
  background: linear-gradient(180deg, rgba(74, 144, 217, 0.92), rgba(15, 105, 196, 0.58));
}

.gestion-page .calendar-day-cell.focus-executed::before {
  background: linear-gradient(180deg, rgba(47, 178, 124, 0.92), rgba(26, 163, 95, 0.58));
}

.gestion-page .calendar-day-cell.today {
  border-color: rgba(47, 178, 124, 0.34);
  background: linear-gradient(180deg, rgba(47, 178, 124, 0.10), rgba(255, 255, 255, 0.06));
}

.gestion-page .calendar-day-cell.outside {
  opacity: 0.55;
}

.gestion-page .calendar-day-cell.selected {
  border-color: rgba(74, 144, 217, 0.42);
  box-shadow: 0 20px 36px rgba(15, 105, 196, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transform: translateY(-1px);
}

.gestion-page .calendar-day-cell:hover {
  transform: translateY(-1px);
}

.gestion-page .calendar-day-cell-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.gestion-page .calendar-day-cell-list {
  display: grid;
  gap: 8px;
}

.gestion-page .calendar-day-cell-item {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--border-soft);
}

.gestion-page .calendar-day-cell.focus-scheduled .calendar-day-cell-item {
  background: rgba(74, 144, 217, 0.10);
  border-color: rgba(74, 144, 217, 0.18);
}

.gestion-page .calendar-day-cell.focus-executed .calendar-day-cell-item {
  background: rgba(47, 178, 124, 0.10);
  border-color: rgba(47, 178, 124, 0.18);
}

.gestion-page .calendar-day-cell-more {
  color: var(--muted);
  font-size: 12px;
  padding: 2px 4px;
}

@media (max-width: 1200px) {
  .gestion-page .hero {
    grid-template-columns: 1fr;
  }

  .gestion-page .gestion-layout {
    grid-template-columns: 1fr;
  }

  .gestion-page .gestion-panel {
    position: static;
  }

  .gestion-page .gestion-calendar-toolbar {
    grid-template-columns: 1fr;
  }

  .gestion-page .calendar-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gestion-page .calendar-week-grid,
  .gestion-page .calendar-month-head,
  .gestion-page .calendar-month-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .confirmation-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .gestion-page .gestion-toolbar,
  .gestion-page .gestion-form {
    grid-template-columns: 1fr;
  }

  .gestion-page .hero-metrics {
    grid-template-columns: 1fr;
  }

  .gestion-page .calendar-summary {
    grid-template-columns: 1fr;
  }

  .gestion-page .calendar-week-grid,
  .gestion-page .calendar-month-grid,
  .gestion-page .calendar-month-head {
    grid-template-columns: 1fr;
  }

  .confirmation-meta {
    grid-template-columns: 1fr;
  }
}

.confirm-check {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(47, 178, 124, 0.06);
  border: 1px solid rgba(47, 178, 124, 0.22);
  color: var(--text);
  font-size: 14px;
}
.confirm-check input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.confirmation-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 8%, rgba(74, 144, 217, 0.22), transparent 24%),
    radial-gradient(circle at 90% 10%, rgba(47, 178, 124, 0.12), transparent 22%),
    linear-gradient(160deg, #eef4fb 0%, #edf2f8 48%, #e3ebf5 100%);
}

:root[data-theme="dark"] .confirmation-page {
  background:
    radial-gradient(circle at 10% 8%, rgba(74, 144, 217, 0.22), transparent 24%),
    radial-gradient(circle at 90% 10%, rgba(47, 178, 124, 0.12), transparent 22%),
    linear-gradient(150deg, #071525, #0a2340 52%, #102f50);
}

.confirmation-shell {
  width: min(980px, calc(100vw - 32px));
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 0;
}

.confirmation-card {
  width: 100%;
  padding: 24px;
  border-radius: 28px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.confirmation-detail {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.confirmation-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.confirmation-meta-card {
  padding: 14px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}

.confirmation-meta-card strong {
  display: block;
  font-size: 1rem;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.confirmation-description {
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-soft);
  display: grid;
  gap: 8px;
  line-height: 1.6;
}

.confirmation-form {
  display: grid;
  gap: 16px;
}

.confirmation-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 600;
}

.confirmation-form textarea {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  padding: 14px 16px;
  font: inherit;
  resize: vertical;
  min-height: 120px;
}

.confirmation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.confirmation-actions button {
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

.confirmation-actions button.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.confirmation-result {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  display: grid;
  gap: 6px;
}

.confirmation-result.ok {
  border-color: rgba(47, 178, 124, 0.35);
  background: rgba(47, 178, 124, 0.10);
}

.confirmation-result.error {
  border-color: rgba(229, 72, 77, 0.35);
  background: rgba(229, 72, 77, 0.10);
}

.doc-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  font-size: 13px;
}
.doc-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  text-decoration: none;
  background: rgba(115, 167, 255, 0.16);
  color: #a9c6ff;
  border: 1px solid rgba(115, 167, 255, 0.28);
}
.doc-link:hover { background: rgba(115, 167, 255, 0.28); }
.doc-link::before { content: "📄"; }

/* Version FIRMADA (escaneo cargado en el paso 4): es la que vale para revision y pago,
   por eso se destaca en verde. El generado por el sistema queda como enlace secundario. */
.doc-link.firmado {
  background: rgba(47, 178, 124, 0.16);
  color: #7fdcb4;
  border-color: rgba(47, 178, 124, 0.32);
}
.doc-link.firmado:hover { background: rgba(47, 178, 124, 0.28); }
.doc-link.firmado::before { content: "✍"; }
.doc-link.muted-link {
  background: transparent;
  border-color: var(--border-soft);
  color: var(--muted);
  font-size: 12px;
}
.doc-link.muted-link::before { content: "📄"; opacity: .6; }
:root[data-theme="light"] .doc-link.firmado { color: #1c7a54 !important; }
:root[data-theme="light"] .doc-link.muted-link { color: var(--muted) !important; }

.review-ot-docs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
}
.review-ot-docs .doc-link { padding: 4px 10px; }

/* --- Item fuera del itemizado --- */
.nuevo-item-block { border-color: rgba(255, 209, 102, 0.28); background: rgba(255, 209, 102, 0.05); }
.nuevo-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 0;
}
#nuevo-item-body { margin-top: 12px; }
.nuevo-item-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.nuevo-item-grid .full { grid-column: 1 / -1; }
.nuevo-item-grid label { display: grid; gap: 5px; color: var(--muted); font-size: 13px; }
.nuevo-item-grid input {
  font: inherit;
  border-radius: 12px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  padding: 10px 12px;
}
#btn-add-nuevo {
  border: 0;
  border-radius: 12px;
  padding: 11px 18px;
  cursor: pointer;
  font-weight: 700;
  color: #04111d;
  background: linear-gradient(135deg, var(--warn), #ffb454);
}
.tag-new, .tag-cot {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.tag-new { background: rgba(255, 209, 102, 0.18); color: var(--warn); }
.tag-cot { background: rgba(115, 167, 255, 0.16); color: #a9c6ff; }

/* --- Login / sesion --- */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at top left, rgba(47, 178, 124, 0.18), transparent 30%),
    radial-gradient(circle at bottom right, rgba(115, 167, 255, 0.18), transparent 32%),
    linear-gradient(145deg, #08101a, #0e1726 55%, #152238);
}
.login-overlay[hidden] { display: none; }
.login-card {
  width: min(400px, 100%);
  display: grid;
  gap: 12px;
  padding: 28px;
  border-radius: 24px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.login-card h2 { margin: 0; }
.login-card label { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
.login-card input {
  font: inherit;
  border-radius: 14px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  padding: 12px 14px;
}
.login-card button {
  margin-top: 4px;
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 700;
  color: #04111d;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.login-error {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(229, 72, 77, 0.16);
  color: #f2a0a2;
  font-size: 13px;
}
.login-error[hidden] { display: none; }
.login-card .link-inline {
  background: transparent !important;
  color: var(--accent-2) !important;
  border: 0;
  padding: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  text-align: center;
}
#reset-request-form[hidden] { display: none; }

.user-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.user-chip .muted { display: block; font-size: 12px; }
.chip-actions { display: flex; gap: 8px; flex-shrink: 0; }
.user-chip button {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
}
#btn-logout { background: rgba(229, 72, 77, 0.16); color: #f2a0a2; }
#btn-theme { background: rgba(74, 144, 217, 0.16); color: #a9cdf1; }
#btn-theme:hover { background: rgba(74, 144, 217, 0.28); }
.nav-item[hidden] { display: none; }

/* --- Carga masiva --- */
.bulk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.bulk-card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 18px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
}
.bulk-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.bulk-head h3 { margin: 0; }
.bulk-card .doc-link { justify-self: start; }
.bulk-file { display: grid; gap: 5px; color: var(--muted); font-size: 13px; }
.bulk-file input { font: inherit; color: var(--text); }
.bulk-replace { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.bulk-replace input { width: 16px; height: 16px; accent-color: var(--warn); }
.bulk-import {
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 700;
  color: #04111d;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.bulk-import:disabled { opacity: 0.6; cursor: wait; }
.historical-preview {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}
@media (max-width: 920px) {
  .nuevo-item-grid { grid-template-columns: 1fr; }
}

@media (max-width: 920px) {
  .hero, .grid { grid-template-columns: 1fr; }
  .hero h1 { white-space: normal; }
  .console { grid-template-columns: 1fr; }
  .console-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }
  .form { grid-template-columns: 1fr; }
  .selected-row,
  .chart-row,
  .item-row,
  .review-ot-row {
    grid-template-columns: 1fr;
  }

  .review-ot-amount {
    width: fit-content;
    text-align: left;
  }
}

@media (max-width: 720px) {
  .hero-metrics { grid-template-columns: 1fr; }
}

/* --- Dashboard de Inicio v2 (simple + cross-filtering) --- */
.report-stack { display: grid; gap: 16px; }
.dash-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(172px, 1fr)); gap: 12px; }
.dash-kpi { padding: 12px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border-soft); min-width: 0; }
.dash-kpi span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.dash-kpi strong { display: block; font-size: clamp(0.95rem, 1.5vw, 1.15rem); white-space: nowrap; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.dashboard-card { padding: 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border-soft); }
.dashboard-card .block-head { margin-bottom: 12px; }

.dash-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
.dash-table th, .dash-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border-soft); }
.dash-table th.num, .dash-table td.num { text-align: right; white-space: nowrap; }
.dash-conv { cursor: pointer; }
.dash-conv:hover { background: var(--hover); }
.dash-conv.active { background: rgba(74, 144, 217, 0.16); }
.dash-conv.alerta td:first-child { border-left: 3px solid var(--danger); }
.dash-sub td { color: var(--muted); font-size: 13px; border-bottom: 1px dashed var(--border-soft); }
.dash-sub td:first-child { padding-left: 22px; }

.dash-legends { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.dash-legend { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 12px; cursor: pointer; }
.dash-legend.active { border-color: var(--accent); background: rgba(74, 144, 217, 0.16); }
.dash-legend .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.dash-stack { display: flex; align-items: flex-end; gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.dash-col { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 54px; }
.dash-col-total { font-size: 11px; color: var(--muted); white-space: nowrap; }
.dash-col-bars { display: flex; flex-direction: column-reverse; justify-content: flex-start; width: 34px; border-radius: 6px 6px 0 0; overflow: hidden; background: var(--track); }
.dash-seg { width: 100%; }
.dash-col-label { font-size: 11px; color: var(--muted); }

.dash-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.dash-list { display: grid; gap: 6px; }
.dash-row { display: grid; grid-template-columns: minmax(90px, 1.2fr) 2fr auto; align-items: center; gap: 10px; padding: 6px 8px; border: 0; border-radius: 10px; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.dash-row:hover { background: var(--hover); }
.dash-row.active { background: rgba(74, 144, 217, 0.16); }
.dash-row-name { font-size: 13px; }
.dash-row-bar { height: 10px; border-radius: 999px; background: var(--track); overflow: hidden; }
.dash-row-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.dash-row-val { font-size: 12px; color: var(--muted); white-space: nowrap; text-align: right; }

.dash-chip { display: inline-flex; align-items: center; gap: 10px; padding: 6px 12px; border-radius: 999px; background: rgba(74, 144, 217, 0.16); border: 1px solid var(--accent); font-size: 13px; }
.dash-chip button { border: 0; background: transparent; color: var(--danger); cursor: pointer; font-weight: 700; }

@media (max-width: 720px) { .dash-two { grid-template-columns: 1fr; } }

/* --- Tarjetas de convenio con velocimetro (gauge) --- */
.conv-gauge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.conv-gauge-card { display: grid; gap: 10px; padding: 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border-soft); cursor: pointer; transition: border-color .15s, transform .15s; }
.conv-gauge-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.conv-gauge-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(74,144,217,0.35) inset; }
.conv-gauge-card.alerta { border-color: rgba(229,72,77,0.5); }
.conv-gauge-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.conv-gauge-head strong { font-size: 14px; line-height: 1.2; }
.conv-gauge-card .gauge { width: 100%; max-width: 180px; height: auto; margin: 2px auto 0; display: block; }
.conv-gauge-card .gauge-val { font-size: 22px; font-weight: 800; fill: var(--text); }
.conv-gauge-lines { display: grid; gap: 4px; }
.conv-gauge-lines > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13px; }
.conv-gauge-lines span { color: var(--muted); }
.conv-gauge-lines strong { font-variant-numeric: tabular-nums; }
.conv-gauge-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.conv-gauge-actions .link-inline {
  background: rgba(74, 144, 217, 0.16) !important;
  color: #a9cdf1 !important;
  border: 0;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.conv-gauge-actions .link-inline:hover { background: rgba(74, 144, 217, 0.28) !important; }
.conv-gauge-detail { display: grid; gap: 8px; margin-top: 2px; padding-top: 8px; border-top: 1px solid var(--border-soft); }
.conv-sub-row { display: grid; gap: 2px; font-size: 12px; }
.conv-sub-row .sub-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 600; }
.conv-sub-row .sub-bot { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.conv-sub-row.sobregiro .sub-top, .conv-sub-row.sobregiro .sub-bot { color: var(--danger); }

/* ---------------------------------------------------------------- */
/* Analisis de items                                                */
/* ---------------------------------------------------------------- */

.items-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 4px 0 14px; }
.items-kpi { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--border-soft); border-radius: 10px; background: var(--surface); }
.items-kpi span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.items-kpi strong { font-size: clamp(18px, 2vw, 24px); font-variant-numeric: tabular-nums; }
.items-kpi small { font-size: 11px; color: var(--muted); }
.items-kpi.alerta { border-color: var(--danger); }
.items-kpi.alerta strong { color: var(--danger); }

.items-tabs { display: flex; gap: 6px; margin-bottom: 12px; border-bottom: 1px solid var(--border-soft); }
.items-tab { padding: 8px 14px; border: 0; border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; }
.items-tab:hover { color: var(--text); }
.items-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.items-pane-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.items-pane-head h3 { margin: 0; }
.items-sort, .items-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.items-nota { margin: -4px 0 12px; font-size: 12px; max-width: 78ch; }
.items-resumen { margin: 0 0 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.items-tree { display: grid; gap: 6px; }
.items-node { border: 1px solid var(--border-soft); border-radius: 8px; overflow: hidden; background: var(--surface); }
.items-node.abierto { border-color: var(--border); }
.items-node-head {
  display: grid; align-items: center; gap: 10px; width: 100%; padding: 10px 12px;
  grid-template-columns: 14px minmax(140px, 2fr) minmax(60px, 1fr) auto 52px 64px;
  border: 0; background: transparent; color: var(--text); text-align: left; cursor: pointer; font-size: 13px;
}
.items-node-head:hover { background: var(--border-soft); }
.items-caret { color: var(--muted); font-size: 11px; }
.items-node-name { font-weight: 600; display: grid; gap: 1px; min-width: 0; }
.items-sub { display: block; font-style: normal; font-size: 11px; font-weight: 400; color: var(--muted); }
.items-tag { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: var(--border-soft); color: var(--muted); font-style: normal; font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; }
.items-bar { height: 6px; border-radius: 999px; background: var(--border-soft); overflow: hidden; }
.items-bar i { display: block; height: 100%; background: var(--accent); }
.items-node-monto, .items-node-pct, .items-node-ot { font-variant-numeric: tabular-nums; text-align: right; }
.items-node-monto { font-weight: 600; }
.items-node-pct, .items-node-ot { color: var(--muted); font-size: 12px; }

.items-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.items-table th, .items-table td { padding: 7px 12px; border-top: 1px solid var(--border-soft); text-align: left; vertical-align: top; }
.items-table th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 600; }
.items-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.items-table tbody tr:hover { background: var(--border-soft); }
.items-table .items-periodico { opacity: 0.62; }
.items-var { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: var(--border-soft); color: var(--muted); font-size: 10px; }
.items-rep { margin-left: 4px; color: var(--danger); }

@media (max-width: 900px) {
  .items-node-head { grid-template-columns: 14px 1fr auto; }
  .items-bar, .items-node-pct { display: none; }
}
.items-table-scroll { overflow-x: auto; }
.items-folios { display: flex; flex-wrap: wrap; gap: 5px; }
.items-folio {
  display: inline-grid; gap: 0; padding: 2px 7px; border: 1px solid var(--border-soft);
  border-radius: 6px; background: var(--surface); font-variant-numeric: tabular-nums;
  font-size: 11.5px; line-height: 1.35; white-space: nowrap;
}
.items-folio em { font-style: normal; color: var(--muted); font-size: 10px; }

/* ---------------------------------------------------------------- */
/* Analisis de items - tablero con segmentadores                     */
/* ---------------------------------------------------------------- */

.items-descargas { display: flex; gap: 8px; flex-wrap: wrap; }

/* Segmentadores: una caja por dimension, opciones multiseleccionables */
.slicers { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-bottom: 12px; }
.slicer { border: 1px solid var(--border-soft); border-radius: 10px; background: var(--surface); overflow: hidden; }
.slicer.activo { border-color: var(--accent); }
.slicer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--border-soft);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
}
.slicer.activo .slicer-head { color: var(--text); }
.slicer-clear { border: 0; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; text-transform: none; letter-spacing: 0; padding: 2px 4px; }
.slicer-clear:hover { color: var(--accent); text-decoration: underline; }
.slicer-body { max-height: 190px; overflow-y: auto; padding: 4px; display: grid; gap: 2px; }

.slicer-item {
  display: grid; grid-template-columns: 15px 1fr auto; align-items: center; gap: 8px;
  width: 100%; padding: 6px 8px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text); text-align: left; font-size: 12.5px; cursor: pointer;
}
.slicer-item:hover { background: var(--border-soft); }
.slicer-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.slicer-check {
  width: 15px; height: 15px; border: 1.5px solid var(--border); border-radius: 4px; display: block;
}
.slicer-item.on .slicer-check { background: var(--accent); border-color: var(--accent); position: relative; }
.slicer-item.on .slicer-check::after {
  content: ''; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.slicer-item.on { font-weight: 600; }
.slicer-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slicer-monto { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.slicer-item.vacio { opacity: 0.4; }

.slicer-status {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; margin-bottom: 14px; border-radius: 8px;
  background: rgba(74, 144, 217, 0.12); border: 1px solid var(--border-soft); font-size: 12.5px;
}
.slicer-status button { border: 0; background: transparent; color: var(--accent); font-size: 12px; cursor: pointer; text-decoration: underline; padding: 0; }

/* Graficos */
.items-charts { display: grid; grid-template-columns: 1.35fr 1fr; gap: 14px; margin-bottom: 16px; align-items: start; }
.items-chart-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.items-back { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.items-back:hover { border-color: var(--accent); color: var(--accent); }

.bars { display: grid; gap: 3px; }
.bar-row {
  display: grid; grid-template-columns: minmax(120px, 1.5fr) minmax(70px, 2fr) auto 48px;
  align-items: center; gap: 10px; width: 100%; padding: 6px 8px;
  border: 0; border-radius: 6px; background: transparent; color: var(--text);
  text-align: left; font-size: 12.5px; cursor: default;
}
.bar-row.drillable, .bar-row[data-comuna] { cursor: pointer; }
.bar-row:hover { background: var(--border-soft); }
.bar-row.on { background: rgba(74, 144, 217, 0.16); font-weight: 600; }
.bar-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 9px; border-radius: 999px; background: var(--border-soft); overflow: hidden; }
.bar-track i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar-valor { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; white-space: nowrap; }
.bar-pct { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 11.5px; text-align: right; }

/* Territorio */
.terr-zonas { display: grid; gap: 12px; margin-bottom: 6px; }
.terr-zona { display: grid; gap: 4px; }
.terr-zona-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; font-variant-numeric: tabular-nums; }
.terr-zona-bar { height: 11px; border-radius: 999px; background: var(--border-soft); overflow: hidden; }
.terr-zona-bar i { display: block; height: 100%; border-radius: 999px; }
.terr-zona-bot { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.terr-sub { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
.terr-sub em { font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 11px; opacity: 0.75; }

@media (max-width: 1100px) {
  .items-charts { grid-template-columns: 1fr; }
}
.slicer-status.error { background: rgba(229, 72, 77, 0.12); border-color: var(--danger); color: var(--text); }
.slicer-status.error strong { color: var(--danger); }

/* Apertura de un concepto: donde se ejecuto */
.concepto-fila { cursor: pointer; }
.concepto-fila:hover { background: var(--border-soft); }
.concepto-fila.abierto { background: rgba(74, 144, 217, 0.14); font-weight: 600; }
.concepto-fila .items-caret { color: var(--muted); font-size: 10px; margin-right: 2px; }
.concepto-apertura > td { padding: 0 0 12px 0 !important; background: var(--surface); }
.apertura-resumen {
  margin: 8px 14px 10px; padding: 8px 12px; border-radius: 8px;
  background: var(--surface-2, var(--border-soft)); font-size: 12.5px; color: var(--muted);
}
.apertura-resumen strong { color: var(--text); font-variant-numeric: tabular-nums; }
.items-table.apertura { font-size: 12px; }
.items-table.apertura th { background: transparent; }
.items-table.apertura td { border-top: 1px solid var(--border-soft); }
.items-kpi.ojo { border-color: var(--warn, #f2b705); }
.items-kpi.ojo small { color: var(--warn, #f2b705); }
