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

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #1e1e32;
  --bg-input: #252540;
  --border: #2d2d4a;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --sidebar-width: 260px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

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

.sidebar-header {
  padding: 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-header .logo { font-size: 28px; }
.sidebar-header h2 { font-size: 16px; color: var(--text-primary); font-weight: 600; }
.sidebar-header small { color: var(--text-muted); font-size: 11px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; color: var(--text-secondary);
  text-decoration: none; font-size: 14px; font-weight: 500;
  transition: all 0.2s; border-left: 3px solid transparent;
}
.sidebar-nav a:hover { color: var(--text-primary); background: rgba(99, 102, 241, 0.1); }
.sidebar-nav a.active {
  color: var(--accent); background: rgba(99, 102, 241, 0.1);
  border-left-color: var(--accent);
}
.sidebar-nav a i { width: 20px; text-align: center; font-size: 15px; }
.sidebar-nav .badge {
  margin-left: auto; background: var(--danger); color: white;
  font-size: 11px; padding: 2px 7px; border-radius: 10px; font-weight: 600;
}

.sidebar-footer {
  padding: 16px 20px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar-footer .user-info { font-size: 13px; color: var(--text-secondary); }
.sidebar-footer .logout-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 16px; transition: color 0.2s;
}
.sidebar-footer .logout-btn:hover { color: var(--danger); }

/* ========== MAIN CONTENT ========== */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 24px 30px;
  min-height: 100vh;
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; font-weight: 700; }
.page-header .actions { display: flex; gap: 8px; }

