/* Panel de administración — sobre los tokens de /brand/brand.css */
:root {
  --bg: #F4F3F8;
  --line: #E2E0EA;
  --muted: #5B5870;
  --ok: #06A4D4;
  --warn: #E0A100;
  --bad: #C0264B;
  --bad-bg: #FCE8EE;
  --warn-bg: #FFF4D6;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--q-font);
  font-weight: 300;
  font-size: 16px;
  color: var(--q-negro);
  background: var(--bg);
}
h1, h2, h3 { margin: 0; font-weight: 700; color: var(--q-indigo); }
h2 { font-size: 20px; }
h2 small { font-weight: 300; font-size: 14px; color: var(--muted); margin-left: 6px; }
.muted { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
button { font-family: inherit; }

/* ---------- Ingreso ---------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 16px; background: var(--q-indigo) url("/brand/assets/img/fondo-degradado.jpg") center / cover no-repeat; }
.gate__card { width: min(400px, 100%); background: var(--q-blanco); border-radius: 24px; padding: 28px 24px; box-shadow: 0 20px 50px rgba(3, 3, 3, .3); }
.gate__back { display: block; margin-bottom: 10px; font-size: 14px; color: var(--muted); text-decoration: none; }
.gate__back:hover { text-decoration: underline; }
.gate__logo { width: 44px; height: 44px; }
.gate__title { font-size: 26px; margin-top: 6px; }
.gate__sub { margin: 2px 0 20px; color: var(--muted); }

/* ---------- Controles ---------- */
.fld { display: block; margin-bottom: 14px; }
.fld > span { display: block; font-weight: 500; font-size: 15px; margin-bottom: 5px; }
.fld small { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], select {
  width: 100%;
  font: 300 16px/1.3 var(--q-font);
  padding: 10px 12px;
  border: 1.5px solid #D5D3DE;
  border-radius: 10px;
  background: #FAFAFC;
  color: var(--q-negro);
}
input:focus, select:focus { outline: none; border-color: var(--q-azul-gota); background: var(--q-blanco); }
.fld--inline { margin: 0; min-width: 150px; flex: 1 1 150px; }
.fld--inline > span { font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 3px; }
.check { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--q-azul-gota); }

.btn { font: 700 16px var(--q-font); color: var(--q-blanco); background: var(--q-azul-gota); border: 0; border-radius: 999px; padding: 12px 22px; cursor: pointer; min-height: 44px; transition: filter .15s; }
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn--ghost { background: transparent; color: var(--q-indigo); border: 1.5px solid var(--q-indigo); }
.btn--light { background: rgba(255, 255, 255, .14); color: var(--q-blanco); }
.btn--sm { padding: 6px 14px; min-height: 36px; font-size: 14px; }
.btn--danger { background: var(--bad); }
.gate .btn { width: 100%; margin-top: 4px; }

