:root {
  --primary: #f59e0b;
  --primary-dark: #d97706;
  --primary-light: #fbbf24;
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #263348;
  --bg-input: #1e293b;
  --bg-sidebar: #0c1524;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --border: #334155;
  --border-light: #1e293b;
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.1);
  --blue: #3b82f6;
  --green: #22c55e;
  --orange: #f59e0b;
  --red: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --font-main: 'Space Grotesk', 'Sora', system-ui, -apple-system, sans-serif;
  --sidebar-w: 260px;
  --topbar-h: 60px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

.app-root { display: flex; width: 100%; min-height: 100vh; }

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

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

.logo-wrap { display: flex; align-items: center; gap: 12px; }
.logo-icon { font-size: 2rem; }
.logo-title { font-size: 1.2rem; font-weight: 700; color: var(--primary); }
.logo-sub { font-size: 0.7rem; color: var(--text-muted); letter-spacing: 0.5px; }
.sidebar-close { display: none; background: none; border: none; color: var(--text); font-size: 1.2rem; cursor: pointer; }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
}

.nav-item:hover { background: var(--bg-card); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--bg);
  font-weight: 600;
}

.nav-icon { font-size: 1.1rem; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.user-avatar { font-size: 1.2rem; }

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 90;
  display: none;
}

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

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

.menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
}

.topbar-title { font-size: 1rem; font-weight: 600; color: var(--text); flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.theme-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--bg);
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(245, 158, 11, 0.3); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-xs { padding: 4px 10px; font-size: 0.75rem; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ghost:hover { border-color: var(--text-muted); color: var(--text); }

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-outline:hover { background: var(--primary); color: var(--bg); }
.btn-outline:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }

/* Tab Content */
.tab-content { padding: 24px; flex: 1; }

/* Page Hero */
.page-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.hero-title { font-size: 1.6rem; font-weight: 700; }
.hero-sub { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }

.hero-badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  text-align: center;
}

.hero-badge span { display: block; font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.hero-badge small { color: var(--text-muted); font-size: 0.75rem; }

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

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

.kpi-blue::before { background: var(--blue); }
.kpi-green::before { background: var(--green); }
.kpi-orange::before { background: var(--orange); }
.kpi-red::before { background: var(--red); }

.kpi-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.kpi-value { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.kpi-delta { font-size: 0.8rem; color: var(--text-dim); }

/* Section Header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  margin-top: 8px;
}

.section-title { font-size: 1.05rem; font-weight: 600; }

/* Alerts */
.alerts-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.alert-item {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  border-left: 4px solid;
}

.alert-warning { background: var(--warning-bg); border-color: var(--warning); color: var(--warning); }
.alert-danger { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.alert-info { background: var(--info-bg); border-color: var(--info); color: var(--info); }
.alert-empty { color: var(--text-muted); font-size: 0.85rem; padding: 12px; }

/* Chart */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  min-height: 200px;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  height: 180px;
  gap: 8px;
}

.bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  height: 100%;
  justify-content: flex-end;
}

.bar-fill {
  width: 100%;
  max-width: 48px;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  transition: height 0.5s ease;
}

.bar-value {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-align: center;
  white-space: nowrap;
}

.bar-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 8px;
}

/* Top Taxis */
.top-taxis-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.top-taxi-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.top-taxi-rank {
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
  min-width: 30px;
}

.top-taxi-name { flex: 1; font-weight: 600; }
.top-taxi-count { font-size: 0.8rem; color: var(--text-muted); }
.top-taxi-total { font-weight: 600; color: var(--green); }

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-input {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 0.85rem;
}

.filter-input:focus, .filter-select:focus { outline: none; border-color: var(--primary); }

.filter-select {
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 0.85rem;
}

/* Deposits List */
.deposits-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.deposit-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  transition: all 0.2s;
}

.deposit-card:hover { border-color: var(--primary); background: var(--bg-card-hover); }

.deposit-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.deposit-taxi-name { font-weight: 600; font-size: 1rem; }
.deposit-amount { font-weight: 700; font-size: 1.1rem; color: var(--green); }

.deposit-card-meta {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.deposit-obs {
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 6px 0;
  border-top: 1px solid var(--border-light);
  margin-top: 6px;
}

.deposit-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* Taxis Grid */
.taxis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.taxi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.2s;
}

.taxi-card:hover { border-color: var(--primary); }

.taxi-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.taxi-card-icon { font-size: 2rem; }
.taxi-card-name { font-weight: 700; font-size: 1.05rem; }
.taxi-card-driver { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.taxi-card-info {
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 4px 0;
}

.taxi-card-stats {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  margin-top: 8px;
  border-top: 1px solid var(--border-light);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.taxi-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* AI Cards */
.ai-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.ai-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  transition: all 0.2s;
}

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

.ai-card-icon { font-size: 2.4rem; margin-bottom: 12px; }
.ai-card-title { font-weight: 700; font-size: 1rem; margin-bottom: 6px; }
.ai-card-desc { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 16px; line-height: 1.4; }

/* AI Result Panel */
.ai-result-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.ai-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.ai-result-content {
  padding: 20px;
  font-size: 0.9rem;
  line-height: 1.7;
}

.ai-text { white-space: pre-wrap; color: var(--text); }

.ai-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding: 32px;
  color: var(--text-muted);
}

.ai-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* History */
.history-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.export-actions { display: flex; gap: 8px; }

.history-table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.history-table thead { background: var(--bg-sidebar); }
.history-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.history-table td {
  padding: 12px 16px;
  border-top: 1px solid var(--border-light);
  color: var(--text);
}

.history-table tbody tr:hover { background: var(--bg-card-hover); }

.amount-cell { font-weight: 600; color: var(--green); }
.empty-cell { text-align: center; color: var(--text-muted); padding: 32px 16px; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-backdrop.active { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

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

.modal-header h3 { font-size: 1.1rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
}

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

.modal-form { padding: 24px; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.form-control:focus { outline: none; border-color: var(--primary); }

.readonly-field { background: var(--bg); color: var(--text-dim); cursor: not-allowed; }

textarea.form-control { resize: vertical; }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

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

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 300;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: var(--shadow);
}

.toast.show { transform: translateY(0); opacity: 1; }

.toast-success { background: var(--success); color: var(--bg); }
.toast-warning { background: var(--warning); color: var(--bg); }
.toast-error { background: var(--danger); color: white; }

/* Empty State / Skeleton */
.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 20px;
  font-size: 0.9rem;
}

.skeleton-list { display: flex; flex-direction: column; gap: 12px; }

.skeleton-item {
  height: 64px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .sidebar-close { display: block; }

  .overlay { display: block; }

  .main { margin-left: 0; }

  .menu-btn { display: block; }

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

  .form-row { grid-template-columns: 1fr; }

  .filter-bar { flex-direction: column; }

  .filter-input { min-width: auto; }

  .taxis-grid { grid-template-columns: 1fr; }

  .ai-cards { grid-template-columns: 1fr; }

  .page-hero { flex-direction: column; align-items: flex-start; }

  .history-filters { flex-direction: column; }
}

@media (max-width: 480px) {
  .tab-content { padding: 16px; }
  .hero-title { font-size: 1.3rem; }
  .kpi-grid { grid-template-columns: 1fr; }
}