@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&family=Be+Vietnam+Pro:wght@400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --cream: #FAF6EF;
  --brown: #4A2C17;
  --gold: #C8923A;
  --gold-light: #F0D9AE;
  --ink: #2A1A0E;
  --muted: #8C6A4A;
  --divider: #DDD0BC;
  --white: #FFFFFF;
  --danger: #CC4444;
  --green: #2E7D32;
}

body {
  font-family: 'Be Vietnam Pro', sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button { touch-action: manipulation; font-family: inherit; }
input, textarea { font-family: inherit; }

/* ── INSTALL BANNER ── */
#installBanner {
  display: none;
  background: var(--brown);
  color: var(--white);
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  font-size: 13px;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  text-align: center;
}
#installBanner.show { display: flex; }
#installBanner .ib-install {
  background: var(--gold);
  color: var(--white);
  border: none;
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
#installBanner .ib-dismiss {
  background: transparent;
  color: rgba(255,255,255,.7);
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}

/* ── OFFLINE BANNER ── */
#offlineBanner {
  display: none;
  background: #c0392b;
  color: #fff;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  gap: 8px;
  align-items: center;
  justify-content: center;
  letter-spacing: .3px;
  text-align: center;
}
#offlineBanner.show { display: flex; }
.offline-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #ff6b6b;
  flex-shrink: 0;
  animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* sync status indicator in header */
#syncStatus {
  position: absolute;
  left: 54px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: rgba(255,255,255,.6);
  white-space: nowrap;
  pointer-events: none;
  transition: color .3s;
}
#syncStatus.syncing { color: var(--gold-light); }
#syncStatus.synced  { color: #a8e6a3; }

/* ── HEADER ── */
.header {
  background: var(--brown);
  color: var(--white);
  text-align: center;
  padding: 18px 16px 14px;
  padding-top: calc(18px + env(safe-area-inset-top));
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(74,44,23,.35);
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: transform;
}
.header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  letter-spacing: .5px;
  color: var(--gold-light);
}
.header p {
  font-size: 11px;
  opacity: .65;
  margin-top: 2px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

/* ── TABLE BAR ── */
.table-bar {
  background: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 9px 16px;
}
.table-bar label {
  color: var(--white);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.table-bar input {
  width: 72px;
  border: 2px solid rgba(255,255,255,.6);
  background: rgba(255,255,255,.25);
  color: var(--white);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  border-radius: 8px;
  padding: 4px 8px;
  outline: none;
  -webkit-appearance: none;
}
.table-bar input::placeholder { color: rgba(255,255,255,.55); }
.table-bar input:focus { border-color: var(--white); background: rgba(255,255,255,.35); }

/* ── LAYOUT ── */
.main { display: flex; }

/* ── MENU PANEL ── */
.menu-panel { flex: 1; min-width: 0; padding: 14px 14px 120px; }

/* pills */
.cat-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.cat-scroll::-webkit-scrollbar { display: none; }
.cat-pill {
  flex-shrink: 0;
  background: var(--white);
  border: 1.5px solid var(--divider);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 13px;
  border-radius: 99px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  -webkit-appearance: none;
}
.cat-pill.active, .cat-pill:hover {
  background: var(--brown);
  border-color: var(--brown);
  color: var(--white);
}

/* menu sections */
.cat-section { margin-top: 12px; }
.cat-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--gold);
  padding: 5px 0 7px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 6px;
}
.item-list { display: flex; flex-direction: column; gap: 4px; }
.item-row {
  background: var(--white);
  border-radius: 10px;
  padding: 9px 12px;
  box-shadow: 0 1px 4px rgba(74,44,23,.06);
}
.item-row-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.item-name { flex: 1; font-size: 13.5px; font-weight: 500; line-height: 1.3; }
.item-price {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  min-width: 58px;
  text-align: right;
}
.qty-ctrl { display: flex; align-items: center; gap: 5px; }
.qty-btn {
  width: 36px; height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--brown);
  color: var(--white);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  -webkit-appearance: none;
  transition: background .12s;
}
.qty-btn:active { background: var(--gold); }
.qty-num {
  width: 22px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
}

/* discount row inside menu item */
.item-discount-row {
  display: none;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--divider);
}
.item-discount-row.visible { display: flex; }
.item-discount-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.discount-preset-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.disc-preset {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 99px;
  border: 1.5px solid var(--divider);
  background: var(--cream);
  color: var(--muted);
  cursor: pointer;
  -webkit-appearance: none;
  transition: all .12s;
}
.disc-preset.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.disc-input-wrap {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
.disc-input {
  width: 80px;
  border: 1.5px solid var(--divider);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  text-align: right;
  outline: none;
  color: var(--ink);
  background: var(--cream);
  -webkit-appearance: none;
}
.disc-input:focus { border-color: var(--gold); }
.disc-unit { font-size: 11px; color: var(--muted); }

/* ── ORDER PANEL DESKTOP ── */
@media (min-width: 720px) {
  .menu-panel { padding-bottom: 16px; }
  .order-panel {
    width: 320px;
    min-width: 280px;
    background: var(--white);
    border-left: 1px solid var(--divider);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }
  .drawer-handle { display: none; }
  .order-toggle-btn { display: none; }
  .order-peek { cursor: default; }
}

/* ── ORDER DRAWER MOBILE ── */
@media (max-width: 719px) {
  .order-panel {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--white);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -4px 28px rgba(74,44,23,.22);
    z-index: 200;
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateY(calc(100% - 64px));
    -webkit-transform: translateY(calc(100% - 64px)) translateZ(0);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    -webkit-transition: -webkit-transform .28s cubic-bezier(.4,0,.2,1);
    will-change: transform;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .order-panel.open {
    transform: translateY(0);
    -webkit-transform: translateY(0) translateZ(0);
  }
  .drawer-handle {
    width: 38px; height: 4px;
    background: var(--divider);
    border-radius: 99px;
    margin: 10px auto 0;
    flex-shrink: 0;
  }
}

/* peek bar */
.order-peek {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 10px;
  cursor: pointer;
  flex-shrink: 0;
}
.order-peek-left { display: flex; align-items: center; gap: 8px; }
.order-peek-left h3 { font-size: 15px; font-weight: 600; }
.badge {
  background: var(--brown);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  border-radius: 99px;
  padding: 2px 7px;
  min-width: 22px;
  text-align: center;
}
.total-small { font-size: 13px; color: var(--gold); font-weight: 600; }

/* order body */
.order-body { padding: 0 14px 12px; }

.order-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 22px 0 16px;
  opacity: .7;
}

