/* Gemelo digital del abasto de medicamentos · © 2026 Gersain Barron · Licencia MIT */
/* =====================================================================
   CEDIS Medicamentos · Visor 3D
   Interfaz oscura translúcida sobre la escena, pensada para iPad (táctil)
   ===================================================================== */
:root {
  --bg: #0d1117;
  --glass: rgba(15, 20, 27, 0.80);
  --glass-strong: rgba(13, 17, 23, 0.92);
  --line: rgba(148, 163, 184, 0.16);
  --line-strong: rgba(148, 163, 184, 0.28);
  --text: #e6edf3;
  --muted: #8b98a5;
  --faint: #5b6773;
  --accent: #2dd4bf;
  --accent-ink: #062e2a;
  --ok: #34d399;
  --warn: #fbbf24;
  --crit: #f87171;
  --info: #60a5fa;
  --amber: #f5b400;
  --radius: 14px;
  --gap: 12px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --top-h: 60px;
  --cam-h: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; -webkit-text-size-adjust: 100%; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
h2, h3 { margin: 0; }

#viewport { position: fixed; inset: 0; }
#viewport canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

/* ---------- Barra superior ---------- */
.topbar {
  position: fixed; z-index: 20;
  top: calc(var(--gap) + var(--safe-t)); left: calc(var(--gap) + var(--safe-l)); right: calc(var(--gap) + var(--safe-r));
  height: var(--top-h);
  display: flex; align-items: center; gap: 16px; padding: 0 10px 0 12px;
  border-radius: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 32px; height: 32px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text b { font-size: 15px; letter-spacing: 0.1px; white-space: nowrap; }
.brand-text span { font-size: 12px; color: var(--muted); white-space: nowrap; }

.sim { display: flex; align-items: center; gap: 10px; margin: 0 auto; }
.speed { display: flex; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.speed button { min-width: 40px; height: 34px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }
.speed button.active { background: rgba(45, 212, 191, 0.16); color: var(--accent); }
.clock-box { display: flex; flex-direction: column; line-height: 1.15; min-width: 150px; }
.clock { font-size: 16px; white-space: nowrap; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: 0.3px; }
.sim-status { font-size: 11px; color: var(--ok); display: flex; align-items: center; gap: 5px; }
.sim-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); }
.sim-status.paused { color: var(--warn); }
.sim-status.paused::before { box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.18); }

.actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line);
}
.icon-btn:active { transform: scale(0.96); }
.icon-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.pill-btn {
  height: 42px; padding: 0 14px; border-radius: 11px; display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); font-size: 14px; font-weight: 550; position: relative;
}
a.pill-btn { color: inherit; text-decoration: none; }
.pill-btn.active { background: rgba(45, 212, 191, 0.14); border-color: rgba(45, 212, 191, 0.45); color: var(--accent); }
.badge:empty { display: none; }
.badge {
  font-style: normal; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 12px; font-weight: 700;
  display: grid; place-items: center; background: var(--crit); color: #2a0606;
}

/* ---------- Paneles ---------- */
.panel { position: fixed; z-index: 15; border-radius: var(--radius); transition: transform 0.28s ease, opacity 0.28s ease; }
.panel.closed { pointer-events: none; opacity: 0; }

#kpi-panel {
  top: calc(var(--top-h) + var(--gap) * 2 + var(--safe-t)); right: calc(var(--gap) + var(--safe-r));
  bottom: calc(var(--cam-h) + var(--gap) * 2 + var(--safe-b)); width: 384px;
  overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px; scrollbar-width: thin;
}
#kpi-panel.closed { transform: translateX(calc(100% + 24px)); }

.card { padding: 12px 12px 14px; border-bottom: 1px solid var(--line); }
.card:last-child { border-bottom: 0; }
.card h3 { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.7px; color: var(--muted); margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card h3 small { font-size: 11px; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--faint); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: 10px; padding: 9px 9px 8px; display: flex; flex-direction: column; gap: 2px; }
.tile b { font-size: 22px; font-weight: 680; font-variant-numeric: tabular-nums; }
.tile span { font-size: 11px; color: var(--muted); line-height: 1.25; }

