:root {
  --bg: #F6F2E7;
  --surface: #FFFFFF;
  --surface-muted: #EEE8D9;
  --border: #E1D8C4;
  --text: #262420;
  --text-muted: #78715F;
  --text-faint: #A69D87;
  --accent: #262420;
  --accent-light: #3D3A33;
  --accent-lighter: #262420;
  --accent-soft: rgba(38,36,32,0.06);
  --accent-soft-border: rgba(38,36,32,0.14);
  --danger: #B3453D;
  --danger-strong: #96332C;
  --danger-soft: rgba(179,69,61,0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: 64px;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
svg { display: block; }
p { margin: 0; }

button, input, select {
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
}

label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 6px; }

button {
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .12s ease, border-color .12s ease, transform .06s ease, color .12s ease;
}
button:active { transform: scale(0.98); }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 1px;
}
button:hover { border-color: #C9BFA6; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 8px 20px rgba(38,36,32,0.18);
}
button.primary:hover { background: var(--accent-light); border-color: var(--accent-light); }
button.primary:disabled {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text-faint);
  cursor: not-allowed;
  box-shadow: none;
}
button.ghost { background: transparent; border-color: var(--border); color: var(--text-muted); font-weight: 600; }
button.ghost:hover { color: var(--text); }
button.danger-fill { background: var(--danger-strong); border-color: var(--danger-strong); color: #fff; }
button.danger-fill:hover { background: #A83E35; border-color: #A83E35; }

button.chip {
  border-radius: 999px; padding: 0 16px; min-height: 38px; font-weight: 600; font-size: 13px;
  background: var(--surface); color: var(--text-muted); white-space: nowrap;
}
button.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(38,36,32,0.18); }

.icon-btn-sm {
  width: 34px; height: 34px; min-height: 34px; padding: 0; border-radius: 10px;
  background: var(--surface-muted); color: var(--text-muted);
}
.icon-btn-sm svg { width: 16px; height: 16px; }
.icon-btn-sm:hover { background: var(--accent-soft); color: var(--accent-lighter); border-color: var(--accent-soft-border); }
.icon-btn-sm.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: rgba(179,69,61,0.3); }

.qty-btn { width: 26px; height: 26px; min-height: 26px; padding: 0; border-radius: 8px; background: var(--bg); font-size: 13px; }

input[type="text"], input[type="number"], input[type="date"], input[type="password"] {
  width: 100%; min-height: 46px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); -webkit-appearance: none; appearance: none;
}
input::placeholder { color: var(--text-faint); }
input[type="date"] { color-scheme: light; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 2px rgba(38,36,32,0.03), 0 8px 20px rgba(38,36,32,0.04); }
.stat-card .label { font-size: 11px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.stat-card .value { font-size: 23px; font-weight: 800; color: var(--text); }
.stat-card.accent .value { color: var(--accent-lighter); }

.rank-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(38,36,32,0.06); }
.rank-row:last-child { border-bottom: none; }
.rank-num {
  width: 24px; height: 24px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-lighter);
  display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 800; flex-shrink: 0;
}
.rank-row .nama { flex: 1; min-width: 0; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .qty { font-size: 12px; color: var(--text-muted); }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 12px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 3px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 8px 10px 24px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; overflow: hidden;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; box-shadow: 0 8px 18px rgba(38,36,32,0.22);
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-name { color: var(--text); font-weight: 800; font-size: 15px; }
.brand-sub { color: var(--text-muted); font-size: 11px; margin-top: 1px; }

.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 11px 13px; border-radius: 12px;
  color: var(--text-muted); text-decoration: none; font-size: 14px; font-weight: 600;
}
.nav-link svg { width: 18px; height: 18px; }
.nav-link:hover { background: var(--surface-muted); color: var(--text); }
.nav-link.active { background: var(--accent); color: #fff; box-shadow: 0 8px 18px rgba(38,36,32,0.2); }

.status-card {
  margin-top: auto; padding: 12px; border-radius: 14px;
  background: var(--surface-muted); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse-dot 2s ease-in-out infinite; flex-shrink: 0; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.main-area { flex: 1; min-width: 0; }

.page-header {
  padding: 16px 26px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,0.82);
  backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  position: sticky; top: 0; z-index: 5;
}
.page-header h1 { font-size: 17px; color: var(--text); }
.page-header .subtitle { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.clock-text { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; font-weight: 600; }

.page-content { padding: 22px 26px; max-width: 1140px; margin: 0 auto; }

.badge {
  display: inline-flex; align-items: center; font-size: 12px; font-weight: 700;
  padding: 5px 11px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-lighter);
  border: 1px solid var(--accent-soft-border);
}

/* Mobile bottom nav */
.bottom-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.92); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  justify-content: space-around; padding: 8px 0; z-index: 9;
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 1;
  color: var(--text-faint); text-decoration: none; font-size: 10.5px; font-weight: 700;
  padding: 4px 2px; border-radius: 10px;
}
.bottom-nav a svg { width: 20px; height: 20px; }
.bottom-nav a.active { color: var(--accent); }

@media (max-width: 859px) {
  .sidebar { display: none; }
  .bottom-nav { display: flex; }
  .page-content { padding: 14px; }
  .page-header { padding: 12px 14px; }
}

