:root {
  --navy: #0b1628;
  --side: #0f1c30;
  --blue: #1172ff;
  --cyan: #13c7f4;
  --bg: #eef3f9;
  --text: #10223c;
  --muted: #6b7b92;
  --line: #e2eaf4;
  --white: #ffffff;
  --ok: #12a97b;
  --danger: #e25555;
  --warn: #e6a23c;
  --side-w: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Outfit, system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* —— Login (no shell) —— */
.login-body {
  min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem;
  background:
    radial-gradient(1000px 480px at 8% -8%, rgba(17,114,255,.14), transparent 55%),
    radial-gradient(800px 420px at 95% 0%, rgba(19,199,244,.12), transparent 50%),
    linear-gradient(160deg, #e8f2ff, #f3f8ff 40%, #eef5ff);
}
.login-card {
  width: min(400px, 100%); text-align: center;
  background: rgba(255,255,255,.9); border: 1px solid var(--line);
  border-radius: 18px; padding: 2rem 1.5rem 1.75rem;
  box-shadow: 0 18px 50px rgba(7,22,46,.08);
}
.login-logo { margin-bottom: .75rem; filter: drop-shadow(0 10px 22px rgba(17,114,255,.25)); }
.brand { font-weight: 700; letter-spacing: .18em; font-size: 1.4rem; color: var(--navy); }
.brand span { color: var(--blue); }
.login-card h1 { margin: .85rem 0 .35rem; font-size: 1.35rem; color: var(--navy); }
.stack { display: grid; gap: .9rem; text-align: left; margin-top: 1.25rem; }
.stack label { display: grid; gap: .35rem; font-weight: 600; font-size: .9rem; }
.stack input {
  border: 1px solid var(--line); border-radius: 10px; padding: .7rem .85rem; font: inherit; font-weight: 400;
}

/* —— App shell —— */
.app-shell { display: flex; min-height: 100dvh; background: var(--bg); }

.sidebar {
  width: var(--side-w); flex-shrink: 0;
  background: linear-gradient(180deg, #0b1628 0%, #101e34 100%);
  color: #fff; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100dvh; overflow: auto;
}
.side-top {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.side-top .side-brand { border-bottom: 0; flex: 1; }
.nav-close {
  display: none; width: 42px; height: 42px; margin-right: .4rem;
  border: 0; background: transparent; color: #fff; font-size: 1.6rem; cursor: pointer;
}
.nav-scrim {
  display: none; position: fixed; inset: 0; background: rgba(7,22,46,.45);
  z-index: 40; border: 0; padding: 0; cursor: pointer;
}
.nav-toggle {
  display: none; width: 42px; height: 42px; flex-shrink: 0;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  flex-direction: column; justify-content: center; align-items: center; gap: 5px;
  cursor: pointer; padding: 0;
}
.nav-toggle span {
  display: block; width: 18px; height: 2px; background: var(--navy); border-radius: 2px;
}
.top-brand-mobile {
  display: none; font-weight: 700; letter-spacing: .1em; color: var(--navy); text-decoration: none;
}
.top-brand-mobile span { color: var(--blue); }

.side-brand {
  display: flex; align-items: center; gap: .65rem;
  padding: 1.1rem 1rem; color: #fff; font-weight: 700; letter-spacing: .12em;
  text-decoration: none;
}
.side-brand span span { color: var(--cyan); }
.side-brand:hover { text-decoration: none; color: #fff; }

.side-label {
  padding: .85rem 1rem .25rem;
  font-size: .68rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: rgba(255,255,255,.35);
}
.side-group summary .dot {
  width: .55rem; height: .55rem; border-radius: 50%;
  background: var(--blue); flex-shrink: 0;
}
.dept-val summary .dot { background: #3b82f6; }
.dept-riesgo summary .dot { background: #22c55e; }
.dept-teso summary .dot { background: #a855f7; }
.dept-cob summary .dot { background: #ef4444; }
.dept-atc summary .dot { background: #f59e0b; }
.dept-rep summary .dot { background: #64748b; }

.side-nav { padding: .75rem .55rem 1.5rem; display: flex; flex-direction: column; gap: .15rem; }
.side-nav > a, .side-group > a, .side-group summary {
  display: flex; align-items: center; gap: .55rem;
  padding: .55rem .7rem; border-radius: 10px;
  color: rgba(255,255,255,.72); font-size: .9rem; font-weight: 500;
  text-decoration: none; cursor: pointer;
}
.side-nav > a:hover, .side-group > a:hover, .side-group summary:hover {
  background: rgba(255,255,255,.06); color: #fff; text-decoration: none;
}
.side-nav > a.active, .side-group > a.active {
  background: var(--blue); color: #fff; font-weight: 600;
}
.side-nav .ico { width: 1.1rem; text-align: center; opacity: .9; font-size: .85rem; }
.badge-n {
  margin-left: auto; min-width: 1.25rem; height: 1.25rem; padding: 0 .35rem;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: .7rem; font-weight: 700; display: inline-grid; place-items: center;
}

.side-group { border: 0; }
.side-group summary {
  list-style: none; user-select: none;
}
.side-group summary::-webkit-details-marker { display: none; }
.side-group summary::after { content: "▾"; margin-left: auto; opacity: .5; font-size: .75rem; }
.side-group:not([open]) summary::after { content: "▸"; }
.side-group > a { padding-left: 2.2rem; font-size: .85rem; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .85rem 1.25rem; background: var(--white);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.top-search { flex: 1; min-width: 220px; }
.top-search input {
  width: 100%; border: 1px solid var(--line); border-radius: 999px;
  padding: .65rem 1rem; font: inherit; background: #f7fafc;
}
.top-meta { display: flex; align-items: center; gap: .75rem; }
.chip {
  background: #f0f4f9; color: var(--muted); border-radius: 999px;
  padding: .4rem .75rem; font-size: .82rem; font-weight: 600; white-space: nowrap;
}
.bell { font-size: 1.1rem; opacity: .7; }
.who { display: flex; align-items: center; gap: .55rem; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--navy); color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: .9rem;
}
.who strong { display: block; font-size: .85rem; line-height: 1.1; }
.who small { color: var(--muted); font-size: .72rem; }
.logout { font-size: .8rem; font-weight: 600; margin-left: .25rem; }

.content { padding: 1.25rem 1.35rem 2.5rem; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.page-head h1, .dash-title { margin: 0 0 .25rem; color: var(--navy); font-size: 1.45rem; }
.muted { color: var(--muted); margin: 0; }

.kpi-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .75rem; margin-bottom: 1rem;
}
.kpi {
  background: var(--white); border: 1px solid var(--line); border-radius: 12px;
  padding: .9rem 1rem;
}
.kpi-l { display: block; color: var(--muted); font-size: .78rem; font-weight: 600; margin-bottom: .35rem; }
.kpi-n { display: block; font-size: 1.45rem; font-weight: 700; color: var(--navy); }
.kpi-s { display: block; margin-top: .25rem; font-size: .75rem; font-weight: 600; color: var(--ok); }

.dash-grid {
  display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: .85rem; margin-bottom: 1rem;
}
.panel {
  background: var(--white); border: 1px solid var(--line); border-radius: 14px;
  padding: 1rem 1.1rem; min-height: 180px;
}
.panel h2 { margin: 0 0 .75rem; font-size: .95rem; color: var(--navy); }
.panel-muted { color: var(--muted); font-size: .88rem; line-height: 1.45; }
.chart-fake {
  height: 120px; border-radius: 10px;
  background:
    linear-gradient(180deg, transparent 60%, rgba(17,114,255,.08) 60%),
    repeating-linear-gradient(90deg, transparent, transparent 28px, rgba(17,114,255,.08) 28px, rgba(17,114,255,.08) 29px);
  position: relative; overflow: hidden;
}
.chart-fake::after {
  content: ""; position: absolute; left: 8%; right: 8%; bottom: 28%; height: 2px;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  border-radius: 2px; box-shadow: 0 0 0 1px rgba(17,114,255,.15);
}
.donut {
  width: 110px; height: 110px; margin: .5rem auto;
  border-radius: 50%;
  background: conic-gradient(var(--ok) 0 72%, var(--danger) 72% 100%);
  mask: radial-gradient(circle 34px, transparent 98%, #000 100%);
  -webkit-mask: radial-gradient(circle 34px, transparent 98%, #000 100%);
}
.legend { display: flex; gap: 1rem; justify-content: center; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; margin-right: .3rem; }
.legend .ok { background: var(--ok); }
.legend .bad { background: var(--danger); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: #fff; color: var(--navy);
  border-radius: 10px; padding: .6rem 1rem; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: #b9d0ef; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }

.search-row { display: flex; gap: .6rem; margin: 1rem 0 1.25rem; align-items: center; flex-wrap: wrap; }
.search-row input,
.search-row select {
  flex: 1; min-width: 12rem; border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem;
  background: #fff; font: inherit; color: var(--navy); box-sizing: border-box;
}
.search-row select {
  appearance: none; -webkit-appearance: none; max-width: 16rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7b92' d='M1.4 1.4L6 6l4.6-4.6L12 2.8 6 8.8 0 2.8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .9rem center; padding-right: 2.2rem;
}

.table-wrap {
  overflow: auto; background: var(--white);
  border: 1px solid var(--line); border-radius: 14px;
}
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .85rem 1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
.empty { text-align: center; color: var(--muted); padding: 2rem !important; }
.row-actions { white-space: nowrap; display: flex; gap: .75rem; align-items: center; }
.linkish { background: none; border: 0; color: var(--blue); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.pill { display: inline-block; padding: .15rem .5rem; border-radius: 999px; background: #e8f1ff; color: var(--blue); font-size: .8rem; font-weight: 600; }
.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge.ok { background: #e6f7f1; color: var(--ok); }
.badge.off { background: #f3f4f6; color: var(--muted); }
.badge.warn { background: #fff4e5; color: #b86e00; }
.badge.bad { background: #fdeCEC; color: #b42318; }
.alert.bad { background: #fdeCEC; color: #b42318; border-color: #f3b4b0; }
.kv { display: grid; gap: .55rem; margin: 0; }
.kv > div { display: grid; grid-template-columns: 8.5rem 1fr; gap: .5rem; }
.kv dt { margin: 0; color: var(--muted); font-size: .85rem; }
.kv dd { margin: 0; font-weight: 600; }
.score-detail {
  margin: .85rem 0 0;
  padding: .75rem;
  background: #f6f8fc;
  border-radius: 10px;
  white-space: pre-wrap;
  font-size: .82rem;
  line-height: 1.4;
  max-height: 180px;
  overflow: auto;
}
.decision-form { display: grid; gap: .85rem; margin-top: .75rem; max-width: 36rem; }
.decision-form .field { display: grid; gap: .35rem; }
.decision-form label { font-weight: 600; font-size: .9rem; color: var(--navy); }
.decision-form input,
.decision-form select,
.decision-form textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .65rem .8rem;
  font: inherit;
  font-weight: 400;
  background: #fff;
  color: var(--navy);
  width: 100%;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
}
.decision-form select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7b92' d='M1.4 1.4L6 6l4.6-4.6L12 2.8 6 8.8 0 2.8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .9rem center;
  padding-right: 2.2rem;
}
.decision-form input:focus,
.decision-form select:focus,
.decision-form textarea:focus {
  outline: none;
  border-color: #8bb8f0;
  box-shadow: 0 0 0 3px rgba(17,114,255,.12);
}
.decision-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.panel-form {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.25rem 1.35rem;
  margin: .75rem 0 1.25rem;
  max-width: 52rem;
}
.panel-form .form-grid {
  border: 0;
  padding: 0;
  background: transparent;
  margin: 0;
}
.panel-form .form-grid label span {
  font-weight: 600;
  font-size: .9rem;
  color: var(--navy);
}
.panel-form .form-grid input,
.panel-form .form-grid select,
.panel-form .form-grid textarea {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .65rem .8rem;
  font: inherit;
  font-weight: 400;
  background: #fff;
  color: var(--navy);
  width: 100%;
  box-sizing: border-box;
}
.panel-form .form-grid select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7b92' d='M1.4 1.4L6 6l4.6-4.6L12 2.8 6 8.8 0 2.8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .9rem center;
  padding-right: 2.2rem;
}
.panel-form .form-grid input:focus,
.panel-form .form-grid select:focus,
.panel-form .form-grid textarea:focus {
  outline: none;
  border-color: #8bb8f0;
  box-shadow: 0 0 0 3px rgba(17,114,255,.12);
}
.panel-form .span-2 { grid-column: 1 / -1; }
.panel-form .form-actions { margin-top: .25rem; }
.btn-sm {
  padding: .4rem .75rem;
  font-size: .85rem;
  border-radius: 8px;
}
.btn-danger {
  background: #b42318;
  color: #fff;
  border: 0;
}

.alert {
  background: #ffe8e8; color: var(--danger); border: 1px solid #f5c2c2;
  border-radius: 10px; padding: .75rem 1rem; margin-bottom: 1rem;
}
.alert.ok { background: #e6f7f1; color: var(--ok); border-color: #b7e6d5; }
.alert.warn { background: #fff6e8; color: #8a5a00; border-color: #f3ddb0; }

.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin: 0 0 1rem; }
.tabs a {
  display: inline-flex; align-items: center; border: 1px solid var(--line); background: #fff;
  color: var(--navy); border-radius: 999px; padding: .4rem .8rem; font-weight: 600; font-size: .86rem;
}
.tabs a:hover { text-decoration: none; border-color: #b9d0ef; }
.tabs a.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.diff-pos { color: var(--ok); font-weight: 700; }
.diff-neg { color: #b42318; font-weight: 700; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, Consolas, monospace; font-size: .82rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .85rem; align-items: center; }
.mini-note { color: var(--muted); font-size: .84rem; margin: .2rem 0 .9rem; line-height: 1.45; }
.choice-list { display: grid; gap: .45rem; margin: .35rem 0 .8rem; }
.choice-list label { display: flex; gap: .55rem; align-items: flex-start; font-weight: 500; }
.choice-list input { margin-top: .2rem; }
label.check { display: flex; flex-direction: row; align-items: center; gap: .5rem; font-weight: 600; }
.row-actions select, .panel-form > label input {
  border: 1px solid var(--line); border-radius: 10px; padding: .45rem .7rem; font: inherit; font-weight: 400; background: #fff; color: var(--navy);
}
.panel-form > label { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; margin-top: .8rem; }

.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
  background: var(--white); border: 1px solid var(--line);
  border-radius: 14px; padding: 1.25rem;
}
.form-grid label { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; font-size: .9rem; }
.form-grid input, .form-grid select, .form-grid textarea {
  border: 1px solid var(--line); border-radius: 10px; padding: .65rem .8rem; font: inherit; font-weight: 400; background: #fff; color: var(--navy); width: 100%; box-sizing: border-box;
}
.form-grid select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7b92' d='M1.4 1.4L6 6l4.6-4.6L12 2.8 6 8.8 0 2.8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .9rem center; padding-right: 2.2rem;
}
.form-grid .check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 600; margin-top: 1.4rem; }
.form-actions { grid-column: 1 / -1; }
.field-error { color: var(--danger); font-size: .8rem; font-weight: 500; }

.soon {
  background: var(--white); border: 1px solid var(--line); border-radius: 14px;
  padding: 2.5rem 1.5rem; text-align: center;
}
.soon h1 { margin: 0 0 .5rem; }
.soon p { color: var(--muted); max-width: 36ch; margin: 0 auto; }

@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: 1fr 1fr; }
  .dash-grid .panel:first-child { grid-column: 1 / -1; }
}

@media (max-width: 960px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 50;
    width: min(300px, 88vw); max-width: 300px;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: none;
  }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: 12px 0 40px rgba(0,0,0,.25); }
  body.nav-open .nav-scrim { display: block; }
  body.nav-open { overflow: hidden; }
  .nav-toggle { display: flex; }
  .nav-close { display: grid; place-items: center; }
  .top-brand-mobile { display: inline-block; }
  .chip-date { display: none; }
  .who-text { display: none; }
  .topbar {
    padding: .65rem .85rem;
    gap: .55rem;
    flex-wrap: nowrap;
  }
  .top-search { min-width: 0; order: 3; flex: 1 1 100%; }
  .top-meta { margin-left: auto; }
  .content { padding: 1rem .85rem 2rem; }
  .page-head h1, .dash-title { font-size: 1.25rem; }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-grid .panel:first-child { grid-column: auto; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .search-row { flex-wrap: wrap; }
  .search-row input, .search-row select { min-width: 0; width: 100%; flex: 1 1 100%; }
  .search-row .btn { width: 100%; }
  .table-wrap { margin: 0 -.25rem; border-radius: 12px; -webkit-overflow-scrolling: touch; }
  table { font-size: .84rem; min-width: 640px; }
  th, td { padding: .7rem .75rem; }
  .row-actions { flex-wrap: wrap; gap: .5rem; }
  .form-grid { grid-template-columns: 1fr; padding: 1rem; }
  .panel-form .form-grid { padding: 0; }
  .panel-form .span-2 { grid-column: 1; }
  .panel { min-height: 0; }
  .login-card { padding: 1.5rem 1.1rem; }
}

@media (max-width: 480px) {
  .kpi-row { grid-template-columns: 1fr 1fr; gap: .55rem; }
  .kpi-n { font-size: 1.25rem; }
  .page-head { gap: .65rem; }
  .page-head .btn, .page-head > div:last-child { width: 100%; }
  .page-head > div:last-child { display: flex; flex-direction: column; gap: .5rem; }
  .avatar { width: 32px; height: 32px; font-size: .8rem; }
  .logout { font-size: .75rem; }
}
