/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f1117;
  --bg-surface: #1a1d27;
  --bg-card: #20243a;
  --bg-hover: #252940;
  --border: #2d3155;
  --accent: #6c63ff;
  --accent-light: #8b84ff;
  --accent-glow: rgba(108,99,255,0.2);
  --green: #22c55e;
  --green-bg: rgba(34,197,94,0.12);
  --orange: #f97316;
  --orange-bg: rgba(249,115,22,0.12);
  --blue: #3b82f6;
  --blue-bg: rgba(59,130,246,0.12);
  --purple: #a855f7;
  --purple-bg: rgba(168,85,247,0.12);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.12);
  --yellow: #eab308;
  --text: #e8eaf0;
  --text-secondary: #8b93b0;
  --text-muted: #5a6280;
  --sidebar-w: 240px;
  --topbar-h: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
}
html { scroll-behavior: smooth; }
body {
  font-family: 'Noto Sans HK', 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  font-size: 28px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  padding: 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
}
.brand-name {
  display: block;
  font-size: 16px;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent-light), #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-sub {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.5px;
}

.nav-menu {
  list-style: none;
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  color: var(--text-secondary);
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent-light);
  font-weight: 600;
  border: 1px solid rgba(108,99,255,0.3);
}
.nav-icon { font-size: 18px; width: 22px; text-align: center; }
.nav-label { flex: 1; font-size: 13.5px; }
.nav-badge {
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}
.nav-badge.warning { background: var(--orange); }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-muted); }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.menu-toggle:hover { background: var(--bg-hover); }
.page-title { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  transition: all var(--transition);
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-box input {
  background: none;
  border: none;
  color: var(--text);
  width: 200px;
  outline: none;
  font-size: 13px;
  font-family: inherit;
}
.search-box input::placeholder { color: var(--text-muted); }
.topbar-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  transition: all var(--transition);
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.topbar-btn:hover { border-color: var(--accent); color: var(--accent-light); }
.notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--red);
  border-radius: 50%;
  border: 1.5px solid var(--bg-surface);
}

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

/* ===== WELCOME BANNER ===== */
.welcome-banner {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e3a5f 100%);
  border: 1px solid rgba(108,99,255,0.3);
  border-radius: var(--radius);
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.welcome-banner::after {
  content: '🍜';
  position: absolute;
  right: 120px; top: 50%;
  transform: translateY(-50%);
  font-size: 80px;
  opacity: 0.08;
}
.welcome-banner h1 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.welcome-banner p { color: #a5b4fc; font-size: 13.5px; }
.welcome-banner strong { color: #fbbf24; }

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon.green { background: var(--green-bg); }
.stat-icon.blue { background: var(--blue-bg); }
.stat-icon.orange { background: var(--orange-bg); }
.stat-icon.purple { background: var(--purple-bg); }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin: 3px 0; }
.stat-change { font-size: 11px; font-weight: 600; }
.stat-change.positive { color: var(--green); }
.stat-change.negative { color: var(--orange); }

/* ===== DASHBOARD LAYOUT ===== */
.dash-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}
.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-header h3 { font-size: 15px; font-weight: 700; }
.month-tag {
  background: var(--blue-bg);
  color: var(--blue);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
}
.btn-link {
  background: none;
  border: none;
  color: var(--accent-light);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  padding: 0;
  transition: color var(--transition);
}
.btn-link:hover { color: white; }

