:root {
  --bg: #0b0e14;
  --surface: #131722;
  --surface-hover: #1a1f2e;
  --border: #232838;
  --text: #e6e9f0;
  --text-dim: #8b93a7;
  --green: #26a69a;
  --red: #ef5350;
  --accent: #6c7dff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

.top-bar {
  display: flex;
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.indices-ribbon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 28px;
  padding: 8px 24px;
  font-size: 13px;
  white-space: nowrap;
  overflow-x: auto;
}

/* .site-link is 🌐 Hjemmeside, the link out to the public Portfolio Dashboard
   website (FAQ, guides, download, release notes) — issue #133. It sits leftmost
   of the ribbon actions and shares .admin-link's styling so 🌐 / 💡 / ⚙️ read as
   one row. Its own class, not .admin-link: feature-suggest.js injects 💡 before
   the FIRST .admin-link, and 💡 belongs next to ⚙️, not out at the edge. */
.admin-link, .site-link {
  flex-shrink: 0;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  padding: 8px 20px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}

.admin-link:hover, .site-link:hover { color: var(--text); background: var(--surface-hover); }

/* 💡 "Foreslå en feature" trigger in the top ribbon, sitting immediately left
   of ⚙️ Admin (issue #23). Styled to match .admin-link so the two read as one
   pair of ribbon actions. */
.feature-ribbon-btn {
  flex-shrink: 0;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
  padding: 8px 16px;
  cursor: pointer;
}
.feature-ribbon-btn:hover { color: var(--text); background: var(--surface-hover); }

/* Diagnostics / feature-suggestion modal. Moved here from admin.html's inline
   <style> so the feature-suggestion modal (feature-suggest.js injects it) is
   styled on every page, not only admin.html (issue #23). */
.diag-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center; z-index: 1000;
}
.diag-overlay.open { display: flex; }
.diag-modal {
  background: var(--surface, #171b26); border: 1px solid var(--border, #232838);
  border-radius: 12px; width: min(680px, 92vw); max-height: 86vh; overflow: auto;
  padding: 20px 22px; box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.diag-modal h2 { margin: 0 0 4px; font-size: 18px; }
.diag-modal .diag-sub { color: var(--text-dim, #8b93a7); font-size: 13px; margin: 0 0 14px; }
.diag-preview {
  background: #0d1017; border: 1px solid var(--border, #232838); border-radius: 8px;
  padding: 10px 12px; font: 12px/1.5 ui-monospace, Menlo, monospace;
  white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; color: var(--text, #e6e9f0);
}
.diag-note-input {
  width: 100%; margin-top: 12px; box-sizing: border-box; background: #0d1017;
  color: var(--text, #e6e9f0); border: 1px solid var(--border, #232838);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; resize: vertical; min-height: 52px;
}
.diag-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.diag-actions button { padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border, #232838); cursor: pointer; font-size: 14px; }
.diag-actions .diag-send { background: var(--accent, #6c7dff); color: #fff; border-color: transparent; }
.diag-actions .diag-cancel { background: transparent; color: var(--text, #e6e9f0); }
.diag-status { margin-top: 12px; font-size: 13px; }
.diag-status .ok { color: var(--green, #26a69a); }
.diag-status .warn { color: #f0a500; }

/* Left sidebar (Nordnet-style account list) -- replaces the old horizontal,
   flex-wrapping tab strip. A vertical list of fixed-height rows doesn't
   reflow/jump around as portfolios are added, unlike a wrapping flex row. */
.app-layout {
  display: flex;
  align-items: flex-start;
}

.app-main {
  flex: 1;
  min-width: 0;
}

.portfolio-tabs {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 280px;
  flex-shrink: 0;
  padding: 16px 10px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  /* Fixed viewport height (not min-height) so a long depot list scrolls WITHIN
     the sidebar when the mouse is over it (#48), instead of growing the sidebar
     and scrolling the whole page. */
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
}

/* On pages with a sticky .top-bar (index.html, all-portfolios.html), the
   sidebar must stick just below it, not at the very top of the viewport --
   otherwise it slides up and overlaps the pinned top-bar while scrolling.
   admin.html has no .top-bar, so this selector simply doesn't match there
   and the sidebar keeps sticking at top: 0. */
.top-bar ~ .app-layout .portfolio-tabs {
  top: 34px;
  height: calc(100vh - 34px);
}

.portfolio-tab {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 4px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid transparent;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}

.portfolio-tab:hover { color: var(--text); background: var(--surface-hover); }
.portfolio-tab.active { background: var(--accent); color: white; }
.portfolio-tab-add {
  font-weight: 600;
  justify-content: center;
  color: var(--accent);
  border: 1px dashed var(--accent);
  padding: 12px 10px;
  margin-top: 8px;
}
.portfolio-tab-add:hover { color: white; background: var(--accent); border-style: solid; }

/* Admin center "➕ Ny portefølje" button below the manage table -- same
   create flow as the sidebar's, styled as a normal admin action button. */
.portfolio-add-btn { margin-top: 10px; }

/* Free-text category heading above each group of portfolios in the sidebar. */
.portfolio-cat-header {
  display: block;
  text-decoration: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 4px 10px 2px;
  margin-top: 8px;
  border-radius: 6px;
  cursor: pointer;
}
.portfolio-cat-header:hover { color: var(--text); background: var(--surface-hover); }
/* On its own scoped overview the heading is the active selection (#47). */
.portfolio-cat-header.active { color: white; background: var(--green); }
.portfolio-cat-header.active:hover { color: white; background: var(--green); }
.portfolio-cat-header:first-child { margin-top: 0; }

/* Matching group heading row in the admin "Porteføljer" management table. */
.portfolio-cat-header-row td { border: none; padding-top: 12px; }
.portfolio-cat-header-cell {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
#portfolio-manage-body .portfolio-cat-input { width: 130px; }

.tab-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-badge { font-size: 11px; opacity: 0.85; white-space: nowrap; flex-shrink: 0; }

.tab-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  vertical-align: -4px;
  margin-right: 6px;
}

/* Inside a sidebar row (flex), spacing comes from the row's own gap, not
   the icon's own margin/vertical-align (which only matters inline, e.g. the
   Porteføljeanalyse table's non-flex usage of the same .tab-icon class). */
.portfolio-tab .tab-icon {
  margin-right: 0;
  vertical-align: unset;
}

.portfolio-tab-all {
  text-decoration: none;
  color: var(--green);
  margin-bottom: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
}
.portfolio-tab-all:hover { background: var(--surface-hover); }
.portfolio-tab-all.active { background: var(--green); color: white; }

.indices-ribbon .index-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-shrink: 0;
}

.indices-ribbon .index-name {
  color: var(--text-dim);
}

.indices-ribbon .index-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.indices-ribbon .index-change {
  font-variant-numeric: tabular-nums;
}

.indices-ribbon .index-change.up { color: var(--green); }
.indices-ribbon .index-change.down { color: var(--red); }
.indices-ribbon .index-change.flat { color: var(--text-dim); }

header {
  padding: 32px 24px 20px;
  max-width: 1240px;
  margin: 0 auto;
}

h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.h1-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  vertical-align: -6px;
  margin-right: 10px;
}

.subtitle {
  color: var(--text-dim);
  margin: 4px 0 16px;
  font-size: 14px;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.portfolio-summary {
  display: flex;
  gap: 32px;
  margin-top: 18px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.summary-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.summary-value {
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.summary-change {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.summary-change.up { color: var(--green); }
.summary-change.down { color: var(--red); }
.summary-change.flat { color: var(--text-dim); }

.returns-row {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 12px;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.returns-label {
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
}

.returns-items {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}

.returns-item .summary-change {
  font-size: 16px;
}

.yield-value {
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#last-updated {
  font-size: 12px;
  color: var(--text-dim);
}

/* Mini private mode eye toggle. Same class everywhere; compact/borderless next
   to the "Samlet værdi" label, and a bordered control when it sits in the
   .meta-row on pages without a summary figure. */
.privacy-toggle {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 6px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
  opacity: 0.7;
}

.privacy-toggle:hover { background: var(--surface-hover); opacity: 1; }
.privacy-toggle.active { opacity: 1; }

.meta-row .privacy-toggle {
  border: 1px solid var(--border);
  padding: 6px 12px;
  font-size: 14px;
}
.meta-row .privacy-toggle:hover { color: var(--text); }
.meta-row .privacy-toggle.active { background: var(--accent); border-color: var(--accent); }

#refresh-btn, #print-btn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

#refresh-btn:hover, #print-btn:hover { color: var(--text); background: var(--surface-hover); }
#refresh-btn:disabled { opacity: 0.6; cursor: default; }

/* Which depot is active, shown once above the section-nav tab bar on every
   per-depot page (Oversigt/Aktieoverblik/Udbytte/Analyse) -- a fixed
   landmark that doesn't move or disappear as you click between sections,
   unlike an earlier version that only existed on one page next to its tabs. */
.active-portfolio-box {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 8px 16px 8px 10px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 0 0 1px var(--accent), 0 0 20px rgba(108, 125, 255, 0.3);
  font-size: 14px;
  color: var(--text-dim);
}
.active-portfolio-box img { width: 26px; height: 26px; border-radius: 50%; }
.active-portfolio-box strong { color: var(--accent); font-weight: 600; }

/* Second-level depot navigation (Oversigt | Aktieoverblik | Udbytte |
   Analyse) -- a segmented control shown on every per-depot page, so each
   depot behaves like one app with sections rather than loose pages. Plain
   links (each section is its own page, loading independently); the active
   segment is marked per-page with .active. */
.section-nav {
  display: inline-flex;
  gap: 4px;
  margin: 18px 0 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.section-nav a {
  padding: 8px 18px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

.section-nav a:hover { color: var(--text); }

.section-nav a.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 0 16px rgba(108, 125, 255, 0.4);
}

/* Mini private mode (Nordnet style): every kr amount (.money-all) becomes small
   dots; percentages, which live outside .money-all, stay visible. The real text
   is kept but made transparent so column widths don't jump; the dots overlay it. */
body.privacy-all .money-all {
  color: transparent !important;
  position: relative;
  user-select: none;
}
body.privacy-all .money-all::after {
  content: "••••";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  letter-spacing: 0.15em;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}
/* Right-aligned numeric table cells: anchor the dots to the right edge. */
body.privacy-all td.money-all::after,
body.privacy-all .num.money-all::after {
  left: auto;
  right: 0;
}

main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px 40px;
}

section { margin-bottom: 32px; }

.highlights-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 32px;
}

.highlight-box {
  margin-bottom: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
}

.highlight-box h2 { margin-bottom: 10px; }

.triple-row { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .triple-row { grid-template-columns: 1fr; } }
.single-row { grid-template-columns: 1fr; }

.div-history-body {
  display: flex;
  gap: 24px;
}

.div-history-chart {
  flex: 2;
  min-width: 0;
}
.div-history-chart svg { width: 100%; height: 160px; display: block; }

.div-history-list {
  flex: 1;
  min-width: 200px;
  display: flex;
  flex-direction: column;
}

.div-history-total {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
}
.div-history-total .div-history-total-label {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-dim);
  margin-left: 4px;
}

.div-history-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.div-history-tab {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.div-history-tab:hover { color: var(--text); }
.div-history-tab.active { background: var(--accent); color: white; border-color: var(--accent); }

.div-history-rows {
  overflow-y: auto;
  max-height: 160px;
}

.div-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  font-size: 14px;
}

.div-history-amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* The dedicated Udbytter page gives this widget the whole page instead of
   a cramped highlight-box, so let the chart/list actually use that room. */
.dividend-history-box.full-page .div-history-body { gap: 40px; }
.dividend-history-box.full-page .div-history-chart svg { height: 300px; }
.dividend-history-box.full-page .div-history-rows { max-height: 300px; }
.dividend-history-box.full-page .div-history-total { font-size: 26px; }

@media (max-width: 640px) {
  .div-history-body { flex-direction: column; }
}

.pie-chart {
  display: flex;
  align-items: center;
  gap: 16px;
}

.pie-chart svg { flex-shrink: 0; }

.pie-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  min-width: 0;
}

.pie-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pie-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.pie-legend-pct {
  color: var(--text-dim);
  margin-left: auto;
  padding-left: 8px;
}

.sector-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
}

.sector-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sector-row.sector-header {
  padding-bottom: 6px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--border);
}

.sector-metric-toggle {
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
}

.sector-metric-toggle:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.sector-header .sector-pct,
.sector-header .sector-return {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sector-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.sector-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sector-pct {
  color: var(--text-dim);
  width: 42px;
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.sector-return {
  width: 100px;
  text-align: right;
  flex-shrink: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sector-return.up { color: var(--green); }
.sector-return.down { color: var(--red); }
.sector-return.flat { color: var(--text-dim); }

.next-dividend-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.next-dividend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
}

.next-dividend-row:first-of-type { border-top: none; }

.next-dividend-name {
  font-size: 14px;
  font-weight: 600;
}

.next-dividend-date {
  font-size: 12px;
  color: var(--text-dim);
}

.next-dividend-amount {
  font-size: 15px;
  font-weight: 700;
  color: var(--green);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.wl-header {
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.winners-losers {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
}

.wl-row .wl-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.wl-row .wl-amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}

.wl-row .wl-amount.up { color: var(--green); }
.wl-row .wl-amount.down { color: var(--red); }

/* 4th-place "medal" for Top vindere -- emoji only goes up to 🥉, so this
   fills in a matching circular badge rather than falling back to a plain
   bullet. */
.medal-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #9aa2b8, #626a80);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

@media (max-width: 640px) {
  .highlights-row { grid-template-columns: 1fr; }
}

h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0 0 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  transition: background 0.15s;
}

.card:hover { background: var(--surface-hover); }

.card .symbol {
  font-weight: 600;
  font-size: 15px;
}

.card .name {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 8px;
}

.card .price {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.card .change {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.change.up { color: var(--green); }
.change.down { color: var(--red); }
.change.flat { color: var(--text-dim); }

.extended-hours {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.extended-hours.up span { color: var(--green); }
.extended-hours.down span { color: var(--red); }
.extended-hours.flat span { color: var(--text-dim); }

.card .position {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.card .position .value {
  color: var(--text);
  font-weight: 600;
}

.card .position .day-change.up { color: var(--green); }
.card .position .day-change.down { color: var(--red); }
.card .position .day-change.flat { color: var(--text-dim); }

.card.error {
  color: var(--text-dim);
  font-size: 13px;
}

footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 20px;
}

.skeleton {
  color: var(--text-dim);
  font-size: 13px;
}

.card { cursor: pointer; }
.card.error { cursor: default; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.overlay.hidden { display: none; }

.detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 920px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 24px;
  position: relative;
}

.detail-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.detail-close:hover { background: var(--surface-hover); color: var(--text); }

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.detail-logo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--bg);
  object-fit: contain;
  padding: 6px;
  box-sizing: border-box;
}

.detail-header-info { flex: 1; min-width: 0; }
.detail-symbol { font-size: 20px; font-weight: 700; }
.detail-name { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.detail-tag {
  font-size: 11px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
}

.detail-price-block { text-align: right; }
.detail-price-row { display: flex; align-items: baseline; justify-content: flex-end; gap: 6px; }
.detail-price { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.detail-price-arrow.up { color: var(--green); }
.detail-price-arrow.down { color: var(--red); }
.detail-change { font-size: 13px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.detail-change.up { color: var(--green); }
.detail-change.down { color: var(--red); }
.detail-change.flat { color: var(--text-dim); }
.detail-updated { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

.detail-chart-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.detail-chart-col { flex: 2; min-width: 280px; }

.detail-quickstats-col {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 16px;
}

.detail-range-block { font-size: 12px; }
.detail-range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}
.detail-range-track {
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  margin-top: 6px;
  position: relative;
}
.detail-range-dot {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  transform: translate(-50%, -50%);
}

.detail-quickstats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.detail-chart-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

#detail-chart-change {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-transform: none;
  letter-spacing: normal;
}

#detail-chart-change.up { color: var(--green); }
#detail-chart-change.down { color: var(--red); }

.range-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.range-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.range-btn:hover { color: var(--text); }
.range-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

.detail-chart {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
}

.detail-chart .skeleton { text-align: center; width: 100%; padding: 55px 0; }

.chart-body {
  display: flex;
  height: 130px;
}

.chart-plot { flex: 1; min-width: 0; position: relative; cursor: crosshair; }
.chart-plot svg { width: 100%; height: 100%; display: block; }

.chart-hover-price,
.chart-hover-date {
  position: absolute;
  top: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  opacity: 0;
  z-index: 2;
}
.chart-hover-price { left: 2px; font-weight: 700; color: var(--accent); }
.chart-hover-date { right: 2px; color: var(--text-dim); }

.chart-hover-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--text-dim);
  pointer-events: none;
  opacity: 0;
  z-index: 1;
}

.chart-hover-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  z-index: 2;
}

.chart-yaxis {
  position: relative;
  width: 58px;
  flex-shrink: 0;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

.chart-yaxis span {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
  white-space: nowrap;
}

.chart-xaxis {
  position: relative;
  height: 16px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-dim);
}

.chart-xaxis span {
  position: absolute;
  transform: translateX(-50%);
}

.detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.detail-stats-extra {
  border-top: none;
  padding-top: 14px;
}

.detail-stats-extra.hidden { display: none; }

.detail-more-toggle {
  width: 100%;
  margin-top: 14px;
  padding: 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
}

.detail-more-toggle:hover { color: var(--text); background: var(--surface-hover); }

.detail-stat-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.detail-stat-value {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.detail-stat-value.up { color: var(--green); }
.detail-stat-value.down { color: var(--red); }
.detail-stat-value.flat { color: var(--text); }

/* showTextPrompt() in native-bridge.js -- replaces window.prompt(), which
   (like alert/confirm) silently no-ops under the Tauri desktop app. Used
   identically in a plain browser too, so it's not gated on window.__TAURI__. */
.native-prompt-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.native-prompt-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; min-width: 320px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
.native-prompt-message { font-size: 14px; margin-bottom: 12px; }
.native-prompt-input {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 8px 10px; font-size: 14px; box-sizing: border-box;
}
.native-prompt-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.native-prompt-cancel { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }
.native-prompt-ok { background: var(--accent); color: white; border: none; }

/* ---- Phone drill-in navigation (<=720px) ----
   On a narrow screen the sidebar + content side-by-side is too cramped for the
   whole overview, so the depot LIST becomes the front page and you drill into
   one depot at a time (Nordnet-app style), with a back button. Desktop/iPad
   (wider than 720px) are completely unaffected -- none of this applies there.
   The list<->depot state is driven by `body.nav-depot`, toggled by the mobile
   nav logic in portfolios.js. */
.mobile-back { display: none; }

@media (max-width: 720px) {
  /* Stack the layout; the sidebar becomes a full-width, non-sticky list. */
  .app-layout { display: block; }
  .portfolio-tabs {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px 16px;
    box-sizing: border-box;
    gap: 4px;
  }
  .top-bar ~ .app-layout .portfolio-tabs { top: 0; height: auto; }
  /* Bigger, finger-friendly depot rows. */
  .portfolio-tab { padding: 14px 12px; font-size: 15px; }
  .portfolio-tab .tab-icon { width: 26px; height: 26px; }
  .tab-badge { font-size: 13px; }

  /* Default state = LIST: show the depot list, hide the depot content. */
  .app-main { display: none; }
  /* Drilled into a depot: hide the list, show the content full-width. */
  body.nav-depot .portfolio-tabs { display: none; }
  body.nav-depot .app-main { display: block; }

  /* admin.html is NOT part of the depot drill-in flow -- it's a standalone
     tools page reached from the top-bar "Admin" link, which never sets the
     nav-depot drill state. Without this, tapping Admin from the depot list
     lands on admin.html with its .app-main (all the admin tools: portfolio
     management/add-depot, CSV import/export, holdings CRUD) still hidden, so
     the user just sees the depot list again. Always show admin's content on
     mobile; the sidebar tabs stay stacked above it for switching the active
     portfolio. Scoped to admin via :has(.admin-wrap) so no other page is
     affected. */
  .app-main:has(.admin-wrap) { display: block; }

  /* Back-to-list button, only while inside a depot. */
  body.nav-depot .mobile-back {
    display: flex;
    align-items: center;
    gap: 4px;
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    background: var(--surface);
    border: none;
    border-bottom: 1px solid var(--border);
    color: var(--accent);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
  }

  /* The indices ribbon is wide/secondary on a phone -- hide it to give the
     list and content the full width. The Admin link stays reachable in the
     top-bar on the pages that have one. */
  .indices-ribbon { display: none; }

  /* With the ribbon gone the top-bar is only the actions, and 🌐 + 💡 +
     ⚙️ Import / konto + Log ud is already at the width of a phone. The website
     link keeps just its globe here (the title still names it). */
  .site-link-text { display: none; }
  .site-link { padding-left: 16px; padding-right: 16px; }
}

/* Analyst-sentiment bull/bear bar on the stock detail card. Segments are
   sized with inline style="width:..%" set from the recommendationTrend
   distribution (allowed under the CSP's style-src 'unsafe-inline'). */
.sentiment-bar {
  display: flex;
  width: 100%;
  height: 6px;
  margin-top: 5px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--border);
}
.sentiment-bar span { height: 100%; }
.sentiment-bull { background: var(--green); }
.sentiment-hold { background: var(--text-dim); }
.sentiment-bear { background: var(--red); }
/* Reddit retail-sentiment approval bar: a single green fill (mean upvote
   ratio) on the same grey track as the analyst bar above. */
.retail-fill { background: var(--green); height: 100%; }

/* ==========================================================================
   Print / save-as-PDF (#37). Kept LAST in the file on purpose: these rules
   override the dark theme for a clean paper/PDF, and must win on source order
   over equal-specificity !important rules earlier in the sheet (e.g. the
   privacy-mode `.money-all { color: transparent }` at line ~460).
   Colours are forced ON THE ELEMENTS, not via a :root custom-property override —
   WebKit (Safari + the Mac app's WKWebView) doesn't reliably apply var overrides
   inside @media print, which left light text on white = a blank-looking page.
   ========================================================================== */
@media print {
  html, body {
    background: #fff !important; color: #000 !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  body *, body *::before, body *::after {
    background: transparent !important; background-color: transparent !important;
    box-shadow: none !important; text-shadow: none !important;
  }
  body, h1, h2, h3, h4, h5, p, span, div, td, th, li, a, strong, b, label, small, em,
  input, select, textarea {
    color: #000 !important;
  }
  /* Inputs (FIRE assumption fields etc.) also need a visible border and no
     dark-theme focus/background bleed-through on white paper. */
  input, select, textarea { border-color: #999 !important; background: #fff !important; }
  /* Keep gain/loss semantics, legible on white. */
  .up, .green, .pdot.up, [class*="pct"].up { color: #0a7d33 !important; }
  .down, .red, .pdot.down { color: #c02626 !important; }
  /* Muted secondary text. */
  .subtitle, .summary-label, .stock-name, .mut, .flat, .detail-stat-label,
  .kpi-label, .section-label, .admin-note { color: #555 !important; }
  /* Card / table outlines so structure reads on paper. */
  .highlight-box, .card, section, table, td, th, tr, .summary-box,
  .detail-card, .analysis-table { border-color: #ccc !important; }
  /* Show the REAL amounts even when privacy mode (👁) is on — an export/PDF is
     for your own records, not a screen-share. Otherwise every kr value printed
     as its •••• dots (which read as "no data"). This rule sits after the base
     privacy rule, so it wins. */
  body.privacy-all .money-all { color: #000 !important; }
  body.privacy-all .money-all::after { content: none !important; display: none !important; }
  /* Hide the app chrome. */
  .top-bar, .portfolio-tabs, .section-nav, .meta-row, .privacy-toggle,
  #refresh-btn, #print-btn, #lang-toggle, .back-link, .admin-link,
  .feature-suggest, .diag-overlay { display: none !important; }
  .app-layout { display: block !important; }
  .app-main, main, header, .all-wrap {
    max-width: none !important; width: auto !important; margin: 0 !important; padding: 0 !important;
  }
  .table-scroll { overflow: visible !important; max-height: none !important; }
  section, .highlight-box, .card, .summary-box, table { break-inside: avoid; }
  @page { margin: 12mm; }
}

/* ---- Global stock-search modal (stock-search.js) ---- */
.stock-search-overlay { align-items: flex-start; }
.stock-search-modal { width: min(720px, 94vw); margin-top: 8vh; padding: 16px 18px; }
.ssm-top { display: flex; align-items: center; gap: 10px; }
.ssm-input {
  flex: 1; box-sizing: border-box; background: #0d1017;
  border: 1px solid var(--border, #232838); border-radius: 8px;
  padding: 11px 14px; color: var(--text, #e6e9f0); font-size: 15px;
}
.ssm-input:focus { outline: none; border-color: var(--accent); }
.ssm-close {
  background: none; border: none; color: var(--text-dim); font-size: 26px;
  line-height: 1; cursor: pointer; padding: 0 6px;
}
.ssm-close:hover { color: var(--text); }
.ssm-body { margin-top: 14px; }
.ssm-section { color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; margin: 2px 2px 6px; }
.ssm-empty { color: var(--text-dim); font-size: 14px; padding: 14px 4px; }
.ssm-list { max-height: 46vh; overflow-y: auto; }
.ssm-result {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
}
.ssm-result:hover { background: var(--surface-hover); }
.ssm-result-main { display: flex; flex-direction: column; min-width: 0; }
.ssm-result-symbol { font-weight: 600; font-size: 14px; }
.ssm-result-name { color: var(--text-dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ssm-result-meta { color: var(--text-dim); font-size: 11px; white-space: nowrap; flex-shrink: 0; }
/* Selected-stock info card */
.ssm-info { display: none; margin-top: 6px; }
.ssm-info.shown { display: block; }
.ssm-info-loading { color: var(--text-dim); padding: 16px 4px; }
.ssm-info-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 6px 2px 12px; border-bottom: 1px solid var(--border); }
.ssm-info-name { font-size: 17px; font-weight: 700; }
.ssm-info-sub { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.ssm-tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.ssm-tag { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; color: var(--text-dim); font-size: 11px; padding: 3px 9px; }
.ssm-info-price { text-align: right; flex-shrink: 0; }
.ssm-price { font-size: 20px; font-weight: 700; }
.ssm-change { font-size: 14px; margin-top: 2px; }
.ssm-change.up, .ssm-stat-value.up { color: var(--green); }
.ssm-change.down, .ssm-stat-value.down { color: var(--red); }
.ssm-change.flat, .ssm-stat-value.flat { color: var(--text-dim); }
.ssm-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; padding: 14px 2px; }
.ssm-stat-label { color: var(--text-dim); font-size: 11px; }
.ssm-stat-value { font-size: 15px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.ssm-info-actions { display: flex; align-items: center; gap: 12px; padding: 6px 2px 2px; }
.ssm-add-btn {
  background: var(--accent); border: none; border-radius: 8px; color: #fff;
  font-size: 14px; font-weight: 600; padding: 9px 16px; cursor: pointer;
}
.ssm-add-btn:disabled { opacity: 0.6; cursor: default; }
.ssm-add-status { color: var(--text-dim); font-size: 13px; }

/* ---- Per-stock notes (stock-notes.js) ---- */
.detail-note-block { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
/* Collapsed trigger: just a small icon+label until clicked */
.stock-note-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-dim); cursor: pointer; font-size: 13px; font-weight: 500; padding: 7px 12px;
}
.stock-note-toggle:hover { color: var(--text); border-color: var(--text-dim); }
.stock-note-toggle.has-note { color: var(--text); border-color: var(--accent); }
.stock-note-editor { margin-top: 10px; }
.stock-note-status { color: var(--text-dim); font-size: 12px; font-weight: 400; }
.stock-note-input {
  width: 100%; box-sizing: border-box; min-height: 84px; resize: vertical;
  background: #0d1017; border: 1px solid var(--border, #232838); border-radius: 8px;
  padding: 10px 12px; color: var(--text, #e6e9f0); font: inherit; font-size: 14px; line-height: 1.5;
}
.stock-note-input:focus { outline: none; border-color: var(--accent); }
.stock-note-input:disabled { opacity: 0.6; }
.stock-note-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.stock-note-save {
  background: var(--accent); border: none; border-radius: 8px; color: #fff;
  font-size: 13px; font-weight: 600; padding: 8px 16px; cursor: pointer;
}
.stock-note-save:disabled { opacity: 0.6; cursor: default; }
/* 📝 note indicator on a table row / result */
.has-note-mark { margin-left: 6px; opacity: 0.85; font-size: 12px; }
/* note block inside the global search info card */
#ssm-note .detail-note-block { border-top: none; padding-top: 0; margin-top: 14px; }

/* (The rule that hid .portfolio-tab-add is gone: multi-portfolio create/manage
   IS supported now, so the sidebar's "+ Ny portefølje" button must be visible.) */
