:root {
  --bg: #EEF0F2;
  --surface: #FFFFFF;
  --surface-sunk: #F5F6F8;
  --border: #DBDFE4;
  --ink: #1C2333;
  --ink-soft: #5B6472;
  --ink-faint: #8B93A1;
  --brand: #2B3A67;
  --accent: #C98A12;
  --accent-soft: #F4E3BE;
  --good: #2E7D5B;
  --good-soft: #DEEFE6;
  --bad: #B23A34;
  --bad-soft: #F6DEDC;
  --mono: 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); }
a { color: inherit; text-decoration: none; }
input, button { font-family: inherit; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--border); background: var(--surface);
  flex-wrap: wrap; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 8px; background: var(--brand);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.brand-title { font-weight: 700; font-size: 15.5px; }
.brand-sub { font-size: 11.5px; color: var(--ink-faint); font-family: var(--mono); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-badge {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface-sunk); border: 1px solid var(--border);
}
.user-name { font-size: 13px; font-weight: 700; }
.user-role {
  font-size: 10.5px; font-weight: 700; color: var(--ink-faint); font-family: var(--mono);
  text-transform: uppercase;
}

.page { padding: 20px 24px 80px; max-width: 1180px; margin: 0 auto; }

.flash { padding: 10px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; margin-bottom: 16px; }
.flash-ok { background: var(--good-soft); color: var(--good); }
.flash-error { background: var(--bad-soft); color: var(--bad); }
.flash-warn { background: var(--accent-soft); color: #8A6108; }

.view-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 16px; flex-wrap: wrap; gap: 10px;
}
.view-header h1 { font-size: 21px; margin: 0; font-weight: 700; }
.view-header p { margin: 4px 0 0; font-size: 13px; color: var(--ink-soft); }
.view-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-soft);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-outline { background: var(--surface); border: 1px solid var(--border); color: var(--ink-soft); }
.btn-dashed { background: transparent; border: 1px dashed var(--ink-faint); color: var(--ink-soft); }
.btn-sm { padding: 5px 10px; font-size: 11.5px; border-radius: 7px; }
.btn:disabled { background: var(--surface-sunk); color: var(--ink-faint); border-color: var(--border); cursor: not-allowed; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-soft);
  font-size: 13.5px; font-weight: 600;
}
.pill.active { background: var(--brand); border-color: var(--brand); color: #fff; }

h2.section-title { font-size: 15px; font-weight: 700; margin: 0 0 10px; }

.product-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; margin-bottom: 32px;
}
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
}
.product-card-head { display: flex; justify-content: space-between; align-items: flex-start; }
.product-code { font-size: 11px; font-family: var(--mono); color: var(--accent); font-weight: 700; }
.product-name { font-weight: 700; font-size: 14.5px; margin-top: 2px; }
.product-cat { font-size: 12px; color: var(--ink-faint); margin-top: 1px; }
.product-price { font-weight: 700; font-size: 14px; color: var(--brand); white-space: nowrap; }

.stock-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.stock-label { width: 54px; font-size: 12px; color: var(--ink-soft); }
.stock-track { flex: 1; height: 6px; border-radius: 4px; background: var(--surface-sunk); border: 1px solid var(--border); overflow: hidden; }
.stock-fill { height: 100%; background: var(--brand); }
.stock-fill.accent { background: var(--accent); }
.stock-fill.empty { background: var(--ink-faint); }
.stock-value { width: 34px; text-align: right; font-family: var(--mono); font-size: 12.5px; font-weight: 600; }

