:root {
  --brand-red: #820000;
  --brand-red-dark: #5c0000;
  --brand-red-light: #fbeaea;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #f4f6f8;
  color: #1c2530;
}

.app { display: flex; height: 100vh; overflow: hidden; }

/* ---- Login screen ---- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #1c2530, var(--brand-red-dark));
}
.login-card {
  background: #fff; border-radius: 14px; padding: 36px 40px; width: 460px; max-width: 92vw;
  box-shadow: 0 20px 50px rgba(0,0,0,.35); text-align: center;
}
.login-logo { max-width: 220px; margin: 0 auto 10px; display: block; }
.login-card h1 { font-size: 18px; margin: 0 0 20px; color: #667; font-weight: 600; }
.login-users-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.login-user-btn {
  padding: 14px 10px; border: 2px solid #e6eaf0; border-radius: 10px; background: #f8fafc;
  cursor: pointer; font-weight: 700; font-size: 13px; color: #1c2530; text-align: left;
}
.login-user-btn:hover { border-color: var(--brand-red); background: var(--brand-red-light); }
.login-user-btn .role-label { display: block; font-weight: 500; font-size: 11px; color: #667; margin-top: 3px; text-transform: uppercase; }
.login-divider { font-size: 12px; color: #99a; margin: 14px 0 10px; }
.login-barcode-input {
  width: 100%; padding: 12px 14px; font-size: 15px; border: 1px solid #d5dae1; border-radius: 8px;
  text-align: center; margin-bottom: 16px;
}
.login-email-row { display: flex; gap: 8px; margin-bottom: 16px; }
.login-email-row .login-barcode-input { margin-bottom: 0; }
.login-email-row input[type="email"] { flex: 1.4; }
.login-email-row input[type="password"] { flex: 0.8; text-align: center; }
.login-email-row .btn { flex: 0 0 auto; padding: 12px 18px; }
.login-backdoor-btn { width: 100%; }
.login-error {
  margin-top: 14px; background: #fdecec; color: #c1272d; padding: 10px 14px; border-radius: 6px; font-size: 13px;
}

.sidebar-spacer { flex: 1; }
.session-info { padding: 10px 20px; font-size: 12px; color: #b7c0cc; line-height: 1.5; }
.session-info strong { color: #fff; display: block; font-size: 13px; }
.logout-btn { border-top: 1px solid #33465b; color: #ffb4b4; }
.logout-btn:hover { background: var(--brand-red-dark); color: #fff; }

.sidebar {
  width: 170px;
  background: #1c2530;
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 14px 0;
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { padding: 0 16px 18px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.brand img { width: 100%; max-width: 120px; height: auto; }
.brand .brand-subtitle { font-weight: 700; font-size: 11px; letter-spacing: .5px; color: #b7c0cc; text-transform: uppercase; }
.nav-btn {
  background: none; border: none; color: #b7c0cc; text-align: left;
  padding: 14px 16px; font-size: 14px; cursor: pointer; min-height: 46px;
  position: relative;
}
.nav-btn:hover { background: #2a3542; color: #fff; }
.nav-btn.active { background: #33465b; color: #fff; border-left: 3px solid #e2434a; }
.nav-badge {
  position: absolute; top: 8px; right: 12px; background: #e2434a; color: #fff;
  border-radius: 10px; font-size: 11px; font-weight: 700; line-height: 1;
  padding: 3px 6px; min-width: 10px; text-align: center;
}

.content { flex: 1; padding: 22px 28px; overflow-y: auto; height: 100vh; }
h1 { margin-top: 0; font-size: 20px; }
h2 { font-size: 16px; margin: 0 0 12px; }

.tab { display: none; height: 100%; }
.tab.active { display: flex; flex-direction: column; min-height: 0; }
.tab.active > .list-container { flex: 1; min-height: 0; }

/* Desktop/widescreen (office laptops - Operation/Purchasing/Stock Manager) get a
   little more breathing room than the 1080x1080 touch POS (Production Team
   Leader) the compact sizing above targets. */
@media (min-width: 1400px) {
  .sidebar { width: 210px; }
  .content { padding: 32px 44px; }
  h1 { font-size: 24px; }
}

.card {
  background: #fff; border-radius: 8px; padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 20px;
}