.order-item-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--divider);
}
.order-item-left { flex: 1; min-width: 0; }
.order-item-name { font-size: 13px; font-weight: 500; line-height: 1.35; }
.order-item-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.order-item-disc { font-size: 11px; color: var(--green); margin-top: 1px; }
.order-item-price { font-size: 13px; font-weight: 600; white-space: nowrap; padding-top: 1px; }
.remove-btn {
  background: none; border: none;
  color: var(--danger); font-size: 15px;
  cursor: pointer; padding: 2px 4px;
  line-height: 1; flex-shrink: 0;
  border-radius: 4px;
}
.remove-btn:active { opacity: .6; }

/* totals block */
.order-totals-block {
  display: none;
  flex-direction: column;
  gap: 3px;
  padding: 10px 0 6px;
  border-top: 1.5px solid var(--ink);
}
.totals-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}
.totals-row.discount { color: var(--green); }
.totals-row.grand {
  font-weight: 700;
  font-size: 15px;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed var(--divider);
}

/* note */
.note-row { padding: 6px 0 10px; }
.note-row label {
  font-size: 12px; color: var(--muted);
  display: block; margin-bottom: 4px; font-weight: 500;
}
.note-row textarea {
  width: 100%;
  border: 1.5px solid var(--divider);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 16px;
  resize: none;
  outline: none;
  color: var(--ink);
  background: var(--cream);
  -webkit-appearance: none;
}
.note-row textarea:focus { border-color: var(--gold); }

/* action buttons */
.btn-print {
  width: 100%;
  background: var(--brown);
  color: var(--white);
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  letter-spacing: .3px;
  transition: background .15s;
  -webkit-appearance: none;
}
.btn-print:hover { background: var(--gold); }

.btn-pdf {
  width: 100%;
  background: var(--gold);
  color: var(--white);
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  letter-spacing: .2px;
  transition: background .15s;
  -webkit-appearance: none;
  line-height: 1.3;
}
.btn-pdf:hover { background: #b07a28; }
.btn-pdf:disabled { opacity: .55; cursor: wait; }
.btn-pdf small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  opacity: .85;
  margin-top: 1px;
}

.btn-clear {
  width: 100%;
  background: none;
  border: 1.5px solid var(--divider);
  color: var(--muted);
  border-radius: 10px;
  padding: 9px;
  font-size: 13px;
  cursor: pointer;
  margin-top: 6px;
  transition: border-color .15s, color .15s;
  -webkit-appearance: none;
}
.btn-clear:hover { border-color: var(--danger); color: var(--danger); }

.btn-copy {
  width: 100%;
  background: none;
  border: 1.5px solid var(--gold);
  color: var(--gold);
  border-radius: 10px;
  padding: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: all .15s;
  -webkit-appearance: none;
}
.btn-copy:hover { background: var(--gold); color: var(--white); }
.btn-copy.copied { background: var(--green); border-color: var(--green); color: var(--white); }

.btn-new {
  width: 100%;
  background: var(--green);
  color: var(--white);
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  letter-spacing: .3px;
  transition: background .15s;
  -webkit-appearance: none;
}
.btn-new:hover { background: #1b5e20; }

/* Dark mode toggle button in header */
.dark-toggle {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,.15);
  border: none;
  border-radius: 50%;
  width: 34px; height: 34px;
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--white);
  transition: background .15s;
}
.dark-toggle:hover { background: rgba(255,255,255,.28); }

