/* Complejo Tulkal — sistema visual
 *
 * Deliberately NOT the default SaaS look. Two registers in one product:
 *   · the cover reads like an executive report — serif display figures, air, one
 *     dominant number, strong hierarchy. It is for the director who signs.
 *   · everything behind it reads like a control room — dense, monospaced, high
 *     information rate. It is for the engineer who operates.
 * Ink + amber instead of corporate blue, because every dashboard is corporate blue. */

:root {
  --ink:        #0a1014;
  --ink-2:      #101922;
  --ink-3:      #16212c;
  --ink-hover:  #1c2936;
  --line:       #223040;
  --line-soft:  #1a2530;

  --sand:       #eef2f0;
  --sand-dim:   #94a4a8;
  --sand-faint: #5f7078;

  --amber:      #e0a33e;
  --amber-soft: rgba(224, 163, 62, .12);
  --teal:       #4ec9b0;
  --teal-soft:  rgba(78, 201, 176, .12);

  --ok:   #4ec9b0;
  --warn: #e0a33e;
  --crit: #f2645a;
  --info: #a78bfa;

  --r:    12px;
  --r-lg: 18px;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px -18px rgba(0,0,0,.7);

  --display: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="light"] {
  --ink:        #f7f5f1;
  --ink-2:      #ffffff;
  --ink-3:      #f2efe9;
  --ink-hover:  #ebe7df;
  --line:       #ddd7cc;
  --line-soft:  #e8e3da;
  --sand:       #16212c;
  --sand-dim:   #5a6670;
  --sand-faint: #8b959d;
  --amber:      #a76f10;
  --amber-soft: rgba(167, 111, 16, .1);
  --teal:       #0d7a68;
  --teal-soft:  rgba(13, 122, 104, .1);
  --ok: #0d7a68; --warn: #a76f10; --crit: #c0362c;
  --shadow: 0 1px 2px rgba(20,15,5,.05), 0 10px 26px -18px rgba(20,15,5,.4);
}

* { box-sizing: border-box; }

body {
  margin: 0; background: var(--ink); color: var(--sand);
  font-family: var(--sans); font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ----------------------------------------------------------------- shell */

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--ink-2) 92%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1620px; margin: 0 auto;
  display: flex; align-items: center; gap: 26px;
  padding: 12px 34px;
}

.brand { flex: none; }
.brand h1 { font-family: var(--display); font-size: 18px; margin: 0; letter-spacing: -0.018em; font-weight: 700; line-height: 1.1; }
.brand span { font-size: 9.5px; color: var(--sand-faint); letter-spacing: .13em; text-transform: uppercase; }

.topnav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.nav-item {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 8px; color: var(--sand-dim);
  font-weight: 550; cursor: pointer; border: none; background: none;
  font-size: 13.5px; font-family: inherit; white-space: nowrap;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--ink-hover); color: var(--sand); }
.nav-item.active { background: var(--amber-soft); color: var(--amber); font-weight: 650; }
.nav-item .badge { font-size: 10px; background: var(--crit); color: #fff; border-radius: 20px; padding: 1px 7px; font-weight: 700; }

.topbar-right { display: flex; align-items: center; gap: 10px; flex: none; }
.scope-select {
  background: var(--ink-3); border: 1px solid var(--line); color: var(--sand);
  padding: 8px 11px; border-radius: 8px; font-size: 12.5px; font-family: inherit;
  font-weight: 600; cursor: pointer; max-width: 190px;
}
.scope-select:hover { border-color: var(--amber); }
.snapshot-box {
  display: flex; align-items: center; gap: 7px; padding: 7px 11px;
  background: var(--ink-3); border: 1px solid var(--line); border-radius: 8px;
  font-size: 11.5px; color: var(--sand-dim); white-space: nowrap;
}
.snapshot-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--teal); flex: none; box-shadow: 0 0 0 3px var(--teal-soft); }
.theme-toggle { background: none; border: 1px solid var(--line); color: var(--sand-dim); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 15px; }
.theme-toggle:hover { color: var(--sand); border-color: var(--sand-faint); }

.main { max-width: 1620px; margin: 0 auto; padding: 34px 34px 90px; }

/* ----------------------------------------------------------------- chips */

.chiprow { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--ink-2); border: 1px solid var(--line); color: var(--sand-dim);
  border-radius: 20px; padding: 7px 14px; font-size: 12.5px; font-family: inherit;
  font-weight: 600; cursor: pointer; transition: all .12s;
}
.chip:hover { border-color: var(--sand-faint); color: var(--sand); }
.chip.active { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }
.chip em { font-style: normal; font-variant-numeric: tabular-nums; opacity: .6; font-size: 11.5px; }
.chip-bad {
  font-style: normal; background: var(--warn); color: var(--ink);
  border-radius: 20px; padding: 0 6px; font-size: 10.5px; font-weight: 800;
}

