/* ---------- kort ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 22px 24px; }
.card-title { font-family: var(--font-head); font-size: 18px; line-height: 26px; font-weight: 500; }

/* SectionHeader */
.eyebrow { font-size: 12.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--accent-text); font-weight: 600; margin-bottom: 8px; }
.sh h2 { max-width: 30ch; }
.sh .lead { margin-top: 10px; max-width: 70ch; color: var(--text-muted); font-size: 17px; line-height: 1.6; }

/* NextStepCard */
.next { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 24px; }
.next .eyebrow { margin-bottom: 4px; }
.next h4 { margin-bottom: 2px; }
.next p { color: var(--text-muted); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  min-height: 44px; padding: 10px 20px; border-radius: var(--radius-btn); font-weight: 600; font-size: 15px;
  text-decoration: none; cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--text-muted); }
.btn svg { width: 18px; height: 18px; stroke: currentColor; }

/* KpiCard */
.kpi { display: flex; flex-direction: column; gap: 6px; min-height: 100%; }
.kpi-label { font-size: 14.5px; font-weight: 500; color: var(--text); display: flex; justify-content: space-between; gap: 8px; }
.kpi-value { font-family: var(--font-head); font-size: 36px; line-height: 40px; font-weight: 500; font-variant-numeric: tabular-nums; margin-top: 6px; }
.kpi-value .unit { font-size: 22px; margin-left: 2px; }
.kpi-value.na { font-size: 22px; line-height: 40px; color: var(--text-muted); }
.kpi-note { font-size: 13.5px; line-height: 1.55; color: var(--text-muted); margin-top: 4px; }
.delta { font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; }
.delta.good { color: var(--positive); }
.delta.bad { color: var(--negative); }
.delta.flat { color: var(--neutral); }
.delta .vs { color: var(--text-muted); font-weight: 400; }
.foot-note { font-size: 13px; color: var(--text-muted); margin-top: 12px; }

/* Förklaring (?) */
.help-wrap { flex: none; }
.kpi, .card { position: relative; }
.help-btn { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); font: 600 13px var(--font-body); cursor: pointer; display: grid; place-items: center; padding: 0; }
.help-btn:hover, .help-btn[aria-expanded="true"] { border-color: var(--text-muted); color: var(--text); }
.help-pop { position: absolute; left: 12px; right: 12px; top: 52px; z-index: 5; background: var(--text); color: var(--bg); font-size: 13.5px; line-height: 1.5; font-weight: 400; padding: 10px 12px; border-radius: 10px; box-shadow: var(--shadow-card); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); white-space: nowrap; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--neutral); }
.badge.yes::before, .badge.done::before { background: var(--positive); }
.badge.partial::before, .badge.measuring::before, .badge.progress::before { background: var(--accent); }
.badge.worse::before { background: var(--negative); }
.badge.open::before { background: var(--accent); }
.badge.none::before { display: none; }
.cat { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; color: var(--text-muted); }

/* Tabs */
.tabs { display: flex; gap: 4px; background: var(--surface-2); border-radius: 12px; padding: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: transparent; padding: 9px 14px; border-radius: 9px; cursor: pointer; font-weight: 500; font-size: 14.5px; color: var(--text-muted); white-space: nowrap; display: inline-flex; gap: 8px; align-items: center; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-card); }
.tab .count { font-size: 12px; background: var(--bg); border-radius: 999px; padding: 1px 8px; color: var(--text-muted); }
.tab[aria-selected="true"] .count { background: var(--accent-soft); color: var(--accent-text); }