/* ── DARK MODE ── */
body.dark {
  --cream: #1A1208;
  --brown: #2E1B0A;
  --gold: #C8923A;
  --gold-light: #F0D9AE;
  --ink: #EDE0CC;
  --muted: #A8896A;
  --divider: #3A2A18;
  --white: #231608;
  --danger: #FF6B6B;
  --green: #4CAF50;
}
body.dark .header { background: #1A0E05; }
body.dark .item-row { box-shadow: 0 1px 4px rgba(0,0,0,.3); }
body.dark .order-panel { background: #231608; }
body.dark .cat-pill { background: #2A1A0A; }
body.dark .disc-input { background: #2A1A0A; color: var(--ink); }
body.dark .disc-preset { background: #2A1A0A; color: var(--muted); }
body.dark .note-row textarea { background: #2A1A0A; color: var(--ink); }

/* ── CREATOR SELECT ── */
.creator-bar {
  background: var(--brown);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 7px 16px;
  border-top: 1px solid rgba(255,255,255,.12);
}
.creator-bar label {
  color: rgba(255,255,255,.85);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}
.creator-select {
  border: 2px solid rgba(255,255,255,.5);
  background: rgba(255,255,255,.18);
  color: var(--white);
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  padding: 4px 10px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  min-width: 120px;
  font-family: inherit;
}
.creator-select:focus { border-color: var(--white); background: rgba(255,255,255,.28); }
.creator-select option { background: var(--brown); color: var(--white); font-weight: 600; }

/* ── STAFF MANAGEMENT (inside dashboard) ── */
.staff-list-wrap { padding: 0; }
.staff-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--divider);
}
.staff-item-name { flex: 1; font-size: 14px; font-weight: 500; }
.staff-del-btn {
  background: none;
  border: 1.5px solid var(--danger);
  color: var(--danger);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all .12s;
}
.staff-del-btn:hover { background: var(--danger); color: #fff; }
.staff-add-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}
.staff-add-input {
  flex: 1;
  border: 1.5px solid var(--divider);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 14px;
  outline: none;
  color: var(--ink);
  background: var(--cream);
  font-family: inherit;
  -webkit-appearance: none;
}
.staff-add-input:focus { border-color: var(--gold); }
.staff-add-btn {
  background: var(--brown);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background .12s;
}
.staff-add-btn:hover { background: var(--gold); }

/* ── CREATOR STATS ── */
.creator-stat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--divider);
}
.creator-stat-name { flex: 1; font-size: 14px; font-weight: 600; }
.creator-stat-count {
  font-size: 13px;
  color: var(--gold);
  font-weight: 700;
  white-space: nowrap;
}
.creator-stat-revenue {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ── MENU EDITOR ── */
.me-header {
  background: var(--brown);
  color: var(--white);
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.me-header h2 { font-size: 16px; font-weight: 700; color: var(--gold-light); margin: 0; }
.me-add-cat-btn {
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.me-cat-block {
  margin: 0;
  border-bottom: 2px solid var(--divider);
}
.me-cat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 8px;
  background: var(--cream);
  cursor: pointer;
}
.me-cat-name {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold);
}
.me-cat-actions { display: flex; gap: 6px; }
.me-cat-btn {
  background: none;
  border: 1.5px solid var(--divider);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  color: var(--muted);
  transition: all .12s;
}
.me-cat-btn.rename:hover { border-color: var(--gold); color: var(--gold); }
.me-cat-btn.del:hover { border-color: var(--danger); color: var(--danger); }
.me-cat-btn.add-item {
  background: rgba(74,44,23,.1);
  border-color: var(--brown);
  color: var(--brown);
}
.me-cat-btn.add-item:hover { background: var(--brown); color: #fff; }
.me-item-list { display: flex; flex-direction: column; }
.me-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--divider);
  background: var(--white);
}
.me-item-name { flex: 1; font-size: 14px; font-weight: 500; line-height: 1.3; }
.me-item-price { font-size: 13px; color: var(--muted); white-space: nowrap; min-width: 70px; text-align: right; }
.me-item-cost { font-size: 11px; color: var(--green); }
.me-edit-btn {
  background: none;
  border: 1.5px solid var(--gold);
  color: var(--gold);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: all .12s;
}
.me-edit-btn:hover { background: var(--gold); color: #fff; }
.me-del-item-btn {
  background: none;
  border: 1.5px solid var(--divider);
  color: var(--muted);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: all .12s;
}
.me-del-item-btn:hover { border-color: var(--danger); color: var(--danger); }

/* Menu Editor Modal */
#meModal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 9999;
  align-items: flex-end;
  justify-content: center;
}
#meModal.open { display: flex; }
#meModalBox {
  background: var(--white);
  border-radius: 20px 20px 0 0;
  padding: 22px 18px 36px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 -4px 32px rgba(0,0,0,.3);
  animation: slideUp .2s ease;
}
body.dark #meModalBox { background: #231608; }
#meModalBox h3 { margin: 0 0 16px; font-size: 18px; color: var(--gold); }
.me-modal-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .5px;
  text-transform: uppercase;
  margin-bottom: 5px;
  display: block;
}
.me-modal-input {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid var(--divider);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 16px;
  font-family: inherit;
  background: var(--cream);
  color: var(--ink);
  outline: none;
  margin-bottom: 13px;
  -webkit-appearance: none;
}
.me-modal-input:focus { border-color: var(--gold); }
body.dark .me-modal-input { background: #2A1A0A; color: var(--ink); }
.me-modal-row { display: flex; gap: 10px; }
.me-modal-row > div { flex: 1; }
.me-modal-actions { display: flex; gap: 10px; margin-top: 4px; }
.me-modal-save {
  flex: 1;
  background: var(--brown);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.me-modal-cancel {
  background: none;
  border: 1.5px solid var(--divider);
  color: var(--muted);
  border-radius: 10px;
  padding: 13px 18px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.me-empty {
  text-align: center;
  padding: 30px 20px;
  color: var(--muted);
  font-size: 14px;
}
.me-cat-toggle { font-size: 14px; color: var(--muted); transition: transform .2s; }
.me-cat-block.collapsed .me-cat-toggle { transform: rotate(-90deg); }
.me-cat-block.collapsed .me-item-list { display: none; }
.me-search-bar {
  display: flex;
  gap: 8px;
  padding: 10px 14px 8px;
  background: var(--cream);
  border-bottom: 1px solid var(--divider);
  position: sticky;
  top: 54px;
  z-index: 40;
}
.me-search-input {
  flex: 1;
  border: 1.5px solid var(--divider);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 14px;
  font-family: inherit;
  background: var(--white);
  color: var(--ink);
  outline: none;
}
.me-search-input:focus { border-color: var(--gold); }
body.dark .me-search-input { background: #2A1A0A; }
.me-stats-bar {
  display: flex;
  gap: 0;
  background: var(--brown);
  color: #fff;
  font-size: 12px;
  text-align: center;
}
.me-stat { flex: 1; padding: 7px 6px; border-right: 1px solid rgba(255,255,255,.15); }
.me-stat:last-child { border-right: none; }
.me-stat b { display: block; font-size: 15px; color: var(--gold-light); }

@media print {
  body { background: #fff; }
  #installBanner, .header, .table-bar, .menu-panel,
  .drawer-handle, .remove-btn, .btn-clear, .btn-print, .btn-pdf,
  .note-row textarea, .cat-scroll, .cat-section, .qty-ctrl,
  .order-peek { display: none !important; }

  .main { display: block; }
  .order-panel {
    position: static !important;
    width: 100% !important;
    max-height: none !important;
    height: auto !important;
    transform: none !important;
    -webkit-transform: none !important;
    box-shadow: none !important;
    border: none !important;
    padding-bottom: 0 !important;
  }
  .print-header { display: block !important; }
  .order-body { padding: 0; }
  .note-label-print { display: block !important; }
  .print-qr-section { display: block !important; }
  .order-totals-block { display: flex !important; }
}

/* ── PRINT HEADER (hidden except @print) ── */
.print-header {
  display: none;
  text-align: center;
  padding: 10px 0 8px;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 10px;
}
.print-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 18px; font-weight: 700;
}
.ph-sub { font-size: 11px; color: #555; margin-top: 2px; }
.ph-table { font-size: 14px; font-weight: 700; margin-top: 5px; letter-spacing: .5px; }
.ph-time { font-size: 10px; color: #777; margin-top: 2px; }

.note-label-print { display: none; font-size: 12px; font-weight: 600; margin-top: 8px; }
.note-print-area {
  font-size: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 5px 8px;
  margin-top: 3px;
  min-height: 28px;
  white-space: pre-wrap;
}

/* ── PRINT QR SECTION ── */
.print-qr-section {
  display: none;
  text-align: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #000;
}
.print-qr-section img {
  width: 120px;
  height: 120px;
  display: block;
  margin: 6px auto 4px;
  image-rendering: pixelated;
}
.print-qr-label {
  font-size: 10px;
  color: #555;
  margin-top: 3px;
}
.print-qr-bank {
  font-size: 9px;
  color: #777;
  margin-top: 2px;
}

/* ── DASHBOARD / THỐNG KÊ ── */
#dashBtn {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,.15);
  border: none;
  border-radius: 50%;
  width: 34px; height: 34px;
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--white);
  transition: background .15s;
}
#dashBtn:hover { background: rgba(255,255,255,.28); }

#dashOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 300;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
  padding-top: calc(14px + env(safe-area-inset-top));
}
#dashOverlay.open { display: block; }

#dashPanel {
  background: var(--cream);
  max-width: 520px;
  margin: 0 auto;
  border-radius: 16px;
  padding: 0 0 24px;
  box-shadow: 0 8px 32px rgba(74,44,23,.35);
}

.dash-header {
  background: var(--brown);
  color: var(--white);
  padding: 18px 16px 16px;
  border-radius: 16px 16px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.dash-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  color: var(--gold-light);
}
.dash-close {
  background: rgba(255,255,255,.18);
  border: none;
  border-radius: 50%;
  width: 38px; height: 38px;
  font-size: 20px;
  color: var(--white);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

.dash-tabs {
  display: flex;
  gap: 6px;
  padding: 14px 14px 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.dash-tabs::-webkit-scrollbar { display: none; }
.dash-tab {
  flex-shrink: 0;
  background: var(--white);
  border: 1.5px solid var(--divider);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: all .15s;
  font-family: inherit;
  min-height: 44px;
}
.dash-tab.active {
  background: var(--brown);
  border-color: var(--brown);
  color: var(--white);
}

.dash-content { padding: 14px 14px 0; }

.stat-card {
  background: var(--white);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(74,44,23,.07);
}
.stat-card-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--divider);
  font-size: 15px;
}
.stat-row:last-child { border-bottom: none; }
.stat-row-label { color: var(--ink); }
.stat-row-val { font-weight: 700; font-size: 16px; }
.stat-row-val.revenue { color: var(--brown); }
.stat-row-val.profit  { color: var(--green); }
.stat-row-val.cost    { color: var(--muted); }
.stat-row-val.orders  { color: var(--gold); }

.dash-empty {
  text-align: center;
  color: var(--ink);
  font-size: 14px;
  padding: 24px 16px;
  line-height: 1.7;
}
.dash-empty .empty-icon { font-size: 36px; display: block; margin-bottom: 10px; }
.dash-empty .empty-steps {
  background: var(--white);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 12px;
  text-align: left;
  font-size: 13px;
  color: var(--ink);
  line-height: 2;
  border: 1.5px solid var(--divider);
}

/* Top items list */
.top-item-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--divider);
  font-size: 13px;
}
.top-item-row:last-child { border-bottom: none; }
.top-rank {
  width: 22px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  flex-shrink: 0;
  padding-top: 1px;
}
.top-rank.gold   { color: #C8923A; }
.top-rank.silver { color: #8C8C8C; }
.top-rank.bronze { color: #a0522d; }
.top-info { flex: 1; min-width: 0; }
.top-name { font-weight: 500; line-height: 1.3; }
.top-bar-wrap {
  margin-top: 5px;
  background: var(--divider);
  border-radius: 99px;
  height: 4px;
}
.top-bar-fill {
  height: 4px;
  border-radius: 99px;
  background: var(--gold);
}
.top-qty {
  font-weight: 700;
  color: var(--brown);
  white-space: nowrap;
  font-size: 13px;
  padding-top: 1px;
}
.stat-row-val.cost-real { color: var(--danger); }
.stat-row-val.nh-cost  { color: #e67e22; }
.stat-row.real-profit-row {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 2px solid var(--ink);
  border-bottom: none;
}
.stat-row-val.real-profit { color: var(--green); font-size: 20px; }
.stat-row-val.real-profit.negative { color: var(--danger); font-size: 20px; }
.stat-formula-divider {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  color: var(--muted);
  font-size: 12px;
}
.stat-formula-divider::before,
.stat-formula-divider::after {
  content: '';
  flex: 1;
  border-top: 1px dashed var(--divider);
}
/* Top items bigger on mobile */
.top-item-row { padding: 10px 0; font-size: 14px; }
.top-name { font-size: 14px; font-weight: 600; }
.top-qty { font-size: 14px; }
.top-bar-wrap { height: 5px; margin-top: 6px; }
.top-bar-fill { height: 5px; }
  flex: 1;
  border-top: 1px dashed var(--divider);
}

/* ── NHẬP HÀNG OVERLAY ── */
#nhOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 300;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
  padding-top: calc(14px + env(safe-area-inset-top));
}
#nhOverlay.open { display: block; }
#nhPanel {
  background: var(--cream);
  max-width: 520px;
  margin: 0 auto;
  border-radius: 16px;
  padding: 0 0 24px;
  box-shadow: 0 8px 32px rgba(74,44,23,.35);
}
.nh-form {
  padding: 16px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.nh-row2 {
  display: flex;
  gap: 10px;
}
.nh-field { display: flex; flex-direction: column; gap: 6px; }
.nh-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
}
.nh-input {
  border: 1.5px solid var(--divider);
  border-radius: 10px;
  padding: 13px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  background: var(--white);
  outline: none;
  width: 100%;
  -webkit-appearance: none;
  min-height: 50px;
}
.nh-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200,146,58,.15); }
.nh-save-btn {
  width: 100%;
  background: var(--brown);
  color: var(--white);
  border: none;
  border-radius: 12px;
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  margin-top: 4px;
  transition: background .15s;
  min-height: 54px;
  letter-spacing: .3px;
}
.nh-save-btn:hover { background: var(--gold); }
.nh-summary {
  margin: 14px 14px 0;
  background: var(--white);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(74,44,23,.07);
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nh-summary-label { color: var(--muted); font-weight: 500; }
.nh-summary-val { font-weight: 700; color: var(--danger); font-size: 18px; }
.nh-history-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 14px 8px;
}
.nh-history-title {
  flex: 1;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}
