:root {
  --bg: #f7f7f5; --card: #ffffff; --text: #1d1d1b; --muted: #6b6b66; --line: #e3e2dd;
  --accent: #2459d6; --good: #1f7a3f; --warn: #a05a00; --bad: #b42318;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 16px; line-height: 1.5;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151514; --card: #1f1f1d; --text: #ecebe6; --muted: #a3a29b; --line: #34332f; --accent: #7aa2ff; --good: #5fc27e; --warn: #e0a547; --bad: #ff7a6b; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
.top { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; padding: .75rem 1rem; border-bottom: 1px solid var(--line); background: var(--card); }
.logo { letter-spacing: .08em; }
nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.right { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.tab { background: none; border: 0; padding: .4rem .7rem; border-radius: .4rem; color: var(--text); cursor: pointer; font: inherit; }
.tab.active { background: var(--bg); font-weight: 600; }
main { max-width: 64rem; margin: 0 auto; padding: 1rem; }
h1 { font-size: 1.4rem; margin: .5rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: .6rem; padding: 1rem; margin-bottom: 1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: .75rem; }
.kpi .label { color: var(--muted); font-size: .9rem; }
.kpi .value { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; font-size: .75rem; padding: .05rem .45rem; border-radius: 1rem; border: 1px solid currentColor; margin-left: .35rem; vertical-align: middle; }
.badge.measured { color: var(--good); }
.badge.indication { color: var(--warn); }
.badge.hypothesis { color: var(--muted); }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: .85rem; margin-top: .25rem; }
label { display: block; margin: .5rem 0 .2rem; font-weight: 550; }
input, select { font: inherit; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: .4rem; background: var(--card); color: var(--text); width: 100%; max-width: 24rem; }
button.primary, button.secondary { font: inherit; padding: .5rem 1rem; border-radius: .4rem; cursor: pointer; margin-top: .75rem; }
button.primary { background: var(--accent); color: #fff; border: 0; }
button.secondary { background: none; color: var(--accent); border: 1px solid var(--accent); }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: .4rem .3rem; border-bottom: 1px solid var(--line); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: .6rem; background: var(--accent); border-radius: .3rem; min-width: 2px; }
.notice { max-width: 64rem; margin: 1rem auto 0; padding: .75rem 1rem; border-radius: .5rem; background: var(--card); border: 1px solid var(--line); }
.notice.error { border-color: var(--bad); }
code, pre { font-family: ui-monospace, monospace; font-size: .85rem; }
pre { background: var(--bg); border: 1px solid var(--line); padding: .6rem; border-radius: .4rem; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
.row > div { flex: 1 1 12rem; }
@media (max-width: 40rem) { .right { margin-left: 0; width: 100%; } }
.chart { display: flex; align-items: flex-end; gap: 2px; height: 8rem; border-bottom: 1px solid var(--line); }
.chart .col { flex: 1 1 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.chart .colbar { width: 100%; background: var(--accent); border-radius: .2rem .2rem 0 0; min-height: 1px; }
.chart .dot { margin-bottom: 2px; flex: none; width: .45rem; height: .45rem; border-radius: 50%; background: var(--good); }
.chart-axis { display: flex; justify-content: space-between; font-size: .8rem; margin-top: .25rem; }
.alert { border-left: 3px solid var(--warn); padding: .4rem .7rem; background: var(--bg); border-radius: .3rem; }
tr.hl td { background: var(--bg); font-weight: 600; }
.scroll { overflow-x: auto; }
th { font-size: .85rem; color: var(--muted); font-weight: 550; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.health { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; padding: .6rem .8rem; border-radius: .4rem; background: var(--bg); border-left: 4px solid var(--good); }
.health.warning { border-left-color: var(--warn); }
.health.error { border-left-color: var(--bad); }
.health .dot { width: .7rem; height: .7rem; border-radius: 50%; background: var(--good); flex: none; }
.health.warning .dot { background: var(--warn); }
.health.error .dot { background: var(--bad); }
button:disabled { opacity: .6; cursor: default; }
/* Administrationspanelen */
main.wide { max-width: 80rem; }
.admin-badge { color: var(--bad); margin-left: 0; }
.pill { display: inline-block; font-size: .78rem; padding: .05rem .5rem; border-radius: 1rem; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { color: var(--good); border-color: currentColor; }
.pill.warning { color: var(--warn); border-color: currentColor; }
.pill.error { color: var(--bad); border-color: currentColor; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bg); }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.toolbar input, .toolbar select { width: auto; flex: 1 1 12rem; }
.findings { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.findings li { padding: .5rem .75rem; border-radius: .4rem; background: var(--bg); border-left: 4px solid var(--good); }
.findings li.warning { border-left-color: var(--warn); }
.findings li.error { border-left-color: var(--bad); }
.findings .act { display: block; color: var(--muted); font-size: .85rem; }
.kv td:first-child { color: var(--muted); width: 40%; }
textarea { font: inherit; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: .4rem; background: var(--card); color: var(--text); width: 100%; min-height: 4rem; }
.small { font-size: .85rem; }
[hidden] { display: none !important; }
.spark { display: flex; align-items: flex-end; gap: 1px; height: 2rem; margin-top: .4rem; }
.spark .colbar { flex: 1 1 0; background: var(--accent); border-radius: .15rem .15rem 0 0; min-height: 1px; opacity: .8; }
.kpi.goal { margin-bottom: 0; }
.badge.estimate { color: var(--accent); }
details summary { cursor: pointer; font-weight: 550; }

/* M15: förhandsvisning av annonsen */
.ad-preview { border: 1px solid var(--line); border-radius: .6rem; padding: .75rem; margin: .6rem 0; max-width: 26rem; background: var(--card, #fff); }
.ad-preview .ad-head { margin: .3rem 0; }
.ad-preview .ad-text { margin: .3rem 0 .5rem; white-space: pre-wrap; }
.ad-preview .ad-image { aspect-ratio: 1 / 1; max-height: 16rem; width: 100%; background: var(--bg); border-radius: .4rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; padding: 1rem; text-align: center; color: var(--muted, #666); }
.ad-preview .ad-image strong { font-size: 1.2rem; color: inherit; }
.ad-preview .ad-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: .5rem; }
.ad-preview .ad-cta { border: 1px solid var(--line); border-radius: .4rem; padding: .25rem .6rem; font-size: .85rem; white-space: nowrap; }
.ad-preview.google .ad-title { color: var(--accent); font-size: 1.05rem; margin: .2rem 0; }
.revise { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem; margin-top: .5rem; }
.ad-preview .ad-image.has-img { position: relative; padding: 0; overflow: hidden; }
.ad-preview .ad-image.has-img img { width: 100%; height: 100%; object-fit: cover; }
.ad-preview .ad-image .overlay { position: absolute; bottom: .6rem; left: .6rem; right: .6rem; background: rgba(0,0,0,.55); color: #fff; padding: .3rem .5rem; border-radius: .3rem; font-size: 1rem; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: .6rem; margin-top: .6rem; }
.media-item { margin: 0; }
.media-item img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: .4rem; border: 1px solid var(--line); background: var(--bg); }
.media-item figcaption { display: flex; justify-content: space-between; gap: .3rem; }
