/* ─── Variables ─────────────────────────────────────────────────── */
:root {
  --bg:            #f5f6fa;
  --surface:       #ffffff;
  --surface-2:     #f8f9fc;
  --border:        #e2e6ef;
  --border-strong: #c8d0e0;
  --border-focus:  #1a56db;
  --text:          #0f1117;
  --text-muted:    #5a6478;
  --text-light:    #9ba3b6;
  --primary:       #1a56db;
  --primary-dark:  #1348c0;
  --success:       #059669;
  --danger:        #dc2626;
  --header-bg:     #0d1b2e;
  --header-text:   #e5eaf3;
  --header-muted:  #8fa3c3;
  --radius:        4px;
  --radius-lg:     6px;
  --shadow-sm:     0 1px 3px rgba(13, 27, 46, 0.07), 0 1px 2px rgba(13, 27, 46, 0.04);
  --shadow-md:     0 4px 12px rgba(13, 27, 46, 0.10), 0 2px 4px rgba(13, 27, 46, 0.05);
}

/* ─── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Base ───────────────────────────────────────────────────────── */
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ─── Nav ───────────────────────────────────────────────────────── */
header {
  background: var(--header-bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  position: sticky;
  top: 0;
  z-index: 100;
}

nav {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 54px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  position: relative;
}

.logo {
  font-weight: 700;
  font-size: 1rem;
  color: #ffffff;
  text-decoration: none;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.logo-mark {
  width: 28px;
  height: 28px;
  display: block;
  flex-shrink: 0;
}

nav ul {
  list-style: none;
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

nav a {
  color: var(--header-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 450;
  transition: color 0.15s;
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius);
}

nav a:hover { color: var(--header-text); }
nav a.active { color: var(--header-text); background: rgba(255,255,255,0.08); }

/* ─── Layout ─────────────────────────────────────────────────────── */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.container { width: 100%; }

/* ─── Landing hero ───────────────────────────────────────────────── */
.landing {
  max-width: 640px;
  margin: 4rem auto 0;
  text-align: center;
}

.landing-eyebrow {
  display: inline-block;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.25rem 0.75rem;
  border-radius: 2px;
  margin-bottom: 1.25rem;
}

.landing-title {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.08;
  color: var(--text);
  margin-bottom: 1rem;
}

.landing-desc {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 2rem;
}

.btn-lg {
  padding: 0.65rem 1.6rem;
  font-size: 0.9375rem;
}

.landing-meta {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  margin-top: 2.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.meta-item { text-align: center; }

.meta-label {
  display: block;
  font-size: 0.67rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-light);
  margin-bottom: 0.2rem;
}

.meta-value {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

/* ─── Nav search (centered, dark) ───────────────────────────────── */
.nav-search-wrap {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 340px;
}
.nav-search-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.11);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 0 1rem;
  height: 36px;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.nav-search-row:focus-within {
  background: rgba(255, 255, 255, 0.17);
  border-color: rgba(255, 255, 255, 0.42);
  box-shadow: 0 0 0 3px rgba(99, 163, 255, 0.22);
}
.nav-search-icon {
  color: rgba(255, 255, 255, 0.45);
  flex-shrink: 0;
}
.nav-search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--header-text);
  font-size: 0.875rem;
  padding: 0;
  min-width: 0;
}
.nav-search-input::placeholder { color: rgba(255, 255, 255, 0.38); }
.nav-search-input::-webkit-search-cancel-button { display: none; }

/* ─── Search bar ─────────────────────────────────────────────────── */
.search-wrap {
  position: relative;
  max-width: 520px;
  margin: 1.75rem auto 0;
}

.search-wrap-page {
  margin: 0 0 2rem;
  max-width: 560px;
}

.search-input-row {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: 999px;
  padding: 0 0.4rem 0 1.1rem;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input-row:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}
.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  padding: 0.7rem 0;
  background: transparent;
  color: var(--text);
}
.search-input::placeholder { color: var(--text-light); }
/* Remove default browser search-cancel button */
.search-input::-webkit-search-cancel-button { display: none; }
.search-btn {
  flex-shrink: 0;
  background: var(--primary);
  border: none;
  border-radius: 999px;
  color: #fff;
  padding: 0.45rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin: 3px 0;
}
.search-btn:hover { background: var(--primary-dark); }

