:root {
  --paper: #ffffff;
  --ink: #121316;
  --muted: #6b6f76;
  --line: #e3e4e7;
  --card: #f6f7f8;
  --accent: #2a4cff;
  --accent-ink: #ffffff;
  --accent-soft: #e8ecff;
  --danger: #b3261e;
  --good: #0e7a5f;
  --good-soft: #e3f0ea;
  --warn: #8a6100;
  --warn-soft: #f6ecd2;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0a0b0d;
    --ink: #edeef0;
    --muted: #90949c;
    --line: #26282d;
    --card: #17181b;
    --accent: #6b87ff;
    --accent-ink: #0a0b0d;
    --accent-soft: #1b2140;
    --danger: #ff7a6e;
    --good: #4cc39a;
    --good-soft: #1e332b;
    --warn: #e0b64a;
    --warn-soft: #362c12;
  }
}
:root[data-theme="dark"] {
  --paper: #0a0b0d;
  --ink: #edeef0;
  --muted: #90949c;
  --line: #26282d;
  --card: #17181b;
  --accent: #6b87ff;
  --accent-ink: #0a0b0d;
  --accent-soft: #1b2140;
  --danger: #ff7a6e;
  --good: #4cc39a;
  --good-soft: #1e332b;
  --warn: #e0b64a;
  --warn-soft: #362c12;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Archivo", "Segoe UI", system-ui, sans-serif;
  line-height: 1.55;
}
h1, h2, h3, .display {
  font-family: "Archivo", system-ui, sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin: 0 0 12px;
}
.mono {
  font-family: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
}
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 11px 20px; border-radius: 3px;
  font-size: 14px; font-weight: 600; font-family: inherit;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  background: transparent; color: var(--ink); border-color: var(--line);
}
.btn-accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-small { padding: 6px 12px; font-size: 12.5px; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.field { text-align: left; margin: 0 0 16px; }
.field label,
.field .field-label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.field input,
.field select,
.field textarea {
  width: 100%; padding: 11px 13px; border-radius: 3px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); font-size: 15px; font-family: inherit;
}
.field textarea { resize: vertical; min-height: 70px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

.status-msg { font-size: 14px; margin-top: 12px; min-height: 20px; }
.status-msg.ok { color: var(--accent); }
.status-msg.err { color: var(--danger); }

/* Shell */
.top-bar {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 1080px; margin: 0 auto; padding: 20px; font-size: 14px;
}
.top-bar .brand { font-weight: 700; }
.top-bar .who { color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: 12.5px; }
.top-bar nav { display: flex; gap: 16px; align-items: center; }

.app-wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px 80px; }

.tabbar {
  display: flex; gap: 4px; border-bottom: 1px solid var(--line);
  margin-bottom: 28px; overflow-x: auto;
}
.tab {
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 12px 16px; cursor: pointer; white-space: nowrap;
}
.tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }
.view { display: none; }
.view.is-active { display: block; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 24px;
  margin-bottom: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-sub { color: var(--muted); font-size: 13.5px; margin: -6px 0 16px; }
.section-title { font-size: 17px; margin: 8px 0 14px; }

.empty-note { color: var(--muted); font-size: 14px; padding: 10px 0; }

/* Sortable overview table */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th {
  text-align: left; color: var(--muted); font-weight: 500; padding: 8px 10px;
  font-family: "IBM Plex Mono", monospace; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.04em; border-bottom: 1px solid var(--line); cursor: pointer; white-space: nowrap;
}
table.data-table th:hover { color: var(--ink); }
table.data-table th.is-sorted { color: var(--accent); }
table.data-table th .arrow { margin-left: 4px; opacity: 0.7; }
table.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.data-table tr.is-clickable { cursor: pointer; }
table.data-table tr.is-clickable:hover td { background: var(--paper); }

.badge {
  display: inline-block; font-family: "IBM Plex Mono", monospace;
  font-size: 10px; font-weight: 500; letter-spacing: 0.04em;
  text-transform: uppercase; padding: 3px 9px; border-radius: 2px;
  width: fit-content;
}
.badge-invest { background: var(--good-soft); color: var(--good); }
.badge-watch { background: var(--warn-soft); color: var(--warn); }
.badge-pass { background: #3a1b18; color: var(--danger); }
@media (prefers-color-scheme: light) { .badge-pass { background: #f7e2e0; } }
:root[data-theme="light"] .badge-pass { background: #f7e2e0; }
:root[data-theme="dark"] .badge-pass { background: #3a1b18; }
.badge-none { background: var(--line); color: var(--muted); }

/* Weight configurator */
.weights-grid { display: grid; gap: 12px; }
.weight-row { display: grid; grid-template-columns: 1fr 90px; gap: 12px; align-items: center; }
.weight-row label { font-size: 13.5px; font-weight: 500; }
.weight-row input[type="number"] {
  width: 100%; padding: 8px 10px; border-radius: 3px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); font-family: "IBM Plex Mono", monospace;
  font-size: 13.5px; text-align: right;
}
.weights-sum {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line);
  font-family: "IBM Plex Mono", monospace; font-size: 13px;
}
.weights-sum.is-ok { color: var(--good); }
.weights-sum.is-bad { color: var(--danger); }
.threshold-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
@media (max-width: 560px) { .threshold-row { grid-template-columns: 1fr; } }

/* Score sliders */
.slider-field { margin: 0 0 20px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.slider-head span.name { font-size: 14px; font-weight: 600; }
.slider-head span.val { font-family: "IBM Plex Mono", monospace; font-size: 13px; color: var(--accent); font-weight: 600; }
.slider-hint { font-size: 12.5px; color: var(--muted); margin: 2px 0 8px; }
input[type="range"] {
  width: 100%; accent-color: var(--accent); height: 4px; cursor: pointer;
}
.slider-scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); font-family: "IBM Plex Mono", monospace; }

/* Result panel */
.result-panel { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; margin-bottom: 6px; }
.result-score { font-family: "IBM Plex Mono", monospace; font-size: 42px; font-weight: 700; line-height: 1; }
.result-score-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }

/* Radar chart */
.chart-wrap { position: relative; display: flex; justify-content: center; }
canvas#radar-canvas { max-width: 100%; height: auto; }
.legend-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 18px; }
.legend-list li { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend-list li.is-checkable { cursor: pointer; }
.legend-list li.is-off { opacity: 0.4; }
.company-select-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.company-select-row .field { margin-bottom: 0; flex: 1; min-width: 200px; }

/* Methodology */
.method-dim { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 18px; }
.method-dim:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.method-dim h3 { font-size: 15.5px; margin-bottom: 6px; }
.method-weight { font-family: "IBM Plex Mono", monospace; font-size: 11.5px; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 2px; margin-left: 8px; }
.method-dim p { font-size: 14.5px; margin: 0 0 10px; max-width: 72ch; }

dialog.modal {
  border: 1px solid var(--line); border-radius: 4px; padding: 28px;
  background: var(--card); color: var(--ink); max-width: 480px; width: 92vw;
}
dialog.modal::backdrop { background: rgba(0,0,0,0.4); }
.modal-close-form { position: absolute; top: 10px; right: 10px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); padding: 4px 8px; }
