/* ============================================================
   Sistema visual — sobrio y minimalista.
   Negro, blanco y grises. El color existe solo cuando significa
   algo (cumplió / no cumplió / por revisar / colores de marca).
   Sin gradientes, sin brillos, sin adornos: menos es más.
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Modo claro */
  --bg: #fafafa;
  --card: #ffffff;
  --surface2: #f4f4f5;
  --text: #18181b;
  --muted: #71717a;
  --line: #e4e4e7;
  --primary: #18181b;        /* el "acento" es el propio negro */
  --primary-text: #ffffff;
  --ok: #16a34a; --bad: #dc2626; --warn: #d97706;
  --sombra: 0 1px 2px rgba(0, 0, 0, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0b;
    --card: #131316;
    --surface2: #1c1c21;
    --text: #f4f4f5;
    --muted: #8b8b93;
    --line: #26262b;
    --primary: #f4f4f5;      /* en oscuro, el acento es el blanco */
    --primary-text: #0a0a0b;
    --ok: #4ade80; --bad: #f87171; --warn: #fbbf24;
    --sombra: none;
  }
}
/* Hooks por si algún día se agrega un toggle de tema */
:root[data-theme="light"] {
  --bg: #fafafa; --card: #ffffff; --surface2: #f4f4f5; --text: #18181b; --muted: #71717a;
  --line: #e4e4e7; --primary: #18181b; --primary-text: #ffffff;
  --ok: #16a34a; --bad: #dc2626; --warn: #d97706; --sombra: 0 1px 2px rgba(0, 0, 0, .04);
}
:root[data-theme="dark"] {
  --bg: #0a0a0b; --card: #131316; --surface2: #1c1c21; --text: #f4f4f5; --muted: #8b8b93;
  --line: #26262b; --primary: #f4f4f5; --primary-text: #0a0a0b;
  --ok: #4ade80; --bad: #f87171; --warn: #fbbf24; --sombra: none;
}

body { font-family: -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
td, .card .num, .pt-pct, .cumple-fecha { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--muted); outline-offset: 2px; }

/* ---------- Header y navegación ---------- */
header { background: var(--bg); border-bottom: 1px solid var(--line); padding: 12px 22px; display: flex; align-items: center; gap: 22px; flex-wrap: wrap; position: sticky; top: 0; z-index: 10; }
.logo { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
nav { display: flex; gap: 2px; flex-wrap: wrap; }
nav button { border: none; background: transparent; padding: 7px 12px; border-radius: 6px; cursor: pointer; font-size: 13.5px; color: var(--muted); transition: background .12s, color .12s; }
nav button.active { background: var(--surface2); color: var(--text); font-weight: 500; }
nav button:hover:not(.active) { color: var(--text); }

main { max-width: 1180px; margin: 0 auto; padding: 24px 22px; }
.tab { display: none; }
.tab.active { display: block; }

/* ---------- Controles ---------- */
.toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; background: var(--card); padding: 12px 16px; border-radius: 10px; border: 1px solid var(--line); }
.toolbar label { font-size: 13.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
input, select, textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: var(--card); color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--muted); }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
button { padding: 8px 14px; border: 1px solid var(--line); background: var(--card); border-radius: 8px; cursor: pointer; font-size: 13.5px; color: var(--text); transition: background .12s, border-color .12s; }
button:hover { background: var(--surface2); }
button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 500; }
button.primary:hover { opacity: .9; background: var(--primary); }
button:disabled { opacity: .5; cursor: wait; }
.muted { color: var(--muted); font-size: 13px; }
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--muted); }

