:root {
  --primary: #FF6B00;
  --primary-dark: #e05a00;
  --primary-light: #fff3eb;
  --primary-lighter: #fff8f3;
  --bg: #f5f6fa;
  --bg2: #eceef5;
  --sidebar-bg: #1a1d2e;
  --sidebar-hover: #2a2e45;
  --sidebar-active: #FF6B00;
  --card-bg: #ffffff;
  --text: #1a1d2e;
  --text-muted: #8b8fa8;
  --text-light: #c4c6d4;
  --border: #e8eaf0;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.13);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;

  --state-new: #3b82f6;
  --state-packing: #f59e0b;
  --state-ready: #10b981;
  --state-transit: #8b5cf6;
  --state-delivered: #059669;
  --state-cancelled: #ef4444;

  --status-on_sale: #10b981;
  --status-on_review: #f59e0b;
  --status-require_corrections: #ef4444;
  --status-removed_from_sale: #6b7280;
  --status-deleted: #374151;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

/* ===== LOGIN ===== */
.login-page {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #FF6B00 0%, #ff9248 40%, #ffb380 100%);
  padding: 16px;
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}

.login-logo h1 { font-size: 20px; font-weight: 700; color: var(--text); }
.login-logo p { font-size: 12px; color: var(--text-muted); }

.login-form { display: flex; flex-direction: column; gap: 16px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-group input {
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  transition: border-color 0.2s;
  outline: none;
}
.form-group input:focus { border-color: var(--primary); }

.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-family: var(--font);
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; }
.btn-warning { background: #f59e0b; color: white; }
.btn-warning:hover { background: #d97706; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; }
.btn-icon { background: var(--bg); color: var(--text-muted); padding: 8px; border-radius: var(--radius-sm); border: none; cursor: pointer; }
.btn-icon:hover { background: var(--border); color: var(--text); }

/* ===== APP LAYOUT ===== */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.25s ease;
  overflow: hidden;
  z-index: 100;
}
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .partner-info .partner-avatar + div,
.sidebar.collapsed .nav-item span:not(.nav-icon),
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .sidebar-footer span { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px; }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand { flex: 1; }
.brand-name { display: block; color: white; font-weight: 700; font-size: 15px; }
.brand-sub { display: block; color: rgba(255,255,255,0.45); font-size: 11px; }
.sidebar-toggle { background: none; border: none; color: rgba(255,255,255,0.5); cursor: pointer; font-size: 18px; padding: 2px; }

.partner-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.partner-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 16px;
  flex-shrink: 0;
}
.partner-name { color: white; font-size: 13px; font-weight: 600; }
.partner-badge {
  background: rgba(255,107,0,0.2);
  color: var(--primary);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 600;
  display: inline-block;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  position: relative;
  white-space: nowrap;
}
.nav-item:hover { background: var(--sidebar-hover); color: white; }
.nav-item.active { background: var(--primary); color: white; }
.nav-item.active .nav-icon { fill: white; }

.nav-icon { width: 20px; height: 20px; fill: currentColor; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}
.notif-badge { background: var(--primary); }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.btn-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: all 0.2s;
  font-family: var(--font);
}
.btn-logout:hover { background: rgba(239,68,68,0.15); color: #ef4444; }

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

.top-bar {
  height: var(--topbar-h);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 14px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
  z-index: 50;
}
.hamburger { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); display: none; }
.top-bar-title { font-size: 17px; font-weight: 700; flex: 1; }
.top-bar-actions { display: flex; align-items: center; gap: 10px; }
.top-bar-user { display: flex; align-items: center; gap: 8px; }
.user-avatar { width: 34px; height: 34px; background: var(--primary); color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }

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

/* ===== PAGE ===== */
.page { display: none; }
.page.active { display: block; }

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.section-header h2 { font-size: 20px; font-weight: 700; }
.text-muted { color: var(--text-muted); }

/* ===== CARDS ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-header h3 { font-size: 15px; font-weight: 700; }

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
  transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-new { border-left-color: var(--state-new); }
.stat-packing { border-left-color: var(--state-packing); }
.stat-ready { border-left-color: var(--state-ready); }
.stat-transit { border-left-color: var(--state-transit); }
.stat-delivered { border-left-color: var(--state-delivered); }
.stat-cancelled { border-left-color: var(--state-cancelled); }

.stat-icon { font-size: 28px; }
.stat-value { font-size: 26px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }

/* ===== DASHBOARD ROW ===== */
.dashboard-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.dash-card-wide { grid-column: 1; }
.dash-card-narrow { grid-column: 2; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  background: var(--bg);
}
.data-table td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--primary-lighter); }
.data-table tbody tr:last-child td { border-bottom: none; }