.nh-filter-btn {
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 99px;
  border: 1.5px solid var(--divider);
  background: var(--white);
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: all .12s;
  min-height: 36px;
}
.nh-filter-btn.active {
  background: var(--brown);
  border-color: var(--brown);
  color: var(--white);
}
.nh-list {
  padding: 0 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nh-entry {
  background: var(--white);
  border-radius: 12px;
  padding: 13px 14px;
  box-shadow: 0 1px 4px rgba(74,44,23,.06);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.nh-entry-left { flex: 1; min-width: 0; }
.nh-entry-name { font-size: 15px; font-weight: 600; }
.nh-entry-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.nh-entry-note { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 2px; }
.nh-entry-amount { font-size: 16px; font-weight: 700; color: var(--danger); white-space: nowrap; padding-top: 2px; }
.nh-del-btn {
  background: none;
  border: 1.5px solid var(--divider);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  flex-shrink: 0;
  transition: all .12s;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nh-del-btn:hover { color: var(--danger); border-color: var(--danger); }
.nh-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 20px 0;
  opacity: .7;
}
body.dark #nhPanel { background: var(--cream); }
body.dark .nh-input { background: #2A1A0A; color: var(--ink); }
body.dark .nh-entry { background: #231608; }
body.dark .nh-summary { background: #231608; }

/* ── STATS BAR (top of page) ── */
.stats-bar {
  background: var(--brown);
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  border-top: 1px solid rgba(255,255,255,.1);
}
.stat-box {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  color: var(--white);
  border-right: 1px solid rgba(255,255,255,.1);
}
.stat-box:last-child { border-right: none; }
.stat-box-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--gold-light);
  display: block;
  line-height: 1.2;
}
.stat-box-lbl {
  font-size: 10px;
  opacity: .65;
  letter-spacing: .5px;
}

/* ── MAIN TABS ── */
.main-tabs {
  display: flex;
  background: var(--white);
  border-bottom: 2px solid var(--divider);
  position: sticky;
  top: 0;
  z-index: 90;
}
.main-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 11px 6px 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  position: relative;
}
.main-tab.active {
  color: var(--brown);
  border-bottom-color: var(--brown);
}
.main-tab .tab-badge {
  background: var(--gold);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 99px;
  padding: 1px 5px;
  margin-left: 3px;
  display: inline-block;
  vertical-align: top;
  margin-top: -1px;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── SERVING ORDERS ── */
.serving-panel { padding: 0 0 100px; }
.serving-search-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px 8px; background: var(--surface);
  position: sticky; top: 0; z-index: 10;
  border-bottom: 1px solid var(--divider);
}
.serving-search-input {
  flex: 1; background: rgba(255,255,255,.6);
  border: 1.5px solid var(--divider); border-radius: 10px;
  padding: 9px 14px; font-size: 14px; color: var(--text);
  font-family: inherit; outline: none;
}
.serving-search-input:focus { border-color: var(--gold); }
.serving-search-clear {
  background: none; border: none; font-size: 18px;
  color: var(--muted); cursor: pointer; padding: 4px 6px;
  line-height: 1; display: none;
}
.serving-list-inner { padding: 12px 14px 8px; }

/* Merge order modal */
#mergeModal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 9998;
  align-items: flex-end; justify-content: center;
}
#mergeModal.open { display: flex; }
#mergeBox {
  background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 20px 18px 36px; width: 100%; max-width: 540px;
  max-height: 80vh; overflow-y: auto;
  box-shadow: 0 -4px 32px rgba(0,0,0,.3);
  animation: slideUp .2s ease;
}
#mergeBox h3 { margin: 0 0 6px; font-size: 18px; color: var(--gold); }
#mergeBox p { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.merge-table-list { display: flex; flex-direction: column; gap: 8px; }
.merge-table-btn {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,.7); border: 1.5px solid var(--divider);
  border-radius: 12px; padding: 12px 14px; cursor: pointer;
  font-family: inherit; font-size: 14px; color: var(--text);
  transition: border-color .15s, background .15s;
  text-align: left;
}
.merge-table-btn:hover { border-color: var(--gold); background: rgba(200,146,42,.07); }
.merge-table-name { font-weight: 700; font-size: 15px; }
.merge-table-detail { font-size: 12px; color: var(--muted); margin-top: 2px; }
.merge-table-total { font-weight: 800; color: var(--brown); }
.merge-cancel {
  width: 100%; margin-top: 12px; background: none;
  border: 1.5px solid var(--divider); color: var(--muted);
  border-radius: 12px; padding: 12px; font-size: 14px;
  cursor: pointer; font-family: inherit;
}

