/* Shared styles for all screens. Dark, high contrast, readable from 2 m and under sunlight. */
:root {
  --bg: #0d0f14;
  --surface: #171a22;
  --surface-2: #222733;
  --surface-3: #2d3342;
  --line: #3a4154;
  --text: #f6f7fb;
  --muted: #b4bccd;
  --accent: #ff9a1f;
  --accent-ink: #1a1000;
  --ok: #43e08a;
  --ok-ink: #04210f;
  --warn: #ffc83d;
  --warn-ink: #231800;
  --danger: #ff6464;
  --danger-ink: #2a0606;
  --info: #66b3ff;
  --focus: #ffffff;
  --radius: 14px;
  --tap: 52px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 18px; line-height: 1.35; min-height: 100dvh; overflow-wrap: anywhere;
}
h1, h2, h3 { margin: 0; line-height: 1.15; }
p { margin: 0 0 .75em; }
a { color: var(--info); }
[hidden] { display: none !important; }

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

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: 12px; }

/* Buttons */
.btn {
  appearance: none; border: 2px solid transparent; cursor: pointer; font: inherit; font-weight: 700;
  min-height: var(--tap); padding: 10px 18px; border-radius: var(--radius);
  background: var(--surface-3); color: var(--text); display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; text-align: center; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent; text-decoration: none; overflow-wrap: normal;
}
.btn:active { transform: scale(.98); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ok { background: var(--ok); color: var(--ok-ink); }
.btn-danger { background: var(--danger); color: var(--danger-ink); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-lg { min-height: 64px; font-size: 1.15rem; width: 100%; }
.btn-sm { min-height: 48px; padding: 6px 14px; font-size: .95rem; }
.btn.on { border-color: var(--focus); background: var(--accent); color: var(--accent-ink); }

/* Forms */
.field { display: block; }
.field > span { display: block; font-weight: 700; margin-bottom: 6px; }
.field small { display: block; color: var(--muted); margin-top: 4px; font-size: .85rem; }
input[type=text], input[type=tel], input[type=number], input[type=date], input[type=search], textarea, select {
  font: inherit; font-size: 1rem; color: var(--text); background: var(--surface-2); border: 2px solid var(--line);
  border-radius: 12px; padding: 12px 14px; min-height: var(--tap); width: 100%;
}
textarea { min-height: 110px; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--focus); border-color: var(--accent); }

/* Switch (checkbox styled) */
.switch { display: flex; align-items: center; gap: 12px; min-height: var(--tap); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .pista { flex: none; width: 58px; height: 34px; border-radius: 20px; background: var(--surface-3);
  border: 2px solid var(--line); position: relative; transition: background .15s; }
.switch .pista::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--text); transition: transform .15s; }
.switch input:checked + .pista { background: var(--ok); border-color: var(--ok); }
.switch input:checked + .pista::after { transform: translateX(24px); background: var(--ok-ink); }
.switch input:focus-visible + .pista { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: .85rem;
  font-weight: 800; background: var(--surface-3); color: var(--text); white-space: nowrap; border: 0; font-family: inherit; overflow-wrap: normal; }
.badge.ok { background: var(--ok); color: var(--ok-ink); }
.badge.warn { background: var(--warn); color: var(--warn-ink); }
.badge.danger { background: var(--danger); color: var(--danger-ink); }
.badge.info { background: var(--info); color: #02172c; }
.badge.outline { background: transparent; border: 2px solid var(--line); color: var(--muted); }
button.badge { cursor: pointer; min-height: 36px; }

/* Layout shells */
.page { max-width: 1100px; margin: 0 auto; padding: 16px; }
.page.narrow { max-width: 520px; }
.card { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; }
.topbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; background: var(--surface);
  border-bottom: 2px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 1.15rem; margin-right: auto; }
.navlinks { display: flex; gap: 6px; flex-wrap: wrap; }
.navlinks a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 700; border: 2px solid transparent; }
.navlinks a[aria-current="page"] { color: var(--text); border-color: var(--line); background: var(--surface-2); }

/* Tabs */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px 0; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { appearance: none; font: inherit; font-weight: 800; color: var(--muted); background: var(--surface); cursor: pointer;
  border: 2px solid var(--line); border-bottom: 0; border-radius: 12px 12px 0 0; padding: 0 16px; min-height: var(--tap);
  white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Toasts */
#toasts { position: fixed; left: 0; right: 0; bottom: 0; z-index: 100; display: flex; flex-direction: column; gap: 8px;
  align-items: center; padding: 12px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 560px; width: 100%;
  background: #fff; color: #11141b; padding: 10px 10px 10px 16px; border-radius: 14px; font-weight: 700;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .55); animation: sube .18s ease-out; }
.toast.error { background: var(--danger); color: var(--danger-ink); }
.toast.ok { background: var(--ok); color: var(--ok-ink); }
.toast .btn { min-height: 44px; background: #11141b; color: #fff; }
.toast.error .btn, .toast.ok .btn { background: rgba(0, 0, 0, .75); }
.toast .cerrar { margin-left: auto; }
.toast .texto { flex: 1 1 auto; }
@keyframes sube { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Sheets (native <dialog>): bottom sheet on phones, centered on wide screens */
dialog.hoja { border: 2px solid var(--line); background: var(--surface); color: var(--text); border-radius: 20px 20px 0 0;
  padding: 18px; width: min(100%, 560px); max-height: 92dvh; overflow: auto; margin: auto auto 0; }
dialog.hoja::backdrop { background: rgba(0, 0, 0, .7); }
@media (min-width: 700px) { dialog.hoja { margin: auto; border-radius: 20px; } }
dialog.hoja h2 { font-size: 1.3rem; margin-bottom: 14px; }
.opciones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.opciones .btn { min-height: 64px; padding: 6px; }
.aviso { padding: 10px 14px; border-radius: 12px; font-weight: 700; background: var(--warn); color: var(--warn-ink); }
.aviso.danger { background: var(--danger); color: var(--danger-ink); }

/* Tables */
.tabla-wrap { overflow-x: auto; border: 2px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; background: var(--surface); }
td.r, th.r { text-align: right; }
@media (max-width: 600px) { th, td { padding: 8px 7px; font-size: .85rem; } }
tr:last-child td { border-bottom: 0; }

/* Confirmation overlay with the order number in huge type */
.gran-numero { position: fixed; inset: 0; z-index: 90; background: var(--ok); color: var(--ok-ink); display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 24px; cursor: pointer; }
.gran-numero .n { font-size: clamp(5rem, 28vw, 16rem); font-weight: 900; line-height: 1; }
.gran-numero .t { font-size: 1.6rem; font-weight: 800; }

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