/* Uni-AI F&B POS -- shared look. Warm paper, ink, and the restaurant's accent
   (set per restaurant in Settings → Business; defaults to a tea-house red). */
:root {
  --accent: #8b1e1e;
  --accent-ink: #fff;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--bg));
  --bg: #f7f3ec;
  --panel: #ffffff;
  --panel-2: #fbf8f3;
  --ink: #1f1a17;
  --ink-2: #5b524b;
  --ink-3: #8c827a;
  --line: #e7dfd3;
  --line-2: #d8cdbf;
  --ok: #1f7a4d;
  --ok-soft: #e3f3ea;
  --warn: #b86a00;
  --warn-soft: #fdf0dc;
  --bad: #b3261e;
  --bad-soft: #fbe6e4;
  --info: #1d5fa8;
  --info-soft: #e4eefa;
  --gold: #a87a1c;
  --shadow: 0 1px 2px rgb(40 25 10 / 6%), 0 4px 16px rgb(40 25 10 / 6%);
  --radius: 14px;
  --radius-s: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171412; --panel: #221e1b; --panel-2: #1c1916; --ink: #f3ece4; --ink-2: #c4b9ae; --ink-3: #8f857b;
    --line: #342e29; --line-2: #463e37; --ok-soft: #173326; --warn-soft: #3a2a12; --bad-soft: #3a1b18; --info-soft: #172a40;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 18px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171412; --panel: #221e1b; --panel-2: #1c1916; --ink: #f3ece4; --ink-2: #c4b9ae; --ink-3: #8f857b;
  --line: #342e29; --line-2: #463e37; --ok-soft: #173326; --warn-soft: #3a2a12; --bad-soft: #3a1b18; --info-soft: #172a40;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 18px rgb(0 0 0 / 25%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 16px; }
.muted { color: var(--ink-2); } .faint { color: var(--ink-3); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; } .row.wrap { flex-wrap: wrap; } .row.top { align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; } .right { margin-left: auto; } .center { text-align: center; }
.gap-s { gap: 6px; } .gap-l { gap: 16px; }
.sep { height: 1px; background: var(--line); margin: 10px 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- buttons ---------- */
.btn { appearance: none; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); border-radius: var(--radius-s);
  padding: 10px 16px; min-height: 44px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .06s, background .15s, border-color .15s; user-select: none; text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.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 { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.lg { min-height: 56px; font-size: 17px; padding: 14px 22px; }
.btn.block { width: 100%; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); display: inline-grid; place-items: center; cursor: pointer; font-size: 18px; padding: 0; }

/* ---------- inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line-2); background: var(--panel); border-radius: var(--radius-s); padding: 10px 12px; min-height: 44px; outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { min-height: 80px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); margin-top: 1px; flex: none; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line-2); border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgb(0 0 0 / 25%); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 99px; background: var(--panel); overflow: hidden; }
.stepper button { width: 38px; height: 38px; border: 0; background: transparent; font-size: 20px; font-weight: 700; cursor: pointer; color: var(--accent); }
.stepper button:disabled { color: var(--ink-3); }
.stepper b { min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; }
.stepper.lg button { width: 52px; height: 52px; font-size: 26px; } .stepper.lg b { min-width: 44px; font-size: 22px; }

/* ---------- surfaces ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card.tight { padding: 12px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line-2); background: var(--panel); border-radius: 99px; padding: 7px 14px; font-weight: 600; cursor: pointer; white-space: nowrap; font-size: 14px; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tabs { display: flex; gap: 4px; background: var(--panel-2); border: 1px solid var(--line); padding: 4px; border-radius: 12px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 9px 10px; border-radius: 9px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.tabs button.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi b { font-size: 24px; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12px; color: var(--ink-2); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-size: 12px; color: var(--ink-2); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr.click { cursor: pointer; } table.list tr.click:hover td { background: var(--panel-2); }
table.list td.r, table.list th.r { text-align: right; }
.empty { padding: 30px 16px; text-align: center; color: var(--ink-3); }

/* ---------- overlays ---------- */
.scrim { position: fixed; inset: 0; background: rgb(20 12 6 / 42%); z-index: 50; animation: fade .15s; }
.sheet { position: fixed; z-index: 51; background: var(--panel); box-shadow: 0 -6px 30px rgb(0 0 0 / 18%); display: flex; flex-direction: column; animation: up .2s ease-out;
  left: 0; right: 0; bottom: 0; max-height: 92vh; border-radius: 20px 20px 0 0; }
.sheet .sheet-head { padding: 16px 18px 10px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.sheet .sheet-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.sheet .sheet-foot { padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 10px; }
@media (min-width: 900px) {
  .sheet.side { left: auto; top: 0; bottom: 0; width: min(560px, 46vw); max-height: none; border-radius: 0; animation: slide .2s ease-out; }
  .sheet.center { left: 50%; top: 50%; bottom: auto; transform: translate(-50%, -50%); width: min(520px, 92vw); border-radius: 18px; animation: pop .15s ease-out; max-height: 90vh; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
@keyframes pop { from { transform: translate(-50%, -48%) scale(.98); opacity: 0; } }
.toasts { position: fixed; z-index: 80; left: 50%; transform: translateX(-50%); bottom: 24px; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 520px); }
.toast { background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); font-weight: 600; pointer-events: auto; animation: up .2s; max-width: 100%; }
.toast.bad { background: var(--bad); color: #fff; } .toast.ok { background: var(--ok); color: #fff; }
.banner { padding: 10px 14px; border-radius: var(--radius-s); font-weight: 600; font-size: 14px; }
.banner.bad { background: var(--bad-soft); color: var(--bad); } .banner.warn { background: var(--warn-soft); color: var(--warn); } .banner.info { background: var(--info-soft); color: var(--info); } .banner.ok { background: var(--ok-soft); color: var(--ok); }
.offline { position: fixed; top: 0; left: 0; right: 0; z-index: 90; background: var(--bad); color: #fff; text-align: center; padding: 8px; font-weight: 700; }

/* ---------- PIN pad ---------- */
.pinpad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; justify-content: center; }
.pinpad button { height: 64px; border-radius: 16px; border: 1px solid var(--line-2); background: var(--panel); font-size: 24px; font-weight: 700; cursor: pointer; }
.pinpad button:active { background: var(--accent-soft); }
.pindots { display: flex; gap: 14px; justify-content: center; margin: 14px 0; }
.pindots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink-3); }
.pindots i.on { background: var(--ink); border-color: var(--ink); }
.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ---------- misc ---------- */
.qr { background: #fff; padding: 12px; border-radius: 12px; display: inline-block; line-height: 0; }
.qr svg, .qr img { display: block; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.lang-toggle { display: inline-flex; border: 1px solid var(--line-2); border-radius: 99px; overflow: hidden; }
.lang-toggle button { border: 0; background: transparent; padding: 6px 12px; font-weight: 700; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.lang-toggle button.on { background: var(--ink); color: var(--bg); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--ink-3); }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }
@media print { .no-print { display: none !important; } }
