:root {
  --bg: #090b11;
  --panel: #11151d;
  --panel-2: #151a24;
  --panel-3: #1a202c;
  --text: #f5f7fb;
  --muted: #8f98aa;
  --line: rgba(255,255,255,.08);
  --accent: #c9ff4f;
  --accent-2: #8bffcf;
  --danger: #ff7f7f;
  --warning: #ffcb66;
  --shadow: 0 18px 60px rgba(0,0,0,.28);
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-width: 1180px;
  background:
    radial-gradient(circle at 80% -10%, rgba(201,255,79,.12), transparent 28%),
    radial-gradient(circle at -10% 40%, rgba(95,136,255,.08), transparent 24%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { color: inherit; }

.app-shell {
  width: min(1600px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0 28px;
}

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 18px;
}

.brand-block, .top-actions, .kpi-row, .leader-row, .detail-topline, .ranking-tools, .chart-legend {
  display: flex;
  align-items: center;
}

.brand-block { gap: 14px; }
.logo {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: var(--accent);
  color: #090b11;
  font-weight: 900;
  font-size: 21px;
  box-shadow: 0 0 0 6px rgba(201,255,79,.08);
}

h1, h2, p { margin: 0; }
h1 { font-size: 22px; line-height: 1.2; letter-spacing: -.025em; }
h2 { font-size: 18px; line-height: 1.25; letter-spacing: -.018em; }
.eyebrow { font-size: 10px; letter-spacing: .16em; color: var(--muted); font-weight: 800; margin-bottom: 5px; }

.top-actions { gap: 10px; }
.status-pill {
  height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #c7ceda;
  font-size: 12px;
  background: rgba(255,255,255,.025);
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 14px var(--accent-2); }

.ghost-btn, .primary-btn {
  height: 38px;
  border-radius: 10px;
  padding: 0 16px;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: .2s ease;
}
.ghost-btn { background: rgba(255,255,255,.035); }
.primary-btn { background: var(--accent); color: #0b0e13; border-color: transparent; font-weight: 800; }
.ghost-btn:hover { background: rgba(255,255,255,.075); }
.primary-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(201,255,79,.18); }

.dashboard {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 16px;
}

.card {
  background: linear-gradient(180deg, rgba(255,255,255,.025), transparent 20%), var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 20px;
  min-height: calc(100vh - 122px);
  position: sticky;
  top: 12px;
  align-self: start;
}
.panel-heading, .card-header, .control-label-row, .weights-title, .detail-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.step-badge {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(201,255,79,.08);
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
}

.search-box {
  height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 20px 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 11px;
  color: var(--muted);
}
.search-box:focus-within { border-color: rgba(201,255,79,.5); box-shadow: 0 0 0 3px rgba(201,255,79,.07); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.search-box input::placeholder { color: #697386; }

.control-group { margin-bottom: 18px; }
.control-label-row { font-size: 12px; color: #d7dce5; margin-bottom: 10px; }
.control-label-row output { color: var(--accent); font-weight: 800; }

.range {
  width: 100%;
  height: 4px;
  appearance: none;
  background: linear-gradient(to right, var(--accent) 0 var(--fill,50%), #2a303c var(--fill,50%) 100%);
  border-radius: 999px;
  outline: none;
}
.range::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #10131a;
  box-shadow: 0 0 0 1px var(--accent), 0 2px 10px rgba(0,0,0,.5);
  cursor: pointer;
}
.range::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 3px solid #10131a; cursor: pointer;
}

.divider { height: 1px; background: var(--line); margin: 20px 0; }
.weights-title, .sector-title { font-size: 12px; font-weight: 800; color: #e4e8ef; margin-bottom: 14px; }
.text-btn { border: 0; background: transparent; color: var(--accent); font-size: 11px; cursor: pointer; padding: 0; }
.weight-controls { display: grid; gap: 13px; }
.weight-row { display: grid; grid-template-columns: 1fr 42px; align-items: center; gap: 10px; }
.weight-row label { display: grid; gap: 7px; font-size: 11px; color: #b7becb; }
.weight-value { text-align: right; color: #727d90; font-size: 11px; font-variant-numeric: tabular-nums; }

.sector-filters { display: flex; flex-wrap: wrap; gap: 7px; }
.sector-chip {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 10px;
  color: #9ea7b8;
  cursor: pointer;
  transition: .18s ease;
}
.sector-chip:hover { border-color: rgba(255,255,255,.2); color: var(--text); }
.sector-chip.active { color: #10131a; background: var(--accent); border-color: var(--accent); font-weight: 800; }

.model-note {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,203,102,.06);
  border: 1px solid rgba(255,203,102,.12);
}
.info-mark { flex: 0 0 auto; width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; color: var(--warning); border: 1px solid rgba(255,203,102,.35); font-size: 11px; font-weight: 800; }
.model-note p { font-size: 10px; line-height: 1.5; color: #9ea7b8; }

.workspace { min-width: 0; display: grid; gap: 16px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.kpi-card { min-height: 108px; padding: 16px; }
.kpi-label { color: var(--muted); font-size: 11px; margin-bottom: 13px; }
.kpi-row { gap: 7px; align-items: baseline; }
.kpi-row strong { font-size: 28px; letter-spacing: -.04em; }
.kpi-row span { color: var(--muted); font-size: 11px; }
.kpi-foot { margin-top: 9px; font-size: 10px; color: #8993a5; }
.kpi-foot.positive { color: var(--accent-2); }
.mini-progress { height: 4px; border-radius: 999px; background: #242a35; margin-top: 14px; overflow: hidden; }
.mini-progress i { display: block; width: 74%; height: 100%; background: var(--accent); border-radius: inherit; transition: width .3s ease; }
.leader-row { gap: 10px; }
.company-mark {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px;
  background: #222935; border: 1px solid var(--line); font-size: 10px; font-weight: 900; color: var(--accent);
}
.company-mark.large { width: 44px; height: 44px; border-radius: 13px; font-size: 12px; }
.leader-row div:last-child { display: grid; gap: 3px; }
.leader-row strong { font-size: 13px; }
.leader-row span { color: var(--muted); font-size: 10px; }

.analysis-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(310px, .85fr); gap: 12px; }
.chart-card, .detail-card { height: 355px; }
.chart-card { padding: 18px 18px 12px; }
.card-header { margin-bottom: 10px; }
.chart-legend { gap: 13px; font-size: 10px; color: var(--muted); }
.chart-legend span { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.legend-dot.best { background: var(--accent); }
.legend-dot.base { background: #667086; }
.chart-wrap { position: relative; height: calc(100% - 55px); }
#opportunityChart { width: 100%; height: 100%; display: block; }
.chart-tooltip {
  position: absolute;
  z-index: 10;
  min-width: 145px;
  pointer-events: none;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(14,17,24,.96);
  box-shadow: 0 12px 28px rgba(0,0,0,.35);
  font-size: 10px;
  line-height: 1.5;
  color: #b9c1cf;
  transform: translate(10px, -50%);
}
.chart-tooltip strong { display: block; color: var(--text); font-size: 11px; }

.detail-card { padding: 18px; display: flex; flex-direction: column; }
.detail-topline { align-items: center; }
.detail-title { margin-left: 10px; min-width: 0; }
.detail-title h2 { font-size: 18px; }
.score-ring {
  --score: 86;
  margin-left: auto;
  width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--score) * 1%), #2a303b 0);
  position: relative;
}
.score-ring::before { content: ""; position: absolute; inset: 4px; background: var(--panel); border-radius: 50%; }
.score-ring span { position: relative; font-size: 13px; font-weight: 900; }
.detail-thesis { color: #a9b1bf; font-size: 11px; line-height: 1.55; margin: 15px 0 13px; min-height: 34px; }
.metric-list { display: grid; gap: 9px; }
.metric-row { display: grid; grid-template-columns: 86px 1fr 28px; gap: 8px; align-items: center; font-size: 10px; color: #9ea7b8; }
.metric-track { height: 5px; background: #262c37; border-radius: 999px; overflow: hidden; }
.metric-track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #84f5ca, var(--accent)); transition: width .25s ease; }
.metric-row b { text-align: right; color: #dfe4ec; font-variant-numeric: tabular-nums; }
.detail-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); gap: 12px; align-items: flex-end; }
.detail-caption { color: var(--accent); font-size: 9px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.detail-footer p { margin-top: 4px; color: #8f99aa; font-size: 10px; line-height: 1.35; }
.icon-btn { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #0b0e13; border: 0; font-size: 20px; cursor: pointer; }
.icon-btn.pinned { background: #2c3441; color: var(--accent); }

.ranking-card { min-height: 290px; padding: 18px; }
.ranking-header { margin-bottom: 12px; }
.ranking-tools { gap: 10px; }
.view-toggle { display: flex; padding: 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; }
.view-toggle button { border: 0; background: transparent; color: #778194; padding: 6px 10px; font-size: 10px; border-radius: 6px; cursor: pointer; }
.view-toggle button.active { background: #2a313e; color: var(--text); }
select { height: 31px; padding: 0 28px 0 10px; background: var(--panel-2); color: #c3cad5; border: 1px solid var(--line); border-radius: 9px; outline: none; font-size: 10px; }

.ranking-table { display: grid; }
.table-row {
  display: grid;
  grid-template-columns: 38px 1.35fr 1fr .72fr .72fr .72fr 72px;
  align-items: center;
  min-height: 41px;
  padding: 0 10px;
  border-top: 1px solid rgba(255,255,255,.055);
  font-size: 10px;
  cursor: pointer;
  transition: .16s ease;
}
.table-row:hover, .table-row.selected { background: rgba(255,255,255,.03); }
.table-row.selected { box-shadow: inset 2px 0 var(--accent); }
.table-head { min-height: 30px; border-top: 0; color: #687285; cursor: default; text-transform: uppercase; letter-spacing: .06em; font-size: 8px; }
.table-head:hover { background: transparent; }
.rank-num { color: #697386; font-variant-numeric: tabular-nums; }
.company-cell { display: flex; align-items: center; gap: 8px; }
.company-cell .company-mark { width: 27px; height: 27px; border-radius: 8px; font-size: 8px; }
.company-cell strong { display: block; font-size: 10px; }
.company-cell span { display: block; color: #6f798b; font-size: 8px; margin-top: 2px; }
.score-badge { justify-self: end; min-width: 40px; text-align: center; padding: 5px 7px; border-radius: 999px; background: rgba(201,255,79,.09); color: var(--accent); font-weight: 900; }
.metric-inline { color: #b6becb; }
.metric-inline.risk-high { color: var(--danger); }
.metric-inline.risk-low { color: var(--accent-2); }

.ranking-bars { display: grid; gap: 8px; padding-top: 5px; }
.bar-row { display: grid; grid-template-columns: 95px 1fr 32px; gap: 10px; align-items: center; cursor: pointer; }
.bar-name { font-size: 10px; color: #b7c0ce; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 22px; background: #1e2430; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; display: flex; align-items: center; padding-left: 9px; border-radius: inherit; background: linear-gradient(90deg, rgba(139,255,207,.65), rgba(201,255,79,.85)); color: #0a0d12; font-weight: 900; font-size: 9px; min-width: 28px; transition: width .3s ease; }
.bar-score { text-align: right; font-size: 10px; color: var(--accent); font-weight: 900; }

.empty-state { padding: 36px 16px; text-align: center; color: var(--muted); font-size: 12px; }
.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 50;
  opacity: 0; transform: translateY(12px); pointer-events: none;
  padding: 12px 14px; border-radius: 12px; background: #f1f5ea; color: #151812;
  font-size: 11px; font-weight: 800; box-shadow: 0 14px 40px rgba(0,0,0,.35); transition: .25s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-height: 820px) {
  .control-panel { padding: 17px; }
  .search-box { margin: 15px 0; }
  .control-group { margin-bottom: 13px; }
  .divider { margin: 15px 0; }
  .weight-controls { gap: 9px; }
  .model-note { margin-top: 14px; }
  .chart-card, .detail-card { height: 322px; }
  .ranking-card { min-height: 250px; }
  .table-row { min-height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
