@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("vendor/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("vendor/fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Theme: light by default, dark from the system setting unless the visitor
   picked light with the toggle, or dark when they picked it explicitly. */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-muted: #56657a; /* ≥ 4.5:1 on both surface and bg */
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-strong: #1d4ed8; /* accent as small text on accent-soft (WCAG AA) */
  --accent-soft: #dbeafe;
  --good: #15803d; /* 4.9:1 on white, so small green text stays readable */
  --bad: #dc2626;
  --navy: #0b1b3a;
  --navy-2: #13295a;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 8px 30px rgba(15, 23, 42, 0.12);
  --code-keyword: #7c3aed;
  --code-string: #047857;
  --code-number: #b45309;
  --code-comment: #56657a;
  --code-builtin: #2563eb;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0f1c;
    --surface: #111827;
    --surface-2: #0f1626;
    --text: #e5e9f0;
    --text-muted: #94a3b8;
    --border: #1f2a3d;
    --accent: #60a5fa;
    --accent-strong: #93c5fd;
    --accent-soft: #1e3a5f;
    --good: #4ade80;
    --bad: #f87171;
    --navy: #070d1c;
    --navy-2: #0e1a36;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
    --code-keyword: #c4b5fd;
    --code-string: #6ee7b7;
    --code-number: #fcd34d;
    --code-comment: #9aa1ad;
    --code-builtin: #93c5fd;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0a0f1c;
  --surface: #111827;
  --surface-2: #0f1626;
  --text: #e5e9f0;
  --text-muted: #94a3b8;
  --border: #1f2a3d;
  --accent: #60a5fa;
  --accent-strong: #93c5fd;
  --accent-soft: #1e3a5f;
  --good: #4ade80;
  --bad: #f87171;
  --navy: #070d1c;
  --navy-2: #0e1a36;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  --code-keyword: #c4b5fd;
  --code-string: #6ee7b7;
  --code-number: #fcd34d;
  --code-comment: #9aa1ad;
  --code-builtin: #93c5fd;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

button, input, select, textarea { font-family: inherit; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  padding-bottom: 64px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Top bar + hero (navy band) --- */

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 0 16px;
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  color: #2563eb;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-toggle {
  height: 36px;
  min-width: 44px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lang-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* Show the icon for the theme you'd switch TO. */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

.hero {
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  padding: 28px 16px 30px;
}

.hero > * {
  max-width: 1080px;
  margin-left: auto;
  margin-right: auto;
}

.hero h1 {
  font-size: clamp(1.45rem, 3.2vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-top: 0;
  margin-bottom: 8px;
}

.hero p {
  color: #b6c2d9;
  margin-top: 0;
  margin-bottom: 0;
  font-size: 0.98rem;
}

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.hero .status-chip {
  /* Solid, so the background curve doesn't show through. */
  background: #13254d;
  border-color: rgba(255, 255, 255, 0.14);
  color: #cbd5e1;
}

.hero .status-chip.fail {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.6);
}

.hero .status-chip .dot {
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.18);
}

.hero .status-chip.fail .dot {
  background: #f87171;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.status-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  flex-shrink: 0;
}

.status-chip.fail .dot {
  background: var(--bad);
}

.status-chip.fail {
  color: var(--bad);
  border-color: var(--bad);
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 0;
}

/* --- Sticky tab bar --- */

.tabs-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
}

/* Tabs (scrolling sideways on phones) with the search button beside them. */
.tabs-row {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tabs-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.tabs-search {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.tabs-search svg { width: 18px; height: 18px; }
.tabs-search:hover { color: var(--text); background: color-mix(in srgb, var(--text) 7%, transparent); }

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  padding: 14px 12px 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--text);
  font-weight: 600;
}

.tabs { position: relative; }

/* One underline that slides to the active tab. */
.tab-indicator {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 0;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), width 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.panel.active {
  animation: panel-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .panel.active { animation: none; }
  .tab-indicator { transition: none; }
}

/* --- Chart legend: selected banks + picker + quick picks --- */

.legend-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 16px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.legend-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1 1 420px;
  min-width: 0;
}

.sel-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 100%;
  padding: 3px 3px 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.8rem;
  transition: border-color 0.15s, background 0.15s;
}

.sel-chip:hover {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 8%, var(--surface));
}

/* Marker = the line's color and point shape. */
.sel-dot {
  display: inline-flex;
  flex-shrink: 0;
  margin-right: 5px;
}

.sel-chip .avatar {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  margin-right: 5px;
  font-size: 0.6rem;
}

.sel-chip .avatar.wide { width: 34px; }

.sel-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
  font-weight: 500;
}

.sel-remove {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-left: 2px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.sel-remove:hover {
  background: var(--surface-2);
  color: var(--bad);
}

.legend-empty {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 4px 0;
}

.legend-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.bank-picker { position: relative; }

.picker-btn {
  font-weight: 600;
  border-style: dashed;
}

.picker-btn[aria-expanded="true"] {
  border-style: solid;
  border-color: var(--accent);
  color: var(--accent);
}

.picker-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 60;
  width: min(360px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 8px;
}

@media (max-width: 640px) {
  .picker-pop { right: auto; left: 0; }
}

.picker-search {
  width: 100%;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
}

.picker-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.picker-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  max-height: 300px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.picker-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 0.84rem;
}

.picker-item .avatar { margin: 0; }

.picker-item.active,
.picker-item:hover { background: var(--accent-soft); }

.picker-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-rate {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.picker-empty {
  padding: 12px 8px;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.quick-picks {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.quick-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
}

.quick-picks { flex-wrap: wrap; border-radius: 18px; }

.quick-btn:hover:not(:disabled):not(.active) {
  color: var(--text);
}

/* The quick pick the chart currently matches. */
.quick-btn.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 650;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12), 0 0 0 1px var(--border);
}

.quick-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* --- Chart download --- */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  min-width: 34px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.icon-btn svg { width: 16px; height: 16px; }

.controls .chart-download {
  margin-left: auto;
  align-self: flex-start;
}

.card-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: -6px 0 8px;
}

