/* =========================================================
   Inspección de infraestructura - estilos
   Relieve suave (neumorfismo) en claro con barra lateral grafito
   y acento naranja, igual que el portafolio.
   ========================================================= */

@font-face { font-family: "Inter"; font-weight: 100 900; font-display: swap; src: url("/vendor/fonts/inter-latin-wght-normal.woff2") format("woff2"); }
@font-face { font-family: "Unbounded"; font-weight: 200 900; font-display: swap; src: url("/vendor/fonts/unbounded-latin-wght-normal.woff2") format("woff2"); }

:root {
  /* Zona clara */
  --bg: #EEF1F6; --hi: #FFFFFF; --lo: #C5CCD8;
  --text: #1E2126; --muted: #5B6472; --line: #D5DBE4;
  /* Barra lateral */
  --side: #3B4049; --side-hi: #4D535E; --side-lo: #252930; --side-text: #F3F4F6; --side-muted: #C7CCD3;
  /* Acentos */
  --accent: #EE7A0C; --accent-text: #B4540A;
  --grad: linear-gradient(135deg, #FFC21A 0%, #FF9A1A 55%, #FF6A1A 100%);
  --glow: 0 10px 24px rgba(238, 122, 12, .30);
  /* Estados */
  --ok: #1FA463; --obs: #E08A00; --bad: #D64545; --na: #8A93A3; --info: #2F6FDE;

  --raise:   9px 9px 20px var(--lo), -8px -8px 18px var(--hi);
  --raise-s: 5px 5px 12px var(--lo), -5px -5px 12px var(--hi);
  --press:   inset 5px 5px 10px var(--lo), inset -5px -5px 10px var(--hi);

  --head: "Unbounded", "Segoe UI", system-ui, sans-serif;
  --body: "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: Consolas, "Courier New", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); font-size: 15.5px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
h1, h2 { font-family: var(--head); letter-spacing: -0.03em; line-height: 1.1; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #FFC21A; outline-offset: 2px; }
[hidden] { display: none !important; }

.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.raised { background: var(--bg); box-shadow: var(--raise); }
.inset  { background: var(--bg); box-shadow: var(--press); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* ----- Estructura ----- */
.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 26px;
  padding: 26px 18px; background: var(--side); color: var(--side-text);
  --bg: var(--side); --hi: var(--side-hi); --lo: var(--side-lo);
  --raise-s: 5px 5px 12px var(--side-lo), -4px -4px 10px var(--side-hi);
  --press: inset 4px 4px 9px var(--side-lo), inset -4px -4px 9px var(--side-hi);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; padding: 0 6px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; background: var(--grad); color: #1E2126; box-shadow: var(--glow); }
.brand-mark .ico { width: 22px; height: 22px; }
.brand b { display: block; font-family: var(--head); font-size: .95rem; line-height: 1.2; }
.brand small { color: var(--side-muted); font-size: .78rem; }

.menu { display: grid; gap: 10px; }
.menu a {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px;
  text-decoration: none; font-weight: 600; color: var(--side-muted);
  transition: box-shadow .2s, color .2s;
}
.menu a .ico { color: var(--side-muted); }
.menu a:hover { color: var(--side-text); box-shadow: var(--raise-s); }
.menu a.is-active { color: #FFB547; box-shadow: var(--press); }
.menu a.is-active .ico { color: #FFB547; }

.side-user { margin-top: auto; display: grid; gap: 10px; padding: 14px; border-radius: 18px; box-shadow: var(--press); }
.side-user b { display: block; font-size: .92rem; }
.side-user small { color: var(--side-muted); font-size: .8rem; }
.side-user .btn { justify-content: center; }

.main { padding: clamp(18px, 3vw, 36px); min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.page-head h1 { font-size: clamp(1.5rem, 3vw, 2.2rem); }
.page-head p { margin-top: 6px; color: var(--muted); }

/* ----- Botones ----- */
.btn {
  display: inline-flex; align-items: center; gap: 9px; border: 0; cursor: pointer; text-decoration: none;
  font-weight: 600; font-size: .92rem; padding: 11px 18px; border-radius: 999px;
  background: var(--bg); color: var(--text); box-shadow: var(--raise-s);
  transition: box-shadow .2s, transform .2s, color .2s, filter .2s;
}
.btn .ico { width: 18px; height: 18px; color: var(--accent); }
.btn:hover { transform: translateY(-1px); color: var(--accent-text); }
.btn:active { transform: none; box-shadow: var(--press); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--grad); color: #1E2126; box-shadow: var(--raise-s), var(--glow); }
.btn-primary .ico { color: #1E2126; }
.btn-primary:hover { color: #1E2126; filter: brightness(1.05); }
.btn-danger { color: var(--bad); }
.btn-danger .ico { color: var(--bad); }
.btn-sm { padding: 7px 13px; font-size: .84rem; }

/* ----- Tarjetas y tablero ----- */
.card { padding: clamp(18px, 2.4vw, 26px); border-radius: 26px; }
.card h2 { font-size: 1.02rem; letter-spacing: -0.02em; margin-bottom: 4px; }
.card .sub { color: var(--muted); font-size: .86rem; margin-bottom: 16px; }
.grid { display: grid; gap: 24px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.charts { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); margin-top: 24px; }
.charts-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); margin-top: 24px; }

.kpi { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; align-items: center; }
.kpi .key { grid-row: span 2; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 17px; box-shadow: var(--raise-s); color: var(--accent); }
.kpi .key.k-bad { color: var(--bad); }
.kpi .key.k-ok { color: var(--ok); }
.kpi .val { font-family: var(--head); font-weight: 800; font-size: 1.85rem; line-height: 1; letter-spacing: -0.04em; }
.kpi .lbl { color: var(--muted); font-size: .86rem; }

.chart-box { position: relative; height: 290px; }
.chart-box.tall { height: 330px; }
.empty { display: grid; place-items: center; text-align: center; min-height: 160px; color: var(--muted); padding: 20px; }

/* Indicador de puntaje */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; box-shadow: 2px 2px 5px var(--lo), -2px -2px 5px var(--hi); background: var(--bg); }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.b-ok { color: var(--ok); } .b-info { color: var(--info); } .b-obs { color: var(--obs); } .b-bad { color: var(--bad); } .b-na { color: var(--na); }

/* ----- Tablas ----- */
.table-wrap { overflow-x: auto; border-radius: 20px; box-shadow: var(--press); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 13px 16px; text-align: left; vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr { border-top: 1px solid var(--line); }
tbody tr:hover { background: rgba(255,255,255,.55); }
td a.row-link { font-weight: 600; text-decoration: none; }
td a.row-link:hover { color: var(--accent-text); }
.list-plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.list-plain li { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 16px; box-shadow: var(--press); font-size: .9rem; }
.code { font-family: var(--mono); font-size: .78rem; font-weight: 600; color: var(--accent-text); padding: 4px 8px; border-radius: 8px; background: var(--bg); box-shadow: 2px 2px 5px var(--lo), -2px -2px 5px var(--hi); white-space: nowrap; }

/* ----- Formularios ----- */
.field { display: grid; gap: 7px; }
.field label, .field .label { font-weight: 600; font-size: .88rem; }
.input, select.input, textarea.input {
  width: 100%; border: 0; border-radius: 14px; padding: 12px 14px; background: var(--bg); box-shadow: var(--press);
}
textarea.input { resize: vertical; min-height: 70px; }
.filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 22px; }
.filters .field { min-width: 160px; }
.form-grid { display: grid; gap: 16px; }
.checks { display: grid; gap: 10px; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 16px; box-shadow: var(--raise-s); cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--accent); width: 18px; height: 18px; }
.check b { display: block; }
.check small { color: var(--muted); }
.msg { min-height: 1.4em; font-size: .9rem; font-weight: 600; color: var(--bad); }
.msg.ok { color: var(--ok); }

/* ----- Diálogo ----- */
dialog { border: 0; padding: 0; border-radius: 26px; background: var(--bg); color: var(--text); box-shadow: 0 30px 80px rgba(10,14,22,.35); width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(22, 26, 32, .55); backdrop-filter: blur(3px); }
.dlg { padding: 26px; display: grid; gap: 18px; }
.dlg h2 { font-size: 1.2rem; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }

/* ----- Aviso flotante ----- */
.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: 360px;
  padding: 14px 18px; border-radius: 16px; background: var(--side); color: #fff; font-weight: 600; font-size: .9rem;
  box-shadow: 0 16px 40px rgba(10,14,22,.3); transform: translateY(20px); opacity: 0; transition: .3s; pointer-events: none;
}
.toast.show { transform: none; opacity: 1; }
.toast.err { background: #A33030; }

/* ----- Inicio de sesión ----- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, #3B4049 0%, #3B4049 38%, #EEF1F6 38.1%); }
.login { width: min(420px, 100%); padding: 34px; border-radius: 30px; display: grid; gap: 18px; }
.login .brand { padding: 0; }
.login .brand b { color: var(--text); font-size: 1.05rem; }
.login .brand small { color: var(--muted); }
.login h1 { font-size: 1.5rem; margin-top: 6px; }

/* ----- Inspección ----- */
.insp-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; }
.insp-meta { display: flex; flex-wrap: wrap; gap: 10px 22px; color: var(--muted); font-size: .9rem; margin-top: 10px; }
.insp-meta b { color: var(--text); }
.ring { --p: 0; --c: var(--accent); width: 126px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), #D9DEE7 0); box-shadow: var(--raise-s); }
.ring-in { width: 76%; aspect-ratio: 1; border-radius: 50%; display: grid; place-content: center; text-align: center; background: var(--bg); box-shadow: var(--press); }
.ring-in b { font-family: var(--head); font-size: 1.45rem; letter-spacing: -0.04em; line-height: 1; }
.ring-in small { font-size: .72rem; color: var(--muted); margin-top: 4px; }

.progress { display: flex; align-items: center; gap: 12px; margin-top: 16px; font-size: .88rem; color: var(--muted); font-weight: 600; }
.bar { flex: 1; height: 10px; border-radius: 999px; overflow: hidden; box-shadow: var(--press); }
.bar i { display: block; height: 100%; width: 0; background: var(--grad); border-radius: inherit; transition: width .4s; }

.toolbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px;
  margin: 24px calc(-1 * clamp(18px, 3vw, 36px)) 0; padding: 14px clamp(18px, 3vw, 36px); background: rgba(238, 241, 246, .92); backdrop-filter: blur(8px); }
.tabs { display: inline-flex; gap: 6px; padding: 6px; border-radius: 999px; box-shadow: var(--press); flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; cursor: pointer; font-weight: 600; font-size: .9rem; padding: 9px 16px; border-radius: 999px; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--bg); color: var(--accent-text); box-shadow: var(--raise-s); }
.save-state { font-size: .84rem; color: var(--muted); font-weight: 600; }

.section-block { margin-top: 26px; }
.section-block > h3 { font-family: var(--head); font-size: 1rem; letter-spacing: -0.02em; margin: 0 0 14px 4px; }
.items { display: grid; gap: 14px; }
.item { display: grid; grid-template-columns: 6px minmax(0, 1fr) auto; gap: 16px; padding: 16px 18px 16px 14px; border-radius: 22px; box-shadow: var(--press); align-items: start; }
.item::before { content: ""; width: 6px; align-self: stretch; border-radius: 6px; background: var(--na); opacity: .35; }
.item[data-status="cumple"]::before { background: var(--ok); opacity: 1; }
.item[data-status="observacion"]::before { background: var(--obs); opacity: 1; }
.item[data-status="no_cumple"]::before { background: var(--bad); opacity: 1; }
.item[data-status="na"]::before { background: var(--na); opacity: .8; }
.item[data-status]:not([data-status=""]) { box-shadow: var(--raise-s); }
.item.is-missing { outline: 2px dashed var(--bad); outline-offset: 3px; }
.item-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.item h4 { margin: 8px 0 0; font-size: 1rem; font-weight: 600; }
.item p.guide { margin-top: 4px; color: var(--muted); font-size: .9rem; }
.crit { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.crit-alta { color: var(--bad); } .crit-media { color: var(--obs); } .crit-baja { color: var(--na); }
.ref { font-size: .78rem; color: var(--muted); }
.item textarea { margin-top: 12px; min-height: 52px; font-size: .9rem; }
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding: 6px; border-radius: 18px; box-shadow: var(--press); min-width: 250px; }
.seg button { border: 0; background: transparent; cursor: pointer; font-weight: 600; font-size: .82rem; padding: 9px 10px; border-radius: 12px; color: var(--muted); transition: box-shadow .2s, color .2s; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--bg); box-shadow: 3px 3px 7px var(--lo), -3px -3px 7px var(--hi); }
.seg button[data-v="cumple"][aria-pressed="true"] { color: var(--ok); }
.seg button[data-v="observacion"][aria-pressed="true"] { color: var(--obs); }
.seg button[data-v="no_cumple"][aria-pressed="true"] { color: var(--bad); }
.seg button[data-v="na"][aria-pressed="true"] { color: #4D5664; }
.seg button:disabled { cursor: default; }
.only-open .item[data-status="cumple"], .only-open .item[data-status="na"] { display: none; }
.readonly-status { font-weight: 700; font-size: .9rem; }
.comment-ro { margin-top: 10px; padding: 10px 12px; border-radius: 12px; box-shadow: var(--press); font-size: .9rem; }

.head-card { margin-top: 18px; }
.admin-top { margin-top: 0; align-items: start; }
.audit-card { margin-top: 24px; }
.notes-card { margin-top: 28px; }
.check-plain { box-shadow: none; padding: 0; align-items: center; font-weight: 600; font-size: .9rem; }
.check-plain input { margin-top: 0; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ----- Responsive ----- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts, .charts-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: relative; z-index: 10; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 14px; }
  .brand small { display: none; }
  .menu { order: 3; width: 100%; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; overflow-x: auto; }
  .menu a { justify-content: center; padding: 10px; font-size: .84rem; }
  .menu a span { display: none; }
  .side-user { margin: 0 0 0 auto; padding: 8px 10px; grid-auto-flow: column; align-items: center; box-shadow: none; }
  .side-user .who { display: none; }
  .toolbar { position: static; margin-inline: 0; padding-inline: 0; background: transparent; backdrop-filter: none; }
  .item { grid-template-columns: 6px minmax(0, 1fr); }
  .item .seg, .item .readonly-status { grid-column: 2; }
  .insp-head { grid-template-columns: 1fr; }
  .ring { width: 108px; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr; }
  .seg { min-width: 0; }
  .menu a span { display: none; }
  th, td { padding: 11px 12px; }
}

/* ----- Impresión: informe limpio ----- */
@media print {
  .side, .toolbar, .no-print, .toast { display: none !important; }
  .layout { display: block; }
  body, .raised, .inset, .item, .seg, .card, .table-wrap, .ring, .ring-in, .code, .badge { background: #fff !important; box-shadow: none !important; }
  .card, .item { border: 1px solid #ddd; break-inside: avoid; }
  .main { padding: 0; }
  .seg button:not([aria-pressed="true"]) { display: none; }
  textarea.input { border: 1px solid #ddd; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

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