/* ------------------------------------------------------------- readings */

.reading {
  display: inline-flex; flex-direction: column; margin: 0 14px 4px 0;
  font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px;
}
.reading i { font-style: normal; font-size: 9.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--sand-faint); font-weight: 700; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -------------------------------------------------------------- verify */

.verify {
  display: grid; grid-template-columns: 46px 1fr; gap: 16px; align-items: start;
  border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px;
  background: var(--ink-2); margin-top: 8px;
}
.verify-ok {}
.verify-bad {}
.verify-mark {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
  font-size: 24px; font-weight: 700;
}
.verify-ok .verify-mark { background: var(--teal-soft); color: var(--ok); }
.verify-bad .verify-mark { background: rgba(242,100,90,.14); color: var(--crit); }
.verify strong { font-size: 15px; }
.verify p { margin: 5px 0 0; font-size: 12.5px; color: var(--sand-dim); }

/* --------------------------------------------------------------- cover -- */

.cover { margin-bottom: 40px; }
.cover-eyebrow { font-size: 10.5px; text-transform: uppercase; letter-spacing: .16em; color: var(--amber); font-weight: 700; }
.cover h2 { font-family: var(--display); font-size: clamp(30px, 4vw, 46px); line-height: 1.08; margin: 10px 0 14px; letter-spacing: -0.028em; font-weight: 700; max-width: 20ch; }
.cover-thesis { font-size: 16px; color: var(--sand-dim); max-width: 62ch; line-height: 1.6; margin: 0; }
.cover-thesis strong { color: var(--sand); font-weight: 600; }

.headline {
  display: grid; grid-template-columns: auto 1fr; gap: 34px; align-items: end;
  padding: 26px 0 28px; margin: 30px 0 0;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.headline-figure { font-family: var(--display); font-size: clamp(46px, 7vw, 82px); line-height: .92; letter-spacing: -0.04em; font-weight: 750; font-variant-numeric: tabular-nums; }
.headline-figure sup { font-size: .3em; vertical-align: super; color: var(--amber);
  font-weight: 700; letter-spacing: .04em; margin-left: 4px; }
.headline-label { font-size: 11px; text-transform: uppercase; letter-spacing: .13em; color: var(--sand-faint); font-weight: 700; margin-bottom: 8px; }
.headline-split { display: flex; gap: 30px; flex-wrap: wrap; padding-bottom: 8px; }
.headline-split div { min-width: 96px; }
.headline-split b { display: block; font-family: var(--display); font-size: 25px; letter-spacing: -0.025em; font-weight: 700; font-variant-numeric: tabular-nums; }
.headline-split span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--sand-faint); font-weight: 650; }

/* ---------------------------------------------------------------- stats -- */

.statline { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--ink-2); }
.stat { padding: 18px 20px; border-right: 1px solid var(--line-soft); cursor: pointer; transition: background .12s; }
.stat:last-child { border-right: none; }
.stat:hover { background: var(--ink-hover); }
.stat b { display: block; font-family: var(--display); font-size: 30px; letter-spacing: -0.03em; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat b em { font-style: normal; font-size: .52em; color: var(--sand-dim); font-weight: 700;
  margin-left: 2px; letter-spacing: 0; }
.stat span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--sand-faint); font-weight: 650; }
.stat small { display: block; font-size: 11.5px; color: var(--sand-dim); margin-top: 3px; }

/* ---------------------------------------------------------------- cards -- */

.card { background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow); }
.card[data-goto], .card[data-type] { cursor: pointer; transition: border-color .14s, transform .14s; }
.card[data-goto]:hover, .card[data-type]:hover { border-color: var(--amber); transform: translateY(-1px); }

.grid { display: grid; gap: 14px; }
.grid.k4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.k3 { grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.grid.k2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.kpi-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--sand-faint); font-weight: 650; }
.kpi-value { font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; margin-top: 4px; line-height: 1.15; }
.kpi-value .of { font-size: 16px; color: var(--sand-faint); }
.kpi-foot { font-size: 12px; color: var(--sand-dim); margin-top: 5px; }

