/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   RESET & BASE
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   THEME â€” light (default) / dark, Claude-inspired warm palette
   (dark mode is a warm charcoal, never pure black)
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
:root {
  --bg-page: #F7F6F2;
  --surface-1: #FFFFFF;
  --surface-2: #F3F1EA;
  --surface-3: #ECE9E0;
  --border: #E4E2D8;
  --border-strong: #D2CFC1;
  --text-primary: #1E1D1A;
  --text-secondary: #6B6A63;
  --text-muted: #9C9A90;
  --overlay: rgba(30, 29, 26, 0.45);
  --shadow: rgba(30, 29, 26, 0.08);
  
  --row-critical-bg: #fff5f5;
  --row-critical-text: #1f2937;
  --row-reorder-bg: #fffdf0;
  --row-reorder-text: #1f2937;
  --row-complete-bg: #f8fff8;
  --row-complete-text: #1f2937;
  
  color-scheme: light;
}

[data-theme="dark"] {
  --bg-page: #26241F;
  --surface-1: #2F2D27;
  --surface-2: #3A3831;
  --surface-3: #45423A;
  --border: #4C493F;
  --border-strong: #5E5A4E;
  --text-primary: #F2F0E8;
  --text-secondary: #BAB6A9;
  --text-muted: #8C887C;
  --overlay: rgba(0, 0, 0, 0.6);
  --shadow: rgba(0, 0, 0, 0.35);

  --row-critical-bg: transparent;
  --row-critical-text: var(--text-primary);
  --row-reorder-bg: transparent;
  --row-reorder-text: var(--text-primary);
  --row-complete-bg: transparent;
  --row-complete-text: var(--text-primary);

  color-scheme: dark;
}

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  background: var(--bg-page);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  transition: background 0.15s, color 0.15s;
}

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   LAYOUT
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
#app {
  display: flex;
  height: 100vh;
}

