@import url("https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:wght@600;700;800&family=Public+Sans:wght@400;500;600;700&display=swap");

/* Design tokens. Brand: SENA's green and navy. Navy carries structure and
   the one hero moment; green means progress; amber and red are reserved for
   attention; slate is "not yet". Old variable names (--accent, --success…)
   are kept and remapped so every page recolors together. */
:root {
  color-scheme: light;
  --navy: #00304d;
  --navy-hover: #0b4a6f;
  --navy-tint: #e5edf2;
  --green: #39a900;
  --green-deep: #2c7a00;
  --green-tint: #eaf6e0;
  --slate: #64748b;
  --amber: #c77700;
  --amber-deep: #955700;
  --amber-tint: #fff3dc;
  --red: #c2352b;
  --red-tint: #fdecea;

  --bg: #f2f5f3;
  --bg-alt: #f7faf8;
  --surface: #ffffff;
  --line: #dce3de;
  --track: #e4eae6;
  --text: #1d2b26;
  --muted: #5d6b65;

  --border: var(--line);
  --accent: var(--navy);
  --success: var(--green-deep);
  --success-bg: var(--green-tint);
  --pending: var(--track);
  --warning: var(--amber);
  --warning-bg: var(--amber-tint);
  --info-bg: var(--navy-tint);

  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bricolage Grotesque", "Public Sans", system-ui, sans-serif;
  --shadow-card: 0 1px 2px rgba(0, 48, 77, 0.05), 0 4px 14px rgba(0, 48, 77, 0.05);
}

* {
  box-sizing: border-box;
}

/* Author `display` rules (e.g. `form div { display: flex }`) would otherwise
   override the browser's own `[hidden]` rule and keep hidden elements shown. */
[hidden] {
  display: none !important;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2.5rem;
  line-height: 1.5;
}

a {
  color: var(--green-deep);
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 3px solid rgba(57, 169, 0, 0.5);
  outline-offset: 2px;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  color: var(--navy);
  letter-spacing: -0.01em;
}

h1 {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  margin: 0;
}

/* --- Navigation --------------------------------------------------------- */

body > nav[aria-label="Navegación principal"] {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.3rem;
  margin-bottom: 1.5rem;
  background: var(--navy);
  border-radius: 12px;
}

body > nav[aria-label="Navegación principal"] a {
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.45rem 0.95rem;
  border-radius: 8px;
  border-bottom: 2px solid transparent;
}

body > nav[aria-label="Navegación principal"] a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

body > nav[aria-label="Navegación principal"] a[aria-current="page"] {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-bottom-color: var(--green);
}

/* --- Page header and tabs ------------------------------------------------ */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-bottom: 1.25rem;
}

.page-header p {
  margin: 0.3rem 0 0;
}

.page-header-meta {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

.page-header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.header-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.tabs {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 0.6rem 0.1rem;
  margin-bottom: -1px;
  font-weight: 600;
}

.tab-button:hover {
  filter: none;
  color: var(--navy);
}

.tab-button.tab-active {
  color: var(--navy);
  border-bottom-color: var(--green);
}

/* --- Surfaces ------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h2,
.card h3 {
  margin-top: 0;
}

.card h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.card > h2 + .muted,
.card > .operativo-table-header .muted {
  margin-top: 0;
}

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

/* --- Hero: the one bold moment -------------------------------------------- */

.hero {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 1.6fr;
  gap: 2rem 2.5rem;
  align-items: center;
  margin-bottom: 1.5rem;
  padding: 1.75rem 2rem;
  color: #fff;
  background: var(--navy);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0, 48, 77, 0.22);
}