/* ------------------------------------------------------------- headings -- */

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; }
.page-head h2 { font-family: var(--display); margin: 0; font-size: 28px; letter-spacing: -0.025em; font-weight: 700; }
.page-sub { color: var(--sand-dim); margin: 0 0 26px; font-size: 13.5px; max-width: 80ch; }
.section-title { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .13em; color: var(--sand-faint); margin: 34px 0 13px; }
.snapshot-tag { font-size: 10.5px; padding: 3px 10px; border-radius: 20px; background: var(--amber-soft); color: var(--amber); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }

/* ----------------------------------------------------------- room grid -- */

.roomgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 4px; }
.roomcell {
  aspect-ratio: 1; border-radius: 6px; border: 1px solid var(--line);
  background: var(--ink-3); display: flex; flex-direction: column;
  align-items: center; justify-content: center; cursor: pointer;
  font-size: 10px; line-height: 1.15; position: relative; overflow: hidden;
  transition: transform .1s, border-color .1s;
}
.roomcell:hover { transform: scale(1.14); border-color: var(--sand); z-index: 3; }
.roomcell b { font-family: var(--mono); font-size: 10px; font-weight: 600; }
.roomcell i { font-style: normal; font-size: 8.5px; color: var(--sand-faint); font-variant-numeric: tabular-nums; }
.roomcell.inrange { background: var(--teal-soft); border-color: rgba(78,201,176,.45); }
.roomcell.outrange { background: rgba(224,163,62,.2); border-color: var(--warn); }
.roomcell.outrange i { color: var(--warn); font-weight: 700; }
.roomcell.alarm { background: rgba(242,100,90,.18); border-color: var(--crit); }
.roomcell.critical { background: var(--crit); border-color: var(--crit); color: #fff; }
.roomcell.critical i { color: rgba(255,255,255,.75); }
.roomcell.offline { background: repeating-linear-gradient(45deg, var(--ink-3), var(--ink-3) 4px, var(--ink-2) 4px, var(--ink-2) 8px); color: var(--sand-faint); }

.legend { display: flex; gap: 18px; flex-wrap: wrap; margin: 14px 0 4px; font-size: 12px; color: var(--sand-dim); }
.legend i { width: 13px; height: 13px; border-radius: 4px; display: inline-block; vertical-align: -2px; margin-right: 6px; border: 1px solid var(--line); }

/* --------------------------------------------------------------- tables -- */

.table-wrap { overflow: auto; max-height: 76vh; border: 1px solid var(--line); border-radius: var(--r); background: var(--ink-2); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--sand-faint); padding: 12px 15px; white-space: nowrap; position: sticky; top: 0; background: var(--ink-2); z-index: 2; font-weight: 700; border-bottom: 1px solid var(--line); }
td { padding: 10px 15px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--ink-hover); }
tr.total-row td { font-weight: 700; background: var(--ink-3); border-top: 1px solid var(--line); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 11.5px; }
.dim { color: var(--sand-dim); }

/* ---------------------------------------------------------------- pills -- */

.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 10px; font-weight: 700; white-space: nowrap; letter-spacing: .04em; text-transform: uppercase; }
.pill.ok { background: var(--teal-soft); color: var(--ok); }
.pill.dead { background: rgba(242,100,90,.13); color: var(--crit); }
.pill.unknown { background: rgba(148,164,168,.13); color: var(--sand-dim); }
.pill.critica { background: rgba(242,100,90,.16); color: var(--crit); }
.pill.alta { background: var(--amber-soft); color: var(--warn); }
.pill.media { background: rgba(224,163,62,.08); color: var(--warn); }
.pill.servicio { background: var(--teal-soft); color: var(--teal); }
.pill.info { background: rgba(167,139,250,.13); color: var(--info); }
.pill.role-sensa { background: var(--teal-soft); color: var(--teal); }
.pill.role-comanda { background: var(--amber-soft); color: var(--amber); }
.pill.role-calcula { background: rgba(148,164,168,.12); color: var(--sand-dim); }
.pill.role-registra { background: rgba(167,139,250,.12); color: var(--info); }
.pill.role-alarma { background: rgba(242,100,90,.13); color: var(--crit); }
.pill.tier1 { background: var(--amber-soft); color: var(--amber); }

/* -------------------------------------------------------------- filters -- */