/* ===== TABLES ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 12px 12px;
  border-bottom: 1px solid rgba(45,49,85,0.5);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.order-id { font-family: 'Inter', monospace; color: var(--accent-light); font-weight: 600; }
.full-table { background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.full-table th:first-child { padding-left: 20px; }
.full-table td:first-child { padding-left: 20px; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.badge.pending { background: var(--orange-bg); color: var(--orange); }
.badge.delivered { background: var(--blue-bg); color: var(--blue); }
.badge.paid { background: var(--green-bg); color: var(--green); }
.badge.info { background: rgba(139,147,176,0.15); color: var(--text-secondary); }
.badge.overdue { background: var(--red-bg); color: var(--red); }

/* ===== PRODUCT RANK ===== */
.product-rank-list { display: flex; flex-direction: column; gap: 12px; }
.rank-item { display: flex; align-items: center; gap: 10px; }
.rank-num {
  width: 24px; height: 24px;
  background: var(--bg-surface);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.rank-num.rank-1 { background: linear-gradient(135deg,#fbbf24,#f59e0b); color: white; }
.rank-num.rank-2 { background: linear-gradient(135deg,#94a3b8,#64748b); color: white; }
.rank-num.rank-3 { background: linear-gradient(135deg,#c2956b,#a97c50); color: white; }
.rank-info { flex: 1; }
.rank-name { font-size: 12.5px; margin-bottom: 4px; }
.rank-bar-wrap { background: var(--bg-surface); border-radius: 4px; height: 5px; overflow: hidden; }
.rank-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--purple)); border-radius: 4px; transition: width 1s ease; }
.rank-qty { font-size: 12px; color: var(--text-secondary); font-weight: 600; white-space: nowrap; }

/* ===== DELIVERY LIST ===== */
.delivery-list { display: flex; flex-direction: column; gap: 10px; }
.delivery-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  transition: all var(--transition);
}
.delivery-item:hover { border-color: var(--accent); }
.delivery-time { font-weight: 700; font-size: 13px; color: var(--accent-light); min-width: 44px; }
.delivery-info { flex: 1; }
.delivery-client { font-weight: 600; font-size: 13.5px; }
.delivery-addr { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.delivery-items { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }

/* ===== PAGE TOOLBAR ===== */
.page-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
}
.filter-group { display: flex; gap: 10px; }
.select-input, .search-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.select-input:focus, .search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-input { width: 220px; }

/* ===== PRODUCT CARDS ===== */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--accent); }
.product-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--purple));
}
.pc-cat {
  display: inline-block;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 10px;
  font-weight: 600;
}
.cat-醬料 { background: var(--orange-bg); color: var(--orange); }
.cat-椰奶飲品 { background: var(--blue-bg); color: var(--blue); }
.cat-米麵 { background: var(--green-bg); color: var(--green); }
.cat-即食湯底 { background: var(--purple-bg); color: var(--purple); }
.cat-冷凍 { background: rgba(56,189,248,0.12); color: #38bdf8; }
.pc-name { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.pc-name-en { font-size: 11px; color: var(--text-muted); margin-bottom: 12px; }
.pc-id { font-size: 11px; color: var(--text-muted); font-family: 'Inter', monospace; }
.pc-divider { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.pc-prices {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.pc-cost { font-size: 11px; color: var(--text-muted); }
.pc-cost span { color: var(--text-secondary); }
.pc-sell { text-align: right; }
.pc-sell-label { font-size: 10px; color: var(--text-muted); }
.pc-sell-price { font-size: 18px; font-weight: 800; color: var(--green); }
.pc-unit { font-size: 11px; color: var(--text-muted); }
.pc-stock { margin-top: 10px; font-size: 12px; }
.pc-stock .stock-ok { color: var(--green); }
.pc-stock .stock-low { color: var(--orange); }
.pc-margin {
  position: absolute;
  top: 12px; right: 14px;
  background: var(--green-bg);
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

/* ===== EXCEL-STYLE PRODUCT TABLE ===== */
.excel-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  max-height: calc(100vh - 180px);
  position: relative;
}
.excel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 900px;
}
.excel-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}
.excel-table th {
  background: #1e2240;
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 14px;
  text-align: left;
  border-bottom: 2px solid var(--accent);
  border-right: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  user-select: none;
}
.excel-table th:hover { background: var(--bg-hover); color: var(--text); }
.excel-table th:last-child { border-right: none; cursor: default; }
.sort-icon { font-size: 10px; opacity: 0.5; margin-left: 4px; }
.excel-table th:hover .sort-icon { opacity: 1; }

.excel-row td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(45,49,85,0.5);
  border-right: 1px solid rgba(45,49,85,0.3);
  vertical-align: middle;
  transition: background var(--transition);
}
.excel-row td:last-child { border-right: none; }
.excel-row:hover td { background: var(--bg-hover); }
.excel-row:nth-child(even) td { background: rgba(255,255,255,0.02); }
.excel-row:nth-child(even):hover td { background: var(--bg-hover); }
.excel-row:last-child td { border-bottom: none; }

/* Column types */
.col-sticky {
  position: sticky;
  left: 0;
  background: var(--bg-card);
  z-index: 5;
  border-right: 2px solid var(--border) !important;
}
.excel-row:hover .col-sticky { background: var(--bg-hover); }
.excel-table thead th.col-sticky { background: #1e2240; z-index: 11; }

.excel-id {
  font-family: 'Inter', monospace;
  font-size: 12px;
  color: var(--accent-light);
  font-weight: 700;
  white-space: nowrap;
}
.excel-name { font-weight: 600; color: var(--text); }
.excel-en { color: var(--text-muted); font-size: 12px; }
.excel-center { text-align: center; color: var(--text-secondary); }
.excel-num { text-align: right; font-family: 'Inter', monospace; font-weight: 600; white-space: nowrap; }
.excel-sell { color: var(--green); font-size: 14px; }

.excel-margin-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.excel-margin-badge {
  background: var(--green-bg);
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}
.excel-profit { font-size: 11px; color: var(--text-muted); }

/* Stock color coding */
.stock-cell-ok { color: var(--green); }
.stock-cell-warn { color: var(--yellow); }
.stock-cell-low { color: var(--red); font-weight: 700; }

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-light); transform: translateY(-1px); box-shadow: 0 4px 12px var(--accent-glow); }
.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--text-secondary); }
.btn-outline {
  background: transparent;
  color: var(--accent-light);
  border-color: var(--accent);
}
.btn-outline:hover { background: var(--accent-glow); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  font-size: 15px;
  transition: background var(--transition);
}
.btn-icon:hover { background: var(--bg-hover); }
.btn-icon.danger:hover { background: var(--red-bg); }

