/* ============================================================
   Quant Suite — Design System
   ============================================================ */

:root {
  /* Brand accent */
  --accent: #34d399;
  --accent-2: #38bdf8;
  --accent-3: #a78bfa;
  --warn: #fbbf24;
  --danger: #f87171;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
  --sidebar-w: 264px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- Dark (default) ---------- */
[data-theme="dark"] {
  --bg: #0a0b0e;
  --bg-soft: #101218;
  --surface: #14161d;
  --surface-2: #191c25;
  --border: #242833;
  --border-soft: #1c1f28;
  --text: #e8eaf0;
  --muted: #8b909e;
  --muted-2: #5e6472;
  --grid: rgba(255,255,255,.05);
  --input-bg: #0e1016;
}

/* ---------- Light ---------- */
[data-theme="light"] {
  --bg: #f4f5f8;
  --bg-soft: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --border: #e4e7ee;
  --border-soft: #eef0f4;
  --text: #11151c;
  --muted: #5b616e;
  --muted-2: #9aa0ad;
  --grid: rgba(0,0,0,.06);
  --input-bg: #ffffff;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
}

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

html, body { height: 100%; }

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

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

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
}

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; letter-spacing: -.02em; color: #04130d;
  background: linear-gradient(135deg, var(--accent), #10b981);
  box-shadow: 0 4px 14px rgba(52,211,153,.3);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.22; }
.brand-name { font-weight: 600; font-size: 13.5px; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; color: var(--muted); }

.nav {
  flex: 1; overflow-y: auto;
  padding: 12px 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.nav::-webkit-scrollbar { width: 8px; }
.nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

.nav-section {
  font-size: 10.5px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted-2);
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--muted); cursor: pointer;
  font-weight: 500; font-size: 13.5px;
  border: 1px solid transparent;
  transition: background .15s, color .15s;
  user-select: none;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.nav-item.active svg { color: var(--accent); }

.sidebar-footer {
  padding: 14px 18px; border-top: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: 12px;
}
.foot-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.foot-legal { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.foot-legal a { color: var(--muted); text-decoration: none; }
.foot-legal a:hover { color: var(--accent); }
.foot-legal .dot-sep { color: var(--muted-2); }
.tag {
  font-size: 11px; font-weight: 600; color: var(--accent);
  background: rgba(52,211,153,.1); padding: 3px 8px; border-radius: 6px;
}
.socials { display: flex; gap: 8px; }
.social-btn {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  color: var(--muted); border: 1px solid var(--border); background: var(--surface);
  transition: color .15s, border-color .15s, background .15s;
}
.social-btn svg { width: 17px; height: 17px; }
.social-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--surface-2); }

/* ---------- Star rating ---------- */
.stars { display: flex; gap: 6px; margin: 4px 0 2px; }
.star {
  width: 30px; height: 30px; cursor: pointer; color: var(--border);
  transition: color .12s, transform .08s;
}
.star svg { width: 100%; height: 100%; }
.star:hover { transform: scale(1.1); }
.star.on { color: var(--warn); }
.rating-label { font-size: 12.5px; color: var(--muted); margin-top: 4px; min-height: 18px; }

/* ---------- Feedback success ---------- */
.thanks {
  text-align: center; padding: 40px 20px;
}
.thanks .check {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 16px;
  display: grid; place-items: center; color: var(--accent);
  background: rgba(52,211,153,.12); border: 1px solid rgba(52,211,153,.3);
}
.thanks h3 { font-size: 17px; font-weight: 600; }
.thanks p { color: var(--muted); margin-top: 7px; }

/* ---------- Connect card ---------- */
.connect-row { display: flex; gap: 12px; margin-top: 12px; }
.connect-link {
  flex: 1; display: flex; align-items: center; gap: 11px;
  padding: 13px 15px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-weight: 500; font-size: 13.5px;
  transition: border-color .15s, transform .1s;
}
.connect-link:hover { border-color: var(--accent); transform: translateY(-1px); }
.connect-link svg { width: 19px; height: 19px; color: var(--accent); }

/* ============================================================
   Main + topbar
   ============================================================ */
.main {
  flex: 1; margin-left: var(--sidebar-w);
  display: flex; flex-direction: column; min-width: 0;
}

.topbar {
  height: 60px; flex-shrink: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 0 26px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-weight: 600; font-size: 15px; flex: 1; letter-spacing: -.01em; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--muted-2); background: var(--surface); }
#menuBtn { display: none; }

.theme-toggle .ico-sun { display: none; }
[data-theme="light"] .theme-toggle .ico-moon { display: none; }
[data-theme="light"] .theme-toggle .ico-sun { display: block; }

.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 35; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.overlay.show { opacity: 1; pointer-events: auto; }

/* ============================================================
   View / module layout
   ============================================================ */
.view { padding: 28px 26px 60px; max-width: 1240px; width: 100%; margin: 0 auto; }

.module-head { margin-bottom: 22px; }
.module-head h1 {
  font-size: 22px; font-weight: 600; letter-spacing: -.02em;
  display: flex; align-items: center; gap: 11px;
}
.module-head h1 .h-ico {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--accent);
}
.module-head h1 .h-ico svg { width: 17px; height: 17px; }
.module-head p { color: var(--muted); margin-top: 7px; max-width: 70ch; font-size: 13.5px; }

.layout { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  padding: 15px 18px; border-bottom: 1px solid var(--border-soft);
  font-weight: 600; font-size: 13.5px;
  display: flex; align-items: center; justify-content: space-between;
}
.card-head .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.card-body { padding: 18px; }