.alert { border-radius: 10px; padding: 10px 12px; font-size: 15px; margin: 0 0 14px; }
.alert--error { background: var(--bad-bg); color: #8A1235; }
.alert--warn { background: var(--warn-bg); color: #6B4E00; margin-top: 14px; }

/* ---------- Barra superior y tabs ---------- */
.bar { background: var(--q-indigo); color: var(--q-blanco); display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 12px 16px; position: sticky; top: 0; z-index: 5; }
.bar__brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.bar__brand img { height: 34px; width: auto; }
.bar__brand span { font-weight: 700; font-size: 17px; }
.bar__brand em { font-style: normal; font-weight: 300; color: var(--q-cyan-texto); margin-left: 6px; }
.tabs { display: flex; gap: 4px; order: 3; width: 100%; overflow-x: auto; }
.tab { background: none; border: 0; color: rgba(255, 255, 255, .75); font-size: 16px; font-weight: 500; padding: 10px 14px; border-radius: 10px 10px 0 0; cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--q-blanco); background: rgba(255, 255, 255, .12); box-shadow: inset 0 -3px 0 var(--q-cyan-texto); }
@media (min-width: 760px) { .tabs { order: 0; width: auto; } }
@media (max-width: 480px) { .bar__brand em { display: none; } }

.page { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; }
.section-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* ---------- Filtros ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
@media (min-width: 900px) { .chips { width: auto; } }
.chip { border: 1.5px solid var(--line); background: var(--q-blanco); color: var(--q-indigo); border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 500; cursor: pointer; min-height: 38px; }
.chip[aria-pressed="true"] { background: var(--q-indigo); border-color: var(--q-indigo); color: var(--q-blanco); }

/* ---------- Tarjetas ---------- */
.card { background: var(--q-blanco); border-radius: 18px; padding: 18px; box-shadow: 0 2px 10px rgba(38, 31, 73, .06); }
.card h2 { margin-bottom: 12px; }
.card--flush { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); margin-top: 16px; }
.grid > *, .cycle > * { min-width: 0; }   /* un hijo ancho (mapa de calor) no debe estirar la columna */
@media (min-width: 900px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid__wide { grid-column: 1 / -1; } }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

/* Ciclo */
.cycle { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .cycle { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; } }
.cycle__title { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.cycle__big { font-size: 30px; font-weight: 700; color: var(--q-indigo); line-height: 1.1; }
.cycle__big small { font-size: 16px; font-weight: 300; color: var(--muted); }
.track { position: relative; height: 14px; border-radius: 999px; background: #EFEEF4; margin: 12px 0 6px; overflow: visible; }
.track__fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--ok); }
.track__fill[data-state="warning"] { background: var(--warn); }
.track__fill[data-state="blocked"] { background: var(--bad); }
.track__mark { position: absolute; top: -5px; bottom: -5px; width: 3px; background: var(--q-indigo); border-radius: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--muted); }
.legend b { color: var(--q-negro); font-weight: 500; }
.cap { display: flex; gap: 8px; align-items: flex-end; margin-top: 4px; }
.cap .fld { margin: 0; flex: 1; }

