/* InsiderKompassen mobil – vitt + orange.
   Kontrast: --accent (#C2410C) mot vitt 5.2:1, vit text på --accent likaså.
   --brand (#EA580C) används bara bakom fet text >= 18px (topbar). */
:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --raised: #fff7ed;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --text: #1c1917;
  --muted: #57534e;
  --soft: #44403c;
  --brand: #ea580c;
  --accent: #c2410c;
  --accent-soft: #ffedd5;
  --buy: #15803d;
  --buy-bg: #dcfce7;
  --buy-text: #166534;
  --sell: #b91c1c;
  --sell-bg: #fee2e2;
  --sell-text: #991b1b;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Ramar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 4px;
  min-height: calc(56px + var(--safe-top));
  padding: var(--safe-top) 16px 0;
  background: var(--brand); color: #fff;
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; margin-left: -10px;
  border: 0; border-radius: 22px; background: transparent; color: #fff;
}
.back[hidden] { display: none; }
main { padding: 12px 16px calc(96px + var(--safe-bottom)); max-width: 720px; margin: 0 auto; outline: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  padding-bottom: var(--safe-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.tabbar[hidden] { display: none; }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 60px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active { color: var(--accent); }
.tabbar a.active svg { stroke-width: 2.4; }

/* ---------- Byggstenar ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.muted { color: var(--muted); font-size: 13px; }
.small { color: var(--muted); font-size: 12px; }
.section { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 8px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.label { display: block; margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--soft); }
.empty { color: var(--muted); text-align: center; padding: 28px 8px; }
.error { color: var(--sell-text); background: var(--sell-bg); padding: 12px 14px; border-radius: 12px; }
.hscroll { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }

.chip {
  flex: none; min-height: 38px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 19px;
  background: var(--surface); color: var(--soft); font-size: 13px; font-weight: 600;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.segment { display: flex; padding: 3px; border: 1px solid var(--border-strong); border-radius: 22px; background: var(--surface); }
.segment button { flex: 1; min-height: 38px; border: 0; border-radius: 19px; background: transparent; color: var(--soft); font-weight: 600; }
.segment button[aria-pressed="true"] { background: var(--accent); color: #fff; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 20px; border-radius: 24px;
  border: 1.5px solid var(--accent); background: var(--accent); color: #fff;
  font-weight: 700; text-decoration: none;
}
.btn.secondary { background: var(--surface); color: var(--accent); }
.btn.secondary[aria-pressed="true"] { background: var(--accent); color: #fff; }
.btn.small { min-height: 44px; padding: 0 14px; font-size: 13px; }
.btn.danger { border-color: var(--sell); background: var(--surface); color: var(--sell-text); }
.btn:disabled { opacity: .5; }

.input {
  width: 100%; height: 48px; padding: 0 14px;
  border: 1.5px solid var(--border-strong); border-radius: 12px; background: var(--surface);
}
.input:focus { border-color: var(--accent); outline: none; }
.searchbox { display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 6px 0 14px; border: 1.5px solid var(--accent); border-radius: 12px; background: var(--surface); }
.searchbox input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none; font-size: 16px; }
.searchbox svg { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.iconbtn { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: 22px; background: transparent; color: var(--soft); }
.iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.switchrow { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 0; }
.switchrow + .switchrow { border-top: 1px solid var(--border); }
.switch {
  position: relative; flex: none; width: 50px; height: 30px; padding: 0;
  border: 0; border-radius: 15px; background: var(--border-strong);
}
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 12px; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* ---------- Transaktionskort ---------- */
.trade { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; }
.trade:active { background: var(--raised); }
.trade .company { font-weight: 700; font-size: 15px; }
.trade .value { font-size: 20px; font-weight: 700; }
.compact .trade { gap: 3px; padding: 10px 14px; }
.compact .trade .value { font-size: 17px; }
.compact .trade .meta { display: none; }
.tag { flex: none; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--soft); font-size: 11px; font-weight: 700; letter-spacing: .4px; }
.badge { flex: none; padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; letter-spacing: .3px; }
.badge.buy { background: var(--buy-bg); color: var(--buy-text); }
.badge.sell { background: var(--sell-bg); color: var(--sell-text); }
.badge.other { background: var(--bg); color: var(--soft); border: 1px solid var(--border); }
.pill { flex: none; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.BUY { background: var(--accent); color: #fff; }
.pill.WATCH { background: var(--accent-soft); color: var(--accent); }
.pill.HOLD { background: var(--bg); color: var(--soft); }
.pill.SELL { background: var(--sell-bg); color: var(--sell-text); }
.up { color: var(--buy-text); }
.down { color: var(--sell-text); }

/* ---------- Mönster ---------- */
.ptitle { margin: 0; font-size: 17px; font-weight: 700; }
.pdesc { margin: 2px 0 8px; color: var(--muted); font-size: 13px; }
.pitem { display: block; padding: 10px 0; border-top: 1px solid var(--border); color: var(--text); text-decoration: none; }
.pitem .name { font-weight: 600; }
.count { flex: none; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; }
.bar { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.bar .lbl { width: 64px; flex: none; font-size: 13px; color: var(--soft); }
.bar .track { flex: 1; display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--bg); }
.bar .fill-buy { background: var(--buy); }
.bar .fill-sell { background: var(--sell); }
.bar .val { width: 116px; flex: none; text-align: right; font-size: 12px; font-weight: 600; color: var(--soft); }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat { padding: 12px; border-radius: 12px; background: var(--bg); }
.stat .v { font-size: 20px; font-weight: 700; margin-top: 2px; }

/* ---------- Övrigt ---------- */
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--soft); font-size: 13px; }
.cluster { padding: 14px 16px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--brand); }
.suggest { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin-top: 8px; }
.suggest a { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; color: var(--text); text-decoration: none; }
.suggest a + a { border-top: 1px solid var(--border); }
.chart { display: block; width: 100%; height: 140px; }
.fact { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.big { font-size: 32px; font-weight: 700; }
.live { display: inline-block; width: 8px; height: 8px; border-radius: 4px; background: var(--buy); }
.login { max-width: 380px; margin: 40px auto 0; }
.login h2 { margin: 0 0 4px; font-size: 24px; }
.disclaimer { margin-top: 24px; color: var(--muted); font-size: 12px; text-align: center; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(76px + var(--safe-bottom)); z-index: 20; padding: 12px 16px; border-radius: 12px; background: var(--text); color: #fff; font-weight: 600; text-align: center; }
.spinner { width: 28px; height: 28px; margin: 40px auto; border: 3px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } .switch::after { transition: none; } }

/* Grupperade affärer i flödet */
.trade.group { gap: 10px; }
.trade.group:active { background: var(--surface); }
.grouphead { display: flex; flex-direction: column; gap: 6px; color: inherit; text-decoration: none; }
.trade.group > .btn { align-self: flex-start; padding: 6px 12px; font-size: 13px; }
.stack.grouped .trade { background: var(--raised); }
[hidden] { display: none !important; }
.trade[role="link"], .grouphead[role="link"] { cursor: pointer; }
.personlink { color: var(--accent); font-weight: 600; text-decoration: none; padding: 2px 0; }
.personlink:active { text-decoration: underline; }

/* Logga, Om-sidan och juridiska länkar */
.topbar .brand { width: 28px; height: 28px; flex: none; margin-right: 8px; }
.login-logo { display: block; margin: 0 auto 4px; border-radius: 18px; }
.about { text-align: center; max-width: 420px; margin: 24px auto 0; }
.about-logo { display: block; margin: 0 auto; border-radius: 24px; }
.about h2 { margin: 8px 0 0; }
.legal-links { text-align: center; font-size: 13px; margin: 12px 0 0; color: var(--muted); }
.legal-links a { color: var(--accent); }

/* Nya affärer: kort orange markering som tonar bort */
.isnew { animation: ik-new 4s ease-out 1; border-color: #fb923c; box-shadow: 0 0 0 2px #fed7aa; }
@keyframes ik-new { 0% { background: #ffedd5; } 100% { background: var(--surface); } }
@media (prefers-reduced-motion: reduce) { .isnew { animation: none; } }

/* Långtryck + åtgärdsmeny */
.pressable { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(28, 25, 23, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; background: var(--surface); border-radius: 20px 20px 0 0; padding: 12px 12px calc(12px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 6px; }
.sheet-title { padding: 6px 8px 10px; font-weight: 700; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-btn { min-height: 48px; border: 0; border-radius: 12px; background: var(--raised); color: var(--text); font-size: 16px; font-weight: 600; text-align: left; padding: 0 16px; }
.sheet-btn.cancel { background: transparent; color: var(--accent); text-align: center; }
.tip { margin: 8px 2px 0; }

/* Signalregler */
.rule { display: flex; flex-direction: column; gap: 8px; }
.rule-label { font-weight: 700; }
.rules-bar { position: sticky; bottom: calc(64px + var(--safe-bottom)); margin-top: 16px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.08); display: flex; flex-direction: column; gap: 10px; }

/* Introduktion */
.onb { max-width: 460px; margin: 8px auto 0; display: flex; flex-direction: column; gap: 16px; }
.onb-body { display: flex; flex-direction: column; gap: 12px; }
.onb-body h2 { margin: 0; font-size: 22px; }
.onb-sub { margin-top: 10px !important; font-size: 18px !important; }
.onb-list { margin: 0; padding-left: 20px; line-height: 1.8; }
.onb-dots { display: flex; gap: 6px; justify-content: center; }
.onb-dots span { width: 8px; height: 8px; border-radius: 4px; background: var(--border); }
.onb-dots span.on { width: 22px; background: var(--brand); }
.onb-nav { gap: 10px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 56px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); text-align: left; font-size: 16px; }
.choice[aria-pressed="true"] { border-color: var(--accent); background: var(--raised); box-shadow: 0 0 0 1px var(--accent); }

/* Konto och nivåer */
.banner.upgrade { text-decoration: none; color: var(--text); background: var(--raised); border-color: #fdba74; margin-bottom: 10px; }
.banner.upgrade strong { color: var(--accent); }
.tierpill { padding: 3px 10px; border-radius: 12px; font-size: 13px; font-weight: 700; background: var(--raised); color: var(--accent); }
.tierpill.t-BRONZE { background: #fbe7d3; color: #9a3412; }
.tierpill.t-SILVER { background: #e7e5e4; color: #44403c; }
.tierpill.t-GOLD { background: #fef3c7; color: #92400e; }
.tiercard { display: flex; flex-direction: column; gap: 8px; }
.tiercard.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tiercard .price { font-weight: 700; }
.featlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.featlist li { display: flex; gap: 8px; align-items: baseline; }
.featlist .ok { color: #15803d; font-weight: 700; width: 14px; }
.featlist .no { color: var(--muted); width: 14px; }
.current-label { color: var(--accent); font-weight: 700; }
.locked { text-align: center; align-items: center; margin-top: 24px; }
.locked .lock-icon { font-size: 36px; }
.locked h2 { font-size: 19px; margin: 0; }
.tabbar a span { font-size: 11px; }
/* Sex flikar: tätare etiketter så att allt ryms på en rad */
.tabbar a { padding: 0 2px; }
.tabbar a span { font-size: 10.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Fristående knappar i en lista fyller bredden */
main .stack > button.btn, main > button.btn { width: 100%; }
/* Meny-knappen i tabbaren ser ut som flikarna */
.tabbar button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 60px; padding: 0 2px; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 11px; font-weight: 600; cursor: pointer;
}
.tabbar button.active { color: var(--accent); }
.tabbar button.active svg { stroke-width: 2.4; }
.tabbar a span, .tabbar button span { font-size: 11px; }
.sheet-btn.danger { color: #b91c1c; }
.sheet-title { white-space: normal; line-height: 1.4; }
.pricerow { color: var(--text); }
.pricerow strong { font-weight: 700; }
/* Köp-/säljkurs till höger på kortet, och senaste kurs på personsidan */
.tradeprice { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; text-align: right; flex: none; }
.tradeprice .tp-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.tradeprice .tp-value { font-size: 18px; font-weight: 800; color: var(--text); white-space: nowrap; }
.companyrow { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); padding: 12px 16px; }
.companyrow .company { font-weight: 700; }
.compact .tradeprice .tp-value { font-size: 16px; }

/* Bolagsprofil och nyckeltal */
.chip.static { cursor: default; background: var(--raised); border-color: #fed7aa; color: var(--text); }
.desc { margin: 0; line-height: 1.5; }
.desc.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.linkbtn { align-self: flex-start; border: 0; background: none; padding: 0; color: var(--accent); font-weight: 700; cursor: pointer; }
.kvgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 560px) { .kvgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kv { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.kv-v { font-size: 18px; font-weight: 800; margin-top: 2px; }

/* Insidereffekt */
.ichart { height: 170px; margin: 8px 0 4px; }
.itable { width: 100%; border-collapse: collapse; font-size: 14px; }
.itable th { text-align: right; font-weight: 600; font-size: 12px; color: var(--muted); padding: 4px 6px; }
.itable th:first-child, .itable td:first-child { text-align: left; padding-left: 0; }
.itable td { padding: 8px 6px; border-top: 1px solid var(--border); vertical-align: top; }
.itable td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.legend { display: flex; align-items: center; gap: 6px; }
.legend .sw { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-left: 8px; }
.legend .sw:first-child { margin-left: 0; }
.legend .sw.buy { background: var(--buy); }
.legend .sw.sell { background: var(--sell); }
.ievent { display: block; color: inherit; text-decoration: none; }
.ievent .badge { flex: none; }
.ievals { display: flex; flex-direction: column; align-items: flex-end; flex: none; }
.ievals .num { font-weight: 700; font-variant-numeric: tabular-nums; }
.upsell { align-items: flex-start; }

/* Kursgraf med insiderkryss (bolagssidan) */
.pchart .segment button { white-space: nowrap; padding-left: 10px; padding-right: 10px; }
.pwrap { display: flex; gap: 6px; align-items: stretch; margin-top: 8px; }
.pyax { display: flex; flex-direction: column; justify-content: space-between; min-width: 2.6em; text-align: right; color: var(--muted, #6b7280); }
.pplot { position: relative; flex: 1; min-width: 0; }
.pplot .chart { height: 160px; }
.pmark { position: absolute; transform: translate(-50%, -50%); width: 28px; height: 28px; padding: 0; border: 0; background: transparent; font-weight: 800; font-size: 15px; line-height: 28px; text-align: center; cursor: pointer; }
.pmark.buy { color: #15803D; }
.pmark.sell { color: #B91C1C; }
.pmark:focus-visible { outline: 2px solid currentColor; border-radius: 50%; }
.pxax { display: flex; justify-content: space-between; padding-left: calc(2.6em + 6px); color: var(--muted, #6b7280); margin-top: 2px; }
.pkey { font-weight: 800; }
.pkey.buy { color: #15803D; }
.pkey.sell { color: #B91C1C; }
.pinfo { margin-top: 6px; min-height: 1.4em; }
details.card > summary { cursor: pointer; list-style: revert; }
.pchart { scroll-margin-top: 72px; }
.pmark.focus { font-size: 20px; text-shadow: 0 0 0 currentColor; background: rgba(255, 255, 255, 0.85); border-radius: 50%; box-shadow: 0 0 0 2px currentColor; }
.pinfo .chip.static { cursor: default; }
/* Insiders i bolaget: vanliga länkar utan kort */
.insiders { display: flex; flex-direction: column; gap: 2px; }
.insiderlink { display: block; padding: 8px 2px; min-height: 44px; box-sizing: border-box; text-decoration: none; color: inherit; border-bottom: 1px solid var(--line, #e5e7eb); }
.insiderlink:last-child { border-bottom: 0; }
.insiderlink .name { color: var(--accent); font-weight: 600; }
/* Flödet: rapporteringsland */
.feedlabel { margin-top: 10px; margin-bottom: 4px; }
.feedcountries.muted { opacity: 0.55; }
/* Mönster: klickbara staplar */
.barbtn { width: 100%; border: 0; background: transparent; font: inherit; color: inherit; text-align: left; cursor: pointer; padding: 6px 0; min-height: 44px; }
.barbtn .fill-buy, .barbtn .fill-sell { cursor: pointer; }
.barbtn:focus-visible { outline: 2px solid var(--accent); border-radius: 8px; }
.version-line { text-align: center; margin: 4px 0 0; }
/* (?)-förklaringar */
.help {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; margin-left: 6px; padding: 0; vertical-align: middle;
  border: 1.5px solid var(--border-strong); border-radius: 50%; background: var(--surface);
  color: var(--muted); font: 700 12px/1 system-ui, sans-serif; cursor: pointer; flex: none;
  position: relative;
}
.help::after { content: ""; position: absolute; inset: -10px; } /* större tryckyta */
.help:hover, .help:focus-visible { color: var(--accent); border-color: var(--accent); }
th .help { margin-left: 4px; }
.help-sheet p { margin: 0 4px 12px; line-height: 1.5; color: var(--text); }
.warnline { color: #92400e; background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 6px 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.help-sheet .sheet-title { color: var(--text); font-size: 17px; }