.day-panel-market {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dash {
  display: inline-block;
  width: 16px;
  border-top: 2px dashed var(--text-muted);
}

/* --- Clickable bank names --- */

.bank-open {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  text-align: left;
  cursor: pointer;
}

.bank-name {
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 4px;
}

.bank-name:hover,
.bank-open:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* Name + ↗ (+ pill) side by side; the ↗ stays on the first line even when a
   long name wraps. */
.bank-cell > div {
  display: flex;
  align-items: baseline;
  gap: 0 2px;
  min-width: 0;
}

.bank-cell .pill { margin-left: 6px; white-space: nowrap; }

.bank-cell .bank-name { flex: 0 1 auto; min-width: 0; }

/* KPI card: one line, name shortened with … */
.kpi-ellipsis {
  display: flex;
  align-items: center;
  min-width: 0;
}

.kpi-ellipsis .bank-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ext-link {
  margin-left: 6px;
  font-size: 0.78em;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0 3px;
  border-radius: 4px;
}

.ext-link:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.day-panel-list .name.bank-open {
  display: block;
  width: 100%;
}

/* --- Calculator --- */

.calc-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 12px 14px;
  margin-bottom: 6px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.calc-icon {
  width: 22px;
  height: 22px;
  color: var(--accent);
  flex-shrink: 0;
}

.calc-amount {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 500;
}

.calc-input-wrap {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 10px 0 0;
}

.calc-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.calc-input {
  width: 120px;
  border: none;
  background: none;
  color: var(--text);
  padding: 7px 8px 7px 10px;
  font-size: 0.95rem;
  font-weight: 650;
  text-align: right;
  font-variant-numeric: tabular-nums;
  outline: none;
}

.calc-cur {
  color: var(--text-muted);
  font-weight: 600;
}

.calc-tax {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}

.calc-note { margin: 0 0 12px; }

.earn {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.earn-best { color: var(--good); font-weight: 600; }

/* --- Bank detail drawer --- */

.drawer-root[hidden] { display: none; }

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(8, 15, 30, 0.45);
  opacity: 0;
  transition: opacity 0.25s;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 91;
  width: min(520px, 100vw);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  outline: none;
}

.drawer-root.open .drawer-backdrop { opacity: 1; }
.drawer-root.open .drawer { transform: none; }

@media (prefers-reduced-motion: reduce) {
  .drawer, .drawer-backdrop { transition: none; }
}

html.drawer-lock { overflow: hidden; }

.drawer-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 20px 24px;
}

.drawer-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin: 0 -20px;
  padding: 18px 20px 14px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.drawer-logo .avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  margin: 0;
  font-size: 1.2rem;
}

.drawer-logo .avatar.wide { width: 96px; }

.drawer-titles { flex: 1; min-width: 0; }

.drawer-titles h2 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.drawer-product {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 2px;
}

.drawer-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.drawer-close { flex-shrink: 0; }

.drawer-hero,
.drawer-section,
.dstat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.drawer-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: 16px 18px;
}

