/* NexoMesa · sistema de diseño
   Reglas: contraste AA, objetivos táctiles ≥ 44 px, foco visible, respeta "reducir movimiento",
   una sola familia tipográfica del sistema (carga instantánea, sin fuentes externas). */

:root {
  color-scheme: dark;
  --bg: #0a1124;
  --bg-2: #0e1730;
  --surface: #141d36;
  --surface-2: #1b2646;
  --surface-3: #243055;
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.16);
  --text: #f3f5fb;
  --text-2: #b4bdd4;
  --text-3: #8a94b0;
  --accent: #ffb59a;
  --accent-2: #ff9d7a;
  --accent-ink: #2a1208;
  --accent-soft: rgba(255, 181, 154, 0.14);
  --ok: #86dfb4;
  --ok-soft: rgba(134, 223, 180, 0.14);
  --warn: #f6d878;
  --warn-soft: rgba(246, 216, 120, 0.14);
  --danger: #ff8d8d;
  --danger-soft: rgba(255, 141, 141, 0.14);
  /* Estados de comanda (tarjetas de color con tinta oscura) */
  --st-new: #f6d878;
  --st-cook: #f5a58e;
  --st-ready: #9fdcc0;
  --st-ink: #1d1a17;
  /* Series de gráficas (validadas para daltonismo) */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-muted: #7d88a6;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --font: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f8;
  --bg-2: #eceef5;
  --surface: #ffffff;
  --surface-2: #f1f3f8;
  --surface-3: #e5e8f0;
  --line: rgba(16, 24, 48, 0.1);
  --line-2: rgba(16, 24, 48, 0.2);
  --text: #111a30;
  --text-2: #46506a;
  --text-3: #636d87;
  --accent: #c94f27;
  --accent-2: #b54420;
  --accent-ink: #ffffff;
  --accent-soft: rgba(201, 79, 39, 0.1);
  --ok: #0f7a4d;
  --ok-soft: rgba(15, 122, 77, 0.1);
  --warn: #8a6400;
  --warn-soft: rgba(138, 100, 0, 0.1);
  --danger: #c0302f;
  --danger-soft: rgba(192, 48, 47, 0.09);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-muted: #8a93a8;
  --shadow: 0 18px 44px rgba(16, 24, 48, 0.14);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
body::before { /* brillo de fondo suave, fijo */
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(88, 120, 220, 0.2), transparent 60%),
    radial-gradient(700px 480px at 100% 0%, rgba(255, 157, 122, 0.1), transparent 60%);
  pointer-events: none;
}
:root[data-theme="light"] body::before { opacity: 0.5; }

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.5rem, 2.6vw, 2rem); font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
h2 { font-size: 1.1rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 0.95rem; font-weight: 600; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 0.82rem; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.icon { flex: none; display: block; }

/* ------------------------------ Botones ------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border-color: var(--line-2); color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.soft { background: var(--surface-2); color: var(--text); }
.btn.soft:hover { background: var(--surface-3); }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn.danger:hover { border-color: var(--danger); }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 0.85rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.busy { cursor: progress; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }
.icon-btn.sm { width: 36px; height: 36px; }
.icon-btn.plain { background: transparent; border-color: transparent; }

/* ------------------------------ Superficies ------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }

/* Selector segmentado y filtros en pastilla */
.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border: 0; border-radius: 999px; background: transparent;
  color: var(--text-2); font-weight: 600; font-size: 0.85rem; white-space: nowrap;
}
.form > .seg, .field > .seg, .card > .seg { justify-self: start; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* ------------------------------ Formularios ------------------------------ */
.field { display: grid; gap: 6px; }
.field label { font-size: 0.82rem; font-weight: 600; color: var(--text-2); }
.hint { color: var(--text-3); font-size: 0.78rem; }
.input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--bg-2);
  color: var(--text);
  font-size: 16px; /* evita el zoom automático de iOS al enfocar */
}
textarea.input { padding: 10px 14px; min-height: 76px; resize: vertical; }
.input::placeholder { color: var(--text-3); }
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
select.input { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.form { display: grid; gap: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

/* Interruptor */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-size: 0.85rem; color: var(--text-2); }
.switch input { position: absolute; opacity: 0; width: 46px; height: 28px; margin: 0; cursor: pointer; }
.switch i { width: 46px; height: 28px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line-2); position: relative; transition: background 0.15s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--text-2); transition: transform 0.15s, background 0.15s; }
.switch input:checked + i { background: var(--ok-soft); border-color: var(--ok); }
.switch input:checked + i::after { transform: translateX(18px); background: var(--ok); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------ Diálogos ------------------------------ */
.dlg {
  width: min(520px, calc(100vw - 24px));
  max-height: min(88dvh, 860px);
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.dlg[open] { display: flex; flex-direction: column; }
.dlg.wide { width: min(760px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(4, 8, 20, 0.62); backdrop-filter: blur(3px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 12px 22px; }
.dlg-title { font-size: 1.1rem; }
.dlg-body { padding: 4px 22px 20px; overflow-y: auto; overscroll-behavior: contain; flex: 1; min-height: 0; }
.dlg-foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding: 14px 22px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.dlg-foot:empty { display: none; }
.dlg.drawer {
  margin: 0 0 0 auto;
  width: min(520px, 100vw);
  height: 100dvh;
  max-height: none;
  border-radius: var(--r-lg) 0 0 var(--r-lg);
  border-width: 0 0 0 1px;
}
@media (max-width: 640px) {
  .dlg, .dlg.wide { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; border-width: 1px 0 0; max-height: 92dvh; }
  .dlg.drawer { height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; }
  .dlg-foot .btn { flex: 1; }
  .row { grid-template-columns: 1fr; }
}

/* ------------------------------- Avisos ------------------------------- */
.toasts { position: fixed; inset: auto auto calc(88px + env(safe-area-inset-bottom)) 50%; transform: translateX(-50%); z-index: 2147483647; display: grid; gap: 8px; width: min(420px, calc(100vw - 24px)); margin: 0; padding: 0; border: 0; background: transparent; color: inherit; overflow: visible; pointer-events: none; }
.toasts:empty { display: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--r-md); background: var(--surface-3); border: 1px solid var(--line-2); box-shadow: var(--shadow); font-weight: 600; font-size: 0.9rem; animation: rise 0.2s ease-out; }
.toast.ok .icon { color: var(--ok); }
.toast.error .icon { color: var(--danger); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.empty { display: grid; gap: 8px; justify-items: center; text-align: center; padding: 36px 16px; color: var(--text-2); }
.empty strong { color: var(--text); font-size: 1rem; }

/* ------------------------------- Tablas ------------------------------- */
.table-wrap { overflow-x: auto; position: relative; } /* el texto .sr-only de las tablas es absoluto; sin esto escapa del scroll y ensancha toda la página */
table.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th { text-align: left; font-size: 0.74rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; font-variant-numeric: tabular-nums; }

/* Marca */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; color: var(--text); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--accent); color: var(--accent-ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