.search-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  z-index: 200;
  overflow: hidden;
}
.suggestions-list { display: flex; flex-direction: column; }
.suggestion-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.55rem 1rem;
  color: var(--text);
  text-decoration: none;
  transition: background 0.1s;
  border-bottom: 1px solid var(--border);
}
.suggestion-item:last-of-type { border-bottom: none; }
.suggestion-item:hover, .suggestion-item:focus { background: var(--surface-2); outline: none; }
.suggestion-name { font-size: 0.9rem; font-weight: 500; }
.suggestion-meta { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.suggestion-footer {
  display: block;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--primary);
  background: var(--surface-2);
  text-decoration: none;
  border-top: 1px solid var(--border);
}
.suggestion-footer:hover { text-decoration: underline; }

/* ─── Search results page ─────────────────────────────────────── */
.search-page {
  max-width: 960px;
  margin: 2.5rem auto 0;
}
.search-page-header { margin-bottom: 0; }
.search-results-header {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.search-results-count {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th {
  background: var(--header-bg);
  color: var(--header-text);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.6rem 0.9rem;
  text-align: left;
  white-space: nowrap;
}
.data-table td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.mono-cell { font-family: "SF Mono", "Fira Code", monospace; font-size: 0.8rem; color: var(--text-muted); }
.bransch-cell { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius);
  background: #dbeafe;
  color: #1d4ed8;
}

/* ─── Landing distribution charts (bransch + kommun) ─────────────── */
.landing-dist-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  margin-top: 3rem;
  padding-top: 3rem;
  border-top: 1px solid var(--border);
}
.landing-dist-card {
  min-width: 0;
}
.landing-bransch-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.2rem;
}
.landing-bransch-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.bransch-chart {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.bc-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.bc-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.82rem;
}
.bc-label { color: var(--text); }
.bc-count {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}
.bc-bar-wrap {
  background: var(--border);
  border-radius: 3px;
  height: 7px;
  overflow: hidden;
}
.bc-bar {
  height: 100%;
  background: var(--primary);
  opacity: 0.5;
  border-radius: 3px;
  min-width: 2px;
}

/* ─── Landing mini-tables section ────────────────────────────────── */
.mini-tables-section {
  margin-top: 4rem;
  padding-top: 3rem;
  border-top: 1px solid var(--border);
}

.mini-tables-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.mini-table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.mini-table-header {
  padding: 0.875rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.mini-table-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.mini-table-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.mini-table th {
  padding: 0.4rem 0.75rem;
  font-size: 0.67rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
  text-align: left;
  background: transparent;
  white-space: nowrap;
}

.mini-table td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid #f0f3f8;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-table tbody tr:last-child td { border-bottom: none; }
.mini-table tbody tr:hover { background: var(--surface-2); }

.rank-cell {
  color: var(--text-light);
  font-size: 0.75rem;
  font-weight: 600;
  width: 28px;
  text-align: center;
}

.company-link {
  color: var(--primary);
  font-weight: 500;
  text-decoration: none;
  transition: color 0.12s;
}

.company-link:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

/* ─── Page header ────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.back-link {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  display: inline-block;
  margin-bottom: 0.5rem;
  transition: color 0.12s;
}

.back-link:hover { color: var(--text); }

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.15rem;
}

.page-actions {
  display: flex;
  gap: 0.6rem;
  flex-shrink: 0;
  margin-top: 0.35rem;
}

/* ─── Section title ──────────────────────────────────────────────── */
.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 0.875rem;
}

.similar-section {
  margin-top: 3rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}
