/* Designsystemet, se docs/design-system.md. Ändra tokens här – inte i komponenterna. */

:root {
  --bg: #FFFDF8;
  --bg-soft: #FAF6ED;
  --bg-dark: #1C1C1C;
  --surface: #FFFFFF;

  --ink: #373737;
  --ink-strong: #2B2B2B;
  --ink-muted: #6E6A64;
  --ink-invert: #FFFDF8;

  --accent: #92574B;
  --accent-dark: #7C4A40;
  --accent-soft: #F0E4DF;

  --taupe: #937A6C;
  --taupe-light: #C7BFBC;
  --olive: #5D5637;
  --olive-dark: #27220D;

  --line: #E7DFD3;
  --line-strong: #C7BFBC;

  --radius: 2px;
  --radius-card: 4px;
  --shadow: 0 1px 2px rgba(39, 34, 13, .06), 0 8px 24px rgba(39, 34, 13, .06);

  --status-grey: #6E6A64;
  --status-brick: #8A4038;
  --status-amber: #9A7B3F;
  --status-olive: #5D5637;
  --status-terracotta: #92574B;
  --status-warmgrey: #8C8279;
  --status-green: #4F6B4A;
  --status-orange: #A5682B;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;
  --text-3xl: 2.75rem;
  --text-hero: clamp(2.5rem, 6vw, 3.75rem);

  --font-head: 'Raleway', Georgia, serif;
  --font-body: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1C1C1C;
    --bg-soft: #242320;
    --surface: #2B2B2B;
    --ink: #E8E2D8;
    --ink-strong: #FFFDF8;
    --ink-muted: #A9A298;
    --ink-invert: #1C1C1C;
    --accent: #C98474;
    --accent-dark: #DFA091;
    --accent-soft: #3A2B27;
    --line: #3A3733;
    --line-strong: #4E4A44;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

:root[data-theme="dark"] {
  --bg: #1C1C1C;
  --bg-soft: #242320;
  --surface: #2B2B2B;
  --ink: #E8E2D8;
  --ink-strong: #FFFDF8;
  --ink-muted: #A9A298;
  --ink-invert: #1C1C1C;
  --accent: #C98474;
  --accent-dark: #DFA091;
  --accent-soft: #3A2B27;
  --line: #3A3733;
  --line-strong: #4E4A44;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-head);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--ink-strong);
  margin: 0 0 .5em;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }

p { margin: 0 0 1em; max-width: 68ch; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-dark); }

:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
  border-radius: var(--radius);
}

/* --- Struktur --- */

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.wrap--narrow { max-width: 760px; }
@media (min-width: 768px) { .wrap { padding: 0 32px; } }

.section { padding: 56px 0; }
@media (min-width: 768px) { .section { padding: 96px 0; } }
.section--soft { background: var(--bg-soft); }

.eyebrow {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 12px;
}

.lead { font-size: var(--text-lg); color: var(--ink); }
.muted { color: var(--ink-muted); }
.small { font-size: var(--text-sm); }

.stack > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 32px; }

.grid { display: grid; gap: 24px; }
@media (min-width: 768px) {
  .grid--2 { grid-template-columns: repeat(2, 1fr); }
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
  .grid--sidebar { grid-template-columns: 2fr 1fr; align-items: start; }
}

/* --- Sidhuvud --- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
}

.site-header__brand {
  font-family: var(--font-head);
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--ink-strong);
  text-decoration: none;
}

.site-nav { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.site-nav a {
  font-size: var(--text-sm);
  color: var(--ink);
  text-decoration: none;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent); }

/* --- Hero --- */

.hero {
  background: var(--bg-dark);
  color: var(--ink-invert);
  padding: 96px 0;
  position: relative;
}
.hero h1 { color: #FFFDF8; font-size: var(--text-hero); max-width: 14ch; }
.hero .eyebrow { color: rgba(255, 253, 248, .66); }
.hero p { color: rgba(255, 253, 248, .86); max-width: 52ch; }

/* --- Knappar --- */

.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 14px 32px;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  background: var(--accent);
  color: #FFFDF8;
  transition: background-color .15s ease;
}
.btn:hover { background: var(--accent-dark); color: #FFFDF8; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn--secondary:hover { background: var(--bg-soft); color: var(--ink); }

.btn--small { padding: 8px 16px; letter-spacing: .08em; }
.btn--danger { background: var(--status-brick); }
.btn--danger:hover { background: #73352E; }

.btn-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* --- Kort --- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card__title { font-size: var(--text-xl); margin-bottom: 8px; }
.card--flat { box-shadow: none; }

/* --- Formulär --- */

.field { margin-bottom: 24px; }

.field label,
.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="number"],
.field input[type="password"],
.field input[type="date"],
.field input[type="time"],
.field input[type="month"],
.field input[type="search"],
.field select,
.field textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.field textarea { min-height: auto; line-height: 1.6; resize: vertical; }

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-dark);
  outline-offset: 1px;
}

.field .help {
  display: block;
  font-size: var(--text-sm);
  color: var(--ink-muted);
  margin-top: 6px;
  max-width: 62ch;
}

.field--checkbox { display: flex; gap: 12px; align-items: flex-start; }
.field--checkbox input { width: 20px; height: 20px; margin-top: 3px; flex: none; accent-color: var(--accent); }
.field--checkbox label {
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--ink);
  margin: 0;
}

