@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-primary: #0d0f14;
  --bg-secondary: #141720;
  --bg-card: #1a1e2e;
  --bg-hover: #1f2438;
  --border: #252a3d;
  --border-light: #2e3450;

  --accent-emerald: #00d084;
  --accent-emerald-dim: rgba(0, 208, 132, 0.12);
  --accent-blue: #3d8bff;
  --accent-blue-dim: rgba(61, 139, 255, 0.12);
  --accent-amber: #ffaa00;
  --accent-amber-dim: rgba(255, 170, 0, 0.12);
  --accent-rose: #ff4d6d;
  --accent-rose-dim: rgba(255, 77, 109, 0.12);
  --accent-purple: #a855f7;
  --accent-purple-dim: rgba(168, 85, 247, 0.12);

  --text-primary: #e8ecf4;
  --text-secondary: #8892a4;
  --text-muted: #4a5568;

  --sidebar-width: 260px;
  --topbar-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
}

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

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: 'Sora', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent-emerald), var(--accent-blue));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.logo-sub {
  font-size: 10px;
  font-weight: 500;
  color: var(--accent-emerald);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 8px 20px 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: 0;
  transition: all 0.2s;
  position: relative;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-item.active {
  color: var(--accent-emerald);
  background: var(--accent-emerald-dim);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--accent-emerald);
  border-radius: 0 3px 3px 0;
}

.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.nav-badge {
  margin-left: auto;
  background: var(--accent-rose);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 20px;
  font-family: 'JetBrains Mono', monospace;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}

.avatar-info .name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.avatar-info .role { font-size: 11px; color: var(--text-muted); }

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

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.topbar-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  width: 240px;
  transition: border-color 0.2s;
}

.search-bar:focus-within { border-color: var(--accent-blue); }

.search-bar input {
  background: none; border: none; outline: none;
  color: var(--text-primary); font-size: 13px;
  font-family: 'Sora', sans-serif;
  width: 100%;
}

.search-bar input::placeholder { color: var(--text-muted); }

.icon-btn {
  width: 36px; height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 16px;
  transition: all 0.2s;
}

.icon-btn:hover { border-color: var(--border-light); color: var(--text-primary); }

/* ===== PAGE CONTENT ===== */
.page-content {
  flex: 1;
  padding: 28px;
  display: none;
}

.page-content.active { display: block; }

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}

.stat-card:nth-child(1)::before { background: linear-gradient(90deg, var(--accent-emerald), transparent); }
.stat-card:nth-child(2)::before { background: linear-gradient(90deg, var(--accent-blue), transparent); }
.stat-card:nth-child(3)::before { background: linear-gradient(90deg, var(--accent-amber), transparent); }
.stat-card:nth-child(4)::before { background: linear-gradient(90deg, var(--accent-rose), transparent); }
.stat-card:nth-child(5)::before { background: linear-gradient(90deg, var(--accent-purple), transparent); }

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

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 8px;
}

.stat-icon {
  position: absolute;
  right: 16px; top: 16px;
  font-size: 24px;
  opacity: 0.15;
}

.stat-change {
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-change.up { color: var(--accent-emerald); }
.stat-change.neutral { color: var(--text-muted); }

/* ===== GRID LAYOUT ===== */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  margin-bottom: 24px;
}

.content-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 0 2px var(--accent-emerald-dim);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 2px var(--accent-emerald-dim); }
  50% { box-shadow: 0 0 0 6px var(--accent-emerald-dim); }
}

.card-action {
  font-size: 12px;
  color: var(--accent-blue);
  cursor: pointer;
  font-weight: 500;
  text-decoration: none;
}

.card-action:hover { text-decoration: underline; }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 12px 20px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  transition: background 0.15s;
  cursor: pointer;
}

tbody tr:hover { background: var(--bg-hover); }

tbody td {
  padding: 13px 20px;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

.badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-delivered { background: var(--accent-emerald-dim); color: var(--accent-emerald); }
.badge-processing { background: var(--accent-blue-dim); color: var(--accent-blue); }
.badge-pending { background: var(--accent-amber-dim); color: var(--accent-amber); }
.badge-shipped { background: var(--accent-purple-dim); color: var(--accent-purple); }
.badge-cancelled { background: var(--accent-rose-dim); color: var(--accent-rose); }
.badge-active { background: var(--accent-emerald-dim); color: var(--accent-emerald); }
.badge-inactive { background: rgba(74,85,104,0.3); color: var(--text-muted); }
.badge-vip { background: var(--accent-amber-dim); color: var(--accent-amber); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  font-family: 'Sora', sans-serif;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-emerald);
  color: #0d0f14;
  border-color: var(--accent-emerald);
}

