/* ── Design system (dark) — paleta validada dataviz ─────────────────────────── */
:root {
  --bg: #0d0d0d;            /* page plane */
  --surface: #16171c;      /* cards / panels */
  --surface-2: #1e2027;    /* raised / hover */
  --surface-3: #262932;
  --border: rgba(255,255,255,0.09);
  --border-2: rgba(255,255,255,0.14);
  --text: #ffffff;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;

  --series: #3987e5;       /* categorical slot 1 (blue) — para gráficos */
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --crit: #d03b3b;

  /* Marca Golem AI (golem pixel morado + brillo magenta) */
  --brand: #9a7cff; --brand-2: #e0569f; --brand-glow: rgba(154,124,255,.28);

  --tg: #3987e5; --wa: #199e70; --meta: #d55181; --twilio: #c98500; --instagram:#d55181; --messenger:#3987e5;

  --radius: 14px; --radius-sm: 9px;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.18);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; -webkit-font-smoothing: antialiased; }
h1,h2,h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
.dim { color: var(--muted); } .tiny { font-size: 11px; }
a { color: var(--series); }

/* minmax(0,1fr) — NO 1fr — para que la columna de contenido no se estire al
   min-content de un hijo ancho (tabla/gráfica) y desborde el viewport. */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); height: 100vh; }
.main { min-width: 0; }

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar { background: linear-gradient(180deg, rgba(154,124,255,.06), transparent 220px), var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 18px 14px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 4px; }
.logo-img { width: 38px; height: 38px; border-radius: 11px; box-shadow: 0 0 0 1px var(--border-2), 0 0 22px var(--brand-glow); image-rendering: auto; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.brand-name span { color: var(--brand-2); }
.brand-sub { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 2px; margin-top: 1px; }

.health-mini { display: flex; align-items: center; gap: 9px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; }
.health-mini .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 4px rgba(255,255,255,.04); }
.health-mini.good .dot { background: var(--good); box-shadow: 0 0 0 4px rgba(12,163,12,.15); }
.health-mini.warning .dot { background: var(--warn); box-shadow: 0 0 0 4px rgba(250,178,25,.15); }
.health-mini.critical .dot { background: var(--crit); box-shadow: 0 0 0 4px rgba(208,59,59,.15); }
.health-mini .txt { font-weight: 500; }

nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
nav button { display: flex; align-items: center; gap: 11px; background: transparent; border: none; color: var(--text-2); padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px; text-align: left; transition: background .12s, color .12s; }
nav button .ic { width: 16px; text-align: center; opacity: .7; }
nav button:hover { background: var(--surface-2); color: var(--text); }
nav button.active { background: linear-gradient(90deg, var(--brand-glow), var(--surface-2) 40%); color: var(--text); font-weight: 500; box-shadow: inset 2px 0 0 var(--brand); }
nav button.active .ic { color: var(--brand); opacity: 1; }

.sidebar-foot { padding: 8px 10px; border-top: 1px solid var(--border); }
.status { font-size: 12px; color: var(--muted); }
.status.ok { color: var(--good); } .status.err { color: var(--crit); }

/* ── Main ────────────────────────────────────────────────────────────────────── */
.main { overflow-y: auto; padding: 22px 28px 40px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.topbar h1 { font-size: 20px; }
.section-head h2 { font-size: 18px; } .section-head p { margin: 4px 0 0; font-size: 13px; }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.row-end { display: flex; justify-content: flex-end; margin-top: 16px; }
.actions { display: flex; gap: 8px; flex-shrink: 0; }

.tab { display: none; animation: fade .18s ease; }
.tab.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-2); padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-family: inherit; transition: border-color .12s, background .12s, transform .05s; }
.btn:hover { border-color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-color: transparent; font-weight: 600; box-shadow: 0 2px 14px var(--brand-glow); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--crit); border-color: transparent; background: transparent; padding: 6px 10px; }
.btn.danger:hover { background: rgba(208,59,59,.12); border-color: transparent; }

