:root {
  --bg-0: #080b10;
  --bg-0-trans: rgba(8,11,16,0.9);
  --bg-1: #0d1117;
  --bg-2: #131920;
  --bg-3: #1a2230;
  --bg-4: #1f2a3c;
  --border: #242f42;
  --border-light: #2e3d55;
  --text-1: #e8edf5;
  --text-2: #8a9ab5;
  --text-3: #5a6a82;
  --accent-buy: #4d9fff;
  --accent-buy-dim: rgba(77,159,255,0.12);
  --accent-sell: #00c896;
  --accent-sell-dim: rgba(0,200,150,0.12);
  --accent-profit: #f5c842;
  --accent-profit-dim: rgba(245,200,66,0.12);
  --accent-loss: #ff5c7a;
  --accent-loss-dim: rgba(255,92,122,0.12);
  --accent-purple: #b48aff;
  --accent-purple-dim: rgba(180,138,255,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

body.light-mode {
  --bg-0: #f4f6fa;
  --bg-0-trans: rgba(244,246,250,0.9);
  --bg-1: #ffffff;
  --bg-2: #eef1f7;
  --bg-3: #e3e8f0;
  --bg-4: #d8dfeb;
  --border: #cdd5e0;
  --border-light: #bcc6d6;
  --text-1: #0d1117;
  --text-2: #4a5568;
  --text-3: #8a9ab5;
  --shadow: 0 4px 24px rgba(0,0,0,0.06);
}

*, *::before, *::after { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
}

/* Hide scrollbars globally */
*::-webkit-scrollbar {
  display: none;
}
* {
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

body { 
  font-family: 'Syne', sans-serif; 
  background: var(--bg-0); 
  color: var(--text-1); 
  min-height: 100vh; 
  overflow-x: hidden; 
  -webkit-font-smoothing: antialiased;
}

body::before { 
  content:''; 
  position:fixed; 
  top:-200px; 
  left:-200px; 
  width:600px; 
  height:600px; 
  background:radial-gradient(circle, rgba(0,200,150,0.04) 0%, transparent 70%); 
  pointer-events:none; 
  z-index:0; 
}

body::after { 
  content:''; 
  position:fixed; 
  bottom:-200px; 
  right:-200px; 
  width:700px; 
  height:700px; 
  background:radial-gradient(circle, rgba(77,159,255,0.04) 0%, transparent 70%); 
  pointer-events:none; 
  z-index:0; 
}

.app { 
  display:flex; 
  min-height:100vh; 
  position:relative; 
  z-index:1; 
}

/* SIDEBAR */
.sidebar { 
  width:240px; 
  background:var(--bg-1); 
  border-right:1px solid var(--border); 
  display:flex; 
  flex-direction:column; 
  position:fixed; 
  top:0; 
  left:0; 
  height:100vh; 
  z-index:100; 
  overflow-y:auto; 
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-logo { 
  padding:24px 24px 20px; 
  border-bottom:1px solid var(--border); 
  flex-shrink:0; 
}

.logo-mark { 
  font-size:22px; 
  font-weight:800; 
  letter-spacing:-0.5px; 
  color:var(--text-1); 
}

.logo-mark span { color:var(--accent-buy); }

.logo-sub { 
  font-family:'JetBrains Mono',monospace; 
  font-size:10px; 
  color:var(--text-3); 
  margin-top:2px; 
  letter-spacing:1px; 
  text-transform:uppercase; 
}

.sidebar-nav { padding:14px 12px; flex:1; }

.nav-label { 
  font-family:'JetBrains Mono',monospace; 
  font-size:9px; 
  letter-spacing:2px; 
  text-transform:uppercase; 
  color:var(--text-3); 
  padding:0 12px; 
  margin:10px 0 5px; 
}

.nav-item { 
  display:flex; 
  align-items:center; 
  gap:12px; 
  padding:9px 12px; 
  border-radius:var(--radius-sm); 
  cursor:pointer; 
  transition:all 0.18s; 
  color:var(--text-2); 
  font-size:13px; 
  font-weight:500; 
  margin-bottom:2px; 
  border:1px solid transparent; 
}

.nav-item:hover { background:var(--bg-3); color:var(--text-1); }
.nav-item.active { background:var(--bg-4); color:var(--text-1); border-color:var(--border-light); }
.nav-item.active.buy { color:var(--accent-buy); border-color:rgba(0,200,150,0.25); background:var(--accent-buy-dim); }
.nav-item.active.sell { color:var(--accent-sell); border-color:rgba(77,159,255,0.25); background:var(--accent-sell-dim); }
.nav-item.active.dash { color:var(--accent-profit); border-color:rgba(245,200,66,0.2); background:var(--accent-profit-dim); }
.nav-item.active.prod { color:var(--accent-purple); border-color:rgba(180,138,255,0.25); background:var(--accent-purple-dim); }

.nav-icon { 
  font-size:15px; 
  width:20px; 
  text-align:center; 
  flex-shrink:0; 
}

.sidebar-footer { 
  padding:14px 24px; 
  border-top:1px solid var(--border); 
  font-family:'JetBrains Mono',monospace; 
  font-size:10px; 
  color:var(--text-3); 
  flex-shrink:0; 
}

/* MOBILE OVERLAY */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(3px);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.3s;
}

/* MAIN */
.main { margin-left:240px; flex:1; transition: margin 0.3s; }
.topbar { 
  position:sticky; 
  top:0; 
  z-index:80; 
  background:var(--bg-0-trans); 
  backdrop-filter:blur(16px); 
  border-bottom:1px solid var(--border); 
  padding:14px 32px; 
  display:flex; 
  align-items:center; 
  justify-content:space-between; 
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-1);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.mobile-menu-btn:active {
  background: var(--bg-3);
}

.topbar-title { font-size:18px; font-weight:700; color:var(--text-1); }
.topbar-date { font-family:'JetBrains Mono',monospace; font-size:11px; color:var(--text-3); }
.content { padding:28px 32px; max-width:1280px; }

.page { display:none; }
.page.active { display:block; animation:fadeIn 0.25s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

/* SECTION HEADER */
.section-header { margin-bottom:24px; }
.section-title { font-size:26px; font-weight:800; letter-spacing:-0.5px; }
.section-title span { -webkit-background-clip:text; -webkit-text-fill-color:transparent; background-clip:text; }
.section-title .buy-grad { background-image:linear-gradient(135deg, var(--accent-buy), #00a878); }
.section-title .sell-grad { background-image:linear-gradient(135deg, var(--accent-sell), #2d7fd4); }
.section-title .dash-grad { background-image:linear-gradient(135deg, var(--accent-profit), #e8a800); }
.section-title .prod-grad { background-image:linear-gradient(135deg, var(--accent-purple), #8a5cf5); }
.section-sub { font-size:13px; color:var(--text-3); margin-top:4px; font-weight:400; }

/* CARDS */
.card { 
  background:var(--bg-1); 
  border:1px solid var(--border); 
  border-radius:var(--radius); 
  padding:22px; 
  transition:border-color 0.2s; 
}
.card:hover { border-color:var(--border-light); }
.card-title { 
  font-size:10px; 
  font-family:'JetBrains Mono',monospace; 
  letter-spacing:2px; 
  text-transform:uppercase; 
  color:var(--text-3); 
  margin-bottom:18px; 
}

/* GRID */
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.grid-3 { display:grid; grid-template-columns:repeat(3,1fr); gap:20px; }
.grid-4 { display:grid; grid-template-columns:repeat(4,1fr); gap:16px; }

/* FORM */
.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.form-group { display:flex; flex-direction:column; gap:5px; }
.form-group.full { grid-column:1/-1; }

label { 
  font-size:10px; 
  font-family:'JetBrains Mono',monospace; 
  letter-spacing:1.5px; 
  text-transform:uppercase; 
  color:var(--text-3); 
}

input, select, textarea { 
  background:var(--bg-2); 
  border:1px solid var(--border); 
  border-radius:var(--radius-sm); 
  padding:9px 13px; 
  color:var(--text-1); 
  font-family:'Syne',sans-serif; 
  font-size:13px; 
  font-weight:500; 
  outline:none; 
  transition:border-color 0.18s, box-shadow 0.18s; 
  width:100%; 
}

input:focus, select:focus, textarea:focus { 
  border-color:var(--accent-buy); 
  box-shadow:0 0 0 3px rgba(0,200,150,0.08); 
}

input[type="number"] { font-family:'JetBrains Mono',monospace; }
select option { background:var(--bg-2); }
.sell-form input:focus, .sell-form select:focus { border-color:var(--accent-sell); box-shadow:0 0 0 3px rgba(77,159,255,0.08); }
.prod-form input:focus, .prod-form select:focus, .prod-form textarea:focus { border-color:var(--accent-purple); box-shadow:0 0 0 3px rgba(180,138,255,0.08); }

/* BUTTONS */
.btn { 
  display:inline-flex; 
  align-items:center; 
  justify-content: center;
  gap:8px; 
  padding:10px 20px; 
  border-radius:var(--radius-sm); 
  font-family:'Syne',sans-serif; 
  font-size:13px; 
  font-weight:600; 
  cursor:pointer; 
  border:none; 
  transition:all 0.18s; 
  letter-spacing:0.3px; 
}
.btn-buy { background:var(--accent-buy); color:#051a13; }
.btn-buy:hover { background:#00e0aa; transform:translateY(-1px); box-shadow:0 6px 20px rgba(0,200,150,0.3); }
.btn-sell { background:var(--accent-sell); color:#03102a; }
.btn-sell:hover { background:#6bb3ff; transform:translateY(-1px); box-shadow:0 6px 20px rgba(77,159,255,0.3); }
.btn-prod { background:var(--accent-purple); color:#120a2a; }
.btn-prod:hover { background:#c9a8ff; transform:translateY(-1px); box-shadow:0 6px 20px rgba(180,138,255,0.3); }
.btn-danger { background:transparent; border:1px solid rgba(255,92,122,0.3); color:var(--accent-loss); padding:5px 10px; font-size:11px; }
.btn-danger:hover { background:var(--accent-loss-dim); }
.btn-ghost { background:transparent; border:1px solid var(--border); color:var(--text-2); padding:5px 13px; font-size:12px; }
.btn-ghost:hover { border-color:var(--border-light); color:var(--text-1); }
.btn-sm { padding:6px 14px; font-size:12px; }
.btn-icon { padding:6px 10px; font-size:13px; }

/* STAT CARDS */
.stat-card { 
  background:var(--bg-1); 
  border:1px solid var(--border); 
  border-radius:var(--radius); 
  padding:18px 20px; 
  position:relative; 
  overflow:hidden; 
  transition:all 0.2s; 
}
.stat-card::before { content:''; position:absolute; top:0; left:0; right:0; height:2px; }
.stat-card.green::before { background:linear-gradient(90deg, var(--accent-buy), transparent); }
.stat-card.blue::before { background:linear-gradient(90deg, var(--accent-sell), transparent); }
.stat-card.yellow::before { background:linear-gradient(90deg, var(--accent-profit), transparent); }
.stat-card.red::before { background:linear-gradient(90deg, var(--accent-loss), transparent); }
.stat-card.purple::before { background:linear-gradient(90deg, var(--accent-purple), transparent); }
.stat-card:hover { border-color:var(--border-light); transform:translateY(-2px); box-shadow:var(--shadow); }

.stat-label { 
  font-family:'JetBrains Mono',monospace; 
  font-size:9px; 
  letter-spacing:2px; 
  text-transform:uppercase; 
  color:var(--text-3); 
  margin-bottom:8px; 
}
.stat-value { font-size:24px; font-weight:800; letter-spacing:-0.5px; line-height:1; margin-bottom:5px; }
.stat-card.green .stat-value { color:var(--accent-buy); }
.stat-card.blue .stat-value { color:var(--accent-sell); }
.stat-card.yellow .stat-value { color:var(--accent-profit); }
.stat-card.red .stat-value { color:var(--accent-loss); }
.stat-card.purple .stat-value { color:var(--accent-purple); }
.stat-sub { font-size:11px; color:var(--text-3); }
.stat-icon { position:absolute; top:16px; right:16px; font-size:20px; opacity:0.15; }

/* TABLE */
.table-wrap { overflow-x:auto; border-radius:var(--radius); border:1px solid var(--border); }
table { width:100%; border-collapse:collapse; font-size:12px; }
thead tr { background:var(--bg-2); border-bottom:1px solid var(--border); }
th { 
  padding:10px 14px; 
  text-align:left; 
  font-family:'JetBrains Mono',monospace; 
  font-size:9px; 
  letter-spacing:2px; 
  text-transform:uppercase; 
  color:var(--text-3); 
  font-weight:400; 
  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(--bg-2); }
td { padding:10px 14px; color:var(--text-2); font-size:12px; vertical-align:middle; white-space: nowrap; }
td.mono { font-family:'JetBrains Mono',monospace; font-size:11px; }
td.name { color:var(--text-1); font-weight:600; font-size:13px; white-space: normal; min-width: 120px; }
td.buy { color:var(--accent-buy); font-family:'JetBrains Mono',monospace; font-size:11px; }
td.sell { color:var(--accent-sell); font-family:'JetBrains Mono',monospace; font-size:11px; }
td.yellow { color:var(--accent-profit); font-family:'JetBrains Mono',monospace; font-size:11px; }
td.red { color:var(--accent-loss); font-family:'JetBrains Mono',monospace; font-size:11px; }
td.purple { color:var(--accent-purple); font-family:'JetBrains Mono',monospace; font-size:11px; }

/* BADGE */
.badge { 
  display:inline-flex; 
  align-items:center; 
  padding:2px 7px; 
  border-radius:4px; 
  font-family:'JetBrains Mono',monospace; 
  font-size:10px; 
  font-weight:500; 
  letter-spacing:0.5px; 
  text-transform:uppercase; 
}
.badge-profit { background:var(--accent-buy-dim); color:var(--accent-buy); border:1px solid rgba(0,200,150,0.2); }
.badge-loss { background:var(--accent-loss-dim); color:var(--accent-loss); border:1px solid rgba(255,92,122,0.2); }
.badge-purple { background:var(--accent-purple-dim); color:var(--accent-purple); border:1px solid rgba(180,138,255,0.2); }
.badge-cat { background:var(--bg-3); color:var(--text-2); border:1px solid var(--border); }

.empty-state { padding:50px 24px; text-align:center; color:var(--text-3); }
.empty-icon { font-size:36px; margin-bottom:10px; opacity:0.5; }
.empty-state p { font-size:13px; }

.summary-row { display:flex; align-items:center; justify-content:space-between; padding:9px 0; border-bottom:1px solid var(--border); font-size:13px; }
.summary-row:last-child { border-bottom:none; }
.summary-key { color:var(--text-2); }
.summary-val { font-family:'JetBrains Mono',monospace; font-weight:600; color:var(--text-1); }

.gst-breakdown { 
  background:var(--bg-2); 
  border:1px solid var(--border); 
  border-radius:var(--radius-sm); 
  padding:12px 14px; 
  display:grid; 
  grid-template-columns:1fr 1fr 1fr; 
  gap:10px; 
}
.gst-item { text-align:center; }
.gst-item-label { 
  font-size:9px; 
  font-family:'JetBrains Mono',monospace; 
  letter-spacing:1.5px; 
  text-transform:uppercase; 
  color:var(--text-3); 
  margin-bottom:3px; 
}
.gst-item-val { font-size:15px; font-weight:700; font-family:'JetBrains Mono',monospace; }

.margin-pill { 
  display:inline-flex; 
  align-items:center; 
  gap:4px; 
  padding:2px 7px; 
  border-radius:20px; 
  font-family:'JetBrains Mono',monospace; 
  font-size:10px; 
  font-weight:500; 
}

/* MODAL */
.modal-overlay { 
  display:none; 
  position:fixed; 
  inset:0; 
  background:rgba(0,0,0,0.7); 
  backdrop-filter:blur(4px); 
  z-index:1000; 
  align-items:center; 
  justify-content:center; 
  padding:20px; 
}
.modal-overlay.open { display:flex; }
.modal { 
  background:var(--bg-1); 
  border:1px solid var(--border-light); 
  border-radius:var(--radius); 
  width:100%; 
  max-width:700px; 
  max-height:90vh; 
  overflow-y:auto; 
  box-shadow:0 20px 60px rgba(0,0,0,0.6); 
  animation:fadeIn 0.2s ease; 
}
.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(--bg-1); 
  z-index:1; 
}
.modal-title { font-size:16px; font-weight:700; }
.modal-close { background:none; border:none; color:var(--text-3); font-size:20px; cursor:pointer; padding:4px; line-height:1; transition:color 0.15s; }
.modal-close:hover { color:var(--text-1); }
.modal-body { padding:24px; }
.modal-footer { padding:16px 24px; border-top:1px solid var(--border); display:flex; gap:10px; justify-content:flex-end; }

/* PRODUCT CARD */
.product-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(280px, 1fr)); gap:16px; }
.product-card { 
  background:var(--bg-1); 
  border:1px solid var(--border); 
  border-radius:var(--radius); 
  padding:18px; 
  transition:all 0.2s; 
  cursor:pointer; 
  position:relative; 
  overflow:hidden; 
}
.product-card::before { 
  content:''; position:absolute; top:0; left:0; right:0; height:2px; background:linear-gradient(90deg, var(--accent-purple), transparent); 
}
.product-card:hover { border-color:rgba(180,138,255,0.4); transform:translateY(-2px); box-shadow:var(--shadow); }
.product-card-name { font-size:15px; font-weight:700; color:var(--text-1); margin-bottom:4px; }
.product-card-sku { font-family:'JetBrains Mono',monospace; font-size:10px; color:var(--text-3); margin-bottom:12px; }
.product-card-stats { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-bottom:12px; }
.pc-stat { background:var(--bg-2); border-radius:var(--radius-sm); padding:8px 10px; }
.pc-stat-label { font-size:9px; font-family:'JetBrains Mono',monospace; letter-spacing:1px; text-transform:uppercase; color:var(--text-3); margin-bottom:2px; }
.pc-stat-val { font-size:14px; font-weight:700; font-family:'JetBrains Mono',monospace; }

/* TABS */
.tabs { display:flex; gap:4px; background:var(--bg-2); border-radius:var(--radius-sm); padding:4px; margin-bottom:20px; border:1px solid var(--border); }
.tab { flex:1; padding:8px 12px; border-radius:6px; cursor:pointer; font-size:12px; font-weight:600; text-align:center; transition:all 0.18s; color:var(--text-3); border:1px solid transparent; }
.tab.active { background:var(--bg-4); color:var(--text-1); border-color:var(--border-light); }
.tab-content { display:none; }
.tab-content.active { display:block; }

/* TOAST */
#toast { 
  position:fixed; bottom:24px; right:24px; background:var(--bg-3); border:1px solid var(--border-light); 
  border-radius:var(--radius-sm); padding:12px 18px; font-size:13px; font-weight:500; color:var(--text-1); 
  z-index:9999; opacity:0; transform:translateY(16px); transition:all 0.25s; pointer-events:none; 
  display:flex; align-items:center; gap:10px; max-width:320px; box-shadow:var(--shadow); 
}
#toast.show { opacity:1; transform:translateY(0); }
#toast.success::before { content:'✓'; color:var(--accent-buy); font-size:15px; }
#toast.error::before { content:'✕'; color:var(--accent-loss); font-size:15px; }

.section-gap { margin-top:24px; }

/* FAB FOR MOBILE */
.fab-container { 
  position: fixed; 
  bottom: 24px; 
  right: 24px; 
  z-index: 900; 
  display: none; 
  flex-direction: column; 
  align-items: flex-end; 
  gap: 12px; 
}
.fab-main { 
  width: 56px; 
  height: 56px; 
  border-radius: 50%; 
  background: var(--accent-purple); 
  color: #fff; 
  font-size: 28px; 
  border: none; 
  box-shadow: 0 4px 16px rgba(180,138,255,0.4); 
  cursor: pointer; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  transition: transform 0.2s, background 0.2s; 
}
.fab-main.active { 
  transform: rotate(45deg); 
  background: var(--accent-loss); 
  box-shadow: 0 4px 16px rgba(255,92,122,0.4);
}
.fab-menu { 
  display: flex; 
  flex-direction: column; 
  align-items: flex-end;
  gap: 10px; 
  opacity: 0; 
  pointer-events: none; 
  transform: translateY(15px); 
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); 
}
.fab-menu.show { 
  opacity: 1; 
  pointer-events: auto; 
  transform: translateY(0); 
}
.fab-item { 
  background: var(--bg-1); 
  border: 1px solid var(--border-light); 
  padding: 12px 18px; 
  border-radius: 30px; 
  color: var(--text-1); 
  font-size: 14px; 
  font-weight: 600; 
  cursor: pointer; 
  white-space: nowrap; 
  box-shadow: 0 4px 12px rgba(0,0,0,0.5); 
  transition: all 0.2s; 
  display: flex;
  align-items: center;
  gap: 8px;
}
.fab-item.buy { color: var(--accent-buy); border-color: rgba(0,200,150,0.4); }
.fab-item.sell { color: var(--accent-sell); border-color: rgba(77,159,255,0.4); }


/* RESPONSIVENESS */
@media (max-width:900px) {
  .grid-4 { grid-template-columns:repeat(2,1fr); }
  .grid-3 { grid-template-columns:1fr 1fr; }
}

@media (max-width:650px) {
  /* Hide sidebar default on mobile */
  .sidebar { left:-240px; }
  .sidebar.open { left: 0; box-shadow: 4px 0 24px rgba(0,0,0,0.5); }
  
  .sidebar-overlay.show { display: block; opacity: 1; }
  
  .main { margin-left:0; }
  .content { padding:16px; }
  .grid-2,.grid-3,.grid-4,.form-grid { grid-template-columns:1fr; }
  
  .topbar { padding:12px 16px; gap: 12px; }
  .mobile-menu-btn { display: block; }
  
  /* Fix iOS input zoom */
  input, select, textarea { font-size: 16px; }
  
  /* Show Mobile FAB */
  .fab-container { display: flex; }
  
  /* Stacking modal adjustments for small screens */
  .modal-body { padding: 16px; }
  .modal-footer { padding: 16px; flex-wrap: wrap; }
  .modal-footer button { flex: 1 1 100%; justify-content: center; }
  
  /* Make table wrappers more obviously scrollable */
  .table-wrap {
    box-shadow: inset -10px 0 10px -10px rgba(0,0,0,0.3);
  }
}

/* =========================================================
   MOBILE OPTIMIZATION
========================================================= */

*{
  box-sizing:border-box;
  -webkit-tap-highlight-color:transparent;
}

html,body{
  width:100%;
  overflow-x:hidden;
}

body{
  touch-action:manipulation;
}

/* =========================
   MAIN LAYOUT
========================= */

.app{
  width:100%;
  overflow:hidden;
}

.main{
  width:100%;
  min-width:0;
}

.content{
  padding:14px;
}

/* =========================
   RESPONSIVE GRIDS
========================= */

.grid-2,
.grid-4,
.product-grid{
  display:grid;
  gap:14px;
}

.grid-2{
  grid-template-columns:repeat(2,minmax(0,1fr));
}

.grid-4{
  grid-template-columns:repeat(4,minmax(0,1fr));
}

.product-grid{
  grid-template-columns:repeat(auto-fill,minmax(260px,1fr));
}

/* =========================
   TABLES
========================= */

.table-wrap{
  width:100%;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
  border-radius:14px;
}

table{
  min-width:900px;
  border-collapse:collapse;
}

th,
td{
  white-space:nowrap;
}

/* =========================
   FORM ELEMENTS
========================= */

input,
select,
textarea,
button{
  width:100%;
  min-height:44px;
  font-size:16px; /* prevents iOS zoom */
}

.form-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:14px;
}

.form-group.full{
  grid-column:1/-1;
}

/* =========================
   BUTTONS
========================= */

.btn{
  min-height:46px;
  padding:12px 16px;
  font-size:14px;
  border-radius:12px;
  white-space:nowrap;
}

/* =========================
   TOPBAR
========================= */

.topbar{
  position:sticky;
  top:0;
  z-index:50;
  padding:14px;
  backdrop-filter:blur(10px);
}

.topbar-title{
  font-size:18px;
}

.topbar-date{
  font-size:12px;
}

/* =========================
   SIDEBAR MOBILE
========================= */

.mobile-menu-btn{
  display:none;
}

.sidebar{
  transition:transform .28s ease;
}

.sidebar-overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.5);
  opacity:0;
  visibility:hidden;
  transition:.25s;
  z-index:98;
}

.sidebar-overlay.show{
  opacity:1;
  visibility:visible;
}

/* =========================
   CARDS
========================= */

.card,
.stat-card,
.product-card{
  width:100%;
  min-width:0;
  overflow:hidden;
}

.stat-value{
  font-size:22px;
  word-break:break-word;
}

.summary-row{
  gap:12px;
}

.summary-key{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* =========================
   GST BREAKDOWN
========================= */

.gst-breakdown{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:10px;
}

.gst-item{
  min-width:0;
}

.gst-item-val{
  font-size:14px;
  overflow-wrap:anywhere;
}

/* =========================
   MODALS
========================= */

.modal-overlay{
  padding:14px;
}

.modal{
  width:100%;
  max-width:100%;
  max-height:90vh;
  overflow-y:auto;
  border-radius:18px;
}

.modal-body{
  overflow-x:hidden;
}

/* =========================
   FAB
========================= */

.fab-container{
  position:fixed;
  right:16px;
  bottom:16px;
  z-index:80;
}

.fab-main{
  width:58px;
  height:58px;
  border-radius:50%;
  font-size:28px;
}

.fab-menu{
  display:flex;
  flex-direction:column;
  gap:10px;
  margin-bottom:10px;
}

.fab-item{
  min-height:44px;
}

/* =========================================================
   TABLET
========================================================= */

@media (max-width: 1100px){

  .grid-4{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .product-grid{
    grid-template-columns:repeat(auto-fill,minmax(220px,1fr));
  }
}

/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 650px){

  body{
    font-size:14px;
  }

  .mobile-menu-btn{
    display:flex;
    align-items:center;
    justify-content:center;
    width:42px;
    height:42px;
    border:none;
    border-radius:10px;
  }

  .sidebar{
    position:fixed;
    top:0;
    left:0;
    width:280px;
    height:100vh;
    z-index:99;
    transform:translateX(-100%);
  }

  .sidebar.open{
    transform:translateX(0);
  }

  .main{
    width:100%;
    margin-left:0;
  }

  .content{
    padding:12px;
  }

  .grid-2,
  .grid-4,
  .form-grid,
  .product-grid{
    grid-template-columns:1fr;
  }

  .section-header{
    gap:8px;
  }

  .section-title{
    font-size:22px;
    line-height:1.2;
  }

  .section-sub{
    font-size:13px;
    line-height:1.5;
  }

  .topbar{
    padding:12px;
  }

  .topbar-date{
    display:none;
  }

  .card{
    padding:14px;
    border-radius:16px;
  }

  .stat-card{
    padding:16px;
  }

  .stat-value{
    font-size:20px;
  }

  .gst-breakdown{
    grid-template-columns:1fr;
  }

  .gst-breakdown[style*="repeat(4,1fr)"]{
    grid-template-columns:1fr 1fr;
  }

  .summary-row{
    align-items:flex-start;
    flex-direction:column;
  }

  .summary-val{
    width:100%;
  }

  .btn{
    width:100%;
  }

  .modal{
    border-radius:20px 20px 0 0;
    margin-top:auto;
  }

  .modal-footer{
    flex-direction:column;
  }

  .tabs{
    overflow-x:auto;
    flex-wrap:nowrap;
    -webkit-overflow-scrolling:touch;
  }

  .tab{
    white-space:nowrap;
  }

  .fab-item{
    font-size:13px;
  }
}

/* =========================================================
   SMALL PHONES
========================================================= */

@media (max-width: 420px){

  .content{
    padding:10px;
  }

  .card,
  .stat-card{
    padding:12px;
  }

  .section-title{
    font-size:20px;
  }

  .topbar-title{
    font-size:16px;
  }

  .stat-value{
    font-size:18px;
  }

  .btn{
    font-size:13px;
    padding:11px 14px;
  }

  table{
    min-width:780px;
  }
}

/* =========================================================
   DYNAMIC ROW LOGGING SYSTEM (MOBILE FIRST)
   ========================================================= */

.entry-rows {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

.entry-rows-header {
  display: none; /* Hidden on mobile */
}

/* Card-style row on mobile */
.entry-row-card {
  background: var(--bg-3);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: border-color 0.2s, transform 0.2s;
}

.entry-row-card:hover {
  border-color: var(--accent-purple);
}

/* Mobile row header */
.row-header-mobile {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 4px;
}

.row-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
}

/* Mobile close/delete button */
.btn-remove-row {
  background: var(--accent-loss-dim);
  border: 1px solid rgba(255, 92, 122, 0.2);
  color: var(--accent-loss);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-remove-row:hover {
  background: var(--accent-loss);
  color: #fff;
}

.btn-remove-row-desktop {
  display: none; /* Hidden on mobile */
}

/* Inputs grid inside card */
.row-inputs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Span fields to full width on mobile if needed */
.row-col-name,
.row-col-product,
.row-col-gst,
.row-col-gst-custom,
.row-col-total {
  grid-column: span 2;
}

.mobile-label {
  display: block; /* Show labels on mobile */
  font-size: 9px;
  margin-bottom: 4px;
  color: var(--text-2);
}

/* Unit label styling (read-only box for product logging) */
.unit-label {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 13px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  min-height: 44px;
  font-family: 'JetBrains Mono', monospace;
}

/* Stacked GST select and custom input container */
.row-col-gst {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.custom-gst-wrap {
  margin-top: 2px;
}

/* Custom section headers/actions */
.form-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
  gap: 12px;
}

/* Desktop Adaptive Rules */
@media (min-width: 768px) {
  .entry-rows {
    gap: 8px;
  }

  /* Table Header */
  .entry-rows-header {
    display: grid;
    padding: 0 12px 6px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
    align-items: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-3);
  }

  /* Table style row on desktop */
  .entry-row-card {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 6px 0;
    margin: 0;
    flex-direction: row;
    align-items: center;
    box-shadow: none;
    gap: 8px;
    border-bottom: 1px solid var(--border);
  }

  .entry-row-card:hover {
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.01);
  }

  .row-header-mobile {
    display: none; /* Hide mobile labels/buttons */
  }

  /* Desktop layout for inputs */
  .row-inputs-grid {
    flex: 1;
    display: grid;
    gap: 8px;
    align-items: center;
  }

  /* Reset spans on desktop */
  .row-col-name,
  .row-col-product,
  .row-col-gst,
  .row-col-gst-custom,
  .row-col-total {
    grid-column: auto;
  }

  /* Hide labels on desktop as headers cover them */
  .mobile-label {
    display: none;
  }

  .btn-remove-row-desktop {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-3);
    font-size: 16px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
  }

  .btn-remove-row-desktop:hover {
    background: var(--accent-loss-dim);
    color: var(--accent-loss);
  }

  /* Custom grid alignments for columns per form type */
  /* Buy & Sell: Name, Qty, Unit, Price, Discount, Total */
  .buy-rows-grid .row-inputs-grid,
  .sell-rows-grid .row-inputs-grid {
    grid-template-columns: 3fr 1.2fr 1fr 1.5fr 1.2fr 1.5fr;
  }
  .buy-rows-grid.gst-enabled .row-inputs-grid,
  .sell-rows-grid.gst-enabled .row-inputs-grid {
    grid-template-columns: 3fr 1.2fr 1fr 1.5fr 1.2fr 1.2fr 1.5fr;
  }

  .buy-header,
  .sell-header {
    grid-template-columns: 3fr 1.2fr 1fr 1.5fr 1.2fr 1.5fr 32px;
    gap: 8px;
  }
  .buy-rows-grid.gst-enabled .buy-header,
  .sell-rows-grid.gst-enabled .sell-header {
    grid-template-columns: 3fr 1.2fr 1fr 1.5fr 1.2fr 1.2fr 1.5fr 32px;
    gap: 8px;
  }
}

.layout-logging {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 1024px) {
  .layout-logging {
    grid-template-columns: 3.2fr 1.2fr;
  }
}

/* Insight tabs container and components */
.insight-tab-content {
  display: none;
}
.insight-tab-content.active {
  display: block;
}

/* Inventory Badge Statuses */
.badge-status {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.badge-status-green {
  background: rgba(0, 200, 150, 0.12);
  color: var(--accent-buy);
  border: 1px solid rgba(0, 200, 150, 0.25);
}
.badge-status-yellow {
  background: rgba(245, 200, 66, 0.12);
  color: var(--accent-profit);
  border: 1px solid rgba(245, 200, 66, 0.2);
}
.badge-status-red {
  background: rgba(255, 92, 122, 0.12);
  color: var(--accent-loss);
  border: 1px solid rgba(255, 92, 122, 0.25);
}

/* Forecast Panel styling */
.forecast-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.forecast-stat {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.forecast-label {
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.forecast-val {
  font-size: 15px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-1);
}
.forecast-status-box {
  background: var(--bg-3);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-2);
}

/* =========================================================
   DASHBOARD ENHANCEMENTS
========================================================= */

/* Quick action buttons in dashboard header */
.dash-quick-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.dash-quick-actions .btn {
  min-height: 38px;
  padding: 8px 16px;
  font-size: 13px;
  width: auto;
}

/* Onboarding welcome banner */
.onboard-banner {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: linear-gradient(135deg, rgba(0,200,150,0.07), rgba(77,159,255,0.07));
  border: 1px solid rgba(0,200,150,0.2);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
}

.onboard-icon {
  font-size: 28px;
  flex-shrink: 0;
  line-height: 1;
}

.onboard-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 4px;
}

.onboard-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
}

/* =========================================================
   MOBILE TABLE SCROLL HINT
========================================================= */
.table-scroll-hint {
  font-size: 11px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  text-align: right;
  margin-bottom: 6px;
  display: none;
}

/* =========================================================
   GRID-3 RESPONSIVE IMPROVEMENT
   Keep 3-col on medium screens, collapse to 1 on small phones
========================================================= */
@media (max-width: 520px) {
  .grid-3 {
    grid-template-columns: 1fr;
  }
  /* Stat cards in a row on small phones - compact mode */
  .grid-3 .stat-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
  }
  .grid-3 .stat-card .stat-icon {
    position: static;
    font-size: 22px;
    opacity: 0.6;
    flex-shrink: 0;
  }
  .grid-3 .stat-card .stat-value {
    font-size: 18px;
    margin-bottom: 2px;
  }
  .grid-3 .stat-card .stat-label {
    margin-bottom: 2px;
    font-size: 8px;
  }
  .grid-3 .stat-card .stat-sub {
    font-size: 10px;
  }
  .grid-3 .stat-card > div:not(.stat-icon) {
    flex: 1;
    min-width: 0;
  }

  .table-scroll-hint { display: block; }

  /* Toast at top on very small screens so it doesn't hide FAB */
  #toast {
    bottom: auto;
    top: 70px;
    right: 12px;
    left: 12px;
    max-width: none;
    text-align: center;
    justify-content: center;
  }

  /* Section header stacks cleanly */
  .dash-quick-actions {
    width: 100%;
  }
  .dash-quick-actions .btn {
    flex: 1;
    justify-content: center;
  }
}

/* Keep summary-row horizontal always (not column on mobile) */
.summary-row {
  flex-direction: row !important;
  align-items: center !important;
}

.summary-key {
  flex: 1;
}

.summary-val {
  text-align: right;
  flex-shrink: 0;
}

/* =========================================================
   IMPROVED EMPTY STATES
========================================================= */
.empty-state p {
  font-size: 12px;
  margin-top: 6px;
}

/* =========================================================
   CARD TITLE WITH EMOJI (don't uppercase emoji)
========================================================= */
.card-title {
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 18px;
}

/* =========================================================
   MOBILE LOGGING FORM IMPROVEMENTS
========================================================= */

/* Sticky bottom action bar on mobile for log forms */
.log-actions-bar {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

@media (max-width: 650px) {
  .log-actions-bar {
    position: sticky;
    bottom: 0;
    background: var(--bg-1);
    border-top: 1px solid var(--border);
    padding: 12px 0 4px;
    margin: 12px -14px -14px;
    padding-left: 14px;
    padding-right: 14px;
    z-index: 10;
  }

  .log-actions-bar .btn {
    flex: 1;
  }

  /* Tighter entry row cards on mobile */
  .entry-row-card {
    padding: 12px;
    gap: 10px;
  }

  /* Topbar logo visible on mobile */
  .topbar-title {
    font-weight: 800;
  }

  /* Larger touch targets for remove row buttons */
  .btn-remove-row {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }

  /* Add row button full width on mobile */
  .btn-add-row-mobile {
    width: 100%;
    justify-content: center;
  }
}

/* =========================================================
   CHART TIME-RANGE FILTER BAR
========================================================= */

.chart-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding: 14px 18px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.chart-filter-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--text-2);
  font-family: 'Syne', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  min-height: 32px;
  width: auto;
}

.filter-pill:hover {
  border-color: var(--accent-profit);
  color: var(--accent-profit);
  background: var(--accent-profit-dim);
}

.filter-pill.active {
  background: var(--accent-profit-dim);
  border-color: var(--accent-profit);
  color: var(--accent-profit);
}

.chart-filter-custom {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-filter-custom input[type="date"] {
  width: auto;
  min-width: 130px;
  min-height: 34px;
  font-size: 12px;
  padding: 6px 10px;
}

.chart-filter-label {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-3);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

@media (max-width: 650px) {
  .chart-filter-bar {
    padding: 12px;
    gap: 10px;
  }
  .chart-filter-label {
    margin-left: 0;
    width: 100%;
  }
  .filter-pill {
    padding: 5px 11px;
    font-size: 11px;
  }
}

/* =========================================================
   EXPORT PAGE
========================================================= */

.export-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 750px) {
  .export-grid { grid-template-columns: 1fr; }
}

.export-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, transform 0.2s;
}

.export-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.export-card-icon {
  font-size: 28px;
  margin-bottom: 10px;
}

.export-card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 6px;
}

.export-card-sub {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.5;
  flex: 1;
}

/* =========================================================
   IMPORT PAGE
========================================================= */

.import-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.import-tab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.18s;
  min-height: 38px;
  width: auto;
  border-radius: 0;
}

.import-tab:hover { color: var(--text-1); }
.import-tab.active {
  color: var(--accent-purple);
  border-bottom-color: var(--accent-purple);
}

.import-panel {
  padding-top: 4px;
}

.import-dropzone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-2);
  margin-top: 16px;
}