.similar-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.similar-table .company-link { font-weight: 500; }
.similar-kommun {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ─── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.45rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, opacity 0.12s, box-shadow 0.12s;
  white-space: nowrap;
  line-height: 1;
  font-family: inherit;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(26, 86, 219, 0.28);
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 2px 6px rgba(26, 86, 219, 0.38);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
  background: var(--surface-2);
  border-color: #a8b4c8;
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ─── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 1.1rem 1.25rem 0.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card-body {
  padding: 0 1.25rem 0.75rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  flex: 1;
}

.card-footer {
  padding: 0.85rem 1.25rem;
  display: flex;
  gap: 0.6rem;
  border-top: 1px solid var(--border);
}

/* ─── Badge ──────────────────────────────────────────────────────── */
.badge {
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 2px;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

/* ─── Filter bar ─────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.input-search,
.input-select {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.input-search { flex: 1; min-width: 180px; }

.input-search:focus,
.input-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.10);
}

/* ─── Table meta row ─────────────────────────────────────────────── */
.table-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  min-height: 2rem;
}

.export-links {
  display: flex;
  gap: 0.4rem;
}

/* ─── Table ──────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.8375rem;
}

thead tr {
  background: var(--surface-2);
}

th {
  text-align: left;
  padding: 0.65rem 0.875rem;
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 0.575rem 0.875rem;
  border-bottom: 1px solid #edf0f7;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tbody tr:hover { background: #f8faff; }
tbody tr:last-child td { border-bottom: none; }

/* ─── Status alerts ──────────────────────────────────────────────── */
#ingest-status:not(:empty) { margin-bottom: 1rem; }

.status {
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.status-success { background: #d1fae5; color: #065f46; }
.status-error   { background: #fee2e2; color: #991b1b; }

/* ─── Empty & loading states ─────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
}

.empty-state p + p { margin-top: 0.5rem; }

.empty-cell {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  white-space: normal;
  font-size: 0.875rem;
}

.loading {
  text-align: center;
  padding: 2.5rem;
  color: var(--text-light);
  font-size: 0.875rem;
}

/* ─── htmx indicator ─────────────────────────────────────────────── */
.htmx-request.btn { opacity: 0.65; cursor: wait; }

/* ─── Footer ─────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 2rem 1.5rem;
  margin-top: 4rem;
  color: var(--text-light);
  font-size: 0.78rem;
  border-top: 1px solid var(--border);
}

/* ─── Numeric cells ──────────────────────────────────────────────── */
.num-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
  font-family: "SF Mono", "Fira Mono", "Consolas", monospace;
}

.num-neg { color: var(--danger); }
.num-pos { color: var(--success); }

/* ─── Pagination ─────────────────────────────────────────────────── */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 0;
}

.pagination-info {
  color: var(--text-muted);
  font-size: 0.8125rem;
  min-width: 120px;
  text-align: center;
}

/* ─── Screener page ──────────────────────────────────────────────── */
.screener-page { width: 100%; }

/* Screener table */
.screener-table thead tr:first-child {
  background: var(--header-bg);
}

.screener-table thead tr:first-child th {
  color: var(--header-muted);
  border-bottom: none;
  padding: 0.65rem 0.75rem;
  font-size: 0.66rem;
  letter-spacing: 0.09em;
}

/* Column min-widths (keyed by data-col so they survive column toggling) */
.screener-table th[data-col="foretagsnamn"]        { min-width: 165px; }
.screener-table th[data-col="org_nr"]              { min-width: 110px; }
.screener-table th[data-col="period_end"]          { min-width: 90px;  }
.screener-table th[data-col="nettoomsattning"]     { min-width: 130px; }
.screener-table th[data-col="rorelseresultat"]     { min-width: 135px; }
.screener-table th[data-col="arets_resultat"]      { min-width: 125px; }
.screener-table th[data-col="rorelsemarginal"]     { min-width: 125px; }
.screener-table th[data-col="vinstmarginal"]       { min-width: 115px; }
.screener-table th[data-col="eget_kapital"]        { min-width: 120px; }
.screener-table th[data-col="tillgangar"]          { min-width: 115px; }
.screener-table th[data-col="medelantal_anstallda"]{ min-width: 90px;  }
.screener-table th[data-col="rev_cagr_3yr"]        { min-width: 115px; }
.screener-table th[data-col="rev_cagr_5yr"]        { min-width: 115px; }
.screener-table th[data-col="resultat_cagr_3yr"]   { min-width: 110px; }
.screener-table th[data-col="resultat_cagr_5yr"]   { min-width: 110px; }
.screener-table th[data-col="bransch"]             { min-width: 130px; }
.screener-table th[data-col="kommun"]              { min-width: 100px; }

/* Column visibility toggling */
.screener-table.hide-col-org_nr            [data-col="org_nr"]            { display: none; }
.screener-table.hide-col-arets_resultat    [data-col="arets_resultat"]    { display: none; }
.screener-table.hide-col-vinstmarginal     [data-col="vinstmarginal"]     { display: none; }
.screener-table.hide-col-eget_kapital      [data-col="eget_kapital"]      { display: none; }
.screener-table.hide-col-tillgangar        [data-col="tillgangar"]        { display: none; }
.screener-table.hide-col-rev_cagr_5yr      [data-col="rev_cagr_5yr"]      { display: none; }
.screener-table.hide-col-resultat_cagr_3yr [data-col="resultat_cagr_3yr"] { display: none; }
.screener-table.hide-col-resultat_cagr_5yr [data-col="resultat_cagr_5yr"] { display: none; }
.screener-table.hide-col-kommun            [data-col="kommun"]            { display: none; }

/* Column picker */
.col-picker-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.4rem;
}

.col-picker { position: relative; }

.col-picker-panel {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 0.4rem;
  z-index: 100;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 175px;
}

.col-picker-panel.is-open { display: flex; }

.col-picker-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.28rem 0.4rem;
  font-size: 0.8125rem;
  cursor: pointer;
  border-radius: 3px;
  color: var(--text);
  user-select: none;
}

