/* Palette/tokens ported from design/mf-screener-wireframe.html - see dataviz skill notes there. */
:root {
  --surface-1:      #fcfcfb;
  --page:           #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --axis:           #c3c2b7;
  --border:         rgba(11,11,11,0.10);
  --series-1:       #2a78d6;
  --series-1-soft:  rgba(42,120,214,0.14);
  --good:           #0ca30c;
  --warning:        #fab219;
  --critical:       #d03b3b;
  --good-bg:        rgba(12,163,12,0.12);
  --warning-bg:     rgba(250,178,25,0.18);
  --critical-bg:    rgba(208,59,59,0.12);
  --chip-neutral-bg: rgba(137,135,129,0.16);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface-1:      #1a1a19;
    --page:           #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --gridline:       #2c2c2a;
    --axis:           #383835;
    --border:         rgba(255,255,255,0.10);
    --series-1:       #3987e5;
    --series-1-soft:  rgba(57,135,229,0.20);
    --good-bg:        rgba(12,163,12,0.20);
    --warning-bg:     rgba(250,178,25,0.22);
    --critical-bg:    rgba(208,59,59,0.20);
    --chip-neutral-bg: rgba(137,135,129,0.22);
  }
}

* { box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  margin: 0;
  min-height: 100vh;
}

.app-header {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.app-header .left { display: flex; align-items: center; gap: 14px; }
.brand { font-weight: 700; font-size: 15px; }
.brand span { color: var(--text-muted); font-weight: 500; }

select.category-select {
  font: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 24px 0 24px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
}
.tab-btn.active { color: var(--text-primary); border-bottom-color: var(--series-1); }

.panel { padding: 20px 24px; max-width: 1180px; margin: 0 auto; }

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 4px 0 10px 0;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.table-scroll {
  /* The table can be wider than the card (many columns) - scroll it inside
     its own container rather than letting the card's overflow:hidden (there
     for rounded corners) silently clip columns off the right edge. */
  overflow-x: auto;
}
table.screener { width: 100%; border-collapse: collapse; font-size: 13px; }
table.screener th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-muted); padding: 10px 12px; border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}
table.screener td {
  padding: 10px 12px; border-bottom: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
table.screener tbody tr { cursor: pointer; }
table.screener tbody tr:hover, table.screener tbody tr.selected { background: var(--series-1-soft); }
table.screener tbody tr:last-child td { border-bottom: none; }
.fund-name {
  font-weight: 600;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  /* white-space: nowrap already applies via table.screener td */
}

.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700;
  padding: 4px 9px; border-radius: 20px;
}
.badge.recommended { background: var(--good-bg); color: var(--good); }
.badge.neutral { background: var(--warning-bg); color: var(--warning); }
.badge.avoid { background: var(--critical-bg); color: var(--critical); }
.badge.unscored { background: var(--chip-neutral-bg); color: var(--text-secondary); }

.detail-wrap { margin-top: 18px; }
.detail-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.detail-head h3 { margin: 0; font-size: 16px; }
.funnel { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.gate-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.gate-card.disabled { opacity: .45; }
.gate-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.gate-card-head h4 { margin: 0; font-size: 13px; }
.metric-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 4px 0; color: var(--text-secondary); }
.metric-row b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.stop-note { margin-top: 10px; font-size: 12px; color: var(--text-secondary); border-top: 1px dashed var(--gridline); padding-top: 8px; }
.final-banner { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-radius: 10px; font-size: 13px; }
.final-banner.recommended { background: var(--good-bg); }
.final-banner.neutral { background: var(--warning-bg); }
.final-banner.avoid { background: var(--critical-bg); }
.final-banner .score { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

svg text { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.chart-wrap { position: relative; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 9px; font-size: 11.5px; box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  opacity: 0; transition: opacity .1s; white-space: nowrap; z-index: 5;
}
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-secondary); margin-top: 8px; flex-wrap: wrap; }
.legend .item { display: flex; align-items: center; gap: 6px; }
.legend .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.table-toggle-row { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.ghost-btn {
  font: inherit; font-size: 12px; font-weight: 600; padding: 6px 11px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-secondary); cursor: pointer;
}
.ghost-btn:hover { background: var(--series-1-soft); }

.note-banner {
  background: var(--chip-neutral-bg); border-radius: 10px; padding: 12px 16px;
  font-size: 12.5px; color: var(--text-secondary); margin-bottom: 14px;
}

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; font-size: 12.5px; color: var(--text-secondary);
  border-top: 1px solid var(--gridline);
}
.pagination .ghost-btn[disabled] { opacity: .4; pointer-events: none; }

/* Login page */
.login-wrap { max-width: 360px; margin: 80px auto; padding: 28px; }
.login-wrap h1 { font-size: 18px; margin-bottom: 20px; }
.login-wrap form p { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.login-wrap label { font-size: 12px; color: var(--text-secondary); }
.login-wrap input {
  font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--page); color: var(--text-primary);
}
.login-wrap button {
  font: inherit; font-size: 13px; font-weight: 600; padding: 9px 14px; border-radius: 7px;
  border: none; background: var(--series-1); color: #fff; cursor: pointer; margin-top: 6px;
}
.login-wrap .errorlist { color: var(--critical); font-size: 12px; list-style: none; padding: 0; }
