/* Typsnittet Onest ligger på vår egen server, så att inga besökares uppgifter skickas till Google. Licens: assets/fonts/OFL.txt */
@font-face { font-family: 'Onest'; src: url('/assets/fonts/onest.woff') format('woff'); font-weight: 100 900; font-style: normal; font-display: swap; }

:root {
  --bg: #ECEDEF;
  --surface: #F7F7F8;
  --card: #FFFFFF;
  --line: #E3E4E7;
  --line-soft: #EEEFF1;
  --ink: #111214;
  --ink-2: #3A3D42;
  --muted: #6B6F76;
  --faint: #9A9EA5;
  --up: #1E7A45; --up-bg: #E7F4EC;
  --down: #B42318; --down-bg: #FBE9E7;
  --warn: #8A6100; --warn-bg: #FDF3D7;
  --chip: #F1F2F4;
  --r-card: 28px;
  --r-sm: 22px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Onest', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); }
a:hover { color: var(--muted); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  flex: 0 0 272px; padding: 16px 0 16px 16px;
  position: sticky; top: 0; height: 100vh;
}
.nav {
  height: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 30px;
  padding: 26px 18px; display: flex; flex-direction: column; gap: 24px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; border-radius: 50%; background: var(--ink); display: grid; place-items: center; flex: none; }
.brand-name { font-weight: 500; font-size: 16px; display: block; }
.brand-sub { font-size: 12.5px; color: var(--muted); display: block; }
.welcome { padding: 0 6px; }
.welcome b { display: block; font-size: 26px; font-weight: 400; letter-spacing: -0.02em; line-height: 1.15; }
.welcome span { font-size: 13px; color: var(--muted); }
.nav-group { display: flex; flex-direction: column; gap: 4px; }
.nav-label { font-size: 12.5px; color: var(--faint); padding: 0 16px 4px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-radius: 999px;
  text-decoration: none; color: #55595F; min-height: 46px; font-size: 15px;
}
.nav-link:hover { background: var(--chip); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--ink); color: #FFFFFF; }
.nav-badge { margin-left: auto; font-size: 11.5px; min-width: 20px; height: 20px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--ink); color: #FFFFFF; padding: 0 6px; }
.nav-link[aria-current="page"] .nav-badge { background: #FFFFFF; color: var(--ink); }
.nav-foot { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--line-soft); font-size: 12.5px; color: var(--muted); padding-left: 6px; padding-right: 6px; }

.main { flex: 1; min-width: 0; padding: 26px 32px 48px; display: flex; flex-direction: column; gap: 24px; }
.main > *, .card, .split > * { min-width: 0; }
.main:focus { outline: none; }

/* ---------- Topbar ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 10px; font-size: 16px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs .here { color: var(--ink); }
.searchbar {
  display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 0 6px 0 18px; flex: 0 1 360px; min-height: 48px;
}
.searchbar input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 15px; color: var(--ink); padding: 12px 0; outline: none; }
.searchbar:focus-within { border-color: var(--ink); }
.searchbar input::placeholder { color: var(--faint); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  padding: 10px 20px; border-radius: 999px; border: 1px solid var(--ink); background: var(--ink); color: #FFFFFF;
  text-decoration: none; cursor: pointer; font-size: 15px; white-space: nowrap;
}
.btn:hover { color: #FFFFFF; background: #2A2C30; }
.btn.ghost { background: var(--card); color: var(--ink); border-color: #D5D7DB; }
.btn.ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn.white { background: #FFFFFF; color: var(--ink); border-color: #FFFFFF; }
.btn.small { min-height: 38px; padding: 7px 16px; font-size: 14px; }

/* ---------- Typography ---------- */
.eyebrow { font-size: 14px; color: var(--muted); }
h1.title { margin: 0; font-size: clamp(36px, 5vw, 52px); font-weight: 400; letter-spacing: -0.02em; line-height: 1.05; }
h2.section { margin: 0; font-size: 26px; font-weight: 400; letter-spacing: -0.01em; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.more { font-size: 14px; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 22px; }
.card.dark { background: var(--ink); color: #FFFFFF; border-color: var(--ink); position: relative; overflow: hidden; }
.card.dark .muted { color: rgba(255,255,255,0.62); }
.card.dark .faint { color: rgba(255,255,255,0.5); }
.card.dark a { color: #FFFFFF; }
.card.dark .btn.white, .card.dark .btn.white:hover { color: var(--ink); }
.hero-link, .hero-link:hover { text-decoration: none; color: var(--ink); }
.hero-link.dark, .hero-link.dark:hover { color: #FFFFFF; }
.hero-link:hover { border-color: #B9BBC0; }
.rings::before, .rings::after { content: ''; position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,0.12); pointer-events: none; }
.rings::before { right: -70px; top: -70px; width: 220px; height: 220px; }
.rings::after { right: -25px; top: -25px; width: 130px; height: 130px; border-color: rgba(255,255,255,0.08); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid { display: grid; gap: 18px; }
.g3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.split > .wide { flex: 3 1 520px; min-width: 0; }
.split > .narrow { flex: 1 1 280px; min-width: 0; }

.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--chip); display: grid; place-items: center; font-size: 12px; flex: none; }
.card.dark .avatar { background: rgba(255,255,255,0.1); }

/* ---------- Pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 11px; border-radius: 999px; background: var(--chip); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill.up { background: var(--up-bg); color: var(--up); }
.pill.down { background: var(--down-bg); color: var(--down); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.inv { background: #FFFFFF; color: var(--ink); }
.pill.outline { background: transparent; border: 1px solid var(--line); color: var(--ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 14px; font-size: 14px; cursor: pointer; color: var(--ink-2); min-height: 38px; }
.chip-btn[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; border-color: var(--ink); }

.tabs { display: inline-flex; padding: 4px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; padding: 0 22px; min-height: 42px; border-radius: 999px; cursor: pointer; color: var(--muted); font-size: 15px; }
.tabs button[aria-selected="true"] { background: var(--ink); color: #FFFFFF; }

/* ---------- Ticker ---------- */
.ticker { display: flex; flex-wrap: wrap; gap: 10px 22px; padding: 12px 0; border-top: 1px solid #DADBDF; border-bottom: 1px solid #DADBDF; font-size: 14px; }
.ticker span { display: inline-flex; gap: 8px; align-items: baseline; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); display: inline-block; }

/* ---------- Hero ---------- */
.hero { display: flex; flex-direction: column; gap: 14px; min-height: 190px; }
.hero .big { font-size: 36px; font-weight: 400; letter-spacing: -0.02em; line-height: 1.1; }

/* ---------- Lists ---------- */
.row-link { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-soft); text-decoration: none; color: var(--ink); min-height: 48px; }
.row-link:first-of-type { border-top: 0; }
.row-link .grow { flex: 1; min-width: 0; }
.news-item { display: flex; gap: 18px; align-items: flex-start; }
.news-icon { flex: none; width: 48px; height: 48px; border-radius: 16px; background: var(--chip); display: grid; place-items: center; }
.news-item h3 { margin: 0; font-size: 19px; font-weight: 500; line-height: 1.3; }
.news-item p { margin: 0; color: #55595F; font-size: 15px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; font-size: 13px; color: var(--muted); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; padding: 8px; position: relative; }
table { width: 100%; border-collapse: collapse; min-width: 620px; font-size: 15px; }
th { font-weight: 400; color: var(--muted); font-size: 13px; text-align: left; padding: 12px 14px; }
td { padding: 12px 14px; border-top: 1px solid var(--line-soft); }
td.r, th.r { text-align: right; }
tbody tr:hover { background: #FAFAFB; }
.co { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); min-height: 44px; }

/* ---------- Search / risk ---------- */
.big-search { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 6px 6px 22px; }
.big-search:focus-within { border-color: var(--ink); }
.big-search input { flex: 1; min-width: 0; background: transparent; border: 0; font: inherit; font-size: 17px; padding: 12px 0; outline: none; color: var(--ink); }
.result {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--r-sm);
  background: var(--card); border: 1px solid var(--line); text-align: left; cursor: pointer; width: 100%; min-height: 64px;
}
.result:hover { border-color: #B9BBC0; }
.result[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; border-color: var(--ink); }
.result[aria-pressed="true"] .avatar { background: rgba(255,255,255,0.12); }
.result[aria-pressed="true"] .muted { color: rgba(255,255,255,0.6); }
.result[aria-pressed="true"] .pill { background: #FFFFFF; color: var(--ink); }
.score { font-size: 64px; font-weight: 300; line-height: 1; }
.meter { display: flex; gap: 4px; }
.meter span { flex: 1; height: 8px; border-radius: 999px; background: rgba(255,255,255,0.15); }
.meter span.on { background: #FFFFFF; }
.factor { border-radius: 24px; padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; }
.factor .hd { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 500; }

/* ---------- Performance bars ---------- */
.perf-row { display: grid; grid-template-columns: 70px minmax(0, 1fr) 76px; gap: 14px; align-items: center; font-size: 14px; }
.perf-track { position: relative; height: 12px; border-radius: 999px; background: var(--chip); }
.perf-track .zero { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: #C9CBD0; }
.perf-bar { position: absolute; top: 0; bottom: 0; border-radius: 999px; background: var(--ink); }
.perf-bar.neg { background: var(--down); }

/* ---------- Footer ---------- */
.foot { font-size: 13px; color: var(--faint); border-top: 1px solid #DADBDF; padding-top: 16px; }
.empty { border: 1px dashed #D0D2D6; border-radius: var(--r-sm); padding: 16px 18px; font-size: 14px; color: var(--muted); }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { position: sticky; top: 0; height: auto; flex: none; padding: 10px 12px 0; z-index: 10; background: var(--bg); }
  .nav { flex-direction: row; align-items: center; padding: 8px 10px; gap: 8px; border-radius: 999px; overflow-x: auto; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .brand-text, .welcome, .nav-label, .nav-foot { display: none; }
  .brand { padding: 0; }
  .brand-mark { width: 36px; height: 36px; }
  .nav-group { flex-direction: row; gap: 4px; }
  .nav-link { min-height: 40px; padding: 8px 14px; white-space: nowrap; font-size: 14px; }
  .nav-link svg { display: none; }
  .main { padding: 18px 16px 40px; gap: 20px; }
  .searchbar { flex: 1 1 100%; }
  .ticker { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; white-space: nowrap; margin: 0 -16px; padding: 10px 16px; }
  .ticker::-webkit-scrollbar { display: none; }
  .score { font-size: 52px; }
}

/* ---------- Bolagssida ---------- */
.label-up { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.co-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px 32px; flex-wrap: wrap; }
.statbar { display: flex; flex-wrap: wrap; gap: 1px; padding: 0; background: var(--line); overflow: hidden; }
.stat { background: var(--card); padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; flex: 1 1 150px; }
.stat .num { font-size: 16px; }
.co-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 24px; align-items: start; }
.co-side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 16px; }
.co-section { display: flex; flex-direction: column; gap: 14px; padding: 26px 28px; }
.lead { margin: 0; font-size: 18px; line-height: 1.6; color: var(--ink); max-width: 68ch; }
.sub { margin: 0; font-size: 17px; font-weight: 500; }
.prose p { margin: 0 0 12px; color: var(--ink-2); font-size: 15.5px; line-height: 1.7; max-width: 68ch; }
.prose p:last-child { margin-bottom: 0; }
.facts { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: 18px; overflow: hidden; }
.facts div { background: var(--card); padding: 12px 16px; }
.facts dt { font-size: 12.5px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-size: 15px; }
.factor-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line-soft); }
.factor-row:first-child { border-top: 0; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
a.result { text-decoration: none; color: var(--ink); }
a.result:hover { color: var(--ink); }
@media (max-width: 1100px) {
  .co-grid { grid-template-columns: minmax(0, 1fr); }
  .co-side { position: static; order: -1; }
}
@media (max-width: 900px) {
  .co-head { align-items: flex-start; }
  .co-head > .stack { align-items: flex-start !important; }
  .co-section { padding: 20px; }
  .lead { font-size: 16.5px; }
}

/* ================= Rörelse och 3D =================
   Bara transform och opacity, så att allt körs på grafikkortet och sidan förblir snabb.
   Allt stängs av för den som valt "minska rörelse" i sitt system. */
@keyframes mk-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes mk-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mk-bar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes mk-fill { from { transform: scaleY(0.2); opacity: 0.2; } to { transform: none; opacity: 1; } }
@keyframes mk-sweep { to { transform: translateX(100%); } }
@keyframes mk-pulse { 0% { transform: scale(1); opacity: 0.5; } 80%, 100% { transform: scale(2.6); opacity: 0; } }
@keyframes mk-spin { to { transform: rotateY(360deg); } }
@keyframes mk-float { 0%, 100% { transform: translateY(0) rotateX(64deg) rotateZ(0); } 50% { transform: translateY(-6px) rotateX(64deg) rotateZ(8deg); } }
@keyframes mk-flash-up { 0% { background: var(--up-bg); } 100% { background: transparent; } }
@keyframes mk-flash-down { 0% { background: var(--down-bg); } 100% { background: transparent; } }

@media (prefers-reduced-motion: no-preference) {
  /* Innehållet glider in, kort för kort */
  .main > * { animation: mk-rise 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) backwards; }
  .main > *:nth-child(2) { animation-delay: 40ms; } .main > *:nth-child(3) { animation-delay: 80ms; }
  .main > *:nth-child(4) { animation-delay: 120ms; } .main > *:nth-child(5) { animation-delay: 160ms; }
  .main > *:nth-child(6) { animation-delay: 200ms; } .main > *:nth-child(n+7) { animation-delay: 240ms; }
  #bolag .card, #results > *, .co-side > *, .grid > .card { animation: mk-rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) backwards; }
  .grid > :nth-child(2), #results > :nth-child(2), .co-side > :nth-child(2) { animation-delay: 60ms; }
  .grid > :nth-child(3), #results > :nth-child(3), .co-side > :nth-child(3) { animation-delay: 120ms; }
  #results > :nth-child(n+4), .co-side > :nth-child(n+4) { animation-delay: 170ms; }
  .co-main > :nth-child(2) { animation-delay: 70ms; } .co-main > :nth-child(3) { animation-delay: 130ms; } .co-main > :nth-child(n+4) { animation-delay: 180ms; }

  /* Staplar och riskmätare växer fram */
  .perf-bar { animation: mk-bar 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) 0.25s backwards; transform-origin: left center; }
  .perf-bar.neg, .perf-bar[style*="right"] { transform-origin: right center; }
  .meter span.on { animation: mk-fill 0.5s cubic-bezier(0.3, 1.4, 0.5, 1) backwards; animation-delay: calc(var(--i, 0) * 60ms + 200ms); transform-origin: bottom; }

  /* Laddning: skimrande yta i stället för stillastående text */
  .empty[aria-busy="true"] { position: relative; overflow: hidden; border-style: solid; border-color: transparent; background: #F2F3F5; }
  .card.dark .empty[aria-busy="true"] { background: rgba(255,255,255,0.06); }
  .empty[aria-busy="true"]::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.65), transparent); transform: translateX(-100%); animation: mk-sweep 1.4s ease-in-out infinite; }
  .card.dark .empty[aria-busy="true"]::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent); }

  /* Pulserande livepunkt */
  .dot { background: var(--up); position: relative; }
  .dot::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--up); animation: mk-pulse 2.4s ease-out infinite; }


  /* Kort lyfter vid hovring */
  .hero-link, a.result, .row-link[href] { transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.25s ease, border-color 0.2s ease, background-color 0.2s ease; }
  a.result:hover, .hero-link:hover { box-shadow: 0 14px 34px -18px rgba(17,18,20,0.35); }
  .row-link[href]:hover { transform: translateX(3px); }
  .btn { transition: transform 0.15s ease, background-color 0.2s ease, color 0.2s ease; }
  .btn:active { transform: scale(0.97); }

  /* Kurser blinkar grönt eller rött när de uppdateras */
  .flash-up { animation: mk-flash-up 1.2s ease-out; border-radius: 6px; }
  .flash-down { animation: mk-flash-down 1.2s ease-out; border-radius: 6px; }
}