.col-picker-item:hover { background: var(--surface-2); }
.col-picker-item input[type="checkbox"] { cursor: pointer; accent-color: var(--primary); }

/* Filter row */
.filter-row th {
  padding: 0.35rem 0.5rem;
  background: #eef3fc;
  border-top: 1px solid #c7d7f4;
  border-bottom: 2px solid #c7d7f4;
}

.col-filter-input {
  width: 100%;
  padding: 0.28rem 0.4rem;
  font-size: 0.75rem;
  font-family: inherit;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.col-filter-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.10);
}

.col-filter-input::placeholder { color: var(--text-light); }

.range-inputs { display: flex; gap: 0.3rem; }
.range-inputs input { flex: 1; min-width: 0; }

/* Result count badge */
.result-count-badge {
  display: inline-block;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  border-radius: 2px;
  letter-spacing: 0.01em;
}

/* Cap warning */
.cap-warning {
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  color: #92400e;
  font-size: 0.825rem;
  padding: 0.6rem 0.9rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 0.75rem;
}

/* ─── Sidebar (datasets page) ────────────────────────────────────── */
.screener-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.filter-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem;
  position: sticky;
  top: 70px;
  max-height: calc(100vh - 84px);
  overflow-y: auto;
}

.filter-section {
  padding-bottom: 0.9rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.filter-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0.5rem;
  padding-bottom: 0;
}

.filter-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.sidebar-input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.825rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.sidebar-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.08);
}

/* ─── Company detail page ────────────────────────────────────────── */
.company-header {
  margin-bottom: 1.5rem;
}

.company-title-row h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  color: var(--text);
  margin-top: 0.25rem;
  margin-bottom: 0.6rem;
}

.company-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.company-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.15rem 0.5rem;
}

.company-desc {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.65;
}

.company-sni {
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sni-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: #e0e7ff;
  color: #3730a3;
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
}

/* KPI + Balance grid */
.company-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.company-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.company-card-header {
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
}

.kpi {
  padding: 1rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.kpi:nth-child(4n) { border-right: none; }
.kpi:nth-last-child(-n+4) { border-bottom: none; }

.kpi-label {
  font-size: 0.67rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-light);
  margin-bottom: 0.3rem;
}