.import-dropzone:hover,
.import-dropzone.drag-over {
  border-color: var(--accent-purple);
  background: var(--accent-purple-dim);
}

.import-dz-icon {
  font-size: 36px;
  margin-bottom: 10px;
  opacity: 0.7;
}

.import-dz-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 6px;
}

.import-dz-sub {
  font-size: 11px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
}

.import-status {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}

.import-status-success {
  background: var(--accent-buy-dim);
  color: var(--accent-buy);
  border: 1px solid rgba(0,200,150,0.25);
}

.import-status-error {
  background: var(--accent-loss-dim);
  color: var(--accent-loss);
  border: 1px solid rgba(255,92,122,0.25);
}

.import-csv-format {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-top: 8px;
}

.import-format-title {
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
}

.import-format-code {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--accent-sell);
  background: var(--bg-0);
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
  overflow-x: auto;
  white-space: nowrap;
}

.import-format-note {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.4;
}

@media (max-width: 650px) {
  .import-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .import-tab {
    white-space: nowrap;
    font-size: 12px;
    padding: 7px 12px;
  }
  .import-dropzone {
    padding: 28px 16px;
  }
}

/* Custom Settings Switches & Layout */
.switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.switch-row:last-child {
  border-bottom: none;
}
.switch-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 14px;
}
.switch-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
}
.switch-desc {
  font-size: 12px;
  color: var(--text-3);
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-3);
  border: 1px solid var(--border);
  transition: .2s;
  border-radius: 24px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 4px;
  bottom: 4px;
  background-color: var(--text-2);
  transition: .2s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--accent-purple-dim);
  border-color: var(--accent-purple);
}
input:checked + .slider:before {
  transform: translateX(20px);
  background-color: var(--accent-purple);
}