/* ---------- Cards & tables ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
  box-shadow: 0 1px 2px rgba(38,36,32,0.03), 0 8px 20px rgba(38,36,32,0.05);
}
.card-title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.card-title-row .icon-box {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent-lighter);
  display: flex; align-items: center; justify-content: center;
}
.card-title-row .icon-box svg { width: 16px; height: 16px; }
.card-title-row h3 { font-size: 15px; }
.card-sub { font-size: 12px; color: var(--text-muted); margin: 8px 0 16px; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 480px; }
.data-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-faint); padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 14px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(38,36,32,0.02); }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td.actions { text-align: right; white-space: nowrap; }
.cat-badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-lighter); font-size: 11.5px; font-weight: 700;
  border: 1px solid var(--accent-soft-border);
}

/* ---------- Kasir page ---------- */
.layout { display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 860px) {
  .layout { flex-direction: row; align-items: flex-start; }
  .layout .col-produk { flex: 1.6; min-width: 0; }
  .layout .col-cart { flex: 1; min-width: 330px; position: sticky; top: 78px; }
}
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 168px)); justify-content: start; gap: 12px; }
.product-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 8px;
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.product-card:hover { border-color: var(--accent-soft-border); transform: translateY(-2px); box-shadow: 0 10px 22px rgba(38,36,32,0.08); }
.product-tile { width: 100%; aspect-ratio: 1.6; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 19px; }
.product-card .nama { font-weight: 700; font-size: 13.5px; color: var(--text); }
.product-card .harga { color: var(--accent-lighter); font-weight: 700; font-size: 13px; }
.product-card .stok { color: var(--text-faint); font-size: 11px; }

.cart-item { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 8px 0; border-bottom: 1px solid rgba(38,36,32,0.06); }
.cart-item:last-child { border-bottom: none; }
.cart-item .nama { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.cart-item .qty { min-width: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.cart-item .subtotal { min-width: 76px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.receipt-total {
  border-top: 2px dashed var(--border); margin-top: 6px; padding-top: 12px;
  display: flex; justify-content: space-between; align-items: baseline;
}
.receipt-total .label { color: var(--text-muted); font-size: 13px; }
.receipt-total .value { font-size: 21px; font-weight: 800; color: var(--accent-lighter); }

.quick-cash-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.quick-cash-btn {
  min-height: 34px; padding: 0 4px; font-size: 11px; font-weight: 700;
  background: var(--surface-muted); color: var(--text-muted);
}
.quick-cash-btn:hover { color: var(--text); }

.summary-bar {
  position: fixed; left: 14px; right: 14px; bottom: 74px;
  background: rgba(255,255,255,0.96); backdrop-filter: blur(10px);
  border: 1px solid var(--border); border-radius: 16px;
  padding: 10px 14px; display: none; align-items: center; justify-content: space-between; z-index: 8;
  box-shadow: 0 12px 30px rgba(38,36,32,0.14);
}
@media (max-width: 859px) { .summary-bar.visible { display: flex; } }

.mobile-cart-spacer { display: none; }
@media (max-width: 859px) { .mobile-cart-spacer { display: block; height: 150px; } }

/* ---------- Struk cetak ---------- */
#receiptPrint { display: none; }
@media print {
  body * { visibility: hidden; }
  #receiptPrint, #receiptPrint * { visibility: visible; }
  #receiptPrint {
    display: block !important;
    position: absolute; top: 0; left: 0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 11px; line-height: 1.45; color: #000; padding: 3mm;
  }
  .receipt-center { text-align: center; }
  .receipt-bold { font-weight: 700; }
  .receipt-line { border-top: 1px dashed #000; margin: 5px 0; }
  .receipt-row { display: flex; justify-content: space-between; gap: 8px; }
  .receipt-item-name { display: block; }
}

.error-text { color: var(--danger); font-size: 13px; margin: 0; }
.muted { color: var(--text-muted); font-size: 13px; }
.disabled-note {
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-muted);
  padding: 10px 12px; color: var(--text-muted); font-size: 12px; display: flex; gap: 8px; align-items: flex-start;
}
.disabled-note svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; color: var(--accent-lighter); }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 520px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }

.settings-grid { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
@media (min-width: 860px) { .settings-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- Settings ---------- */
.tab-row { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; overflow-x: auto; }
.tab-btn {
  background: transparent; border: none; border-bottom: 2px solid transparent; border-radius: 0;
  padding: 10px 4px; margin-right: 24px; font-weight: 600; font-size: 14px; color: var(--text-muted);
  min-height: auto; white-space: nowrap;
}
.tab-btn:hover { color: var(--text); border-color: transparent; }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.setting-row .info .title { font-weight: 700; font-size: 14px; color: var(--text); }
.setting-row .info .desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--surface-muted); border: 1px solid var(--border); border-radius: 999px; transition: .18s ease;
}
.switch .slider:before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 50%; transform: translateY(-50%);
  background: var(--text-muted); border-radius: 50%; transition: .18s ease;
}
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider:before { transform: translate(18px, -50%); background: #fff; }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent-light); outline-offset: 2px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(38,36,32,0.4); backdrop-filter: blur(6px);
  z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px;
  opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
.modal-backdrop.show { opacity: 1; pointer-events: auto; }
.modal-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 24px; max-width: 380px; width: 100%; text-align: center;
  box-shadow: 0 24px 60px rgba(38,36,32,0.25);
}
.modal-icon {
  width: 46px; height: 46px; border-radius: 50%; margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--danger-soft); color: var(--danger);
}
.modal-icon svg { width: 22px; height: 22px; }
