:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #17181c;
  --muted: #61666f;
  --border: #e4e5e8;
  --accent: #4f5bd5;
  --accent-soft: #eceefc;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1013;
    --surface: #17191e;
    --text: #eceef2;
    --muted: #9aa0ab;
    --border: #282b33;
    --accent: #8f98f2;
    --accent-soft: #1d2140;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; min-height: 100vh;
}

a { color: var(--accent); text-underline-offset: 2px; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 20px; width: 100%; }

/* Topp */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; text-decoration: none; font-size: 1.05rem; }
.mark { width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 45%, #22c1a6)); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; font-size: .92rem; padding: 6px 10px; border-radius: 8px; }
.nav a:hover { color: var(--text); background: var(--accent-soft); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

main { flex: 1; padding: 48px 0 64px; }

/* Startsida */
.hero { padding: 32px 0 40px; max-width: 640px; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.4rem); line-height: 1.1; margin: 0 0 12px; letter-spacing: -0.02em; }
.hero .lead { font-size: 1.2rem; color: var(--muted); margin: 0 0 28px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-block; text-decoration: none; font-weight: 600;
  background: var(--accent); color: #fff; padding: 11px 20px; border-radius: 10px;
}
.btn:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface); }

.facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1px;
  background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  margin-bottom: 40px;
}
.facts div { background: var(--surface); padding: 18px 20px; display: flex; flex-direction: column; gap: 2px; }
.facts strong { font-size: .95rem; }
.facts span { color: var(--muted); font-size: .9rem; line-height: 1.5; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.card {
  display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card h2 { margin: 0; font-size: 1.15rem; }
.card p { margin: 0; color: var(--muted); font-size: .95rem; flex: 1; }
.card .more { color: var(--accent); font-weight: 600; font-size: .92rem; margin-top: 8px; }

/* Dokumentsidor */
.doc-head { max-width: 720px; margin-bottom: 36px; }
.doc-head h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); line-height: 1.15; margin: 0 0 10px; letter-spacing: -0.015em; }
.doc-head .lead { font-size: 1.12rem; color: var(--muted); margin: 0 0 10px; }
.doc-head .meta { font-size: .85rem; color: var(--muted); margin: 0; }