.field--radio-group .choices { display: grid; gap: 10px; }
.field--radio-group .choice {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}
.field--radio-group .choice input { accent-color: var(--accent); width: 20px; height: 20px; }
.field--radio-group .choice label { margin: 0; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: var(--text-base); color: var(--ink); cursor: pointer; }
.field--radio-group .choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.field-error {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  color: var(--status-brick);
  font-size: var(--text-sm);
  margin-top: 6px;
}
.field-error::before { content: "!"; font-weight: 700; flex: none; }
.field--invalid input, .field--invalid select, .field--invalid textarea { border-color: var(--status-brick); }

.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* --- Etiketter --- */

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: .04em;
  white-space: nowrap;
  color: var(--status-grey);
  background: color-mix(in srgb, var(--status-grey) 12%, transparent);
}
.badge--grey { color: var(--status-grey); background: color-mix(in srgb, var(--status-grey) 12%, transparent); }
.badge--brick { color: var(--status-brick); background: color-mix(in srgb, var(--status-brick) 12%, transparent); }
.badge--amber { color: var(--status-amber); background: color-mix(in srgb, var(--status-amber) 14%, transparent); }
.badge--olive { color: var(--status-olive); background: color-mix(in srgb, var(--status-olive) 14%, transparent); }
.badge--terracotta { color: var(--status-terracotta); background: color-mix(in srgb, var(--status-terracotta) 12%, transparent); }
.badge--warmgrey { color: var(--status-warmgrey); background: color-mix(in srgb, var(--status-warmgrey) 14%, transparent); }
.badge--green { color: var(--status-green); background: color-mix(in srgb, var(--status-green) 14%, transparent); }
.badge--orange { color: var(--status-orange); background: color-mix(in srgb, var(--status-orange) 14%, transparent); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge { filter: brightness(1.45); }
}

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--status-amber);
  margin-right: 6px;
  vertical-align: middle;
}
.dot--overdue { background: var(--status-brick); }

/* --- Meddelanden --- */

.flash {
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
  padding: 14px 18px;
  margin-bottom: 24px;
  border-radius: var(--radius);
}
.flash--success { border-color: var(--status-green); }
.flash--error { border-color: var(--status-brick); }

.notice {
  border: 1px solid var(--line);
  background: var(--accent-soft);
  padding: 16px 20px;
  border-radius: var(--radius-card);
}

/* --- Tabell --- */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
table.data th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--bg-soft); }
table.data a { text-decoration: none; font-weight: 500; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* --- Administrationen --- */

.admin-header {
  background: var(--bg-dark);
  color: var(--ink-invert);
  border-bottom: none;
}
.admin-header .site-header__brand,
.admin-header .site-nav a { color: rgba(255, 253, 248, .82); }
.admin-header .site-nav a:hover,
.admin-header .site-nav a[aria-current="page"] { color: #FFFDF8; }

.stat-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat {
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  padding: 20px 24px;
  text-decoration: none;
  display: block;
  color: inherit;
}
.stat:hover { border-color: var(--line-strong); color: inherit; }
.stat__value { display: block; font-family: var(--font-head); font-size: var(--text-2xl); line-height: 1; color: var(--ink-strong); }
.stat__label { display: block; font-size: var(--text-xs); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-muted); margin-top: 8px; }
.stat--alert .stat__value { color: var(--accent); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.tabs a {
  padding: 12px 18px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .count { font-variant-numeric: tabular-nums; opacity: .7; }

.filters {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
  margin-bottom: 24px;
}
.filters .field { margin-bottom: 0; }

.detail-grid { display: grid; gap: 8px 24px; grid-template-columns: max-content 1fr; font-size: var(--text-sm); }
.detail-grid dt { color: var(--ink-muted); }
.detail-grid dd { margin: 0; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  padding: 0 0 20px 24px;
  border-left: 1px solid var(--line);
  font-size: var(--text-sm);
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -5px; top: 6px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline time { color: var(--ink-muted); }

.email-preview {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 24px;
  white-space: pre-wrap;
  font-size: var(--text-sm);
  line-height: 1.7;
}

.thumbs { display: flex; gap: 12px; flex-wrap: wrap; }
.thumbs img {
  width: 120px;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; }
.steps li { counter-increment: step; position: relative; padding-left: 44px; margin-bottom: 24px; }
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: -2px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: 600;
}
.steps h3 { font-size: var(--text-lg); margin-bottom: 4px; }

.progress { list-style: none; margin: 0; padding: 0; }
.progress li {
  display: flex; gap: 12px; align-items: baseline;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.progress li:last-child { border-bottom: none; }
.progress li[data-state="done"] { color: var(--ink-muted); }
.progress li[data-state="current"] { color: var(--accent); font-weight: 600; }
.progress li[data-state="todo"] { color: var(--taupe-light); }

.site-footer {
  background: var(--bg-dark);
  color: rgba(255, 253, 248, .7);
  padding: 48px 0;
  font-size: var(--text-sm);
  margin-top: 96px;
}
.site-footer a { color: rgba(255, 253, 248, .9); }
.site-footer h3 { color: #FFFDF8; font-size: var(--text-base); }

.pagination { display: flex; gap: 8px; align-items: center; margin-top: 24px; justify-content: center; }
.pagination a, .pagination span {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  text-decoration: none;
}
.pagination [aria-current="page"] { background: var(--accent); color: #FFFDF8; border-color: var(--accent); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .site-header, .site-footer, .btn, .tabs, .filters { display: none !important; }
  body { background: #fff; color: #000; }
}