/* KPIs */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); margin-top: 16px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--q-blanco); border-radius: 16px; padding: 14px 16px; box-shadow: 0 2px 10px rgba(38, 31, 73, .06); }
.kpi__label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi__value { font-size: 26px; font-weight: 700; color: var(--q-indigo); line-height: 1.15; margin-top: 2px; }
.kpi__value--bad { color: var(--bad); }
.kpi__note { font-size: 13px; color: var(--muted); margin-top: 2px; }
.split { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: #EFEEF4; margin-top: 8px; }
.split span:nth-child(1) { background: var(--ok); }
.split span:nth-child(2) { background: var(--bad); }
.split span:nth-child(3) { background: #B7B4C6; }

/* Gráficos */
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid-line { stroke: #EFEEF4; stroke-width: 1; }
.chart text { font: 300 11px var(--q-font); fill: var(--muted); }
.chart .area { fill: rgba(6, 164, 212, .14); }
.chart .line { fill: none; stroke: var(--ok); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--q-blanco); stroke: var(--ok); stroke-width: 2; }
.chart .dot--err { stroke: var(--bad); }
.hbars { display: grid; gap: 10px; }
.hbar__top { display: flex; justify-content: space-between; gap: 8px; font-size: 15px; }
.hbar__top b { font-weight: 500; overflow-wrap: anywhere; }
.hbar__top span { color: var(--muted); font-size: 14px; white-space: nowrap; }
.hbar__track { height: 10px; border-radius: 999px; background: #EFEEF4; margin-top: 4px; overflow: hidden; }
.hbar__fill { height: 100%; border-radius: 999px; background: var(--ok); min-width: 3px; }
.heat-wrap { overflow-x: auto; padding-bottom: 4px; }
.heat { display: grid; grid-template-columns: 34px repeat(24, minmax(15px, 1fr)); gap: 3px; min-width: 520px; align-items: center; font-size: 11px; color: var(--muted); }
@media (max-width: 600px) {   /* en el celular entra completo, sin scroll lateral */
  .heat { grid-template-columns: 26px repeat(24, minmax(0, 1fr)); gap: 2px; min-width: 0; font-size: 10px; }
  .heat__hour { overflow: visible; white-space: nowrap; }
}
.heat__cell { aspect-ratio: 1; border-radius: 4px; background: #EFEEF4; }
@media (max-width: 600px) { .heat__cell { border-radius: 2px; } }
.heat__hour { text-align: center; }

/* Riesgo */
.risk { display: grid; gap: 10px; }
.risk__row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.risk__row b { font-weight: 500; }

/* ---------- Usuarios ---------- */
.users { display: grid; gap: 12px; }
.user { background: var(--q-blanco); border-radius: 16px; padding: 16px; box-shadow: 0 2px 10px rgba(38, 31, 73, .06); display: grid; gap: 12px; }
@media (min-width: 900px) { .user { grid-template-columns: 1.1fr 1.6fr auto; align-items: center; gap: 24px; } }
.user__name { font-weight: 700; font-size: 18px; color: var(--q-indigo); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.user__mail { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.user__meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.usage__top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; flex-wrap: wrap; }
.usage__top b { font-weight: 500; }
.usage__top span { color: var(--muted); }
.user__actions { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #E8F7FC; color: #05708F; white-space: nowrap; }
.badge--warning { background: var(--warn-bg); color: #6B4E00; }
.badge--blocked, .badge--error { background: var(--bad-bg); color: #8A1235; }
.badge--off, .badge--cancelled { background: #EFEEF4; color: var(--muted); }

/* ---------- Historial ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 760px; }
th { background: var(--q-indigo); color: var(--q-blanco); text-align: left; font-weight: 700; padding: 10px 12px; position: sticky; top: 0; white-space: nowrap; }
td { padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td:first-child { white-space: nowrap; }
tr.is-failed td { background: #FFF8FA; }
.err-detail { color: #8A1235; font-size: 13px; margin-top: 3px; overflow-wrap: anywhere; }
.sub { color: var(--muted); font-size: 13px; }

/* ---------- Diálogos ---------- */
.modal { border: 0; border-radius: 22px; padding: 24px 22px; width: min(460px, calc(100vw - 24px)); box-shadow: 0 24px 60px rgba(3, 3, 3, .4); color: var(--q-negro); }
.modal::backdrop { background: rgba(38, 31, 73, .7); }
.modal h2 { margin-bottom: 14px; }
.modal form { margin: 0; }
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.secret { display: flex; gap: 8px; align-items: center; background: #F4F3F8; border-radius: 12px; padding: 10px 12px; margin-top: 12px; }
.secret code { flex: 1; font: 700 20px/1.2 ui-monospace, Consolas, monospace; letter-spacing: .04em; overflow-wrap: anywhere; color: var(--q-indigo); }

/* Datos de demostración */
.section-head__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.modal--wide { width: min(640px, calc(100vw - 24px)); }
.modal--wide p { margin: 0 0 12px; }
.demo-table { min-width: 0; margin: 4px 0 14px; }
.demo-table th { position: static; }
.demo-table td { overflow-wrap: anywhere; }
.demo-table code { font: 500 13px ui-monospace, Consolas, monospace; color: var(--q-indigo); }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.btn--ghost { color: var(--q-indigo); }

/* Contraseña con botón Mostrar / Ocultar */
.pw { position: relative; }
.pw input { padding-right: 92px; }
.pw__toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; padding: 8px 10px; border-radius: 8px; cursor: pointer;
  font: 500 14px var(--q-font); color: var(--q-azul-gota);
}
.pw__toggle:hover { background: #E8F7FC; }
.pw__toggle:focus-visible { outline: 2px solid var(--q-azul-gota); }