.settings-info-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.settings-info-row:last-child {
  border-bottom: none;
}
.settings-info-label {
  color: var(--text-2);
}
.settings-info-value {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-1);
}

/* Simulated Usage Limits Display */
.usage-bar-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}
.usage-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}
.usage-bar-label {
  color: var(--text-2);
}
.usage-bar-count {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}
.usage-bar-track {
  height: 6px;
  background: var(--bg-3);
  border-radius: 3px;
  overflow: hidden;
}
.usage-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Customers Section styles */
.customer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.customer-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.customer-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.customer-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-purple-dim);
  color: var(--accent-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}
.customer-card-info {
  flex: 1;
  min-width: 0;
}
.customer-card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.customer-card-meta {
  font-size: 11px;
  color: var(--text-3);
  display: flex;
  gap: 10px;
}
.customer-card-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-sell);
  flex-shrink: 0;
}

/* Customer Profile / Timeline Styles */
.customer-profile-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.btn-back {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-1);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-back:hover {
  background: var(--bg-3);
  border-color: var(--border-light);
}

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.timeline-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.timeline-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
}
.timeline-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--accent-sell);
}
.timeline-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-3);
}

/* Auth Overlay Glassmorphism card */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 16, 0.93);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
body.light-mode .auth-overlay {
  background: rgba(244, 246, 250, 0.93);
}
.auth-card {
  background: var(--bg-1);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: fadeIn 0.25s ease;
}
.auth-logo {
  text-align: center;
}
.auth-logo-title {
  font-size: 26px;
  font-weight: 800;
}
.auth-logo-title span {
  color: var(--accent-buy);
}
.auth-logo-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-3);
  margin-top: 4px;
  letter-spacing: 1.5px;
}
.auth-tabs {
  display: flex;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  padding: 4px;
  border: 1px solid var(--border);
}
.auth-tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.18s;
}
.auth-tab.active {
  background: var(--bg-4);
  color: var(--text-1);
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Dashboard Filter Pills */
.dash-filter-container {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.dash-pill {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 28px;
  width: auto;
}
.dash-pill:hover {
  border-color: var(--accent-profit);
  color: var(--accent-profit);
  background: var(--accent-profit-dim);
}
.dash-pill.active {
  background: var(--accent-profit-dim);
  border-color: var(--accent-profit);
  color: var(--accent-profit);
}

/* Inventory prefill Log actions */
.inv-action-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.inv-action-row button {
  flex: 1;
  min-height: 34px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

/* Settings user badge */
.settings-user-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.settings-user-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-purple-dim);
  color: var(--accent-purple);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.settings-user-details {
  display: flex;
  flex-direction: column;
}
.settings-user-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
}
.settings-user-role {
  font-size: 12px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
}

/* CUSTOM SELECT MENU */
.custom-select-container {
  position: relative;
  width: 100%;
}

.custom-select-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-1);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.2s, background 0.2s;
}