.kpi-value {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.kpi-neg { color: var(--danger); }
.kpi-pos { color: var(--success); }

/* Balance sheet */
.balance-table { padding: 0.5rem 0; }

.balance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 1rem;
  font-size: 0.8375rem;
  color: var(--text-muted);
}

.balance-row:hover { background: var(--surface-2); }

.balance-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-family: "SF Mono", "Fira Mono", "Consolas", monospace;
  font-size: 0.8125rem;
}

.balance-total {
  font-weight: 600;
  color: var(--text);
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
}

.balance-total:hover { background: var(--surface-2); }

.balance-divider {
  height: 1.25rem;
}

/* ─── Charts ─────────────────────────────────────────────────────── */
.charts-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1rem;
}

.chart-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.bar-chart {
  width: 100%;
  display: block;
}

.chart-baseline {
  stroke: var(--border-strong);
  stroke-width: 1.5;
}

.chart-gridline {
  stroke: var(--border);
  stroke-width: 0.5;
  stroke-dasharray: 3 3;
}

.chart-axis-label {
  font-size: 8.5px;
  fill: var(--text-muted);
  font-family: "Inter", sans-serif;
}

.chart-bar-pos {
  fill: var(--primary);
  opacity: 1;
  transition: opacity 0.12s;
}

.chart-bar-neg {
  fill: var(--danger);
  opacity: 1;
  transition: opacity 0.12s;
}


.chart-label {
  font-size: 9px;
  fill: var(--text-light);
  font-family: "Inter", sans-serif;
}

.bar-tooltip {
  font-size: 9.5px;
  font-weight: 600;
  fill: var(--text);
  font-family: "Inter", sans-serif;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s;
}

.chart-bar-group:hover .bar-tooltip {
  opacity: 1;
}

.chart-bar-group:hover .chart-bar-pos,
.chart-bar-group:hover .chart-bar-neg {
  opacity: 0.75;
}

/* ─── Financial statements (resultaträkning / balansräkning) ──────── */
.stmt-download-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

.stmt-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 900px) {
  .stmt-pair { grid-template-columns: 1fr; }
}

.stmt-section { margin-bottom: 2.5rem; }

.stmt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.stmt-table th,
.stmt-table td {
  padding: 0.3rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.stmt-label-col {
  min-width: 220px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stmt-table thead th.num-cell {
  font-weight: 600;
  color: var(--text-secondary);
}

.stmt-section-header td {
  background: var(--surface-2);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.stmt-group-header td {
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}

.stmt-row td { color: var(--text-secondary); }

.stmt-indent td:first-child { padding-left: 1.5rem; }

.stmt-subtotal td {
  font-weight: 600;
  color: var(--text);
  border-top: 1px solid var(--border);
}

.stmt-total td {
  font-weight: 700;
  color: var(--text);
  border-top: 2px solid var(--border);
}

.stmt-table tbody tr:hover td { background: var(--surface-2); }

/* ─── Company history ────────────────────────────────────────────── */
.company-history { margin-bottom: 2rem; }

/* ─── Source grid ────────────────────────────────────────────────── */
.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .mini-tables-grid { grid-template-columns: 1fr; }
  .charts-section { grid-template-columns: 1fr; }
  .company-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(2n) { border-right: none; }
  .kpi:nth-last-child(-n+2) { border-bottom: none; }
}

@media (max-width: 768px) {
  .screener-layout { grid-template-columns: 1fr; }
  .filter-sidebar { position: static; max-height: none; }
  .landing-title { font-size: 2rem; }
  .landing-meta { gap: 1.25rem; }
}

@media (max-width: 900px) {
  .nav-search-wrap { display: none; }
}

@media (max-width: 640px) {
  .page-header { flex-direction: column; }
  .source-grid { grid-template-columns: 1fr; }
  main { padding: 1.25rem 1rem; }
  .mini-tables-grid { grid-template-columns: 1fr; }
  nav { padding: 0 1rem; }
  .logo-text { display: none; }
}