/* SIDEBAR — follows the active theme (same surfaces as the rest of the app) */
#sidebar {
  width: 210px;
  min-width: 210px;
  background: var(--surface-1);
  display: flex;
  flex-direction: column;
  padding: 0;
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.sidebar-brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .brand-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}
.sidebar-brand .brand-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 16px 16px 6px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
.sidebar-section:hover { color: var(--text-secondary); }
.section-chevron {
  font-size: 9px;
  transition: transform 0.2s;
  opacity: 0.7;
}
.sidebar-section.collapsed .section-chevron { transform: rotate(-90deg); }
.section-items { overflow: hidden; }
.section-items.collapsed { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  user-select: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item.active {
  background: var(--surface-3);
  color: var(--text-primary);
  border-left-color: #cc2222;
}
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-sub { padding-left: 30px; font-size: 12px; }
.nav-sublabel { padding: 8px 16px 3px 20px; font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-version {
  margin-bottom: 10px;
  font-size: 10px;
  color: var(--text-muted);
}

.sidebar-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  text-align: left;
}
.sidebar-btn:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.sidebar-btn-danger { border-color: rgba(204,34,34,0.35); }
.sidebar-btn-danger:hover {
  background: rgba(204,34,34,0.12);
  border-color: #cc2222;
  color: #cc2222;
}

/* MAIN CONTENT */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top-bar {
  background: var(--surface-1);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px var(--shadow);
}
.top-bar h2 { font-size: 17px; font-weight: 700; color: var(--text-primary); }
.top-bar .top-actions { display: flex; gap: 8px; align-items: center; }

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 3px 5px;
  margin-left: 12px;
}
.zoom-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-secondary);
  width: 26px;
  height: 26px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  line-height: 1;
}
.zoom-btn:hover { background: var(--surface-3); color: var(--text-primary); }
.zoom-btn:active { background: var(--border-strong); }
.zoom-reset { font-size: 13px; }
.zoom-level {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 38px;
  text-align: center;
  user-select: none;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   VIEWS (show/hide)
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.view { display: none; }
.view.active { display: block; }

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   BUTTONS
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: #cc2222; color: #fff; }
.btn-primary:hover { background: #aa1111; }
.btn-secondary { background: #1a1a2e; color: #fff; }
.btn-secondary:hover { background: #2a2a4e; }
.btn-outline { background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border-strong); }
.btn-outline:hover { background: var(--surface-2); }
.btn-danger { background: #ff4444; color: #fff; }
.btn-danger:hover { background: #dd2222; }
.btn-success { background: #22aa55; color: #fff; }
.btn-success:hover { background: #119944; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   CARDS
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.card {
  background: var(--surface-1);
  border-radius: 10px;
  box-shadow: 0 1px 4px var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.card-body { padding: 20px; }

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   DASHBOARD
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  color: #ffffff !important;
  box-shadow: 0 4px 12px var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: default;
}
.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px var(--shadow);
}
.kpi-card.gradient-blue   { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.kpi-card.gradient-green  { background: linear-gradient(135deg, #10b981, #047857); }
.kpi-card.gradient-orange { background: linear-gradient(135deg, #f59e0b, #b45309); }
.kpi-card.gradient-purple { background: linear-gradient(135deg, #8b5cf6, #5b21b6); }
.kpi-card.gradient-dark   { background: linear-gradient(135deg, #475569, #0f172a); }

.kpi-icon { font-size: 36px; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2)); }
.kpi-info { flex: 1; }
.kpi-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; opacity: 0.9; margin-bottom: 4px; }
.kpi-value { font-size: 24px; font-weight: 800; line-height: 1.1; margin-bottom: 4px; }
.kpi-sub { font-size: 12px; opacity: 0.8; font-weight: 500; }

.dash-middle-row { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 24px; }
.dash-bottom-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* 6 Month Trend Chart */
.chart-container {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 200px;
  gap: 12px;
  padding-top: 20px;
}
.chart-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
}
.chart-bar {
  width: 100%;
  max-width: 40px;
  background: linear-gradient(to top, #3b82f6, #60a5fa);
  border-radius: 6px 6px 0 0;
  min-height: 5px;
  transition: height 0.5s ease-out;
}
.chart-label {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
}
.chart-value-tooltip {
  font-size: 10px;
  color: var(--text-primary);
  font-weight: 700;
  margin-bottom: 4px;
}

/* Quick Actions */
.action-tile {
  background: var(--surface-1);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  cursor: pointer;
  transition: all 0.2s;
}
.action-tile:hover {
  border-color: #3b82f6;
  background: var(--surface-2);
  transform: translateX(4px);
}
.action-tile .at-icon { font-size: 24px; margin-right: 16px; }
.action-tile .at-text { font-size: 15px; font-weight: 700; color: var(--text-primary); }

/* Activity Tabs */
.activity-tabs {
  display: flex;
}
.activity-tab {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.activity-tab:hover { color: var(--text-primary); }
.activity-tab.active { color: #cc2222; border-bottom-color: #cc2222; }

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   FORMS
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.form-row {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--surface-1);
  transition: border-color 0.15s;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #cc2222;
  box-shadow: 0 0 0 3px rgba(204,34,34,0.08);
}

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   TABLES (data tables)
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  background: var(--surface-2);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }

/* Alert rows (critical/reorder/complete) */
.data-table tr.row-critical td { background: var(--row-critical-bg) !important; color: var(--row-critical-text) !important; }
.data-table tr.row-reorder  td { background: var(--row-reorder-bg) !important; color: var(--row-reorder-text) !important; }
.data-table tr.row-complete td { background: var(--row-complete-bg) !important; color: var(--row-complete-text) !important; }

/* Safety net: any row that sets its OWN inline background (a highlighted /
   total / alert row not using one of the classes above) forces its cells'
   text dark unless that cell already declares its own color. Covers
   one-off pale highlight rows scattered across the report/table renderers
   without needing to enumerate every hex value used for them. */
[data-theme="light"] .data-table tr[style*="background"] td:not([style*="color"]) { color: #1f2937 !important; }
.data-table tr:hover td { background: var(--surface-2); }
.data-table .td-actions { white-space: nowrap; }
.data-table .td-actions .btn { margin-right: 6px; }
.data-table .td-actions .btn:last-child { margin-right: 0; }
.data-table .td-right { text-align: right; font-family: monospace; }

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   INVOICE FORM
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.invoice-section {
  background: var(--surface-1);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px var(--shadow);
}
.invoice-section h4 {
  font-size: 13px;
  font-weight: 700;
  color: #cc2222;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f0e0e0;
}

/* Line items table â€” shared class for BOTH regular and tax invoice */
.items-wrapper { overflow-x: auto; }
.inv-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 580px;
}
.inv-table th {
  background: #1a1a2e;
  color: #fff;
  padding: 9px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.inv-table th:last-child { text-align: center; }
.inv-table td {
  padding: 4px 4px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.inv-table tr:hover td { background: var(--surface-2); }
.inv-table .col-no     { width: 44px; text-align: center; color: var(--text-secondary); font-size: 12px; }
.inv-table .col-desc   { min-width: 280px; }
.inv-table .col-qty    { width: 100px; }
.inv-table .col-price  { width: 130px; }
.inv-table .col-amount { width: 130px; }
.inv-table .col-del    { width: 40px; text-align: center; }

.inv-table input {
  width: 100%;
  border: 1px solid transparent;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 13px;
  background: transparent;
  font-family: inherit;
}
.inv-table input:focus {
  outline: none;
  border-color: #cc2222;
  background: var(--surface-1);
  box-shadow: 0 0 0 2px rgba(204,34,34,0.08);
}
.inv-table input.amount-display {
  background: var(--surface-2);
  color: var(--text-primary);
  font-weight: 600;
  cursor: default;
}
.inv-table input[type="number"] { text-align: right; }

/* Description / customer autocomplete
   Uses position:fixed + JS coordinates so it
   escapes any overflow:auto parent container */
.desc-wrapper { position: relative; }
.autocomplete-list {
  position: fixed;          /* JS will set top / left / width */
  background: var(--surface-1);
  border: 1.5px solid #cc2222;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 6px 24px var(--shadow);
  z-index: 9000;
  max-height: 220px;
  overflow-y: auto;
}
.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.autocomplete-item:hover { background: var(--surface-2); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item .ac-name { font-weight: 600; color: var(--text-primary); }
.autocomplete-item .ac-code { font-size: 11px; color: var(--text-secondary); }
.autocomplete-item .ac-price { font-size: 12px; color: #cc2222; font-weight: 700; }

/* Totals */
.totals-section {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}
.totals-table {
  width: 300px;
  border-collapse: collapse;
}
.totals-table td {
  padding: 7px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.totals-table .t-label { color: var(--text-secondary); }
.totals-table .t-value { text-align: right; font-family: monospace; font-weight: 600; color: var(--text-primary); }
.totals-table .grand-total td {
  background: #1a1a2e;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  border: none;
}
.totals-table .grand-total .t-value { color: #ffcccc; }

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   MODAL
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
  overflow-y: auto;
  padding: 24px 0;
}
.hidden { display: none !important; }
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface-1);
  border-radius: 12px;
  padding: 28px;
  width: 460px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px var(--shadow);
}
.modal h3 { font-size: 17px; font-weight: 800; margin-bottom: 20px; color: var(--text-primary); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   SEARCH BAR
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}
.search-bar input {
  flex: 1;
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface-1);
  color: var(--text-primary);
}
.search-bar input:focus { outline: none; border-color: #cc2222; }

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   BADGE / STATUS
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.badge-tax     { background: #ffe0e0; color: #cc2222; }
.badge-regular { background: #e0e8ff; color: #2244cc; }

/* Inline status badges in data tables (fixes line-wrap "folder" glitch) */
.data-table td span[style*="border-radius"] {
  display: inline-block;
  white-space: nowrap;
}

/* Dark mode overrides for hardcoded inline badge colors */
[data-theme="dark"] .data-table td span[style*="background:#f8d7da"] { background: #4a1919 !important; color: #ffb3b3 !important; border: 1px solid #802b2b !important; } /* Critical */
[data-theme="dark"] .data-table td span[style*="background:#fff3cd"] { background: #4a3f11 !important; color: #ffe885 !important; border: 1px solid #806b1d !important; } /* Reorder */
[data-theme="dark"] .data-table td span[style*="background:#d4edda"] { background: #133a1b !important; color: #9df2b2 !important; border: 1px solid #236b32 !important; } /* OK */
[data-theme="dark"] .data-table td span[style*="background:#fef3c7"] { background: #4a2e0a !important; color: #ffdc85 !important; border: 1px solid #805011 !important; } /* Breakable */
[data-theme="dark"] .data-table td span[style*="background:#e0f2fe"] { background: #0c3552 !important; color: #9cd5ff !important; border: 1px solid #165b8c !important; } /* Part */
[data-theme="dark"] .data-table td span[style*="background:#e0e8ff"] { background: #132454 !important; color: #a3b8ff !important; border: 1px solid #1f3b8a !important; } /* Service */
/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   HISTORY VIEW
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-bar input,
.filter-bar select {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface-1);
  color: var(--text-primary);
}
.filter-bar input:focus,
.filter-bar select:focus { outline: none; border-color: #cc2222; }

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   SETTINGS VIEW
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.setting-item {
  background: var(--surface-1);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 4px var(--shadow);
}
.setting-item label { display: block; font-size: 12px; font-weight: 700; color: var(--text-secondary); margin-bottom: 8px; text-transform: uppercase; }
.setting-item input { width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 6px; font-size: 14px; font-family: inherit; background: var(--surface-1); color: var(--text-primary); }

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   TOAST NOTIFICATION
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1a1a2e;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 9999;
  max-width: 320px;
}
#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { background: #22aa55; }
#toast.error   { background: #cc2222; }

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   PRINT STYLES  â€” This is what gets printed
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
#print-area { display: none; }

@media print {
  /* Hide the entire app */
  #app, #toast { display: none !important; }

  body {
    margin: 0;
    padding: 0;
    background: #fff;
    /* Real PDF uses Times New Roman 11pt throughout */
    font-family: 'Times New Roman', Times, serif;
    font-size: 11pt;
    color: #000;
  }

  /* Show only print area */
  #print-area {
    display: block !important;
    width: 100%;
    padding: 14mm 12mm 10mm;
    margin: 0;
    box-sizing: border-box;
  }

  /* â”€â”€â”€â”€â”€â”€â”€â”€ OUTER WRAPPER â”€â”€â”€â”€â”€â”€â”€â”€ */
  .pi-page {
    width: 100%;
    font-family: 'Times New Roman', Times, serif;
    font-size: 11pt;
    color: #000;
  }

  /* â”€â”€â”€â”€â”€â”€â”€â”€ HEADER BOX â”€â”€â”€â”€â”€â”€â”€â”€ */
  /* Single outer border â€” NO vertical divider inside */
  .pi-header {
    display: table;
    width: 100%;
    border: 1.5px solid #000;
    border-collapse: collapse;
  }
  .pi-header-left {
    display: table-cell;
    width: 57%;
    padding: 5px 10px 5px 7px;
    vertical-align: top;
    /* NO border-right â€” dividing line removed */
    box-sizing: border-box;
  }
  .pi-header-right {
    display: table-cell;
    width: 43%;
    padding: 3px 6px 3px 8px;
    vertical-align: middle;
    text-align: right;
    box-sizing: border-box;
  }

  /* Left side company info */
  .pi-co-name {
    font-weight: bold;
    font-size: 11pt;
    margin-bottom: 1px;
  }
  .pi-co-addr {
    font-size: 11pt;
    line-height: 1.45;
  }

  /* Full logo image â€” height drives scale, width follows aspect ratio */
  .pi-logo-full {
    height: 30mm;
    width: auto;
    display: block;
    margin-left: auto;  /* right-align within the cell */
  }

  /* â”€â”€â”€â”€â”€â”€â”€â”€ TAX INVOICE TITLE â”€â”€â”€â”€â”€â”€â”€â”€ */
  .pi-title {
    text-align: center;
    font-size: 11pt;
    font-weight: bold;
    padding: 10px 0 8px;
    font-family: 'Times New Roman', Times, serif;
  }
  .pi-title-gap {
    height: 8px;
  }

  /* â”€â”€â”€â”€â”€â”€â”€â”€ META FIELDS (no border) â”€â”€â”€â”€â”€â”€â”€â”€ */
  .pi-meta-tbl {
    width: 100%;
    border-collapse: collapse;
    margin: 6px 0 4px;
  }
  .pi-meta-left {
    width: 52%;
    padding: 0 10px 0 0;
    vertical-align: top;
  }
  .pi-meta-right {
    width: 48%;
    padding: 0 0 0 6px;
    vertical-align: top;
  }
  .pi-fields {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
  }
  .pi-fields tr td {
    padding: 6px 2px;
    font-size: 11pt;
    line-height: 1.4;
    font-family: 'Times New Roman', Times, serif;
    vertical-align: bottom;
  }
  .pi-fl {
    white-space: nowrap;
    font-size: 11pt;
    width: 88px;
  }
  .pi-fc {
    padding: 0 3px;
    width: 10px;
    font-size: 11pt;
    white-space: nowrap;
  }
  /* Dotted field value â€” border-bottom spans full remaining cell width */
  .pi-fd {
    font-size: 11pt;
    border-bottom: 1px dotted #000;
    width: auto;
  }
  .pi-fd-plain {
    font-size: 11pt;
    font-weight: bold;
    padding-left: 3px;
  }
  .pi-fv {
    display: inline-block;
    font-weight: bold;
    font-family: 'Times New Roman', Times, serif;
    padding-bottom: 1px;
    margin-bottom: -1px;
  }

  /* â”€â”€â”€â”€â”€â”€â”€â”€ ITEMS TABLE â”€â”€â”€â”€â”€â”€â”€â”€ */
  .pi-items {
    width: 100%;
    border-collapse: collapse;
    border: 1.5px solid #000;   /* same as cells â€” uniform thickness */
    margin-top: 14px;
  }
  .pi-items th, .pi-items td {
    border: 1.5px solid #000;   /* inner and outer all 1.5px â€” consistent */
    padding: 4px 6px;
    font-size: 11pt;
    font-family: 'Times New Roman', Times, serif;
  }
  .pi-items thead tr th {
    text-align: center;
    font-weight: bold;
    background: #fff;
    padding: 5px 6px;
  }
  .pi-no    { text-align: center; width: 28px; }
  .pi-desc  { text-align: left; }
  .pi-qty   { text-align: center; width: 68px; }
  .pi-price { text-align: right;  width: 88px; }
  .pi-amt   { text-align: right;  width: 88px; }

  /* Empty rows â€” full grid matching real invoice */
  .pi-row-empty td {
    height: 22px;
    border: 1.5px solid #000;
  }

  /* Total rows */
  .pi-no-border { border: none !important; }
  .pi-total-label {
    text-align: left;           /* left-aligned like the real invoice */
    font-weight: normal;
    padding-left: 6px;
    padding-right: 4px;
    border: 1.5px solid #000;
    white-space: nowrap;
    font-size: 11pt;
    font-family: 'Times New Roman', Times, serif;
  }
  .pi-total-val {
    text-align: right;
    border: 1.5px solid #000;
    width: 90px;
    padding-right: 6px;
    font-size: 11pt;
    font-family: 'Times New Roman', Times, serif;
  }
  .pi-grand-label { font-weight: bold; }
  .pi-grand-val   { font-weight: bold; }

  /* â”€â”€â”€â”€â”€â”€â”€â”€ BANK DETAILS â”€â”€â”€â”€â”€â”€â”€â”€ */
  .pi-bank {
    margin-top: 10px;
    font-size: 11pt;
    line-height: 1.65;
    font-family: 'Times New Roman', Times, serif;
  }
  .pi-bank-title {
    font-weight: bold;
    text-decoration: underline;
    font-size: 11pt;
    margin-bottom: 1px;
  }
  .pi-bank-table {
    border-collapse: collapse;
    font-size: 11pt;
    font-family: 'Times New Roman', Times, serif;
  }
  .pi-bank-table td {
    padding: 0 4px 1px 0;
    vertical-align: top;
    font-size: 11pt;
    font-family: 'Times New Roman', Times, serif;
  }
  .pi-bank-table .pi-bk-label {
    white-space: nowrap;
    font-weight: normal;
    padding-right: 2px;
  }
  .pi-bank-table .pi-bk-colon {
    padding: 0 4px;
    width: 6px;
  }
  .pi-bank-row {
    font-size: 11pt;
  }

  /* â”€â”€â”€â”€â”€â”€â”€â”€ RECEIVED LINE â”€â”€â”€â”€â”€â”€â”€â”€ */
  .pi-received {
    margin-top: 12px;
    font-size: 11pt;
    font-family: 'Times New Roman', Times, serif;
  }

  /* â”€â”€â”€â”€â”€â”€â”€â”€ SIGNATURES â”€â”€â”€â”€â”€â”€â”€â”€ */
  .pi-sigs {
    display: flex;
    justify-content: space-between;
    margin-top: 52px;
    padding: 0 10px;
    align-items: flex-end;
  }
  .pi-sig {
    text-align: center;
    min-width: 140px;
    padding-top: 16px;
  }
  .pi-sig-dots {
    font-size: 11pt;
    font-family: 'Times New Roman', Times, serif;
    margin-bottom: 5px;
    letter-spacing: 1px;
  }
  .pi-sig-lbl {
    font-size: 11pt;
    font-family: 'Times New Roman', Times, serif;
    margin-top: 2px;
  }

  /* margin:0 suppresses browser-injected URL/date/page-number headers */
  @page {
    margin: 0;
  }
}

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   ROLE-BASED ACCESS CONTROL
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
/* Staff users cannot see delete buttons or admin-only controls */
body:not(.is-admin) .del-btn { display: none !important; }
body:not(.is-admin) [data-admin-only] { display: none !important; }

/* Developer-only controls (e.g. Users management) — admin role only,
   hidden even from subadmin despite subadmin sharing admin's delete rights */
body:not(.role-admin) [data-developer-only] { display: none !important; }

/* Subadmin (MD / Accountant): same access as admin except Accounts,
   which is still under development */
body.role-subadmin [data-section="accounts"],
body.role-subadmin #section-accounts { display: none !important; }

/* Executive: Stocking + Sales only — Ordering, Costing, Accounts and
   Settings are hidden. (Products keeps working via the Costing-nested
   Products screen's underlying API even though its nav link is hidden,
   since Stocking/Sales views depend on the shared product list.) */
body.role-executive [data-section="ordering"], body.role-executive #section-ordering,
body.role-executive [data-section="costing"],  body.role-executive #section-costing,
body.role-executive [data-section="accounts"], body.role-executive #section-accounts,
body.role-executive .nav-item[data-view="settings"],
body.role-executive [data-restricted-section] { display: none !important; }

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   DARK MODE OVERRIDES for dynamically-rendered report/dashboard
   HTML (costing.js, order-report.js, grn.js, etc.) that use
   inline hex colors baked in at render time. These attribute
   selectors only match literal color tokens that are exclusively
   used as text / panel-background / border colors in this app's
   JS (verified before adding). Print popups are separate
   `window.open()` documents with no `data-theme` attribute and
   no link to this stylesheet, so they are completely unaffected.
â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */
[data-theme="dark"] [style*="color:#1a1a2e"],
[data-theme="dark"] [style*="color: #1a1a2e"],
[data-theme="dark"] [style*="color:#333"],
[data-theme="dark"] [style*="color: #333"],
[data-theme="dark"] [style*="color:#111"],
[data-theme="dark"] [style*="color: #111"],
[data-theme="dark"] [style*="color:#000"],
[data-theme="dark"] [style*="color: #000"] { color: var(--text-primary) !important; }

[data-theme="dark"] [style*="color:#555"],
[data-theme="dark"] [style*="color: #555"],
[data-theme="dark"] [style*="color:#666"],
[data-theme="dark"] [style*="color: #666"],
[data-theme="dark"] [style*="color:#888"],
[data-theme="dark"] [style*="color: #888"],
[data-theme="dark"] [style*="color:#444"],
[data-theme="dark"] [style*="color: #444"],
[data-theme="dark"] [style*="color:#777"],
[data-theme="dark"] [style*="color: #777"] { color: var(--text-secondary) !important; }

[data-theme="dark"] [style*="color:#aaa"],
[data-theme="dark"] [style*="color: #aaa"],
[data-theme="dark"] [style*="color:#999"],
[data-theme="dark"] [style*="color: #999"],
[data-theme="dark"] [style*="color:#bbb"],
[data-theme="dark"] [style*="color: #bbb"],
[data-theme="dark"] [style*="color:#ccc"],
[data-theme="dark"] [style*="color: #ccc"] { color: var(--text-muted) !important; }

/* Anchored on ";" or end-of-string so "#fff" (pure white) never matches
   near-white TINTED colors like #fffbeb, #fff3cd, #fff5f5, #fff7ed, #fff0f0
   (pale alert/status backgrounds elsewhere in the app that must stay literal). */
[data-theme="dark"] [style*="background:#fff;"],
[data-theme="dark"] [style*="background: #fff;"],
[data-theme="dark"] [style*="background-color:#fff;"],
[data-theme="dark"] [style*="background-color: #fff;"],
[data-theme="dark"] [style$="background:#fff"],
[data-theme="dark"] [style$="background: #fff"],
[data-theme="dark"] [style$="background-color:#fff"],
[data-theme="dark"] [style$="background-color: #fff"] { background: var(--surface-1) !important; }

[data-theme="dark"] [style*="background:#f5f6fb"],
[data-theme="dark"] [style*="background: #f5f6fb"],
[data-theme="dark"] [style*="background:#f3f4f6"],
[data-theme="dark"] [style*="background: #f3f4f6"],
[data-theme="dark"] [style*="background:#f5f5f5"],
[data-theme="dark"] [style*="background: #f5f5f5"],
[data-theme="dark"] [style*="background:#f9fafb"],
[data-theme="dark"] [style*="background: #f9fafb"],
[data-theme="dark"] [style*="background:#f0f0f0"],
[data-theme="dark"] [style*="background: #f0f0f0"],
[data-theme="dark"] [style*="background:#eee"],
[data-theme="dark"] [style*="background: #eee"],
[data-theme="dark"] [style*="background:#fafafa"],
[data-theme="dark"] [style*="background: #fafafa"],
[data-theme="dark"] [style*="background:#fafbff"],
[data-theme="dark"] [style*="background: #fafbff"],
[data-theme="dark"] [style*="background:#f8f9ff"],
[data-theme="dark"] [style*="background: #f8f9ff"],
[data-theme="dark"] [style*="background:#fafbfe"],
[data-theme="dark"] [style*="background: #fafbfe"] { background: var(--surface-2) !important; }

[data-theme="dark"] [style*="#dde0ee"],
[data-theme="dark"] [style*="#e0e3f0"],
[data-theme="dark"] [style*="#e5e7f0"],
[data-theme="dark"] [style*="#f0f0f8"],
[data-theme="dark"] [style*="#f0f1f6"],
[data-theme="dark"] [style*="#e5e7eb"],
[data-theme="dark"] [style*="#d1d5db"],
[data-theme="dark"] [style*="#f0e0e0"] { border-color: var(--border) !important; }

/* COSTING CALCULATOR DARK MODE OVERRIDES */
[data-theme="dark"] [style*="background:#eff6ff"],
[data-theme="dark"] [style*="background:#f5f3ff"],
[data-theme="dark"] [style*="background:#fff7ed"],
[data-theme="dark"] [style*="background:#f0fdf4"],
[data-theme="dark"] [style*="background:#f5f6fb"],
[data-theme="dark"] [style*="background:#f9f9f9"],
[data-theme="dark"] [style*="background:#c2410c20"] {
  background: transparent !important;
}

[data-theme="dark"] [style*="color:#7c3aed"] { color: #a78bfa !important; } /* Flat (Purple) */
[data-theme="dark"] [style*="color:#c2410c"] { color: #fb923c !important; } /* Customs (Orange) */
[data-theme="dark"] [style*="color:#15803d"] { color: #4ade80 !important; } /* Landed (Green) */
[data-theme="dark"] [style*="color:#0f766e"] { color: #2dd4bf !important; } /* Per Unit (Teal) */
[data-theme="dark"] [style*="color:#1d4ed8"] { color: #60a5fa !important; } /* CID (Blue) */
[data-theme="dark"] [style*="color:#065f46"] { color: #34d399 !important; } /* VAT (Dark Green) */

/* Dark Mode Overrides for Gradients */
[data-theme="dark"] .kpi-card.gradient-blue { background: linear-gradient(135deg, #1e3a8a, #172554); border: 1px solid #1e40af; }
[data-theme="dark"] .kpi-card.gradient-green { background: linear-gradient(135deg, #064e3b, #022c22); border: 1px solid #065f46; }
[data-theme="dark"] .kpi-card.gradient-orange { background: linear-gradient(135deg, #78350f, #451a03); border: 1px solid #9a3412; }
[data-theme="dark"] .kpi-card.gradient-purple { background: linear-gradient(135deg, #4c1d95, #2e1065); border: 1px solid #5b21b6; }
[data-theme="dark"] .kpi-card.gradient-dark { background: linear-gradient(135deg, #1e293b, #0f172a); border: 1px solid #334155; }