/* Payment quick panel inside payOrder */
#quickPayModal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 9997;
  align-items: flex-end; justify-content: center;
}
#quickPayModal.open { display: flex; }
#quickPayBox {
  background: var(--white); border-radius: 20px 20px 0 0;
  padding: 20px 18px 36px; width: 100%; max-width: 540px;
  box-shadow: 0 -4px 32px rgba(0,0,0,.4);
  animation: slideUp .2s ease;
}
body.dark #quickPayBox { background: #231608; }
#quickPayBox h3 { margin: 0 0 4px; font-size: 18px; color: var(--gold); }
#quickPayBox .qp-table { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.qp-total-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--divider); margin-bottom: 10px;
}
.qp-total-label { font-size: 14px; color: var(--muted); }
.qp-total-amt { font-size: 24px; font-weight: 900; color: var(--gold); }
.qp-received-row { margin-bottom: 10px; }
.qp-received-label { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.qp-received-input {
  width: 100%; box-sizing: border-box;
  background: var(--white); border: 2px solid var(--gold);
  border-radius: 12px; padding: 12px 14px; font-size: 20px;
  font-weight: 800; color: var(--ink); font-family: inherit; outline: none;
  text-align: right;
}
.qp-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.qp-preset-btn {
  background: rgba(200,146,42,.12); border: 1px solid var(--gold);
  color: var(--brown); border-radius: 8px; padding: 6px 10px;
  font-size: 12px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.qp-change-row {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(46,125,50,.1); border-radius: 12px; padding: 12px 14px;
  margin-bottom: 14px;
}
.qp-change-label { font-size: 14px; color: var(--green); font-weight: 600; }
.qp-change-amt { font-size: 22px; font-weight: 900; color: var(--green); }
.qp-change-amt.neg { color: var(--danger); }
.qp-actions { display: flex; gap: 10px; }
.qp-cancel {
  background: none; border: 1.5px solid var(--divider); color: var(--muted);
  border-radius: 12px; padding: 12px 18px; font-size: 14px; cursor: pointer; font-family: inherit;
}
.qp-confirm {
  flex: 1; background: var(--green); color: #fff; border: none;
  border-radius: 12px; padding: 12px; font-size: 15px; font-weight: 800;
  cursor: pointer; font-family: inherit;
}

/* Backup buttons */
.backup-row {
  display: flex; gap: 8px; padding: 10px 14px;
  border-top: 1px solid var(--divider); margin-top: 4px;
}
.btn-backup-export, .btn-backup-import {
  flex: 1; border-radius: 10px; padding: 10px;
  font-size: 13px; font-weight: 700; cursor: pointer; font-family: inherit;
  border: 1.5px solid var(--divider);
}
.btn-backup-export { background: rgba(46,125,50,.12); color: var(--green); }
.btn-backup-import { background: rgba(200,146,42,.12); color: var(--brown); }
.serving-empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: 14px;
}
.serving-empty .empty-icon { font-size: 48px; display: block; margin-bottom: 12px; }
.order-card {
  background: var(--white);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(74,44,23,.09);
  border: 1.5px solid var(--divider);
}
.order-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.order-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--brown);
  background: var(--gold-light);
  border-radius: 6px;
  padding: 2px 8px;
}
.order-table {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
}
.order-time {
  font-size: 11px;
  color: var(--muted);
}
.order-items-list {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 10px;
  padding-left: 4px;
}
.order-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.order-total-amt {
  font-size: 17px;
  font-weight: 700;
  color: var(--brown);
}
.order-status {
  font-size: 11px;
  font-weight: 600;
  background: #e8f5e9;
  color: var(--green);
  border-radius: 99px;
  padding: 3px 10px;
}
.order-actions {
  display: flex;
  gap: 8px;
}
.btn-pay {
  flex: 1;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.btn-pay:hover { background: #1b5e20; }
.btn-view-pdf {
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
  white-space: nowrap;
}
.btn-view-pdf:hover { background: #b07a28; }
.btn-del-order {
  background: none;
  border: 1.5px solid var(--divider);
  color: var(--muted);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all .12s;
}
.btn-del-order:hover { color: var(--danger); border-color: var(--danger); }
.btn-edit-order {
  background: none;
  border: 1.5px solid var(--divider);
  color: var(--muted);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all .12s;
}
.btn-edit-order:hover { color: var(--gold); border-color: var(--gold); }

/* ── EDIT BILL MODAL ── */
#editBillModal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 19999;
  align-items: flex-end;
  justify-content: center;
}
#editBillModal.open { display: flex; }
#editBillBox {
  background: var(--white);
  border-radius: 20px 20px 0 0;
  padding: 20px 18px 36px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 -4px 32px rgba(0,0,0,.4);
  animation: slideUp .2s ease;
  position: relative;
  z-index: 20000;
}
body.dark #editBillBox { background: #231608; }
@keyframes slideUp { from { transform: translateY(40px); opacity:0; } to { transform: translateY(0); opacity:1; } }
#editBillBox h3 { margin: 0 0 16px; font-size: 18px; color: var(--gold); }
.edit-bill-label { font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.edit-bill-input {
  width: 100%; box-sizing: border-box;
  background: rgba(255,255,255,.1);
  border: 1.5px solid var(--divider);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  padding: 10px 12px;
  margin-bottom: 12px;
  outline: none;
}
.edit-bill-input:focus { border-color: var(--gold); }
.edit-items-list { margin-bottom: 14px; }
.edit-item-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--divider);
}
.edit-item-name { flex: 1; font-size: 14px; }
.edit-item-qty {
  width: 48px; text-align: center;
  background: rgba(255,255,255,.1);
  border: 1.5px solid var(--divider);
  border-radius: 8px; color: var(--text);
  font-size: 14px; font-family: inherit; padding: 5px 6px;
}
.edit-item-price { font-size: 13px; color: var(--muted); width: 80px; text-align: right; }
.edit-item-del {
  background: none; border: none; color: var(--danger);
  font-size: 16px; font-weight: 700; cursor: pointer;
  padding: 2px 6px; border-radius: 6px; line-height: 1;
  opacity: 0.7; transition: opacity .15s;
}
.edit-item-del:hover { opacity: 1; background: rgba(220,50,50,.12); }
.edit-payment-box {
  background: rgba(255,255,255,.06);
  border-radius: 12px; padding: 14px;
  margin-bottom: 14px; border: 1.5px solid var(--divider);
}
.edit-payment-box .pay-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 14px; }
.edit-payment-box .pay-row:last-child { margin-bottom: 0; }
.edit-payment-box .pay-label { color: var(--muted); }
.edit-payment-box .pay-total { font-size: 20px; font-weight: 800; color: var(--gold); }
.edit-payment-box .pay-change { font-size: 16px; font-weight: 700; color: #4caf50; }
.edit-payment-box .pay-change.neg { color: var(--danger); }
.edit-bill-actions { display: flex; gap: 10px; }
.edit-bill-save { flex: 1; background: var(--green); color: #fff; border: none; border-radius: 10px; padding: 12px; font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit; }
.edit-bill-cancel { background: none; border: 1.5px solid var(--divider); color: var(--muted); border-radius: 10px; padding: 12px 18px; font-size: 14px; cursor: pointer; font-family: inherit; }

/* ── HISTORY PANEL ── */
.history-panel { padding: 12px 14px 100px; }
.history-entry {
  background: var(--white);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(74,44,23,.07);
}
.history-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.history-num { font-size: 12px; font-weight: 700; color: var(--muted); }
.history-table { font-size: 13px; font-weight: 600; flex: 1; }
.history-time { font-size: 11px; color: var(--muted); }
.history-total { font-size: 16px; font-weight: 700; color: var(--brown); margin-bottom: 6px; }
.history-items-preview { font-size: 12px; color: var(--muted); line-height: 1.6; margin-bottom: 8px; }
.history-actions { display: flex; gap: 6px; }
.btn-reprint {
  flex: 1;
  background: none;
  border: 1.5px solid var(--gold);
  color: var(--gold);
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .12s;
}
.btn-reprint:hover { background: var(--gold); color: #fff; }
.btn-del-hist {
  background: none;
  border: 1.5px solid var(--divider);
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
  transition: all .12s;
}
.btn-del-hist:hover { color: var(--danger); border-color: var(--danger); }

/* ── DAILY REPORT ── */
.report-btn {
  display: block;
  width: 100%;
  background: var(--brown);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 12px;
  text-align: center;
  transition: background .15s;
}
.report-btn:hover { background: var(--gold); }

/* ── UNDO TOAST ── */
#undoToast {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #333;
  color: #fff;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transition: all .3s;
  z-index: 500;
  min-width: 260px;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
}
#undoToast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
#undoToast .undo-msg { flex: 1; }
#undoToast .undo-bar {
  height: 3px;
  background: var(--gold);
  border-radius: 99px;
  position: absolute;
  bottom: 0; left: 0;
  width: 100%;
  border-radius: 0 0 12px 12px;
  transform-origin: left;
  animation: undoProgress 30s linear forwards;
}
@keyframes undoProgress { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.btn-undo {
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}

/* Dark mode for new elements */
body.dark .order-card { background: #231608; border-color: var(--divider); }
body.dark .history-entry { background: #231608; }
body.dark .order-status { background: rgba(76,175,80,.15); }

/* ── ITEM NOTE (ghi chú từng món) ── */
.item-note-btn {
  background: none; border: 1px solid var(--divider);
  color: var(--muted); border-radius: 6px;
  padding: 2px 7px; font-size: 11px;
  cursor: pointer; font-family: inherit;
  transition: all .12s; white-space: nowrap;
  flex-shrink: 0;
}
.item-note-btn:hover { border-color: var(--gold); color: var(--gold); }
.item-note-btn.has-note { border-color: var(--gold); color: var(--gold); background: rgba(200,146,58,.1); }
.item-note-input {
  display: none; width: 100%;
  border: 1.5px solid var(--gold); border-radius: 8px;
  padding: 6px 10px; font-size: 13px; font-family: inherit;
  outline: none; color: var(--ink); background: var(--cream);
  margin-top: 6px; -webkit-appearance: none;
}
.item-note-input.visible { display: block; }
body.dark .item-note-input { background: #2A1A0A; color: var(--ink); }
.order-item-note { font-size: 11px; color: var(--gold); margin-top: 2px; font-style: italic; }

/* ── HẾT HÀNG (out of stock) ── */
.item-row.out-of-stock { opacity: .45; }
.item-row.out-of-stock .qty-btn { pointer-events: none; opacity: .4; }
.item-oos-badge {
  font-size: 10px; font-weight: 700; color: var(--danger);
  background: rgba(204,68,68,.1); border: 1px solid var(--danger);
  border-radius: 4px; padding: 1px 5px; flex-shrink: 0;
}
.oos-toggle-btn {
  background: none; border: 1.5px solid var(--divider);
  color: var(--muted); border-radius: 6px;
  padding: 2px 7px; font-size: 10px; cursor: pointer;
  font-family: inherit; transition: all .12s;
}
.oos-toggle-btn.oos { border-color: var(--danger); color: var(--danger); background: rgba(204,68,68,.08); }
.oos-toggle-btn:hover { border-color: var(--brown); color: var(--brown); }

/* ── BIỂU ĐỒ DOANH THU ── */
.chart-container {
  background: var(--white); border-radius: 14px;
  padding: 16px; margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(74,44,23,.07);
}
.chart-title {
  font-size: 12px; font-weight: 700; letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted); margin-bottom: 12px;
}
.chart-svg-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart-svg-wrap svg { display: block; }
.chart-bar-group { cursor: default; }
.chart-bar { transition: opacity .15s; }
.chart-bar:hover { opacity: .8; }
.chart-label { font-size: 8px; fill: var(--muted); text-anchor: middle; }
.chart-val { font-size: 7px; fill: var(--brown); text-anchor: middle; font-weight: 700; }
.chart-empty { text-align:center; color:var(--muted); font-size:13px; padding:24px 0; }

/* Peak hours chart */
.peak-bar-h { fill: var(--gold); transition: opacity .12s; }
.peak-bar-h:hover { opacity: .7; }
.peak-label-h { font-size: 8px; fill: var(--muted); text-anchor: middle; }
.peak-val-h { font-size: 7px; fill: var(--brown); text-anchor: middle; font-weight:700; }

/* ── TÁCH BILL ── */
#splitBillModal {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 9998;
  align-items: flex-end; justify-content: center;
}
#splitBillModal.open { display: flex; }
#splitBillBox {
  background: var(--cream); border-radius: 20px 20px 0 0;
  padding: 20px 18px 36px; width: 100%; max-width: 540px;
  max-height: 85vh; overflow-y: auto;
  box-shadow: 0 -4px 32px rgba(0,0,0,.3);
  animation: slideUp .2s ease;
}
#splitBillBox h3 { margin: 0 0 12px; font-size: 18px; color: var(--gold); }
.split-people-row { display:flex; align-items:center; gap:10px; margin-bottom:14px; }
.split-people-label { font-size:14px; color:var(--muted); }
.split-people-ctrl { display:flex; align-items:center; gap:8px; }
.split-people-btn {
  width:36px; height:36px; border-radius:50%; border:none;
  background:var(--brown); color:#fff; font-size:20px;
  cursor:pointer; display:flex; align-items:center; justify-content:center;
}
.split-people-num { font-size:20px; font-weight:800; color:var(--brown); min-width:28px; text-align:center; }
.split-items-section { margin-bottom:14px; }
.split-section-title { font-size:12px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.8px; margin-bottom:8px; }
.split-item-row {
  display:flex; align-items:center; gap:8px;
  padding:8px 0; border-bottom:1px solid var(--divider);
}
.split-item-name { flex:1; font-size:13px; }
.split-item-price { font-size:12px; color:var(--muted); }
.split-item-check {
  width:22px; height:22px; border-radius:6px;
  border:2px solid var(--divider); cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  font-size:13px; flex-shrink:0; transition:all .12s;
}
.split-item-check.checked { background:var(--green); border-color:var(--green); color:#fff; }
.split-result-box {
  background: rgba(200,146,58,.1); border-radius: 12px;
  padding: 14px; margin-bottom: 14px; border: 1.5px solid var(--gold-light);
}
.split-result-row { display:flex; justify-content:space-between; align-items:center; padding:4px 0; font-size:14px; }
.split-result-total { font-size:20px; font-weight:800; color:var(--gold); }
.split-person-tag { display:inline-block; background:var(--gold-light); color:var(--brown); border-radius:6px; padding:2px 8px; font-size:12px; font-weight:700; margin-right:4px; }
.split-actions { display:flex; gap:10px; }
.split-cancel { background:none; border:1.5px solid var(--divider); color:var(--muted); border-radius:12px; padding:11px 18px; font-size:14px; cursor:pointer; font-family:inherit; }
.split-copy { flex:1; background:var(--brown); color:#fff; border:none; border-radius:12px; padding:11px; font-size:14px; font-weight:700; cursor:pointer; font-family:inherit; }
body.dark .split-result-box { background: rgba(200,146,58,.08); }
body.dark #splitBillBox { background: #1A1208; }

/* Dark mode */
body.dark #dashPanel { background: var(--cream); }
body.dark .stat-card { background: #231608; }
body.dark .dash-tab { background: #2A1A0A; }