/* ---------- Tarjetas de estadística ---------- */
.cards { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; min-width: 150px; box-shadow: var(--sombra); }
.card .num { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.card .lbl { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card.clickable { cursor: pointer; transition: border-color .12s; }
.card.clickable:hover { border-color: var(--muted); }

/* ---------- Paneles ---------- */
.panel-box { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 16px; box-shadow: var(--sombra); position: relative; }
.panel-box h3 { margin-bottom: 10px; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.panel-box.alerta { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row input { flex: 1; min-width: 160px; }
.form-col { display: flex; flex-direction: column; gap: 8px; }
.form-col label { font-size: 13px; color: var(--muted); margin-top: 6px; }

.brand-header { display: flex; align-items: center; gap: 10px; padding: 10px 0 6px; }
.brand-toggle { cursor: pointer; user-select: none; margin: -10px 0 -6px; padding: 10px 0; }
.brand-toggle:hover h3 { color: var(--muted); }
.chev { color: var(--muted); font-size: 13px; width: 14px; flex-shrink: 0; }
.brand-body { margin-top: 6px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; }
.brand-header h3 { font-size: 14.5px; }
.brand-header .muted { flex: 1; }

/* ---------- Tablas ---------- */
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 10px; overflow: hidden; font-size: 13.5px; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface2); }
.scrollx { overflow-x: auto; }

/* Estados en celdas: tinte sutil, el símbolo carga el color */
.cell-ok   { background: color-mix(in srgb, var(--ok) 10%, var(--card));  color: var(--ok);   text-align: center; font-weight: 600; }
.cell-bad  { background: color-mix(in srgb, var(--bad) 10%, var(--card)); color: var(--bad);  text-align: center; font-weight: 600; }
.cell-warn { background: color-mix(in srgb, var(--warn) 10%, var(--card)); color: var(--warn); text-align: center; font-weight: 600; }
.cell-none { background: transparent; text-align: center; color: color-mix(in srgb, var(--muted) 45%, transparent); }

/* ---------- Chips ---------- */
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: color-mix(in srgb, currentColor 10%, transparent); border: 1px solid color-mix(in srgb, currentColor 25%, transparent); }
.chip.cumplio { color: var(--ok); }
.chip.no_cumplio { color: var(--bad); }
.chip.revisar { color: var(--warn); }
.chip.sin_revisar { color: var(--muted); }

/* ---------- Revisión manual ---------- */
.story-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 12px; box-shadow: var(--sombra); }
.story-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.story-head b { font-size: 15px; }
.story-thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.story-thumbs a img { height: 190px; border-radius: 8px; border: 1px solid var(--line); display: block; }
.story-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-ok:hover { background: var(--ok); opacity: .9; }
.btn-bad:hover { background: var(--bad); opacity: .9; }

.amb-row-inactive { opacity: .45; }
.small-btn { padding: 4px 9px; font-size: 12px; }

/* ---------- Avisos ---------- */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 100; max-width: 380px; }
.toast { padding: 12px 14px; border-radius: 8px; font-size: 13.5px; background: var(--card); color: var(--text); border: 1px solid var(--line); border-left-width: 3px; box-shadow: 0 4px 16px rgba(0, 0, 0, .18); animation: toast-in .2s ease; }
.toast.error { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }
.toast.ok { border-left-color: var(--ok); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

.onboarding ol { margin: 8px 0 0 20px; line-height: 2; font-size: 14.5px; }

/* ---------- Cajas de configuración dentro de marcas ---------- */
.auto-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; padding: 10px 12px; background: var(--surface2); border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; }
.dia-chk { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; color: var(--muted); }
#rep-rachas select { padding: 4px 6px; }
.acceso-marcas { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.importar-box { margin-top: 10px; padding: 12px; background: var(--surface2); border: 1px solid var(--line); border-radius: 8px; }

/* Franja del modo de pruebas (visible para todos mientras dura la prueba) */
.banner-prueba { position: sticky; top: 0; z-index: 50; text-align: center; padding: 9px 14px; font-size: 13.5px;
  color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, var(--bg));
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }

