:root {
  --bg: #f6f4f1;
  --card: #ffffff;
  --line: #e5e0d8;
  --text: #1f1a17;
  --muted: #7a6f66;
  --primary: #c2410c;
  --primary-soft: #ffedd5;
  --green: #15803d;
  --green-soft: #dcfce7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --blue: #1d4ed8;
  --blue-soft: #dbeafe;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); font-weight: 600; min-height: 1.2em; }
h1, h2, h3 { margin: 0 0 8px; }
input, select, textarea, button { font: inherit; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); border-color: transparent; }
label { display: block; font-weight: 600; margin: 10px 0 4px; }
label input, label select { margin-top: 4px; font-weight: 400; }

/* ---------- Tombol ---------- */
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { filter: brightness(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--red); border-color: #f3c4c4; }
.btn.ghost { background: transparent; }
.btn.link { background: none; border: none; color: var(--primary); padding: 6px 0; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.big { padding: 16px; font-size: 18px; }
.btn.block { width: 100%; margin-top: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 7px 14px; cursor: pointer; font-weight: 600;
}
.chip.on { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--card); padding: 28px; border-radius: 18px; width: 100%; max-width: 400px; box-shadow: 0 10px 30px rgba(0,0,0,.07); }
.user-list { display: grid; gap: 8px; }
.user-btn { display: flex; justify-content: space-between; align-items: center; text-align: left; padding: 12px 14px; }
.user-btn.on { border-color: var(--primary); background: var(--primary-soft); }
.role { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 8px 16px; flex-wrap: wrap;
}
.brand { font-weight: 800; font-size: 18px; color: var(--primary); }
.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tab { border: none; background: none; padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; color: var(--muted); position: relative; }
.tab.on { background: var(--primary-soft); color: var(--primary); }
.tab .badge { margin-left: 4px; vertical-align: 1px; }
.badge { background: var(--red); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 6px; font-weight: 700; }
.top-right { display: flex; align-items: center; gap: 10px; }
.conn { font-size: 13px; font-weight: 600; }
.conn.on { color: var(--green); }
.conn.wait { color: var(--amber); }
.conn.off { color: var(--red); }
.who { font-weight: 600; }

main { padding: 16px; }
@media (max-width: 700px) {
  .topbar { gap: 6px 10px; padding: 8px 12px; }
  .brand { flex: 1; }
  .tabs { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; }
  .tab { white-space: nowrap; }
  .who { display: none; }
  main { padding: 12px; }
  .sticky { position: static; max-height: none; }
}

/* ---------- Kasir ---------- */
.kasir { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .kasir { grid-template-columns: 1fr; } }
.panel { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); padding: 16px; }
.sticky { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow: auto; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 4px 0 10px; }
.tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.table-card {
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px; cursor: pointer; text-align: left;
}
.table-card:hover { border-color: #f5b98f; }
.table-card.on { border-color: var(--primary); background: var(--primary-soft); }
.table-card.fresh { animation: pulse 1.2s ease-in-out 3; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(194,65,12,.25); } }
.table-no { font-size: 26px; font-weight: 800; }
.table-total { font-size: 18px; font-weight: 700; margin-top: 6px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.pay-list { display: grid; gap: 6px; margin-top: 8px; }
.pay-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.pay-row .grow { flex: 1; }
.pay-row.void .grow b { text-decoration: line-through; }
.small { font-size: 13px; }

.bill-lines { margin: 8px 0; }
.line { display: flex; gap: 8px; padding: 5px 0; }
.line .q { width: 36px; font-weight: 700; }
.line .n { flex: 1; }
.amt { display: flex; justify-content: space-between; padding: 3px 0; }
.amt.total { font-size: 24px; font-weight: 800; color: var(--primary); border-top: 2px solid var(--line); padding-top: 10px; margin-top: 6px; }
.change { display: flex; justify-content: space-between; align-items: center; font-size: 18px; margin-top: 8px; }
.change b { font-size: 26px; color: var(--green); }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; }
.switch { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 10px 0; cursor: pointer; }
.switch input { width: auto; }
hr { border: none; border-top: 1px solid var(--line); margin: 12px 0; }

