:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #efeee8;
  --text: #1f1e1b;
  --text-2: #6b6a64;
  --border: #dddcd4;
  --accent: #2563c9;
  --accent-bg: #e3edfb;
  --ok: #2f7a1f;
  --ok-bg: #e4f2d9;
  --warn: #8a5300;
  --warn-bg: #fbeed6;
  --danger: #b42a2a;
  --danger-bg: #fbe5e5;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1b19;
    --surface: #262624;
    --surface-2: #31312e;
    --text: #ecebe6;
    --text-2: #a4a39c;
    --border: #3d3d39;
    --accent: #7fb0f5;
    --accent-bg: #1d3557;
    --ok: #9ed27f;
    --ok-bg: #22381a;
    --warn: #f2c071;
    --warn-bg: #45320f;
    --danger: #f19a9a;
    --danger-bg: #4a1d1d;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 10px 14px; }
button:active { transform: scale(0.98); }
button.primario { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; }
button.peligro { color: var(--danger); border-color: var(--danger); background: transparent; }
@media (prefers-color-scheme: dark) {
  button.primario, button.ok { color: #111; }
}
input, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.sub { color: var(--text-2); font-size: 0.85rem; }
.oculto { display: none !important; }

.pill { display: inline-block; font-size: 0.75rem; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.estado-PENDIENTE { background: var(--surface-2); color: var(--text-2); }
.estado-EN_PREPARACION { background: var(--warn-bg); color: var(--warn); }
.estado-LISTA { background: var(--ok-bg); color: var(--ok); }
.estado-SERVIDA { background: var(--accent-bg); color: var(--accent); }
.estado-CANCELADA { background: var(--danger-bg); color: var(--danger); }

.conexion { font-size: 0.8rem; color: var(--text-2); }
.conexion::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); margin-right: 6px; }
.conexion.on::before { background: var(--ok); }

.marca { display: flex; align-items: center; gap: 10px; min-width: 0; }
.marca img { height: 36px; width: auto; max-width: 120px; object-fit: contain; border-radius: 6px; }
.marca .marca-textos { min-width: 0; }
.marca .marca-nombre { font-size: 0.8rem; color: var(--text-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.usuario-sesion { display: flex; align-items: center; gap: 12px; font-size: 0.85rem; }
.usuario-sesion .usuario-nombre { font-weight: 600; }
.usuario-sesion a { color: var(--text-2); }
.usuario-sesion button { padding: 5px 10px; font-size: 0.85rem; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--ok); color: #fff; padding: 12px 18px; border-radius: var(--radius); font-weight: 600; max-width: 92vw; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.error { background: var(--danger); }

.etiqueta-anadido { display: inline-block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 7px; border-radius: 6px; background: var(--warn-bg); color: var(--warn); vertical-align: middle; }

/* Alérgenos */
.alergenos { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.alergeno { font-size: 0.7rem; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.alergeno.peligro { background: var(--danger); color: #fff; font-weight: 700; }
.aviso-alergia { display: flex; gap: 8px; align-items: baseline; background: var(--danger-bg); color: var(--danger); border: 2px solid var(--danger); border-radius: 10px; padding: 8px 12px; font-weight: 600; }
.aviso-alergia strong { text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.85em; white-space: nowrap; }
