/* QuantAI Platform - Design System v1.0 */

:root {
  --bg-0: #080c14;
  --bg-1: #0d1424;
  --bg-2: #131c30;
  --bg-3: #1a2640;
  --bg-4: #243050;
  --border: #2a3756;
  --border-muted: #1a2440;

  --text-1: #e8edf5;
  --text-2: #8b9cbf;
  --text-3: #566180;

  --brand: #6366f1;
  --brand-light: #818cf8;
  --brand-dim: #4338ca;

  --up: #f56565;
  --down: #48bb78;
  --green: #4ade80;
  --red: #f87171;
  --yellow: #fbbf24;
  --orange: #fb923c;
  --cyan: #22d3ee;
  --purple: #c084fc;

  --sidebar-w: 220px;
  --topbar-h: 52px;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,.5);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.65);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, 'Noto Sans SC', sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --t: .15s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg-0); color: var(--text-1); font-size: 14px; line-height: 1.5; overflow: hidden; }
a { color: var(--brand-light); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); font-size: 14px; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* ---- LAYOUT ---- */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--bg-1);
  border-right: 1px solid var(--border-muted);
  display: flex; flex-direction: column;
  z-index: 50;
}
.sidebar-logo {
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border-muted);
  display: flex; align-items: center; gap: 10px;
}
.logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--brand-dim), var(--brand));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}
.logo-text { font-size: 15px; font-weight: 700; letter-spacing: -.3px; }
.logo-sub { font-size: 10px; color: var(--text-3); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.nav-group-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-3);
  padding: 10px 18px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 18px;
  color: var(--text-2);
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: all var(--t);
  font-size: 13.5px;
  text-decoration: none;
}
.nav-item:hover { background: var(--bg-3); color: var(--text-1); text-decoration: none; }
.nav-item.active { background: rgba(99,102,241,.12); color: var(--brand-light); border-left-color: var(--brand); }
.nav-icon { width: 18px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--brand-dim); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
}
.sidebar-bottom { border-top: 1px solid var(--border-muted); padding: 10px 12px; }
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--radius);
  cursor: pointer; transition: background var(--t);
}
.user-card:hover { background: var(--bg-3); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #4338ca, #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 500; }
.user-plan { font-size: 10px; color: var(--yellow); font-weight: 600; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.topbar {
  height: var(--topbar-h);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-muted);
  display: flex; align-items: center;
  padding: 0 20px; gap: 10px;
  flex-shrink: 0;
}
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-breadcrumb { font-size: 12px; color: var(--text-3); }
.topbar-spacer { flex: 1; }
.page { flex: 1; overflow-y: auto; padding: 20px; }
.page-full { flex: 1; display: flex; overflow: hidden; }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px; font-weight: 500;
  transition: all var(--t);
  white-space: nowrap;
  text-decoration: none !important;
  line-height: 1.4;
}
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-light); border-color: var(--brand-light); }
.btn-success { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-1); }
.btn-ghost:hover { background: var(--bg-3); }
.btn-text { background: none; border: none; padding: 4px 8px; color: var(--text-2); }
.btn-text:hover { color: var(--text-1); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 22px; font-size: 14px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---- CARDS ---- */
.card { background: var(--bg-2); border: 1px solid var(--border-muted); border-radius: var(--radius-lg); }
.card-header {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border-muted);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 13.5px; font-weight: 600; }
.card-body { padding: 18px; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text-1);
  outline: none;
  transition: border-color var(--t);
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--brand); }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-3); }
.form-select option { background: var(--bg-3); }
.form-textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ---- TABS ---- */
.tabs { display: flex; border-bottom: 1px solid var(--border-muted); margin-bottom: 16px; }
.tab {
  padding: 8px 16px;
  font-size: 13px; font-weight: 500;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: all var(--t);
  white-space: nowrap;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--text-1); border-bottom-color: var(--brand); }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 9px 12px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border-muted); }
tr:hover td { background: var(--bg-3); }
tr:last-child td { border-bottom: none; }

/* ---- BADGES ---- */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-brand { background: rgba(99,102,241,.15); color: var(--brand-light); }
.badge-green { background: rgba(74,222,128,.12); color: var(--green); }
.badge-red { background: rgba(248,113,113,.12); color: var(--red); }
.badge-yellow { background: rgba(251,191,36,.12); color: var(--yellow); }
.badge-gray { background: var(--bg-4); color: var(--text-2); }
.badge-cyan { background: rgba(34,211,238,.12); color: var(--cyan); }
.badge-purple { background: rgba(192,132,252,.12); color: var(--purple); }

/* ---- STAT CARDS ---- */
.stat-grid { display: grid; gap: 14px; }
.stat-grid-2 { grid-template-columns: repeat(2, 1fr); }
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-grid-4 { grid-template-columns: repeat(4, 1fr); }
.stat-card {
  background: var(--bg-2); border: 1px solid var(--border-muted);
  border-radius: var(--radius-lg); padding: 16px;
}
.stat-label { font-size: 11px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .07em; margin-bottom: 8px; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1; font-family: var(--mono); }
.stat-change { font-size: 12px; margin-top: 5px; color: var(--text-3); }
.up { color: var(--up); }
.down { color: var(--down); }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 560px; max-width: 95vw; max-height: 82vh;
  overflow-y: auto;
  transform: scale(.96) translateY(8px);
  transition: transform .2s;
  box-shadow: var(--shadow-lg);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal-header { padding: 18px 20px; border-bottom: 1px solid var(--border-muted); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-3); font-size: 20px; cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: var(--bg-3); color: var(--text-1); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border-muted); display: flex; justify-content: flex-end; gap: 8px; }

/* ---- ANIMATIONS ---- */
@keyframes shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.skeleton {
  background: linear-gradient(90deg, var(--bg-3) 25%, var(--bg-4) 50%, var(--bg-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: var(--radius);
}
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.fade-in { animation: fadeIn .3s ease; }

/* ---- CODE ---- */
pre, code { font-family: var(--mono); font-size: 12px; }
pre {
  background: var(--bg-0);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  color: #abb2bf;
  line-height: 1.7;
  white-space: pre;
}
.kw { color: #c678dd; } .str { color: #98c379; } .cmt { color: #5c6370; font-style: italic; }
.fn { color: #61afef; } .num { color: #d19a66; } .cls { color: #e5c07b; }

/* ---- UTILITIES ---- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; min-width: 0; min-height: 0; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.mt-1 { margin-top: 4px; } .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; }
.p-4 { padding: 16px; }
.text-sm { font-size: 12px; } .text-xs { font-size: 11px; }
.text-lg { font-size: 16px; } .text-xl { font-size: 20px; }
.text-muted { color: var(--text-2); } .text-dim { color: var(--text-3); }
.text-brand { color: var(--brand-light); }
.text-right { text-align: right; } .text-center { text-align: center; }
.mono { font-family: var(--mono); }
.fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.overflow-hidden { overflow: hidden; }
.rounded { border-radius: var(--radius); }
.divider { border-top: 1px solid var(--border-muted); margin: 16px 0; }