.filters { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
input[type="search"], select { background: var(--ink-2); border: 1px solid var(--line); color: var(--sand); padding: 9px 12px; border-radius: 8px; font-size: 13px; font-family: inherit; }
input[type="search"] { min-width: 250px; flex: 1; max-width: 400px; }
input[type="search"]:focus, select:focus { outline: 2px solid var(--amber); outline-offset: -1px; }
.result-count { color: var(--sand-dim); font-size: 12px; margin-left: auto; font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------------------- bars -- */

.bar-row { display: grid; grid-template-columns: 1fr 52px; gap: 12px; align-items: center; margin-bottom: 6px; }
.bar-track { background: var(--ink); border-radius: 6px; height: 26px; position: relative; overflow: hidden; border: 1px solid var(--line-soft); }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--amber), var(--teal)); opacity: .42; }
.bar-label { position: absolute; left: 11px; top: 0; line-height: 26px; font-size: 11.5px; white-space: nowrap; font-weight: 550; }
.health { height: 5px; border-radius: 6px; background: var(--ink); overflow: hidden; margin-top: 10px; border: 1px solid var(--line-soft); }
.health-fill { height: 100%; border-radius: 6px; transition: width .3s; }

/* ------------------------------------------------------ zones & types -- */

.zone-card { display: flex; flex-direction: column; gap: 11px; }
.zone-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.zone-head h3 { font-family: var(--display); margin: 0; font-size: 19px; letter-spacing: -0.02em; font-weight: 700; }
.trunk-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--ink-3); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; font-size: 12px; cursor: pointer; color: var(--sand); font-family: inherit; transition: border-color .12s, background .12s; }
.trunk-chip:hover { border-color: var(--amber); background: var(--ink-hover); }
.trunk-chip b { font-family: var(--mono); font-size: 11.5px; }
.trunk-chip span { color: var(--sand-dim); }
.trunk-wrap { display: flex; flex-wrap: wrap; gap: 7px; }

.type-card { display: grid; grid-template-columns: 70px 1fr; gap: 18px; align-items: start; }
.type-count { font-family: var(--display); font-size: 32px; font-weight: 750; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.type-count small { display: block; font-family: var(--sans); font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--sand-faint); font-weight: 700; margin-top: 4px; }
.type-body h3 { font-family: var(--display); margin: 0 0 5px; font-size: 17px; letter-spacing: -0.015em; font-weight: 700; }
.type-body p { margin: 0 0 10px; font-size: 12.5px; color: var(--sand-dim); }
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { background: var(--ink-3); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: 10.5px; color: var(--sand-dim); font-family: var(--mono); }

/* -------------------------------------------------------------- notices -- */

.notice { border: 1px solid var(--line); background: var(--ink-2); border-radius: var(--r); padding: 14px 18px; font-size: 13px; color: var(--sand-dim); }
.notice strong { color: var(--sand); }
.notice ul { margin: 8px 0 0; padding-left: 18px; }
.notice.phase2 { }

.method { margin-top: 28px; background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r); padding: 0 19px; }
.method summary { cursor: pointer; padding: 14px 0; font-size: 12.5px; font-weight: 650; color: var(--sand-dim); }
.method summary:hover { color: var(--sand); }
.method[open] summary { border-bottom: 1px solid var(--line-soft); margin-bottom: 13px; }
.method ul { padding-left: 18px; font-size: 13px; color: var(--sand-dim); }
.method li { margin-bottom: 7px; }
.method p { font-size: 12.5px; padding-bottom: 15px; }

.what-is { background: var(--ink-3); border: 1px solid var(--line); border-radius: 9px; padding: 13px 17px; margin: 18px 0 4px; }
.what-is strong { font-size: 14.5px; }
.what-is p { margin: 6px 0 0; font-size: 12.5px; color: var(--sand-dim); }

.role-row { display: flex; gap: 9px; flex-wrap: wrap; margin: 20px 0 4px; }
.role-chip { flex: 1; min-width: 112px; background: var(--ink-3); border: 1px solid var(--line); border-radius: 9px; padding: 11px 14px; font-size: 12px; color: var(--sand-dim); }
.role-chip b { display: block; font-family: var(--display); font-size: 21px; color: var(--sand); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; font-weight: 700; }
.role-chip span { display: block; font-size: 10.5px; color: var(--sand-faint); }

/* --------------------------------------------------------------- drawer -- */

.drawer-backdrop { position: fixed; inset: 0; background: rgba(4,8,10,.66); z-index: 60; backdrop-filter: blur(3px); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(840px, 96vw); background: var(--ink); border-left: 1px solid var(--line); z-index: 61; display: flex; flex-direction: column; box-shadow: -24px 0 60px -24px rgba(0,0,0,.75); }
.drawer-head { padding: 22px 26px; border-bottom: 1px solid var(--line); background: var(--ink-2); position: relative; }
.drawer-head h3 { font-family: var(--display); margin: 0 0 3px; font-size: 21px; letter-spacing: -0.02em; padding-right: 40px; font-weight: 700; }
.drawer-body { overflow-y: auto; padding: 0 26px 44px; flex: 1; }
.drawer-body .section-title:first-child { margin-top: 24px; }
.drawer-close { position: absolute; top: 18px; right: 22px; background: none; border: none; color: var(--sand-dim); font-size: 27px; cursor: pointer; line-height: 1; }
.drawer-close:hover { color: var(--sand); }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 15px; margin: 20px 0 6px; }
.meta-grid div span { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--sand-faint); font-weight: 700; margin-bottom: 2px; }