/* Disclosure */
details.disc { border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
details.disc > summary { list-style: none; cursor: pointer; padding: 16px 22px; font-weight: 500; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
details.disc > summary::-webkit-details-marker { display: none; }
details.disc > summary::after { content: ''; width: 9px; height: 9px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-right: 4px; transition: transform .15s; }
details.disc[open] > summary::after { transform: rotate(-135deg); }
details.disc > .disc-body { padding: 0 22px 20px; }
details.inline > summary { list-style: none; cursor: pointer; color: var(--accent-text); font-weight: 500; font-size: 14.5px; display: inline-flex; gap: 6px; align-items: center; margin-top: 10px; }
details.inline > summary::-webkit-details-marker { display: none; }
details.inline > summary::before { content: '+'; font-weight: 600; }
details.inline[open] > summary::before { content: '−'; }

/* Tabeller */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14.5px; font-variant-numeric: tabular-nums; }
table.data th { text-align: left; font-weight: 500; color: var(--text-muted); font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.data td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data .r { text-align: right; white-space: nowrap; }

/* Diagram */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--chart-grid); }
.chart .axis text { fill: var(--text-muted); font-size: 12px; font-family: var(--font-body); }
.chart .s-main { stroke: var(--accent); fill: none; stroke-width: 2.5; stroke-linejoin: round; }
.chart .s-main-area { fill: var(--accent); opacity: .12; }
.chart .s-ctx { stroke: var(--chart-context); fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .s-ctx.dash { stroke-dasharray: 5 4; }
.chart .marker line { stroke: var(--text-muted); stroke-dasharray: 3 3; }
.chart .marker circle { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .vline { stroke: var(--text); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .hover-line { stroke: var(--text-muted); stroke-width: 1; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart-tip { position: absolute; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12.5px; line-height: 1.5; padding: 7px 10px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -110%); font-variant-numeric: tabular-nums; z-index: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13.5px; color: var(--text-muted); margin: 4px 0 10px; }
.legend i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 7px; background: var(--accent); }
.legend i.ctx { background: var(--chart-context); }
.legend i.ctx.dash { background: repeating-linear-gradient(90deg, var(--chart-context) 0 5px, transparent 5px 9px); }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }

/* Lista med punkter (Att förbättra) */
.issue { display: grid; gap: 10px; }
.issue-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.issue p.expl { color: var(--text); }
.issue .rec { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; font-size: 15px; }
.issue .rec b { font-weight: 600; }
.metrics { display: flex; flex-wrap: wrap; gap: 8px; }
.metric { font-size: 13px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px; font-variant-numeric: tabular-nums; }
.url-list { margin: 6px 0 0; padding-left: 18px; font-size: 14px; color: var(--text-muted); columns: 2; column-gap: 28px; }
.url-list li { break-inside: avoid; }
.count-card { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--text); cursor: pointer; text-align: left; font: inherit; }
.count-card .n { font-family: var(--font-head); font-size: 32px; line-height: 38px; font-variant-numeric: tabular-nums; }
.count-card:hover { border-color: var(--text-muted); }
.count-card.kpi { cursor: default; gap: 6px; }
.count-card.kpi:hover { border-color: var(--border); }
.link-btn { background: none; border: 0; padding: 0; margin-top: 4px; font: inherit; font-size: 14.5px; font-weight: 600; color: var(--accent-text); cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }
.trend { font-size: 14px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.trend.bad { color: var(--negative); }
.trend.good { color: var(--positive); }
.issue .rec-label { display: block; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); font-weight: 600; margin-bottom: 3px; }

/* Förfrågningar */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; font-weight: 500; }
.lead-won { text-align: right; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; }
.lead-won b { font-family: var(--font-head); font-size: 24px; color: var(--text); letter-spacing: 0; margin-right: 4px; }
.lead-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; }
.lead-list li { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--border); font-size: 14.5px; }
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; }
.bar-list li { display: grid; grid-template-columns: minmax(150px, 1.2fr) 3fr 3.5ch; align-items: center; gap: 14px; padding: 9px 0; font-size: 14.5px; }
.bar-list li + li { border-top: 1px solid var(--border); }
.bar-list .bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-list .bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.bar-list b { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .bar-list li { grid-template-columns: 1fr 3.5ch; } .bar-list .bar { grid-column: 1 / -1; grid-row: 2; } }

