/* Bar Colis - shared design system. System fonts only (no font download = faster). */
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0eee9;
  --border: #e5e2db;
  --text: #1c1b19;
  --muted: #6f6b63;
  --accent: #c8782a;
  --accent-ink: #ffffff;
  --accent-soft: #f6e7d6;
  --ok: #1f8a4c;
  --ok-soft: #dcf2e4;
  --warn: #b7791f;
  --warn-soft: #fbefd5;
  --danger: #c43d3d;
  --danger-soft: #fbe1e1;
  --info: #2f6fca;
  --info-soft: #dfeafb;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.18);
  --r: 14px;
  --r-sm: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121110;
    --surface: #1c1b19;
    --surface-2: #262421;
    --border: #34312d;
    --text: #f3f1ec;
    --muted: #a39e94;
    --accent: #e39a4f;
    --accent-ink: #1a1207;
    --accent-soft: #3a2a1a;
    --ok: #4cc27f;
    --ok-soft: #173524;
    --warn: #e2b04f;
    --warn-soft: #3a2f17;
    --danger: #ef6b6b;
    --danger-soft: #3d1c1c;
    --info: #6ea5f2;
    --info-soft: #1a2a40;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #121110;
    --surface: #1c1b19;
    --surface-2: #262421;
    --border: #34312d;
    --text: #f3f1ec;
    --muted: #a39e94;
    --accent: #e39a4f;
    --accent-ink: #1a1207;
    --accent-soft: #3a2a1a;
    --ok: #4cc27f;
    --ok-soft: #173524;
    --warn: #e2b04f;
    --warn-soft: #3a2f17;
    --danger: #ef6b6b;
    --danger-soft: #3d1c1c;
    --info: #6ea5f2;
    --info-soft: #1a2a40;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
    color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer;
  transition: transform .08s ease, background .15s ease, opacity .15s; user-select: none; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.soft { background: var(--surface-2); border-color: transparent; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn.lg { min-height: 54px; font-size: 17px; padding: 0 24px; }
.btn.block { width: 100%; }
.btn.icon { width: 44px; padding: 0; }
.btn.sm.icon { width: 34px; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .chip:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px;
}

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 14px; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface); outline: none;
}
.input:focus { border-color: var(--accent); }
textarea.input { min-height: 80px; resize: vertical; }
.code-input { font-size: 28px; letter-spacing: 10px; text-align: center; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 46px; height: 28px; border-radius: 999px; background: var(--border); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); }
.pad { padding: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.new { background: var(--info-soft); color: var(--info); }
.badge.preparing { background: var(--warn-soft); color: var(--warn); }
.badge.served { background: var(--accent-soft); color: var(--accent); }
.badge.paid { background: var(--ok-soft); color: var(--ok); }
.badge.cancelled { background: var(--danger-soft); color: var(--danger); }

/* ---------- dialogs / sheets ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92dvh;
  border-radius: 22px 22px 0 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
}
dialog.sheet:not([open]) { display: none; }
dialog.sheet::backdrop { background: rgba(0,0,0,.45); backdrop-filter: blur(2px); }
dialog.sheet[open] { animation: sheet-up .22s cubic-bezier(.2,.8,.2,1); }
@media (min-width: 700px) { dialog.sheet { margin: auto; border-radius: 22px; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 10px; }
.sheet-head h2 { margin: 0; font-size: 20px; flex: 1; }
.sheet-body { padding: 4px 18px 18px; overflow: auto; overscroll-behavior: contain; }
.sheet-foot { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface); }
.grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 8px auto 0; }
@media (min-width: 700px) { .grabber { display: none; } }

/* ---------- toast ---------- */
#toasts { position: fixed; left: 0; right: 0; top: calc(10px + env(safe-area-inset-top)); display: grid; justify-items: center; gap: 8px; z-index: 1000; pointer-events: none; padding: 0 16px; }
.toast { pointer-events: auto; max-width: 480px; background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow-lg); font-weight: 600; font-size: 15px; animation: toast-in .2s ease; display: flex; gap: 10px; align-items: center; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
.toast button { background: transparent; border: 0; color: inherit; font-weight: 800; text-decoration: underline; cursor: pointer; padding: 0; }
@keyframes toast-in { from { transform: translateY(-10px); opacity: 0; } }

.offline-bar { position: sticky; top: 0; z-index: 60; background: var(--danger); color: #fff; text-align: center; font-weight: 600; font-size: 14px; padding: 6px 12px; }

.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--r); }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .big { font-size: 42px; margin-bottom: 6px; }

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