:root {
  --bg: #f4f1ea; --surface: #ffffff; --surface-2: #faf8f3; --ink: #1f2a24; --muted: #6b726c;
  --line: #e2ddd2; --brand: #2f4a3a; --brand-2: #3f6450; --accent: #b0703c; --accent-soft: #f6e8db;
  --ok: #2e7d4f; --ok-soft: #e3f2e8; --bad: #b3261e; --bad-soft: #fbe7e5; --warn: #a76a00; --warn-soft: #fdf1d8;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.05);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-size: 15px; }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
input, select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: transparent; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; font-weight: 500; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }
.hidden { display: none !important; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px;
  border-radius: 10px; font-weight: 600; background: var(--surface); border: 1px solid var(--line); min-height: 44px; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.chip { display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 999px; font-size: 12.5px;
  font-weight: 600; border: 1px solid var(--line); background: var(--surface); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: #7a4518; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }

/* ---------- login */
.login { min-height: 100%; display: flex; justify-content: center; align-items: center; padding: 24px 16px; }
.login-box { width: 100%; max-width: 440px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand img { width: 52px; height: 52px; border-radius: 14px; }
.brand h1 { font-size: 21px; }
.login-box .brand { justify-content: flex-start; }
.ugroup + .ugroup { margin-top: 18px; }
.ulabel { font-size: 12.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 8px 2px; }
.users { display: flex; flex-direction: column; gap: 8px; }
.user-card { display: flex; align-items: center; gap: 14px; width: 100%; background: var(--surface); border-radius: 12px;
  padding: 12px 14px; box-shadow: var(--shadow); text-align: left; min-height: 64px; }
.user-card:active { transform: scale(.99); }
.user-card .av { width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; }
.user-card.role-owner .av { background: var(--accent); }
.user-card .un { flex: 1; font-size: 16.5px; font-weight: 600; }
.user-card .chev { color: var(--muted); font-size: 22px; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 18px 0; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--brand); }
.pin-dots span.f { background: var(--brand); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pinpad button { height: 62px; border-radius: 14px; background: var(--surface); font-size: 22px; font-weight: 600;
  box-shadow: var(--shadow); }
.pinpad button.fn { font-size: 15px; color: var(--muted); }

/* ---------- topbar */
.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--brand); color: #fff;
  position: sticky; top: 0; z-index: 5; }
.top .who { font-weight: 650; }
.top .sub { font-size: 12.5px; opacity: .8; }
.top .btn { background: rgba(255,255,255,.12); border-color: transparent; color: #fff; min-height: 40px; padding: 8px 12px; }
.top .cash { background: rgba(255,255,255,.14); border-radius: 10px; padding: 6px 10px; text-align: right; }
.top .cash b { display: block; font-size: 15px; }
.top-actions { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }

/* ---------- POS */
.pos { display: grid; grid-template-columns: 1fr 380px; height: calc(100% - 62px); }
.pos-menu { overflow: auto; padding: 14px 16px 24px; }
.tabs { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; position: sticky; top: 0;
  background: var(--bg); padding-bottom: 6px; z-index: 2; }
.tab { padding: 9px 16px; border-radius: 999px; background: var(--surface); font-weight: 600; white-space: nowrap;
  border: 1px solid var(--line); }
.tab.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.mcard { background: var(--surface); border-radius: 12px; padding: 12px; min-height: 92px; text-align: left;
  display: flex; flex-direction: column; justify-content: space-between; box-shadow: var(--shadow);
  border-left: 4px solid var(--brand-2); }
.mcard[data-s="Matcha"] { border-left-color: #7fa23a; }
.mcard[data-s="Coffee"] { border-left-color: #6b4423; }
.mcard[data-s="Royal"] { border-left-color: #8a5a9e; }
.mcard[data-s="Korean"] { border-left-color: #c2577a; }
.mcard b { font-size: 14.5px; line-height: 1.25; }
.mcard .p { color: var(--muted); font-weight: 600; margin-top: 8px; }
.mcard .q { align-self: flex-end; background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 9px;
  font-size: 13px; font-weight: 700; margin-top: -20px; }
.cart { background: var(--surface); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.cart-head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.cart-list { flex: 1; overflow: auto; padding: 6px 16px; }
.cline { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.cline .t { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.qty { display: inline-flex; align-items: center; gap: 4px; }
.qty button { width: 34px; height: 34px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line);
  font-size: 18px; font-weight: 700; }
.qty span { min-width: 26px; text-align: center; font-weight: 700; }
.addons { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.cart-foot { padding: 14px 16px; border-top: 1px solid var(--line); background: var(--surface-2); }
.total { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.total b { font-size: 26px; }
.pay { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay .btn { min-height: 56px; font-size: 16px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.cart-toggle { display: none; }

/* ---------- modal */
.overlay { position: fixed; inset: 0; background: rgba(20,25,22,.45); display: flex; align-items: center;
  justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 520px; max-height: calc(100% - 20px);
  display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 760px; }
.modal-h { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-b { padding: 4px 18px 18px; overflow: auto; }
.modal-f { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.x { width: 36px; height: 36px; border-radius: 10px; font-size: 22px; color: var(--muted); }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.big { font-size: 30px; font-weight: 700; }
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; padding: 9px 8px; border-radius: 8px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink);
  color: #fff; padding: 12px 18px; border-radius: 12px; opacity: 0; transition: .2s; pointer-events: none; z-index: 80;
  max-width: calc(100% - 32px); font-weight: 500; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { background: var(--bad); }

/* ---------- tables & lists */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12.5px; color: var(--muted); font-weight: 600; }
td.r, th.r { text-align: right; }
.list-item { display: flex; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.section { margin-top: 18px; }
.section > h3 { font-size: 15px; margin-bottom: 8px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.kpi { background: var(--surface); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); }
.kpi .l { font-size: 12.5px; color: var(--muted); }
.kpi .v { font-size: 20px; font-weight: 700; margin-top: 4px; }
.pos-val { color: var(--ok); } .neg-val { color: var(--bad); }

/* ---------- owner */
.owner { max-width: 980px; margin: 0 auto; padding: 14px 16px 96px; }
.bnav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line);
  display: flex; justify-content: center; z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
.bnav-in { display: flex; width: 100%; max-width: 980px; }
.bnav button { flex: 1; padding: 10px 4px 12px; font-size: 12px; font-weight: 600; color: var(--muted); display: flex;
  flex-direction: column; align-items: center; gap: 3px; }
.bnav button svg { width: 22px; height: 22px; }
.bnav button.on { color: var(--brand); }
.bnav .dot { background: var(--bad); color: #fff; border-radius: 999px; font-size: 10.5px; padding: 0 5px; margin-left: 2px; }
.page-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 6px 0 14px; flex-wrap: wrap; }
.page-h h2 { font-size: 20px; }
.ritem { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.recipe-row { display: grid; grid-template-columns: 1fr 90px 40px; gap: 8px; align-items: center; margin-top: 8px; }
.search { margin-bottom: 12px; }

@media (max-width: 900px) {
  .pos { grid-template-columns: 1fr; height: auto; }
  .cart { position: fixed; inset: auto 0 0 0; max-height: 78%; border-left: 0; border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,.15); transform: translateY(calc(100% - 74px));
    transition: transform .2s; z-index: 10; }
  .cart.open { transform: none; }
  .cart-toggle { display: flex; }
  .pos-menu { padding-bottom: 110px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .top { flex-wrap: wrap; row-gap: 8px; padding: 10px 12px; }
  .top .grow { min-width: 0; }
  .top .who, .top .grow .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top-actions { order: 3; flex-basis: 100%; }
  .top-actions .btn { flex: none; }
  .top .cash { padding: 4px 10px; }
  .top .cash .sub { white-space: nowrap; }
}
@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  
  .modal { border-radius: 16px; }
  .overlay { padding: 8px; align-items: flex-end; }
}

tr.click { cursor: pointer; }
tr.click:active td { background: var(--surface-2); }
.tw { overflow-x: auto; }
a { color: var(--brand-2); font-weight: 600; text-decoration: none; }
@media (max-width: 520px) { th, td { padding: 8px 4px; font-size: 14px; } }