.custom-select-trigger:hover {
  border-color: var(--border-light);
  background: var(--bg-3);
}

.custom-select-container.open .custom-select-trigger {
  border-color: var(--accent-purple);
  background: var(--bg-3);
}

.select-arrow {
  font-size: 8px;
  color: var(--text-3);
  transition: transform 0.2s;
}

.custom-select-container.open .select-arrow {
  transform: rotate(180deg);
}

.custom-select-options {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-0-trans);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.custom-select-container.open .custom-select-options {
  display: block;
}

.custom-select-option {
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.custom-select-option:hover {
  background: var(--bg-4);
  color: var(--text-1);
}

.custom-select-option.active {
  background: var(--accent-purple-dim);
  color: var(--accent-purple);
  font-weight: 600;
}

/* SEGMENTED CONTROL */
.segmented-control {
  display: flex;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
  width: 100%;
}

.seg-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.seg-btn:hover {
  color: var(--text-1);
  background: rgba(255,255,255,0.03);
}

body.light-mode .seg-btn:hover {
  background: rgba(0,0,0,0.03);
}

.seg-btn.active {
  background: var(--accent-purple);
  color: var(--bg-1);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(180,138,255,0.3);
}

body.light-mode .seg-btn.active {
  color: #fff;
}

/* PAYMENT BREAKDOWN GRID */
.payment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.payment-amount-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-1);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.payment-amount-input:focus {
  border-color: var(--accent-buy);
  background: var(--bg-3);
}

