/* VendorPOSPro — tablet POS
   Design intent: outdoor-readable working tool. Light "griddle steel" ground,
   near-black ink, one hot accent (flat-top red). Kitchen-ticket vernacular:
   the order rail is a paper ticket; kitchen cards are tickets on a rail.
   System font stack on purpose — offline must never break typography. */

:root {
  --bg: #EEF0ED;
  --panel: #FFFFFF;
  --ink: #171A1E;
  --ink-soft: #5A6169;
  --line: #D7DAD5;
  --accent: #C8331F;      /* flat-top red */
  --accent-ink: #FFFFFF;
  --ok: #2E6E4E;          /* line-cook green */
  --warn: #B77400;
  --ticket-edge: repeating-linear-gradient(90deg, var(--panel) 0 12px, transparent 12px 24px);
  --radius: 10px;
  --tap: 64px;            /* minimum touch target */
  font-size: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.hidden { display: none !important; }
.view { min-height: 100vh; }

/* ---------- buttons ---------- */
.btn {
  min-height: var(--tap);
  padding: 0 22px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:disabled { background: var(--line); border-color: var(--line); color: var(--ink-soft); }
.btn-big { min-height: 72px; font-size: 1.2rem; }
.btn-ghost { background: transparent; border: none; color: var(--ink-soft); font-weight: 600; min-height: 44px; cursor: pointer; }

/* ---------- login ---------- */
#view-login { display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 36px 32px;
  display: grid;
  gap: 18px;
}
.brand {
  font-size: 1.9rem; font-weight: 900; letter-spacing: 0.06em;
}
.brand span { color: var(--accent); }
.brand-sub { color: var(--ink-soft); margin-top: -12px; }
label { display: grid; gap: 6px; font-weight: 700; font-size: 0.9rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); }
input[type=email], input[type=password], input[type=text] {
  min-height: 56px; padding: 0 14px; font-size: 1.1rem;
  border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--bg); color: var(--ink);
}
input:focus { outline: none; border-color: var(--ink); }
.login-msg { color: var(--accent); font-weight: 600; min-height: 1.2em; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 16px;
  background: var(--ink); color: #fff;
}
.topbar-brand { font-weight: 900; letter-spacing: 0.05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 26vw; }
.topbar-tabs { display: flex; gap: 8px; flex: 1; }
.tab {
  min-height: 52px; padding: 0 20px;
  border: none; border-radius: 8px;
  background: transparent; color: #cfd4d9;
  font-size: 1.05rem; font-weight: 700; cursor: pointer;
}
.tab.active { background: #fff; color: var(--ink); }
.kbadge {
  display: inline-block; min-width: 24px; padding: 2px 7px; margin-left: 6px;
  border-radius: 999px; background: var(--accent); color: #fff; font-size: 0.85rem;
}
.topbar-status { display: flex; align-items: center; gap: 12px; }
.topbar-status .btn-ghost { color: #cfd4d9; }
.conn { font-weight: 800; font-size: 0.8rem; letter-spacing: 0.08em; padding: 6px 12px; border-radius: 999px; }
.conn.online { background: var(--ok); color: #fff; }
.conn.offline { background: var(--warn); color: #fff; }
.outbox-pill { font-size: 0.8rem; font-weight: 700; color: #ffd9a0; }

.cap-banner {
  padding: 12px 16px; font-weight: 700; text-align: center;
  background: var(--warn); color: #fff;
}
.cap-banner.blocked { background: var(--accent); }

/* ---------- register layout ---------- */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0;
  height: calc(100vh - 72px);
}
.pos-left { display: flex; flex-direction: column; overflow: hidden; }

.crumbs {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px;
}
.crumb {
  min-height: 48px; padding: 0 18px;
  border: 2px solid var(--ink); border-radius: 999px;
  background: var(--panel); font-weight: 800; font-size: 0.95rem;
  letter-spacing: 0.03em; cursor: pointer;
}
.crumb.here { background: var(--ink); color: #fff; }

.grid {
  flex: 1; overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px; padding: 4px 16px 16px;
  align-content: start;
}
.tile {
  min-height: 110px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--panel);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 12px; cursor: pointer; text-align: left;
}
.tile:active { transform: scale(0.98); }
.tile .t-name { font-weight: 800; font-size: 1.05rem; line-height: 1.15; }
.tile .t-price { font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; font-weight: 700; color: var(--ink-soft); }
.tile.cat { background: var(--ink); color: #fff; border-color: var(--ink); }
.tile.cat .t-price { color: #aeb6bd; font-family: inherit; font-size: 0.8rem; letter-spacing: 0.08em; }
.tile.soldout { opacity: 0.45; }
.tile.soldout .t-name::after { content: " · 86'd"; color: var(--accent); }
.tile .t-low { font-size: 0.75rem; font-weight: 800; color: var(--warn); }

/* ---------- ticket rail ---------- */
.ticket {
  background: var(--panel);
  border-left: 2px solid var(--ink);
  display: flex; flex-direction: column;
}
.ticket-head {
  padding: 14px 16px 10px;
  font-weight: 900; letter-spacing: 0.14em; font-size: 0.8rem;
  border-bottom: 2px dashed var(--line);
}
.ticket-lines { flex: 1; overflow-y: auto; padding: 8px 0; }
.ticket-empty { padding: 24px 16px; color: var(--ink-soft); }
.tline {
  display: grid; grid-template-columns: 44px 1fr auto 44px;
  align-items: center; gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 1rem;
}
.tline .q { font-weight: 900; text-align: center; }
.tline .amt { font-family: ui-monospace, Menlo, monospace; font-weight: 700; }
.tline .rm {
  min-height: 44px; min-width: 44px; border: none; background: transparent;
  color: var(--accent); font-size: 1.3rem; font-weight: 900; cursor: pointer;
}
.ticket-total {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  border-top: 2px dashed var(--line);
  font-size: 1.4rem; font-weight: 900;
}
.ticket-total span:last-child { font-family: ui-monospace, Menlo, monospace; }
.ticket-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; padding: 0 16px 16px; }

/* ---------- kitchen ---------- */
.kitchen-layout {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  padding: 16px; height: calc(100vh - 72px);
}
.kitchen-col { display: flex; flex-direction: column; overflow: hidden; }
.kitchen-col-head {
  font-weight: 900; letter-spacing: 0.12em; font-size: 0.85rem;
  padding: 10px 14px; border-radius: 8px 8px 0 0; color: #fff;
}
.col-paid { background: var(--warn); }
.col-ready { background: var(--ok); }
.kitchen-cards { flex: 1; overflow-y: auto; display: grid; gap: 10px; padding: 12px 2px; align-content: start; }
.kcard {
  background: var(--panel);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
}
.kcard:active { transform: scale(0.99); }
.kcard .k-name { font-weight: 900; font-size: 1.3rem; }
.kcard .k-lines { color: var(--ink-soft); font-size: 0.95rem; margin: 6px 0; }
.kcard .k-hint { font-size: 0.8rem; font-weight: 800; letter-spacing: 0.06em; color: var(--accent); }
.kcard.ready .k-hint { color: var(--ok); }
.kcard .k-age { float: right; font-family: ui-monospace, Menlo, monospace; color: var(--ink-soft); }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(23,26,30,0.55);
  display: grid; place-items: center; z-index: 50; padding: 20px;
}
.modal {
  width: min(480px, 100%);
  background: var(--panel);
  border: 2px solid var(--ink); border-radius: 14px;
  padding: 26px; display: grid; gap: 18px;
}
.modal-title { font-size: 1.5rem; font-weight: 900; }
.modal-title span { font-family: ui-monospace, Menlo, monospace; color: var(--accent); }
.pay-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.pay-btn.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.pay-btn:disabled { opacity: 0.4; }
.pay-note { color: var(--warn); font-weight: 700; }
.modal-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }

@media (max-width: 820px) {
  .pos-layout { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .ticket { border-left: none; border-top: 2px solid var(--ink); max-height: 44vh; }
  .kitchen-layout { grid-template-columns: 1fr; height: auto; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
