/* ===== Admin Dashboard — Professional Light Theme ===== */

:root {
  --primary: #1565C0;
  --primary-light: #E3F2FD;
  --primary-dark: #0D47A1;
  --accent: #7C3AED;
  --success: #16A34A;
  --success-light: #DCFCE7;
  --danger: #DC2626;
  --danger-light: #FEE2E2;
  --warning: #D97706;
  --warning-light: #FEF3C7;
  --info: #0891B2;
  --info-light: #ECFEFF;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #1E293B;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'Cascadia Code', 'Fira Code', Consolas, monospace;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ===== Layout ===== */

.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--surface);
  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 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-brand-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
}

.sidebar-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  text-decoration: none;
  margin-bottom: 2px;
  user-select: none;
}

.nav-item:hover { background: var(--primary-light); color: var(--primary); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

.nav-item-icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }

.nav-section-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 16px 14px 6px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 0;
  min-height: 100vh;
}

/* ===== Top Bar ===== */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 16px; font-weight: 600; color: var(--text); }

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

/* ===== Page Content ===== */

.page-content { padding: 24px; max-width: 1400px; }

.page-header {
  margin-bottom: 24px;
}

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

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ===== Cards ===== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg);
}

.card-body { padding: 18px; }

.card-body-flush { padding: 0; }

/* ===== Buttons ===== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  font-family: var(--font);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover:not(:disabled) { background: #b45309; }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled) { background: var(--bg); color: var(--text); }

.btn-ghost { background: transparent; color: var(--text-secondary); border: none; }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-icon { padding: 6px; min-width: 32px; }

/* ===== Form Controls ===== */

.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.3px;
}

.form-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.1);
}

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

.form-select {
  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='%2364748B' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

/* ===== Toggle Switch ===== */

.toggle {
  position: relative;
  width: 44px; height: 24px;
  cursor: pointer;
  display: inline-block;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute; inset: 0;
  background: #CBD5E1;
  border-radius: 12px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle input:disabled + .toggle-slider { opacity: 0.5; cursor: not-allowed; }

/* ===== Badges & Chips ===== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-neutral { background: #F1F5F9; color: var(--text-secondary); }

/* ===== Tables ===== */

.table-responsive { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
}

.data-table tr:hover td { background: #FAFBFC; }
.data-table tr:last-child td { border-bottom: none; }

/* ===== Stats Grid ===== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
}

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

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-top: 4px;
}

.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }

.stat-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ===== Slider Control ===== */

.slider-control {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}

.slider-label {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.slider-value {
  min-width: 60px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: var(--radius);
}

.slider-input {
  width: 140px;
  accent-color: var(--primary);
}

/* ===== Settings Section ===== */

.settings-section {
  margin-bottom: 20px;
}

.settings-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 18px 8px;
  border-bottom: 1px solid var(--border);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid #F8FAFC;
  gap: 12px;
}

.settings-row:last-child { border-bottom: none; }

.settings-row-label {
  font-size: 13px;
  color: var(--text);
  flex: 1;
}

.settings-row-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.settings-row-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ===== Chart Container ===== */

.chart-container {
  position: relative;
  width: 100%;
  height: 300px;
}

/* ===== Login Page ===== */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #E3F2FD 0%, #F3E5F5 100%);
}

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

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo-icon {
  width: 56px; height: 56px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 12px;
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.login-error {
  background: var(--danger-light);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Toast Notifications ===== */

.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error { border-left: 3px solid var(--danger); }
.toast.toast-info { border-left: 3px solid var(--info); }

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

/* ===== Modal ===== */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: scaleIn 0.2s ease;
}

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

.modal-title { font-size: 16px; font-weight: 600; }

.modal-body { padding: 20px; }

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

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ===== Loading ===== */

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

.spinner-sm { width: 16px; height: 16px; border-width: 2px; }

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

.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  flex-direction: column;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ===== Utilities ===== */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.font-mono { font-family: var(--mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }

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

/* ===== Filters Bar ===== */

.filters-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  transition: all 0.15s;
}

.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== User Card (List View) ===== */

.user-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  transition: box-shadow 0.15s;
}

.user-card:hover { box-shadow: var(--shadow-md); }

.user-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
  flex-shrink: 0;
}

.user-avatar.active { background: var(--primary-light); color: var(--primary); }
.user-avatar.inactive { background: #F1F5F9; color: var(--text-muted); }

/* ===== PnL Row ===== */

.pnl-positive { color: var(--success); font-weight: 600; }
.pnl-negative { color: var(--danger); font-weight: 600; }
.pnl-zero { color: var(--text-muted); }

/* ===== Responsive ===== */

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

/* ===== Stepper Control ===== */

.stepper {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stepper-btn {
  width: 28px; height: 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.15s;
}

.stepper-btn:hover:not(:disabled) { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.stepper-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ===== Read-only indicator ===== */

.readonly-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

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

.readonly-dot.on { background: var(--success); }
.readonly-dot.off { background: #CBD5E1; }

/* ===== Empty State ===== */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; color: var(--text); }
.empty-state-text { font-size: 13px; }