/* PRODUCT SELECTOR TRIGGER */
.product-selector-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  color: var(--text-1);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.2s, background 0.2s;
}

.product-selector-trigger:hover {
  border-color: var(--border-light);
  background: var(--bg-3);
}

/* PRODUCT SELECT POPUP LIST */
.product-select-item {
  padding: 12px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.product-select-item:hover {
  border-color: var(--accent-purple);
  background: var(--bg-4);
  color: var(--text-1);
}

.product-select-item.active {
  background: var(--accent-purple-dim);
  border-color: var(--accent-purple);
  color: var(--accent-purple);
  font-weight: 600;
}

.product-select-empty {
  padding: 24px 0;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

/* SAVING OVERLAY */
.saving-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 11, 16, 0.85);
  backdrop-filter: blur(6px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  color: var(--text-1);
}

.saving-overlay.active {
  display: flex;
}

.saving-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(77, 159, 255, 0.15);
  border-left-color: var(--accent-buy);
  border-radius: 50%;
  animation: saving-spin 1s linear infinite;
}

@keyframes saving-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.saving-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Sidebar and Topbar Parity Buttons */
.sidebar-close-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}

.sidebar-close-btn:hover {
  color: var(--text-1);
}

@media (max-width: 650px) {
  .sidebar-close-btn {
    display: block;
  }
}

.topbar-back-btn:hover {
  background: var(--bg-3) !important;
}

/* Row Summary Mobile */
.row-summary-mobile {
  display: none;
}

@media (max-width: 767px) {
  .row-summary-mobile {
    display: flex;
  }
}