.hero h2 {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

.hero .muted {
  margin: 0;
  color: rgba(255, 255, 255, 0.74);
}

.hero-main {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.hero-figure {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.hero-figure strong {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
}

.radial-progress {
  --pct: 0;
  flex: none;
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: conic-gradient(var(--green) calc(var(--pct) * 1%), rgba(255, 255, 255, 0.16) 0);
}

.radial-progress-inner {
  display: grid;
  place-items: center;
  width: 102px;
  height: 102px;
  border-radius: 50%;
  background: var(--navy);
}

.radial-progress-inner strong {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1;
}

.radial-progress-inner small {
  margin-left: 1px;
  font-size: 0.9rem;
  font-weight: 600;
}

/* State colours are shared by the segmented bar and the tiles through --rail. */
.state-closed { --rail: #9dbad0; }
.state-active { --rail: var(--green); }
.state-pending { --rail: #94a3b0; }
.state-warn { --rail: #f2b441; }

.state-bar {
  display: flex;
  gap: 2px;
  height: 12px;
  margin-bottom: 1rem;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}

.state-bar-seg {
  height: 100%;
  background: var(--rail);
}

.state-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.state-tiles-two {
  grid-template-columns: repeat(2, 1fr);
}

.state-tile {
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.08);
  border-left: 4px solid var(--rail);
  border-radius: 10px;
}

.state-tile p {
  margin: 0;
}

.state-tile-label {
  font-size: 0.9rem;
  font-weight: 600;
}

.state-tile-count {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.15;
}

.state-tile-hint {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.74);
}

.ranking-note {
  margin: 0 0 0.75rem;
  padding-left: 0.6rem;
  border-left: 2px solid var(--green);
  color: var(--muted);
  font-size: 0.85rem;
}

/* Percentage is the headline figure; counts ("N de M respuestas") are secondary. */
.stat-pct {
  color: var(--navy);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.2;
}

.stat-count {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.hero .stat-count {
  color: rgba(255, 255, 255, 0.78);
}

/* Group colours: same fixed palette as pdf_report.py (_GROUP_PALETTE), by group order. */
.group-0 { --group: #2f80ed; --group-text: #fff; }
.group-1 { --group: #8b5cf6; --group-text: #fff; }
.group-2 { --group: #f2a900; --group-text: var(--navy); }
.group-3 { --group: #14b8a6; --group-text: var(--navy); }
.group-4 { --group: #ec4899; --group-text: #fff; }

.hero-operativo {
  grid-template-columns: minmax(360px, 0.9fr) 1.7fr;
}

.hero-operativo .hero-figure {
  white-space: nowrap;
}

.hero-states-title {
  margin: 0 0 0.75rem;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: left;
}

.hero-operativo .state-tile {
  display: flex;
  flex-direction: column;
}

.group-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: auto;
  padding-top: 0.6rem;
}

.group-badge {
  padding: 0.1rem 0.55rem;
  color: #fff; /* outline pill on the navy hero: navy group text would vanish */
  background: transparent;
  border: 1px solid var(--group);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

/* --- Per-group progress cards --------------------------------------------- */

.group-cards-section h2 {
  margin: 0 0 0.75rem;
}

.group-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.group-card {
  padding: 1rem 1.15rem;
  background: var(--surface);
  border: 1.5px solid var(--group);
  border-radius: 14px;
}

.group-card h3 {
  margin: 0 0 0.25rem;
  color: var(--group);
  font-size: 1.05rem;
}

.group-card-progress {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.6rem;
  margin: 0 0 0.75rem;
}

.group-card-progress .stat-pct {
  font-size: 2rem;
  line-height: 1.1;
}

.group-card-dates {
  margin: -0.4rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.group-card.on-dark .group-card-dates {
  color: rgba(255, 255, 255, 0.78);
}

.group-card-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.group-card-tiles div {
  display: flex;
  flex-direction: column;
  padding: 0.45rem 0.6rem;
  background: color-mix(in srgb, var(--group) 12%, white);
  border-radius: 8px;
}

.group-card-tiles span {
  color: var(--muted);
  font-size: 0.72rem;
}

.group-card-tiles strong {
  color: var(--navy);
  font-size: 1.15rem;
}

/* Cards drawn on the navy hero (single-regional view). */
.group-cards-hero {
  margin-bottom: 0;
}

.group-card.on-dark {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.group-card.on-dark.is-selected {
  border-color: rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.14);
}

.group-card.on-dark h3 {
  display: inline-block;
  padding: 0.1rem 0.65rem;
  color: #fff;
  background: transparent;
  border: 1px solid var(--group);
  border-radius: 999px;
  font-size: 0.85rem;
}

.group-card.on-dark .stat-pct {
  color: #fff;
  font-size: 1.6rem;
}

.group-card.on-dark .group-card-progress {
  flex-wrap: nowrap;
  white-space: nowrap;
}

.group-card.on-dark .stat-count {
  font-size: 0.72rem;
}

.group-card.on-dark .group-card-tiles div {
  background: rgba(255, 255, 255, 0.1);
}

.group-card.on-dark .group-card-tiles div {
  padding: 0.4rem 0.4rem;
}

.group-card.on-dark .group-card-tiles span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.66rem;
  white-space: nowrap;
}

.group-card.on-dark .group-card-tiles strong {
  color: #fff;
}

@media (max-width: 900px) {
  .group-cards {
    grid-template-columns: 1fr;
  }
}

/* --- Form table with pace-vs-progress bars ---------------------------------- */

.operativo-table-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.operativo-table-header .muted {
  margin: 0.2rem 0 0;
  max-width: 60ch;
}

.operativo-table-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.form-table td {
  padding: 0.85rem 0.6rem;
  vertical-align: middle;
}

.num {
  text-align: right !important;
  white-space: nowrap;
}

th.num {
  white-space: normal;
  min-width: 6.5rem;
}

.missing-cell {
  color: var(--text);
  font-weight: 400;
}

.form-title {
  font-weight: 600;
}

.form-note {
  margin: 0.15rem 0 0 1.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.form-row-cerrado .form-title {
  color: var(--muted);
}

.pace-cell {
  min-width: 260px;
}

.pace-bar {
  position: relative;
  height: 10px;
  background: var(--track);
  border-radius: 999px;
}

.pace-fill,
.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--green);
  animation: grow-in 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes grow-in {
  from {
    width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pace-fill,
  .progress-bar-fill {
    animation: none;
  }
}

.pace-behind .pace-fill {
  background: var(--amber);
}

.form-row-cerrado .pace-fill {
  background: #6e8fa6;
}

.form-row-sin_iniciar .pace-fill {
  background: var(--slate);
}

.pace-marker {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: var(--navy);
  border-radius: 2px;
  transform: translateX(-1px);
}

.pace-text {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.6rem;
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
}


.pace-flag {
  font-weight: 600;
}

.pace-flag-ok {
  color: var(--green-deep);
}

.pace-flag-behind {
  color: var(--amber-deep);
}

.form-detail-row td {
  padding: 1rem 1.25rem;
  background: var(--bg-alt);
}

.form-detail-caption {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
}

/* --- Layout helpers -------------------------------------------------------- */

.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.two-col-grid .card {
  margin-bottom: 0;
}

.two-col-grid .card > .muted {
  margin: 0.2rem 0 1rem;
}

/* Fixed to the height the missing-dependencies card has by default (all its
   per-form accordions collapsed) — deliberately NOT stretched to match it,
   so expanding those accordions never resizes this chart. */
.chart-wrap-fixed {
  height: 320px;
}

.chart-wrap {
  position: relative;
  width: 100%;
}

@media (max-width: 900px) {
  .two-col-grid,
  .hero {
    grid-template-columns: 1fr;
  }

  .state-tiles {
    grid-template-columns: 1fr;
  }
}

/* --- Regional tab ---------------------------------------------------------------- */

.regional-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 1.25rem;
  padding: 0.9rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.regional-picker label {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--navy);
}

.regional-picker select {
  min-width: 260px;
  font-weight: 600;
}

.regional-picker p {
  margin: 0;
  font-size: 0.85rem;
}

.missing-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.missing-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  color: #0a72b5;
  background: #e3f1fb;
  border-radius: 14px;
}

.missing-title {
  flex: 1 1 260px;
}

.missing-title h2,
.missing-title p {
  margin: 0;
}

.missing-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.missing-controls input,
.missing-controls select {
  min-width: 220px;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font: inherit;
  font-size: 0.9rem;
}

.missing-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.1rem;
  margin-top: 1.25rem;
  align-items: start;
}

.missing-card {
  --tint: #eaf3fb;
  --ink: #0a72b5;
  padding: 0.7rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.missing-tint-1 { --tint: var(--green-tint); --ink: var(--green-deep); }
.missing-tint-2 { --tint: #f1edfc; --ink: #6a45d6; }
.missing-tint-3 { --tint: #e6f7ef; --ink: #14895a; }

.missing-card-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem;
  background: var(--tint);
  border-radius: 12px;
}

.missing-card-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  color: var(--ink);
  background: var(--surface);
  border-radius: 12px;
}

.missing-card-head > div {
  flex: 1;
  min-width: 0;
}

.missing-card-head h3,
.missing-card-head p {
  margin: 0;
}

.missing-card-head h3 {
  font-size: 1.05rem;
}

.missing-count {
  flex: none;
  padding: 0.3rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #c2570c;
  background: #ffe9d6;
  border-radius: 999px;
}

.missing-count-high {
  color: var(--red);
  background: var(--red-tint);
}

.missing-list {
  margin: 0.6rem 0 0;
  padding: 0;
  list-style: none;
}

.missing-list li {
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  color: var(--navy);
  border-bottom: 1px solid var(--track);
}

.missing-list li:last-child {
  border-bottom: 0;
}

.missing-list li.is-filtered,
.missing-card.is-filtered {
  display: none;
}

.missing-empty {
  margin: 1rem 0 0;
}

.missing-groups[hidden],
.missing-card[hidden] {
  display: none;
}

@media (max-width: 900px) {
  .missing-groups {
    grid-template-columns: 1fr;
  }
}

.all-clear {
  margin: 1rem 0 0;
  padding: 0.9rem 1rem;
  font-weight: 600;
  color: var(--green-deep);
  background: var(--green-tint);
  border-radius: 10px;
}

/* --- Gestión / detail view -------------------------------------------------------- */

.stat-line {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 160px;
}

.stat-card {
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
}

.stat-card-value {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
}

.stat-card-pct {
  font-weight: 800;
  color: var(--green-deep);
}

.stat-card-meta {
  margin-bottom: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.progress-bar {
  position: relative;
  width: 100%;
  height: 8px;
  overflow: hidden;
  background: var(--track);
  border-radius: 999px;
}

.progress-bar-lg {
  height: 12px;
  margin: 0.75rem 0;
}

/* --- Forms, buttons, tables --------------------------------------------------------- */

form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem 1.25rem;
  align-items: end;
  padding: 1.1rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

form div {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
  padding: 0.5rem 0.7rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid #c5d0c9;
  border-radius: 8px;
}

button {
  color: #fff;
  background: var(--navy);
  border-color: var(--navy);
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  background: var(--navy-hover);
  border-color: var(--navy-hover);
}

.btn-secondary {
  color: var(--navy);
  background: var(--surface);
  border-color: var(--navy);
  white-space: nowrap;
}

.btn-secondary:hover {
  color: var(--navy);
  background: var(--navy-tint);
}

/* The <a> variant has to look exactly like the <button>: same box model,
   font and colours, and none of the default link styling. */
a.btn-secondary {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  padding: 0.5rem 0.7rem;
  font: inherit;
  font-weight: 600;
  line-height: normal;
  border: 1px solid var(--navy);
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
}

table {
  width: 100%;
  margin-top: 1rem;
  border-collapse: collapse;
}

caption {
  margin-bottom: 0.5rem;
  color: var(--muted);
  text-align: left;
}

th,
td {
  padding: 0.55rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

tbody tr:hover {
  background: var(--bg-alt);
}

.form-detail-row:hover {
  background: none;
}

[role="alert"] {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  color: #a02a21;
  background: var(--red-tint);
  border: 1px solid #f3b5af;
  border-radius: 10px;
}

[role="status"] {
  color: var(--muted);
}

nav[aria-label="Paginación"] {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* --- Badges --------------------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
}

.badge-complete {
  color: var(--green-deep);
  background: var(--green-tint);
  border: 1px solid #bfe3a6;
}

.badge-pending {
  color: var(--muted);
  background: var(--bg-alt);
  border: 1px solid var(--line);
}

.badge-vencido {
  color: #a02a21;
  background: var(--red-tint);
  border: 1px solid #f3b5af;
}

.badge-por-vencer {
  color: var(--amber-deep);
  background: var(--amber-tint);
  border: 1px solid #f2d08a;
}

.badge-info {
  color: var(--navy);
  background: var(--navy-tint);
  border: 1px solid #bcd0dc;
}

/* --- Missing-dependencies tree ---------------------------------------------------------- */

.tree-form {
  margin-bottom: 0.6rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.tree-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
}

.tree-toggle:hover {
  background: none;
}

.tree-form-title {
  flex: 1;
}

.tree-caret {
  display: inline-block;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.tree-toggle[aria-expanded="true"] .tree-caret {
  transform: rotate(90deg);
}

.tree-body {
  margin-top: 0.6rem;
  padding-left: 0.5rem;
}

.tree-regional {
  margin: 0.4rem 0;
  padding-left: 0.75rem;
  border-left: 2px solid var(--green);
}

.tree-regional .tree-toggle {
  font-weight: 600;
}

.tree-units {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.4rem 0 0.4rem 0.75rem;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
}

.tree-units li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- Management table (Gestión) ------------------------------------------------------------ */

.cierre-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.85rem;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

/* --- Custom-scope unit picker (create/edit form) ------------------------------------------------- */

.scope-list {
  max-height: 320px;
  padding: 0.5rem 0.75rem;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.scope-list fieldset {
  margin: 0 0 0.75rem;
  padding: 0;
  border: none;
}

.scope-list legend {
  margin-bottom: 0.25rem;
  padding: 0;
  font-weight: 700;
}

.scope-list ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.scope-list label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text);
}

.scope-list input[type="checkbox"] {
  padding: 0;
}

.danger-zone {
  border-color: #f3b5af;
}

.danger-zone h2 {
  color: #a02a21;
}

.btn-danger {
  background: var(--red);
  border-color: var(--red);
}

.btn-danger:hover {
  background: #a02a21;
  border-color: #a02a21;
}

/* --- Reports: PDF (browser print) and image export ---------------------------------------------------- */

@page {
  size: A4 landscape;
  margin: 10mm;
}

@media print {
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .no-print {
    display: none !important;
  }

  body {
    max-width: none;
    padding: 0;
    background: #fff;
  }

  .card {
    box-shadow: none;
    break-inside: avoid;
  }

  .hero {
    box-shadow: none;
    break-inside: avoid;
  }

  .form-detail-row {
    break-inside: avoid;
  }
}

.hero-operativo .hero-figure {
  font-size: 0.95rem;
  line-height: 1.35;
}


/* --- Gestión: "Reconciliar todo" quick action ------------------------------ */

.reconcile-all-form {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
}

.reconcile-all-form button[disabled] {
  opacity: 0.7;
  cursor: progress;
}

.reconcile-all-hint {
  margin: 0;
  font-size: 0.8rem;
}

.status-banner {
  margin: 0 0 1.25rem;
  padding: 0.85rem 1.1rem;
  color: var(--navy);
  background: var(--green-tint);
  border: 1px solid var(--green);
  border-radius: 12px;
}

.status-banner p,
.status-banner ul {
  margin: 0.35rem 0 0;
}

@media (max-width: 700px) {
  .page-header:has(.reconcile-all-form) {
    flex-direction: column;
    align-items: stretch;
  }

  .reconcile-all-form {
    align-items: stretch;
  }
}

/* --- Responsive ------------------------------------------------------------ */

/* Wide tables scroll inside their own box instead of stretching the page. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.hero > *,
.hero-main > * {
  min-width: 0;
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    padding: 1.25rem 1rem;
  }

  .hero-main {
    flex-wrap: wrap;
  }
}

@media (max-width: 700px) {
  body {
    padding: 0.75rem 0.75rem 2rem;
  }

  h1 {
    font-size: 1.6rem;
  }

  .card {
    padding: 1rem;
  }

  .tabs {
    gap: 1rem;
  }

  .page-header-meta {
    white-space: normal;
  }

  .header-buttons {
    justify-content: flex-start;
  }
}

@media (max-width: 700px) {
  .missing-controls,
  .missing-controls input,
  .missing-controls select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .missing-card-head h3 {
    overflow-wrap: anywhere;
  }
}

/* Overview table: keep dates and scope badges on one line so the extra column doesn't squeeze the rest. */
.cierre-cell > span:first-child,
.badge {
  white-space: nowrap;
}

#remove-scope,
#custom-scope,
.form-actions {
  grid-column: 1 / -1;
}

#remove-scope {
  min-width: 0;
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

#remove-scope legend {
  padding: 0 0.5rem;
  font-weight: 700;
}

#remove-scope-search {
  width: 100%;
  margin-bottom: 0.5rem;
}

.remove-list {
  max-height: 480px;
}

.remove-list ul {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0 1.5rem;
}

.remove-list li[hidden] {
  display: none;
}

.remove-list label {
  align-items: flex-start;
  padding: 0.25rem 0;
}

.remove-list input[type="checkbox"] {
  flex: none;
  margin-top: 0.2rem;
}

.form-actions {
  align-items: flex-start;
}

.header-actions {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem;
}
