:root {
  --bg: #0a0c0f;
  --bg2: #111318;
  --bg3: #181c23;
  --bg4: #1e232d;
  --border: #252b38;
  --border2: #2e3547;
  --text: #e8ecf4;
  --text2: #8c96b0;
  --text3: #5a6478;
  --accent: #e8b84b;
  --accent2: #f0cc7a;
  --accent-dim: rgba(232,184,75,0.12);
  --green: #3dd68c;
  --green-dim: rgba(61,214,140,0.12);
  --red: #f05c5c;
  --red-dim: rgba(240,92,92,0.12);
  --blue: #5b9ef5;
  --blue-dim: rgba(91,158,245,0.12);
  --purple: #a78bfa;
  --sidebar-w: 240px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

/* ── DAY MODE (Light Theme) ── */
body.day-mode {
  --bg: #f0f2f5;
  --bg2: #ffffff;
  --bg3: #f5f6f8;
  --bg4: #eaecf0;
  --border: #dde1e9;
  --border2: #c8cdd8;
  --text: #111827;
  --text2: #4b5563;
  --text3: #9ca3af;
  --accent: #c8960a;
  --accent2: #e0a80d;
  --accent-dim: rgba(200,150,10,0.1);
  --green: #16a34a;
  --green-dim: rgba(22,163,74,0.1);
  --red: #dc2626;
  --red-dim: rgba(220,38,38,0.1);
  --blue: #2563eb;
  --blue-dim: rgba(37,99,235,0.1);
  --shadow: 0 4px 24px rgba(0,0,0,0.12);
}
body.day-mode .auth-bg {
  background: radial-gradient(ellipse at 20% 50%, rgba(200,150,10,0.08) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(37,99,235,0.06) 0%, transparent 50%);
}
body.day-mode .auth-grid {
  background-image: linear-gradient(var(--border) 1px, transparent 1px),
                    linear-gradient(90deg, var(--border) 1px, transparent 1px);
}
body.day-mode .filter-select option,
body.day-mode .form-group select option { background: var(--bg2); color: var(--text); }
body.day-mode thead th { background: var(--bg3); }
body.day-mode ::-webkit-scrollbar-track { background: var(--bg3); }
body.day-mode ::-webkit-scrollbar-thumb { background: var(--border2); }

/* ── THEME TOGGLE BUTTON ── */
.theme-toggle-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  cursor: pointer;
  font-size: 16px;
  padding: 5px 9px;
  border-radius: 7px;
  transition: all 0.2s;
  flex-shrink: 0;
}
.theme-toggle-btn:hover { border-color: var(--accent); color: var(--accent); }
.mobile-topbar .theme-toggle-btn { margin-left: auto; margin-right: 4px; }

* { margin:0; padding:0; box-sizing:border-box; }
html { font-size:14px; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── UTILITIES ── */
.hidden { display:none !important; }
.full-width { width:100%; }
.text-accent { color: var(--accent); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-muted { color: var(--text2); }
.mono { font-family: 'DM Mono', monospace; }

/* ── AUTH SCREEN ── */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.auth-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 20% 50%, rgba(232,184,75,0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(91,158,245,0.05) 0%, transparent 50%);
}
.auth-grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--border) 1px, transparent 1px),
                    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.3;
}
.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 24px;
}
.auth-brand {
  text-align: center;
  margin-bottom: 24px;
}
.brand-mark {
  width: 64px; height: 64px;
  background: var(--accent);
  color: var(--bg);
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px;
  margin: 0 auto 16px;
  box-shadow: 0 0 40px rgba(232,184,75,0.3);
}
.auth-brand h1 {
  font-family: 'Syne', sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}