/* ---------- Form ---------- */
.field { margin-bottom: 15px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block; font-size: 12.5px; font-weight: 500;
  color: var(--muted); margin-bottom: 6px;
}
.field label .u { color: var(--muted-2); font-weight: 400; }

input, textarea, select {
  width: 100%; font-family: var(--font); font-size: 13.5px;
  color: var(--text); background: var(--input-bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 11px; transition: border-color .15s, box-shadow .15s;
  outline: none;
}
input[type="number"] { font-family: var(--mono); }
textarea { resize: vertical; min-height: 92px; line-height: 1.55; font-family: var(--mono); font-size: 12.5px; }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(52,211,153,.14);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  width: 100%; font-family: var(--font); font-weight: 600; font-size: 13.5px;
  color: #04130d; background: linear-gradient(135deg, var(--accent), #10b981);
  border: none; border-radius: var(--radius-sm); padding: 11px;
  cursor: pointer; transition: filter .15s, transform .05s;
  box-shadow: 0 4px 14px rgba(16,185,129,.22);
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn-ghost {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); box-shadow: none;
}
.btn-ghost:hover { border-color: var(--muted-2); }
.btn-row { display: flex; gap: 10px; margin-top: 4px; }

/* ============================================================
   KPI grid
   ============================================================ */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; margin-bottom: 20px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 16px;
  position: relative; overflow: hidden;
}
.kpi::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent); opacity: .85;
}
.kpi.pos::before { background: var(--accent); }
.kpi.neg::before { background: var(--danger); }
.kpi.warn::before { background: var(--warn); }
.kpi.info::before { background: var(--accent-2); }
.kpi .k-label { font-size: 11.5px; color: var(--muted); font-weight: 500; letter-spacing: .01em; }
.kpi .k-value { font-family: var(--mono); font-size: 22px; font-weight: 600; margin-top: 6px; letter-spacing: -.02em; }
.kpi .k-sub { font-size: 11.5px; color: var(--muted-2); margin-top: 3px; }
.kpi .k-value.pos { color: var(--accent); }
.kpi .k-value.neg { color: var(--danger); }

/* ============================================================
   Chart card
   ============================================================ */
.chart-card { margin-bottom: 20px; }
.chart-wrap { padding: 16px 18px 18px; height: 380px; position: relative; }
.chart-wrap.sm { height: 300px; }

/* ============================================================
   Badge / classification
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-radius: 999px;
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.good { color: var(--accent); background: rgba(52,211,153,.12); }
.badge.ok { color: var(--accent-2); background: rgba(56,189,248,.12); }
.badge.mid { color: var(--warn); background: rgba(251,191,36,.12); }
.badge.bad { color: var(--danger); background: rgba(248,113,113,.12); }

/* ============================================================
   Table
   ============================================================ */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: right; padding: 9px 12px; border-bottom: 1px solid var(--border-soft); }
.tbl th:first-child, .tbl td:first-child { text-align: left; color: var(--muted); }
.tbl th { font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.tbl td { font-family: var(--mono); }
.tbl tr:last-child td { border-bottom: none; }

.muted { color: var(--muted); }
.note { font-size: 12px; color: var(--muted-2); margin-top: 14px; line-height: 1.6; }
.legal { max-width: 760px; }
.legal h3 { font-size: 14.5px; font-weight: 600; color: var(--text); margin: 22px 0 8px; }
.legal h3:first-child { margin-top: 4px; }
.legal p { font-size: 13.5px; color: var(--muted); line-height: 1.75; margin: 0 0 6px; }
.legal a { color: var(--accent); text-decoration: none; }
.legal a:hover { text-decoration: underline; }
.src-hint {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 12px; color: var(--muted); line-height: 1.55;
  background: var(--input-bg); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 12px;
}
.src-hint svg { width: 15px; height: 15px; color: var(--accent); flex-shrink: 0; margin-top: 1px; }
.formula {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  background: var(--input-bg); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 14px;
  overflow-x: auto;
}

/* ---------- Explainer panel ---------- */
.explain {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 20px;
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 22px;
}
.explain h4 {
  font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 8px;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text);
}
.explain h4 svg { width: 15px; height: 15px; color: var(--accent); }
.explain p { color: var(--muted); font-size: 13px; margin-top: 9px; line-height: 1.6; }
.explain-list { margin-top: 6px; display: grid; gap: 7px; }
.explain-list li { list-style: none; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.explain-list b { color: var(--text); font-weight: 600; }
.code {
  font-family: var(--mono); font-size: 11.5px; color: var(--accent);
  background: var(--input-bg); border: 1px solid var(--border-soft);
  padding: 1px 6px; border-radius: 5px;
}
@media (max-width: 760px) { .explain { grid-template-columns: 1fr; gap: 14px; } }

/* ============================================================
   Dashboard home
   ============================================================ */
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 16px; }
.home-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; cursor: pointer; transition: border-color .15s, transform .1s, background .15s;
}
.home-card:hover { border-color: var(--muted-2); transform: translateY(-2px); background: var(--surface-2); }
.home-card .hc-ico {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--accent); margin-bottom: 13px;
}
.home-card h3 { font-size: 14.5px; font-weight: 600; }
.home-card p { color: var(--muted); font-size: 12.5px; margin-top: 5px; line-height: 1.5; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  #menuBtn { display: grid; }
  .view { padding: 20px 16px 50px; }
}
