:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --ink: #2b2622;
  --muted: #7a6f66;
  --line: #e6dfd5;
  --accent: #2f5d50;
  --accent-soft: #e3ede9;
  --warn: #a86a12;
  --warn-soft: #fbf0dc;
  --bad: #b0432d;
  --bad-soft: #f8e4df;
  --ok: #2e7d4f;
  --ok-soft: #e1f2e7;
  --radius: 14px;
  --tabs-h: 64px;
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- top bar & tabs ---------- */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--bg);
  border-bottom: 1px solid var(--line); }
.topbar__logo { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; flex: none; border: 1px solid var(--line); background: #fff; }
.logo-prev { width: 96px; height: 96px; border-radius: 20px; object-fit: cover; border: 1px solid var(--line); background: #fff; display: block; }
.logo-empty { width: 96px; height: 96px; border-radius: 20px; border: 2px dashed var(--line); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .8rem; text-align: center; }
.topbar__title { flex: 1; font-weight: 700; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__btn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 14px; font-size: .9rem; }

.view { padding: 12px 14px calc(var(--tabs-h) + 24px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; height: var(--tabs-h); border: 0; background: none; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; font-size: .78rem; color: var(--muted); }
.tab__ic { font-size: 1.25rem; line-height: 1; }
.tab.is-active { color: var(--accent); font-weight: 600; }

/* ---------- common ---------- */
h2 { font-size: 1.05rem; margin: 18px 4px 8px; }
h2 .count { display: inline-block; min-width: 22px; padding: 1px 7px; margin-left: 6px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: .8rem; text-align: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; align-items: center; gap: 8px; }
.row--between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }
.empty__big { font-size: 2.2rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 14px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: .92rem;
  text-decoration: none; color: var(--ink); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--wa { background: #1f8f4e; border-color: #1f8f4e; color: #fff; }
.btn--danger { color: var(--bad); }
.btn--block { width: 100%; min-height: 50px; font-size: 1rem; }
.btn--sm { min-height: 34px; padding: 4px 10px; font-size: .85rem; }
.btn:disabled { opacity: .45; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600;
  background: #efe9e1; color: var(--muted); white-space: nowrap; }
.pill--accent { background: var(--accent-soft); color: var(--accent); }
.pill--warn { background: var(--warn-soft); color: var(--warn); }
.pill--bad { background: var(--bad-soft); color: var(--bad); }
.pill--ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- order card ---------- */
.oc { cursor: pointer; }
.oc__top { display: flex; align-items: baseline; gap: 8px; }
.oc__no { font-weight: 700; }
.oc__name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oc__amt { font-weight: 700; }
.oc__items { margin-top: 4px; color: var(--muted); font-size: .88rem; }
.oc__pills { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }

/* ---------- forms ---------- */
label.f { display: block; font-size: .85rem; color: var(--muted); margin: 12px 2px 5px; }
.input, select.input, textarea.input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); font-size: 16px; }
textarea.input { min-height: 78px; resize: vertical; }
.input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.seg { display: flex; background: #ece6dd; border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 10px 4px; font-weight: 600; font-size: .9rem; color: var(--muted); }
.seg button.is-on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 2px; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }

/* book picker */
.bk { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--card); margin-bottom: 8px; }
.bk.is-picked { border-color: var(--accent); background: #f5faf8; }
.bk__code { flex: none; width: 42px; height: 42px; border-radius: 10px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 800; }
.bk__title { font-weight: 600; line-height: 1.25; }
.qty { display: flex; align-items: center; gap: 4px; flex: none; }
.qty button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-size: 1.3rem; }
.qty span { min-width: 26px; text-align: center; font-weight: 700; font-size: 1.05rem; }

.sumbar { position: fixed; left: 0; right: 0; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); z-index: 4;
  padding: 10px 14px; background: rgba(246,243,238,.96); border-top: 1px solid var(--line); }
.sumbar__in { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.view--with-sumbar { padding-bottom: calc(var(--tabs-h) + 96px + env(safe-area-inset-bottom)); }

/* ---------- order detail ---------- */
.steps { display: flex; gap: 4px; margin: 10px 0 4px; }
.steps i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.steps i.on { background: var(--accent); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; }
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: .88rem; }
.tl li:last-child { border-bottom: 0; }
.tl .raw { margin-top: 4px; padding: 6px 8px; background: #f3efe9; border-radius: 8px; font-size: .8rem; color: var(--muted); }

/* ---------- sheet / toast ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(30,25,20,.35); z-index: 20; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 92vh; overflow: auto;
  background: var(--bg); border-radius: 18px 18px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 24px rgba(0,0,0,.15); }
.sheet__grip { width: 40px; height: 5px; background: var(--line); border-radius: 3px; margin: 4px auto 10px; }
.sheet__head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.sheet__title { flex: 1; font-weight: 700; font-size: 1.1rem; }
.sheet__close { border: 0; background: #ece6dd; width: 34px; height: 34px; border-radius: 50%; font-size: 1.1rem; }
@media (min-width: 700px) { .sheet { left: 50%; right: auto; width: 620px; transform: translateX(-50%); } }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + 18px + env(safe-area-inset-bottom));
  z-index: 30; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .92rem; max-width: 90vw; }
.toast.is-err { background: var(--bad); }

.setup { max-width: 420px; margin: 60px auto; text-align: center; }