/* ── Cards / tiles ───────────────────────────────────────────────────────────── */
.grid { display: grid; gap: 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.tile .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; margin-bottom: 8px; }
.tile .value { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; line-height: 1; }
.tile .sub { color: var(--text-2); font-size: 12px; margin-top: 6px; }
.tile .value .unit { font-size: 15px; color: var(--muted); font-weight: 500; margin-left: 3px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card h3 { font-size: 14px; margin-bottom: 6px; }
.card label { display: block; margin: 12px 0 6px; color: var(--muted); font-size: 12px; }
.chart-card { grid-column: span 1; }
.chart-row { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; margin-bottom: 20px; }
.card-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.card-title h3 { font-size: 13px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.card-title .hint { color: var(--muted); font-size: 11px; }

/* ── Health hero ─────────────────────────────────────────────────────────────── */
.hero { display: flex; align-items: center; gap: 20px; padding: 22px 24px; margin-bottom: 20px; border-radius: var(--radius); border: 1px solid var(--border); background:
  radial-gradient(130% 150% at 0% 0%, var(--brand-glow), transparent 55%), var(--surface); box-shadow: var(--shadow); }
.hero .beacon { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; flex-shrink: 0; }
.hero.good .beacon { background: rgba(12,163,12,.14); color: var(--good); box-shadow: 0 0 0 6px rgba(12,163,12,.06); }
.hero.warning .beacon { background: rgba(250,178,25,.14); color: var(--warn); box-shadow: 0 0 0 6px rgba(250,178,25,.06); }
.hero.critical .beacon { background: rgba(208,59,59,.14); color: var(--crit); box-shadow: 0 0 0 6px rgba(208,59,59,.06); }
.hero.idle .beacon { background: var(--surface-2); color: var(--muted); }
.hero .h-main { font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }
.hero .h-sub { color: var(--text-2); font-size: 13px; margin-top: 3px; }
.hero .h-stats { margin-left: auto; display: flex; gap: 26px; text-align: right; }
.hero .h-stats .n { font-size: 22px; font-weight: 650; } .hero .h-stats .l { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }

/* ── Tables ──────────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
td.mono, .mono { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.tbl-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }

.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 500; background: var(--surface-3); border: 1px solid var(--border); }
.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.telegram { color: var(--tg); } .tag.whatsapp { color: var(--wa); } .tag.meta { color: var(--meta); } .tag.twilio { color: var(--twilio); }
.tag.instagram { color: var(--instagram); } .tag.messenger { color: var(--messenger); }

/* status pill in tables */
.stpill { display: inline-flex; align-items: center; gap: 7px; }
.stpill .d { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.stpill.online .d { background: var(--good); box-shadow: 0 0 0 3px rgba(12,163,12,.15); }
.stpill.stopped .d { background: var(--muted); }
.stpill.stale .d { background: var(--warn); box-shadow: 0 0 0 3px rgba(250,178,25,.15); }
.stpill.none .d { background: var(--baseline); }

/* inline edit controls */
select, input { background: var(--bg); border: 1px solid var(--border-2); color: var(--text); padding: 7px 10px; border-radius: var(--radius-sm); font-size: 13px; font-family: var(--sans); outline: none; transition: border-color .12s, box-shadow .12s; }
select:focus, input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
td select, td input { padding: 5px 8px; font-size: 12px; }
td select:hover, td input:hover { border-color: var(--border-2); }

/* ── Split panels (bases / postgres) ─────────────────────────────────────────── */
.split { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.panel.grow { min-height: 320px; }
.panel .item { padding: 9px 11px; border-radius: var(--radius-sm); cursor: pointer; transition: background .1s; }
.panel .item:hover { background: var(--surface-2); }
.panel .item.active { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--series); }
.panel .item small { color: var(--muted); display: block; margin-top: 2px; }
.query-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.query-bar input { flex: 1; font-family: var(--mono); }
.result { overflow: auto; max-height: 62vh; border-radius: var(--radius-sm); }
.result .meta { color: var(--muted); font-size: 12px; margin-bottom: 8px; }

/* ── Charts ──────────────────────────────────────────────────────────────────── */
.chart { width: 100%; min-height: 10px; }
.chart .apexcharts-canvas { margin: 0 auto; }
/* Tooltip / menús de ApexCharts con la paleta del panel */
.apexcharts-tooltip.apexcharts-theme-dark, .apexcharts-tooltip { background: var(--surface-2) !important; border: 1px solid var(--border-2) !important; box-shadow: var(--shadow) !important; color: var(--text) !important; }
.apexcharts-tooltip-title { background: var(--surface-3) !important; border-bottom: 1px solid var(--border) !important; font-weight: 600 !important; }
.apexcharts-xaxistooltip, .apexcharts-yaxistooltip { background: var(--surface-2) !important; border-color: var(--border-2) !important; color: var(--text) !important; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-2); }
.legend span i { width: 9px; height: 9px; border-radius: 3px; }

.tip { position: fixed; z-index: 50; background: #000; border: 1px solid var(--border-2); border-radius: 8px; padding: 8px 11px; font-size: 12px; pointer-events: none; box-shadow: 0 6px 20px rgba(0,0,0,.5); }
.tip.hidden { display: none; }
.tip b { color: var(--text); } .tip .k { color: var(--muted); }

/* ── Modal / misc ────────────────────────────────────────────────────────────── */
/* z-index alto: por encima de los th sticky (z-index:1), sidebar (30) y drawer (40). */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(8,8,10,.72); display: flex; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(5px); }
.modal-backdrop.hidden { display: none; }
.modal { background: var(--surface); border: 1px solid var(--border-2); border-radius: 16px; padding: 24px; width: 440px; max-width: 92vw; max-height: 90vh; overflow-y: auto; box-shadow: 0 24px 70px rgba(0,0,0,.6); }
.modal label { display: block; margin: 12px 0 5px; color: var(--muted); font-size: 12px; }
.modal input, .modal select { width: 100%; }
.x { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; }
.x:hover { color: var(--text); }
.error { color: var(--crit); font-size: 12.5px; margin-top: 10px; min-height: 16px; }
.empty { color: var(--muted); padding: 26px; text-align: center; font-size: 13px; }
h3.sec { font-size: 13px; color: var(--text-2); text-transform: uppercase; letter-spacing: .6px; margin: 24px 0 12px; }

/* Donut card layout (chart + legend) */
.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut-wrap .chart { flex: 0 0 240px; width: 240px; max-width: 55%; }
.legend { display: flex; flex-direction: column; gap: 9px; margin: 0; }
.legend span { display: inline-flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-2); }
.legend span i { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.legend span b { color: var(--text); margin-left: auto; font-variant-numeric: tabular-nums; }

/* Grupo por servidor (flota) */
.server-group { margin-bottom: 20px; }
.server-head { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; padding: 0 2px; }
.server-head .srv-ic { color: var(--brand); font-size: 15px; }
.server-head .srv-name { font-weight: 600; font-size: 14px; font-family: var(--mono); }
.server-head .srv-badge { margin-left: 8px; font-size: 11px; color: var(--muted); padding: 2px 9px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--border); }
.server-head .srv-badge.up { color: var(--good); }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td:nth-child(4) { color: var(--brand); }

/* ── Servidores remotos (flota) ──────────────────────────────────────────────── */
.servers-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 20px; box-shadow: var(--shadow); }
.servers-card .sc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.servers-card .sc-head h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-2); }
.srv-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.srv-row:first-of-type { border-top: none; }
.srv-row .d { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.srv-row.up .d { background: var(--good); box-shadow: 0 0 0 3px rgba(12,163,12,.15); }
.srv-row.down .d { background: var(--crit); }
.srv-row .srv-info { flex: 1; }
.srv-row .srv-info b { font-size: 13px; } .srv-row .srv-info small { display: block; color: var(--muted); font-family: var(--mono); font-size: 11px; }
.srv-row .srv-actions { display: flex; gap: 6px; }

/* ── Drawer de detalle ───────────────────────────────────────────────────────── */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(2px); z-index: 40; display: flex; justify-content: flex-end; }
.drawer-backdrop.hidden { display: none; }
.drawer { width: 520px; max-width: 94vw; height: 100%; background: var(--surface); border-left: 1px solid var(--border-2); box-shadow: -8px 0 40px rgba(0,0,0,.5); overflow-y: auto; padding: 22px 24px; animation: slideIn .2s ease; }
@keyframes slideIn { from { transform: translateX(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer .d-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.drawer .d-title { font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.drawer .d-role { color: var(--text-2); font-size: 13px; margin: 8px 0 18px; line-height: 1.5; }
.drawer .d-sec { margin: 20px 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--brand-2); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.drawer .d-sec .n { color: var(--muted); font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 3px 10px; border-radius: 20px; font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.kv { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.kv .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.blist { display: flex; flex-direction: column; gap: 8px; }
.blist .bi { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.blist .bi .s { font-weight: 600; font-size: 12.5px; }
.blist .bi .g { color: var(--text-2); font-size: 12px; margin-top: 3px; line-height: 1.45; }
.doclist, .chatlist { display: flex; flex-direction: column; }
.doclist .di, .chatlist .ci { padding: 8px 10px; border-radius: 8px; font-size: 12.5px; display: flex; justify-content: space-between; gap: 10px; }
.doclist .di:hover, .chatlist .ci:hover { background: var(--surface-2); }
.chatlist .ci { cursor: pointer; }
.chatlist .ci small { color: var(--muted); font-family: var(--mono); }
.chat-msgs { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.chat-msgs .m { padding: 8px 11px; border-radius: 10px; font-size: 12.5px; max-width: 88%; line-height: 1.4; }
.chat-msgs .m.inbound { background: var(--surface-2); align-self: flex-start; border: 1px solid var(--border); }
.chat-msgs .m.outbound { background: linear-gradient(135deg, rgba(154,124,255,.18), rgba(224,86,159,.14)); align-self: flex-end; }
.chat-msgs .m .who { font-size: 10px; color: var(--muted); margin-bottom: 2px; }

/* ── Credenciales & Keys (F1) ─────────────────────────────────────────────────── */
.keys { display: flex; flex-direction: column; gap: 8px; }
.keyrow { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.kr-label { font-size: 12.5px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 7px; }
.kr-body { display: flex; align-items: center; gap: 8px; }
.kr-val { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12px; color: var(--text-2); background: var(--bg); border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px; overflow-x: auto; white-space: nowrap; }
.kr-actions { display: flex; gap: 5px; flex-shrink: 0; }
.btn.tiny { padding: 5px 8px; font-size: 12px; line-height: 1; border-radius: 7px; }
.chip.tiny { font-size: 9.5px; padding: 2px 7px; text-transform: uppercase; letter-spacing: .4px; }
.chip.tiny.warn { background: rgba(250,178,25,.14); border-color: rgba(250,178,25,.35); color: var(--warn); }

/* ── Gestión de conocimiento (KB) por golem ───────────────────────────────────── */
.kbmanage { display: flex; flex-direction: column; gap: 10px; }
.kbm-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kbm-row select { flex: 1; min-width: 130px; }
.kbm-add { display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 11px; }
.kbm-add textarea { width: 100%; background: var(--bg); border: 1px solid var(--border-2); color: var(--text); border-radius: var(--radius-sm); padding: 8px 10px; font-family: var(--sans); font-size: 13px; line-height: 1.5; resize: vertical; outline: none; transition: border-color .12s; }
.kbm-add textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }

/* ── Vista completa e independiente de un golem ───────────────────────────────── */
.gv-hero { display: flex; justify-content: space-between; align-items: center; gap: 16px; background: linear-gradient(135deg, rgba(154,124,255,.12), var(--surface) 62%); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 18px; box-shadow: var(--shadow); }
.gv-hero-l { display: flex; align-items: center; gap: 14px; min-width: 0; }
.gv-back { padding: 9px 13px; font-size: 16px; line-height: 1; }
.gv-hero-id { min-width: 0; }
.gv-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.gv-sub2 { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.gv-hero-acts { display: flex; gap: 8px; flex-shrink: 0; }
.gv-tiles { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); margin-bottom: 18px; }
.gv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.gv-card { display: flex; flex-direction: column; }
.gv-cbody { display: flex; flex-direction: column; }
.gv-sub { margin: 16px 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.gv-card .card-title { margin-bottom: 12px; }

/* ── Login (pantalla de acceso por token) ────────────────────────────────────── */
.login-backdrop { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(1200px 600px at 50% -10%, rgba(154,124,255,.10), transparent), rgba(8,8,10,.9); backdrop-filter: blur(7px); }
.login-backdrop.hidden { display: none; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px 26px; box-shadow: var(--shadow); }
.login-card .logo-img { width: 56px; height: 56px; margin-bottom: 6px; }
.login-brand { font-size: 22px; }
.login-hint { margin: 8px 0 2px; font-size: 12.5px; }
.login-card input { width: 100%; margin: 12px 0 4px; background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text); border-radius: var(--radius-sm); padding: 12px 13px; font-family: var(--mono); font-size: 13px; }
.login-card input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.login-go { width: 100%; padding: 11px; }
.login-card .error { text-align: center; }

/* ── Responsive (móvil / tablet) ─────────────────────────────────────────────── */
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); height: auto; min-height: 100dvh; }
  .main { min-width: 0; overflow-x: hidden; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding: 11px 13px; border-right: none; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; background: var(--surface); }
  .sidebar .brand { flex: 1 1 auto; }
  .health-mini { order: 2; flex: 0 0 auto; padding: 7px 10px; }
  nav { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 4px; flex-basis: 100%; order: 3; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  nav button { white-space: nowrap; padding: 8px 12px; }
  nav button.active { box-shadow: inset 0 -2px 0 var(--brand); background: var(--surface-2); }
  .sidebar-foot { display: none; }
  .main { padding: 16px 14px 34px; }
  .topbar { margin-bottom: 16px; }
  .topbar h1 { font-size: 18px; }
  .row-between { flex-direction: column; align-items: stretch; }
  .actions { flex-wrap: wrap; }
  .split { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr; }
  .query-bar { flex-wrap: wrap; }
  .query-bar input, .query-bar select, .query-bar .btn { flex: 1 1 100%; }
  .tbl-wrap { overflow-x: auto; }
  table { font-size: 12px; }
  .drawer { width: 100%; max-width: 100%; }
  .result { max-height: 50vh; }

  /* Resumen: KPIs 2-col, hero y gráficas apiladas (evita desborde horizontal) */
  .tiles { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tile { padding: 13px 14px; }
  .tile .value { font-size: 24px; }
  .hero { flex-wrap: wrap; padding: 18px; gap: 14px 16px; }
  .hero .h-stats { margin-left: 0; width: 100%; justify-content: space-between; gap: 12px; text-align: left; }
  .chart-row { grid-template-columns: 1fr; }
  .card { min-width: 0; }
  .donut-wrap { flex-direction: column; align-items: center; }
  .donut-wrap .chart { flex: none; width: 100%; max-width: 300px; margin: 0 auto; }
  .chart svg { max-width: 100%; }
  /* Vista completa de golem en móvil: una columna, hero apilado */
  .gv-grid { grid-template-columns: 1fr; }
  .gv-hero { flex-direction: column; align-items: stretch; gap: 12px; padding: 16px; }
  .gv-tiles { grid-template-columns: repeat(2, 1fr); }
  /* red de seguridad: nada empuja el ancho del viewport */
  html, body { overflow-x: hidden; }
}
