/* BIMerendas — estilos comunes, mobile-first, alto contraste */
:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #10b981;
  --danger: #ef4444;
  --warn: #f59e0b;
  --gray: #64748b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button {
  font: inherit;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
  background: var(--panel);
  padding: 14px 20px;
  min-height: 48px;
  touch-action: manipulation;
}
button.primary { background: var(--accent); color: #06281c; font-weight: 700; }
button.danger { background: var(--danger); color: #fff; font-weight: 700; }
button.ghost { background: transparent; outline: 1px solid var(--gray); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
input, select {
  font: inherit;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--gray);
  background: #0b1222;
  color: var(--text);
  min-height: 48px;
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); }
label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 0.9rem; }
a { color: #7dd3fc; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
.card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
}
.small { font-size: 0.85rem; color: var(--muted); }
.error-text { color: var(--danger); }
.ok-text { color: var(--accent); }

/* ---------- Pantalla inicial ---------- */
.splash {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 22px;
  padding: 24px;
  text-align: center;
}
.splash h1 { font-size: 1.7rem; margin: 0 0 8px; }
.splash .big-btn {
  width: min(92vw, 420px);
  padding: 28px 20px;
  font-size: 1.35rem;
  font-weight: 700;
}

/* ---------- Modo control ---------- */
.control {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel);
}
.topbar .day { font-weight: 700; }
.pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  background: #0b1222;
  border: 1px solid var(--gray);
}
.pill.on { border-color: var(--accent); color: var(--accent); }
.pill.off { border-color: var(--danger); color: var(--danger); }
.viewport {
  position: relative;
  flex: 1;
  min-height: 40svh;
  background: #000;
  overflow: hidden;
}
#qr-reader, #qr-reader video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.controls-bar {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  flex-wrap: wrap;
  background: var(--panel);
  align-items: center;
}
.controls-bar select { width: auto; min-height: 44px; }
.manual {
  display: flex;
  gap: 8px;
  padding: 10px 14px 16px;
}
.manual input { flex: 1; }
#result-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 24px;
  z-index: 50;
  color: #fff;
  transition: opacity 0.15s;
}
#result-overlay.green { background: #15803d; }
#result-overlay.red { background: #b91c1c; }
#result-overlay.amber { background: #b45309; }
#result-overlay.gray { background: #475569; }
#result-overlay.black { background: #0f172a; }
#result-overlay .icon { font-size: 3.4rem; margin-bottom: 10px; }
#result-overlay .name { font-size: clamp(1.8rem, 8vw, 3.4rem); font-weight: 800; }
#result-overlay .sub { font-size: clamp(1.1rem, 4.5vw, 1.8rem); margin-top: 8px; }
#result-overlay .detail { font-size: 1rem; margin-top: 14px; opacity: 0.9; }
#result-overlay.compact {
  justify-content: flex-end;
  background: transparent;
  padding: 0;
}
#result-overlay.compact .box {
  margin: 0 12px 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: rgba(180, 83, 9, 0.92);
  font-size: 1.1rem;
  font-weight: 600;
}
#conn-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--danger);
  color: #fff;
  text-align: center;
  padding: 10px;
  font-weight: 700;
  z-index: 60;
}

/* ---------- Panel admin ---------- */
.admin { max-width: 1080px; margin: 0 auto; padding: 12px 14px 80px; }
.admin header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  flex-wrap: wrap;
}
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 0;
  border-bottom: 1px solid var(--gray);
}
.tabs button {
  background: transparent;
  white-space: nowrap;
  min-height: 40px;
  padding: 8px 14px;
  border-bottom: 3px solid transparent;
  border-radius: 8px 8px 0 0;
}
.tabs button.active { border-bottom-color: var(--accent); color: var(--accent); font-weight: 700; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #334155; }
th { color: var(--muted); font-weight: 600; }
.progress {
  height: 14px;
  border-radius: 999px;
  background: #0b1222;
  overflow: hidden;
  border: 1px solid var(--gray);
}
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width 0.2s; }
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 70;
  padding: 16px;
}
.modal {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 560px;
  width: 100%;
  max-height: 90svh;
  overflow: auto;
}
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: #0b1222; border-radius: var(--radius); padding: 14px; text-align: center; }
.kpi b { font-size: 1.7rem; display: block; }
.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #06281c;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 700;
  z-index: 80;
}
.toast.bad { background: var(--danger); color: #fff; }
@media (orientation: landscape) {
  .viewport { min-height: 60svh; }
}