/* 3D-lutning med ljusreflex. Styrs av JavaScript via --rx, --ry, --mx och --my. */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  /* I vila har korten ingen transform alls, så att texten ritas skarpt. Lutningen finns bara under muspekaren. */
  .tilt { transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.3s ease, border-color 0.2s ease; }
  .tilt.is-tilting { transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform 0.08s linear, box-shadow 0.3s ease; box-shadow: 0 24px 50px -26px rgba(17,18,20,0.45); }
  .glare { position: relative; isolation: isolate; }
  .glare > .glare-layer { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 2; opacity: 0; transition: opacity 0.3s ease; transform: none;
    background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,0.16), transparent 45%); }
  .glare:not(.dark) > .glare-layer { background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(17,18,20,0.05), transparent 45%); }
  .glare.is-tilting > .glare-layer { opacity: 1; }
}

/* 3D-klot av roterande ringar, rent i CSS */
.orb { position: absolute; right: 22px; top: 22px; width: 92px; height: 92px; perspective: 600px; pointer-events: none; opacity: 0.9; }
.orb .orb-tilt { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateX(64deg); }
.orb i { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid rgba(255,255,255,0.35); transform-style: preserve-3d; }
.orb i:nth-child(2) { transform: rotateY(60deg); border-color: rgba(255,255,255,0.22); }
.orb i:nth-child(3) { transform: rotateY(120deg); border-color: rgba(255,255,255,0.14); }
.orb b { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #FFFFFF, #8FD3A8 45%, #1E7A45); box-shadow: 0 0 22px rgba(143,211,168,0.55); }
@media (prefers-reduced-motion: no-preference) {
  .orb .orb-tilt { animation: mk-float 6s ease-in-out infinite; }
  .orb .orb-spin { position: absolute; inset: 0; transform-style: preserve-3d; animation: mk-spin 14s linear infinite; }
}
@media (max-width: 900px) { .orb { width: 64px; height: 64px; right: 14px; top: 14px; } }

/* Sidbyten med View Transitions där webbläsaren stöder det */
::view-transition-old(root) { animation: 0.18s ease both mk-fade reverse; }
::view-transition-new(root) { animation: 0.28s ease both mk-fade; }
@media (prefers-reduced-motion: reduce) { ::view-transition-old(root), ::view-transition-new(root) { animation: none; } }

/* ================= Kursdiagram ================= */
.chart { position: relative; min-height: 120px; transition: opacity 0.2s ease; }
.chart.is-loading { opacity: 0.45; }
.chart-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-bottom: 10px; }
.chart-key { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.chart-key i, .chart-tip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chart-plot { position: relative; height: 260px; touch-action: pan-y; cursor: crosshair; }
.chart-plot svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.chart-y { position: absolute; left: 0; font-size: 12px; color: var(--faint); background: var(--card); padding: 0 4px; border-radius: 4px; pointer-events: none; }
.chart-y.top { top: 0; } .chart-y.bottom { bottom: 0; }
.chart-cross { position: absolute; top: 0; bottom: 0; left: 0; width: 1px; background: var(--line); pointer-events: none; }
.chart-dot { position: absolute; left: -5px; top: -5px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--card); pointer-events: none; }
.chart-tip { position: absolute; top: -6px; left: 0; display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; background: var(--ink); color: #FFFFFF; border-radius: 10px; font-size: 13px; pointer-events: none; white-space: nowrap; box-shadow: 0 10px 24px -12px rgba(0,0,0,0.5); }
.chart-tip .muted { color: rgba(255,255,255,0.65); }
.chart-tip b { font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
@media (prefers-reduced-motion: no-preference) {
  .chart-line { stroke-dasharray: 3000; stroke-dashoffset: 3000; animation: mk-draw 1.1s cubic-bezier(0.3, 0.7, 0.2, 1) forwards; }
}
@keyframes mk-draw { to { stroke-dashoffset: 0; } }
@media (max-width: 900px) { .chart-plot { height: 200px; } }

/* ================= AI-sammanfattning ================= */
.ai-box { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 16px 18px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; background: linear-gradient(180deg, #F7F8FA, #FFFFFF); }
.ai-box ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 15px; }

/* ================= Formulär, larm och notiser ================= */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.field input { font: inherit; font-size: 16px; color: var(--ink); padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #FFFFFF; }
.field input:focus { outline: 2px solid var(--ink); outline-offset: 1px; border-color: var(--ink); }
.linkbtn { background: none; border: 0; padding: 4px 0; color: var(--ink); text-decoration: underline; cursor: pointer; align-self: flex-start; font: inherit; }
.select { font: inherit; font-size: 14px; padding: 6px 28px 6px 10px; border: 1px solid var(--line); border-radius: 999px; background: #FFFFFF url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236B6F76' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center; appearance: none; color: var(--ink); cursor: pointer; min-height: 34px; }
.notify-bar { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin: 4px 4px 8px; border-radius: 14px; background: #F5F6F8; flex-wrap: wrap; }
.notify-bar .grow { flex: 1; min-width: 200px; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; flex-direction: column; gap: 3px; padding: 14px 16px; border-radius: 16px; background: var(--ink); color: #FFFFFF; text-decoration: none; box-shadow: 0 16px 40px -18px rgba(0,0,0,0.55); font-size: 14px; transition: opacity 0.35s ease, transform 0.35s ease; }
.toast span { color: rgba(255,255,255,0.72); }
.toast:hover { color: #FFFFFF; }
.toast.out { opacity: 0; transform: translateY(8px); }
@media (prefers-reduced-motion: no-preference) { .toast { animation: mk-rise 0.35s cubic-bezier(0.2, 0.7, 0.2, 1) backwards; } }

/* ================= Jämför ================= */
.picker { display: flex; flex-direction: column; gap: 12px; }
.picked { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.pick-results { display: flex; flex-direction: column; }
.pick { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border: 0; border-top: 1px solid var(--line-soft); background: none; font: inherit; color: var(--ink); cursor: pointer; border-radius: 10px; text-align: left; }
.pick:hover, .pick:focus-visible { background: #F5F6F8; }
table.cmp th[scope="row"] { font-weight: 500; white-space: nowrap; }
table.cmp td { vertical-align: top; }
.cmp-sub { display: block; margin-top: 4px; }
.chart-plot [hidden] { display: none !important; }

/* ================= Inloggning först ================= */
body.booting .sidebar, body.locked .sidebar { display: none; }
body.locked .main { align-items: center; justify-content: center; min-height: 100vh; padding-top: 32px; }
.auth-wrap { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 22px; }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand > span:last-child { display: flex; flex-direction: column; }
.auth-brand b { font-weight: 500; font-size: 17px; }
.auth-intro { display: flex; flex-direction: column; gap: 10px; }
.auth-card > .card { box-shadow: 0 24px 60px -36px rgba(17,18,20,0.35); }
.greet-mobile { display: none; font-size: 15px; color: var(--muted); }
@media (max-width: 900px) { .greet-mobile { display: block; } body.locked .main { min-height: auto; padding-top: 28px; } }

/* ================= Alla aktier ================= */
.ak-filters { display: flex; flex-direction: column; gap: 16px; padding: 20px 22px; }
.ak-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.ak-group { display: flex; flex-direction: column; gap: 8px; }
.chip-n { font-size: 12px; opacity: 0.6; margin-left: 2px; font-variant-numeric: tabular-nums; }
.chip-btn:disabled { opacity: 0.4; cursor: default; }
.chip-btn:not([aria-pressed="true"]):not(:disabled):hover { border-color: var(--ink); }
.ak-table { min-width: 0; }
.ak-table td { vertical-align: middle; }
.ak-name { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; min-width: 0; }
.ak-name > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.ak-name b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34ch; }
.ak-name:hover b { text-decoration: underline; }
.th-sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; white-space: nowrap; }
.th-sort:hover { color: var(--ink); }
th.r .th-sort { text-align: right; }
.star-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid transparent; background: none; color: var(--faint); cursor: pointer; display: inline-grid; place-items: center; }
.star-btn:hover { border-color: var(--line); color: var(--ink); }
.star-btn[aria-pressed="true"] { color: #C58A00; }
.star-btn[aria-pressed="true"] svg path { fill: currentColor; }
@media (max-width: 1100px) { .hide-sm { display: none; } }
@media (max-width: 520px) { .hide-xs { display: none; } .ak-name .avatar { display: none; } .ak-name b { max-width: 20ch; } .ak-filters { padding: 16px; } }
@media (max-width: 900px) { .ak-group .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 2px; } .ak-group .chips::-webkit-scrollbar { display: none; } .ak-group .chip-btn { flex: none; } }

/* ================= Ordförklaringar ================= */
.tip { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-left: 6px; border-radius: 50%; border: 1px solid currentColor; background: none; color: inherit; opacity: 0.55; font: 600 11px/1 'Onest', sans-serif; cursor: pointer; vertical-align: 0.12em; padding: 0; }
.tip:hover, .tip[aria-expanded="true"] { opacity: 1; }
.tip:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; opacity: 1; }
h2 .tip { width: 20px; height: 20px; font-size: 12px; vertical-align: 0.25em; }
.tip-box { position: absolute; z-index: 60; display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; background: var(--ink); color: #FFFFFF; border-radius: 14px; font-size: 14px; line-height: 1.5; box-shadow: 0 18px 40px -18px rgba(0,0,0,0.55); }
.tip-box span { color: rgba(255,255,255,0.82); }
.tip-box a { color: #FFFFFF; font-size: 13px; }
@media (prefers-reduced-motion: no-preference) { .tip-box { animation: mk-fade 0.15s ease; } }
.glossary { margin: 0; display: grid; }
.glossary > div { padding: 16px 0; border-top: 1px solid var(--line-soft); display: grid; grid-template-columns: 180px 1fr; gap: 6px 20px; }
.glossary > div:first-child { border-top: 0; }
.glossary dt { font-weight: 500; }
.glossary dd { margin: 0; color: var(--ink-2); line-height: 1.55; }
@media (max-width: 700px) { .glossary > div { grid-template-columns: 1fr; } }

/* ================= Sidfot, Om oss, integritet ================= */
.foot-links { display: flex; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
.foot-links a { color: var(--ink); }
.om-grid { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.om-person { display: flex; flex-direction: column; gap: 14px; padding: 26px; position: sticky; top: 20px; }
.om-photo { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; font-size: 34px; }
.om-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; line-height: 1.55; }
.prose-sec { max-width: 820px; gap: 14px; }
.prose-sec h2.section { font-size: 20px; margin-top: 10px; }
@media (max-width: 900px) { .om-grid { grid-template-columns: 1fr; } .om-person { position: static; } }
body.nosidebar .sidebar { display: none; }

/* ================= Radera konto ================= */
.danger-link { color: var(--down); }
.btn.danger { background: var(--down); color: #FFFFFF; border-color: var(--down); }
.btn.danger:disabled { opacity: 0.4; cursor: not-allowed; }
.modal-back { position: fixed; inset: 0; z-index: 70; background: rgba(17,18,20,0.45); display: grid; place-items: center; padding: 16px; }
.modal { max-width: 440px; width: 100%; display: flex; flex-direction: column; gap: 14px; padding: 26px; }

/* ================= Kom igång ================= */
.on-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.on-card { position: relative; display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--r-sm); border: 1.5px solid var(--line); background: var(--card); font: inherit; color: var(--ink); cursor: pointer; text-align: left; transition: border-color 0.15s ease, background-color 0.15s ease; }
.on-card b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.on-card .small { display: block; }
.on-card:hover { border-color: var(--ink); }
.on-card[aria-pressed="true"] { border-color: var(--ink); background: #F5F6F8; }
.on-check { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; color: transparent; flex: none; }
.on-card[aria-pressed="true"] .on-check { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
.on-d1 { position: absolute; right: 12px; top: 8px; font-size: 12px; font-variant-numeric: tabular-nums; }
.on-bar { position: sticky; bottom: 12px; display: flex; align-items: center; gap: 16px; padding: 12px 14px 12px 20px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 18px 40px -24px rgba(17,18,20,0.4); margin-top: 4px; }
.on-bar #on-count { margin-right: auto; }
.install-tip { display: flex; gap: 10px; align-items: center; padding: 10px 14px; margin: 0 4px 8px; border-radius: 14px; border: 1px dashed var(--line); }

/* ================= Portföljer ================= */
.mini-bar { display: inline-block; width: 110px; height: 8px; border-radius: 99px; background: #EEEFF1; overflow: hidden; flex: none; }
.mini-bar > span { display: block; height: 100%; border-radius: 99px; background: var(--ink); }
.dist { display: flex; flex-direction: column; gap: 10px; }
.dist-row { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.flags { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.flag { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5; }
.flag svg { flex: none; margin-top: 2px; }
.flag.warn { background: var(--warn-bg, #FDF3D7); color: #5C4300; }
.flag.info { background: #F2F4F7; }
.flag.ok { background: var(--up-bg); color: #145A32; }
.pf-add { display: flex; flex-direction: column; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.pf-form { display: flex; flex-direction: column; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #FAFAFB; }
.pf-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pf-table td { vertical-align: middle; }
.picker-wrap .pick-results:empty { display: none; }
@media (max-width: 520px) { .pf-fields { grid-template-columns: 1fr; } .mini-bar { width: 70px; } }

/* ================= AI-assistent ================= */
.chat-wrap { width: 100%; max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.chat-head { display: flex; align-items: center; gap: 16px; }
.ai-mark { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 16px; background: linear-gradient(140deg, #111214 0%, #2A2D33 60%, #1E7A45 140%); flex: none; }
.ai-mark.small { width: 32px; height: 32px; border-radius: 11px; }
.chat-log { display: flex; flex-direction: column; gap: 18px; min-height: 260px; }
.chat-empty { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.idea-group { display: flex; flex-direction: column; gap: 8px; padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm); }
.idea { text-align: left; font: inherit; font-size: 15px; color: var(--ink); background: #F7F8FA; border: 1px solid transparent; border-radius: 12px; padding: 11px 14px; cursor: pointer; transition: border-color 0.15s ease, background-color 0.15s ease; }
.idea:hover, .idea:focus-visible { border-color: var(--ink); background: #FFFFFF; }
.msg { display: flex; gap: 12px; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { max-width: min(560px, 85%); background: var(--ink); color: #FFFFFF; padding: 12px 16px; border-radius: 18px 18px 6px 18px; font-size: 15px; line-height: 1.5; white-space: pre-wrap; }
.msg.ai .ai-body { flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 6px 18px 18px 18px; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.ai-text { font-size: 15.5px; line-height: 1.62; color: var(--ink); overflow-wrap: anywhere; }
.ai-text p { margin: 0 0 10px; } .ai-text p:last-child { margin-bottom: 0; }
.ai-text h4 { margin: 14px 0 6px; font-size: 16px; font-weight: 600; } .ai-text h4:first-child { margin-top: 0; }
.ai-text ul, .ai-text ol { margin: 0 0 10px; padding-left: 20px; display: flex; flex-direction: column; gap: 5px; }
.ai-text code { font-size: 0.92em; background: #F2F3F5; padding: 1px 5px; border-radius: 5px; }
.ai-text b { font-weight: 600; }
.caret { display: inline-block; width: 8px; height: 1.05em; vertical-align: -0.15em; margin-left: 2px; background: var(--ink); border-radius: 2px; animation: mk-blink 1s steps(2) infinite; }
@keyframes mk-blink { 50% { opacity: 0; } }
.typing { display: inline-flex; gap: 5px; padding: 6px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: mk-dot 1.2s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; } .typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes mk-dot { 0%, 80%, 100% { transform: translateY(0); opacity: 0.4; } 40% { transform: translateY(-4px); opacity: 1; } }
.ai-tools { display: flex; gap: 14px; } .ai-tools .linkbtn { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); text-decoration: none; }
.followups { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.followups .chip-btn { text-align: left; white-space: normal; line-height: 1.35; }
.composer { position: sticky; bottom: 12px; z-index: 5; display: flex; flex-direction: column; gap: 8px; padding: 12px 12px 10px 18px; background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 20px 44px -28px rgba(17,18,20,0.45); }
.composer:focus-within { border-color: var(--ink); }
.composer textarea { border: 0; outline: none; resize: none; font: inherit; font-size: 16px; line-height: 1.5; color: var(--ink); background: transparent; padding: 6px 0; max-height: 200px; }
.composer-row { display: flex; align-items: center; gap: 10px; }
.composer-ctx:empty { display: none; }
.ctx-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 5px 6px 5px 10px; border-radius: 99px; background: #F2F4F7; }
.ctx-chip button { border: 0; background: none; font-size: 16px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.btn.send { width: 42px; height: 42px; padding: 0; border-radius: 50%; display: inline-grid; place-items: center; }
@media (prefers-reduced-motion: reduce) { .caret, .typing i { animation: none; } }
@media (max-width: 700px) { .chat-empty { grid-template-columns: 1fr; } .msg.ai .ai-mark { display: none; } .msg.ai .ai-body { padding: 14px 16px; } .composer { bottom: 8px; } }

/* Dolda element ska alltid vara dolda, även knappar med egen display */
[hidden] { display: none !important; }
@media (max-width: 700px) { .chat-head { flex-wrap: wrap; } }
.field input { width: 100%; min-width: 0; box-sizing: border-box; }
.pf-fields > * { min-width: 0; }
.pf-table { width: 100%; }
.pf-table .ak-name b { white-space: normal; max-width: none; overflow: visible; line-height: 1.3; }
.pf-table td:first-child { min-width: 0; width: 100%; }
.pf-table .avatar { flex: none; }
.dist-row > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1300px) and (min-width: 1101px) { .pf-table .avatar { display: none; } }
.pf-table { min-width: 0 !important; table-layout: auto; }
.pf-table td, .pf-table th { padding-left: 8px; padding-right: 8px; }
.pf-table td.num, .pf-table td.r { white-space: nowrap; }
@media (max-width: 1500px) { .pf-table .hide-xs { display: none; } }
@media (max-width: 520px) { .pf-table .avatar { display: none; } .pf-table .btn.small { padding: 6px 10px; } }