.btn-primary:hover {
  background: #00e892;
  box-shadow: 0 0 20px rgba(0, 208, 132, 0.3);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-secondary:hover { border-color: var(--border-light); color: var(--text-primary); }

.btn-danger {
  background: var(--accent-rose-dim);
  color: var(--accent-rose);
  border-color: transparent;
}

.btn-danger:hover { background: rgba(255, 77, 109, 0.2); }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon { padding: 7px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-control {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'Sora', sans-serif;
  transition: border-color 0.2s;
  outline: none;
}

.form-control:focus { border-color: var(--accent-blue); }
.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%234a5568' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.25s;
  box-shadow: var(--shadow-lg);
}

.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }

.modal-close {
  width: 32px; height: 32px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 16px;
  transition: all 0.2s;
}

.modal-close:hover { color: var(--text-primary); border-color: var(--border-light); }

.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ===== CHARTS ===== */
.chart-container {
  padding: 16px 20px 20px;
  position: relative;
}

.mini-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 80px;
}

.chart-bar {
  flex: 1;
  background: var(--accent-blue-dim);
  border-radius: 4px 4px 0 0;
  border: 1px solid var(--accent-blue);
  border-bottom: none;
  position: relative;
  transition: background 0.2s;
  min-height: 4px;
}

.chart-bar:hover { background: var(--accent-blue); }
.chart-bar.highlight { background: var(--accent-emerald); border-color: var(--accent-emerald); }

.chart-labels {
  display: flex;
  gap: 6px;
  padding: 6px 20px 0;
}

.chart-label {
  flex: 1;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* ===== DONUT CHART ===== */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 20px;
}

.donut-legend { flex: 1; }
.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-value { margin-left: auto; font-weight: 600; font-family: 'JetBrains Mono', monospace; }

/* ===== CUSTOMER CARD ===== */
.customer-row-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  color: var(--text-muted);
  gap: 12px;
}

.empty-state .icon { font-size: 40px; opacity: 0.4; }
.empty-state .title { font-size: 16px; font-weight: 600; color: var(--text-secondary); }
.empty-state .sub { font-size: 13px; text-align: center; max-width: 280px; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== LOADING ===== */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-emerald);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  min-width: 280px;
  max-width: 360px;
}

.toast.success { border-left: 3px solid var(--accent-emerald); }
.toast.error { border-left: 3px solid var(--accent-rose); }
.toast.info { border-left: 3px solid var(--accent-blue); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== FILTER TABS ===== */
.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.filter-tab {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: none;
  font-family: 'Sora', sans-serif;
}

.filter-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.filter-tab:hover:not(.active) { color: var(--text-secondary); }

/* ===== PROGRESS BAR ===== */
.progress-bar {
  height: 6px;
  background: var(--bg-primary);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .content-grid { grid-template-columns: 1fr; }
  .content-grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .content-grid-3 { grid-template-columns: 1fr; }
}

/* ===== DETAIL PANEL ===== */
.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.detail-avatar {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800;
  flex-shrink: 0;
}

.detail-meta .company { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.detail-meta .contact { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.stat-row {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
}

.stat-cell {
  flex: 1;
  padding: 16px 20px;
  border-right: 1px solid var(--border);
}

.stat-cell:last-child { border-right: none; }
.stat-cell .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.stat-cell .value { font-size: 18px; font-weight: 700; }

/* ===== INTERACTION TIMELINE ===== */
.timeline { padding: 16px 20px; }
.timeline-item {
  display: flex;
  gap: 12px;
  padding-bottom: 20px;
  position: relative;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 16px; top: 32px; bottom: 0;
  width: 1px;
  background: var(--border);
}

.timeline-item:last-child::before { display: none; }

.timeline-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.timeline-content .subject { font-size: 13px; font-weight: 600; }
.timeline-content .desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.timeline-content .time { font-size: 11px; color: var(--text-muted); margin-top: 4px; font-family: 'JetBrains Mono', monospace; }

/* ===== AUTH UI ===== */
.auth-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(15,23,42,0.9); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.auth-card { background: var(--surface); padding: 40px; border-radius: 16px; width: 100%; max-width: 400px; box-shadow: 0 20px 40px rgba(0,0,0,0.4); border: 1px solid var(--border); }
.auth-logo { font-size: 24px; font-weight: 700; color: var(--text); margin-bottom: 8px; text-align: center; }
.auth-title { font-size: 20px; font-weight: 600; text-align: center; margin-bottom: 4px; }
.auth-subtitle { font-size: 14px; color: var(--text-muted); text-align: center; margin-bottom: 24px; }
