:root {
  --green-900: #0f4714;
  --green-700: #15611b;
  --green-600: #1f7a27;
  --green-100: #e7f4e8;
  --green-50: #f3f9f3;
  --orange-600: #ef6c00;
  --orange-100: #fff2e2;
  --gold-500: #c89d28;
  --teal-600: #0d7a72;
  --amber-600: #b7791f;
  --red-600: #c62828;
  --red-100: #fdeaea;
  --blue-600: #1565c0;
  --blue-100: #e7f0fb;
  --bg: #f3f6f2;
  --surface: #ffffff;
  --border: #dce4da;
  --text: #1c241d;
  --muted: #5f6d61;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 71, 20, 0.06);
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

.app-shell {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 244px;
  background: linear-gradient(180deg, var(--green-900) 0%, #103d14 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.14);
  margin-bottom: 14px;
}

.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold-500);
  background: #fff;
}

.brand-title { font-size: 1.08rem; font-weight: 800; letter-spacing: 0.2px; }
.brand-sub { font-size: 0.76rem; color: #c5e6c7; }

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #e4f2e5;
  font-size: 0.94rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.16s, color 0.16s;
}

.nav-item:hover { background: rgba(255,255,255,0.1); }
.nav-item.active {
  background: linear-gradient(90deg, var(--orange-600), #f57c00);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.nav-ico { width: 22px; text-align: center; }
.nav-pill-open, .nav-pill-pin {
  margin-left: auto;
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 99px;
  font-weight: 700;
}
.nav-pill-open { background: rgba(167, 243, 208, 0.2); color: #a7f3d0; }
.nav-pill-pin { background: rgba(255, 193, 7, 0.25); color: #ffe082; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.14);
  padding: 12px 8px 4px;
}
.sidebar-footer .muted { color: #b7d4b9; }
.sidebar-footer code {
  background: rgba(255,255,255,0.14);
  padding: 1px 6px;
  border-radius: 4px;
  color: #fff;
}

/* Main column & Topbar */
.main-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left { display: flex; align-items: center; gap: 10px; }
.mobile-menu-btn {
  display: none;
  background: var(--green-50);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.2rem;
  padding: 4px 10px;
  cursor: pointer;
}
.topbar-title { font-weight: 700; color: var(--green-700); font-size: 1rem; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.supplier-lock-btn {
  border: 1px solid #d5c18a;
  background: #fff9e6;
  color: #795500;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 99px;
  cursor: pointer;
}
.supplier-lock-btn.unlocked {
  background: var(--green-100);
  border-color: #9dd0a1;
  color: var(--green-900);
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid transparent;
}
.sync-pill .dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.sync-pill.online { background: var(--green-100); color: var(--green-900); border-color: #a9d9ad; }
.sync-pill.online .dot { background: #2e7d32; }
.sync-pill.offline { background: var(--red-100); color: var(--red-600); border-color: #f3b8b8; }
.sync-pill.offline .dot { background: var(--red-600); }
.sync-pill.syncing { background: var(--orange-100); color: #9c4700; border-color: #f6c992; }
.sync-pill.syncing .dot { background: var(--orange-600); animation: pulse 1s infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.app-main {
  padding: 18px 22px;
  width: 100%;
  max-width: none;
  margin: 0;
  flex: 1;
}

/* Common Typography & Cards */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.view-header h2 { margin: 0 0 4px; font-size: 1.42rem; color: var(--green-900); }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 0.82rem; }
.fw-600 { font-weight: 600; }
.text-right { text-align: right; }
.text-danger { color: var(--red-600); }
.text-green { color: var(--green-700); }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.card-head h3 { margin: 0; font-size: 1.06rem; color: var(--green-900); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 15px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s, background 0.15s, border-color 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green-700); color: #fff; }
.btn-primary:hover { background: var(--green-900); }
.btn-secondary { background: var(--orange-600); color: #fff; }
.btn-secondary:hover { background: #d65f00; }
.btn-whatsapp { background: #128c7e; color: #fff; }
.btn-whatsapp:hover { background: #075e54; }
.btn-amber { background: #8a5a00; color: #fff; }
.btn-lock { background: #fff4d6; color: #7a5200; border-color: #e4c574; }
.btn-outline { background: #fff; color: var(--green-900); border-color: var(--border); }
.btn-outline:hover { background: var(--green-50); border-color: var(--green-600); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #eef2ed; color: var(--text); }
.btn-danger-ghost { background: transparent; color: var(--red-600); }
.btn-danger-ghost:hover { background: var(--red-100); }
.btn-sm { padding: 6px 11px; font-size: 0.82rem; border-radius: 7px; }
.btn-xs { padding: 4px 8px; font-size: 0.77rem; border-radius: 6px; }
.link-btn { background: none; border: none; color: var(--green-700); font-weight: 700; cursor: pointer; font-size: 0.82rem; padding: 0; }

.quick-actions-bar { display: flex; flex-wrap: wrap; gap: 8px; }

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--green-700);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow);
}
.kpi-orange { border-left-color: var(--orange-600); }
.kpi-teal { border-left-color: var(--teal-600); }
.kpi-amber { border-left-color: var(--amber-600); }
.kpi-locked { border-left-color: var(--gold-500); background: #fffdf5; cursor: pointer; }
.kpi-label { font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 1.55rem; font-weight: 800; margin: 5px 0 3px; color: var(--text); }
.kpi-unit { font-size: 0.9rem; font-weight: 600; color: var(--muted); }
.kpi-sub { font-size: 0.8rem; color: var(--muted); }

/* Dashboard split */
.dashboard-split {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
}
.dashboard-split > *, .settings-grid > * { min-width: 0; }

.party-mini-list { display: flex; flex-direction: column; gap: 10px; }
.party-mini-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--green-50);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.party-mini-name { font-weight: 700; font-size: 0.92rem; }
.party-mini-meta { font-size: 0.79rem; color: var(--muted); }
.party-mini-right { text-align: right; flex-shrink: 0; }
.bal-val { font-weight: 800; font-size: 0.95rem; margin-bottom: 4px; }
.mini-btns { display: flex; gap: 4px; justify-content: flex-end; }

/* Tables */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th {
  text-align: left;
  padding: 10px 10px;
  background: var(--green-50);
  border-bottom: 2px solid var(--border);
  color: var(--green-900);
  font-weight: 700;
  white-space: nowrap;
}
.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #ecf0eb;
  vertical-align: middle;
}
.data-table tr:hover td { background: #fafcfa; }
.row-void { opacity: 0.55; text-decoration: line-through; }
.actions-cell { white-space: nowrap; display: flex; gap: 5px; align-items: center; }

/* Badges & Chips */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
  background: #edf1ec;
  color: var(--text);
}
.badge-green { background: var(--green-100); color: var(--green-900); }
.badge-amber { background: var(--orange-100); color: #9c4700; }
.badge-blue { background: var(--blue-100); color: var(--blue-600); }
.badge-red { background: var(--red-100); color: var(--red-600); }

.chip-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: #eff4ee;
  border: 1px solid #d7e2d6;
}
.chip-warn { background: #fff3e0; border-color: #f4c88c; color: #9c4700; }
.chip-lg { padding: 5px 10px; font-size: 0.85rem; }
.chip-x { background: none; border: none; cursor: pointer; font-weight: 800; color: var(--red-600); font-size: 1rem; line-height: 1; }

/* Filter bars & Inputs */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.search-input {
  flex: 1;
  min-width: 240px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
}
.compact-search {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.86rem;
}
.filter-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 99px;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.pill-btn.active { background: var(--green-700); color: #fff; border-color: var(--green-700); }

input, select, textarea {
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.9rem;
  background: #fff;
  color: var(--text);
  width: 100%;
}
input:focus, select:focus { outline: 2px solid rgba(21, 97, 27, 0.25); border-color: var(--green-700); }

.form-grid { display: flex; flex-direction: column; gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 0.84rem; font-weight: 600; color: var(--muted); }
.form-row { display: grid; gap: 10px; }
.two-col { grid-template-columns: repeat(2, 1fr); }
.three-col { grid-template-columns: repeat(3, 1fr); }
.sub-box { background: var(--green-50); border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.sub-box-title { font-size: 0.82rem; font-weight: 700; color: var(--green-900); margin-bottom: 8px; }
.tray-opening-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; }

.inline-rate-cell { display: flex; justify-content: flex-end; }
.quick-rate-inp { width: 92px; text-align: right; font-weight: 700; padding: 5px 8px; }
.compact-select { width: auto; padding: 6px 10px; }

/* Billing Screen */
.bill-type-toggle {
  display: inline-flex;
  background: #e5ece4;
  padding: 4px;
  border-radius: 10px;
  gap: 4px;
}
.toggle-btn {
  border: none;
  background: transparent;
  padding: 7px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--muted);
}
.toggle-btn.active { background: #fff; color: var(--green-900); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }

.bill-header-grid {
  display: grid;
  grid-template-columns: 150px 180px 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.bill-header-grid label, .party-picker-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--muted);
}
.party-picker-top { display: flex; justify-content: space-between; align-items: center; }

/* Party Autocomplete Search Box */
.party-ac-wrap { position: relative; width: 100%; }
.party-ac-input { padding-right: 34px; font-weight: 600; }
.party-ac-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: #edf1ec;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.party-ac-clear:hover { background: #dce4da; color: var(--text); }
.hidden { display: none !important; }
.party-ac-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--green-700);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15, 71, 20, 0.16);
  max-height: 300px;
  overflow-y: auto;
  z-index: 45;
}
.party-ac-opt {
  width: 100%;
  border: none;
  border-bottom: 1px solid #eef2ed;
  background: #fff;
  padding: 9px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}
.party-ac-opt:last-child { border-bottom: none; }
.party-ac-opt:hover, .party-ac-opt.highlighted { background: var(--green-50); }
.party-ac-opt.selected { background: var(--green-100); }
.party-ac-main { min-width: 0; flex: 1; }
.party-ac-bal { font-weight: 800; font-size: 0.88rem; white-space: nowrap; }
.party-ac-empty { padding: 12px; font-size: 0.86rem; color: var(--muted); text-align: center; }

.party-info-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  background: var(--green-50);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 0.86rem;
  margin-bottom: 14px;
}

.section-subhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.section-subhead h4 { margin: 0; font-size: 0.96rem; color: var(--green-900); }

.bill-items-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.bill-items-table th {
  background: var(--green-50);
  padding: 8px;
  font-size: 0.82rem;
  text-align: left;
  border-bottom: 2px solid var(--border);
}
.bill-items-table td { padding: 6px 5px; vertical-align: top; border-bottom: 1px solid #eef2ed; }

.bill-bottom-split {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 16px;
  margin-top: 10px;
}

.tray-entry-box, .cash-summary-box {
  background: #fbfdfb;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.cash-summary-box h4 { margin: 0 0 10px; font-size: 0.96rem; color: var(--green-900); }

.bill-tray-grid { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.bill-tray-grid th, .bill-tray-grid td {
  border: 1px solid var(--border);
  padding: 6px 7px;
  text-align: center;
}
.bill-tray-grid th { background: #f6ebe6; color: #5b1b1b; }
.bill-tray-grid td.lbl { text-align: left; font-weight: 700; color: #5b1b1b; width: 130px; }
.bill-tray-grid input { text-align: center; padding: 5px; font-weight: 700; }
.bill-tray-grid .row-ret { background: #e6f2ff; }
.bill-tray-grid .row-bal { background: #e8f5e9; color: var(--green-900); }

.cash-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 1px dashed #e2e8e0;
  font-size: 0.9rem;
}
.cash-row.total-line { background: var(--green-50); font-size: 0.96rem; }
.cash-row.row-ret { background: #e6f2ff; border-radius: 6px; margin-top: 4px; }
.cash-row.final-bal-line { background: #e8f5e9; border-radius: 6px; margin-top: 4px; font-size: 1.04rem; color: var(--green-900); }
.amt-inp { width: 130px; text-align: right; font-weight: 700; padding: 5px 8px; }
.inline-mini-input { width: 165px; padding: 5px 8px; font-size: 0.84rem; }
.mini-pay-pills { display: flex; gap: 4px; margin-top: 3px; }
.bill-submit-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* Settings & Sync */
.settings-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
}
.settings-full { grid-column: 1 / -1; }
.sync-stats-list { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; margin-bottom: 12px; }
.sync-stats-list div { display: flex; justify-content: space-between; border-bottom: 1px dashed #e6ece5; padding-bottom: 4px; }
.sync-controls-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.checkbox-pill {
  display: inline-flex; align-items: center; gap: 7px; font-size: 0.84rem; font-weight: 600;
  background: var(--green-50); border: 1px solid var(--border); padding: 6px 10px; border-radius: 8px; cursor: pointer;
}
.checkbox-pill input { width: auto; }
.tray-filters-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.small-scroll { max-height: 220px; overflow-y: auto; }

/* Locked Card */
.locked-gate-card {
  max-width: 440px;
  margin: 48px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  box-shadow: var(--shadow);
}
.locked-icon { font-size: 2.8rem; margin-bottom: 8px; }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 30, 18, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 18px 20px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}
.modal-sm { max-width: 460px; }
.modal-md { max-width: 620px; }
.modal-lg { max-width: 920px; }
.modal-slip { max-width: 820px; background: #f2f4f2; }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.modal-head h3 { margin: 0; font-size: 1.12rem; color: var(--green-900); }
.icon-close {
  border: none;
  background: #edf1ec;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.modal-scroll-table { max-height: 55vh; overflow-y: auto; }
.tray-preview-banner {
  background: var(--green-50);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.86rem;
}

/* PIN Modal & Full-Screen App Lock */
body.app-locked .app-shell { display: none !important; }
.app-lock-backdrop {
  background: linear-gradient(135deg, #0f4714 0%, #15611b 55%, #1f7a27 100%) !important;
  z-index: 150;
}
.pin-app-logo {
  width: 68px;
  height: 68px;
  border-radius: 14px;
  object-fit: cover;
  border: 2px solid var(--gold-500);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
}
.pin-modal { max-width: 360px; text-align: center; }
.pin-shield-icon { font-size: 2.3rem; }
.pin-modal-header h3 { margin: 6px 0 4px; color: var(--green-900); }
.pin-dots {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 14px 0 10px;
}
.pin-dots span {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--green-700);
  background: transparent;
  transition: background 0.12s;
}
.pin-dots span.filled { background: var(--green-700); }
.pin-dots.shake { animation: shake 0.35s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}
.pin-text-input { text-align: center; letter-spacing: 6px; font-weight: 800; font-size: 1.05rem; margin-bottom: 6px; }
.pin-error { color: var(--red-600); font-size: 0.83rem; min-height: 18px; margin-bottom: 6px; font-weight: 600; }
.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.pin-key {
  padding: 12px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--green-50);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
}
.pin-key:hover { background: var(--green-100); }
.pin-key-sec { font-size: 0.88rem; background: #f2f3f2; }

/* Toasts */
#toast-container {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: #202a21;
  color: #fff;
  padding: 10px 15px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--green-700); }
.toast-warning { background: var(--orange-600); }
.toast-error { background: var(--red-600); }

.empty-state, .empty-cell, .loading-box {
  text-align: center;
  padding: 26px 14px;
  color: var(--muted);
}

/* Product Images & Photo Grid */
.prod-thumb {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  display: block;
}
.prod-thumb-sm {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}
.prod-thumb-lg {
  width: 86px;
  height: 86px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}
.img-picker-row {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--green-50);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.img-picker-controls { flex: 1; min-width: 0; }
.bill-prod-cell { display: flex; align-items: center; gap: 8px; }
.bill-prod-inputs { flex: 1; min-width: 0; }

.prod-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
.prod-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.prod-card-img-wrap {
  position: relative;
  background: #fff;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  padding: 8px;
}
.prod-card-img-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.prod-card-sku {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(21, 97, 27, 0.88);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
}
.prod-card-body { padding: 11px 12px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.prod-card-name { font-weight: 700; font-size: 0.94rem; color: var(--green-900); line-height: 1.3; }
.prod-card-meta { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.prod-card-rate-row { display: flex; gap: 6px; align-items: center; margin-top: auto; }
.prod-card-rate-row .quick-rate-inp { flex: 1; }
.prod-card-actions { display: flex; justify-content: flex-end; gap: 6px; border-top: 1px dashed #e6ece5; padding-top: 6px; }

/* Mobile Bottom Nav & Sidebar Backdrop (hidden on desktop) */
.sidebar-backdrop { display: none; }
.mobile-bottom-nav { display: none; }

@media (max-width: 980px) {
  .dashboard-split, .bill-bottom-split, .settings-grid { grid-template-columns: 1fr; }
  .bill-header-grid { grid-template-columns: 1fr 1fr; }
  .party-picker-wrap { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  html, body { overflow-x: hidden; }
  .sidebar {
    position: fixed;
    left: -270px;
    top: 0;
    z-index: 80;
    transition: left 0.22s ease;
    height: 100dvh;
  }
  .sidebar.open { left: 0; box-shadow: 10px 0 30px rgba(0,0,0,0.35); }
  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 20, 12, 0.48);
    z-index: 70;
  }

  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
  }

  .topbar {
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar-title {
    font-size: 0.94rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 55vw;
  }
  .topbar-right {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
  }
  .supplier-lock-btn, .sync-pill {
    font-size: 0.76rem;
    padding: 5px 9px;
  }

  .app-main {
    padding: 12px 10px calc(80px + env(safe-area-inset-bottom, 0px));
  }

  .view-header h2 { font-size: 1.2rem; }
  .quick-actions-bar {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .quick-actions-bar .btn,
  .quick-actions-bar .bill-type-toggle {
    width: 100%;
    min-height: 42px;
    font-size: 0.84rem;
  }
  .quick-actions-bar .bill-type-toggle { grid-column: 1 / -1; }

  .bill-type-toggle { width: 100%; }
  .bill-type-toggle .toggle-btn { flex: 1; text-align: center; padding: 8px 8px; font-size: 0.82rem; }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .kpi-card { padding: 11px 12px; }
  .kpi-value { font-size: 1.2rem; }

  .two-col, .three-col, .bill-header-grid { grid-template-columns: 1fr; }
  input, select, textarea { font-size: 16px; min-height: 40px; }
  .search-input { min-width: 100%; }

  .filter-bar { padding: 12px; gap: 10px; }
  .filter-pills { width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .pill-btn { white-space: nowrap; padding: 7px 12px; }

  /* Responsive Card-Table for Data Tables */
  .data-table.mobile-cards thead { display: none; }
  .data-table.mobile-cards,
  .data-table.mobile-cards tbody,
  .data-table.mobile-cards tr,
  .data-table.mobile-cards td {
    display: block;
    width: 100%;
  }
  .data-table.mobile-cards tr {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 10px;
    box-shadow: 0 1px 4px rgba(15, 71, 20, 0.04);
  }
  .data-table.mobile-cards td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px dashed #ebf0ea;
    text-align: right;
  }
  .data-table.mobile-cards td:last-child { border-bottom: none; }
  .data-table.mobile-cards td::before {
    content: attr(data-label);
    font-size: 0.77rem;
    font-weight: 700;
    color: var(--muted);
    text-align: left;
    flex-shrink: 0;
  }
  .data-table.mobile-cards td.empty-cell {
    display: block;
    text-align: center;
  }
  .data-table.mobile-cards td.empty-cell::before { display: none; }
  .data-table.mobile-cards td.actions-cell {
    flex-wrap: wrap;
    justify-content: flex-start;
    padding-top: 8px;
  }
  .data-table.mobile-cards td.actions-cell::before {
    width: 100%;
    margin-bottom: 2px;
  }
  .data-table.mobile-cards td.actions-cell .btn {
    flex: 1 1 auto;
    min-height: 36px;
    font-size: 0.8rem;
  }

  /* Responsive Mobile Billing Item Cards */
  .bill-items-table thead { display: none; }
  .bill-items-table,
  .bill-items-table tbody {
    display: block;
    width: 100%;
  }
  .bill-items-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    background: #fbfdfb;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 10px;
  }
  .bill-items-table td {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0;
    border: none;
  }
  .bill-items-table td[data-label]::before {
    content: attr(data-label);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
  }
  .bill-items-table td.bill-cell-item,
  .bill-items-table td.bill-cell-del {
    grid-column: 1 / -1;
  }
  .bill-items-table td.bill-cell-del .row-del {
    width: 100%;
    min-height: 36px;
    border: 1px solid #f4c6c6;
  }

  .party-info-strip { gap: 8px 14px; font-size: 0.82rem; }
  .bill-tray-grid { font-size: 0.8rem; }
  .bill-tray-grid td.lbl { width: 92px; font-size: 0.76rem; }
  .bill-tray-grid input { min-width: 48px; padding: 6px 4px; }
  .bill-submit-actions {
    flex-direction: column-reverse;
  }
  .bill-submit-actions .btn {
    width: 100%;
    min-height: 46px;
    font-size: 0.98rem;
  }

  /* Product Photo Grid 2-col on mobile */
  .prod-photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .prod-card-img-wrap { height: 118px; }
  .prod-card-name { font-size: 0.84rem; }
  .img-picker-row { flex-direction: column; align-items: stretch; }
  .prod-thumb-lg { margin: 0 auto; }

  /* Modals full-screen friendly */
  .modal-backdrop { padding: 8px; align-items: flex-end; }
  .modal-card { padding: 14px 14px 18px; max-height: 92dvh; border-radius: 14px 14px 10px 10px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 auto; min-height: 42px; }

  #toast-container {
    left: 12px;
    right: 12px;
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  }

  /* Sticky Mobile Bottom Navigation */
  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 14px rgba(15, 71, 20, 0.08);
    z-index: 60;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
  }
  .mb-nav-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 2px;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
  }
  .mb-nav-btn .mb-ico { font-size: 1.15rem; line-height: 1; }
  .mb-nav-btn.active {
    color: var(--green-900);
    background: var(--green-100);
  }
}

@media (max-width: 390px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .quick-actions-bar { grid-template-columns: 1fr; }
}

/* Slip WhatsApp Customer Strip & Missing Number Prompt */
.slip-wa-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  background: #ffffff;
  border: 1px solid #d5e2d4;
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 10px;
}
.slip-wa-customer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.9rem;
}
.wa-phone-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}
.wa-phone-chip.ok { background: #e8f5e9; color: #1b5e20; border: 1px solid #b9dfc0; }
.wa-phone-chip.missing { background: #fff3e0; color: #b45309; border: 1px solid #fed7aa; }

.wa-phone-prompt {
  background: #f0f9f1;
  border: 1px solid #b6dbb9;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.wa-phone-prompt.hidden { display: none; }
.wa-phone-prompt-row {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px 14px;
}
.wa-phone-prompt-lbl {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 240px;
  font-size: 0.84rem;
}
.wa-phone-prompt-actions {
  display: flex;
  gap: 8px;
}

/* Reports View (Cash Ledger & Customer Statements) */
.report-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.rep-tab-btn {
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
}
.rep-tab-btn.active {
  background: var(--green-700);
  color: #ffffff;
  border-color: var(--green-700);
}
.report-filter-bar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px 16px;
}
.rep-date-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.rep-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-bottom: 2px;
}
.rep-cust-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}
.rep-cust-picker {
  flex: 1 1 320px;
  max-width: 520px;
}
.rep-cust-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.inline-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.lock-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 10px 14px;
  border-radius: 10px;
}
.rep-open-row { background: #f8fbf7; }
.rep-total-row { background: #eff6ee; border-top: 2px solid var(--border); }

/* Quick Tray Multi-Type Input Grid */
.qt-top-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px 14px;
}
.qt-grid-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  background: #ffffff;
}
.qt-grid-head {
  padding: 7px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: #f5f9f4;
  border-bottom: 1px solid var(--border);
}
.qt-grid-table {
  margin: 0;
}
.qt-grid-table th, .qt-grid-table td {
  vertical-align: middle;
  padding: 7px 8px;
}
.qt-col-focus {
  background: #eaf5e8;
  color: var(--green-900);
}
.qt-num-inp {
  width: 78px;
  text-align: center;
  font-weight: 700;
  padding: 7px 6px;
}
.text-center { text-align: center; }

@media (max-width: 640px) {
  .mb-nav-btn { font-size: 0.64rem; padding: 6px 1px; }
  .report-tabs { width: 100%; }
  .rep-tab-btn { flex: 1 1 140px; text-align: center; }
  .slip-wa-strip { flex-direction: column; align-items: flex-start; }
  .qt-top-row { grid-template-columns: 1fr; }
  .qt-grid-table th, .qt-grid-table td { padding: 6px 4px; font-size: 0.8rem; }
  .qt-num-inp { width: 58px; padding: 6px 4px; font-size: 0.88rem; }
}