.auth-brand p { color: var(--text2); font-size: 13px; }
.auth-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}
.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg3);
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  color: var(--text2);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}
.auth-tab.active {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}
.auth-back {
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
  margin-bottom: 16px;
  display: inline-block;
}
.auth-note {
  font-size: 11px;
  color: var(--text3);
  text-align: center;
  margin-top: 12px;
  line-height: 1.5;
}
.auth-divider {
  text-align: center;
  margin: 16px 0;
  position: relative;
  color: var(--text3);
  font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content:'';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after { right: 0; }
.auth-error {
  background: var(--red-dim);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 16px;
}

/* ── FORM ELEMENTS ── */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  transition: border-color 0.2s;
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-group select option { background: var(--bg3); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ── BUTTONS ── */
.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 11px 20px;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border2);
  padding: 10px 20px;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost {
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-ghost:hover { background: var(--bg4); color: var(--text); }
.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
  padding: 8px 16px;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-danger:hover { background: var(--red); color: white; }
.btn-success {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid var(--green);
  padding: 8px 16px;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-success:hover { background: var(--green); color: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 7px 14px;
  border-radius: 7px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ── SIDEBAR ── */
.main-app {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: width 0.3s;
  overflow: hidden;
}
.sidebar.collapsed { width: 60px; }
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-mark-sm {
  width: 32px; height: 32px;
  min-width: 32px;
  background: var(--accent);
  color: var(--bg);
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
}
.sidebar-brand-text { overflow: hidden; }
.brand-name {
  display: block;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}
.brand-sub {
  display: block;
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
}
.sidebar-toggle {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
}
.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.user-avatar {
  width: 34px; height: 34px;
  min-width: 34px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.user-info { overflow: hidden; }
.user-info span { display: block; white-space: nowrap; }
.user-info > span:first-child { font-size: 13px; font-weight: 600; }
.role-tag {
  font-size: 10px;
  background: var(--accent-dim);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: inline-block !important;
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text3);
  padding: 12px 16px 4px;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .user-info { display: none; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--text2);
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 500;
}
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-left-color: var(--accent);
}
.nav-icon { font-size: 14px; flex-shrink: 0; min-width: 18px; text-align: center; }
.badge {
  background: var(--red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  margin-left: 4px;
}
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

/* ── MAIN CONTENT ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  transition: margin-left 0.3s;
  padding: 0;
}
.sidebar.collapsed ~ .main-content { margin-left: 60px; }

/* ── MODULE HEADER ── */
.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  position: sticky; top: 0; z-index: 10;
}
.module-title h2 {
  font-family: 'Syne', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.module-title p { font-size: 12px; color: var(--text2); margin-top: 2px; }
.module-actions { display: flex; gap: 10px; align-items: center; }
.module-body { padding: 24px 28px; }

/* ── STATS GRID ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--border2); }
.stat-card.accent { border-color: var(--accent); background: var(--accent-dim); }
.stat-card.green { border-color: var(--green); background: var(--green-dim); }
.stat-card.red { border-color: var(--red); background: var(--red-dim); }
.stat-card.blue { border-color: var(--blue); background: var(--blue-dim); }
.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text2);
  margin-bottom: 10px;
}
.stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.red .stat-value { color: var(--red); }
.stat-card.blue .stat-value { color: var(--blue); }
.stat-sub { font-size: 11px; color: var(--text3); margin-top: 6px; }

/* ── CARDS & TABLES ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 {
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  font-weight: 700;
}
.card-body { padding: 20px; }
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
thead th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text3);
  background: var(--bg3);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }
tbody td {
  padding: 11px 16px;
  color: var(--text);
  white-space: nowrap;
}
.td-actions { display: flex; gap: 6px; align-items: center; }

/* ── STATUS BADGES ── */
.status {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.status.active, .status.paid, .status.delivered, .status.approved {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid var(--green);
}
.status.pending, .status.partial {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.status.overdue, .status.rejected, .status.cancelled {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
}
.status.draft, .status.inactive {
  background: var(--bg3);
  color: var(--text3);
  border: 1px solid var(--border);
}
.status.confirmed, .status.processing {
  background: var(--blue-dim);
  color: var(--blue);
  border: 1px solid var(--blue);
}

/* ── SEARCH & FILTERS ── */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.search-input {
  flex: 1;
  min-width: 200px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  outline: none;
}
.search-input:focus { border-color: var(--accent); }
.filter-select {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
.filter-select option { background: var(--bg2); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.modal-box.wide { max-width: 900px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg2);
  z-index: 1;
}
.modal-header h3 {
  font-family: 'Syne', sans-serif;
  font-size: 17px;
  font-weight: 700;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}
.modal-close:hover { color: var(--red); }
.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ── TOAST ── */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 13px;
  min-width: 260px;
  max-width: 360px;
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
}
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }
.toast.info { border-color: var(--blue); }
.toast-icon { font-size: 16px; }
@keyframes slideIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── DASHBOARD ── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-top: 20px;
}
.activity-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.activity-text { font-size: 13px; flex: 1; }
.activity-time { font-size: 11px; color: var(--text3); }

/* ── PRINT INVOICE ── */
.invoice-print {
  background: white;
  color: #111;
  padding: 40px;
  font-family: 'DM Sans', sans-serif;
}
.invoice-header-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 32px;
}
.invoice-company h2 {
  font-family: 'Syne', sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: #0a0c0f;
}
.invoice-company p { color: #555; font-size: 13px; }
.invoice-meta { text-align: right; }
.invoice-meta h3 { font-size: 28px; color: #e8b84b; font-family: 'Syne', sans-serif; }
.invoice-meta p { font-size: 13px; color: #555; }
.invoice-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
  padding: 20px;
  background: #f8f8f8;
  border-radius: 8px;
}
.invoice-parties h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: #888; margin-bottom: 6px; }
.invoice-parties p { font-size: 14px; color: #111; }
.invoice-table { width: 100%; border-collapse: collapse; margin-bottom: 28px; }
.invoice-table th { background: #0a0c0f; color: white; padding: 10px 14px; font-size: 12px; text-align: left; }
.invoice-table td { padding: 10px 14px; border-bottom: 1px solid #eee; font-size: 13px; }
.invoice-totals { text-align: right; }
.invoice-totals table { margin-left: auto; }
.invoice-totals td { padding: 5px 14px; font-size: 14px; }
.invoice-totals .grand-total td { font-weight: 700; font-size: 16px; border-top: 2px solid #0a0c0f; }

/* ── RETAILER PORTAL ── */
.retailer-portal {
  min-height: 100vh;
  background: var(--bg);
}
.rp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.rp-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 15px;
}
.rp-user { display: flex; align-items: center; gap: 14px; color: var(--text2); font-size: 13px; }
.rp-nav {
  display: flex;
  gap: 4px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
  scrollbar-width: none;
}
.rp-nav::-webkit-scrollbar { display: none; }
.rp-nav-btn {
  background: transparent;
  border: none;
  color: var(--text2);
  padding: 8px 14px;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.rp-nav-btn:hover { background: var(--bg3); color: var(--text); }
.rp-nav-btn.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; border-bottom: 2px solid var(--accent); }
.rp-content { padding: 20px; }

/* Floating cart button */
#rp_float_cart { animation: none; }
#rp_float_cart.pulse { animation: rp-cart-pulse 0.3s ease; }
@keyframes rp-cart-pulse {
  0%   { transform: translateX(-50%) scale(1); }
  50%  { transform: translateX(-50%) scale(1.06); }
  100% { transform: translateX(-50%) scale(1); }
}

/* Scheme badge hover */
.rp-scheme-badge:hover { opacity: 0.8; transform: scale(1.03); transition: all 0.15s; }


/* ── PENDING SCREEN ── */
.pending-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.pending-card {
  text-align: center;
  padding: 48px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 400px;
}
.pending-icon { font-size: 48px; margin-bottom: 20px; }
.pending-card h2 {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  margin-bottom: 12px;
}
.pending-card p { color: var(--text2); font-size: 14px; margin-bottom: 24px; line-height: 1.6; }

/* ── AGING TABLE ── */
.aging-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr 1fr;
  gap: 0;
}
.aging-header {
  display: contents;
}
.aging-header > div {
  background: var(--bg3);
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text3);
}

/* ── PRODUCT ITEM ROW (in orders) ── */
.product-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.product-row:last-child { border-bottom: none; }
.product-row-header {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 0 0 6px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 4px;
}
.product-row-header > div {
  font-size: 10px;
  color: var(--text3);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
/* Hide per-row labels since header row takes their place */
.product-row .form-group label { display: none; }
.add-row-btn {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px dashed var(--accent);
  border-radius: 8px;
  padding: 10px;
  width: 100%;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  text-align: center;
  transition: all 0.2s;
  margin-top: 10px;
}
.add-row-btn:hover { background: var(--accent); color: var(--bg); }
.remove-row {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  align-self: end;
  margin-bottom: 6px;
  line-height: 1;
}

/* ── SECTION DIVIDER ── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 16px;
}
.section-divider h4 {
  font-family: 'Syne', sans-serif;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── LEDGER ── */
.ledger-balance {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}
.ledger-card {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.ledger-dr { border-color: var(--red); }
.ledger-cr { border-color: var(--green); }
.ledger-bal { border-color: var(--accent); }
.ledger-card .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text2); }
.ledger-card .amount { font-family: 'Syne', sans-serif; font-size: 22px; font-weight: 800; margin-top: 4px; }
.ledger-dr .amount { color: var(--red); }
.ledger-cr .amount { color: var(--green); }
.ledger-bal .amount { color: var(--accent); }

/* ── RESPONSIVE (tablet — do not shrink sidebar; mobile drawer is below) ── */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .cash-bank-grid { grid-template-columns: 1fr; }
  .cart-item {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .cart-item > *:first-child { grid-column: 1 / -1; }
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 16px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* ── TWO COL LAYOUT ── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── CASH BANK ── */
.cash-bank-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.txn-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.txn-row:last-child { border-bottom: none; }
.txn-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.txn-dot.in { background: var(--green); }
.txn-dot.out { background: var(--red); }
.txn-info { flex: 1; }
.txn-info .txn-title { font-size: 13px; font-weight: 500; }
.txn-info .txn-sub { font-size: 11px; color: var(--text3); }
.txn-amount { font-family: 'DM Mono', monospace; font-size: 14px; font-weight: 500; }
.txn-amount.in { color: var(--green); }
.txn-amount.out { color: var(--red); }

/* Cart / Order items */
.cart-item {
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 36px;
  gap: 10px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.cart-item:last-child { border-bottom: none; }
.totals-section {
  background: var(--bg3);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 16px;
}
.totals-row {
  display: flex; justify-content: space-between;
  padding: 5px 0; font-size: 14px;
}
.totals-row.total {
  border-top: 1px solid var(--border);
  margin-top: 8px; padding-top: 12px;
  font-weight: 700; font-size: 16px;
  font-family: 'Syne', sans-serif;
}

/* ── PRODUCT SEARCH DROPDOWN (Vyapar-style) ── */
.product-search-wrap { position: relative; }
.psd-item:hover {
  background: var(--accent-dim);
}
.psd-item:last-child { border-bottom: none !important; }

/* ── AUTH FORGOT LINK ── */
.auth-forgot-link {
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
  opacity: 0.85;
  transition: opacity 0.2s;
}
.auth-forgot-link:hover { opacity: 1; text-decoration: underline; }

/* ── LEDGER FILTER BAR ── */
#btnDownloadStatement {
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════
   MOBILE RESPONSIVE — Phase 2
   ══════════════════════════════════════════════════════ */

/* Mobile topbar — hidden on desktop */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  z-index: 200;
  gap: 12px;
}
.mobile-menu-btn {
  background: none; border: none; color: var(--text);
  font-size: 20px; cursor: pointer; padding: 4px 8px;
}
.mobile-topbar-titles {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.mobile-brand {
  font-family: 'Syne', sans-serif; font-weight: 700;
  font-size: 13px; color: var(--accent);
  line-height: 1.2;
}
.mobile-module-title {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

/* Mobile horizontal nav bar — hidden on desktop */
.mobile-nav-bar {
  display: none;
  position: fixed;
  top: 52px; left: 0; right: 0;
  height: 46px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  z-index: 199;
  white-space: nowrap;
  padding: 0 8px;
  gap: 2px;
  align-items: center;
}
.mobile-nav-bar::-webkit-scrollbar { display: none; }
.mobile-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--text2);
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  border: none;
  background: none;
  transition: all 0.15s;
  flex-shrink: 0;
}
.mobile-nav-item:hover { background: var(--bg3); color: var(--text); }
.mobile-nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.mobile-nav-section {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 6px;
  vertical-align: middle;
  opacity: 0.6;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 299;
}

@media (max-width: 768px) {
  html { font-size: 15px; -webkit-text-size-adjust: 100%; }
  body { padding-bottom: env(safe-area-inset-bottom, 0); }

  :root { --mb-topbar: calc(52px + env(safe-area-inset-top, 0)); --mb-navbar: 50px; --mb-header-h: calc(102px + env(safe-area-inset-top, 0)); }
  .mobile-topbar {
    display: flex;
    height: var(--mb-topbar);
    padding-top: env(safe-area-inset-top, 0);
    padding-left: max(12px, env(safe-area-inset-left, 0));
    padding-right: max(12px, env(safe-area-inset-right, 0));
  }
  .mobile-nav-bar {
    display: flex;
    top: var(--mb-topbar);
    height: var(--mb-navbar);
    padding: 6px 10px;
    padding-left: max(10px, env(safe-area-inset-left, 0));
    gap: 6px;
  }
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border-radius: 10px;
    background: var(--bg3);
    flex-shrink: 0;
  }
  .mobile-nav-item {
    padding: 10px 14px;
    font-size: 13px;
    min-height: 38px;
    border-radius: 10px;
  }
  .mobile-nav-item.mobile-nav-menu {
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 700;
  }

  .main-content { margin-left: 0 !important; }

  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    width: min(280px, 88vw) !important;
    z-index: 300;
    transition: left 0.25s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: none;
  }
  .sidebar.open {
    left: 0;
    box-shadow: 8px 0 32px rgba(0,0,0,0.45);
  }
  .sidebar.open .sidebar-brand-text,
  .sidebar.open .nav-label,
  .sidebar.open .nav-section-label,
  .sidebar.open .user-info {
    display: block !important;
  }
  .sidebar.open .nav-section-label { display: block !important; }
  .sidebar.collapsed { width: min(280px, 88vw) !important; left: -280px; }
  .sidebar-toggle { display: block !important; }

  .main-app .main-content {
    margin-left: 0 !important;
    padding: calc(var(--mb-header-h) + 8px) 12px calc(20px + env(safe-area-inset-bottom, 0));
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  #moduleContainer {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .module-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: 12px;
    padding: 14px 14px 12px !important;
    position: static;
    z-index: 20;
  }
  .module-title h2 { font-size: 17px !important; line-height: 1.25; }
  .module-title p { font-size: 11px !important; }
  .module-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    width: 100%;
  }
  .module-actions > button,
  .module-actions > .btn-primary,
  .module-actions > .btn-outline {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    justify-content: center;
    min-height: 44px;
    font-size: 13px !important;
    padding: 10px 12px !important;
  }

  .module-body { padding: 12px 12px 24px !important; scroll-margin-top: 60px; }

  .stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
  }
  .stat-card { padding: 14px 12px !important; }
  .stat-value { font-size: 17px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .stat-label { font-size: 10px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .card { border-radius: 10px; overflow: hidden; }
  .card .module-body,
  .card .table-wrap { margin: 0; }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding-bottom: 4px;
    border-radius: 8px;
    transform: translateZ(0); /* force GPU layer on Android for smooth scroll */
  }
  .table-wrap::after {
    content: '';
    display: block;
    height: 1px;
  }
  table { min-width: 520px; font-size: 12px; }
  table th, table td {
    padding: 8px 10px !important;
    vertical-align: middle;
    line-height: 1.3;
  }
  table th:first-child,
  table td:first-child {
    position: -webkit-sticky; /* Android WebView <9 fallback */
    position: sticky;
    left: 0;
    background: var(--bg2);
    z-index: 2;
    box-shadow: 4px 0 8px -4px rgba(0,0,0,0.25);
    will-change: transform; /* GPU composite layer for smooth sticky on Android */
  }
  /* Sticky cells must not bleed through modal overlay */
  .modal-box table th:first-child,
  .modal-box table td:first-child {
    position: static;
    box-shadow: none;
    z-index: 0;
  }
  body.day-mode table th:first-child,
  body.day-mode table td:first-child {
    background: var(--bg2);
  }

  .two-col,
  .expense-cat-grid {
    grid-template-columns: 1fr !important;
  }
  .expense-cat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .filter-bar {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 8px;
    padding-bottom: 4px;
    margin-bottom: 12px;
    align-items: center;
  }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-bar .search-input,
  .filter-bar .filter-select,
  .filter-bar input[type='text'],
  .filter-bar input[type='search'] {
    min-width: 140px;
    max-width: 180px;
    flex-shrink: 0;
    min-height: 40px;
    font-size: 13px !important;
    box-sizing: border-box;
    width: auto !important;
  }
  .filter-bar select,
  .filter-bar .filter-select {
    min-width: 120px;
    max-width: 160px;
    flex-shrink: 0;
    min-height: 40px;
    font-size: 13px !important;
    width: auto !important;
  }
  .filter-bar input[type='date'] {
    min-width: 130px;
    flex-shrink: 0;
    min-height: 40px;
    font-size: 13px !important;
    width: auto !important;
  }
  .filter-bar button {
    flex-shrink: 0;
    min-height: 40px;
    white-space: nowrap;
    width: auto !important;
  }

  .form-group input,
  .form-group select,
  .form-group textarea,
  .search-input,
  .filter-select {
    font-size: 16px !important;
    min-height: 44px;
    max-width: 100%;
    box-sizing: border-box;
  }
  .form-row,
  .form-row-3 {
    grid-template-columns: 1fr !important;
    display: grid !important;
    gap: 10px !important;
  }

  .product-row {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  .product-row .form-group { flex: 1 1 auto; min-width: 0; }
  .product-row .product-search-wrap { flex: 1 1 100% !important; }
  .product-row .form-group label { display: none !important; }
  .product-row:first-child .form-group label { display: block !important; font-size: 10px; margin-bottom: 3px; }
  .product-row .item-unit-wrap { display: none !important; }
  .product-row input,
  .product-row select {
    font-size: 14px !important;
    padding: 8px 6px !important;
    min-height: 40px;
  }
  .item-sno { padding: 8px 4px !important; font-size: 11px !important; }

  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    max-height: 92vh;
    border-radius: 16px 16px 0 0 !important;
  }
  .modal-header {
    padding: 14px 16px !important;
    min-height: 52px;
  }
  .modal-close {
    min-width: 44px;
    min-height: 44px;
    font-size: 22px;
  }

  .td-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .td-actions button,
  .td-actions .btn-sm {
    min-height: 30px !important;
    padding: 5px 8px !important;
    font-size: 11px !important;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .btn-primary, .btn-outline, .btn-ghost, .btn-success, .btn-danger {
    min-height: 44px;
    padding: 10px 14px;
  }
  .btn-sm {
    min-height: 36px !important;
    padding: 8px 12px !important;
  }
  .add-row-btn {
    min-height: 48px !important;
    font-size: 15px !important;
  }

  .nav-item {
    padding: 12px 16px !important;
    min-height: 44px;
    font-size: 14px !important;
  }

  .rp-header {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px !important;
  }
  .rp-nav {
    overflow-x: auto;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    padding: 8px 10px !important;
    gap: 8px;
  }
  .rp-nav-btn {
    white-space: nowrap;
    flex-shrink: 0;
    min-height: 40px;
    padding: 10px 14px !important;
  }
  .rp-content { padding: 12px !important; }

  .ledger-balance { grid-template-columns: 1fr !important; }
  .totals-section { padding: 14px !important; }
  .totals-row { font-size: 14px !important; padding: 8px 0 !important; }

  .party-search-dropdown {
    max-height: min(50vh, 280px) !important;
  }
  .product-search-dropdown {
    max-height: min(45vh, 240px) !important;
  }

  .auth-container { padding: 12px 16px; max-width: 100%; }
  .auth-brand { margin-bottom: 16px; }
  .auth-brand h1 { font-size: 20px; margin-bottom: 2px; }
  .auth-brand p { font-size: 12px; }
  .auth-card { padding: 20px; }
  .auth-card { padding: 20px 16px; }

  .sidebar-overlay:not(.hidden) {
    display: block !important;
    backdrop-filter: blur(2px);
  }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .expense-cat-grid { grid-template-columns: 1fr !important; }
  .module-actions { grid-template-columns: 1fr !important; }
  .module-title h2 { font-size: 16px !important; }
  table { min-width: 460px; }
  .mobile-nav-item { padding: 9px 11px; font-size: 12px; }
}

/* ── SIDEBAR OVERLAY CLICK TO CLOSE (non-mobile covered by JS) ── */
.sidebar-overlay.hidden { display: none !important; }

/* ── TWO-COL GRID (used in recovery report etc) ── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ── BADGE styling (if not already defined) ── */
.badge {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── EXPENSES MODULE ── */
.expense-cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.expense-cat-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 10px;
  cursor: pointer;
  text-align: center;
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  color: var(--text2);
  transition: all 0.2s;
}
.expense-cat-btn:hover, .expense-cat-btn.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}
.expense-cat-icon { font-size: 20px; display: block; margin-bottom: 6px; }

/* ── BALANCE SHEET ── */
.bs-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}
.bs-section-header {
  background: var(--bg3);
  padding: 13px 20px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.bs-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.bs-row:last-child { border-bottom: none; }
.bs-row.total {
  background: var(--bg3);
  font-weight: 700;
  font-family: 'Syne', sans-serif;
}
.bs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 768px) { .bs-grid { grid-template-columns: 1fr; } }

/* ── BANK STATEMENT DOWNLOAD ── */
.bank-stmt-btn {
  background: var(--blue-dim);
  color: var(--blue);
  border: 1px solid var(--blue);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}
.bank-stmt-btn:hover { background: var(--blue); color: white; }

/* ── CHEQUE BADGE ── */
.status.cheque-pending {
  background: rgba(167,139,250,0.12);
  color: var(--purple);
  border: 1px solid var(--purple);
}

/* ── MODAL INVOICE LOCK (prevent outside tap close) ── */
.modal-overlay.invoice-mode { cursor: default; }
.modal-overlay.invoice-mode::before {
  content: '⚠ Tap Save or Cancel to close';
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text2);
  font-size: 12px;
  padding: 6px 16px;
  border-radius: 20px;
  pointer-events: none;
  opacity: 0;
  z-index: 9998;
}

/* ── PRODUCT WEIGHT FIELD ── */
.weight-input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}
.weight-input-group input { flex: 1; }
.weight-unit-badge {
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
}

/* ── MOBILE INVOICE/ORDER UX ── */
.mob-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.mob-row-num {
  font-size: 11px;
  color: var(--text3);
  font-family: 'DM Mono', monospace;
  font-weight: 600;
}
.mob-remove {
  background: none;
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

/* Mobile product row becomes a card */
@media (max-width: 767px) {
  .product-row {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  .product-row:last-child { border-bottom: 1px solid var(--border) !important; }
  .remove-row { display: flex !important; }
  .add-row-btn {
    padding: 14px !important;
    font-size: 15px !important;
    border-radius: 12px !important;
    margin-top: 4px !important;
  }
  /* Make modal scrollable with sticky bottom bar */
  .modal-box {
    display: flex;
    flex-direction: column;
    max-height: 92vh !important;
  }
  .modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px !important;
    padding-bottom: 96px !important; /* space for sticky footer */
  }
  .modal-footer {
    position: sticky;
    bottom: 0;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    gap: 10px;
    z-index: 10;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
  }
  .modal-footer button {
    flex: 1;
    padding: 14px !important;
    font-size: 15px !important;
    border-radius: 10px !important;
  }
  .totals-section {
    background: var(--bg3);
    border-radius: 10px;
    padding: 12px;
    margin-top: 12px;
  }
}

/* ── CHEQUE STATUS BADGES ── */
.status.bounced {
  background: rgba(231,76,60,0.15);
  color: #e74c3c;
}
.status.cleared {
  background: rgba(39,174,96,0.15);
  color: #27ae60;
}

/* ── BULK UPDATE TABLE ── */
#bu_tbody td { padding: 6px 4px; border-bottom: 1px solid var(--border); }
#bu_tbody tr:hover { background: var(--bg3); }
#bsu_tbody td { padding: 6px 4px; border-bottom: 1px solid var(--border); }
#bsu_tbody tr:hover { background: var(--bg3); }

/* ── PARTY SEARCH WIDGET ── */
.party-search-wrap input:focus {
  border-color: var(--accent) !important;
  outline: none;
  box-shadow: 0 0 0 2px rgba(232,184,75,0.15);
}
.party-search-dropdown .psd-item:hover { background: var(--bg3); }
.party-search-dropdown .psd-add-new:hover { background: rgba(232,184,75,0.08); }

/* ── PRODUCT SEARCH DROPDOWN ── */
.product-search-dropdown .psd-item:hover { background: var(--bg3) !important; }

/* ── ITEM ROW IMPROVEMENTS ── */
.product-row .item-search-input:focus,
.product-row .item-qty:focus,
.product-row .item-price:focus {
  border-color: var(--accent) !important;
  outline: none;
}

/* ── BACKUP MODAL ── */
.backup-col { cursor: pointer; }

/* ── KEYBOARD NAVIGATION HIGHLIGHT ── */
.psd-item.kb-active {
  background: rgba(232,184,75,0.18) !important;
  outline: 2px solid rgba(232,184,75,0.4);
  outline-offset: -2px;
}

/* ── LEAFLET MAP OVERRIDES ── */
.leaflet-container { font-family: inherit; }
.leaflet-popup-content-wrapper {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.leaflet-popup-tip { background: var(--bg2); }
.leaflet-popup-content { font-size: 13px; line-height: 1.5; }
.leaflet-control-zoom a {
  background: var(--bg2) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* ── GPS LOCATION BADGE ── */
.gps-verified { color: var(--green); font-size: 12px; font-weight: 600; }
.gps-flagged  { color: var(--red);   font-size: 12px; font-weight: 600; }
.gps-none     { color: var(--text3); font-size: 12px; }

/* ── CNIC INPUT ── */
#brr_cnic, #arr_cnic, #rc_username, #rc_password {
  font-family: 'DM Mono', monospace;
  letter-spacing: 1px;
}



/* Prevent horizontal page shift on mobile */
body.is-mobile-app {
  overscroll-behavior-x: none;
  -webkit-tap-highlight-color: rgba(232, 184, 75, 0.15);
}
body.is-mobile-app .main-app {
  touch-action: manipulation;
}

/* ── SKELETON LOADING ANIMATION ── */
@keyframes skeleton {
  0%   { opacity: 1; }
  100% { opacity: 0.4; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── INVOICE COLLECT BUTTON ── */
.btn-success {
  background: var(--green);
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.btn-success:hover { opacity: 0.85; }

/* ── INVOICE DATE FILTER ── */
#invFrom, #invTo {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
}
/* ── MOBILE ADDITIONAL FIXES ── */
@media (max-width: 768px) {
  /* Split payment row in invoice modal -- prevent overflow */
  .split-pay-row { flex-wrap: wrap !important; gap: 8px !important; }
  .split-pay-row select, .split-pay-row input { min-width: 0 !important; flex: 1 1 80px !important; }

  /* Party history two-pane: hide left list, show right full-width */
  #ph_left { display: none; }
  #ph_right { width: 100% !important; padding: 0 !important; }

  /* Totals row right-align amount */
  .totals-row span:last-child { text-align: right; flex-shrink: 0; }

  /* Product search dropdown full width */
  .product-search-dropdown { left: 0 !important; right: 0 !important; min-width: 0 !important; width: 100% !important; }

  /* Return qty inputs */
  [id^="sr_qty_"], [id^="pr_qty_"] { width: 64px !important; font-size: 16px !important; }

  /* Topbar title overflow */
  .mobile-topbar-titles { overflow: hidden; }
  .mobile-brand { font-size: 12px; }
  .mobile-module-title { font-size: 10px; }

  /* Table action buttons compact */
  .table-wrap .btn-sm { padding: 6px 8px !important; font-size: 11px !important; min-height: 32px !important; white-space: nowrap; }

  /* Party type toggle buttons */
  #inv_party_toggle, #pur_party_toggle { font-size: 10px !important; padding: 2px 6px !important; margin-top: 2px; display: inline-block; }
}

@media (max-width: 480px) {
  /* Party history single column */
  .ph-two-pane { grid-template-columns: 1fr !important; }
  /* Modal header title truncate */
  .modal-header h3, .modal-header h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100vw - 80px); }
}

/* ── KEYBOARD SHORTCUTS HELP BUTTON ── */
button[onclick="openShortcutsModal()"],
button[onclick*="openShortcutsModal"] {
  transition: color 0.15s, background 0.15s;
}
button[onclick="openShortcutsModal()"):hover,
button[onclick*="openShortcutsModal"]:hover {
  color: var(--accent) !important;
  background: var(--accent-dim) !important;
}
/* KBD tag styling for shortcut keys in modals */
kbd {
  font-family: 'DM Mono', monospace;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--border);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 11px;
  color: var(--accent);
}

/* ── ANDROID / CAPACITOR SPECIFIC FIXES ── */
@media (max-width: 768px) {
  /* Prevent text selection on tap (feels native) */
  .nav-item, .mobile-nav-item, .btn-primary, .btn-outline,
  .btn-ghost, .btn-danger, .btn-sm, .btn-success,
  .td-actions button, .module-actions button {
    -webkit-user-select: none;
    user-select: none;
  }

  /* Smooth overscroll - prevent page bounce on Android */
  .main-content, .modal-body, .sidebar-nav, .table-wrap {
    overscroll-behavior: contain;
  }

  /* Active state feedback (Android has no hover) */
  .btn-primary:active { opacity: 0.82; transform: scale(0.98); }
  .btn-outline:active, .btn-danger:active { opacity: 0.82; }
  .td-actions button:active { opacity: 0.75; }
  .nav-item:active, .mobile-nav-item:active {
    background: var(--accent-dim) !important;
  }

  /* Prevent horizontal body scroll from table overflow */
  body { overflow-x: hidden; }

  /* Bottom safe area for Android navbar */
  .modal-footer {
    padding-bottom: max(12px, env(safe-area-inset-bottom, 12px)) !important;
  }
  .sidebar-footer {
    padding-bottom: max(16px, env(safe-area-inset-bottom, 16px)) !important;
  }
}