/* Markera förfrågningar */
.mark-count { margin-bottom: 6px; }
.mark-list { list-style: none; margin: 0; padding: 0; }
.mark-list li { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; padding: 12px 0; }
.mark-list li + li { border-top: 1px solid var(--border); }
.mark-when { display: grid; }
.mark-when b { font-weight: 500; font-variant-numeric: tabular-nums; }
.mark-list li.is-spam .mark-when { color: var(--text-muted); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { min-height: 40px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 14px; font-weight: 500; cursor: pointer; }
.seg button:hover { border-color: var(--text-muted); }
.seg button[aria-pressed="true"]::before { content: '✓ '; }
.seg button[aria-pressed="true"][data-mark="won"] { background: var(--positive); border-color: var(--positive); color: var(--bg); }
.seg button[aria-pressed="true"][data-mark="lost"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.seg button[aria-pressed="true"][data-mark="spam"] { background: var(--surface-2); border-color: var(--text-muted); }
.seg button:disabled { cursor: progress; opacity: .75; }
@media (max-width: 560px) { .seg { width: 100%; } .seg button { flex: 1 1 0; padding: 7px 8px; } }

/* Inloggning */
.login { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 18px; padding: 32px 16px; }
.login-card { width: 100%; max-width: 440px; padding: 32px; }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; font-family: var(--font-head); font-size: 19px; font-weight: 500; }
.login-brand b { color: var(--accent); font-weight: 500; }
.login h1 { font-size: 30px; }
.login h1:focus { outline: none; }
.login-lead, .login-sent { margin-top: 8px; color: var(--text-muted); }
.login .notice { margin: 18px 0 0; }
.login form .btn { width: 100%; margin-top: 16px; }
.login-card > .btn { margin-top: 22px; }
.login-help { margin-top: 16px; }
.login-links { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 6px; }
.login-foot { max-width: 440px; text-align: center; }
.field { display: grid; gap: 6px; margin-top: 22px; }
.field label { font-weight: 500; font-size: 14.5px; }
.input { width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: 400 16px var(--font-body); }
.input:hover { border-color: var(--text-muted); }
.input.code { font-size: 22px; letter-spacing: .25em; font-variant-numeric: tabular-nums; }
.form-msg { margin-top: 12px; font-size: 14.5px; color: var(--negative); }
.form-msg:empty { display: none; }
.btn:disabled { opacity: .65; cursor: progress; }
.btn-sm { min-height: 44px; padding: 8px 14px; font-size: 14px; }
@media (max-width: 767px) { .login-card { padding: 24px 20px; } }

/* Anslutningar */
.conn .issue-top h4 { margin: 0; }
.conn dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 14px 0 0; font-size: 14px; }
.conn dt { color: var(--text-muted); }
.conn dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; }
.plain-list { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 8px; color: var(--text-muted); max-width: 72ch; }

/* Tidslinje */
.timeline { position: relative; list-style: none; margin: 0; padding: 0 0 0 30px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.timeline > li { position: relative; }
.timeline > li + li { margin-top: 18px; }
.timeline > li::before { content: ''; position: absolute; left: -28px; top: 26px; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 3px solid var(--bg); }
.tl-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 13.5px; color: var(--text-muted); }
.tl-card h4 { margin: 8px 0 6px; }
.steps { margin: 10px 0 0; padding-left: 20px; }
.steps li + li { margin-top: 4px; }