/* ========== CARDS ========== */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card); border-radius: 12px; padding: 20px;
  border: 1px solid var(--border);
}
.stat-card .stat-icon {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; margin-bottom: 12px;
}
.stat-card .stat-icon.blue { background: rgba(59,130,246,0.15); color: #3b82f6; }
.stat-card .stat-icon.green { background: rgba(34,197,94,0.15); color: #22c55e; }
.stat-card .stat-icon.purple { background: rgba(139,92,246,0.15); color: #8b5cf6; }
.stat-card .stat-icon.orange { background: rgba(245,158,11,0.15); color: #f59e0b; }
.stat-card .stat-value { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); }

.card {
  background: var(--bg-card); border-radius: 12px;
  border: 1px solid var(--border); margin-bottom: 20px;
}
.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: 600; }
.card-body { padding: 20px; }

/* ========== TABLES ========== */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse;
}
thead th {
  padding: 12px 16px; text-align: left; font-size: 12px;
  font-weight: 600; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.5px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px; font-size: 13px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:hover { background: rgba(99,102,241,0.05); }
tbody tr:last-child td { border-bottom: none; }

/* ========== BUTTONS ========== */
.btn {
  padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 500;
  border: none; cursor: pointer; display: inline-flex; align-items: center;
  gap: 6px; transition: all 0.2s; white-space: nowrap;
}
.btn-primary { background: var(--accent-gradient); color: white; }
.btn-primary:hover { opacity: 0.9; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: #1a1a2e; }
.btn-outline {
  background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

/* ========== FORMS ========== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; margin-bottom: 6px; font-size: 13px;
  font-weight: 500; color: var(--text-secondary);
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 14px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-primary); font-size: 13px; outline: none;
  transition: border-color 0.2s; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--accent);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ========== BADGE ========== */
.badge {
  padding: 4px 10px; border-radius: 6px; font-size: 11px;
  font-weight: 600; display: inline-block;
}
.badge-success { background: rgba(34,197,94,0.15); color: #22c55e; }
.badge-danger { background: rgba(239,68,68,0.15); color: #ef4444; }
.badge-warning { background: rgba(245,158,11,0.15); color: #f59e0b; }
.badge-info { background: rgba(59,130,246,0.15); color: #3b82f6; }
.badge-secondary { background: rgba(100,116,139,0.15); color: #94a3b8; }

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); display: flex; align-items: center;
  justify-content: center; z-index: 1000;
}
.modal {
  background: var(--bg-card); border-radius: 16px; padding: 24px;
  width: 90%; max-width: 540px; max-height: 85vh; overflow-y: auto;
  border: 1px solid var(--border);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 20px; cursor: pointer;
}
.modal-close:hover { color: var(--text-primary); }
.modal-footer {
  margin-top: 20px; display: flex; gap: 8px; justify-content: flex-end;
}

/* ========== FILTERS ========== */
.filters {
  display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px;
}
.filters select, .filters input {
  padding: 8px 12px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-primary); font-size: 13px; outline: none;
}
.filters select:focus, .filters input:focus { border-color: var(--accent); }

/* ========== CHARTS ========== */
.chart-container { position: relative; height: 300px; }
.charts-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}

/* ========== TOAST ========== */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 20px; border-radius: 10px;
  font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  animation: slideIn 0.3s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.toast-success { background: #166534; color: #bbf7d0; }
.toast-error { background: #991b1b; color: #fecaca; }
.toast-warning { background: #92400e; color: #fef3c7; }

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

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 14px; }

/* ========== TABS ========== */
.tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
.tab {
  padding: 10px 20px; font-size: 13px; font-weight: 500;
  color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; transition: all 0.2s;
  background: none; border-top: none; border-left: none; border-right: none;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ========== LOADING ========== */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.loading i { font-size: 24px; animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ========== SETTINGS GRID ========== */
.settings-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}
.settings-grid .card { padding: 20px; }
.settings-grid .card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.settings-grid label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-top: 12px; }
.settings-grid input, .settings-grid select, .settings-grid textarea {
  width: 100%; padding: 10px 14px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-primary); font-size: 13px; outline: none; font-family: inherit;
}
.settings-grid input:focus, .settings-grid select:focus, .settings-grid textarea:focus { border-color: var(--accent); }
.settings-grid textarea { resize: vertical; min-height: 60px; }

/* ========== MODAL BOX ========== */
.modal-box {
  background: var(--bg-card); border-radius: 16px;
  width: 90%; max-width: 540px; max-height: 85vh; overflow-y: auto;
  border: 1px solid var(--border);
}
.modal-box .modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-box .modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-box .modal-header button {
  background: none; border: none; color: var(--text-muted);
  font-size: 22px; cursor: pointer; line-height: 1;
}
.modal-box .modal-header button:hover { color: var(--text-primary); }
.modal-box .modal-body { padding: 20px; }
.modal-box .modal-body label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-top: 12px; }
.modal-box .modal-body label:first-child { margin-top: 0; }
.modal-box .modal-body input, .modal-box .modal-body select, .modal-box .modal-body textarea {
  width: 100%; padding: 10px 14px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-primary); font-size: 13px; outline: none; font-family: inherit;
}
.modal-box .modal-body input:focus, .modal-box .modal-body select:focus, .modal-box .modal-body textarea:focus { border-color: var(--accent); }
.modal-box .modal-body textarea { resize: vertical; min-height: 80px; }
.modal-box .modal-footer {
  padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ========== DATA TABLE ========== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  padding: 12px 16px; text-align: left; font-size: 12px;
  font-weight: 600; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.5px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 12px 16px; font-size: 13px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: rgba(99,102,241,0.05); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .actions { display: flex; gap: 4px; }

.mini-table { font-size: 12px; }
.mini-table thead th { padding: 8px 10px; font-size: 11px; }
.mini-table tbody td { padding: 8px 10px; font-size: 12px; }

/* ========== STATUS BADGE ========== */
.status-badge {
  padding: 4px 10px; border-radius: 6px; font-size: 11px;
  font-weight: 600; display: inline-block;
}

/* ========== DETAIL GRID ========== */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; font-size: 14px; }
.detail-grid > div { padding: 8px 0; border-bottom: 1px solid var(--border); }

/* ========== CHART ROW ========== */
.chart-row { display: grid; grid-template-columns: 1fr; gap: 20px; margin-bottom: 20px; }
.chart-row .card { padding: 20px; }
.chart-row .card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }

/* ========== STAT CARD COLORS ========== */
.stat-card { display: flex; align-items: center; gap: 14px; }
.stat-card .stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-primary .stat-icon { background: rgba(99,102,241,0.15); color: #6366f1; }
.stat-success .stat-icon { background: rgba(34,197,94,0.15); color: #22c55e; }
.stat-info .stat-icon { background: rgba(59,130,246,0.15); color: #3b82f6; }
.stat-warning .stat-icon { background: rgba(245,158,11,0.15); color: #f59e0b; }

/* ========== EXTRA BUTTONS ========== */
.btn-info { background: var(--info); color: white; }
.btn-lg { padding: 12px 28px; font-size: 15px; font-weight: 600; }

/* ========== BOT STATUS ========== */
.bot-status { margin-bottom: 16px; font-size: 14px; }

/* ========== STOCK LIST ========== */
.stock-item { padding: 6px 0; border-bottom: 1px solid var(--border); color: var(--text-secondary); }
.stock-item:last-child { border-bottom: none; }

/* ========== TOAST SHOW ========== */
.toast { transform: translateX(100%); transition: all 0.3s ease; }
.toast.show { transform: translateX(0); }

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