.drawer-rate {
  font-size: 2.4rem;
  font-weight: 750;
  letter-spacing: -0.035em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.drawer-delta { font-size: 0.85rem; margin-top: 4px; }

.drawer-hero-side { text-align: right; }

.drawer-rank {
  font-size: 1.6rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.drawer-rank span {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 4px;
}

.drawer-both {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.drawer-section { padding: 14px 16px; }

.drawer-section h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.drawer-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.drawer-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.drawer-chart {
  position: relative;
  height: 220px;
}

.dstats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 420px) {
  .dstats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drawer-rate { font-size: 2rem; }
}

.dstat { padding: 12px 14px; min-width: 0; }

.dstat-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.dstat-value {
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.dstat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.drawer-earn {
  font-size: 1.6rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  margin: 2px 0;
  color: var(--good);
  font-variant-numeric: tabular-nums;
}

/* Terms (Forbrukerrådet) */
.term-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.term-tag {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.term-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  margin: 0 0 10px;
  font-size: 0.84rem;
}

.term-facts dt { color: var(--text-muted); }
.term-facts dd { margin: 0; }

.term-text summary {
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--accent-strong);
}

.term-text p {
  white-space: pre-line;
  font-size: 0.86rem;
  line-height: 1.6;
  margin: 8px 0 0;
}

.terms > .note { margin: 8px 0 0; }

/* Related accounts (same bank, and same bank at other sources) */
.related .note { margin: 8px 0 0; }

.rel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rel-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 62px 38px 44px 14px;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 8px;
  border: none;
  border-radius: 10px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

button.rel-row { cursor: pointer; }
button.rel-row:hover { background: var(--surface-2); }
button.rel-row:hover .rel-go { color: var(--accent); }

.rel-row.current { background: var(--accent-soft); }

.rel-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

/* Name on top, type (or source) label underneath. */
.rel-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 0;
}

.rel-main .pill { font-size: 0.6875rem; /* 11px minimum */ }
.rel-rate { font-weight: 700; text-align: right; }
.rel-rank { color: var(--text-muted); font-size: 0.76rem; text-align: right; }
.rel-delta { font-size: 0.76rem; text-align: right; }
.rel-go { color: var(--text-muted); font-size: 1.1rem; line-height: 1; }

.rel-tag {
  font-size: 0.6875rem; /* 11px minimum */
  font-weight: 600;
  color: var(--accent-strong);
  white-space: nowrap;
}

.rel-row.current { grid-template-columns: minmax(0, 1fr) 62px 38px 44px auto; }

@media (max-width: 480px) {
  .rel-row { grid-template-columns: minmax(0, 1fr) 58px 34px 14px; }
  .rel-row.current { grid-template-columns: minmax(0, 1fr) 58px 34px auto; }
  .rel-delta { display: none; }
}

.drawer-back { flex-shrink: 0; }

.change-log {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.change-log li {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.change-log li:last-child { border-bottom: none; }

.change-date { color: var(--text-muted); }

.drawer-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin: 0 -20px -24px;
  padding: 14px 20px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}

.drawer-actions .btn { text-decoration: none; }

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.15s;
}

.skip-link:focus { top: 12px; }

main:focus { outline: none; }

/* Sortable column headers are buttons (keyboard-accessible). */
.th-sort {
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
}

.th-sub {
  display: block;
  font-size: 0.6875rem; /* 11px minimum */
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
}

/* Compact table on desktop: the compare button is just + / ✓ (label in the
   tooltip, and shown again on the phone cards), and the small helper lines
   under the numbers may wrap instead of widening their column. */
.bank-table .compare-btn span { display: none; }
.bank-table .compare-btn { padding: 3px 9px; }
.bank-table td.num .range-hint { white-space: normal; }
.nw { white-space: nowrap; }
.bank-table td.num .range-hint.nw { white-space: nowrap; }

/* Trend: sparkline with the period change next to it. */
.trend-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

.trend-num {
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 34px;
}

/* "/280" lives in the tooltip on desktop; the phone cards show it. */
.bank-table .rank-total { display: none; }
@media (max-width: 640px) {
  .bank-table .rank-total { display: inline; }
}

/* The compare button is "+" / "✓" on phones too (label for screen readers
   comes from its title/aria), so the card's last line fits. */

/* Chosen rate (bold) next to the other one (muted). */
.td-primary .rate { font-weight: 700; }
.td-secondary .rate { font-weight: 400; color: var(--text-muted); }

.th-check { width: 36px; }

.th-icon {
  width: 15px;
  height: 15px;
  display: block;
  color: var(--text-muted);
}

/* Sticky column headings while scrolling the table (desktop). The table
   fits without sideways scrolling there, so its wrapper can stop clipping,
   which is what lets the header stick to the page. */
@media (min-width: 900px) {
  .table-scroll.fits { overflow: visible; }

  .table-scroll.fits .bank-table thead th {
    position: sticky;
    top: var(--tabs-h, 49px);
    z-index: 5;
    background: var(--surface);
    box-shadow: inset 0 -1px 0 var(--border);
  }
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.check-label span { display: none; }

.rank-total { color: var(--text-muted); font-weight: 400; }

.mobile-sort { display: none; }

/* --- Phones: the bank table becomes a list of cards --- */

@media (max-width: 640px) {
  .bank-table { min-width: 0; }
  .bank-table thead { display: none; }

  .bank-table,
  .bank-table tbody { display: block; }

  .bank-table tbody tr {
    display: grid;
    /* Compact card, 3 lines: name + rank / chosen rate, trend, today /
       type, in-chart, compare. The other rate and "per år" are in the
       bank panel (tap the name). */
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "bank  bank  rank"
      "rate  spark delta"
      "type  check cmp";
    align-items: center;
    gap: 8px 12px;
    padding: 12px 14px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
  }

  .bank-table tbody tr:hover { background: var(--surface); }

  .bank-table td,
  .bank-table td.num {
    padding: 0;
    border: none;
    text-align: left;
    min-width: 0;
  }

  .bank-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.6875rem; /* 11px minimum */
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 2px;
  }

  .td-bank { grid-area: bank; }
  .td-rank { grid-area: rank; text-align: right !important; font-weight: 700; font-size: 1.05rem; }
  .td-primary { grid-area: rate; }
  .td-primary .rate { font-size: 1.3rem; }
  .td-secondary, .td-earn, .bank-table td.num .range-hint:not(.nw) { display: none; }
  .td-primary::before { display: none !important; }
  .td-spark { grid-area: spark; }
  .td-delta { grid-area: delta; text-align: right !important; }
  .td-delta::before { display: inline !important; margin-right: 6px; }
  .td-type { grid-area: type; }
  .td-check { grid-area: check; justify-self: end; white-space: nowrap; }
  .td-type { min-width: 0; }
  .td-type .pill { white-space: nowrap; }
  .td-cmp { grid-area: cmp; }
  .td-rank { font-size: 0.95rem; }
  .td-bank .bank-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* Bigger tap targets (≥ 32 px) on phones. */
  .check-label { min-height: 32px; }
  .check-label input { width: 20px; height: 20px; }
  .bank-table .compare-btn { min-height: 32px; min-width: 40px; justify-content: center; padding: 4px 12px; }
  .sel-remove { width: 32px; height: 32px; }
  .quick-btn, .type-btn, .toggle-btn, .period-btn { min-height: 32px; }

  .check-label span { display: inline; font-size: 0.78rem; color: var(--text-muted); }

  .bank-table .table-empty { display: block; }
  .bank-table .table-empty td { display: block; }

  .table-scroll:has(.bank-table) { overflow: visible; }

  .mobile-sort {
    display: block;
    flex: 1;
    min-width: 160px;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* --- Policy rate --- */

.policy-chip {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin: 0 0 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.8rem;
}

.policy-chip svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
  flex-shrink: 0;
}

.policy-chip-sub { color: var(--text); opacity: 0.85; }

.day-panel-policy {
  margin: 0 0 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
}

/* --- Compare: table button, bottom bar, modal --- */

.compare-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  border: 1px dashed var(--border);
  background: none;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.compare-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
}

.compare-btn.on {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.compare-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.drawer-compare.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.compare-bar {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 24px);
  padding: 10px 12px 10px 14px;
  border-radius: 16px;
  background: var(--navy);
  color: #fff;
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, 140%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.compare-bar.show { transform: translate(-50%, 0); }

body.has-compare-bar { padding-bottom: 110px; }

.compare-bar-items {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  min-width: 0;
  scrollbar-width: none;
}

.compare-bar-item {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px 4px 4px 6px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.8rem;
  white-space: nowrap;
}

.compare-bar-item .avatar { margin-right: 6px; }

.compare-bar-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compare-bar-item button {
  border: none;
  background: none;
  color: #cbd5e1;
  font-size: 1rem;
  line-height: 1;
  padding: 2px 6px;
  cursor: pointer;
  border-radius: 6px;
}

.compare-bar-item button:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }

.compare-bar-item,
.compare-bar-slot { flex-shrink: 0; }

.compare-bar-slot {
  font-size: 0.78rem;
  color: #94a3b8;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  padding: 7px 10px;
  white-space: nowrap;
}

.compare-bar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.compare-bar .btn:not(.btn-primary) {
  background: transparent;
  color: #cbd5e1;
  border-color: rgba(255, 255, 255, 0.25);
}

@media (max-width: 640px) {
  .compare-bar { flex-direction: column; align-items: stretch; width: calc(100vw - 24px); }
  .compare-bar-name { display: none; }
  .compare-bar-actions .btn { flex: 1; }
}

.cmp-root[hidden] { display: none; }

.cmp-backdrop {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(8, 15, 30, 0.5);
}

.cmp-dialog {
  position: fixed;
  z-index: 96;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(1040px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  outline: none;
}

.cmp-root.open .cmp-dialog { animation: cmp-in 0.25s cubic-bezier(0.22, 1, 0.36, 1); }

@keyframes cmp-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 12px)); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

@media (prefers-reduced-motion: reduce) {
  .cmp-root.open .cmp-dialog { animation: none; }
  .compare-bar { transition: none; }
}

