/* Layout: periodflikar överst, grafer över uppfyllelse, filterrad, utfällbar lista. Bara ljust tema. */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --ink: #18212d; --muted: #5a6676; --line: #dde2e9;
  --accent: #1d4e89; --accent-soft: #e8eff8; --on-accent: #ffffff;
  /* Statusfärger, samma i listan och i graferna: genomfört -> påbörjat är tre steg av
     samma blå (mörk = mer genomfört), röd = inte genomfört, grått = inte bedömt. */
  --st-genomfort: #104281; --st-delvis: #2a78d6; --st-paborjat: #86b6ef;
  --st-ej_paborjat: #e34948; --st-ej_genomfort: #e34948; --st-overgivet: #e34948;
  --st-ej_bedomt: #c3c2b7; --st-vallofte: #898781;
  --warn: #8a5a00; --ok: #1f6b3f; --del: #b23a3a; --ins: #1f6b3f;
  --font-display: "Open Sans", system-ui, sans-serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font-body); }
.wrap { max-width: 1040px; margin: 0 auto; padding: 28px 16px 64px; display: flex; flex-direction: column; gap: 18px; }
a { color: var(--accent); }
code { font-family: var(--font-mono); font-size: .92em; }

.head { display: flex; flex-direction: column; gap: 8px; }
.head-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.head-text { display: flex; flex-direction: column; gap: 6px; }
h1 { font: 700 clamp(30px, 6vw, 44px)/1.05 var(--font-display); letter-spacing: -.01em; margin: 0; }
.kicker { font: 500 12px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.lede { color: var(--muted); max-width: 64ch; margin: 0; }

.admin { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.admin input { font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); width: 180px; }
button, .btn { font: 600 13px var(--font-body); background: var(--accent); color: var(--on-accent); border: 0; border-radius: 6px; padding: 7px 12px; cursor: pointer; }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.periods { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.periods button { background: transparent; color: var(--muted); border-radius: 6px 6px 0 0; padding: 9px 14px; font: 700 15px var(--font-display); letter-spacing: .02em; border-bottom: 3px solid transparent; }
.periods button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.regering { margin: -8px 0 0; font-size: 13px; color: var(--muted); }

.uppfyllelse { display: flex; flex-direction: column; gap: 12px; }
.uppf-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 16px; flex-wrap: wrap; }
.uppf-head h2 { font: 700 22px var(--font-display); margin: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; }
.stats { display: flex; flex-direction: column; gap: 12px; transition: opacity .15s; }
.stats.laddar { opacity: .55; }

.viz { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.viz figcaption { margin-bottom: 8px; }
.viz h3 { font: 700 17px var(--font-display); margin: 0 0 2px; }
.viz-rad { display: grid; grid-template-columns: minmax(110px, 200px) 1fr 96px; gap: 12px; align-items: center; width: 100%; padding: 6px 4px; margin: 0 -4px; background: none; border: 0; border-radius: 6px; color: var(--ink); font: inherit; text-align: left; cursor: default; box-sizing: content-box; }
button.viz-rad { cursor: pointer; }
button.viz-rad:hover, .viz-rad:focus-visible { background: var(--accent-soft); }
.viz-etikett { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.viz-etikett strong { font-weight: 600; font-size: 14px; }
.viz-etikett .meta { overflow-wrap: anywhere; }
.viz-stapel { display: flex; gap: 2px; height: 20px; min-width: 0; }
.viz-stapel span { min-width: 2px; height: 100%; }
.viz-stapel span:last-child { border-radius: 0 4px 4px 0; }
.viz-rad:hover .viz-stapel span { opacity: .85; }
.viz-rad:hover .viz-stapel span:hover { opacity: 1; }
.viz-varde { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.viz-varde strong { font-size: 18px; font-weight: 600; }
.viz-axel { padding-top: 0; padding-bottom: 0; }
.viz-skala { position: relative; height: 16px; border-top: 1px solid var(--line); }
.viz-skala span { position: absolute; top: 2px; transform: translateX(-50%); font: 11px var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.viz-skala span:first-child { transform: none; }
.viz-skala span:last-child { transform: translateX(-100%); }
.viz-tabell { margin-top: 8px; font-size: 12px; }
.viz-tabell summary { cursor: pointer; color: var(--accent); width: max-content; }
.tabell-wrap { overflow-x: auto; margin-top: 6px; }
.viz-tabell table { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.viz-tabell th, .viz-tabell td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.viz-tabell th:first-child { text-align: left; white-space: normal; min-width: 120px; }
.viz-tabell tr:first-child th { font-weight: 600; color: var(--muted); vertical-align: bottom; white-space: normal; }

.tip { position: fixed; z-index: 10; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(24, 33, 45, .12); padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 3px; max-width: 280px; }
.tip[hidden] { display: none; }
.tip-rubrik { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.tip-rad { display: grid; grid-template-columns: 12px auto 1fr; gap: 6px; align-items: center; color: var(--muted); }
.tip-rad i { height: 3px; border-radius: 2px; }
.tip-rad strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-rad.aktiv { color: var(--ink); }
.tip-rad.aktiv i { height: 8px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input, .filters select { font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; min-width: 0; }
.filters input { flex: 1 1 220px; }
.filters select { flex: 0 1 auto; max-width: 100%; }
.export { font-size: 13px; margin-left: auto; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.chip { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 10px; color: var(--ink); cursor: pointer; font: inherit; font-size: 12px; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.chip b { font-variant-numeric: tabular-nums; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip.total { cursor: default; color: var(--muted); }

.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.row { border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 76px 1fr auto; gap: 12px; align-items: start; padding: 12px 14px; }
.row > summary::-webkit-details-marker { display: none; }
.row > summary:hover { background: var(--accent-soft); }
.parties { display: flex; flex-wrap: wrap; gap: 3px; }
.party { font: 700 11px/1 var(--font-display); letter-spacing: .04em; color: #fff; border-radius: 3px; padding: 4px 5px; min-width: 24px; text-align: center; }
.party.stod { opacity: .6; }
.title { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.title strong { font-weight: 600; }
.meta { font-size: 12px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; font: 500 11px/1 var(--font-mono); letter-spacing: .04em; text-transform: uppercase; color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px 5px 7px; white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); }
.detail { padding: 0 14px 16px 102px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.detail p { margin: 0; max-width: 72ch; }
.detail a { word-break: break-word; }
.label { font: 500 11px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.flags { display: flex; gap: 6px; flex-wrap: wrap; }
.flag { font-size: 11px; border-radius: 4px; padding: 2px 6px; background: var(--accent-soft); color: var(--ink); }
.flag.warn { background: transparent; border: 1px solid var(--warn); color: var(--warn); }
.flag.ok { background: transparent; border: 1px solid var(--ok); color: var(--ok); }
.log { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.log li { font-size: 13px; display: grid; grid-template-columns: 92px 1fr; gap: 10px; }
.log time { font: 12px var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }

.edit { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; padding-top: 10px; border-top: 1px dashed var(--line); }
.edit label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); min-width: 0; }
.edit select, .edit input, .edit textarea { font: inherit; font-size: 13px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0; width: 100%; }
.edit .wide { grid-column: 1 / -1; }
.edit .actions { display: flex; gap: 10px; align-items: center; grid-column: 1 / -1; }
.edit .msg { font-size: 12px; color: var(--muted); }
.edit .check { flex-direction: row; align-items: center; gap: 6px; }
.edit .check input { width: auto; }

.edit .label.wide { padding-top: 6px; }
.edit button.ghost { padding: 6px 12px; }
.partival { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.partival label { flex-direction: row; align-items: center; gap: 6px; }
.partival .party { flex: none; }
.detail > .redigera { align-self: flex-start; }

.list-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.nytt { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.nytt h2 { font: 700 20px var(--font-display); margin: 0 0 4px; }
.nytt .edit { border-top: 0; padding-top: 0; }

.historik { display: flex; flex-direction: column; gap: 6px; }
.log.hist li { grid-template-columns: 118px 1fr; }
.rev { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rev .kommentar { color: var(--muted); font-style: italic; }
.rev details summary { cursor: pointer; font-size: 12px; color: var(--accent); width: max-content; }
.diff { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; margin: 4px 0 0; font-size: 12px; }
.diff dt { color: var(--muted); }
.diff dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.diff del { color: var(--del); }
.diff ins { text-decoration: none; color: var(--ins); }
.rev .flag { font-size: 10px; vertical-align: 1px; }
.aterstall { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 2px; }
.aterstall input { font: inherit; font-size: 12px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; flex: 1 1 180px; min-width: 0; }
.aterstall .msg { font-size: 12px; color: var(--muted); }
button.liten { font-size: 12px; padding: 3px 8px; }

.andringar { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.andringar > summary { cursor: pointer; font: 700 15px var(--font-display); letter-spacing: .02em; }
.andringar #andringarLista { padding-top: 10px; max-height: 420px; overflow-y: auto; }

/* Redaktör: AI-sökning, utkast, publicering och radering */
.redaktor { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.redaktor[hidden], .edit [hidden] { display: none; }
.redaktor-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 16px; flex-wrap: wrap; }
.redaktor h2 { font: 700 20px var(--font-display); margin: 0; }
.redaktor > p { margin: 0; max-width: 72ch; }
.redaktor .edit.ai { border-top: 0; padding-top: 4px; }
.lageval { display: flex; gap: 16px; flex-wrap: wrap; }
.lageval label { font-size: 14px; color: var(--ink); }
.korningar { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.korningar li { font-size: 13px; display: grid; grid-template-columns: 118px 1fr; gap: 10px; }
.korningar time { font: 12px var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.korning.fel .fel { color: var(--del); }
.korning .varning { color: var(--warn); }
.redaktorval { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.redaktorval input { font: inherit; font-size: 13px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; flex: 1 1 200px; min-width: 0; }
.redaktorval .msg { font-size: 12px; color: var(--muted); }
button.fara { background: var(--del); color: var(--on-accent); }
button.ghost.fara { background: transparent; color: var(--del); }
.row.opublicerad > summary { background: repeating-linear-gradient(-45deg, transparent 0 10px, rgba(138, 90, 0, .05) 10px 20px); }
.flag.utkast { align-self: flex-start; font-size: 10px; }

.empty { padding: 28px 16px; color: var(--muted); text-align: center; }
.more { display: flex; justify-content: center; }
.foot { font-size: 12px; color: var(--muted); max-width: 76ch; }

@media (max-width: 620px) {
  .row > summary { grid-template-columns: 1fr; gap: 6px; }
  .row > summary .pill { justify-self: start; }
  .viz-rad { grid-template-columns: 1fr 64px; gap: 4px 10px; }
  .viz-etikett { grid-column: 1 / -1; }
  .viz-axel > span:first-child { display: none; }
  .detail { padding-left: 14px; }
  .export { margin-left: 0; }
  .log.hist li, .korningar li { grid-template-columns: 1fr; gap: 2px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