/* ===== MODALS ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: slideUp 0.25s ease;
}
.modal.large { max-width: 800px; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ===== FORM CONTROLS ===== */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form-row .form-group { margin-bottom: 0; }
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 60px; }
.form-control-sm {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
  width: 100%;
  transition: border-color var(--transition);
}
.form-control-sm:focus { border-color: var(--accent); }

/* ===== ORDER MODAL ===== */
.order-items-section { margin-top: 20px; }
.order-items-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.order-items-header h4 { font-size: 13.5px; font-weight: 700; }
.order-items-table th { font-size: 11px; padding: 8px 10px; }
.order-items-table td { padding: 8px 10px; }
.subtotal-cell { font-weight: 700; color: var(--green); }
.order-totals {
  margin-top: 12px;
  text-align: right;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.total-row { display: flex; justify-content: flex-end; gap: 20px; padding: 3px 0; color: var(--text-secondary); font-size: 13px; }
.total-row span:last-child { min-width: 80px; text-align: right; font-weight: 600; color: var(--text); }
.total-final { font-size: 16px; font-weight: 800; color: var(--green); border-top: 1px solid var(--border); padding-top: 8px; margin-top: 6px; }
.total-final span { color: var(--green) !important; }

/* ===== INVOICE PREVIEW ===== */
.invoice-preview {
  background: white;
  color: #1a1a2e;
  padding: 32px;
  border-radius: var(--radius-sm);
}
.invoice-header { display: flex; justify-content: space-between; margin-bottom: 28px; }
.invoice-logo { font-size: 22px; font-weight: 800; color: #4c1d95; margin-bottom: 6px; }
.invoice-company { font-size: 12.5px; color: #4b5563; line-height: 1.8; }
.invoice-type {
  font-size: 22px;
  font-weight: 800;
  color: #4c1d95;
  text-align: right;
  margin-bottom: 10px;
}
.invoice-meta-table td { font-size: 12.5px; padding: 2px 6px; color: #374151; }
.invoice-bill-to {
  background: #f3f4f6;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 24px;
  font-size: 12.5px;
  color: #374151;
  line-height: 1.8;
}
.bill-label { font-size: 11px; color: #9ca3af; font-weight: 700; text-transform: uppercase;margin-bottom: 4px; }
.bill-name { font-size: 16px; font-weight: 700; color: #1a1a2e; }
.invoice-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 12.5px;
}
.invoice-items-table th {
  background: #4c1d95;
  color: white;
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
}
.invoice-items-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  color: #374151;
}
.invoice-items-table tbody tr:nth-child(even) td { background: #f9fafb; }
.invoice-items-table small { color: #9ca3af; display: block; }
.invoice-totals { text-align: right; margin-bottom: 20px; }
.inv-total-row { display: flex; justify-content: flex-end; gap: 30px; padding: 3px 0; font-size: 12.5px; color: #6b7280; }
.inv-grand-total { font-size: 16px; font-weight: 800; color: #1a1a2e; border-top: 2px solid #4c1d95; padding-top: 8px; margin-top: 6px; }
.invoice-footer { background: #f3f4f6; border-radius: 8px; padding: 12px 16px; font-size: 11.5px; color: #6b7280; line-height: 1.8; }

/* ===== PAYMENTS ===== */
.ar-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.ar-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  transition: all var(--transition);
}
.ar-card:hover { border-color: var(--accent); }
.ar-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; font-weight: 600; }
.ar-value { font-size: 26px; font-weight: 800; }
.ar-value.danger { color: var(--red); }
.ar-value.warning { color: var(--yellow); }
.ar-value.success { color: var(--green); }
.invoice-checklist { display: flex; flex-direction: column; gap: 8px; }
.check-item { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

/* ===== REPORTS ===== */
.reports-tabs { display: flex; gap: 4px; margin-bottom: 20px; background: var(--bg-card); padding: 4px; border-radius: var(--radius-sm); width: fit-content; border: 1px solid var(--border); }
.tab-btn { background: none; border: none; color: var(--text-secondary); font-family: inherit; font-size: 13.5px; font-weight: 600; padding: 7px 16px; border-radius: 6px; cursor: pointer; transition: all var(--transition); }
.tab-btn.active { background: var(--accent); color: white; }
.tab-btn:hover:not(.active) { color: var(--text); }
.report-filters { display: flex; gap: 10px; margin-bottom: 20px; }
.report-summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 24px; }
.report-summary-item { background: var(--bg-surface); border-radius: var(--radius-sm); padding: 14px; text-align: center; border: 1px solid var(--border); }
.rs-label { font-size: 11px; color: var(--text-secondary); margin-bottom: 6px; }
.rs-value { font-size: 18px; font-weight: 800; }
.rs-value.success { color: var(--green); }
.mini-bar-wrap { display: flex; align-items: center; gap: 8px; }
.mini-bar { height: 6px; background: linear-gradient(90deg, var(--accent), var(--purple)); border-radius: 3px; }
.mini-bar-wrap span { font-size: 12px; color: var(--text-secondary); font-weight: 600; }

/* ===== DELIVERY CARDS ===== */
.delivery-cards { display: flex; flex-direction: column; gap: 16px; }
.delivery-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all var(--transition);
}
.delivery-card:hover { border-color: var(--accent); }
.dc-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.dc-title { font-size: 15px; font-weight: 700; }
.dc-meta { color: var(--text-secondary); font-size: 12.5px; margin-bottom: 12px; display: flex; gap: 16px; }
.dc-items table { width: 100%; font-size: 12.5px; }
.dc-items th { background: var(--bg-surface); padding: 6px 10px; font-size: 11px; font-weight: 600; }
.dc-items td { padding: 6px 10px; border-top: 1px solid rgba(45,49,85,0.4); }
.dc-footer { margin-top: 14px; display: flex; gap: 10px; justify-content: flex-end; }

/* ===== CHART ===== */
canvas { display: block; margin: 0 auto; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ===== ACTION BUTTONS IN TABLE ===== */
.action-btns { display: flex; gap: 6px; }
.action-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
}
.action-btn:hover { border-color: var(--accent); color: var(--accent-light); }
.action-btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.action-btn.primary:hover { background: var(--accent-light); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .dash-row { flex-direction: column; }
  .search-box { display: none; }
  .ar-summary { grid-template-columns: 1fr; }
  .report-summary-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page { padding: 16px; }
  .topbar { padding: 0 16px; }
  .welcome-banner { flex-direction: column; gap: 14px; }
}
