/* Only Delivery — estilos compartidos (sin estilos en línea: CSP estricta) */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5; --text: #15181e; --muted: #5d6573; --border: #dde1e7;
  --brand: #0f6b5c; --brand-ink: #ffffff; --accent: #e3f3ef; --danger: #b42318; --danger-bg: #fdecea; --warn: #8a5a00; --warn-bg: #fff4d6;
  --ok: #117a3d; --ok-bg: #e6f6ec; --focus: #2563eb; --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --surface: #171b21; --surface-2: #1f242c; --text: #e8ebf0; --muted: #9aa3b2; --border: #2c323c;
    --brand: #3fb59f; --brand-ink: #06231e; --accent: #16302b; --danger: #ff8a80; --danger-bg: #3a1714; --warn: #ffcf66; --warn-bg: #3a2e10;
    --ok: #6fdc9a; --ok-bg: #12301f; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --surface: #171b21; --surface-2: #1f242c; --text: #e8ebf0; --muted: #9aa3b2; --border: #2c323c;
  --brand: #3fb59f; --brand-ink: #06231e; --accent: #16302b; --danger: #ff8a80; --danger-bg: #3a1714; --warn: #ffcf66; --warn-bg: #3a2e10;
  --ok: #6fdc9a; --ok-bg: #12301f; --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
h1 { font-size: 1.35rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
.mono { font-family: var(--mono); letter-spacing: .02em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* Estructura */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; color: var(--brand); white-space: nowrap; }
.env-badge { font-size: .72rem; padding: .1rem .45rem; border-radius: 999px; background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.spacer { flex: 1; }
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 50px); }
.sidenav { background: var(--surface); border-right: 1px solid var(--border); padding: .75rem .5rem; }
.sidenav button { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--text); padding: .55rem .75rem;
  border-radius: 8px; font: inherit; cursor: pointer; }
.sidenav button:hover { background: var(--surface-2); }
.sidenav button[aria-current="page"] { background: var(--accent); color: var(--brand); font-weight: 600; }
.sidenav .group { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .75rem .75rem .25rem; }
main { padding: 1.25rem; max-width: 1200px; width: 100%; }
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidenav { display: flex; overflow-x: auto; gap: .25rem; border-right: 0; border-bottom: 1px solid var(--border); padding: .4rem; }
  .sidenav button { white-space: nowrap; width: auto; }
  .sidenav .group { display: none; }
  main { padding: 1rem 16px; }
}

/* Componentes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; }
.stat .v { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--muted); font-size: .82rem; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
input, select, textarea { width: 100%; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text); font: inherit; min-height: 40px; }
textarea { min-height: 110px; font-family: var(--mono); font-size: .85rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.field { margin-bottom: .7rem; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 180px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); padding: .5rem .85rem; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; min-height: 40px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.small { padding: .25rem .55rem; min-height: 30px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .5rem .65rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; font-size: .8rem; color: var(--muted); position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
.pill { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--danger-bg); color: var(--danger); }
.pill.info { background: var(--accent); color: var(--brand); }
.alert { padding: .65rem .85rem; border-radius: 8px; margin: .5rem 0; background: var(--surface-2); }
.alert.error { background: var(--danger-bg); color: var(--danger); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.breakdown { width: 100%; font-variant-numeric: tabular-nums; }
.breakdown td:last-child { text-align: right; }
.breakdown tr.total td { font-weight: 700; border-top: 2px solid var(--border); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .45rem 0 .45rem 1rem; border-left: 2px solid var(--border); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .8rem; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 0; width: min(760px, calc(100vw - 32px)); max-height: 90vh; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog .dlg-head { display: flex; align-items: center; padding: .75rem 1rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
dialog .dlg-body { padding: 1rem; overflow: auto; }
.secret-box { font-family: var(--mono); word-break: break-all; padding: .6rem; border: 1px dashed var(--brand); border-radius: 8px; background: var(--accent); }
.center-page { max-width: 420px; margin: 8vh auto; padding: 0 16px; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: .5rem .75rem; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--brand); border-color: var(--brand); font-weight: 600; }
.toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 50; min-width: 240px; max-width: calc(100vw - 32px); }

/* PWA del mensajero */
.courier main { max-width: 640px; margin: 0 auto; }
.stop { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: .8rem; margin-bottom: .6rem; }
.stop .amount { font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stop .amount.zero { color: var(--muted); font-weight: 600; font-size: 1rem; }
.sync-bar { padding: .45rem 1rem; background: var(--warn-bg); color: var(--warn); font-weight: 600; text-align: center; }
.sync-bar.ok { background: var(--ok-bg); color: var(--ok); }
canvas.signature { width: 100%; height: 180px; border: 1px dashed var(--border); border-radius: 8px; background: #fff; touch-action: none; }
video.scanner { width: 100%; border-radius: 8px; background: #000; max-height: 260px; }
.big-btns { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.big-btns .btn { min-height: 52px; }
