:root {
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --primary: #f97316;
  --primary-dark: #ea580c;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: rgba(249,115,22,0.12);
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #eab308;
  --info: #3b82f6;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08),0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
  font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* LOGIN */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg,#0f172a 0%,#1e293b 100%);
}
.login-card {
  background: var(--card);
  border-radius: 16px;
  padding: 48px 40px;
  width: 400px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-logo { margin-bottom: 16px; }
.login-title { font-size: 24px; font-weight: 700; color: var(--text); }
.login-subtitle { color: var(--text-secondary); margin-bottom: 32px; }
.login-form { text-align: left; }
.login-error { color: var(--danger); font-size: 13px; text-align: center; margin-top: 12px; min-height: 20px; }

/* FORM */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border 0.2s;
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full-width { grid-column: span 2; }

/* BUTTONS */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-full { width: 100%; justify-content: center; }
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger {
  padding: 6px 14px;
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.btn-danger:hover { background: var(--danger); color: white; }

.btn-success {
  background: rgba(34,197,94,0.1);
  color: var(--success);
  border: 1px solid rgba(34,197,94,0.3);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-success:hover { background: var(--success); color: white; }

.status-badge.banned {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.2);
}

.status-badge.warning {
  background: rgba(234,179,8,0.1);
  color: #ca8a04;
  border: 1px solid rgba(234,179,8,0.2);
}
.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
}
.btn-sm:hover { border-color: var(--primary); color: var(--primary); }
.btn-logout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
}
.btn-logout:hover { background: rgba(255,255,255,0.1); color: var(--danger); }

/* APP LAYOUT */
.app { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand { display: flex; flex-direction: column; }
.brand-name { color: white; font-weight: 700; font-size: 16px; }
.brand-role { color: var(--primary); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px;
  margin-bottom: 2px;
  transition: all 0.2s;
  font-size: 14px;
}
.nav-item:hover { background: var(--sidebar-hover); color: #cbd5e1; }
.nav-item.active { background: var(--sidebar-active); color: var(--primary); font-weight: 600; }
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.admin-info { display: flex; align-items: center; gap: 10px; }
.admin-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}
.admin-name { color: #e2e8f0; font-size: 13px; font-weight: 600; }
.admin-email { color: var(--text-muted); font-size: 11px; }
.admin-details { display: flex; flex-direction: column; }

/* MAIN */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
}

/* TOPBAR */
.topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title { font-size: 18px; font-weight: 700; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-time { color: var(--text-secondary); font-size: 13px; }
.sidebar-toggle { display: none; background: none; border: none; cursor: pointer; color: var(--text); }
.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--success);
  font-size: 12px;
  font-weight: 600;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse-live 2s ease-in-out infinite;
}
@keyframes pulse-live { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

/* PAGE */
.page-container { padding: 24px; }
.page { display: none; }
.page.active { display: block; }

/* STATS GRID */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 20px; margin-bottom: 24px; }
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 24px; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-secondary); }
.stat-change { font-size: 12px; width: 100%; font-weight: 600; }
.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }

/* DASHBOARD GRID */
.dashboard-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; margin-bottom: 24px; }
.dashboard-grid.triple { grid-template-columns: repeat(3,1fr); }

/* CARDS */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h3 { font-size: 15px; font-weight: 700; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.chart-card { padding-bottom: 16px; overflow: hidden; }
.chart-card canvas { max-height: 300px !important; }
.card canvas { max-height: 300px !important; }

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}
.badge-live { background: #dcfce7; color: #16a34a; }
.badge-active { background: #dbeafe; color: #2563eb; }
.badge-inactive { background: #f1f5f9; color: #64748b; }
.badge-guest { background: #fef3c7; color: #d97706; }
.badge-open { background: #fef3c7; color: #d97706; }
.badge-closed { background: #dcfce7; color: #16a34a; }
.badge-sent { background: #dbeafe; color: #2563eb; }

/* ACTIVITY FEED */
.activity-feed { max-height: 400px; overflow-y: auto; }
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.activity-dot.add { background: var(--success); }
.activity-dot.view { background: var(--info); }
.activity-dot.market { background: var(--primary); }
.activity-dot.delete { background: var(--danger); }
.activity-dot.login { background: var(--warning); }
.activity-text { flex: 1; font-size: 13px; line-height: 1.5; }
.activity-text strong { font-weight: 600; }
.activity-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.activity-empty { text-align: center; color: var(--text-muted); padding: 40px; }

/* TABLES */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
}
.data-table td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: #f8fafc; }

/* SEARCH */
.page-actions { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  flex: 1;
  max-width: 400px;
}
.search-box input { border: none; outline: none; flex: 1; font-size: 14px; }
.select-mini {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  background: white;
}
.input-mini {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  width: 100px;
  text-align: center;
  outline: none;
}
.input-full { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; }

/* TABS */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; background: #f1f5f9; padding: 4px; border-radius: 10px; }
.tab {
  padding: 8px 20px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
}
.tab.active { background: white; color: var(--text); box-shadow: var(--shadow); }

/* METRICS */
.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.metric-row:last-child { border-bottom: none; }
.metric-value { font-weight: 700; font-size: 15px; }
.metric-value.positive { color: var(--success); }
.metric-value.negative { color: var(--danger); }

/* WARNING LIST */
.warning-list { max-height: 200px; overflow-y: auto; }
.warning-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.warning-badge {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}
.warning-badge.critical { background: #fef2f2; color: #dc2626; }
.warning-badge.soon { background: #fef3c7; color: #d97706; }

/* TOGGLE */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #cbd5e1;
  border-radius: 24px;
  transition: 0.3s;
}
.toggle-slider:before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider:before { transform: translateX(20px); }

/* SETTINGS */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.settings-grid .card:last-child { grid-column: span 2; }
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-name { font-weight: 600; font-size: 14px; }
.setting-desc { font-size: 12px; color: var(--text-muted); }
.setting-info { display: flex; flex-direction: column; gap: 2px; }

/* MARKETS */
.markets-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 20px; }
.market-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  text-align: center;
}
.market-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 28px;
}
.market-name { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.market-status { font-size: 12px; margin-bottom: 12px; }
.market-stat { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; border-top: 1px solid var(--border); }

/* MODAL */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  background: white;
  border-radius: 16px;
  padding: 32px;
  width: 500px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal h3 { font-size: 18px; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* NOTIFICATION COMPOSER */
.notification-composer { border-left: 4px solid var(--primary); }

/* FILTER */
.filter-group { display: flex; gap: 8px; }

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* USER CELLS */
.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.user-name { font-weight: 600; font-size: 13px; color: var(--text); }
.user-email { font-size: 12px; color: var(--text-muted); }

/* STATUS BADGES */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}
.status-badge.active {
  background: rgba(34,197,94,0.1);
  color: var(--success);
  border: 1px solid rgba(34,197,94,0.2);
}
.status-badge.inactive {
  background: #f1f5f9;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* MARKET CARDS */
.market-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.market-header h3 {
  font-size: 16px;
  font-weight: 700;
}
.market-stats {
  padding: 8px 0;
  font-size: 13px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  margin-top: 8px;
}
.market-links {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

/* TOAST ANIMATION */
@keyframes fadeIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* MODAL CLOSE */
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.modal-close:hover { background: #f1f5f9; color: var(--text); }

.modal { position: relative; }

/* RESPONSIVE */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-grid.triple { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-grid .card:last-child { grid-column: span 1; }
  .markets-grid { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full-width { grid-column: span 1; }
  .markets-grid { grid-template-columns: 1fr; }
}