/* ---- Team Chat: one shared channel, message bubbles, own vs others' ---- */
.chat-messages {
  flex: 1; min-height: 0; overflow-y: auto; background: #fff; border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.chat-msg { max-width: 70%; }
.chat-msg .chat-meta { font-size: 11px; color: #667; margin-bottom: 2px; }
.chat-msg .chat-bubble { background: #f0f3f7; border-radius: 12px; padding: 8px 12px; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.chat-msg.own { align-self: flex-end; text-align: right; }
.chat-msg.own .chat-bubble { background: #185fa5; color: #fff; }
.chat-compose { display: flex; gap: 10px; margin-top: 12px; flex: 0 0 auto; }
.chat-compose input { flex: 1; }

.scan-card label { font-size: 13px; color: #667; display: block; margin-bottom: 6px; }
.scan-row { display: flex; gap: 10px; }
#barcode-input, #manual-input {
  flex: 1; padding: 12px 14px; font-size: 18px; border: 1px solid #d5dae1;
  border-radius: 6px;
}
.hidden { display: none !important; }
#camera-reader { width: 100%; max-width: 420px; margin: 0 auto 12px; }

.mode-card { padding: 14px 20px; border: 2px solid transparent; }
.mode-card.receive { background: #eafaf0; border-color: #0a8a3b; }
.mode-card.produce { background: #fff8e6; border-color: #b8860b; }
.mode-card.pull_out { background: #e6f1fb; border-color: #185fa5; }
.mode-card.transfer { background: #fbeaea; border-color: var(--brand-red); }
.mode-card.branch_local { background: #f1eafc; border-color: #6b3fa0; }
.mode-row { display: flex; gap: 10px; flex-wrap: wrap; }
.mode-btn {
  flex: 1; min-width: 140px; padding: 12px; border: 2px solid #d5dae1; border-radius: 8px;
  background: #fff; font-weight: 700; font-size: 14px; cursor: pointer; opacity: .55;
}
.mode-btn.selected { opacity: 1; }
.mode-btn.receive.selected { border-color: #0a8a3b; color: #0a8a3b; background: #eafaf0; }
.mode-btn.produce.selected { border-color: #b8860b; color: #b8860b; background: #fff8e6; }
.mode-btn.pull_out.selected { border-color: #185fa5; color: #185fa5; background: #e6f1fb; }
.mode-btn.transfer.selected { border-color: var(--brand-red); color: var(--brand-red); background: #fbeaea; }
.mode-btn.branch_local.selected { border-color: #6b3fa0; color: #6b3fa0; background: #f1eafc; }

.request-item-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; padding: 8px; border: 1px solid #e5e9ef; border-radius: 8px; background: #fafbfc; }
.request-item-row .request-item-select-wrap { flex: 2; display: flex; flex-direction: column; gap: 4px; }
.request-item-row .request-item-select-wrap select { width: 100%; }
.request-item-row .request-item-category-select { font-size: 12px; color: #667; }
.request-item-row .request-item-qty-wrap { flex: 1; }
.request-item-row .request-item-qty-wrap input { width: 100%; }

.method-row { display: flex; gap: 10px; margin-bottom: 16px; }
.method-btn {
  padding: 9px 16px; border: 1px solid #d5dae1; border-radius: 20px;
  background: #f0f3f7; color: #556; font-weight: 600; font-size: 13px; cursor: pointer;
}
.method-btn.selected { background: var(--brand-red); color: #fff; border-color: var(--brand-red); }
.method-panel.hidden { display: none !important; }

.btn {
  padding: 11px 18px; border: none; border-radius: 6px; font-size: 14px;
  cursor: pointer; font-weight: 600; min-height: 42px;
}
.btn.primary { background: var(--brand-red); color: #fff; }
.btn.primary:hover { background: var(--brand-red-dark); }
.btn.primary.primary-out { background: #c1272d; }
.btn.primary.primary-out:hover { background: #a01f24; }
.btn.primary.primary-receive { background: #0a8a3b; }
.btn.primary.primary-receive:hover { background: #087530; }
.btn.primary.primary-pull-out { background: #185fa5; }
.btn.primary.primary-pull-out:hover { background: #124c85; }
.btn.primary.primary-produce { background: #b8860b; }
.btn.primary.primary-produce:hover { background: #9c7009; }
.btn.primary.primary-transfer { background: var(--brand-red); }
.btn.primary.primary-transfer:hover { background: var(--brand-red-dark); }
.btn.primary.primary-branch_local { background: #6b3fa0; }
.btn.primary.primary-branch_local:hover { background: #55317f; }
.btn.secondary { background: #e6eaf0; color: #1c2530; }
.btn.secondary:hover { background: #d8dee7; }
.btn.danger { background: #e6eaf0; color: #c1272d; }
.btn.danger:hover { background: #fbdadc; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; flex-shrink: 0; }
.toolbar input, .toolbar select { padding: 11px 12px; border: 1px solid #d5dae1; border-radius: 6px; font-size: 14px; min-height: 42px; }
#items-search, #history-search { flex: 1; min-width: 200px; }

.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
.data-table th, .data-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #eef1f4; font-size: 14px; }
.data-table th { background: #f0f3f7; font-size: 12px; text-transform: uppercase; color: #667; }
.data-table tr:hover td { background: #f8fafc; }
.data-table .row-actions { display: flex; gap: 8px; }
/* A data-table that can run long (e.g. Low Stock across a big catalog) -
   scrolls within its own box instead of pushing the rest of the page down,
   with the header pinned so column names stay visible while scrolling. */
.table-scroll { overflow-y: auto; border-radius: 8px; }
.table-scroll .data-table thead th { position: sticky; top: 0; z-index: 1; }
.low { color: #c1272d; font-weight: 700; }
.tag-in { color: #0a8a3b; font-weight: 700; }
.tag-out { color: #c1272d; font-weight: 700; }

/* ---- Compact list + tap-a-row-for-details (Items/History/Requests/Users) ----
   Narrow/touch (the 1080x1080 POS, used by Production Team Leader): each row is
   a stacked card, tap anywhere to open the detail modal. Wide desktop (office
   laptops on 1920x1080 - Operation/Purchasing/Stock Manager) reveal an inline
   meta line so more is visible without opening the modal. */
.list-container {
  background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08);
  overflow-y: auto; overflow-x: hidden;
}
.list-row {
  display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap;
  padding: 14px 16px; border-bottom: 1px solid #eef1f4; cursor: pointer; min-height: 56px;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: #f8fafc; }
.list-row:empty, .list-empty { padding: 24px 16px; color: #667; font-size: 14px; cursor: default; }
.list-empty:hover { background: none; }
.list-main { flex: 1 1 200px; min-width: 0; }
.list-main strong { display: block; font-size: 14px; }
.list-sub { font-size: 12px; color: #667; margin-top: 2px; }
.list-meta { display: none; font-size: 13px; color: #556; }
.list-side { flex: 0 0 auto; text-align: right; font-size: 13px; color: #556; }
.list-side strong { display: block; font-size: 15px; }
.list-status { padding: 3px 9px; border-radius: 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; background: #f0f3f7; color: #556; }
.list-status.tag-in { background: #eafaf0; color: #0a8a3b; }
.list-status.tag-out { background: #fbeaea; color: #c1272d; }
.list-chevron { flex: 0 0 auto; color: #b7c0cc; font-size: 18px; }

/* Production's Items list: items grouped under a collapsible category
   header instead of one flat list behind a top filter dropdown. */
.item-category-group { border-bottom: 1px solid #eef1f4; }
.item-category-group:last-child { border-bottom: none; }
.item-category-group summary {
  padding: 12px 16px; cursor: pointer; font-weight: 700; font-size: 14px;
  background: #f8fafc; list-style: none; display: flex; align-items: center; gap: 6px;
}
.item-category-group summary::-webkit-details-marker { display: none; }
.item-category-group summary::before { content: '\25B8'; color: #b7c0cc; display: inline-block; transition: transform .15s; }
.item-category-group[open] summary::before { transform: rotate(90deg); }
.item-category-group .cat-count { color: #667; font-weight: 400; font-size: 12px; }

@media (min-width: 1400px) {
  .list-meta { display: block; flex: 0 1 160px; }
  .list-row { min-height: 50px; }
}

.stat-row { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.stat-card { background: #fff; border-radius: 8px; padding: 20px; flex: 1; min-width: 160px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.stat-card.warn .stat-value { color: #c1272d; }
.stat-value { font-size: 30px; font-weight: 700; }
.stat-label { font-size: 13px; color: #667; margin-top: 4px; }

.dash-columns { display: flex; gap: 20px; flex-wrap: wrap; }
.dash-columns .card { flex: 1; min-width: 320px; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal-box {
  background: #fff; border-radius: 8px; padding: 24px; width: 380px;
  max-height: 92vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.modal-box h2 { margin-bottom: 12px; }
.modal-box input, .modal-box select { padding: 11px 12px; border: 1px solid #d5dae1; border-radius: 6px; font-size: 14px; margin-bottom: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1c2530; color: #fff; padding: 12px 20px; border-radius: 6px;
  font-size: 14px; z-index: 100; box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.toast.error { background: #c1272d; }
.toast.success { background: #0a8a3b; }

.card label { font-size: 13px; color: #667; display: block; margin-bottom: 6px; margin-top: 12px; }
.card label:first-of-type { margin-top: 0; }
.card input[type="text"], .card select {
  width: 100%; padding: 9px 12px; border: 1px solid #d5dae1; border-radius: 6px; font-size: 14px;
}

.item-info { font-size: 15px; margin-bottom: 14px; }
.item-info .stock { font-weight: 700; }
.field-row { display: flex; gap: 10px; margin-bottom: 12px; }
.field-row > div { flex: 1; }
.field-row label { font-size: 13px; color: #667; display: block; margin-bottom: 6px; }
.field-row input { width: 100%; padding: 10px 12px; border: 1px solid #d5dae1; border-radius: 6px; font-size: 14px; }
.field-hint { font-size: 12px; color: #667; margin-top: 4px; }

/* Per-item status on a branch order */
.line-inactive { text-decoration: line-through; color: #889; }
.line-note { font-size: 11px; color: #667; }
.line-actions { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.line-actions .btn { min-height: 28px; padding: 3px 9px; font-size: 12px; }
.wh-stock.short { color: #c1272d; font-weight: 600; }

/* ---- Round 1: organized orders, board, counts ---- */
.stage-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.stage-tab {
  border: 1px solid #d5dae1; background: #fff; border-radius: 18px; padding: 7px 13px; font-size: 13px;
  font-weight: 600; cursor: pointer; color: #334; display: flex; gap: 6px; align-items: center; min-height: 36px;
}
.stage-tab .n { background: #eef1f4; border-radius: 10px; padding: 1px 7px; font-size: 11px; }
.stage-tab.active { background: var(--brand-red); border-color: var(--brand-red); color: #fff; }
.stage-tab.active .n { background: rgba(255,255,255,.25); color: #fff; }
.stage-tab.alert:not(.active) .n { background: #e2434a; color: #fff; }
.orders-filters input { flex: 1; min-width: 200px; }
#requests-list { min-height: 260px; }
.list-day {
  position: sticky; top: 0; z-index: 1; background: #f4f6f8; padding: 6px 16px; font-size: 11px; font-weight: 700;
  color: #667; text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid #eef1f4;
}
.orders-more { display: flex; align-items: center; gap: 12px; margin: 12px 0 4px; }
.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover { box-shadow: 0 2px 10px rgba(0,0,0,.18); }
.stat-card.alert .stat-value { color: #c1272d; }
.stat-card .stat-sub { font-size: 11px; color: #889; margin-top: 2px; }
.shortage-card { margin-bottom: 16px; }
.shortage-card summary { cursor: pointer; font-weight: 700; font-size: 14px; }
#orders-shortages-body { max-height: 260px; overflow-y: auto; margin-top: 8px; }
.shortage-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid #eef1f4; font-size: 13px; }
.shortage-row .need { text-align: right; white-space: nowrap; color: #556; }
.shortage-row.short .need { color: #c1272d; font-weight: 700; }

.timeline { list-style: none; margin: 10px 0 4px; padding: 0 0 0 14px; border-left: 2px solid #e1e6ec; }
.timeline li { position: relative; padding: 2px 0 7px 12px; font-size: 12px; color: #556; }
.timeline li::before { content: ''; position: absolute; left: -20px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: #0a8a3b; }
.timeline li b { color: #1c2530; }
.receive-box { border: 1px solid #d5dae1; border-radius: 8px; padding: 10px 12px; margin: 10px 0; background: #f8fafc; }
.receive-box > strong { display: block; margin-bottom: 6px; }
.receive-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 13px; }
.receive-row input { width: 90px; margin: 0; padding: 7px 9px; border: 1px solid #d5dae1; border-radius: 6px; }
.receive-box input.recv-note { width: 100%; margin: 8px 0; padding: 9px 10px; border: 1px solid #d5dae1; border-radius: 6px; }

.stack-form { display: flex; flex-direction: column; gap: 4px; max-width: 420px; }
.stack-form label { font-size: 13px; font-weight: 600; color: #334; }
.stack-form input, .stack-form select { padding: 10px 12px; border: 1px solid #d5dae1; border-radius: 6px; font-size: 14px; margin-bottom: 10px; }

.count-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.count-tools input { flex: 1; min-width: 180px; }
.count-sheet { max-height: 46vh; overflow-y: auto; border: 1px solid #e1e6ec; border-radius: 8px; margin-bottom: 8px; }
.count-row { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-bottom: 1px solid #eef1f4; }
.count-row .name { flex: 1; font-size: 13px; min-width: 0; }
.count-row .unit { color: #667; font-size: 12px; width: 56px; }
.count-row input { width: 100px; margin: 0; padding: 7px 9px; text-align: right; }
.count-row.flash { background: #fff3c4; }
.variance-neg { color: #c1272d; font-weight: 700; }
.variance-pos { color: #0a8a3b; font-weight: 700; }

/* ---- Round 2: branch messages + branch stock ---- */
.messages-layout { display: flex; gap: 14px; flex: 1; min-height: 0; }
.msg-threads { width: 250px; flex: 0 0 250px; }
.msg-thread.selected { background: #fbeaea; }
.msg-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.msg-thread-title { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.msg-tag { margin: 8px 0 0; padding: 8px 10px; border: 1px solid #d5dae1; border-radius: 6px; font-size: 13px; background: #fff; }
.msg-order { font-size: 11px; font-weight: 700; color: inherit; text-decoration: underline; }
.chat-msg.own .msg-order { color: #fff; }
@media (max-width: 820px) {
  .messages-layout { flex-direction: column; }
  .msg-threads { width: auto; flex: 0 0 auto; max-height: 170px; }
}

.bd-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 16px; }
.bd-card { background: #fff; border: 2px solid transparent; border-radius: 8px; padding: 12px 14px; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.bd-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.18); }
.bd-card.selected { border-color: var(--brand-red); background: var(--brand-red-light); }
.bd-card-line { font-size: 13px; margin: 3px 0; }
.bd-note { background: #fff7e0; border: 1px solid #f0d98a; border-radius: 8px; padding: 9px 12px; margin-bottom: 8px; font-size: 13px; }
.bd-note a { font-weight: 700; }
.bd-par { display: block; font-size: 11px; color: #667; margin-top: 2px; }
.stat-card.warn .stat-value { color: #b8860b; }
.bd-order { min-height: 38px; padding: 6px 14px; }

/* Tablet / touch: four summary cards in a row, finger-sized controls */
#bd-stats .stat-card { min-width: 120px; padding: 16px; }
@media (pointer: coarse) {
  .bd-order, .stage-tab, .line-actions .btn, .chat-compose .btn { min-height: 44px; }
  .list-row { min-height: 60px; }
}

/* ===== Branch POS ===== */
.pos-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: #fff; border-radius: 10px; padding: 10px 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.pos-bar-title strong { font-size: 18px; }
.pos-bar-title span { color: var(--brand-red); font-weight: 700; margin-left: 6px; }
.pos-bar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pos-who { font-size: 14px; color: #445; }
.pos-body { min-height: 0; }
.pos-empty { padding: 40px 20px; font-size: 16px; line-height: 1.6; }

.pos-signin { text-align: center; padding: 20px 0; }
.pos-signin h2 { margin-bottom: 18px; }
.pos-staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; max-width: 760px; margin: 0 auto; }
.pos-staff-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; background: #fff; border: 2px solid #e1e6ec; border-radius: 14px; padding: 18px 10px; font-size: 16px; font-weight: 700; cursor: pointer; min-height: 130px; color: #1c2530; font-family: inherit; }
.pos-staff-tile:active, .pos-staff-tile:hover { border-color: var(--brand-red); background: var(--brand-red-light); }
.pos-staff-tile small { color: #667; font-weight: 500; font-size: 12px; }
.pos-staff-avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--brand-red); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; }

.pos-cats { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; }
.pos-cat { flex: 0 0 auto; border: 2px solid #d5dae1; background: #fff; border-radius: 22px; padding: 10px 20px; font-size: 15px; font-weight: 600; cursor: pointer; min-height: 46px; color: #1c2530; font-family: inherit; }
.pos-cat.active { background: var(--brand-red); border-color: var(--brand-red); color: #fff; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.pos-tile { position: relative; display: flex; flex-direction: column; align-items: stretch; background: #fff; border: 2px solid #e1e6ec; border-radius: 14px; padding: 0; overflow: hidden; cursor: pointer; text-align: left; color: #1c2530; font-family: inherit; }
.pos-tile:active { transform: scale(.97); border-color: var(--brand-red); }
.pos-tile.sold-out { opacity: .5; cursor: not-allowed; }
.pos-tile-photo { display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; background: #f0f3f6; overflow: hidden; }
.pos-tile-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pos-tile-name { padding: 8px 10px 0; font-weight: 700; font-size: 14px; line-height: 1.25; min-height: 38px; }
.pos-tile-price { padding: 2px 10px 10px; color: var(--brand-red); font-weight: 800; font-size: 15px; }
.pos-tile-flag { position: absolute; top: 8px; left: 8px; background: #c1272d; color: #fff; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 10px; }
.menu-initials { color: #8a97a6; font-weight: 800; font-size: 28px; letter-spacing: 1px; }
.menu-initials.big { font-size: 44px; }

/* menu manager */
.menu-toolbar select { max-width: 240px; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.menu-cat-head { grid-column: 1 / -1; font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: #667; margin-top: 8px; }
.menu-card { display: flex; gap: 12px; align-items: center; background: #fff; border: 1px solid #e1e6ec; border-radius: 10px; padding: 8px; cursor: pointer; text-align: left; font-family: inherit; color: #1c2530; min-height: 76px; }
.menu-card:hover { border-color: var(--brand-red); }
.menu-card.inactive { opacity: .6; }
.menu-thumb { flex: 0 0 60px; width: 60px; height: 60px; border-radius: 8px; background: #f0f3f6; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.menu-thumb img { width: 100%; height: 100%; object-fit: cover; }
.menu-thumb .menu-initials { font-size: 18px; }
.menu-card-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.menu-card-name { font-weight: 700; font-size: 14px; }
.menu-card-price { font-size: 14px; color: var(--brand-red); font-weight: 700; }
.menu-card-price small { color: #889; font-weight: 500; }
.menu-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.menu-tag { font-size: 11px; background: #eef1f4; color: #445; border-radius: 10px; padding: 2px 8px; font-weight: 600; }
.menu-tag.warn { background: #fff3c4; color: #7a5b00; }
.menu-tag.off { background: #fbeaea; color: #c1272d; }

/* dialogs */
.pos-modal { width: 420px; max-width: 96vw; }
.pos-modal.wide { width: 720px; }
.pos-modal h3 { font-size: 15px; margin: 0 0 8px; }
.pos-modal h3 small { font-weight: 500; color: #667; }
.pos-label { font-size: 13px; color: #667; display: block; margin: 8px 0 4px; }
.pos-input { width: 100%; padding: 11px 12px; border: 1px solid #d5dae1; border-radius: 8px; font-size: 16px; margin-bottom: 6px; min-height: 44px; font-family: inherit; background: #fff; }
.pos-check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 8px 0; min-height: 40px; }
.pos-check input { width: 22px; height: 22px; margin: 0; }
.pos-confirm-text { font-size: 15px; line-height: 1.5; margin: 4px 0 12px; }
.pos-edit-grid { display: flex; gap: 18px; flex-wrap: wrap; }
.pos-photo-col { flex: 0 0 170px; display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.pos-photo-preview { width: 170px; height: 170px; border-radius: 12px; background: #f0f3f6; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pos-photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.pos-file-btn { text-align: center; cursor: pointer; }
.pos-fields-col { flex: 1; min-width: 220px; }
.pos-section { border-top: 1px solid #e6eaf0; margin-top: 14px; padding-top: 12px; }
.pos-override-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.pos-override-row > * { flex: 1; min-width: 140px; }
.pos-override-row .btn { flex: 0 0 auto; }
.recipe-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.recipe-row .ing-name { flex: 1; margin: 0; }
.recipe-row .ing-qty { width: 100px; margin: 0; text-align: right; }
.recipe-row .ing-unit { width: 56px; font-size: 12px; color: #667; }
.staff-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 4px; border-bottom: 1px solid #eef1f4; }
.staff-row.inactive { opacity: .6; }
.staff-main { font-size: 14px; }
.staff-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.staff-actions .btn { min-height: 38px; padding: 6px 12px; font-size: 13px; }

/* PIN pad */
.pos-modal.pinpad { width: 330px; }
.pos-modal.pinpad h2 { text-align: center; }
.pinpad-sub { text-align: center; color: #667; font-size: 14px; margin-bottom: 8px; }
.pinpad-dots { display: flex; justify-content: center; gap: 12px; margin: 6px 0 16px; }
.pinpad-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #b8c1cc; }
.pinpad-dots span.on { background: var(--brand-red); border-color: var(--brand-red); }
.pinpad-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pinpad-key { min-height: 62px; font-size: 24px; font-weight: 700; border-radius: 12px; border: 1px solid #d5dae1; background: #f8fafc; cursor: pointer; color: #1c2530; font-family: inherit; }
.pinpad-key:active { background: var(--brand-red-light); border-color: var(--brand-red); }
.pinpad-key.alt { font-size: 20px; }
.pinpad-key.ok { background: var(--brand-red); border-color: var(--brand-red); color: #fff; font-size: 20px; }

@media (max-width: 700px) {
  .pos-modal.wide { width: 96vw; }
  .pos-photo-col { flex: 1 1 100%; flex-direction: row; align-items: center; }
  .pos-photo-preview { width: 110px; height: 110px; }
}

.pos-input:disabled { background: #eef1f4; color: #667; cursor: not-allowed; }

/* ===== POS selling screen ===== */
.pos-sell { display: flex; gap: 14px; height: calc(100vh - 118px); min-height: 420px; }
.pos-left { flex: 1; min-width: 0; overflow-y: auto; padding-right: 4px; }
.pos-left .pos-grid { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); }
.pos-tile-qty { position: absolute; top: 8px; right: 8px; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 14px; background: var(--brand-red); color: #fff; font-weight: 800; font-size: 14px; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(0,0,0,.3); }

.pos-cart { flex: 0 0 340px; display: flex; flex-direction: column; background: #fff; border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.12); overflow: hidden; }
.cart-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid #e6eaf0; }
.cart-head .btn { min-height: 34px; padding: 4px 12px; font-size: 13px; }
.cart-lines { flex: 1; overflow-y: auto; padding: 4px 10px; }
.cart-line { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid #f0f3f6; }
.cart-line-name { flex: 1; min-width: 0; font-weight: 700; font-size: 14px; line-height: 1.25; }
.cart-line-name small { display: block; font-weight: 500; color: #667; font-size: 12px; }
.cart-line-total { width: 72px; text-align: right; font-weight: 700; font-size: 14px; }
.cart-stepper { display: flex; align-items: center; gap: 4px; }
.cart-stepper button { width: 38px; height: 38px; border-radius: 10px; border: 1px solid #d5dae1; background: #f8fafc; font-size: 22px; line-height: 1; cursor: pointer; color: #1c2530; font-family: inherit; }
.cart-stepper button:active { background: var(--brand-red-light); border-color: var(--brand-red); }
.cart-stepper span { min-width: 24px; text-align: center; font-weight: 800; font-size: 16px; }
.cart-totals { padding: 8px 14px; border-top: 1px solid #e6eaf0; }
.cart-row { display: flex; justify-content: space-between; font-size: 14px; padding: 2px 0; color: #445; }
.cart-row.disc { color: #0a8a3b; font-weight: 600; }
.cart-total { display: flex; justify-content: space-between; font-size: 24px; font-weight: 800; padding-top: 4px; }
.cart-buttons { display: flex; flex-direction: column; gap: 8px; padding: 10px 14px 14px; }
.cart-buttons .btn { min-height: 52px; font-size: 16px; border-radius: 10px; }
.cart-pay { font-size: 20px !important; }
.cart-pay:disabled { opacity: .45; cursor: not-allowed; }
.cart-discount.on { background: #eafaf0; color: #0a8a3b; border: 2px solid #0a8a3b; }

@media (max-width: 860px) {
  .pos-sell { flex-direction: column; height: auto; }
  .pos-left { overflow: visible; }
  .pos-cart { flex: none; position: sticky; bottom: 0; max-height: 55vh; }
}

/* discount dialog */
.disc-types { display: flex; gap: 8px; margin-bottom: 12px; }
.disc-type { flex: 1; min-height: 56px; border: 2px solid #d5dae1; background: #fff; border-radius: 12px; font-size: 16px; font-weight: 700; cursor: pointer; color: #1c2530; font-family: inherit; }
.disc-type.active { border-color: var(--brand-red); background: var(--brand-red-light); color: var(--brand-red); }
#disc-lines { max-height: 200px; overflow-y: auto; border: 1px solid #e1e6ec; border-radius: 8px; padding: 2px 10px; }

/* payment dialog */
.pos-modal.pay-modal { width: 420px; }
.pay-total { text-align: center; font-size: 38px; font-weight: 800; color: var(--brand-red); margin: 0 0 8px; }
.pay-methods { display: flex; gap: 8px; margin-bottom: 12px; }
.pay-method { flex: 1; min-height: 54px; border: 2px solid #d5dae1; background: #fff; border-radius: 12px; font-size: 18px; font-weight: 800; cursor: pointer; color: #1c2530; font-family: inherit; }
.pay-method.active { border-color: var(--brand-red); background: var(--brand-red); color: #fff; }
.pay-received { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; color: #667; padding: 0 4px; }
.pay-received strong { font-size: 30px; color: #1c2530; }
.pay-change { text-align: center; font-size: 22px; font-weight: 800; min-height: 30px; margin: 4px 0; }
.pay-change.ok { color: #0a8a3b; }
.pay-change.short { color: #c1272d; }
.pay-quick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 8px; }
.pay-quick .btn { min-height: 44px; padding: 4px; font-size: 14px; }
.pay-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-keys .pinpad-key { min-height: 54px; font-size: 22px; }
.pay-go { min-height: 54px; font-size: 17px; }
.pay-go:disabled { opacity: .45; cursor: not-allowed; }

/* receipt dialog */
.pos-modal.receipt-modal { width: 400px; }
.receipt-summary { display: flex; justify-content: space-between; align-items: baseline; background: #eafaf0; color: #0a8a3b; border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; font-size: 16px; font-weight: 700; }
.receipt-summary strong { font-size: 30px; }
.receipt-frame { width: 100%; height: 340px; border: 1px solid #e1e6ec; border-radius: 8px; background: #fff; margin-bottom: 8px; }

/* today's sales */
.today-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.today-summary div { background: #f4f6f8; border-radius: 10px; padding: 8px 10px; }
.today-summary span { display: block; font-size: 12px; color: #667; }
.today-summary strong { font-size: 16px; }
.today-list { max-height: 50vh; overflow-y: auto; }
.today-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid #eef1f4; }
.today-row.voided { opacity: .65; }
.today-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; font-size: 13px; }
.today-main small { color: #667; }
.today-main .void-note { color: #c1272d; }
.today-amount { font-weight: 800; font-size: 16px; }
.today-amount.struck { text-decoration: line-through; }
.today-actions { display: flex; gap: 6px; }
.today-actions .btn { min-height: 40px; padding: 4px 12px; font-size: 13px; }
@media (max-width: 600px) { .today-summary { grid-template-columns: repeat(2, 1fr); } .today-row { flex-wrap: wrap; } }

/* ===== POS: drawer, amount pad, reports ===== */
.open-register { min-height: 64px; font-size: 20px; padding: 0 36px; border-radius: 14px; }
.drawer-actions { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 10px; }
.drawer-actions .btn { min-height: 64px; font-size: 17px; text-align: left; padding: 8px 16px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; border-radius: 12px; }
.drawer-actions .btn small { font-weight: 500; font-size: 12px; opacity: .8; }

.pos-modal.amountpad { width: 340px; }
.amountpad-display { text-align: center; font-size: 38px; font-weight: 800; color: var(--brand-red); margin: 4px 0 12px; }

.report-toolbar { align-items: center; }
.rp-date { font-size: 13px; color: #667; display: flex; align-items: center; gap: 6px; }
.rp-date input { padding: 8px 10px; border: 1px solid #d5dae1; border-radius: 6px; font-size: 14px; min-height: 42px; }
.rp-scope { margin: 4px 0 10px; font-size: 15px; color: #445; }
.rp-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.rp-card { background: #fff; border-radius: 10px; padding: 12px 14px; box-shadow: 0 1px 3px rgba(0,0,0,.08); display: flex; flex-direction: column; }
.rp-card span { font-size: 12px; color: #667; }
.rp-card strong { font-size: 22px; margin: 2px 0; }
.rp-card small { font-size: 12px; color: #889; min-height: 14px; }
.rp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rp-table th { text-align: left; font-size: 12px; color: #667; font-weight: 600; padding: 6px 8px; border-bottom: 2px solid #e6eaf0; white-space: nowrap; }
.rp-table td { padding: 7px 8px; border-bottom: 1px solid #eef1f4; vertical-align: top; }
.rp-table th.r, .rp-table td.r { text-align: right; white-space: nowrap; }
.rp-csv { margin-top: 8px; min-height: 38px; padding: 4px 14px; font-size: 13px; }
#tab-sales .card, #pos-manager-body .card { margin-bottom: 14px; }
@media (max-width: 700px) { .rp-cards { grid-template-columns: repeat(2, 1fr); } }

/* ===== Cashier tablet page (/pos) ===== */
body.pos-page { background: #f4f6f8; }
.pos-app { padding: 12px 16px; min-height: 100vh; }
.pos-page .pos-sell { height: calc(100vh - 100px); }
.pos-status { border: 0; border-radius: 16px; padding: 6px 14px; font-size: 13px; font-weight: 700; cursor: pointer; min-height: 34px; font-family: inherit; }
.pos-status.online { background: #eafaf0; color: #0a8a3b; }
.pos-status.offline { background: #fbeaea; color: #c1272d; }
.pos-status.pending { background: #fff3c4; color: #7a5b00; }
.late-layout { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.late-items { flex: 2 1 380px; max-height: 70vh; overflow-y: auto; }
.late-details { flex: 1 1 300px; }
.late-when { display: flex; gap: 8px; }
.late-when > div { flex: 1; }
.late-row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid #eef1f4; }
.late-row.on { background: #fbeaea; }
.late-name { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; }
.late-name small { display: block; font-weight: 400; color: #667; font-size: 12px; }
.late-price { width: 90px; margin: 0; }
.late-total { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; margin: 12px 0; }
.late-total strong { font-size: 26px; color: var(--brand-red); }

/* One sign-in card, two destinations */
.login-switch { display: flex; background: #eef1f4; border-radius: 12px; padding: 4px; gap: 4px; margin: 0 0 14px; }
.login-switch button { flex: 1; min-height: 46px; border: 0; border-radius: 9px; background: transparent; font-size: 15px; font-weight: 700; color: #556; cursor: pointer; font-family: inherit; }
.login-switch button.active { background: var(--brand-red); color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); }

/* The two front doors: staff (inventory.*) and branches (branchinventory.*) */
.portal-staff .branch-only, .portal-branch .staff-only { display: none !important; }