.loading-cell {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-new { background: #eff6ff; color: var(--state-new); }
.badge-packing { background: #fffbeb; color: var(--state-packing); }
.badge-ready { background: #ecfdf5; color: var(--state-ready); }
.badge-in_transit { background: #f5f3ff; color: var(--state-transit); }
.badge-delivered { background: #ecfdf5; color: var(--state-delivered); }
.badge-cancelled { background: #fef2f2; color: var(--state-cancelled); }

.badge-on_sale { background: #ecfdf5; color: var(--status-on_sale); }
.badge-on_review { background: #fffbeb; color: var(--status-on_review); }
.badge-require_corrections { background: #fef2f2; color: var(--status-require_corrections); }
.badge-removed_from_sale { background: #f3f4f6; color: var(--status-removed_from_sale); }
.badge-deleted { background: #1f2937; color: #9ca3af; }

/* ===== FILTERS BAR ===== */
.filters-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.chip {
  padding: 6px 14px;
  border-radius: 20px;
  background: white;
  border: 1.5px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
  font-family: var(--font);
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); border-color: var(--primary); color: white; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  min-width: 220px;
}
.search-box input {
  border: none;
  outline: none;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  flex: 1;
  background: transparent;
}
.search-box svg { color: var(--text-muted); flex-shrink: 0; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 0 4px;
  flex-wrap: wrap;
}
.page-btn {
  min-width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font);
  padding: 0 10px;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: white; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== SPINNER ===== */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: white;
  border-radius: var(--radius);
  max-height: 90vh;
  overflow-y: auto;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-lg { max-width: 700px; }

.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: white;
  z-index: 1;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 22px;
  cursor: pointer; color: var(--text-muted);
  line-height: 1; padding: 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }

/* ===== ORDER MODAL DETAIL ===== */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.detail-field { display: flex; flex-direction: column; gap: 3px; }
.detail-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.detail-value { font-size: 14px; color: var(--text); font-weight: 500; }

.line-items-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.line-items-table th, .line-items-table td { padding: 8px 10px; border: 1px solid var(--border); }
.line-items-table th { background: var(--bg); font-weight: 700; font-size: 11px; text-transform: uppercase; }

.order-total-row { display: flex; justify-content: flex-end; margin-top: 12px; font-size: 16px; font-weight: 800; gap: 8px; }

.action-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ===== CUSTOMER DETAIL ===== */
.customer-detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.customer-big-avatar {
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 22px; font-weight: 700;
}

.notes-section { margin-top: 20px; }
.notes-section textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  resize: vertical;
  min-height: 80px;
  outline: none;
}
.notes-section textarea:focus { border-color: var(--primary); }

/* ===== PRODUCT IMAGE ===== */
.prod-thumb {
  width: 48px; height: 48px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
}
.prod-no-img {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-light);
  font-size: 20px;
}

/* ===== NOTIFICATIONS ===== */
.notifications-list { display: flex; flex-direction: column; gap: 0; }
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.notif-item:last-child { border-bottom: none; }
.notif-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.notif-content .notif-title { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.notif-content .notif-time { font-size: 11px; color: var(--text-muted); }
.notif-unread .notif-title { color: var(--primary); }

/* ===== WAREHOUSES ===== */
.warehouses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.warehouse-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--primary);
}
.warehouse-name { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.warehouse-detail { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }

/* ===== PRODUCT STATS ===== */
.product-stats-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.ps-item { display: flex; align-items: center; justify-content: space-between; }
.ps-label { font-size: 12px; color: var(--text-muted); }
.ps-val { font-size: 13px; font-weight: 700; }

/* ===== LOCAL STATS ===== */
.local-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.local-stat { text-align: center; padding: 14px; background: var(--bg); border-radius: var(--radius-sm); }
.ls-val { font-size: 24px; font-weight: 800; color: var(--primary); }
.ls-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.top-customer-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.top-customer-item:last-child { border-bottom: none; }
.tc-name { font-size: 12px; font-weight: 600; }
.tc-phone { font-size: 11px; color: var(--text-muted); }
.tc-spent { font-size: 13px; font-weight: 700; color: var(--primary); }

/* ===== SETTINGS ===== */
.settings-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.partner-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999;
}
.toast {
  background: var(--text);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast-success { background: #10b981; }
.toast-error { background: #ef4444; }
.toast-warning { background: #f59e0b; }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== MISC ===== */
.last-update { font-size: 11px; color: var(--text-muted); }
.empty-state { text-align: center; padding: 40px; color: var(--text-muted); }
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }

.phone-link { color: var(--primary); text-decoration: none; font-weight: 600; }
.phone-link:hover { text-decoration: underline; }

.ellipsis { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: -var(--sidebar-w); z-index: 200; height: 100vh; }
  .sidebar.mobile-open { left: 0; }
  .hamburger { display: block; }
  .dashboard-row { grid-template-columns: 1fr; }
  .dash-card-wide, .dash-card-narrow { grid-column: auto; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .page-content { padding: 12px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .search-box { min-width: 0; }
}
.badge-unknown{background:#f3f4f6;color:#6b7280}.badge-return{background:#fef3c7;color:#92400e}