.qty-form { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.qty-input {
  width: 52px; text-align: center; font-family: var(--mono); font-size: 13px;
  border: 1px solid var(--border); border-radius: 7px; padding: 5px 4px;
}
.reserve-actions { display: flex; gap: 6px; }
.reserve-btn {
  flex: 1; padding: 8px 6px; border-radius: 7px; border: 1px solid var(--accent);
  background: #fff; color: var(--accent); font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.reserve-btn.primary { border-color: var(--brand); background: var(--brand); color: #fff; }
.reserve-btn:disabled { border-color: var(--border); background: var(--surface-sunk); color: var(--ink-faint); cursor: not-allowed; }

.stock-manage-row {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px;
  display: grid; grid-template-columns: 1.4fr 1.6fr 1.6fr; gap: 16px; align-items: center; margin-bottom: 10px;
}
.stock-manage-actions { display: flex; flex-direction: column; gap: 6px; }
.split-form { display: flex; gap: 6px; }
.amount-input {
  width: 54px; border: 1px solid var(--border); border-radius: 7px; padding: 6px 8px;
  font-family: var(--mono); font-size: 12.5px;
}

.reservation-row {
  display: flex; align-items: center; justify-content: space-between; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; flex-wrap: wrap; gap: 8px; margin-bottom: 8px;
}
.reservation-left { display: flex; align-items: center; gap: 10px; }
.reservation-id { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); width: 66px; }
.reservation-title { font-size: 13.5px; font-weight: 600; }
.reservation-meta { font-size: 11.5px; color: var(--ink-faint); font-family: var(--mono); }
.reservation-right { display: flex; align-items: center; gap: 10px; }
.countdown { display: flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }
.countdown.low { color: var(--bad); }

.badge { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge-warn { background: var(--accent-soft); color: #8A6108; }
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-muted { background: var(--surface-sunk); color: var(--ink-faint); }

.icon-btn {
  width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--border);
  background: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn.good { color: var(--good); }
.icon-btn.bad { color: var(--bad); }

.history-filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.history-search { margin-left: auto; min-width: 200px; }
.history-search input {
  width: 100%; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); font-size: 12.5px;
}
.empty-note { font-size: 13px; color: var(--ink-faint); padding: 16px 0; }

/* Login page */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 380px; }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; justify-content: center; }
.login-brand .brand-logo { width: 38px; height: 38px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px; }
.login-card label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); display: block; margin-bottom: 5px; }
.login-card input {
  width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border);
  font-size: 13.5px; margin-bottom: 14px;
}
.login-submit {
  width: 100%; padding: 11px 0; border-radius: 9px; border: none; background: var(--brand);
  color: #fff; font-weight: 700; font-size: 14px; cursor: pointer;
}
.login-error {
  background: var(--bad-soft); color: var(--bad); font-size: 12.5px; font-weight: 600;
  padding: 8px 10px; border-radius: 8px; margin-bottom: 14px;
}
.demo-accounts { margin-top: 18px; }
.demo-accounts-title { font-size: 11.5px; color: var(--ink-faint); margin-bottom: 8px; text-align: center; }
.demo-account-form { margin-bottom: 6px; }
.demo-account-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; text-align: left;
}
.demo-account-role { width: 26px; height: 26px; border-radius: 7px; background: var(--surface-sunk);
  display: flex; align-items: center; justify-content: center; color: var(--brand); font-weight: 700; font-size: 11px; flex-shrink: 0; }
.demo-account-name { font-size: 13px; font-weight: 700; }
.demo-account-sub { font-size: 11px; color: var(--ink-faint); font-family: var(--mono); }

/* Receipt */
.receipt-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.receipt-card { background: #fff; border-radius: 14px; width: 100%; max-width: 380px; padding: 26px; box-shadow: 0 20px 60px rgba(28,35,51,0.15); }
.receipt-head { text-align: center; margin-bottom: 16px; }
.receipt-head .brand-logo { margin: 0 auto 8px; }
.receipt-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-soft);
  border-top: 1px dashed var(--border); border-bottom: 1px dashed var(--border); padding: 10px 0; margin-bottom: 14px; }
.receipt-table { width: 100%; font-size: 12.5px; border-collapse: collapse; margin-bottom: 14px; }
.receipt-table th { text-align: left; padding: 0 0 8px; color: var(--ink-faint); font-weight: 600; border-bottom: 1px solid var(--border); }
.receipt-table td { padding: 8px 0; }
.receipt-total { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border); padding-top: 12px; margin-bottom: 20px; }
.receipt-total .amount { font-weight: 700; font-size: 18px; color: var(--brand); }
.receipt-footer-note { text-align: center; font-size: 11px; color: var(--ink-faint); margin-bottom: 18px; }
.receipt-actions { display: flex; gap: 8px; }
.receipt-actions .btn { flex: 1; justify-content: center; padding: 10px 0; }

@media print {
  body * { visibility: hidden; }
  .receipt-printable, .receipt-printable * { visibility: visible; }
  .receipt-printable { position: absolute; top: 0; left: 0; width: 100%; }
  .no-print { display: none !important; }
}