/* ---------- Order (pesanan) ---------- */
.status-filter { margin-bottom: 12px; }
.orders { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.order-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.order-head { display: flex; justify-content: space-between; align-items: center; }
.pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.st-BARU { background: var(--red-soft); color: var(--red); }
.st-DIMASAK { background: var(--amber-soft); color: var(--amber); }
.st-SIAP { background: var(--blue-soft); color: var(--blue); }
.st-DISAJIKAN { background: #ede9fe; color: #6d28d9; }
.st-SELESAI { background: var(--green-soft); color: var(--green); }
.st-BATAL { background: #eee; color: #666; text-decoration: line-through; }
.order-items { margin: 4px 0; padding-left: 0; list-style: none; }
.order-items li { padding: 2px 0; }
.note { color: var(--amber); font-size: 13px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }

/* ---------- Order baru ---------- */
.neworder { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .neworder { grid-template-columns: 1fr; } }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 12px; }
.menu-tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 0; cursor: pointer; text-align: left; overflow: hidden; display: flex; flex-direction: column; }
.menu-tile:hover { border-color: var(--primary); }
.menu-tile.off { opacity: .45; cursor: not-allowed; }
.menu-tile img, .menu-tile .noimg { width: 100%; aspect-ratio: 4/3; object-fit: cover; background: var(--primary-soft); display: grid; place-items: center; font-size: 28px; font-weight: 800; color: var(--primary); }
.menu-tile .t { padding: 8px 10px; }
.menu-tile .qty-tag { position: relative; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 800; }
.cart-line input { grid-column: 1 / -1; padding: 6px 10px; font-size: 13px; }

/* ---------- Menu ---------- */
.menu-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; }
.menu-table th, .menu-table td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; }
.menu-table th { background: #faf8f5; font-size: 13px; color: var(--muted); }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--primary-soft); }
.cat-row td { background: #faf8f5; font-weight: 800; }

td.nowrap, .nowrap { white-space: nowrap; }

/* ---------- Kalkulator modal per porsi ---------- */
.modal-box.wide { max-width: 1040px; }
.recipe-wrap { overflow-x: auto; margin: 8px 0; }
.recipe-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.recipe-table th { text-align: left; font-size: 12px; color: var(--muted); padding: 4px; }
.recipe-table td { padding: 4px; vertical-align: middle; }
.recipe-table td input { width: 100%; padding: 8px 10px; }
.recipe-table td:nth-child(2) { width: 120px; }
.recipe-table td:nth-child(3), .recipe-table td:nth-child(4) { width: 170px; }
.recipe-table td:nth-child(5), .recipe-table td:nth-child(6) { width: 95px; }
.qty-unit { display: flex; gap: 4px; }
.qty-unit input { min-width: 0; flex: 1; }
.qty-unit select { width: 78px; padding: 8px 4px; }
.recipe-sum { background: var(--primary-soft); border-radius: 12px; padding: 12px 14px; margin-top: 12px; display: grid; gap: 6px; }
.recipe-sum .lr { display: flex; justify-content: space-between; gap: 10px; }
.recipe-sum .big-line { font-size: 20px; border-top: 1px solid #f0d9c8; padding-top: 6px; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.recipe-table tr.linked td { background: #f3f8f1; }

/* ---------- Gudang bahan ---------- */
.table-scroll { overflow-x: auto; }
.gd-table { min-width: 760px; }
.gd-actions { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.hint-box { background: #fff7e6; border: 1px solid #f6d79b; border-radius: 10px; padding: 10px 12px; margin: 10px 0; line-height: 1.5; }
.hint-box > div { margin-top: 8px; }
.tag-low { background: var(--red-soft); color: var(--red); border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini.hist th, .mini.plan th { text-align: left; font-size: 12px; color: var(--muted); padding: 4px 6px 4px 0; }
.mini.hist td, .mini.plan td { padding: 6px 6px 6px 0; text-align: left; }
.mini.plan td:last-child, .mini.plan th:last-child { text-align: right; }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }

/* ---------- Laporan ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .v { font-size: 22px; font-weight: 800; margin-top: 4px; }
.report-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.mini { width: 100%; border-collapse: collapse; }
.mini td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.mini td:last-child { text-align: right; }

/* ---------- Modal & toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal-box { background: #fff; border-radius: 16px; padding: 22px; width: 100%; max-width: 460px; max-height: 92vh; overflow: auto; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.big-check { font-size: 48px; text-align: center; color: var(--green); }
.qr { display: block; margin: 10px auto; width: 260px; height: 260px; image-rendering: pixelated; }
.toasts { position: fixed; bottom: 16px; right: 16px; display: grid; gap: 8px; z-index: 30; }
.toast { background: #1f1a17; color: #fff; padding: 12px 16px; border-radius: 10px; max-width: 360px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.new { background: var(--primary); font-weight: 700; }
.toast.err { background: var(--red); }

/* ---------- Pengaturan ---------- */
.settings { max-width: 560px; }
#setRoot { display: grid; gap: 16px; }
#restoSet { max-width: 980px; }
.set-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
@media (max-width: 760px) { .set-grid { grid-template-columns: 1fr; } }
.settings textarea { width: 100%; resize: vertical; }
.logo-row { align-items: center; gap: 8px; flex-wrap: wrap; }
.logo-box { width: 120px; height: 60px; border: 1px dashed var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; background: #fff; overflow: hidden; }
.logo-box img { max-width: 100%; max-height: 100%; }
.br-kop { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin: 6px 0; }
.br-kop summary { cursor: pointer; font-weight: 700; }
.small-sel { width: auto; padding: 4px 8px; }
/* Contoh struk di layar (meniru hasil cetak 80 mm) */
.receipt-preview { position: sticky; top: 12px; margin-top: 8px; background: #fff; color: #000; font-family: "Courier New", monospace; font-size: 12px;
  width: 280px; padding: 12px 10px; border: 1px solid #ddd; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.receipt-preview .c { text-align: center; }
.receipt-preview .big { font-size: 28px; font-weight: 800; text-align: center; margin: 4px 0; }
.receipt-preview .lr { display: flex; justify-content: space-between; gap: 6px; }
.receipt-preview .hr { border-top: 1px dashed #000; margin: 4px 0; }
.receipt-preview .tall { font-size: 16px; font-weight: 700; }
.receipt-preview img.logo { max-width: 70%; max-height: 70px; filter: grayscale(1); }

/* ---------- Cetak struk (printer thermal lewat dialog print browser) ---------- */
.print-area { display: none; }
@media print {
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block; font-family: "Courier New", monospace; font-size: 12px; color: #000; }
  .print-area .c { text-align: center; }
  .print-area .big { font-size: 28px; font-weight: 800; text-align: center; margin: 4px 0; }
  .print-area .lr { display: flex; justify-content: space-between; gap: 6px; }
  .print-area .hr { border-top: 1px dashed #000; margin: 4px 0; }
  .print-area .tall { font-size: 16px; font-weight: 700; }
  .print-area img.logo { max-width: 70%; max-height: 25mm; filter: grayscale(1); margin-bottom: 2px; }
}

/* ---------- Pusat & cabang ---------- */
.branch-sel { width: auto; padding: 6px 10px; font-weight: 700; border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.branch-tag { font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 4px 10px; border-radius: 999px; font-size: 13px; }
.order-card.incoming { border: 2px solid var(--primary); }
.send-table input { padding: 6px 10px; }
.mobile-only { display: none !important; }

/* ---------- HP waiter: keranjang jadi lembar dari bawah ---------- */
@media (max-width: 700px) {
  .mobile-only { display: block !important; }
  .table-top { margin-top: 0; }
  .table-top input { font-size: 22px; font-weight: 800; text-align: center; padding: 12px; }
  .neworder { padding-bottom: 76px; }
  .menu-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .menu-tile .t { padding: 6px 8px; }
  #cartPanel { display: none; }
  #cartPanel.open {
    display: block; position: fixed; inset: auto 0 0 0; z-index: 15; max-height: 88vh; overflow: auto;
    border-radius: 18px 18px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,.25); padding-bottom: 24px;
  }
  .cart-bar {
    position: fixed; left: 10px; right: 10px; bottom: 10px; z-index: 10;
    display: flex !important; justify-content: space-between; align-items: center; gap: 8px;
    background: var(--primary); color: #fff; border: none; border-radius: 14px; padding: 14px 16px;
    font: inherit; font-size: 15px; box-shadow: 0 6px 20px rgba(0,0,0,.25); cursor: pointer; text-align: left;
  }
  .cart-bar.empty { background: #fff; color: var(--text); border: 1px solid var(--line); }
  .cart-bar .go { font-weight: 800; white-space: nowrap; }
  .cart-line .stepper button { width: 40px; height: 40px; font-size: 18px; }
  .branch-sel { max-width: 140px; }
  .toasts { left: 10px; right: 10px; bottom: 80px; }
}

/* Fast food: pilihan mode & nomor antrean besar */
.mode-chips { margin: 4px 0 10px; }
.queue-no { text-align: center; margin: 8px 0 14px; font-weight: 700; letter-spacing: 2px; color: var(--muted, #6b6b6b); }
.queue-no b { display: block; font-size: 72px; line-height: 1; color: var(--primary, #c2410c); letter-spacing: 0; }

.take-in { width: 90px; padding: 6px 8px; display: inline-block; }

/* Isi / bungkus per porsi (produksi menu) */
.contents-box { border: 1px dashed var(--line, #ddd); border-radius: 10px; padding: 10px 12px; margin: 12px 0; }
.contents-box .lr { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.contents-box p { margin: 4px 0 8px; }
.contents-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.contents-row input[data-cname] { flex: 1; min-width: 0; }
.contents-row input[data-cqty] { width: 52px; text-align: center; }
.contents-line { margin-top: 2px; }
.ct-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* Menu titipan */
.tag-titip { background: #fff3d6; color: #8a5a00; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.titip-box { background: #fffaf0; border: 1px solid #f1e2bf; border-radius: 10px; padding: 8px 10px; margin: 6px 0; }
.titip-card { border: 1px solid var(--line, #e5e5e5); border-radius: 10px; padding: 8px 10px; margin: 6px 0; }
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { width: auto; }

/* Gudang: filter kategori + cari */
.gd-filter { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 8px; }
.gd-filter input[type="search"] { max-width: 320px; }
.gd-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.gd-table tr.gd-cat td { background: var(--primary-soft); font-weight: 700; padding-top: 10px; border-top: 2px solid var(--line, #ddd); }
