/* Gambito — panel administrativo */
.admin-page {
  --series-1: #3987e5;   /* azul  */
  --series-2: #d95926;   /* naranja */
  --series-3: #199e70;   /* aqua */
  --grid: #34312d;
}
.brand small { font-weight: 500; color: var(--muted); font-size: 14px; margin-left: 6px; }
.updated { color: var(--muted); font-size: 12px; align-self: center; margin-right: 4px; white-space: nowrap; }
.select {
  height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font: inherit; font-weight: 600;
}
a.btn { text-decoration: none; }

.admin { max-width: 1320px; margin: 0 auto; padding: 20px 16px 48px; display: flex; flex-direction: column; gap: 16px; }
.gate { display: grid; place-items: center; min-height: 60vh; }
.card.login { width: min(400px, 100%); padding: 24px; }
.card.login h2 { margin: 0 0 6px; }
.card.login .btn { margin-top: 18px; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25); min-width: 0;
}
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card h3 { margin: 0; font-size: 15px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi .k-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.kpi .k-value { font-size: 30px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi .k-sub b { color: var(--text); }
.kpi.live .k-value::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #0ca30c; margin-right: 8px; vertical-align: middle; box-shadow: 0 0 0 4px rgba(12,163,12,.2); }

/* Gráficas */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text, .chart text { fill: var(--muted); font-size: 11px; font-family: system-ui, sans-serif; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .bar { fill: var(--series-1); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .bar, .chart .bar.hover { filter: brightness(1.25); }
.empty-chart { color: var(--muted); font-size: 13px; padding: 40px 0; text-align: center; }

.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 120px 1fr 44px; align-items: center; gap: 10px; font-size: 13px; }
.hbar .lbl { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar .track { height: 14px; border-radius: 4px; background: var(--bg2); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }
.hbar .val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.stack { display: flex; height: 22px; border-radius: 4px; overflow: hidden; gap: 2px; background: var(--panel); margin: 6px 0 14px; }
.stack div { height: 100%; }
.stack div:first-child { border-radius: 4px 0 0 4px; }
.stack div:last-child { border-radius: 0 4px 4px 0; }
.legend { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.legend .row { display: flex; align-items: center; gap: 8px; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.legend .row span:last-child { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.legend small { color: var(--muted); font-weight: 500; margin-left: 4px; }

/* Tablas */
.table-wrap { overflow: auto; max-height: 420px; border-radius: 8px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  position: sticky; top: 0; background: var(--panel2); text-align: left; color: var(--muted);
  font-weight: 600; font-size: 12px; padding: 8px 10px; white-space: nowrap; z-index: 1;
}
table.data td { padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,.05); white-space: nowrap; }
table.data tr:hover td { background: rgba(255,255,255,.03); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .empty td { color: var(--muted); text-align: center; padding: 24px; white-space: normal; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.pill.ok { background: rgba(12,163,12,.15); color: #6fd36f; }
.pill.wait { background: rgba(250,178,25,.15); color: #fab219; }
.pill.bad { background: rgba(208,59,59,.18); color: #f08080; }
.pill.neutral { background: var(--panel2); color: var(--muted); }
.pos { color: #6fd36f; font-weight: 700; }
.neg { color: #f08080; font-weight: 700; }
.tools { display: flex; gap: 8px; align-items: center; }
.search { height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font: 13px system-ui, sans-serif; width: 220px; }
.badge-n { display: inline-block; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--panel2); color: var(--muted); font-size: 12px; text-align: center; margin-left: 4px; }
td .btn.small { height: 26px; }

.tooltip {
  position: fixed; z-index: 200; pointer-events: none; background: #f4f3ef; color: #1b1a17;
  padding: 6px 10px; border-radius: 6px; font-size: 12px; box-shadow: 0 6px 18px rgba(0,0,0,.4); white-space: nowrap;
}
.tooltip b { font-size: 14px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g2 { grid-template-columns: 1fr; }
  .updated { display: none; }
  .search { width: 150px; }
  .top-actions .lbl { display: none; }
}

/* ---------- v2: navegación, filtros, ficha de usuario, mapa de calor ---------- */
.subnav {
  position: sticky; top: var(--header); z-index: 15; display: flex; gap: 4px; overflow-x: auto;
  padding: 8px 16px; background: rgba(22,21,18,.92); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px);
}
.subnav a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 13px; padding: 7px 12px; border-radius: 8px; white-space: nowrap; }
.subnav a:hover { color: var(--text); background: var(--panel2); }
.subnav a.active { color: var(--text); background: var(--panel2); }
.sec-title { margin: 18px 0 0; font-size: 18px; scroll-margin-top: 120px; display: flex; align-items: center; gap: 8px; }
.sec-title::after { content: ''; flex: 1; height: 1px; background: var(--line); margin-left: 8px; }
.kpis.small .kpi { padding: 10px 14px; }
.kpis.small .k-value { font-size: 22px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--line); background: var(--bg2); color: var(--muted); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.chips button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.table-wrap.tall { max-height: 560px; }
table.clickable tbody tr { cursor: pointer; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.flag { font-size: 15px; }

.dialog.user-dlg { width: min(980px, calc(100vw - 32px)); }
.u-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.u-head .avatar.big { width: 64px; height: 64px; font-size: 36px; border-radius: 14px; }
.u-head h2 { margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.u-head .close { margin-left: auto; align-self: flex-start; }
.u-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.u-item { background: var(--bg2); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.u-item small { display: block; color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.u-item span { font-weight: 700; font-size: 13.5px; word-break: break-word; }
.u-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.u-action { background: var(--bg2); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.u-action h4 { margin: 0; font-size: 13px; }
.u-action .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0; }
.u-action select, .u-action input { height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 0 10px; font: inherit; flex: 1; min-width: 120px; }
.u-section { margin-top: 16px; }
.u-section h3 { font-size: 14px; margin: 0 0 8px; }

.heat { display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 2px; font-size: 10px; color: var(--muted); }
.heat .cell { aspect-ratio: 1; border-radius: 3px; background: var(--bg2); }
.heat .lbl { display: flex; align-items: center; }
.heat .hlbl { text-align: center; }
.heat-legend { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 11px; color: var(--muted); }
.heat-legend i { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }
.admin-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.05); font-size: 13.5px; }
#addAdminForm { margin-top: 12px; }
#addAdminForm input { flex: 1; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); padding: 0 10px; }

@media (max-width: 760px) {
  .u-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .u-actions { grid-template-columns: 1fr; }
  .heat { font-size: 8px; grid-template-columns: 26px repeat(24, minmax(0, 1fr)); }
}
