:root {
  --navy: #12385f;
  --navy-2: #1c4d7c;
  --gold: #b8863b;
  --ink: #1f2733;
  --muted: #6a7684;
  --line: #e2e7ee;
  --bg: #eef1f6;
  --panel: #ffffff;
  --ok: #1f8a4c;
  --shadow: 0 1px 3px rgba(18, 56, 95, .08), 0 8px 24px rgba(18, 56, 95, .06);
  --radius: 12px;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  background: linear-gradient(120deg, var(--navy), var(--navy-2));
  color: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--gold); color: #fff;
  font-size: 24px; font-weight: 700; font-family: Georgia, serif;
}
.brand h1 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: .2px; }
.brand p { margin: 0; font-size: 11.5px; opacity: .8; }

.colegio-picker { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.colegio-picker label { font-size: 12px; opacity: .85; }
.colegio-picker select {
  min-width: 320px; padding: 8px 10px; border-radius: 8px; border: none;
  background: rgba(255,255,255,.96); color: var(--ink); font-size: 13px;
}
.colegio-info { font-size: 11.5px; opacity: .8; white-space: nowrap; }

/* ---------- franja corporativa superior ---------- */
.corp-strip {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 5px 20px; background: #0d2033; color: #cdd7e2;
  font-size: 12px; letter-spacing: .2px;
}
.corp-strip .corp-name { font-weight: 600; color: #e7eef6; }
.corp-strip .corp-right { display: flex; align-items: center; gap: 8px; }
.corp-strip .corp-sep { color: #5a6a7a; }
.corp-strip .corp-mail { color: var(--gold); text-decoration: none; }
.corp-strip .corp-mail:hover { text-decoration: underline; }
.corp-strip .corp-link {
  background: none; border: none; color: var(--gold); cursor: pointer;
  font: inherit; padding: 0; text-decoration: none;
}
.corp-strip .corp-link:hover { text-decoration: underline; }

/* aviso legal */
.aviso-body { overflow: auto; padding: 4px 22px 8px; font-size: 13px; line-height: 1.6; color: #33404f; }
.aviso-body p { margin: 10px 0; }
.aviso-body .aviso-final { font-style: italic; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }
.res-disclaimer { font-size: 11.5px; color: var(--muted); line-height: 1.5; margin: 12px 0 0; }
.res-disclaimer strong { color: var(--stop, #b0392b); }
.linklike { background: none; border: none; color: var(--navy2); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

/* ---------- layout ---------- */
.layout {
  flex: 1; display: grid;
  grid-template-columns: var(--sidebar-w, 340px) 6px 1fr;
  min-height: 0;
}

/* separador arrastrable entre el listado y el contenido */
.resizer {
  cursor: col-resize; background: var(--line);
  transition: background .15s; position: relative;
}
.resizer:hover, .resizer.dragging { background: var(--gold); }
.resizer::before {
  content: ""; position: absolute; top: 50%; left: 50%;
  width: 2px; height: 34px; transform: translate(-50%, -50%);
  background: var(--muted); border-radius: 2px; opacity: .5;
}
body.resizing { cursor: col-resize; user-select: none; }

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.search { padding: 14px; border-bottom: 1px solid var(--line); }
.search input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 13px; background: #f8fafc;
}
.search input:focus { outline: none; border-color: var(--navy-2); background:#fff; }

.tree { overflow: auto; padding: 8px 6px 20px; flex: 1; }

/* ---------- tree ---------- */
.tnode { user-select: none; }
.trow {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; border-radius: 7px; cursor: pointer; font-size: 13px;
  color: var(--ink);
}
.trow:hover { background: #f0f4f9; }
.trow.leaf { color: var(--navy); }
.trow.active { background: var(--navy); color: #fff; }
.trow.active .tabr { color: #e8d8b6; }
.tcaret { width: 14px; text-align: center; color: var(--muted); font-size: 10px; flex: none; transition: transform .12s; }
.tcaret.open { transform: rotate(90deg); }
.tabr { font-size: 11px; color: var(--gold); font-weight: 600; flex: none; }
.ttitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tchildren { margin-left: 14px; border-left: 1px dashed var(--line); padding-left: 4px; }
.tchildren.collapsed { display: none; }
.tdot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); flex: none; margin: 0 4px; }

/* ---------- content ---------- */
.content { overflow: auto; padding: 24px; min-height: 0; }
.hidden { display: none !important; }

.placeholder {
  height: 100%; display: grid; place-content: center; justify-items: center;
  text-align: center; color: var(--muted); gap: 6px;
}
.placeholder-mark {
  font-family: Georgia, serif; font-size: 64px; color: var(--line);
  width: 110px; height: 110px; border-radius: 50%; display: grid; place-items: center;
  border: 3px solid var(--line); margin-bottom: 8px;
}
.placeholder h2 { margin: 0; color: var(--ink); }
.placeholder p { max-width: 380px; margin: 0; }

/* ---------- aviso de vigencia ---------- */
.vigencia-banner {
  display: flex; align-items: center; gap: 12px;
  max-width: 1100px; margin: 0 auto 18px; padding: 12px 16px;
  border-radius: 10px; border: 1px solid var(--line); font-size: 13px;
}
.vigencia-banner .vig-icon {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; color: #fff;
}
.vigencia-banner .vig-text { flex: 1; }
.vigencia-banner .vig-text strong { display: block; }
.vigencia-banner .vig-btn { padding: 7px 12px; white-space: nowrap; }
.vig-warn { background: #fdf6ea; border-color: #ecd9b0; }
.vig-warn .vig-icon { background: var(--gold); }
.vig-stop { background: #fdecea; border-color: #f5c6c0; }
.vig-stop .vig-icon { background: #c0392b; }
.vig-ok { background: #eaf6ef; border-color: #b9e0c9; }
.vig-ok .vig-icon { background: var(--ok); }
.vig-info { background: #eef2f7; border-color: var(--line); }
.vig-info .vig-icon { background: var(--muted); }
.paso-aviso { color: var(--stop, #b0392b) !important; font-weight: 600; }
.paso-aviso::before { content: "⚠" !important; }
.src-note { font-size: 12px; color: var(--muted); word-break: break-word; }

.concepto { max-width: 1100px; margin: 0 auto; }
.concepto-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 20px;
  margin-bottom: 18px;
}
.pill {
  display: inline-block; background: var(--gold); color: #fff;
  font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; margin-bottom: 8px;
}
.concepto-head h2 { margin: 0; font-size: 20px; color: var(--navy); line-height: 1.25; }
.formula {
  font-family: "Consolas", "SF Mono", monospace; font-size: 12.5px;
  background: #0f2540; color: #dfe8f2; padding: 8px 12px; border-radius: 8px;
  white-space: nowrap;
}

.concepto-body { display: grid; grid-template-columns: 1.05fr 1fr; gap: 24px; align-items: start; }

/* ---------- form ---------- */
.col-form form {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.params { display: grid; gap: 12px; margin-bottom: 6px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.field input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 15px; background: #f8fafc;
}
.field input:focus { outline: none; border-color: var(--navy-2); background: #fff; }

.excepciones { display: grid; gap: 8px; margin: 14px 0; }
.excepciones:empty { margin: 0; }
.exc {
  display: flex; gap: 9px; align-items: flex-start; font-size: 13px;
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
  background: #fbfcfe;
}
.exc:hover { border-color: var(--navy-2); }
.exc input { margin-top: 2px; }
.exc .exc-tag {
  font-size: 10px; font-weight: 700; color: #fff; background: var(--muted);
  border-radius: 4px; padding: 1px 5px; margin-left: auto; flex: none;
}
.exc .exc-tag.plus { background: var(--ok); }
.exc .exc-tag.minus { background: #c0392b; }

.switch { display: flex; align-items: center; gap: 8px; margin: 12px 0; font-size: 13px; color: var(--ink); }
/* el atributo hidden debe ocultar el conmutador pese a display:flex (p. ej. la casilla de IPC) */
.switch[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  border: none; border-radius: 8px; padding: 10px 16px; font-size: 13.5px;
  font-weight: 600; cursor: pointer; transition: filter .12s, background .12s;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-outline { background: #fff; color: var(--navy); border: 1.5px solid var(--navy); }
.btn-outline:hover { background: #f0f4f9; }
.btn-ghost { background: rgba(255,255,255,.14); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.24); }
.btn-block { width: 100%; margin-top: 8px; }

.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px;
  padding: 0 5px; border-radius: 999px; background: var(--gold); color: #fff;
  font-size: 11px; font-weight: 700; margin-left: 4px;
}

/* ---------- resultado ---------- */
.resultado {
  margin-top: 16px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.res-total {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-bottom: 12px; border-bottom: 2px solid var(--line); margin-bottom: 12px;
}
.res-total span { color: var(--muted); font-size: 13px; }
.res-total strong { font-size: 28px; color: var(--navy); }
.res-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.res-table td { padding: 6px 0; }
.res-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.res-table tr + tr td { border-top: 1px solid var(--line); }
.pasos { list-style: none; margin: 12px 0 4px; padding: 0; }
.pasos li {
  font-size: 12px; color: var(--muted); padding: 4px 0 4px 16px; position: relative;
}
.pasos li::before { content: "›"; position: absolute; left: 4px; color: var(--gold); }
.error {
  margin-top: 14px; padding: 12px; border-radius: 8px; font-size: 13px;
  background: #fdecea; color: #b02a1e; border: 1px solid #f5c6c0;
}

/* ---------- criterio text ---------- */
.col-text h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.criterio-text {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); max-height: 62vh; overflow: auto;
  font-size: 13px; line-height: 1.55; color: #33404f;
}
.criterio-text table { border-collapse: collapse; margin: 8px 0; font-size: 12px; width: 100%; }
.criterio-text td, .criterio-text th { border: 1px solid var(--line); padding: 4px 8px; }
.criterio-text p { margin: 6px 0; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,30,50,.5); display: grid; place-items: center; z-index: 20; }
.modal-card {
  width: min(720px, 92vw); max-height: 86vh; background: #fff; border-radius: 14px;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-head, .modal-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-foot { border-bottom: none; border-top: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; color: var(--navy); }
.icon-btn { border: none; background: none; font-size: 16px; cursor: pointer; color: var(--muted); }
.minuta-body { overflow: auto; padding: 8px 20px; }
.minuta-item {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.minuta-item .mi-titulo { font-size: 13.5px; }
.minuta-item .mi-sub { font-size: 11.5px; color: var(--muted); }
.minuta-item .mi-imp { font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; white-space: nowrap; }
.minuta-item .mi-del { border: none; background: none; color: #c0392b; cursor: pointer; font-size: 12px; }
.minuta-total strong { color: var(--navy); font-size: 18px; }
.modal-actions { display: flex; gap: 10px; }
.empty-minuta { text-align: center; color: var(--muted); padding: 30px 0; }

/* ---------- vista de impresión de la minuta ---------- */
.print-area { position: fixed; inset: 0; background: #fff; z-index: 200; overflow: auto; }
.print-bar {
  position: sticky; top: 0; display: flex; align-items: center; gap: 12px;
  justify-content: flex-end; padding: 12px 22px; background: #f4f6f9;
  border-bottom: 1px solid var(--line);
}
.print-bar .print-hint { margin-right: auto; font-size: 12px; color: var(--muted); }
.print-bar .btn-ghost { background: #e5eaf0; color: var(--ink); }
.print-content { max-width: 820px; margin: 0 auto; padding: 34px; color: #1f2733; }
.print-content h1 { color: var(--navy); font-size: 20px; border-bottom: 3px solid var(--gold); padding-bottom: 8px; }
.print-content .p-sub { color: var(--muted); font-size: 12px; margin-bottom: 24px; }
.print-content table { width: 100%; border-collapse: collapse; font-size: 13px; }
.print-content th, .print-content td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.print-content th { background: var(--navy); color: #fff; }
.print-content td.r, .print-content th.r { text-align: right; font-variant-numeric: tabular-nums; }
.print-content tfoot td { font-weight: 700; border-top: 2px solid var(--navy); }
.print-content .p-aviso { margin-top: 26px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 10px; color: var(--muted); line-height: 1.5; text-align: justify; }
@media print {
  body > *:not(#print-area) { display: none !important; }
  .print-area { position: static; overflow: visible; }
  .print-bar { display: none !important; }
  .print-content { max-width: none; padding: 0; }
  .print-content th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- banner publicitario HAL9000 ---------- */
.hal-banner {
  display: flex; align-items: center; gap: 30px;
  padding: 26px 30px; text-decoration: none; color: #1f2733;
  background:
    radial-gradient(120% 180% at 12% 0%, rgba(20,125,116,.16), transparent 60%),
    linear-gradient(100deg, #f6faf9 0%, #eaf4f1 55%, #dcefe9 130%);
  border-top: 3px solid var(--gold);
  box-shadow: 0 -6px 20px rgba(18,56,95,.10);
}
.hal-banner .hal-logo {
  height: 92px; width: auto; flex: none;
  filter: drop-shadow(0 1px 3px rgba(18,56,95,.18));
}
.hal-banner .hal-text { display: flex; flex-direction: column; gap: 5px; line-height: 1.4; }
.hal-banner .hal-text strong { font-size: 20px; color: #0f2b45; }
.hal-banner .hal-text span { font-size: 14px; color: #43555f; max-width: 720px; }
.hal-banner .hal-text b { color: #147d74; }
.hal-cta {
  margin-left: auto; flex: none; white-space: nowrap;
  background: #147d74; color: #fff; font-weight: 700; font-size: 15px;
  padding: 13px 22px; border-radius: 10px; transition: transform .12s, filter .12s;
  box-shadow: 0 2px 8px rgba(20,125,116,.35);
}
.hal-banner:hover .hal-cta { filter: brightness(1.06); transform: translateY(-1px); }
@media (max-width: 820px) {
  .hal-banner .hal-text span { display: none; }
}
