/* El panel de administracion. Sin nada heredado de la app: ni styles.css ni
   la capa ui12-/ui14- de index.html. Sigue el tema del sistema. */

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6eb;
  --text: #14181f;
  --muted: #5d6675;
  --accent: #0e9f6e;
  --accent-text: #ffffff;
  --danger: #c93a3a;
  --notice-bg: #fff6db;
  --notice-text: #6b4e00;
  /* Validados con el validador de paleta del skill dataviz el 2026-09-23:
     contraste >= 3:1 y banda de luminosidad, en cada tema. */
  --chart-bar: #2a78d6;
  --chart-muted: #b4b2a9;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1318;
    --surface: #171c23;
    --border: #2a313b;
    --text: #e8ecf1;
    --muted: #98a2b1;
    --accent: #34c38f;
    --accent-text: #06111f;
    --danger: #f07070;
    --notice-bg: #3a3115;
    --notice-text: #f3dd9a;
    --chart-bar: #3987e5;
    --chart-muted: #5f5e5a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 16px 0 8px; color: var(--muted); }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
code { font-size: 12px; word-break: break-all; }

.brand { font-weight: 700; margin: 0 0 20px; display: flex; flex-direction: column; }
.brand span { font-weight: 500; font-size: 12px; color: var(--muted); }

/* Pantallas de acceso */
.screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 18px; margin-bottom: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.qr {
  display: block;
  width: 184px;
  height: 184px;
  margin: 8px auto 12px;
  padding: 8px;
  background: #ffffff;
  border-radius: 8px;
}

.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: default; }
.link-btn {
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}
.form-message { min-height: 18px; margin: 0; font-size: 13px; color: var(--danger); }
.form-message.ok { color: var(--accent); }
.notice { background: var(--notice-bg); color: var(--notice-text); padding: 10px 12px; border-radius: 8px; margin: 0; }

/* El armazon */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: var(--text); text-decoration: none; padding: 8px 10px; border-radius: 8px; white-space: nowrap; }
.nav a.active { background: var(--bg); font-weight: 600; }
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.whoami { margin: 0 0 6px; font-size: 12px; color: var(--muted); word-break: break-all; }
.content { padding: 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* Resumen */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
}
.stat span { font-size: 12px; color: var(--muted); }
.stat strong { font-size: 24px; font-variant-numeric: tabular-nums; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

/* Tablas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input[type="search"], .filters input[type="email"] { flex: 1 1 220px; }
.pager { display: flex; align-items: center; gap: 12px; margin-top: 12px; }

/* Filas con acciones */
.row-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
}
.row-card > div:first-child { display: flex; flex-direction: column; min-width: 0; }
.row-card .form-message { flex-basis: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
}
.chip .link-btn { font-size: 12px; }

/* Graficos del Resumen (js/charts.js). Los colores van por clase y no por
   atributo: asi el tema los cambia sin redibujar. */
.chart-split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart-bar { fill: var(--chart-bar); }
.chart-bar.muted { fill: var(--chart-muted); }
.chart-grid { stroke: var(--border); stroke-width: 0.5; }
.chart-axis { stroke: var(--border); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 11px; }
.chart-label.strong { fill: var(--text); font-weight: 600; }
.chart-hit { fill: transparent; }
.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .chart-split { grid-template-columns: minmax(0, 1fr); }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); padding: 12px 16px; }
  .brand { margin-bottom: 12px; }
  .nav { flex-direction: row; overflow-x: auto; }
  .sidebar-footer { margin-top: 12px; }
  .content { padding: 16px; }
}