.cmp-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 16px 20px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.cmp-head h2 { margin: 0; font-size: 1.15rem; }
.cmp-head .icon-btn { margin-left: auto; }

.cmp-body { padding: 16px 20px 22px; }

.cmp-muted { color: var(--text-muted); font-size: 0.82rem; }

.cmp-table {
  min-width: 640px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

.cmp-table th[scope="row"] {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  width: 170px;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.cmp-table thead th {
  vertical-align: top;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.85rem;
  color: var(--text);
}

.cmp-table td { font-size: 0.9rem; }

.cmp-hint {
  display: block;
  font-weight: 400;
  font-size: 0.72rem;
}

.cmp-bank {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding-right: 20px;
  white-space: normal;
}

.cmp-bank .avatar { width: 32px; height: 32px; border-radius: 8px; margin: 0; }
.cmp-bank .avatar.wide { width: 56px; }

.cmp-swatch {
  position: absolute;
  left: -10px;
  top: -10px;
  right: -10px;
  height: 3px;
}

.cmp-name {
  font: inherit;
  font-weight: 700;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.cmp-name:hover { color: var(--accent); text-decoration: underline; }

.cmp-product {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  margin: 2px 0 6px;
}

.cmp-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}

.cmp-remove:hover { color: var(--bad); background: var(--surface-2); }

.cmp-big { font-size: 1.15rem; }

.cmp-sub { display: block; font-size: 0.72rem; }

td.cmp-best {
  background: color-mix(in srgb, var(--good) 10%, transparent);
  box-shadow: inset 3px 0 0 var(--good);
}

.cmp-chart-wrap {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}

.cmp-chart-wrap h3 { margin: 0 0 10px; font-size: 0.95rem; }

.cmp-chart { position: relative; height: 280px; }

/* --- Endringer tab --- */

.chg-summary .kpi-value { font-size: 1.5rem; }

.chg-filters { padding: 14px 18px; }
.chg-filters .chip-row { margin: 4px 0; }
.chg-filters .note { margin: 8px 0 0; }

.chip-group { display: inline-flex; flex-wrap: wrap; gap: 6px; }

.chg-day { padding: 0; overflow: hidden; }

.chg-day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.chg-day-head h2 {
  margin: 0;
  font-size: 1rem;
}

.chg-day-head h2 span {
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 6px;
  font-size: 0.88rem;
}

.chg-day-count {
  display: inline-flex;
  gap: 10px;
  font-size: 0.82rem;
  font-weight: 600;
}

.chg-list { list-style: none; margin: 0; padding: 0; }

.chg-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}

.chg-item:last-child { border-bottom: none; }

.chg-icon .avatar { width: 32px; height: 32px; border-radius: 8px; margin: 0; }
.chg-icon .avatar.wide { width: 56px; }

.chg-policy .chg-icon {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
}

.chg-policy .chg-icon svg { width: 18px; height: 18px; }
.chg-policy { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }

.chg-name {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

button.chg-name:hover { color: var(--accent); text-decoration: underline; }

.chg-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-top: 3px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.chg-rank span { color: var(--text-muted); margin-left: 2px; }

.chg-rates {
  font-size: 0.9rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.chg-delta {
  min-width: 78px;
  text-align: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Text mixed toward the page text color so it keeps AA contrast on the tint. */
.chg-up { background: color-mix(in srgb, var(--good) 14%, transparent); color: color-mix(in srgb, var(--good) 75%, var(--text)); }
.chg-down { background: color-mix(in srgb, var(--bad) 14%, transparent); color: color-mix(in srgb, var(--bad) 75%, var(--text)); }

@media (max-width: 640px) {
  .chg-item { grid-template-columns: auto minmax(0, 1fr) auto; }
  .chg-rates { grid-column: 2; font-size: 0.82rem; }
  .chg-delta { grid-column: 3; grid-row: 1 / span 2; }
}

.chg-more { display: block; margin: 0 auto 20px; }

/* --- Om (about) tab --- */

.about-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.about-toc {
  position: sticky;
  top: 72px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px;
  font-size: 0.86rem;
}

.about-toc strong {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.about-toc a {
  color: var(--text);
  text-decoration: none;
  padding: 5px 8px;
  border-radius: 6px;
}

.about-toc a {
  position: relative;
  transition: background 0.2s, color 0.2s;
}

.about-toc a:hover {
  background: var(--surface-2);
  color: var(--accent);
}

/* Section currently being read */
.about-toc a.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.about-toc a.active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.about article h2 {
  transition: color 0.2s;
}

.about article.reading h2 {
  color: var(--accent);
}

.about article {
  transition: border-color 0.2s, box-shadow 0.2s;
}

.about article.reading {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

@media (max-width: 760px) {
  .about-grid { grid-template-columns: minmax(0, 1fr); }
  .about-toc { display: none; }
}

.about article {
  scroll-margin-top: 72px;
}

.about p,
.about-list {
  font-size: 0.94rem;
  line-height: 1.65;
  max-width: 68ch;
}

.about p { margin: 0 0 12px; }
.about p:last-child { margin-bottom: 0; }

.about-list {
  margin: 0 0 12px;
  padding-left: 20px;
}

.about-list li { margin-bottom: 6px; }

.about-table {
  min-width: 520px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.about-table td {
  vertical-align: top;
  line-height: 1.55;
}

.about-table td:first-child {
  font-weight: 600;
  white-space: nowrap;
}

.about .note { margin: 0; }

.formula {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 4px 0 14px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.formula-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.formula code {
  border: none;
  background: none;
  padding: 0;
  font-size: 0.98rem;
}

/* --- Footer --- */

.site-footer {
  margin-top: 40px;
  border-top: 1px solid var(--border);
  padding: 22px 16px 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text);
}

.footer-brand svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.footer-link {
  margin-left: auto;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.footer-link:hover { text-decoration: underline; }

/* --- Bank logos / letter avatars --- */

.avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-right: 8px;
  vertical-align: middle;
  border-radius: 6px;
  overflow: hidden;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
  color: hsl(var(--av-h) 55% 38%);
  background: hsl(var(--av-h) 70% 92%);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06);
}

:root[data-theme="dark"] .avatar {
  color: hsl(var(--av-h) 70% 80%);
  background: hsl(var(--av-h) 35% 22%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .avatar {
    color: hsl(var(--av-h) 70% 80%);
    background: hsl(var(--av-h) 35% 22%);
  }
}

.avatar .bank-logo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 2px;
  background: #fff;
}

.avatar.wide {
  width: 48px;
}

.bank-cell {
  display: flex;
  align-items: center;
  min-width: 0;
}

.bank-cell .avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  margin-right: 10px;
  font-size: 0.8rem;
}

.bank-cell .avatar.wide {
  width: 64px;
}

/* --- Loading skeleton --- */

.sk {
  border-radius: 6px;
  background: linear-gradient(90deg, var(--border) 0%, var(--surface-2) 50%, var(--border) 100%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.3s ease-in-out infinite;
}

@keyframes sk-shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sk { animation: none; }
}

.sk-line { height: 11px; margin: 6px 0; }
.sk-value { height: 28px; width: 60%; margin: 8px 0; }
.sk-title { height: 16px; width: 180px; margin-bottom: 18px; }
.sk-chart { height: 300px; border-radius: 10px; }
.sk-avatar { width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; }

.sk-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.sk-row:last-child { border-bottom: none; }

/* --- Error / empty states --- */

.state-card {
  text-align: center;
  padding: 48px 24px;
}

.state-card h2 {
  margin: 14px 0 6px;
  font-size: 1.1rem;
}

.state-card p {
  margin: 0 auto 18px;
  max-width: 420px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.state-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent);
}

.state-error .state-icon {
  background: color-mix(in srgb, var(--bad) 14%, transparent);
  color: var(--bad);
}

.state-icon svg { width: 28px; height: 28px; }

.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.88rem;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  border-radius: 10px;
}

.chart-empty[hidden] { display: none; }

.chart-empty svg {
  width: 36px;
  height: 36px;
  margin-bottom: 6px;
  color: var(--accent);
}

.chart-empty strong { color: var(--text); }

.table-empty td {
  text-align: center;
  padding: 36px 12px;
  color: var(--text-muted);
}

.table-empty strong {
  display: block;
  color: var(--text);
  margin-bottom: 4px;
}

.table-empty:hover { background: none; }

.tab-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.tab-icon.flag {
  width: 20px;
  height: 14px;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.tab-btn.active .tab-icon:not(.flag) {
  color: var(--accent);
}

.tab-sub {
  color: var(--text-muted);
  font-weight: 400;
}

@media (max-width: 560px) {
  .tab-sub { display: none; }
}

.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

@media (max-width: 560px) {
  .card { padding: 16px 14px; border-radius: 12px; }
}

/* --- KPI cards --- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-grid:empty { display: none; }

@media (max-width: 860px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

@media (max-width: 560px) {
  .kpi { padding: 12px 12px; border-radius: 12px; }
}

.kpi-label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.kpi-tag {
  font-size: 0.6875rem; /* 11px minimum */
  letter-spacing: 0.02em;
  text-transform: none;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.kpi-value {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.kpi-value-sm {
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

@media (max-width: 560px) {
  .kpi-value { font-size: 1.35rem; }
}

.kpi-sub {
  font-size: 0.8rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.kpi-sub:empty { display: none; }

.kpi-muted { color: var(--text-muted); }

.kpi-ellipsis,
/* --- Sparklines --- */

.spark-cell { padding-top: 4px; padding-bottom: 4px; }
.spark { display: block; overflow: visible; }
.spark-up { color: var(--good); }
.spark-down { color: var(--bad); }
.spark-flat { color: var(--text-muted); }
.spark-none { color: var(--text-muted); }

.card h2 {
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}

.collapsible summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
}

.collapsible summary::-webkit-details-marker {
  display: none;
}

.collapsible summary::before {
  content: "▸";
  color: var(--text-muted);
  transition: transform 0.15s;
}

.collapsible[open] summary::before {
  transform: rotate(90deg);
}

.collapsible summary h2 {
  margin: 0;
}

.collapsible[open] summary {
  margin-bottom: 12px;
}

.collapsible summary:hover h2 {
  color: var(--accent);
}

.chart-wrap {
  position: relative;
  height: 340px;
}

.rate-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toggle-btn,
.period-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.82rem;
  cursor: pointer;
}

.toggle-btn.active,
.period-btn.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12), 0 0 0 1px var(--border);
}

.toggle-btn,
.period-btn {
  transition: background 0.15s, color 0.15s;
}

.toggle-btn:hover:not(:disabled):not(.active),
.period-btn:hover:not(.active) {
  color: var(--text);
}

.chart-wrap-short {
  height: 240px;
}

.toggle-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.legend-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.legend-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
}

.legend-chip.on {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th, td {
  text-align: left;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

tbody tr {
  transition: background 0.12s;
}

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

tbody tr:last-child td {
  border-bottom: none;
}

/* Row labels and SQL column names keep their own casing. */
.heatmap tbody th,
.sql-table th,
.schema-table th {
  text-transform: none;
  letter-spacing: normal;
  font-size: inherit;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable:hover,
th.sorted {
  color: var(--text);
}

.sort-ind {
  font-size: 0.7rem;
}

.heatmap {
  min-width: 0;
  width: auto;
  font-size: 0.74rem;
  border-collapse: separate;
  border-spacing: 2px;
}

.heatmap th,
.heatmap td {
  border-bottom: none;
  padding: 4px 6px;
}

.heat-label {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-weight: 500;
  color: var(--text);
}

.heat-cell {
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  border-radius: 4px;
  min-width: 44px;
}

.heat-empty {
  background: var(--bg);
}

.heat-changed {
  outline: 2px solid var(--text);
  outline-offset: -2px;
  font-weight: 700;
}

td.num, th.num { text-align: right; white-space: nowrap; }

.rate { font-variant-numeric: tabular-nums; font-weight: 600; }

.rate.estimate {
  font-weight: 400;
  color: var(--text-muted);
  border-bottom: 1px dotted var(--text-muted);
  cursor: help;
}

.delta-up { color: var(--good); }
.delta-down { color: var(--bad); }
.delta-flat { color: var(--text-muted); }

.status {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 8px;
}

.filter-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-row input[type="search"] {
  flex: 1;
  min-width: 160px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.pill {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  white-space: nowrap;
}

/* Account types (Forbrukerrådet): green = free access, amber = restricted.
   Text colors keep ≥ 4.5:1 on their tint in both themes. */
.pill-open {
  background: #dcfce7;
  color: #166534;
}

.pill-restricted {
  background: #fef3c7;
  color: #92400e;
}

:root[data-theme="dark"] .pill-open { background: #14361f; color: #86efac; }
:root[data-theme="dark"] .pill-restricted { background: #3d2a0a; color: #fcd34d; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pill-open { background: #14361f; color: #86efac; }
  :root:not([data-theme="light"]) .pill-restricted { background: #3d2a0a; color: #fcd34d; }
}

.type-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

.type-btn:hover:not(.active) { color: var(--text); }

.type-btn.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12), 0 0 0 1px var(--border);
}

.type-filter { margin-bottom: 0; }

.pill-muted {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: -4px 0 12px;
}

.delisted-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
}

.range-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 1px;
}

.bank-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

.bank-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.bank-link .ext {
  font-size: 0.75em;
  color: var(--text-muted);
}

/* --- SQL tab --- */

code,
kbd,
.sql-editor {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

code {
  font-size: 0.85em;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 10px 0;
}

.chip-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-right: 2px;
}

.schema-help {
  margin: 4px 0 12px;
}

.schema-help summary h2 {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
}

.schema-table {
  min-width: 0;
  font-size: 0.8rem;
}

.schema-table td {
  padding: 4px 8px;
}

.sql-editor {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  tab-size: 2;
}

.sql-editor:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.sql-actions,
.sql-save {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.sql-save input {
  flex: 1;
  min-width: 160px;
  max-width: 320px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.btn-primary kbd {
  font-size: 0.7rem;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 3px;
  padding: 0 4px;
}

.sql-status {
  margin-top: 0;
}

.sql-error {
  color: var(--bad);
}

.saved-chip {
  display: inline-flex;
  align-items: center;
}

.saved-chip .legend-chip {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.saved-delete {
  border: 1px solid var(--accent);
  border-left: none;
  background: var(--accent-soft);
  color: var(--text-muted);
  border-radius: 0 999px 999px 0;
  padding: 4px 9px 4px 6px;
  font-size: 0.8rem;
  cursor: pointer;
}

.saved-delete:hover {
  color: var(--bad);
}


.sql-table {
  min-width: 0;
  width: auto;
  font-size: 0.82rem;
}

.sql-table td,
.sql-table th {
  white-space: nowrap;
  padding: 6px 10px;
}

.sql-null {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.75rem;
}

.sql-download-sql {
  display: inline-flex;
}

.sql-download-sql .btn {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.sql-dialect {
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 8px 8px 0;
  background: var(--bg);
  color: var(--text);
  font-size: 0.82rem;
  padding: 0 8px;
  cursor: pointer;
}

/* --- SQL tab: editor (CodeMirror), history, results --- */

.CodeMirror {
  height: 260px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.85rem;
  line-height: 1.5;
}

.CodeMirror-focused {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.CodeMirror-gutters {
  background: var(--bg);
  border-right: 1px solid var(--border);
  border-radius: 8px 0 0 8px;
}

.CodeMirror-linenumber {
  color: var(--text-muted);
}

.CodeMirror-cursor {
  border-left-color: var(--text);
}

.CodeMirror-selected,
.CodeMirror-focused .CodeMirror-selected {
  background: var(--accent-soft);
}

.cm-s-default .cm-keyword { color: var(--code-keyword); font-weight: 600; }
.cm-s-default .cm-string { color: var(--code-string); }
.cm-s-default .cm-number { color: var(--code-number); }
.cm-s-default .cm-comment { color: var(--code-comment); font-style: italic; }
.cm-s-default .cm-builtin,
.cm-s-default .cm-atom,
.cm-s-default .cm-variable-2 { color: var(--code-builtin); }
.cm-s-default .cm-operator,
.cm-s-default .cm-bracket { color: var(--text); }

div.CodeMirror span.CodeMirror-matchingbracket {
  color: var(--good);
  font-weight: 700;
}

.CodeMirror-hints {
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
}

.CodeMirror-hint {
  color: var(--text);
  padding: 2px 8px;
}

li.CodeMirror-hint-active {
  background: var(--accent);
  color: white;
}

.editor-tip {
  margin: 6px 0 0;
}

.data-info-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: -4px 0 4px;
}

.data-info-row .status {
  margin: 0;
}

.btn-small {
  padding: 4px 10px;
  font-size: 0.78rem;
}

.sql-refresh.has-update {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.sql-history {
  margin-top: 12px;
}

.history-count {
  color: var(--text-muted);
  font-weight: 400;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  min-width: 0;
}

.history-item:hover {
  border-color: var(--accent);
}

.history-item code {
  border: none;
  background: none;
  padding: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.history-time {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.history-clear {
  margin-top: 8px;
}

.result-toolbar {
  margin-bottom: 4px;
}

.sql-message {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.sql-error-box {
  border: 1px solid var(--bad);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--bad);
  font-size: 0.9rem;
}

.sql-error-orig {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  word-break: break-word;
}

.chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.chart-controls select {
  margin-left: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  padding: 3px 6px;
  font-size: 0.82rem;
}

/* Day panel under the rate chart: every shown bank on the hovered day */

.day-panel {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  font-size: 0.82rem;
}

.day-panel:empty {
  display: none;
}

.day-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin-bottom: 6px;
}

.day-panel-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.day-panel-hint {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.day-panel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2px 16px;
}

.day-panel-list li {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto auto 70px;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  border-radius: 6px;
}

.day-panel-list li.focus {
  background: var(--accent-soft);
}

.day-panel-list .dot {
  display: inline-flex;
  width: 12px;
  height: 12px;
}

.day-panel-list .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-panel-list .rank {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.day-panel-list .val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.day-panel-list .delta {
  font-size: 0.72rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Shown only when JavaScript is off. */
.noscript {
  max-width: 1080px;
  margin: 24px auto;
  padding: 16px 20px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}

/* ⓘ next to estimated values, and its bubble. */
.est-info {
  margin-left: 3px;
  padding: 0 2px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  vertical-align: baseline;
}

.est-info:hover,
.est-info[aria-expanded="true"] { color: var(--accent); }

.info-bubble {
  position: absolute;
  z-index: 120;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 0.82rem;
  line-height: 1.5;
}

/* "Vis flere" under the bank table. */
.table-more {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.table-more .status { margin: 0; }
.table-more:empty { display: none; }

/* Fades at the tab bar's edges when tabs are hidden to the side (phones). */
.tabs-wrap { position: relative; }
.tabs-wrap::before,
.tabs-wrap::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 1px;
  width: 36px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 1;
}
.tabs-wrap::before { left: 0; background: linear-gradient(90deg, var(--surface), transparent); }
.tabs-wrap::after { right: 0; background: linear-gradient(270deg, var(--surface), transparent); }
.tabs-wrap.fade-left::before,
.tabs-wrap.fade-right::after { opacity: 1; }

/* Inline text button ("Vis hele historikken") and loading state. */
.link-btn {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--accent-strong);
  text-decoration: underline;
  cursor: pointer;
}

.link-btn:disabled { color: var(--text-muted); text-decoration: none; cursor: wait; }
.history-note { margin: 8px 0 0; }

.period-btn.loading { cursor: wait; opacity: 0.6; }

/* "Hele markedet" above the key figures while the table filter is on, and
   the "Avansert" line in the SQL tab. */
.kpi-scope,
.sql-audience {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.kpi-scope { margin: 0 0 10px; }
.kpi-scope[hidden] { display: none; }
.sql-audience { margin: 4px 0 8px; }

/* Empty pills until the status arrives (they hold the space the real ones take). */
.status-chip.pending { color: transparent; user-select: none; }
.status-chip.pending .dot { visibility: hidden; }

/* At least a screen tall, so the footer isn't on screen while a tab loads
   and then pushed away (a layout shift). */
main { min-height: 100vh; }

/* --- Mine banker (starred products) and "siden sist" --- */

:root { --star: #e8a317; }

.mine-btn {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin: 0 4px 0 -4px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.15s, color 0.15s, transform 0.15s;
}
.mine-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}
.bank-table tr:hover .mine-btn,
.mine-btn:hover,
.mine-btn:focus-visible { opacity: 1; }
.mine-btn:hover { color: var(--star); }
.mine-btn.on { opacity: 1; color: var(--star); }
.mine-btn.on svg { fill: currentColor; }
.mine-btn:active { transform: scale(0.85); }

/* In the bank panel it's a normal icon button beside ×. */
.drawer-mine.mine-btn { width: auto; height: 34px; margin: 0; opacity: 1; border: 1px solid var(--border); background: var(--surface); }
.drawer-mine.mine-btn svg { width: 18px; height: 18px; }

.quick-mine svg {
  width: 13px;
  height: 13px;
  margin-right: 4px;
  vertical-align: -2px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}
.quick-mine.active svg { fill: currentColor; }

/* Group headings in the table: "Mine banker" / "Andre banker". */
.bank-table .group-row th {
  padding: 14px 12px 6px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: none;
  border-bottom: 1px solid var(--border);
}
.bank-table .group-row th svg {
  width: 12px;
  height: 12px;
  margin-right: 6px;
  vertical-align: -1px;
  fill: var(--star);
}
.bank-table tbody tr.group-row:hover { background: none; }

/* A rate that changed since the last visit. */
.since-dot {
  flex-shrink: 0;
  align-self: center;
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.since-note {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin: 0 0 12px;
  padding: 8px 8px 8px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  font-size: 0.88rem;
  animation: panel-in 0.3s ease both;
}
.since-note .since-dot { margin: 0 2px 0 0; }
.since-text { flex: 1; min-width: 12em; }
.since-mine { color: var(--text-muted); }
.since-mine::before { content: "· "; }
.since-note .since-close { height: 30px; min-width: 30px; padding: 0; border-color: transparent; background: none; }
.since-note .since-close svg { width: 16px; height: 16px; }

@media (max-width: 640px) {
  .bank-table tbody tr.group-row {
    display: block;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
  }
  .bank-table .group-row th { display: block; padding: 10px 2px 8px; border: none; }
  .mine-btn { width: 32px; height: 32px; margin: -4px 2px -4px -6px; opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
  .since-note { animation: none; }
  .mine-btn:active { transform: none; }
}

/* --- Installable app --- */

.install-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.install-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.install-btn svg { width: 16px; height: 16px; }
.install-btn[hidden] { display: none; }
@media (max-width: 420px) { .install-btn span { display: none; } .install-btn { padding: 0 10px; } }

/* Offline: saved data is shown. */
.offline-note {
  max-width: 1080px;
  margin: 12px auto 0;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, #d97706 40%, var(--border));
  background: color-mix(in srgb, #f59e0b 12%, var(--surface));
  color: var(--text);
  font-size: 0.88rem;
}
.offline-note[hidden] { display: none; }
@media (max-width: 1112px) { .offline-note { margin-left: 16px; margin-right: 16px; } }

/* KPI "Største endring(er) i dag": per change, logo + bank + change on the
   first line and the product across the card's width under it. */
.kpi-mover {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1px 8px;
  width: 100%;
  margin: 0;
  padding: 6px 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.kpi-mover + .kpi-mover { border-top: 1px dashed var(--border); }
.kpi-mover .avatar { margin: 0; }
.kpi-mover .avatar.wide { width: 44px; }
.kpi-mover-bank {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 600;
}
.kpi-mover-delta {
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.kpi-mover-product {
  grid-column: 2 / 4;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.kpi-mover:hover .kpi-mover-bank { text-decoration: underline; text-underline-offset: 3px; }
.kpi-mover:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
/* Narrow cards (two per row on phones): the change on top, then logo and
   bank, then the product across the card. */
@media (max-width: 640px) {
  .kpi-mover { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "delta delta" "logo bank" "product product"; row-gap: 2px; }
  .kpi-mover .avatar { grid-area: logo; }
  .kpi-mover-bank { grid-area: bank; }
  .kpi-mover-product { grid-area: product; }
  .kpi-mover-delta { grid-area: delta; }
}

/* --- "Min bank": the chosen bank's best accounts under the key figures --- */

.mybank-strip {
  position: relative;
  margin: -6px 0 20px;
  padding: 14px 18px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.mybank-strip:empty { display: none; }
.mybank-strip.is-empty {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 10px 18px;
  font-size: 0.85rem;
  box-shadow: none;
  border-style: dashed;
}
.mybank-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.mybank-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  font-size: 0.85rem;
}
.mybank-bank { display: inline-flex; align-items: center; font-weight: 600; font-size: 0.95rem; }
.mybank-edit {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin: -4px -8px -4px auto;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}
.mybank-edit svg { width: 15px; height: 15px; }
.mybank-edit:hover, .mybank-edit[aria-expanded="true"] { color: var(--text); background: color-mix(in srgb, var(--text) 7%, transparent); }

.mybank-accounts {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.mybank-account {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  height: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: inherit;
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s;
}
.mybank-account:hover { border-color: var(--accent); }
.mybank-account:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mybank-product {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-width: 0;
  margin-bottom: 2px;
  font-weight: 600;
  font-size: 0.86rem;
  line-height: 1.3;
}
.mybank-account:hover .mybank-product { text-decoration: underline; text-underline-offset: 3px; }
.mybank-stats { margin-top: auto; font-variant-numeric: tabular-nums; }
.mybank-stats strong { font-size: 0.95rem; }
.mybank-change { font-size: 0.78rem; }
.mybank-none { margin: 8px 0 0; font-size: 0.85rem; }
.mybank-clear { color: var(--text-muted); font-size: 0.82rem; }

/* The picker opens from the pencil, at the strip's right edge. */
.picker-pop.mybank-pop { right: 0; left: auto; }
.mybank-strip:not(.is-empty) .mybank-pop { top: 44px; }

@media (max-width: 860px) {
  .mybank-strip { margin-top: -10px; }
  .mybank-accounts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
}
@media (max-width: 640px) {
  .mybank-strip { padding: 12px 14px 14px; }
  .mybank-edit { width: 32px; height: 32px; }
}

/* Neighbours on the ranking that fill the row's free places. */
.mybank-account.is-neighbour {
  border-style: dashed;
  background: transparent;
}
.mybank-tag {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.mybank-account .mybank-product .avatar { width: 18px; height: 18px; margin-right: 6px; vertical-align: -4px; font-size: 0.6rem; }
.mybank-account .mybank-product .avatar.wide { width: 36px; }

/* When the rate last changed: under "I dag" in the table, and in the bank panel. */
.changed-hint { white-space: normal; color: var(--text-muted); }
.drawer-changed { margin-top: 6px; font-size: 0.8rem; color: var(--text-muted); }

/* --- "Hvem fulgte?" under the policy chip --- */

.policy-wrap { margin: 0 0 12px; }
.policy-wrap .policy-chip { margin: 0; }
.policy-toggle {
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.8rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s;
}
.policy-toggle:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.policy-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.policy-chip-more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: var(--accent-strong);
}
.policy-chip-more .chev { width: 14px; height: 14px; transition: transform 0.2s; }
.policy-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }

.policy-follow {
  margin-top: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 0.85rem;
}
.pf-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.pf-head strong { font-size: 0.95rem; }
.pf-bar {
  display: flex;
  height: 10px;
  margin: 12px 0 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--border);
}
.pf-seg { height: 100%; }
.pf-seg + .pf-seg { box-shadow: -2px 0 0 var(--surface-2); }
.pf-full, .pf-seg.pf-full { --pf: var(--good); }
.pf-partial, .pf-seg.pf-partial { --pf: color-mix(in srgb, var(--good) 45%, var(--surface)); }
.pf-none, .pf-seg.pf-none { --pf: color-mix(in srgb, var(--text-muted) 45%, var(--surface)); }
.pf-opposite, .pf-seg.pf-opposite { --pf: var(--bad); }
.pf-seg, .pf-swatch { background: var(--pf); }
.pf-swatch { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 3px; vertical-align: -1px; }
.pf-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.pf-lists {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px 20px;
  margin-top: 14px;
}
.pf-group h3 { margin: 0 0 6px; font-size: 0.8rem; font-weight: 600; }
.pf-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.pf-group li { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.pf-name { display: flex; align-items: center; min-width: 0; }
.pf-name span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-name:hover span { text-decoration: underline; text-underline-offset: 3px; }
.pf-name .avatar { width: 18px; height: 18px; margin-right: 6px; font-size: 0.6rem; }
.pf-name .avatar.wide { width: 36px; }
.pf-val { white-space: nowrap; font-variant-numeric: tabular-nums; }
.pf-more, .pf-empty { margin: 6px 0 0; font-size: 0.8rem; }
.policy-follow .note { margin: 12px 0 0; }

/* "Nytt" on recently added features. */
.new-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: none;
  vertical-align: 1px;
  line-height: 1.5;
}
:root[data-theme="dark"] .new-badge { color: #0b1220; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .new-badge { color: #0b1220; } }
.policy-chip-more .new-badge { margin: 0 2px 0 0; }

/* "Neste henting om …" in the status bar. */
.status-next svg { width: 13px; height: 13px; flex-shrink: 0; opacity: 0.8; }

/* Short notice at the bottom ("Nye renter er hentet."). */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 200;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: #0b1b3a;
  color: #fff;
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* --- The hero's background curve: the Norway tab's average rate --- */
.hero { position: relative; overflow: hidden; }
.hero > :not(.hero-art) { position: relative; z-index: 1; }
.hero > .hero-art {
  position: absolute;
  inset: auto 0 0 0;
  max-width: none;
  height: 72%;
  margin: 0;
  pointer-events: none;
}
.hero-curve { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.hero-curve .hc-line {
  fill: none;
  stroke: rgba(147, 197, 253, 0.55);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
/* Drawn in from the left the first time (a clip, since a dash animation
   doesn't work with a non-scaling stroke). */
.hero-curve.draw { animation: hero-draw 1.6s cubic-bezier(0.3, 0.7, 0.2, 1) both; }
.hero-curve .hc-area { fill: url(#hero-fill); }
@keyframes hero-draw { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.hero-dot {
  position: absolute;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: #93c5fd;
  box-shadow: 0 0 0 5px rgba(147, 197, 253, 0.18), 0 0 18px rgba(147, 197, 253, 0.6);
  opacity: 0;
  transition: opacity 0.4s 1.2s;
}
.hero-dot.on { opacity: 1; }
.hero-curve-label {
  position: absolute;
  right: 16px;
  bottom: 8px;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  color: rgba(203, 213, 225, 0.55);
}
@media (prefers-reduced-motion: reduce) {
  .hero-curve.draw { animation: none; }
  .hero-dot { transition: none; }
}
@media (max-width: 640px) { .hero > .hero-art { height: 55%; } }

/* "Hva er nytt" in the Om tab. */
.changelog { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 18px; }
.changelog > li { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 4px 20px; }
.changelog time { font-weight: 600; font-size: 0.88rem; color: var(--text-muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.changelog ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
@media (max-width: 640px) { .changelog > li { grid-template-columns: 1fr; } }

/* "Hva er nytt" stays hidden unless its secret unlocks it. */
#om-nytt[hidden], .about-toc a[hidden] { display: none; }