/* Resultat */
.hero { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; }
.hero .big { font-family: var(--font-head); font-size: clamp(44px, 6vw, 64px); line-height: 1; font-variant-numeric: tabular-nums; text-align: right; }
.hero .big small { display: block; font-family: var(--font-body); font-size: 13.5px; color: var(--text-muted); margin-top: 8px; }
.list-rows { display: grid; }
.list-row { display: grid; grid-template-columns: 110px 1fr auto auto; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.list-row:last-child { border-bottom: 0; }
.list-row:hover .t { text-decoration: underline; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* AI */
.prompt-row { display: grid; grid-template-columns: 1fr repeat(3, minmax(110px, 150px)); gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.prompt-row:last-child { border-bottom: 0; }
.prompt-row.head { font-size: 13px; color: var(--text-muted); padding-top: 0; }
.ai-cell { font-size: 13.5px; display: inline-flex; align-items: center; gap: 7px; }
.ai-cell::before { content: ''; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--neutral); flex: none; }
.ai-cell.cited::before { background: var(--positive); border-color: var(--positive); }
.ai-cell.mentioned::before { background: var(--accent); border-color: var(--accent); }
.ai-cell.noanswer { color: var(--text-muted); }
.ai-cell.noanswer::before { border-style: dashed; }

/* Tillstånd */
.notice { background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: 12px; padding: 12px 16px; font-size: 14.5px; margin-bottom: 22px; }
.empty { text-align: left; padding: 28px 24px; }
.empty h4 { margin-bottom: 4px; }
.empty p { color: var(--text-muted); }
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: skel 1.4s ease infinite; border-radius: 8px; }
@keyframes skel { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skel-line { height: 14px; margin: 10px 0; }
.skel-h { height: 34px; width: 55%; margin: 10px 0 16px; }
.skel-card { height: 150px; border-radius: var(--radius-card); }
.select { appearance: none; border: 1px solid var(--border); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235c5c5c' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 14px center; border-radius: 10px; padding: 10px 40px 10px 14px; font: 500 15px var(--font-body); color: var(--text); min-height: 44px; }

@media (max-width: 767px) {
  .next { flex-direction: column; align-items: stretch; }
  .next .btn { width: 100%; }
  .hero { grid-template-columns: 1fr; }
  .hero .big { text-align: left; }
  .list-row { grid-template-columns: 1fr auto; }
  .list-row .d { grid-column: 1 / -1; font-size: 13px; color: var(--text-muted); }
  .list-row .chg { display: none; }
  .prompt-row { grid-template-columns: 1fr; gap: 6px; }
  .prompt-row.head { display: none; }
  .url-list { columns: 1; }
  .horizons { grid-template-columns: 1fr; }
  .card { padding: 18px; }
}

/* Ämnen och sökord */
.topic-name { font-weight: 500; }
.topic-ex { display: block; font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.topic-pages { display: block; font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.topic-pages a { font-weight: 500; }
.tbl-note { font-size: 13px; color: var(--text-muted); margin: 0 0 10px; }
.kw-list { display: grid; gap: 8px; margin-top: 10px; }
.kw-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.kw-row:last-child { border-bottom: 0; }
.horizons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.horizon { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.horizon b { display: block; font-family: var(--font-head); font-size: 20px; font-weight: 500; margin: 2px 0; font-variant-numeric: tabular-nums; }
.horizon .muted { font-size: 12.5px; }
.page-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--text-muted); }
.page-meta a { font-weight: 500; }
.more-btn { margin-top: 14px; }
.ai-detail { margin-top: 10px; display: grid; gap: 10px; }
.ai-quote { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; font-size: 14.5px; }
.ai-quote .who { font-size: 12.5px; color: var(--text-muted); font-weight: 600; display: block; margin-bottom: 2px; }
.prompt-row details.inline { grid-column: 1 / -1; margin-top: -4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-s { font-size: 13px; border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; background: var(--bg); font-variant-numeric: tabular-nums; }
.chip-s.own { border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

/* ---------- utskrift ---------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --shadow-card: none; }
  body { font-size: 11.5pt; }
  .sidebar, .topbar, .mobile-bar, .scrim, .next .btn, .tabs, .chart-tip, .notice.stale { display: none !important; }
  .shell, .shell.collapsed { display: block; }
  .content { padding: 0; max-width: none; }
  .card, details.disc { break-inside: avoid; box-shadow: none; }
  details > summary { display: none !important; }
  details > *:not(summary) { display: block !important; }
  .tab-panel[hidden] { display: block !important; }
  a { color: inherit; text-decoration: none; }
}