.big-row { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.big { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: 12px; }
.bar { display: block; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.4s ease; }
.bar i.hi { background: var(--warn); }
.bar.main { height: 8px; margin-bottom: 12px; }
.aisles { display: grid; gap: 7px; margin-bottom: 12px; }
.aisle { display: grid; grid-template-columns: 52px 1fr 38px; align-items: center; gap: 8px; font-size: 12px; }
.aisle .a-id::before { content: "Pasillo "; color: var(--faint); }
.aisle .a-val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.kv { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.kv b { color: var(--text); font-variant-numeric: tabular-nums; }

.temp-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.temp b { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; color: #7dd3fc; }
.temp span { font-size: 16px; color: var(--muted); margin-left: 3px; }
.spark { width: 100%; height: 64px; display: block; }

.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: rgba(148, 163, 184, 0.14); color: #cbd5e1; }
.chip.ok { background: rgba(52, 211, 153, 0.14); color: var(--ok); }
.chip.warn { background: rgba(251, 191, 36, 0.15); color: var(--warn); }
.chip.crit { background: rgba(248, 113, 113, 0.16); color: var(--crit); }
.chip.info { background: rgba(96, 165, 250, 0.15); color: var(--info); }
.chip.accent { background: rgba(245, 180, 0, 0.15); color: var(--amber); }
.chip.muted { background: rgba(148, 163, 184, 0.10); color: var(--muted); }

.docks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dock { display: grid; grid-template-columns: 26px 1fr; grid-template-rows: auto 4px; gap: 6px 6px; align-items: center; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.dock .d-id { font-weight: 700; font-size: 13px; }
.dock .chip { justify-self: start; }
.dock .bar { grid-column: 1 / -1; height: 4px; }

.equip-list { display: grid; gap: 4px; }
.equip { display: grid; grid-template-columns: 1fr auto 46px 34px; align-items: center; gap: 8px; padding: 8px 8px; border-radius: 9px; text-align: left; font-size: 13px; }
.equip:active, .equip:hover { background: rgba(255, 255, 255, 0.05); }
.e-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.e-pct { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.batt { display: block; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.batt i { display: block; height: 100%; background: var(--ok); }
.batt i.mid { background: var(--warn); }
.batt i.low { background: var(--crit); }
.batt.big { height: 8px; flex: 1; }

.alerts, .log { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.alerts li { padding: 8px 10px; border-radius: 9px; border-left: 3px solid var(--info); background: rgba(96, 165, 250, 0.08); }
.alerts li.warn { border-color: var(--warn); background: rgba(251, 191, 36, 0.08); }
.alerts li.crit { border-color: var(--crit); background: rgba(248, 113, 113, 0.10); }
.alerts li.none, .log li.none { border: 0; background: none; color: var(--faint); padding: 2px 0; }
.log li { display: grid; grid-template-columns: 44px 1fr; gap: 8px; color: #c9d4de; line-height: 1.3; }
.log time { color: var(--faint); font-variant-numeric: tabular-nums; }

/* ---------- Capas ---------- */
#layers-panel {
  top: calc(var(--top-h) + var(--gap) * 2 + var(--safe-t)); right: calc(var(--gap) + var(--safe-r) + 400px);
  width: 320px; padding: 14px; z-index: 18; max-height: calc(100% - 180px); overflow-y: auto;
}
#layers-panel.closed { transform: translateY(-10px); }
#layers-panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--muted); margin-bottom: 8px; }
.toggle { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.toggle:last-child { border-bottom: 0; }
.t-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.t-text b { font-size: 14px; font-weight: 560; }
.t-text small { font-size: 11.5px; color: var(--muted); }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.sw { width: 44px; height: 26px; border-radius: 13px; background: rgba(148, 163, 184, 0.28); position: relative; transition: background 0.2s; flex: none; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.toggle input:checked + .sw { background: var(--accent); }
.toggle input:checked + .sw::after { transform: translateX(18px); }

/* ---------- Inspector ---------- */
#inspector {
  left: calc(var(--gap) + var(--safe-l)); bottom: calc(var(--cam-h) + var(--gap) * 2 + var(--safe-b));
  width: 360px; max-height: min(60vh, 520px); display: flex; flex-direction: column; overflow: hidden;
}
#inspector.closed { transform: translateY(16px); }
#inspector header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.insp-type { font-size: 11.5px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 650; }
#inspector h2 { font-size: 18px; font-weight: 650; margin-top: 3px; line-height: 1.2; }
#insp-body { overflow-y: auto; padding: 4px 14px 8px; -webkit-overflow-scrolling: touch; }
.insp-live { padding: 10px 0 8px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.live-row { display: flex; justify-content: space-between; align-items: center; }
.live-speed { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.live-batt { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.live-batt b { color: var(--text); font-variant-numeric: tabular-nums; min-width: 40px; text-align: right; }
.live-task { font-size: 13px; color: #cbd5e1; }
.insp-rows { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 10px 0 4px; font-size: 13px; }
.insp-rows dt { color: var(--muted); }
.insp-rows dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; word-break: break-word; }
#inspector footer { display: flex; gap: 8px; padding: 10px 14px 14px; border-top: 1px solid var(--line); }
#inspector footer .pill-btn { flex: 1; justify-content: center; width: auto; padding: 0 12px; }
#inspector footer .pill-btn span { display: inline !important; }
#insp-follow[hidden] { display: none; }

/* ---------- Cámaras ---------- */
.cameras {
  position: fixed; z-index: 20; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--gap) + var(--safe-b)); height: var(--cam-h);
  display: flex; gap: 4px; padding: 6px; border-radius: 16px; max-width: calc(100% - 24px);
  overflow-x: auto; scrollbar-width: none;
}
.cameras::-webkit-scrollbar { display: none; }
.cam-btn {
  flex: none; min-width: 78px; height: 100%; border-radius: 11px; padding: 0 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; font-weight: 560; color: var(--muted);
}
.cam-ico { font-size: 17px; line-height: 1; }
.cam-btn.active { background: rgba(45, 212, 191, 0.16); color: var(--accent); }
.cam-btn:active { transform: scale(0.96); }

/* ---------- Etiquetas 3D ---------- */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.lbl { position: absolute; left: 0; top: 0; white-space: nowrap; will-change: transform; }
.lbl.zone {
  font-size: 12px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: #fff;
  padding: 4px 9px; border-radius: 7px; background: rgba(13, 17, 23, 0.62); border: 1px solid rgba(255, 255, 255, 0.12);
}
.lbl.agent {
  font-size: 11.5px; font-weight: 600; color: #fff; padding: 3px 8px 3px 6px; border-radius: 10px;
  background: rgba(13, 17, 23, 0.78); display: flex; align-items: center; gap: 6px;
}
.lbl.agent i { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.lbl.agent[data-tone="ok"] i { background: var(--ok); }
.lbl.agent[data-tone="warn"] i { background: var(--warn); box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.25); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; z-index: 40; left: 50%; bottom: calc(var(--cam-h) + 30px + var(--safe-b)); transform: translate(-50%, 10px);
  padding: 10px 16px; border-radius: 10px; background: var(--glass-strong); border: 1px solid var(--line); font-size: 14px;
  opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Pantalla de carga ---------- */
#loading {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 40%, #16202b 0%, #0b0f14 70%); transition: opacity 0.6s ease;
}
#loading.done { opacity: 0; pointer-events: none; }
.load-card { display: flex; flex-direction: column; align-items: center; gap: 14px; width: min(340px, 80vw); text-align: center; }
.logo.big { width: 54px; height: 54px; }
.load-card b { font-size: 18px; }
.load-track { width: 100%; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.load-track i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.25s ease; }
#load-msg { font-size: 13px; color: var(--muted); line-height: 1.45; }
#loading.error #load-msg { color: var(--warn); }
#loading.error .load-track { display: none; }

/* ---------- Pestañas del panel ---------- */
.tabs {
  position: sticky; top: -6px; z-index: 3; display: flex; gap: 2px; padding: 6px; margin: -6px -6px 4px;
  background: var(--glass-strong); border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: 1 0 auto; height: 36px; padding: 0 9px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.tabs button.active { background: rgba(45, 212, 191, 0.16); color: var(--accent); }
#urg-count { background: var(--warn); color: #2a1d00; min-width: 18px; height: 18px; font-size: 11px; }
#urg-count.vital { background: var(--crit); color: #2a0606; }
.tab-page { display: none; }
.tab-page.active { display: block; }
.sub { margin: 0 0 8px; }
.empty { color: var(--faint); font-size: 13px; margin: 4px 0; }
.src { font-size: 11px; color: var(--faint); margin: 10px 0 0; }

/* ---------- Tarjetas de KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi { background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-left: 3px solid var(--faint); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.kpi[data-tone="ok"] { border-left-color: var(--ok); }
.kpi[data-tone="warn"] { border-left-color: var(--warn); }
.kpi[data-tone="crit"] { border-left-color: var(--crit); }
.k-label { font-size: 11.5px; color: var(--muted); line-height: 1.25; }
.k-val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.k-val i, .tile b i { font-style: normal; font-size: 12px; color: var(--muted); margin-left: 3px; font-weight: 600; }
.kpi[data-tone="warn"] .k-val { color: var(--warn); }
.kpi[data-tone="crit"] .k-val { color: var(--crit); }
.k-meta { font-size: 11px; color: var(--faint); }

/* ---------- Etiquetas pequeñas ---------- */
.tag { font-style: normal; font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: rgba(148, 163, 184, 0.15); color: #cbd5e1; white-space: nowrap; }
.tag.cold { background: rgba(56, 189, 248, 0.16); color: #7dd3fc; }
.tag.ctrl { background: rgba(248, 113, 113, 0.16); color: var(--crit); }
.tag.late { background: rgba(251, 191, 36, 0.16); color: var(--warn); }

/* ---------- Entradas ---------- */
.arr { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; grid-template-areas: "t m s" "t g s"; gap: 3px 8px; padding: 9px 2px; border-bottom: 1px solid var(--line); align-items: center; }
.arr:last-child { border-bottom: 0; }
.arr time { grid-area: t; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); align-self: start; padding-top: 1px; }
.a-main { grid-area: m; min-width: 0; }
.a-main b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a-main small { font-size: 11.5px; color: var(--muted); }
.a-tags { grid-area: g; display: flex; gap: 4px; }
.a-tags:empty { display: none; }
.arr .chip { grid-area: s; }

/* ---------- Salidas y rutas ---------- */
.route { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.route:last-child { border-bottom: 0; }
.route:active { background: rgba(255, 255, 255, 0.04); }
.r-dot { width: 10px; height: 10px; border-radius: 50%; }
.r-main { min-width: 0; }
.r-main b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-main small { display: block; font-size: 11px; color: var(--muted); margin: 2px 0 6px; }
.r-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; max-width: 168px; }
.r-side small { font-size: 11px; color: var(--muted); }
.r-side .chip { max-width: 168px; overflow: hidden; text-overflow: ellipsis; display: block; line-height: 22px; }

/* ---------- Unidades ---------- */
.u-filters { display: flex; gap: 8px; margin-bottom: 8px; }
.seg { display: flex; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 9px; padding: 2px; flex: none; }
.seg button { height: 32px; padding: 0 10px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.seg button.active { background: rgba(45, 212, 191, 0.16); color: var(--accent); }
select, input[type="search"] { font: inherit; font-size: 13px; color: var(--text); background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 9px; height: 38px; padding: 0 10px; outline: none; }
select { flex: 1; min-width: 0; }
select option { background: #0d1117; }
input[type="search"] { width: 100%; margin-bottom: 10px; -webkit-user-select: text; user-select: text; }
.u-map { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.u-map svg { display: block; width: 100%; height: auto; }
.m-state { fill: rgba(148, 163, 184, 0.10); stroke: rgba(148, 163, 184, 0.5); stroke-width: 1; }
.m-unit { stroke: #0d1117; stroke-width: 1; cursor: pointer; transition: opacity 0.2s; }
.m-unit.dim { opacity: 0.12; }
.m-cedis rect { fill: #fff; stroke: #0d1117; stroke-width: 1.5; }
.m-label { font-size: 10px; font-weight: 700; fill: #fff; }
.m-sel { fill: none; stroke: #fff; stroke-width: 2; pointer-events: none; }
.u-legend { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0; }
.u-legend button { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 9px; border-radius: 14px; font-size: 11.5px; font-weight: 600; color: var(--muted); background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.u-legend button.active { color: var(--text); border-color: var(--line-strong); background: rgba(255, 255, 255, 0.08); }
.u-legend i { width: 8px; height: 8px; border-radius: 50%; }
.u-list { display: grid; }
.unit { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 9px 4px; border-bottom: 1px solid var(--line); border-radius: 8px; }
.unit.active { background: rgba(45, 212, 191, 0.10); }
.u-dot { width: 9px; height: 9px; border-radius: 50%; }
.u-main { min-width: 0; }
.u-main b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-main small { font-size: 11px; color: var(--muted); }

/* ---------- Urgencias ---------- */
.tiles.three { grid-template-columns: repeat(3, 1fr); margin-bottom: 10px; }
.pill-btn.wide { width: 100%; justify-content: center; margin-bottom: 8px; }
.urg-list { display: grid; gap: 8px; }
.urg { display: grid; gap: 5px; width: 100%; text-align: left; padding: 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); border-left: 3px solid var(--info); }
.urg[data-level="1"] { border-left-color: var(--crit); }
.urg[data-level="2"] { border-left-color: var(--warn); }
.u-head { display: flex; align-items: center; gap: 8px; }
.u-head b { font-size: 13px; }
.u-head time { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.u-unit { font-size: 13px; font-weight: 600; }
.u-unit small { font-weight: 500; color: var(--muted); }
.u-item { font-size: 12.5px; color: #cbd5e1; }
.u-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.u-timer { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.u-timer[data-tone="ok"] { color: var(--ok); }
.u-timer[data-tone="warn"] { color: var(--warn); }
.u-timer[data-tone="crit"] { color: var(--crit); font-weight: 700; }

/* ---------- Responsivo (iPad vertical / pantallas angostas) ---------- */
@media (max-width: 1100px) {
  .brand-text span { display: none; }
  .pill-btn span { display: none; }
  .pill-btn { padding: 0 11px; }
  #layers-panel { right: calc(var(--gap) + var(--safe-r)); }
}
@media (max-width: 900px) {
  :root { --top-h: 56px; }
  .brand { display: none; }
  .topbar { gap: 8px; padding: 0 8px; }
  .sim { margin: 0; gap: 8px; }
  .actions { margin-left: auto; gap: 6px; }
  .clock-box { min-width: 0; }
  .clock { font-size: 14px; }
  .sim-status { display: none; }
  .speed button { min-width: 34px; }
  #kpi-panel { left: calc(var(--gap) + var(--safe-l)); width: auto; top: auto; height: 52vh; }
  #kpi-panel.closed { transform: translateY(calc(100% + 120px)); }
  #inspector { width: auto; right: calc(var(--gap) + var(--safe-r)); max-height: 46vh; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 560px) {
  .speed button[data-speed="8"] { display: none; }
  .speed button { min-width: 30px; }
  .clock { font-size: 13px; }
  .icon-btn, .pill-btn { width: 40px; height: 40px; padding: 0; justify-content: center; }
  .cam-btn { min-width: 68px; }
  #btn-fullscreen { display: none; }
}
@media (max-width: 400px) {
  .speed button[data-speed="4"] { display: none; }
  .topbar { gap: 6px; }
  .clock { font-size: 12px; }
}
[hidden] { display: none !important; }

.brand-text .author{font-style:normal;color:#5eead4;font-weight:600}

/* Inventario del CEDIS */
.inv-list { display: flex; flex-direction: column; gap: 6px; }
.inv-row { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06); font-size: 12.5px; }
.inv-row .u-head { display: flex; gap: 8px; align-items: center; } .inv-row .u-head b { flex: 1; } .inv-row time { font-variant-numeric: tabular-nums; font-weight: 700; }
.inv-row .u-unit, .inv-row .u-item { color: var(--muted, #94a3b8); }

/* ---------- Contratos (contratos-ui.js) ---------- */
.ct-list { display: grid; gap: 8px; }
.ct-card { border: 1px solid var(--line); border-radius: 11px; background: rgba(255, 255, 255, 0.03); overflow: hidden; }
.ct-card.open { border-color: var(--line-strong); }
.ct-head { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 9px; padding: 10px 10px 6px; cursor: pointer; }
.ct-title { display: flex; flex-direction: column; min-width: 0; }
.ct-title b { font-size: 13.5px; }
.ct-title span { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px currentColor; color: var(--ok); }
.ct-dot.warn { background: var(--warn); color: var(--warn); }
.ct-dot.accent { background: #f97316; color: #f97316; }
.ct-dot.crit { background: var(--crit); color: var(--crit); animation: ct-blink 1s ease-in-out infinite; }
@keyframes ct-blink { 50% { opacity: 0.35; } }
.ct-bolsa { padding: 0 10px 10px 31px; display: grid; gap: 4px; }
.ct-bolsa span { font-size: 11px; color: var(--faint); }
.ct-body { padding: 4px 10px 10px; display: grid; gap: 5px; border-top: 1px solid var(--line); }
.ct-body .kv { font-size: 12px; gap: 10px; }
.ct-body .kv b { text-align: right; }
.ct-proc { margin: 4px 0; padding: 8px 10px; border-radius: 9px; border-left: 3px solid var(--crit); background: rgba(248, 113, 113, 0.09); font-size: 12px; line-height: 1.45; color: #e2c4c4; }
.ct-os { margin-top: 6px; padding: 8px; border-radius: 9px; background: rgba(0, 0, 0, 0.18); }
.ct-os.focus { outline: 1px solid var(--accent); }
.ct-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; font-size: 12px; }
.ct-row span { color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-tab { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 11.5px; }
.ct-tab th { text-align: left; color: var(--faint); font-weight: 600; padding: 2px 4px; }
.ct-tab td { padding: 4px; border-top: 1px solid var(--line); vertical-align: middle; }
.ct-tab .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ct-tab .chip { height: 19px; font-size: 10.5px; padding: 0 6px; }
.ct-trucks { display: grid; gap: 6px; }
.ct-truck { padding: 8px; border-radius: 9px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); }
.ct-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.35; }
.ct-sub .crit { color: var(--crit); }
.ct-log li { grid-template-columns: 82px 1fr; }
.ct-nota { font-size: 11px; color: var(--faint); line-height: 1.4; margin: 8px 0 0; }

/* ---------- Marbetes (inventario físico) */
.mb-p { font-size: 12px; line-height: 1.45; margin: 6px 0 8px; }
.mb-p input { width: 72px; height: 24px; background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 6px; color: var(--text); padding: 0 6px; font-size: 12px; }
.mb-l { display: block; font-size: 11.5px; color: var(--muted); margin: 8px 0 5px; }
.mb-sel { width: 100%; height: 34px; background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 8px; color: var(--text); padding: 0 8px; font-size: 12.5px; margin-bottom: 8px; }
.mb-seg { width: 100%; } .mb-seg button { flex: 1; }
.mb-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.mb-row .chip, .mb-chips .chip { cursor: pointer; border: 0; }
.mb-chips { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; align-items: flex-start; }
.mb-chips .chip { height: auto; padding: 4px 9px; white-space: normal; text-align: left; }
.tile.ok b { color: var(--ok); } .tile.warn b { color: var(--warn); } .tile.crit b { color: var(--crit); }
.tiles + .pill-btn.wide, .card > .pill-btn.wide { margin-top: 10px; width: 100%; justify-content: center; }
.mb-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: var(--muted); margin-top: 8px; }
.mb-legend i { display: inline-block; width: 10px; height: 7px; border-radius: 2px; margin-right: 4px; }
.mb-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; padding: 7px 0; border-top: 1px solid var(--line); text-align: left; }
.mb-item b { display: block; font-size: 12.5px; font-weight: 600; } .mb-item small { display: block; font-size: 11px; color: var(--faint); }
.mb-item em { font-style: normal; flex: none; }
.mb-bar { display: grid; grid-template-columns: 1fr 70px 30px; gap: 8px; align-items: center; font-size: 12px; padding: 3px 0; }
.mb-bar i { height: 7px; border-radius: 4px; background: rgba(255,255,255,.06); overflow: hidden; display: block; }
.mb-bar i b { display: block; height: 100%; background: var(--warn); }
.mb-bar em { font-style: normal; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.mb-alert { border-left: 3px solid var(--crit); padding: 6px 9px; background: rgba(248,113,113,.08); border-radius: 6px; margin-bottom: 6px; font-size: 12px; }
.mb-alert b { display: block; color: var(--crit); }
.mb-cmp div { padding: 7px 0; border-top: 1px solid var(--line); font-size: 12px; } .mb-cmp div.sel b { color: var(--accent); }
.mb-cmp b { display: block; } .mb-cmp span { color: var(--muted); }
/* el marbete: cartoncillo con dos partes y línea perforada */
.mb-tag { background: #f5f1e6; color: #1f2937; border-radius: 6px; padding: 10px 12px; font-size: 12px; box-shadow: 0 2px 10px rgba(0,0,0,.4); }
.mb-tag .mb-top { display: flex; justify-content: space-between; border-bottom: 2px solid #7f1d1d; padding-bottom: 5px; margin-bottom: 6px; color: #7f1d1d; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.mb-tag .mb-kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; }
.mb-tag .mb-kv span { color: #6b7280; } .mb-tag .mb-kv b { font-weight: 650; }
.mb-tag .mb-counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.mb-tag .mb-c { border: 1px solid #d6cfbd; border-radius: 4px; padding: 5px; }
.mb-tag .mb-c span { display: block; font-size: 10px; color: #6b7280; text-transform: uppercase; } .mb-tag .mb-c b { font-size: 15px; } .mb-tag .mb-c small { display: block; font-size: 10px; color: #6b7280; font-style: italic; }
.mb-tag .mb-perf { border-top: 2px dashed #a8a29e; margin: 8px -12px; }
.mb-tag .pill-btn { margin-top: 10px; width: 100%; justify-content: center; background: #1f2937; color: #e6edf3; }
.tile b { white-space: nowrap; }