/* Barra de progreso de la revisión */
.rp-barra { height: 8px; background: var(--surface2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.rp-relleno { height: 100%; width: 0%; background: var(--primary); border-radius: 99px; transition: width 1.4s ease; }
.importar-box textarea { width: 100%; padding: 10px; font-family: inherit; margin: 8px 0; resize: vertical; }

/* ---------- Pantalla de puerta (celular, de noche) ---------- */
.pt-buscador { width: 100%; padding: 15px; font-size: 19px; border-radius: 10px; margin-top: 6px; }
.pt-card { border-radius: 12px; }
.pt-nombre { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pt-user { font-size: 16px; color: var(--muted); }
.pt-marcas { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.pt-marca { flex: 1; min-width: 240px; border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: var(--surface2); }
.pt-marca-head { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.pt-pct { font-size: 42px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
.pt-alerta { color: var(--bad); font-weight: 600; margin: 4px 0; }
.pt-info { margin-top: 10px; padding: 10px 12px; background: color-mix(in srgb, var(--ok) 10%, var(--card)); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); border-radius: 8px; font-size: 14.5px; font-weight: 600; color: var(--ok); }
.pt-chips { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.pt-invitados { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.pt-inv-botones { display: flex; gap: 8px; flex-wrap: wrap; }
.pt-inv-botones button { min-width: 52px; min-height: 52px; font-size: 20px; font-weight: 600; border-radius: 10px; }

/* Selector Embajadores / Contador (guardias) */
.pt-switch { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 14px; }
.pt-switch button { flex: 1; padding: 13px; font-size: 16px; border: none; border-radius: 0; background: var(--card); color: var(--muted); }
.pt-switch button.activo { background: var(--primary); color: var(--primary-text); font-weight: 600; }

/* Contador de gente de la noche */
.contador-box { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 26px 16px; text-align: center; }
.contador-num { font-size: 96px; font-weight: 700; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.contador-mas { width: 100%; max-width: 420px; min-height: 170px; font-size: 44px; font-weight: 700; border-radius: 16px; background: var(--ok); border-color: var(--ok); color: #fff; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.contador-mas:hover { background: var(--ok); opacity: .92; }
.contador-mas:active { transform: scale(.98); }
.contador-menos { padding: 10px 18px; font-size: 14px; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: transparent; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.contador-menos:active { transform: scale(.97); }

/* ---------- Cumpleaños ---------- */
.cumple-cards { display: flex; gap: 12px; flex-wrap: wrap; }
.cumple-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; min-width: 200px; background: var(--card); }
.cumple-fecha { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; }
.cal-wrap { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; min-width: 560px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--muted); font-weight: 500; padding: 4px; }
.cal-cell { min-height: 66px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; background: var(--card); }
.cal-empty { border: none; background: none; }
.cal-num { font-size: 12.5px; color: var(--muted); }
.cal-today { border-color: var(--text); }
.cal-hasbday { background: var(--surface2); }
.cal-bdays { font-weight: 600; font-size: 13px; }
.cal-names { font-size: 11px; color: var(--muted); line-height: 1.3; }

/* ---------- Movimiento respetuoso ---------- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Adaptación a celular ---------- */
@media (max-width: 720px) {
  main { padding: 12px; }
  header { padding: 10px 12px; gap: 10px; }
  .logo { font-size: 14px; }
  nav { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  nav button { white-space: nowrap; padding: 8px 12px; }
  #quien { margin-left: auto; font-size: 12px; }
  input, select, textarea { font-size: 16px; }
  .panel-box { padding: 13px; overflow-x: auto; }
  table { min-width: 500px; }
  .toolbar { padding: 10px; gap: 8px; }
  .small-btn { padding: 7px 11px; font-size: 12px; }
  .cards { gap: 10px; }
  .card { min-width: calc(50% - 5px); padding: 12px 14px; }
  #toasts { left: 12px; right: 12px; max-width: none; }
  .pt-pct { font-size: 36px; }
  .contador-num { font-size: 84px; }
  .contador-mas { min-height: 44vh; }
}
