/* Shared POS styles: touch-first, large targets, readable in bright light. */
:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --panel-2: #f5f7f9;
  --line: #d9dee4;
  --text: #15191e;
  --muted: #5d6874;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --good: #15803d;
  --warn: #b45309;
  --bad: #c62828;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --panel: #171c22;
    --panel-2: #1f262e;
    --line: #2c353f;
    --text: #e8ebee;
    --muted: #93a0ad;
    --accent: #4b8dff;
    --good: #34c37a;
    --warn: #e2a33b;
    --bad: #ef5350;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
/* The app fills the visible screen exactly (dvh follows mobile browser toolbars). */
#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
#main { flex: 1; min-height: 0; }
[hidden] { display: none !important; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  user-select: none;
}
input, textarea, select { user-select: text; }
h1 { font-size: 24px; margin: 0 0 8px; }
h2 { font-size: 20px; margin: 0 0 8px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 650; }
.spacer { flex: 1; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.big { min-height: 56px; font-size: 17px; padding: 10px 20px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.btn.danger-fill { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.on { background: color-mix(in srgb, var(--accent) 14%, var(--panel)); border-color: var(--accent); color: var(--accent); }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
.seg button { min-height: 40px; padding: 6px 14px; border: 0; background: transparent; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: var(--accent-text); }
.seg.big button { min-height: 52px; flex: 1; font-size: 17px; }
.seg.big { display: flex; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--muted); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.ok { color: var(--good); }
.chip.warn { color: var(--warn); }
.chip.info { color: var(--accent); cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; background: var(--panel-2); color: var(--muted); }
.badge.s-paid { color: var(--good); }
.badge.s-open { color: var(--accent); }
.badge.s-void, .badge.s-refunded { color: var(--bad); }

/* forms */
.field { display: block; font-size: 14px; color: var(--muted); font-weight: 600; margin-bottom: 14px; }
.field input, .field select, .field textarea {
  display: block; width: 100%; margin-top: 6px; min-height: 48px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); font: inherit; font-weight: 400;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 12px; color: var(--text); }
.form-error { color: var(--bad); font-weight: 600; min-height: 1.4em; margin: 4px 0; }

/* colors used by categories and items */
.c-slate { --tint: #64748b; } .c-red { --tint: #dc2626; } .c-orange { --tint: #ea580c; } .c-amber { --tint: #d97706; }
.c-green { --tint: #16a34a; } .c-teal { --tint: #0d9488; } .c-blue { --tint: #2563eb; } .c-purple { --tint: #7c3aed; } .c-pink { --tint: #db2777; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.swatch-pick { position: relative; width: 40px; height: 40px; border-radius: 10px; background: var(--tint, var(--panel-2)); border: 2px solid var(--line); cursor: pointer; }
.swatch-pick input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.swatch-pick:has(input:checked) { outline: 3px solid var(--text); outline-offset: 2px; }
.swatch-pick.inherit { display: grid; place-items: center; font-size: 11px; color: var(--muted); width: auto; padding: 0 8px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; background: var(--tint, var(--line)); flex: none; }

/* sheets */
#sheet { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
#sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); }
.sheet {
  position: relative; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--panel); border-radius: 16px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.sheet.wide { width: min(900px, 100%); }
.sheet-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; }
.sheet-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* pin pad */
.pin { width: 100%; max-width: 320px; margin: 0 auto; }
.pin-dots { display: flex; justify-content: center; gap: 14px; height: 24px; margin: 8px 0 18px; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.pin-dots span.on { background: var(--text); border-color: var(--text); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pad-key {
  min-height: 64px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font: 600 24px/1 system-ui, sans-serif; cursor: pointer;
}
.pad-key:active { background: var(--line); }
.pin-ok { width: 100%; margin-top: 12px; }
.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

/* lock + setup screens */
.lock, .setup {
  flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 16px;
  padding: max(64px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.lock-top {
  position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 14px max(18px, env(safe-area-inset-left));
}
.lock-biz { font-weight: 700; font-size: 18px; }
.lock-card, .setup-card { width: 100%; max-width: 420px; background: var(--panel); border-radius: 20px; padding: 28px 24px; text-align: center; box-shadow: 0 6px 30px rgba(0,0,0,.08); }
.setup-card { max-width: 520px; text-align: left; }
.lock-clock { font-size: 40px; font-weight: 700; font-variant-numeric: tabular-nums; }
.brand-mark { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--accent); margin-bottom: 16px; }
.brand-icon { width: 32px; height: 32px; border-radius: 8px; vertical-align: middle; }
.lock-biz { display: inline-flex; align-items: center; gap: 10px; }
.choices { display: grid; gap: 12px; margin-top: 16px; }
.choice { text-align: left; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); color: var(--text); font: inherit; cursor: pointer; }
.choice strong { display: block; font-size: 18px; margin-bottom: 4px; }
.choice span { color: var(--muted); }

/* top bar */
.bar {
  flex: none; display: flex; align-items: center; gap: 12px; min-height: 60px; background: var(--panel); border-bottom: 1px solid var(--line);
  padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
}
.bar-biz { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav-btn { min-height: 44px; padding: 6px 14px; border-radius: 10px; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 650; cursor: pointer; white-space: nowrap; }
.nav-btn.on { background: var(--panel-2); color: var(--text); }
.bar-right { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.bar-clock { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.bar-user { font: inherit; font-weight: 650; color: var(--text); background: none; border: 1px solid transparent; border-radius: 10px; min-height: 44px; padding: 4px 10px; cursor: pointer; }
.bar-user:hover { border-color: var(--line); }
.lock-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; }
.big-pin { font: 800 48px/1 var(--mono); letter-spacing: .2em; text-align: center; padding: 20px 0; margin: 12px 0; background: var(--panel-2); border-radius: var(--radius); }

/* pages (orders, reports, menu, settings) */
.page {
  height: 100%; overflow-y: auto; max-width: 1200px; margin: 0 auto;
  padding: 18px max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover { background: var(--panel-2); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th.num, .tbl td.num { text-align: right; }
.rows { display: grid; gap: 8px; margin-bottom: 20px; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 14px; width: 100%;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.row .grow { flex: 1; min-width: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat-n { font-size: 26px; font-weight: 750; font-variant-numeric: tabular-nums; }
.stat-l { color: var(--muted); font-size: 13px; }
.cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 16px; align-items: start; }
.cols .card { margin: 0; }
.mini { width: 100%; border-collapse: collapse; }
.mini td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.mini tr:last-child td { border-bottom: 0; }
.empty { padding: 40px 16px; text-align: center; }

/* toast + overlay */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 80;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; max-width: calc(100vw - 32px);
}
.toast.error { background: var(--bad); color: #fff; }
#overlay { position: fixed; inset: 0; z-index: 70; background: rgba(10, 12, 15, .92); display: grid; place-items: center; padding: 16px; color: #fff; text-align: center; }
#overlay[hidden] { display: none; }
.overlay-card { max-width: 440px; }
.overlay-card h1 { font-size: 30px; }

/* phones: sheets slide up from the bottom, full width, clear of the home indicator */
@media (max-width: 600px) {
  #sheet { padding: 0; place-items: end stretch; }
  .sheet, .sheet.wide {
    width: 100%; max-height: 92dvh; border-radius: 18px 18px 0 0;
    padding: 18px max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  }
  .sheet-actions .btn.big { flex: 1; }
  .sheet-actions .spacer { display: none; }
  .lock-card, .setup-card { padding: 22px 16px; }
  .field-row { grid-template-columns: 1fr; }
  .bar-biz { display: none; }
  .page-head h1 { font-size: 20px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-n { font-size: 20px; }
}
/* very narrow (Galaxy Z Fold cover screen ~344px) */
@media (max-width: 380px) {
  body { font-size: 15px; }
  .pad { gap: 8px; }
  .pad-key { min-height: 58px; }
  .btn { padding: 8px 12px; }
  .bar { gap: 8px; }
  .nav-btn { padding: 6px 10px; }
}
/* short screens (phones sideways, ~360-430px tall) */
@media (max-height: 520px) {
  .bar { min-height: 48px; padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 4px; }
  .lock { padding-top: max(52px, env(safe-area-inset-top)); }
  .lock-card { padding: 14px 18px; }
  .lock-clock { font-size: 26px; }
  .lock-card h2 { font-size: 16px; margin-bottom: 4px; }
  .pin-dots { margin: 4px 0 10px; }
  .pad-key { min-height: 46px; font-size: 20px; }
  .btn.big { min-height: 48px; }
  .sheet { max-height: calc(100dvh - 16px); padding: 14px 18px; }
}

/* printing: only the receipt is printed, sized for 80mm thermal paper */
#print-area { display: none; }
@media print {
  @page { size: 80mm auto; margin: 3mm; }
  body { background: #fff; color: #000; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  .r { width: 72mm; font: 12px/1.35 var(--mono); color: #000; }
  .r hr { border: 0; border-top: 1px dashed #000; margin: 6px 0; }
  .r-c { text-align: center; }
  .r-big { font-size: 15px; font-weight: 700; }
  .r-row { display: flex; justify-content: space-between; gap: 8px; }
  .r-sub { padding-left: 12px; font-size: 11px; }
  .r-foot { margin-top: 10px; }
  .k-num { font-size: 34px; font-weight: 800; }
  .k-type { font-size: 18px; font-weight: 800; }
  .k-line { font-size: 16px; font-weight: 700; margin-top: 6px; }
  .k-mod { padding-left: 14px; font-size: 14px; }
  .k-note { padding-left: 14px; font-size: 14px; font-weight: 700; }
}
