/* VIDA 2026 — portal de sala de control. Modo oscuro, mobile-first, sin frameworks. */

/* ── Fuentes de marca ─────────────────────────────────────────── */
@font-face {
  font-family: "Vida BC Mikser";
  src: url("/static/fonts/subset-Vida-BCMikser-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Vida BC Mikser";
  src: url("/static/fonts/subset-Vida-BCMikser-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Graphik";
  src: url("/static/fonts/subset-Graphik-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Graphik";
  src: url("/static/fonts/subset-Graphik-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

/* ── Base ─────────────────────────────────────────────────────── */
:root {
  --bg: #16181d;
  --surface: #202020;
  --surface-2: #262a31;
  --blue: #0c4da2;
  --blue-l: #71abf9;
  --green: #2e9935;
  --amber: #ffb224;
  --red: #e5484d;
  --text: #f1f1f1;
  --muted: #9aa3ad;
  --border: #2e323a;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Graphik", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
h1, h2, h3, .logo-text, .login-logo, .hero-total {
  font-family: "Vida BC Mikser", "Graphik", sans-serif;
}
h1 { font-size: 1.35rem; margin: 0 0 2px; font-weight: 700; }
h2 { font-size: .95rem; margin: 0 0 10px; font-weight: 700; letter-spacing: .02em;
     text-transform: uppercase; color: var(--muted); }
a { color: var(--blue-l); text-decoration: none; }
.muted { color: var(--muted); }
.green { color: var(--green); }
.blue { color: var(--blue-l); }
.red { color: var(--red); }
.amber { color: var(--amber); }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.wrap { word-break: break-word; }

/* ── Barra superior ───────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 2px solid var(--blue);
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo-text {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  letter-spacing: .04em;
}
.mainnav { display: flex; gap: 4px; }
.mainnav a {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 500;
}
.mainnav a.active, .mainnav a:hover { color: var(--text); background: var(--surface-2); }
.mainnav a.active { color: var(--blue-l); }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: .85rem; }
.username { font-weight: 500; }
.role-tag {
  background: var(--blue);
  color: #fff;
  border-radius: 20px;
  padding: 1px 9px;
  font-size: .72rem;
  letter-spacing: .03em;
}
.logout { color: var(--muted); }
.logout:hover { color: var(--red); }

/* ── Layout ───────────────────────────────────────────────────── */
main { padding: 14px; max-width: 1400px; margin: 0 auto; }
.grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
@media (min-width: 900px) {
  main { padding: 20px 24px; }
  .grid { grid-template-columns: repeat(12, 1fr); }
  .span-12 { grid-column: span 12; }
  .span-6 { grid-column: span 6; }
  .span-4 { grid-column: span 4; }
}

.dash-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.dash-head p { margin: 0; font-size: .85rem; }

/* ── Hero (total de jornada) ──────────────────────────────────── */
.hero { text-align: center; padding: 22px 14px; margin-bottom: 14px;
        border-color: var(--blue); }
.hero-total {
  font-size: clamp(3rem, 12vw, 6.5rem);
  font-weight: 700;
  line-height: 1.05;
  color: var(--blue-l);
  letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
}
.hero-kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 16px;
}
@media (min-width: 700px) { .hero-kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi-value { font-size: 1.35rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.kpi-label { font-size: .78rem; color: var(--muted); text-transform: uppercase;
             letter-spacing: .05em; }
.hero-extra { margin-top: 12px; font-size: .8rem; min-height: 1em; }

/* ── Badge de alertas ─────────────────────────────────────────── */
.alert-badge {
  background: var(--red);
  color: #fff;
  font-weight: 500;
  border-radius: 20px;
  padding: 6px 14px;
  white-space: nowrap;
  animation: pulse 2.5s infinite;
}
@keyframes pulse { 50% { opacity: .75; } }

/* ── Gráficas ─────────────────────────────────────────────────── */
.chart { width: 100%; height: 300px; }
.chart-tall { height: 380px; }
@media (max-width: 700px) { .chart-tall { height: 320px; } }

/* ── Tablas ───────────────────────────────────────────────────── */
.table-card { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { padding: 8px 12px; text-align: left; }
.table thead th {
  color: var(--muted);
  font-weight: 500;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
.table tbody tr { border-bottom: 1px solid var(--border); }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.footnote { padding: 10px 12px; font-size: .78rem; margin: 0; }

/* ── Stock: barra de % restante ───────────────────────────────── */
.pct-cell { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.progress {
  flex: 1 1 70px;
  height: 8px;
  min-width: 70px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
}
.progress-fill { height: 100%; }
.progress-fill.ok { background: var(--green); }
.progress-fill.warn { background: var(--amber); }
.progress-fill.crit { background: var(--red); }
.pct-num { font-size: .8rem; font-weight: 500; font-variant-numeric: tabular-nums;
           white-space: nowrap; }
.notice-card { margin-bottom: 14px; border-left: 3px solid var(--amber); }

/* ── Estados / etiquetas ──────────────────────────────────────── */
.status { font-weight: 500; font-size: .8rem; }
.status.ok { color: var(--green); }
.status.fail { color: var(--red); }
.status.pending { color: var(--blue-l); }
.level { font-weight: 500; font-size: .78rem; padding: 1px 8px; border-radius: 4px; }
.level-warning { color: #ffb224; background: rgba(255, 178, 36, .12); }
.level-error, .level-critical { color: var(--red); background: rgba(229, 72, 77, .12); }
.kind-tag {
  font-size: .75rem;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--blue-l);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
}

/* ── Pestañas y filtros ───────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border);
        margin-bottom: 14px; }
.tabs a {
  padding: 8px 16px;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a.active { color: var(--blue-l); border-bottom-color: var(--blue-l); }
.filterbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  font-size: .88rem;
}
.filterbar label { color: var(--muted); }
.total-tag { margin-left: auto; }
select, input[type="text"], input[type="password"], input[type="number"] {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
}
select:focus, input:focus { outline: 2px solid var(--blue); border-color: var(--blue); }

/* ── Ocupación manual (dashboard) ─────────────────────────────── */
.oc-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
           margin-left: auto; }
.oc-form input[type="number"] { width: 110px; }
.oc-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px; padding: 12px 16px;
  background: rgba(229, 72, 77, .16);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  color: var(--text); font-weight: 500;
  animation: pulse 1.6s infinite;
}
.oc-banner .oc-banner-close {
  margin-left: auto; background: none; border: none; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 1.25rem; line-height: 1;
  padding: 2px 6px;
}
.oc-banner .oc-banner-close:hover { color: var(--text); }

/* ── Alertas (cards) ──────────────────────────────────────────── */
.alert-list { display: flex; flex-direction: column; gap: 10px; }
.alert-card.open { border-left: 3px solid var(--red); }
.alert-card.resolved { border-left: 3px solid var(--green); opacity: .65; }
.alert-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
              font-size: .82rem; }
.alert-head form { margin-left: auto; }
.alert-msg { margin: 8px 0 0; font-weight: 500; }
.payload {
  margin: 8px 0 0;
  padding: 8px 10px;
  list-style: none;
  background: var(--bg);
  border-radius: 6px;
  font-size: .78rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  max-height: 220px;
  overflow-y: auto;
}
.payload .pk { color: var(--muted); }
.payload .pv { color: var(--blue-l); }

/* ── Botones ──────────────────────────────────────────────────── */
.btn {
  font: inherit;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
}
.btn:hover { border-color: var(--blue-l); color: var(--blue-l); }
.btn-small { padding: 10px 14px; font-size: .82rem; min-height: 42px; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #0d5ac0; color: #fff; }
.btn-block { width: 100%; padding: 10px; }

/* ── Estado vacío ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-top: 20px;
}
.empty-state.small { padding: 36px 16px; }
.empty-state h2 { color: var(--text); text-transform: none; font-size: 1.2rem; }
.empty-glyph { font-size: 2.5rem; color: var(--blue); font-weight: 700; }

/* ── Escenarios: banners "sonando ahora" / "próximas" ─────────── */
.now-banner { border-color: var(--blue-l); margin-bottom: 14px;
              display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.next-banner { margin-bottom: 14px;
               display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.now-label, .next-label {
  font-family: "Vida BC Mikser", "Graphik", sans-serif;
  font-weight: 700;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}
.now-label { color: var(--blue-l); animation: pulse 2.5s infinite; }
.next-label { color: var(--muted); }
.now-items { display: flex; gap: 10px 22px; flex-wrap: wrap; }
.now-item { font-size: .9rem; display: flex; align-items: baseline; gap: 8px;
            flex-wrap: wrap; }
.now-rate { color: var(--blue-l); font-weight: 500;
            font-variant-numeric: tabular-nums; white-space: nowrap; }
.next-count { color: var(--green); font-weight: 500; white-space: nowrap; }

/* ── Escenarios: timeline tipo cartel ─────────────────────────── */
.tl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.timeline { display: flex; min-width: 720px; }
.tl-hours { width: 46px; flex: none; }
.tl-hour {
  position: absolute;
  right: 8px;
  transform: translateY(-50%);
  font-size: .72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tl-col { flex: 1 1 0; min-width: 132px; border-left: 1px solid var(--border); }
.tl-head {
  height: 46px;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  font-size: .8rem;
  line-height: 1.25;
}
.tl-head strong { font-family: "Vida BC Mikser", "Graphik", sans-serif; }
.tl-head .muted { font-size: .68rem; }
.tl-body { position: relative; }
.tl-gridline { position: absolute; left: 0; right: 0;
               border-top: 1px dashed #23262d; pointer-events: none; }
.tl-card {
  position: absolute;
  left: 4px;
  right: 4px;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, .07);
  font-size: .74rem;
  line-height: 1.25;
  overflow: hidden;
  cursor: pointer;
  transition: filter .15s;
}
.tl-card:hover { filter: brightness(1.25); }
.tl-card.live { outline: 2px solid var(--blue-l); animation: pulse 2.5s infinite; }
.tl-card .a { display: block; font-weight: 500; }
.tl-card .t { display: block; color: var(--muted); font-size: .68rem;
              font-variant-numeric: tabular-nums; }
.tl-card.on-light { color: #10131a; }
.tl-card.on-light .t { color: #2c3644; }

/* ── Escenarios: panel de detalle ─────────────────────────────── */
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(430px, 100vw);
  z-index: 40;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 28px rgba(0, 0, 0, .5);
  padding: 16px;
  overflow-y: auto;
}
.detail-head { display: flex; align-items: flex-start; justify-content: space-between;
               gap: 10px; margin-bottom: 12px; }
.detail-kpis { grid-template-columns: repeat(2, 1fr); margin: 0 0 12px; }

/* ── Login ────────────────────────────────────────────────────── */
.login-wrap {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--blue);
  border-radius: var(--radius);
  padding: 30px 26px;
  width: 100%;
  max-width: 360px;
}
.login-logo {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: .04em;
}
.login-sub { text-align: center; color: var(--muted); font-size: .85rem;
             margin: 4px 0 20px; }
.login-card label { display: block; font-size: .8rem; color: var(--muted);
                    margin: 14px 0 4px; }
.login-card input { width: 100%; }
.login-card button { margin-top: 20px; }
.login-error {
  background: rgba(229, 72, 77, .14);
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: .85rem;
  text-align: center;
}
