/* ═══════════════════════════════════════════════════════════════════
   STREET CAFE POS — Mobile-First, Touch-Friendly, Dark/Light
   Default: GELAP (operasional outdoor/malam). Toggle di topbar/Pengaturan.
   ═══════════════════════════════════════════════════════════════════ */
:root, [data-theme="dark"] {
  --bg: #1a120b;
  --bg-soft: #241a12;
  --panel: #2b2015;
  --panel-2: #36291c;
  --line: #4a3a2b;
  --text: #f7ece1;
  --muted: #c8b4a0;
  --accent: #f59e0b;         /* amber street-cafe */
  --accent-strong: #fbbf24;
  --accent-ink: #241a12;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --blue: #38bdf8;
  --shadow: 0 8px 28px rgba(0,0,0,.45);
  --radius: 16px;
}
[data-theme="light"] {
  --bg: #f6f1ea;
  --bg-soft: #efe7dc;
  --panel: #ffffff;
  --panel-2: #f3ede4;
  --line: #ddd0c0;
  --text: #2b2015;
  --muted: #7a6a5a;
  --accent: #d97706;
  --accent-strong: #b45309;
  --accent-ink: #ffffff;
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #ca8a04;
  --blue: #0284c7;
  --shadow: 0 6px 18px rgba(60,40,20,.15);
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
  font-size: 16px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.code-box { display: block; background: var(--panel-2); border: 1px dashed var(--line); padding: .5rem .65rem; border-radius: 10px; font-size: .8rem; word-break: break-all; color: var(--blue); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ═══════ TOPBAR ═══════ */
#topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; padding: .5rem .75rem;
  background: var(--bg-soft); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.logo { color: var(--accent); flex: 0 0 auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-text strong { letter-spacing: .06em; font-size: 1.05rem; white-space: nowrap; }
.brand-text small { color: var(--muted); font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.topbar-right { display: flex; align-items: center; gap: .4rem; }
.icon-btn {
  width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 1.1rem;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-strong); }
.icon-btn:active { transform: scale(.96); }

/* Indikator koneksi */
.conn-pill {
  display: inline-flex; align-items: center; gap: .45rem;
  height: 40px; padding: 0 .75rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel);
  font-size: .8rem; font-weight: 600; white-space: nowrap;
}
.conn-dot { width: 13px; height: 13px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 3px rgba(239,68,68,.25); }
.conn-pill.online .conn-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(34,197,94,.25); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { transform: scale(1);} 50% { transform: scale(1.2);} }
.conn-pill.online { color: var(--green); border-color: var(--green); }
.conn-pill.offline { color: var(--red); border-color: var(--red); }
.queue-badge { background: var(--yellow); color: #241a12; border-radius: 999px; min-width: 22px; height: 22px; padding: 0 .35rem; font-size: .72rem; display: inline-flex; align-items: center; justify-content: center; }

/* License banner */
.license-banner { padding: .45rem .75rem; font-size: .85rem; font-weight: 600; text-align: center; }
.license-banner.trial { background: #3b2f10; color: #fcd34d; }
.license-banner.grace { background: #422006; color: #fdba74; }
.license-banner.locked { background: #450a0a; color: #fca5a5; }

/* ═══════ LAYOUT ═══════ */
#appMain { padding: .6rem .75rem calc(76px + env(safe-area-inset-bottom)); }
.screen { display: none; animation: fadeIn .18s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none;} }
.screen-head { display: flex; justify-content: space-between; align-items: flex-end; gap: .75rem; margin: .25rem 0 .6rem; flex-wrap: wrap; }
.screen-head h1 { margin: 0; font-size: 1.4rem; }
.screen-head p { margin: .15rem 0 0; color: var(--muted); font-size: .85rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ═══════ BUTTONS ═══════ */
.btn {
  border: none; border-radius: 14px; cursor: pointer;
  min-height: 52px; padding: 0 1.1rem; font-size: 1rem; font-weight: 700;
  background: var(--panel-2); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.97); }
.btn small { font-weight: 600; opacity: .85; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-secondary { background: var(--panel-2); border: 1px solid var(--line); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
.btn-warn { background: #7f1d1d; color: #fecaca; }
.btn-danger { background: var(--red); color: #fff; }
.btn-xl { min-height: 60px; font-size: 1.05rem; }
.btn-lg { min-height: 56px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.input-lg, .field input, .field select, textarea, .date-input {
  width: 100%; min-height: 52px; font-size: 1.05rem; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: .55rem .75rem;
}
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .6rem; }
.field span { font-size: .85rem; color: var(--muted); font-weight: 600; }
.field.inline { flex-direction: row; align-items: center; gap: .5rem; }
.form-error { color: var(--red); font-size: .9rem; text-align: center; margin: .4rem 0 0; }
.input-ribuan { font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.input-xl { font-size: 1.6rem; min-height: 64px; text-align: right; font-weight: 700; }
.input-inline { width: 8em !important; text-align: right; margin: 0; min-height: 44px; padding: .3rem .5rem; }
.date-input { max-width: 9.5em; display: inline-block; min-height: 44px; }

/* ═══════ LOGIN ═══════ */
#screen-login { min-height: calc(100vh - 200px); display: none; align-items: center; justify-content: center; }
#screen-login.active { display: flex; }
.login-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; text-align: center; }
.login-logo { font-size: 3.2rem; }
.login-card h1 { margin: .25rem 0 0; letter-spacing: .08em; }
.login-card h1 span { color: var(--accent); }
.login-sub { color: var(--muted); margin-top: .2rem; }
.login-hint { color: var(--muted); font-size: .75rem; margin-top: .75rem; }

/* ═══════ POS LAYOUT ═══════ */
#screen-pos.active {
  display: grid; grid-template-columns: 1fr 400px; gap: .75rem;
  align-items: start;
}
.pos-toolbar { display: flex; gap: .5rem; margin-bottom: .5rem; }
#productSearch { flex: 1; min-height: 54px; font-size: 1.05rem; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 0 .9rem; }
.shift-pill { display: flex; align-items: center; padding: 0 .8rem; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); font-size: .8rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.shift-pill.open { color: var(--green); border-color: var(--green); }

.category-chips { display: flex; gap: .45rem; overflow-x: auto; padding-bottom: .35rem; scrollbar-width: thin; }
.chip {
  flex: 0 0 auto; min-height: 46px; padding: 0 1rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  font-weight: 700; cursor: pointer;
}
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-strong); }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: .6rem; margin-top: .5rem; }
.product-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .6rem .55rem .65rem; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: .3rem;
  min-height: 132px; transition: transform .08s ease, border-color .15s;
}
.product-card:active { transform: scale(.97); }
.product-card:hover { border-color: var(--accent); }
.product-card .pname { font-weight: 700; font-size: .92rem; line-height: 1.25; min-height: 2.4em; }
.product-card .pprice { font-variant-numeric: tabular-nums; font-size: 1.05rem; font-weight: 800; color: var(--accent-strong); margin-top: auto; }
[data-theme="dark"] .product-card .pprice { color: var(--accent-strong); }
.product-card .pcat { font-size: .68rem; color: var(--muted); }
.product-card.soldout { opacity: .45; filter: grayscale(1); pointer-events: auto; }
.product-card.soldout::after { content: "HABIS"; align-self: flex-start; background: var(--red); color: #fff; font-size: .68rem; border-radius: 6px; padding: .1rem .4rem; }

/* Cart panel */
.pos-cart {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .65rem; display: flex; flex-direction: column; gap: .5rem;
  position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto;
}
.cart-head { display: flex; justify-content: space-between; align-items: center; }
.cart-head h2 { margin: 0; font-size: 1.2rem; }
.cart-count { color: var(--muted); font-size: .85rem; font-weight: 700; }
.order-meta { display: flex; flex-direction: column; gap: .4rem; }
.order-type-toggle { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
.ot-btn { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-weight: 700; cursor: pointer; }
.ot-btn.active { background: var(--blue); border-color: var(--blue); color: #06202e; }

.cart-items { display: flex; flex-direction: column; gap: .4rem; min-height: 120px; }
.cart-empty { text-align: center; color: var(--muted); padding: 1.2rem .5rem; border: 1.5px dashed var(--line); border-radius: 12px; }
.cart-item {
  display: grid; grid-template-columns: 1fr auto; gap: .15rem .5rem;
  background: var(--panel-2); border-radius: 12px; padding: .45rem .55rem;
}
.cart-item .ci-name { font-weight: 700; font-size: .92rem; }
.cart-item .ci-mod { font-size: .75rem; color: var(--muted); }
.cart-item .ci-price { font-variant-numeric: tabular-nums; font-weight: 700; font-size: .85rem; align-self: center; }
.qty-stepper { display: inline-flex; align-items: center; gap: .35rem; margin-top: .25rem; }
.qty-stepper button { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 1.1rem; cursor: pointer; }
.qty-stepper output { min-width: 2ch; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.ci-remove { justify-self: end; background: none; border: none; color: var(--red); font-size: .8rem; font-weight: 700; cursor: pointer; padding: .2rem; }

.cart-totals { border-top: 1px solid var(--line); padding-top: .45rem; display: flex; flex-direction: column; gap: .2rem; }
.cart-totals .row { display: flex; justify-content: space-between; align-items: center; font-size: .95rem; color: var(--muted); }
.cart-totals .row.total { font-size: 1.35rem; color: var(--text); font-weight: 900; font-variant-numeric: tabular-nums; border-top: 1px dashed var(--line); padding-top: .3rem; }
.cart-totals span:last-child { font-variant-numeric: tabular-nums; }

.cart-actions { display: grid; grid-template-columns: 96px 1fr 1.2fr; gap: .45rem; }
.btn-pay { background: var(--green); color: #062b12; flex-direction: column; line-height: 1.15; gap: 0; }
.btn-pay small { font-size: .95rem; }

.floating-cart { display: none; }

/* ═══════ MEJA / FLOOR PLAN ═══════ */
.floor-plan { display: flex; flex-direction: column; gap: .8rem; }
.area-title { font-size: .8rem; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; font-weight: 800; margin: .25rem 0; }
.table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: .6rem; }
.table-cell {
  border-radius: var(--radius); border: 2px solid transparent; min-height: 88px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
  cursor: pointer; font-weight: 900; font-size: 1.3rem; color: #0b1f10; background: var(--green);
}
.table-cell small { font-size: .62rem; font-weight: 800; color: inherit; opacity: .85; }
.table-cell[data-status="terisi"] { background: var(--red); color: #2b0703; }
.table-cell[data-status="menunggu"] { background: var(--yellow); color: #332600; }
.table-cell.selected { outline: 4px solid var(--accent); }
.table-cell .bill-badge { font-size: .68rem; background: rgba(0,0,0,.28); color: #fff; border-radius: 6px; padding: .1rem .4rem; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.table-action { margin-top: .6rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; }
.table-action h3 { margin-top: 0; }
.table-action .ta-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }

/* ═══════ LAPORAN ═══════ */
.summary-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; margin-bottom: .6rem; }
.sum-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .7rem; }
.sum-card small { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.sum-card strong { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; margin-top: .15rem; }
.sum-card .sub { color: var(--muted); font-size: .75rem; margin-top: .15rem; font-variant-numeric: tabular-nums; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; margin-bottom: .6rem; }
.panel h2 { margin: 0 0 .5rem; font-size: 1.05rem; }
.panel h2 small { color: var(--muted); font-weight: 400; font-size: .75rem; }
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.data-table th { text-align: left; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; padding: .35rem .3rem; border-bottom: 2px solid var(--line); }
.data-table td { padding: .4rem .3rem; border-bottom: 1px solid var(--line); }
.data-table td:last-child, .data-table th:last-child { text-align: right; }
.data-table tr:last-child td { border-bottom: none; }
.low { color: var(--red); font-weight: 800; }
.ledger-box { display: flex; gap: .75rem; flex-wrap: wrap; }
.ledger-box .lb { background: var(--panel-2); border-radius: 12px; padding: .5rem .8rem; min-width: 130px; }
.ledger-box .lb small { color: var(--muted); font-size: .7rem; display: block; }
.ledger-box .lb strong { font-variant-numeric: tabular-nums; font-size: 1.1rem; }

/* ═══════ PENGATURAN ═══════ */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: .6rem; align-items: start; }
.segmented { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .6rem; }
.segmented label { display: inline-flex; align-items: center; gap: .35rem; min-height: 46px; padding: 0 .7rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: .9rem; }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; min-height: 52px; padding: .3rem .2rem; border-bottom: 1px solid var(--line); cursor: pointer; }
.switch-row:last-child { border-bottom: none; }
.switch-row input[type="checkbox"] { width: 28px; height: 28px; accent-color: var(--accent); }
.qris-preview { width: 180px; border-radius: 12px; background: #fff; padding: .4rem; margin-top: .5rem; }
.license-box { background: var(--panel-2); border-left: 4px solid var(--accent); border-radius: 10px; padding: .55rem .7rem; margin-bottom: .5rem; font-size: .9rem; font-variant-numeric: tabular-nums; }
.license-box.ok { border-color: var(--green); }
.license-box.locked { border-color: var(--red); color: #fecaca; }
.license-box.trial, .license-box.grace { border-color: var(--yellow); }

/* ═══════ BOTTOM NAV ═══════ */
#bottomNav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--bg-soft); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn { min-height: 64px; background: none; border: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; font-size: .7rem; font-weight: 700; cursor: pointer; }
.nav-btn svg { width: 24px; height: 24px; }
.nav-btn.active { color: var(--accent); }
.nav-btn.active span { text-decoration: underline; text-underline-offset: 3px; }

/* ═══════ MODAL ═══════ */
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.62);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  width: min(460px, 100%); max-height: 92vh; overflow: auto; padding: 1rem;
  box-shadow: var(--shadow); animation: popIn .16s ease;
}
.modal-card.wide { width: min(520px, 100%); }
@keyframes popIn { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-card h2 { margin-top: 0; }
.modal-foot { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .75rem; }
.modal-row { display: flex; justify-content: space-between; gap: .5rem; margin-top: .5rem; }

.mod-group { border: 1px solid var(--line); border-radius: 12px; padding: .5rem .6rem; margin-bottom: .5rem; }
.mod-group legend, .mod-group .mg-title { font-weight: 800; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .3rem; }
.mod-options { display: flex; gap: .4rem; flex-wrap: wrap; }
.mod-chip { min-height: 44px; padding: 0 .8rem; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-weight: 600; cursor: pointer; }
.mod-chip.selected { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-strong); }
.mod-chip small { display: block; font-size: .65rem; opacity: .8; }

.pay-total { text-align: center; background: var(--panel-2); border-radius: 12px; padding: .5rem; margin-bottom: .6rem; }
.pay-total small { display: block; color: var(--muted); }
.pay-total strong { font-size: 2rem; font-variant-numeric: tabular-nums; }
.pay-tabs { margin-bottom: .6rem; }
.pay-tab { flex: 1; min-height: 52px; font-size: 1rem; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 12px; cursor: pointer; font-weight: 800; }
.pay-tab.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-strong); }
.quick-cash { display: flex; gap: .4rem; flex-wrap: wrap; margin: .5rem 0; }
.quick-cash button { min-height: 46px; padding: 0 .75rem; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-weight: 700; cursor: pointer; font-variant-numeric: tabular-nums; }
.change-box { display: flex; justify-content: space-between; align-items: center; background: var(--panel-2); border: 1px dashed var(--line); border-radius: 12px; padding: .5rem .75rem; font-size: 1.1rem; }
.change-box strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.qris-box { display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: .5rem; background: #fff; border-radius: 12px; }
.qris-box .muted { color: #6b7280; text-align: center; }
.qris-image { width: 240px; }

.post-save-invoice { text-align: center; color: var(--muted); }
.success-icon { width: 72px; height: 72px; border-radius: 50%; background: var(--green); color: #062b12; font-size: 2.4rem; display: flex; align-items: center; justify-content: center; margin: 0 auto .5rem; font-weight: 900; }
.post-save-actions { display: flex; flex-direction: column; gap: .5rem; }

.receipt-preview {
  background: #fffdf5; color: #111; font-family: "Consolas","Courier New",monospace;
  font-size: .8rem; line-height: 1.35; padding: .75rem; border-radius: 8px;
  overflow-x: auto; white-space: pre; border: 1px solid #ddd0c0; max-height: 55vh;
}

/* ═══════ TOAST ═══════ */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom) + .5rem);
  z-index: 60; background: var(--panel-2); border: 1px solid var(--accent); color: var(--text);
  border-radius: 12px; padding: .6rem 1rem; font-size: .9rem; max-width: min(90vw, 420px);
  box-shadow: var(--shadow);
}
.toast.error { border-color: var(--red); color: #fecaca; }

/* ═══════ PRINT (window.print fallback) ═══════ */
.print-area { display: none; }
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { display: block; position: absolute; left: 0; top: 0; width: 58mm; font-family: monospace; font-size: 9pt; white-space: pre; color: #000; }
}

/* =========================================================
   RESPONSIVE — HP / TABLET, PORTRAIT & LANDSCAPE
   Sistem membaca orientasi + lebar secara otomatis:
   - HP portrait  (<=620px, portrait) : 1 kolom, keranjang bottom-sheet + tombol mengambang
   - HP landscape (<=940px, landscape, tinggi <=540px): 2 kolom padat vertikal
   - Tablet portrait (621-1099px)     : 2 kolom penuh (menu kiri, keranjang kanan)
   - Besar (>=1100px)                 : grid lebar + keranjang 400px
   ========================================================= */

/* ---------- Tablet portrait & sedang (621-1099px): dua kolom penuh ---------- */
@media (min-width: 621px) and (max-width: 1099px) {
  #appMain { padding: .5rem .6rem calc(70px + env(safe-area-inset-bottom)); }
  #screen-pos.active { grid-template-columns: 1fr 330px; gap: .5rem; }
  .pos-cart { position: sticky; top: 64px; max-height: calc(100vh - 84px); }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
  .cart-actions { grid-template-columns: 84px 1fr 1.15fr; }
  .panel-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
  .icon-btn { width: 42px; height: 42px; }
  .data-table { font-size: .82rem; }
}

/* ---------- HP LANDSCAPE (tinggi kecil): dua kolom, sangat padat ---------- */
@media (max-width: 940px) and (orientation: landscape) and (max-height: 540px) {
  body { font-size: 12px; }
  #topbar { padding: .15rem .45rem; gap: .3rem; }
  .logo { width: 20px !important; height: 20px !important; }
  .brand-text small { display: none; }
  .brand-text strong { font-size: .7rem; }
  .icon-btn { width: 32px; height: 32px; border-radius: 8px; }
  .icon-btn svg { width: 17px; height: 17px; }
  .conn-pill { height: 26px; padding: 0 .4rem; font-size: .68rem; }
  .conn-dot { width: 9px; height: 9px; }
  .conn-pill #connText { display: none; }
  #appMain { padding: .25rem .35rem calc(46px + env(safe-area-inset-bottom)); }
  #bottomNav .nav-btn { min-height: 40px; font-size: .52rem; flex-direction: row; gap: .25rem; }
  .nav-btn svg { width: 15px; height: 15px; }
  .screen-head { margin: .1rem 0 .3rem; }
  .screen-head h1 { font-size: .85rem; }
  .screen-head p { display: none; }
  .btn { min-height: 36px; font-size: .72rem; border-radius: 9px; padding: 0 .6rem; }
  .btn-xl { min-height: 40px; font-size: .78rem; }
  .panel-grid { grid-template-columns: 1fr 1fr; gap: .4rem; }
  .panel { padding: .45rem; margin-bottom: .35rem; border-radius: 10px; }
  .panel h2 { font-size: .8rem; }
  /* POS landscape */
  #screen-pos.active { grid-template-columns: 1fr 290px; gap: .35rem; }
  .pos-cart { position: sticky; top: 46px; max-height: calc(100vh - 58px); width: 100%;
              overflow: hidden; display: flex; flex-direction: column; }
  .cart-items { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  .cart-totals { border-top: 1px solid var(--line); padding-top: .3rem; }
  #productSearch { min-height: 34px; font-size: .78rem; border-radius: 9px; }
  .shift-pill { font-size: .58rem; }
  .category-chips { gap: .2rem; }
  .chip { min-height: 28px; font-size: .65rem; padding: 0 .5rem; }
  .product-grid { grid-template-columns: repeat(4, 1fr); gap: .25rem; }
  .product-card { min-height: 64px; padding: .25rem .3rem; gap: 0; border-radius: 8px; }
  .product-card .pname { font-size: .62rem; min-height: 1.6em; line-height: 1.15; }
  .product-card .pprice { font-size: .72rem; }
  .product-card .pcat { display: none; }
  .order-meta { gap: .2rem; }
  .input-lg, .field input, .field select, textarea { min-height: 34px; font-size: .76rem; border-radius: 9px; }
  .ot-btn { min-height: 32px; font-size: .68rem; }
  .cart-item { padding: .25rem .35rem; }
  .cart-item .ci-name { font-size: .7rem; }
  .cart-item .ci-mod { font-size: .58rem; }
  .qty-stepper button { width: 26px; height: 26px; font-size: .9rem; }
  .cart-totals .row { font-size: .7rem; }
  .cart-totals .row.total { font-size: .9rem; }
  .cart-actions { grid-template-columns: 70px 1fr 1.15fr; gap: .25rem; }
  .input-xl { font-size: 1.05rem; min-height: 40px; }
  /* LAPORAN landscape */
  .summary-cards { grid-template-columns: repeat(4, 1fr); gap: .3rem; }
  .sum-card { padding: .35rem .45rem; border-radius: 10px; }
  .sum-card strong { font-size: .82rem; }
  .sum-card small { font-size: .5rem; }
  .sum-card .sub { display: none; }
  .data-table { font-size: .66rem; }
  /* MEJA landscape */
  .table-grid { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: .3rem; }
  .table-cell { min-height: 48px; font-size: .8rem; border-radius: 9px; }
  .table-cell small { font-size: .48rem; }
  /* PENGATURAN landscape */
  .settings-grid { grid-template-columns: repeat(2, 1fr); gap: .35rem; }
}

/* ---------- HP PORTRAIT (<=620px): 1 kolom + keranjang bottom-sheet ---------- */
@media (max-width: 620px) and (orientation: portrait) {
  body { font-size: 14px; }
  #topbar { padding: .3rem .5rem; gap: .35rem; }
  .brand-text strong { font-size: .82rem; letter-spacing: .04em; }
  .brand-text small { display: none; }
  .logo { width: 26px !important; height: 26px !important; }
  .icon-btn { width: 40px; height: 40px; border-radius: 10px; }
  .conn-pill { height: 32px; padding: 0 .5rem; }
  .conn-dot { width: 11px; height: 11px; }
  .conn-pill #connText { display: none; }
  #appMain { padding: .35rem .45rem calc(60px + env(safe-area-inset-bottom)); }
  #bottomNav .nav-btn { min-height: 54px; font-size: .62rem; }
  .nav-btn svg { width: 20px; height: 20px; }
  .screen-head { margin: .15rem 0 .45rem; }
  .screen-head h1 { font-size: 1.05rem; }
  .screen-head p { font-size: .68rem; }
  .btn { min-height: 46px; font-size: .88rem; border-radius: 12px; padding: 0 .8rem; }
  .btn-xl { min-height: 52px; font-size: .95rem; }
  /* POS */
  #screen-pos.active { grid-template-columns: 1fr; }
  .pos-cart {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    border-radius: 18px 18px 0 0; height: 88vh; top: auto;
    transform: translateY(110%); transition: transform .22s ease; box-shadow: 0 -10px 40px rgba(0,0,0,.5);
    overflow: hidden; display: flex; flex-direction: column;
  }
  .pos-cart.open { transform: translateY(0); }
  .cart-items { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  .cart-totals, .cart-actions { flex: 0 0 auto; background: var(--panel); border-top: 1px solid var(--line); padding-top: .45rem; }
  .floating-cart {
    display: block; position: fixed; right: .8rem; bottom: calc(60px + env(safe-area-inset-bottom) + .6rem); z-index: 44;
    min-height: 54px; padding: 0 1rem; border-radius: 999px; border: none;
    background: var(--accent); color: var(--accent-ink); font-weight: 800; box-shadow: var(--shadow); cursor: pointer;
  }
  #productSearch { min-height: 46px; font-size: .9rem; }
  .shift-pill { font-size: .65rem; padding: 0 .55rem; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; }
  .category-chips { gap: .3rem; }
  .chip { min-height: 38px; padding: 0 .7rem; font-size: .78rem; }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: .4rem; }
  .product-card { min-height: 104px; padding: .45rem .45rem .5rem; gap: .15rem; border-radius: 12px; }
  .product-card .pname { font-size: .8rem; min-height: 2.2em; }
  .product-card .pprice { font-size: .95rem; }
  .product-card .pcat { font-size: .6rem; }
  .order-meta { gap: .3rem; }
  .input-lg, .field input, .field select, textarea { min-height: 44px; font-size: .9rem; }
  .ot-btn { min-height: 42px; font-size: .82rem; }
  .cart-items .cart-item { padding: .35rem .45rem; }
  .cart-item .ci-name { font-size: .82rem; }
  .cart-item .ci-mod { font-size: .68rem; }
  .qty-stepper button { width: 30px; height: 30px; }
  .cart-totals .row { font-size: .82rem; }
  .cart-totals .row.total { font-size: 1.1rem; }
  .cart-actions { grid-template-columns: 82px 1fr 1.2fr; gap: .35rem; }
  .input-xl { font-size: 1.25rem; min-height: 52px; }
  /* MEJA */
  .table-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: .4rem; }
  .table-cell { min-height: 64px; font-size: 1.05rem; border-radius: 12px; }
  .table-cell small { font-size: .52rem; }
  /* LAPORAN */
  .summary-cards { grid-template-columns: repeat(2, 1fr); gap: .4rem; }
  .sum-card { padding: .45rem .55rem; border-radius: 12px; }
  .sum-card strong { font-size: 1.02rem; }
  .sum-card small { font-size: .58rem; }
  .sum-card .sub { font-size: .62rem; }
  .data-table { font-size: .76rem; }
  .panel { padding: .55rem; margin-bottom: .45rem; border-radius: 12px; }
  .panel h2 { font-size: .88rem; }
  .panel-grid { grid-template-columns: 1fr; }
  /* PENGATURAN — panel bisa dilipat (accordion) */
  .settings-grid { grid-template-columns: 1fr; gap: .45rem; }
  .settings-grid .panel h2 { cursor: pointer; user-select: none; display: flex; align-items: center; justify-content: space-between; font-size: .9rem; margin-bottom: .3rem; }
  .settings-grid .panel h2::after { content: 'v'; color: var(--accent); font-size: 1rem; transition: transform .15s; }
  .settings-grid .panel.closed h2::after { transform: rotate(-90deg); }
  .settings-grid .panel.closed > *:not(h2) { display: none !important; }
  .segmented label { min-height: 40px; font-size: .8rem; padding: 0 .55rem; }
  .switch-row { min-height: 44px; }
}

/* ---------- Layar besar tetap leluasa ---------- */
@media (min-width: 1400px) { .product-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }


/* ═══════════════════════════════════════════════════════════
   POS REDESIGN — kategori, kartu menu, tampilan daftar,
   dan panel keranjang yang lebih rapi (menggantikan hotfix lama)
   ═══════════════════════════════════════════════════════════ */
#screen-pos .pos-cart { overflow-x: hidden; }

/* --- toolbar: cari + pilihan tampilan + shift --- */
#screen-pos .pos-toolbar { flex-wrap: wrap; align-items: center; gap: .45rem; }
#screen-pos #productSearch { flex: 1 1 240px; }
#screen-pos .view-toggle {
  display: inline-flex; gap: 3px; padding: 3px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 13px;
}
#screen-pos .view-btn {
  width: 44px; height: 44px; border: 0; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--muted); font-size: 1.15rem; line-height: 1;
  transition: background .15s, color .15s;
}
#screen-pos .view-btn:hover { color: var(--text); }
#screen-pos .view-btn.active { background: var(--accent); color: var(--accent-ink); }

/* --- kategori: bungkus ke bawah, tidak terpotong --- */
#screen-pos .category-chips { flex-wrap: wrap; overflow: visible; gap: .4rem; padding-bottom: 0; }
#screen-pos .chip {
  min-height: 38px; padding: 0 .85rem; font-size: .82rem; border-radius: 999px;
  transition: background .15s, border-color .15s, transform .08s;
}
#screen-pos .chip:active { transform: scale(.97); }

/* --- grid kartu --- */
#productGrid {
  grid-template-columns: repeat(auto-fill, minmax(min(150px, 42%), 1fr));
  gap: .55rem; margin-top: .65rem;
}
.product-card {
  border-radius: 15px; padding: .7rem .75rem .75rem; min-height: 116px; gap: .3rem;
  position: relative; overflow: hidden;
  transition: transform .1s ease, border-color .15s, box-shadow .15s;
}
.product-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.16); }
.product-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); opacity: 0; transition: opacity .15s;
}
.product-card:hover::before { opacity: 1; }
.product-card .pcat {
  font-size: .6rem; letter-spacing: .07em; text-transform: uppercase; opacity: .7;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.product-card .pname {
  font-size: .9rem; line-height: 1.3; min-height: 2.6em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.product-card .pprice { font-size: 1.02rem; letter-spacing: .01em; }

/* --- tampilan daftar (list) --- */
#productGrid.list-view { display: flex; flex-direction: column; gap: .35rem; }
.product-row {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  width: 100%; text-align: left; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: .5rem .8rem; transition: border-color .15s, background .15s;
}
.product-row:hover { border-color: var(--accent); background: var(--panel-2); }
.product-row .pr-name { display: block; font-weight: 700; font-size: .9rem; line-height: 1.3; }
.product-row .pr-cat { display: block; font-size: .66rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.product-row .pr-price { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1rem; color: var(--accent-strong); white-space: nowrap; }
.product-row.soldout { opacity: .45; filter: grayscale(1); }

/* --- keranjang: kepala + tombol --- */
#screen-pos .cart-head { gap: .5rem; }
#screen-pos .cart-title { display: flex; align-items: baseline; gap: .5rem; min-width: 0; }
#screen-pos .cart-clear {
  flex: none; width: 40px; height: 40px; border-radius: 11px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--red); font-size: 1rem;
  transition: background .15s, border-color .15s;
}
#screen-pos .cart-clear:hover { background: var(--panel-2); border-color: var(--red); }

#screen-pos .cart-actions { grid-template-columns: 1fr 1.35fr; gap: .5rem; }
#screen-pos .cart-actions .btn {
  min-height: 58px; border-radius: 14px; padding: .35rem .6rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; line-height: 1.2; font-size: .8rem; letter-spacing: .02em;
}
#screen-pos .cart-actions .btn small { font-size: .66rem; font-weight: 600; opacity: .75; }
#screen-pos .btn-pay { font-size: .95rem; box-shadow: 0 6px 18px rgba(34,197,94,.25); }
#screen-pos .btn-pay small { font-size: 1.05rem; font-weight: 900; opacity: 1; }

@media (max-width: 620px) and (orientation: portrait) {
  #screen-pos .view-btn { width: 40px; height: 40px; }
  #screen-pos .cart-actions .btn { min-height: 54px; }
  #screen-pos .cart-actions .btn small { display: none; }
  #screen-pos .cart-actions .btn-pay small { display: block; }
  /* toolbar rapat: pencarian + tombol tampilan + shift dalam satu baris bila muat */
  #screen-pos #productSearch { flex: 1 1 130px; min-height: 44px; font-size: .86rem; }
  #screen-pos .shift-pill { font-size: .6rem; padding: 0 .55rem; max-width: 36vw; }
  /* beri ruang agar baris terakhir tidak tertutup tombol keranjang mengambang */
  #screen-pos .pos-menu { padding-bottom: 4.5rem; }
}
