/* Panel de admin — tema claro propio (no depende de Tailwind ni de la web). */
:root {
  --paper: #f2ece0;
  --paper-2: #faf6ee;
  --paper-3: #ece5d7;
  --ink: #1e1b16;
  --ink-2: #4a463d;
  --muted: #9a9284;
  --muted-2: #726b5e;
  --gold: #c7a353;
  --gold-dark: #9a7526;
  --blue: #1d447d;
  --green: #3f6b4f;
  --red: #b4432b;
  --border: rgba(154, 146, 132, 0.22);
  --shadow: 0 1px 2px rgba(30, 27, 22, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; }
.mono { font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }
.small { font-size: 12.5px; }
.xsmall { font-size: 11.5px; }
.muted { color: var(--muted); }
.blue { color: var(--blue); }
.right { text-align: right; }
.w-full { width: 100%; }
.inline { display: inline; }
.hidden { display: none; }

/* ── top bar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.brand { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.brand b { font-weight: 700; }
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); display: inline-block; }
.brand-lg { font-size: 16px; margin-bottom: 6px; }

/* ── layout ── */
.container { max-width: 1100px; margin: 0 auto; padding: 22px 20px 60px; }
.footer { max-width: 1100px; margin: 0 auto; padding: 0 20px 40px; color: var(--muted); font-size: 11.5px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-head h1 { margin: 0; font-size: 24px; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── cards ── */
.card {
  background: var(--paper-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-2);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.big { font-size: 24px; font-weight: 800; margin: 4px 0 10px; }

.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { margin: 0; padding: 14px; }
.kpi-label { margin: 0; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.kpi-value { margin: 4px 0 2px; font-size: 22px; font-weight: 900; }
.kpi-sub { margin: 0; font-size: 11.5px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2 .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 18px; }
.wide { grid-column: 1 / -1; }

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ── bar chart ── */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 116px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; }
.bar-num { font-size: 9.5px; color: var(--muted); }
.bar { width: 100%; border-radius: 3px 3px 0 0; background: rgba(199, 163, 83, 0.75); }
.bar-day { font-size: 9px; color: var(--muted-2); }

/* ── lists / tracks ── */
.stack { display: flex; flex-direction: column; gap: 10px; }
.kv { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 3px 0; }
.kv-k { color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv-v { flex: none; }
.track { margin-top: 4px; height: 8px; background: var(--paper-3); border-radius: 4px; overflow: hidden; }
.fill { height: 100%; background: var(--blue); border-radius: 4px; }

/* ── tablas ── */
/* `table-fit` = table-layout fixed + recorte con elipsis: la tabla ocupa
   exactamente el ancho de su tarjeta, sin scroll horizontal al cargar. */
.scroll-x { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-fit { table-layout: fixed; }
.table th,
.table td {
  padding: 7px 8px;
  border-bottom: 1px solid rgba(154, 146, 132, 0.12);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.table th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  vertical-align: bottom;
}
.table th.right, .table td.right { text-align: right; }
.table td.right, .table td.numeric { font-variant-numeric: tabular-nums; }
.table td.mono { font-size: 12px; }
.table tbody tr:hover { background: rgba(250, 246, 238, 0.9); }
.table tr.is-hidden { display: none; }

/* cabeceras ordenables */
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--blue); }
.table th.sorted { color: var(--ink-2); font-weight: 800; }
.table th .sarrow { font-size: 9px; opacity: 0.85; }

/* pie de tabla (contador + paginación) */
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.table-foot .foot-btns { display: flex; gap: 8px; }
.table-foot .btn { padding: 5px 11px; font-size: 12.5px; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; background: var(--paper-3); color: var(--muted-2); }
.pill-gold { background: rgba(199, 163, 83, 0.18); color: var(--gold-dark); font-weight: 700; }
.pill-green { background: rgba(63, 107, 79, 0.15); color: var(--green); font-weight: 600; }

/* ── forms / buttons ── */
.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: var(--paper-2);
  color: var(--ink-2);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--paper-3); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #12100c; font-weight: 700; }
.btn-gold:hover { background: #d9be73; }
.btn-blue { background: rgba(29, 68, 125, 0.15); border-color: rgba(29, 68, 125, 0.28); color: var(--blue); font-weight: 700; }
.btn-soft { background: var(--paper-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted-2); }
.btn-ghost:hover { background: var(--paper-3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.form-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.grow { flex: 1 1 240px; }
.w180 { width: 200px; }
.w90 { width: 88px; }
.field { display: block; margin-bottom: 12px; }
.label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 4px; }
.input {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 14px;
  color: var(--ink-2);
  background: var(--paper-2);
  border: 1px solid rgba(30, 27, 22, 0.14);
  border-radius: 9px;
}
.input:focus { outline: none; border-color: var(--gold); }

/* ── alerts ── */
.alert { padding: 9px 12px; border-radius: 9px; font-size: 13px; margin: 10px 0; }
.alert-error { background: rgba(180, 67, 43, 0.09); border: 1px solid rgba(180, 67, 43, 0.3); color: var(--red); }
.alert-warn { background: rgba(199, 163, 83, 0.12); border: 1px solid rgba(199, 163, 83, 0.4); color: var(--gold-dark); }
.alert-ok { background: rgba(63, 107, 79, 0.12); border: 1px solid rgba(63, 107, 79, 0.3); color: var(--green); }

/* ── login ── */
.login-wrap { min-height: 82vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 400px; padding: 26px; }
.login-title { margin: 12px 0 4px; font-size: 20px; }
.login-form { margin-top: 16px; }

/* ── log ── */
.log {
  margin-top: 10px;
  max-height: 420px;
  overflow: auto;
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px;
}
.log-line { white-space: pre-wrap; word-break: break-all; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 11px; line-height: 1.35; color: #9a9284; }
.log-line.err { color: #f87171; }
.log-line.ok { color: #4ade80; }
.log-line.step { color: #60a5fa; }
.log-line.warn { color: #fbbf24; }