.doc-grid { display: grid; grid-template-columns: 220px minmax(0, 720px); gap: 56px; align-items: start; }
.toc { position: sticky; top: 84px; font-size: .9rem; }
.toc-title { text-transform: uppercase; letter-spacing: .07em; font-size: .75rem; color: var(--muted); font-weight: 700; margin: 0 0 10px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
.toc li a { display: block; padding: 5px 0 5px 14px; margin-left: -2px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; line-height: 1.35; }
.toc li a:hover { color: var(--text); border-left-color: var(--accent); }

.prose h2 { font-size: 1.3rem; margin: 2.4em 0 .6em; letter-spacing: -0.01em; }
.prose h2:first-child { margin-top: 0; }
.prose p { margin: 0 0 1em; }
.prose ul { padding-left: 1.2em; margin: 0 0 1em; }
.prose li { margin: .35em 0; }
.prose li::marker { color: var(--accent); }

.table-wrap { overflow-x: auto; margin: 0 0 1em; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td:first-child { font-weight: 600; white-space: nowrap; }

/* Fot */
.foot { border-top: 1px solid var(--border); background: var(--surface); }
.foot-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 20px; padding-bottom: 20px; font-size: .88rem; color: var(--muted); }
.foot-links { display: flex; gap: 16px; flex-wrap: wrap; }

@media (max-width: 820px) {
  main { padding-top: 28px; }
  .doc-grid { grid-template-columns: 1fr; gap: 24px; }
  .toc { position: static; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
  td:first-child { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card { transition: none; }
}

/* ---------------- Admin och installation ---------------- */
.admin main { padding: 32px 0 80px; }
.badge { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }
.inline { display: inline; margin: 0; }
button.link { background: none; border: 0; color: var(--muted); font: inherit; font-size: .92rem; padding: 6px 10px; cursor: pointer; border-radius: 8px; }
button.link:hover { color: var(--text); background: var(--accent-soft); }

.admin-title { font-size: 1.6rem; margin: 0 0 14px; letter-spacing: -0.01em; }
.title-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.title-row .admin-title { margin: 0; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; }
.panel h2 { font-size: 1.05rem; margin: 0 0 12px; }
.narrow { max-width: 420px; margin: 40px auto; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: #d64545; }
.flash { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 10px; padding: 10px 14px; margin-bottom: 18px; }
.notice { background: color-mix(in srgb, #e8b33a 15%, var(--surface)); border: 1px solid color-mix(in srgb, #e8b33a 40%, transparent); border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-size: .92rem; }
.notice a { margin-left: 4px; }

.btn { border: 0; cursor: pointer; font: inherit; font-weight: 600; }
.btn-small { padding: 7px 13px; font-size: .85rem; border-radius: 8px; }
.btn-danger { background: transparent; color: #d64545; border: 1px solid color-mix(in srgb, #d64545 40%, transparent); }

.rows { display: flex; flex-direction: column; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.row:last-child { border-bottom: 0; }
.row > div:first-child { display: flex; flex-direction: column; gap: 2px; }
.row-title { font-weight: 600; color: var(--text); text-decoration: none; }
a.row-title:hover { color: var(--accent); }
.row-actions { display: flex; gap: 8px; }
.row form { margin: 0; }
.links { line-height: 2; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; background: var(--accent-soft); padding: 1px 5px; border-radius: 5px; }

.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: .9rem; font-weight: 600; }
.form small { font-weight: 400; color: var(--muted); font-size: .8rem; }
.ph { font-weight: 400; font-family: ui-monospace, Menlo, monospace; font-size: .75rem; color: var(--muted); }
input, textarea, select {
  font: inherit; font-weight: 400; color: var(--text); width: 100%;
  background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px;
}
textarea { resize: vertical; line-height: 1.55; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86rem; }
input:focus, textarea:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.grid-fact { display: grid; grid-template-columns: minmax(140px, 1fr) 2fr; gap: 12px; margin-bottom: 10px; }
.form .check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: auto; }

.editor { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 20px; align-items: start; }
.help { font-size: .85rem; position: sticky; top: 84px; }
.help h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.help h3 + * { margin-top: 0; }
.help dl { margin: 0 0 12px; display: grid; gap: 6px; }
.help dt { margin: 0; }
.help dd { margin: 0 0 4px; color: var(--muted); }
.ph-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.ph-list li { display: flex; flex-direction: column; }
.ph-list .muted { font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sticky-save {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border); padding: 12px 0; margin-top: 4px;
}
.spacer { flex: 1; }
.preview { border: 2px dashed color-mix(in srgb, var(--accent) 50%, transparent); }
.preview-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); font-weight: 700; margin: 0 0 12px; }
.reset { margin-top: 14px; }

.reqs { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: .92rem; }
.reqs li { display: flex; gap: 8px; align-items: center; }
.reqs .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: #1f9d55; }
.reqs .bad .dot { background: #d64545; }
.pre { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-family: ui-monospace, Menlo, monospace; font-size: .82rem; white-space: pre-wrap; word-break: break-all; }

@media (max-width: 820px) {
  .editor { grid-template-columns: 1fr; }
  .help { position: static; }
  .grid-fact { grid-template-columns: 1fr; gap: 6px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
}

/* Ramar på sekundära knappar (måste ligga efter .btn { border: 0 }) */
.btn.btn-ghost { border: 1px solid var(--border); background: transparent; color: var(--text); }
.btn.btn-ghost:hover { background: var(--surface); filter: none; }
.btn.btn-danger { border: 1px solid color-mix(in srgb, #d64545 40%, transparent); }