.empty { padding: 48px; text-align: center; color: var(--sand-dim); }

@media (max-width: 1100px) {
  .topbar-inner { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .topnav { order: 3; width: 100%; }
  .topbar-right { margin-left: auto; }
  .snapshot-box { display: none; }
  .main { padding: 22px 16px 70px; }
  .headline { grid-template-columns: 1fr; gap: 20px; align-items: start; }
  .statline { grid-template-columns: repeat(2, 1fr); }
  .stat { border-bottom: 1px solid var(--line-soft); }
}

/* -------------------------------------------------- insights / diagnóstico */

.alertbar {
  display: grid; grid-template-columns: auto 1fr; gap: 26px; align-items: center;
  background: var(--ink-2); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 22px 26px; margin-bottom: 8px;
  cursor: pointer; transition: border-color .14s;
}
.alertbar:hover { border-color: var(--amber); }
.alertbar-hot { background: linear-gradient(100deg, rgba(242,100,90,.07), transparent 55%), var(--ink-2); }
.alertbar-figure {
  font-family: var(--display); font-size: clamp(48px, 6vw, 74px); line-height: .9;
  font-weight: 750; letter-spacing: -0.04em; color: var(--crit); font-variant-numeric: tabular-nums;
}
.alertbar strong { font-size: 16px; display: block; }
.alertbar p { margin: 6px 0 0; font-size: 13px; color: var(--sand-dim); max-width: 74ch; }

.maint { display: flex; flex-direction: column; gap: 12px; }
.maint-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.maint-sub { margin: 3px 0 0; font-size: 12px; color: var(--sand-dim); max-width: 30ch; }
.maint-total {
  font-family: var(--display); font-size: 34px; font-weight: 750;
  letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums;
}
.maint-crit {}
.maint-crit .maint-total { color: var(--crit); }
.maint-warn {}
.maint-warn .maint-total { color: var(--warn); }
.maint-info {}
.maint-info .maint-total { color: var(--info); }

.maint-row {
  display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: start;
  padding-top: 12px; border-top: 1px solid var(--line-soft);
}
.maint-n {
  font-family: var(--display); font-size: 21px; font-weight: 600;
  text-align: right; font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.maint-row strong { display: block; font-size: 13px; line-height: 1.35; }
.maint-row span { display: block; font-size: 11.5px; color: var(--sand-dim); margin-top: 2px; }

@media (max-width: 700px) {
  .alertbar { grid-template-columns: 1fr; gap: 10px; }
}

.pattern {
  display: grid; grid-template-columns: 92px 1fr; gap: 20px; align-items: center;
  background: var(--ink-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 18px 22px; margin-bottom: 10px;
}
.pattern-ratio {
  font-family: var(--display); font-size: 42px; font-weight: 750; color: var(--amber);
  letter-spacing: -0.04em; line-height: 1; text-align: right; font-variant-numeric: tabular-nums;
}
.pattern-ratio em { font-style: normal; font-size: 20px; }
.pattern strong { font-size: 14.5px; }
.pattern p { margin: 5px 0 0; font-size: 12.5px; color: var(--sand-dim); max-width: 88ch; }
.pattern-action { color: var(--amber) !important; font-weight: 600; }
@media (max-width: 700px) { .pattern { grid-template-columns: 1fr; gap: 8px; } .pattern-ratio { text-align: left; } }

/* ------------------------------------------------------------- tendencias */
.chart-card { display:flex; flex-direction:column; gap:10px; }
.chart-hd { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; }
.chart-now { font-size:21px; font-weight:750; letter-spacing:-.02em; font-variant-numeric:tabular-nums; white-space:nowrap; }
.chart-now i { font-style:normal; font-size:12px; color:var(--sand-faint); font-weight:600; }
.chart-slot { min-height:74px; }
.spark { width:100%; height:74px; display:block; }
.spark-area { fill:var(--amber-soft); }
.spark-line { fill:none; stroke:var(--amber); stroke-width:1.6; vector-effect:non-scaling-stroke; }
.spark-avg { stroke:var(--sand-faint); stroke-width:1; stroke-dasharray:3 3; vector-effect:non-scaling-stroke; opacity:.55; }
.chart-foot { display:flex; gap:16px; font-size:11px; color:var(--sand-dim); font-variant-numeric:tabular-nums; }
.chart-foot b { color:var(--sand); font-weight:650; }

/* ------------------------------------------------------------ caso de valor */
.valuecase { display:grid; gap:1px; background:var(--line); border:1px solid var(--line); border-radius:var(--r); overflow:hidden; }
.vc-item { display:grid; grid-template-columns:130px 1fr; gap:20px; align-items:center; padding:16px 20px; background:var(--ink-2); }
.vc-n { font-size:34px; font-weight:750; letter-spacing:-.035em; font-variant-numeric:tabular-nums; line-height:1; color:var(--amber); text-align:right; }
.vc-n span { display:block; font-size:10px; letter-spacing:.1em; text-transform:uppercase; color:var(--sand-faint); font-weight:700; margin-top:4px; }
.vc-item strong { font-size:14.5px; }
.vc-item p { margin:4px 0 0; font-size:12.5px; color:var(--sand-dim); max-width:80ch; }
.vc-note { font-size:12px; color:var(--sand-dim); margin-top:12px; max-width:88ch; font-style:italic; }
@media (max-width:700px){ .vc-item{grid-template-columns:1fr;gap:6px;} .vc-n{text-align:left;} }

/* las filas de mantenimiento son accionables, no decorativas */
.maint-row { width:100%; text-align:left; background:none; border:none; font-family:inherit;
  color:inherit; cursor:pointer; border-radius:8px; transition:background .12s; }
.maint-row:hover { background:var(--ink-3); }
.maint-rooms { display:flex; flex-wrap:wrap; gap:4px; margin-top:6px; }
.maint-rooms i { font-style:normal; font-family:var(--mono); font-size:10.5px;
  background:var(--ink-3); border:1px solid var(--line); border-radius:5px;
  padding:1px 6px; color:var(--sand-dim); }
.maint-row:hover .maint-rooms i { border-color:var(--sand-faint); }
.maint-rooms i.more { background:var(--amber-soft); border-color:var(--amber);
  color:var(--amber); font-weight:700; font-family:var(--sans); }

/* medidor que no mide: la fila se atenúa para que su número no se lea como actual */
.row-stale td { opacity:.55; }
.row-stale td:first-child, .row-stale td:last-child { opacity:1; }
/* matriz de energéticos */
.matrix th.grp { text-align:center; border-left:1px solid var(--line); color:var(--sand-dim); }
.matrix td:nth-child(2), .matrix td:nth-child(4), .matrix td:nth-child(6) { border-left:1px solid var(--line-soft); }
.matrix th:nth-child(2), .matrix th:nth-child(4), .matrix th:nth-child(6) { border-left:1px solid var(--line-soft); }

/* aviso de tendencias con fallas */
.trendwarn { display:grid; grid-template-columns:78px 1fr; gap:20px; align-items:center;
  background:var(--ink-2); border:1px solid var(--warn); border-radius:var(--r);
  padding:16px 20px; margin-bottom:18px; }
.trendwarn-n { font-size:38px; font-weight:750; color:var(--warn); letter-spacing:-.035em;
  text-align:right; line-height:1; font-variant-numeric:tabular-nums; }
.trendwarn strong { font-size:14.5px; }
.trendwarn p { margin:4px 0 0; font-size:12.5px; color:var(--sand-dim); max-width:88ch; }
.trendwarn b { color:var(--sand); }
.chart-bad { border-color:var(--warn); }
.chart-bad .spark-line { stroke:var(--warn); opacity:.7; }
.chart-bad .spark-area { fill:rgba(224,163,62,.07); }
@media (max-width:700px){ .trendwarn{grid-template-columns:1fr;gap:6px;} .trendwarn-n{text-align:left;} }

/* gráfica grande */
.clickable-card { cursor:pointer; transition:border-color .14s; }
.clickable-card:hover { border-color:var(--amber); }
.bigchart { position:relative; margin:18px 0 10px; }
.bigsvg { width:100%; height:auto; display:block; cursor:crosshair; }
.bigsvg .grid { stroke:var(--line); stroke-width:1; vector-effect:non-scaling-stroke; opacity:.5; }
.bigsvg .axis-y { fill:var(--sand-faint); font-size:11px; text-anchor:end; font-family:var(--mono); }
.bigsvg .axis-x { fill:var(--sand-faint); font-size:10px; text-anchor:middle; font-family:var(--mono); }
.bigsvg .axis-unit { fill:var(--sand-dim); font-size:11px; font-weight:700; }
.bigsvg .big-line { fill:none; stroke:var(--amber); stroke-width:2; vector-effect:non-scaling-stroke; }
.bigsvg .cursor-line { stroke:var(--sand-faint); stroke-width:1; stroke-dasharray:3 3; vector-effect:non-scaling-stroke; }
.bigsvg .cursor-dot { fill:var(--amber); stroke:var(--ink); stroke-width:2; }
.tooltip { position:absolute; top:0; transform:translateX(-50%); pointer-events:none;
  background:var(--ink-3); border:1px solid var(--amber); border-radius:7px; padding:6px 10px;
  font-size:12px; white-space:nowrap; box-shadow:var(--shadow); }
.tooltip b { display:block; font-variant-numeric:tabular-nums; }
.tooltip span { color:var(--sand-dim); font-size:11px; font-family:var(--mono); }

/* chips grandes: control de navegación, con su conteo y su estado a la vista */
.chiprow.big { gap:9px; }
.chip.xl { flex-direction:column; align-items:flex-start; gap:2px; padding:12px 18px;
  border-radius:11px; min-width:132px; }
.chip.xl b { font-size:14px; font-weight:700; color:var(--sand); letter-spacing:-.01em; }
.chip.xl.active b { color:var(--amber); }
.chip.xl span { font-size:11px; color:var(--sand-dim); font-weight:550; }
.chip.xl .chip-live { font-size:10.5px; color:var(--ok); font-weight:650; }
.chip.xl .chip-live.warn { color:var(--warn); }

/* ==========================================================================
   RESPONSIVE — tres cortes, con una regla de fondo:
   en pantalla chica la información no se achica, se REORDENA. Las tablas
   anchas scrollean dentro de su caja y el cuerpo de la página nunca lo hace.
   ========================================================================== */

/* El cuerpo no scrollea de costado, pero NO se usa overflow-x:hidden en html/body:
   eso convierte al elemento en contenedor de scroll y anula el position:sticky del
   menú superior. El desborde se contiene en los hijos que lo producen. */
.main, .cover, .statline, .grid, .card { min-width: 0; }
.table-wrap { -webkit-overflow-scrolling: touch; max-width: 100%; }
/* Nada de min-width:max-content — era lo que forzaba el scroll horizontal en
   todas las tablas. Las columnas de texto largo se recortan con elipsis y el
   texto completo queda en el title. */
th, td { overflow-wrap: anywhere; }
td.clip { max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topnav { min-width: 0; }

@media (max-width: 1240px) {
  .main { padding: 26px 22px 70px; }
  .grid.k2, .grid.k3 { grid-template-columns: 1fr; }
  .statline { grid-template-columns: repeat(2, 1fr); }
  .stat { border-bottom: 1px solid var(--line-soft); }
  .headline { grid-template-columns: 1fr; gap: 18px; align-items: start; }
}

@media (max-width: 860px) {
  .main { padding: 20px 14px 70px; }

  /* barra superior: marca y controles arriba, navegación abajo con scroll propio */
  .topbar-inner { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .brand h1 { font-size: 16px; }
  .topnav { order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto;
            scrollbar-width: none; padding-bottom: 2px; }
  .topnav::-webkit-scrollbar { display: none; }
  .nav-item { flex: none; padding: 8px 12px; font-size: 13px; }
  .topbar-right { margin-left: auto; gap: 7px; }
  .snapshot-box { padding: 6px 9px; font-size: 11px; }
  .scope-select { max-width: 150px; padding: 7px 9px; }

  .cover h2 { font-size: 27px; }
  .cover-thesis { font-size: 14.5px; }
  .headline-figure { font-size: 46px; }
  .headline-split { gap: 20px; }

  .grid.k4 { grid-template-columns: repeat(2, 1fr); }
  .kpi-value, .stat b { font-size: 24px; }

  /* filtros: el buscador ocupa la línea entera y los selects se reparten */
  .filters { gap: 8px; }
  input[type="search"] { min-width: 100%; max-width: 100%; order: -1; }
  select { flex: 1; min-width: 44%; }
  .result-count { width: 100%; margin-left: 0; text-align: right; }

  /* la retícula de habitaciones se densifica en vez de desbordar */
  .roomgrid { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 3px; }
  .roomcell b { font-size: 9px; }
  .roomcell i { font-size: 7.5px; }

  .chip.xl { min-width: 118px; padding: 10px 14px; }
  .type-card { grid-template-columns: 54px 1fr; gap: 12px; }
  .maint-row { grid-template-columns: 34px 1fr; gap: 9px; }
  .role-row { gap: 7px; }
  .role-chip { min-width: 96px; padding: 9px 11px; }

  /* el panel lateral pasa a hoja completa */
  .drawer { width: 100%; }
  .drawer-head { padding: 16px 18px; }
  .drawer-head h3 { font-size: 17px; }
  .drawer-body { padding: 0 18px 36px; }
  .meta-grid { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 11px; }

  .verify { grid-template-columns: 38px 1fr; gap: 12px; padding: 14px 16px; }
  .verify-mark { width: 38px; height: 38px; font-size: 19px; }
  .bar-row { grid-template-columns: 1fr 42px; gap: 9px; }
  .bar-label { font-size: 10.5px; }
}

@media (max-width: 560px) {
  .main { padding: 16px 11px 64px; }
  .page-head h2 { font-size: 21px; }
  .cover h2 { font-size: 23px; }
  .cover { margin-bottom: 26px; }
  .headline-figure { font-size: 38px; }

  .statline, .grid.k4 { grid-template-columns: 1fr; }
  .stat:last-child { border-bottom: none; }

  .section-title { margin: 24px 0 10px; }
  .card { padding: 14px 15px; }
  .table-wrap { max-height: 62vh; }
  td, th { padding: 9px 11px; }

  .chiprow { gap: 6px; }
  .chip { padding: 6px 11px; font-size: 12px; }
  .chip.xl { min-width: calc(50% - 3px); flex: 1; }

  .roomgrid { grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); }
  .legend { gap: 10px; font-size: 11px; }

  .alertbar-figure, .trendwarn-n, .vc-n { font-size: 34px; }
  .maint-total, .type-count { font-size: 26px; }

  /* la gráfica grande necesita más alto proporcional para que los ejes respiren */
  .bigsvg { min-height: 240px; }
  .tooltip { font-size: 11px; padding: 5px 8px; }
}

/* pantallas muy anchas: la lectura no debe estirarse sin límite */
@media (min-width: 1900px) {
  .main { max-width: 1720px; }
}


/* ------------------------------------------------------------ equipos */
.devgrid { display:grid; grid-template-columns:repeat(auto-fill,minmax(330px,1fr)); gap:12px; }
.devcard { background:var(--ink-2); border:1px solid var(--line); border-radius:var(--r);
  padding:15px 17px; cursor:pointer; transition:border-color .14s, transform .14s;
  display:flex; flex-direction:column; gap:9px; min-width:0; }
.devcard:hover { border-color:var(--amber); transform:translateY(-1px); }
.devcard-off { opacity:.62; }
.devcard header { display:flex; justify-content:space-between; align-items:flex-start; gap:10px; }
.devcard h3 { margin:0; font-size:14.5px; font-weight:700; letter-spacing:-.01em; line-height:1.25; }
.devtype { margin:2px 0 0; font-size:11.5px; color:var(--sand-dim); }
.devloc { margin:0; font-size:11.5px; color:var(--sand-faint); line-height:1.4;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.devreads { display:grid; grid-template-columns:repeat(auto-fit,minmax(130px,1fr)); gap:8px;
  border-top:1px solid var(--line-soft); padding-top:10px; margin-top:auto; }
.devread { min-width:0; }
.devread i { display:block; font-style:normal; font-size:9.5px; text-transform:uppercase;
  letter-spacing:.06em; color:var(--sand-faint); font-weight:700;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.devread b { font-size:14px; font-weight:700; font-variant-numeric:tabular-nums; }
.devnone { margin:auto 0 0; font-size:11.5px; color:var(--sand-faint); font-style:italic;
  border-top:1px solid var(--line-soft); padding-top:10px; }
@media (max-width:560px){ .devgrid { grid-template-columns:1fr; } }

/* Las tres familias se distinguen por una guía de color sobre su cabecera, no
   por un icono: el emoji cambia de forma según el sistema y ensucia una tabla. */
.matrix th.grp { position:relative; padding-top:12px; }
.matrix th.grp::before { content:''; position:absolute; top:0; left:8px; right:8px; height:2px; border-radius:2px; }
.matrix th.grp-luz::before  { background:var(--amber); }
.matrix th.grp-agua::before { background:var(--teal); }
.matrix th.grp-gas::before  { background:var(--info); }
.chart-note { margin:0; font-size:11px; color:var(--warn); line-height:1.4; }
.pattern-rooms { font-weight:550; color:var(--sand-dim); font-size:12.5px; }
