:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef3f0;
  --ink: #1d2420;
  --muted: #60706a;
  --line: #d8e0db;
  --accent: #1f7a5c;
  --accent-2: #b54436;
  --gold: #a46b12;
  --blue: #315f8c;
  --shadow: 0 18px 45px rgba(35, 48, 42, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand h1,
.section-head h2,
.panel h2,
.detail-view h2,
.empty-state h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 23px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.source-status {
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(340px, 0.95fr) minmax(430px, 1.25fr);
  gap: 18px;
  padding: 18px;
  min-height: 0;
}

.rules-panel {
  margin: 0 18px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.todo-section {
  margin: 0 18px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sidebar,
.change-list-panel,
.detail-panel {
  min-height: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.search,
.filter-group,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 8px 22px rgba(35, 48, 42, 0.05);
}

.search span,
.filter-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.search input,
.filter-group select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: #fbfcfb;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  min-height: 76px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 12px;
}

.stat strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.stat span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.panel h2 {
  font-size: 15px;
  margin-bottom: 12px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin-bottom: 0;
}

.panel-head span {
  min-width: 26px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.source-list {
  margin: 0;
}

.source-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.source-list dd {
  margin: 3px 0 12px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.sidebar .todo-list {
  display: grid;
  gap: 10px;
}

.todo-section .todo-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  padding: 14px;
}

.todo-count {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.todo-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfb;
}

.todo-item.is-done {
  background: #f1f5f2;
  opacity: 0.72;
}

.todo-item.is-done strong,
.todo-item.is-done p {
  text-decoration: line-through;
}

.todo-section .todo-item {
  min-height: 138px;
}

.todo-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.todo-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.todo-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.todo-priority {
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.todo-priority.priority-high {
  background: var(--accent-2);
}

.todo-priority.priority-medium {
  background: var(--gold);
}

.todo-priority.priority-low {
  background: var(--muted);
}

.todo-status {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.todo-item strong {
  display: block;
  font-size: 13px;
  line-height: 1.35;
}

.todo-item p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.todo-framework {
  display: inline-flex;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.todo-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.change-list-panel,
.detail-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.section-head {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.section-head h2 {
  font-size: 18px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.button-row {
  display: flex;
  gap: 8px;
}

.rules-actions {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.compact-select {
  display: grid;
  gap: 4px;
}

.compact-select span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.compact-select select {
  min-width: 230px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--ink);
}

.text-button {
  min-width: 52px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.text-button.wide {
  min-width: 82px;
}

.change-list {
  height: calc(100vh - 160px);
  overflow: auto;
  padding: 10px;
}

.change-card {
  width: 100%;
  min-height: 124px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.change-card:hover,
.change-card.is-active {
  border-color: rgba(31, 122, 92, 0.45);
  background: #f5faf7;
}

.card-topline {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.badge.status-forslag {
  background: var(--blue);
}

.badge.status-utreds {
  background: var(--gold);
}

.badge.status-beslutad {
  background: var(--accent);
}

.paragraph {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.title {
  font-size: 15px;
  line-height: 1.3;
}

.summary {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.detail-panel {
  position: relative;
  overflow: auto;
}

.empty-state {
  max-width: 440px;
  margin: 16vh auto 0;
  padding: 20px;
  text-align: center;
}

.empty-state p {
  color: var(--muted);
  line-height: 1.55;
}

.detail-view {
  padding: 20px;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.detail-header h2 {
  font-size: 24px;
}

.meta-line {
  margin: 8px 0 0;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.text-block,
.reason-block,
.notes-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfb;
}

.reason-block,
.notes-block {
  margin-top: 14px;
}

.text-block h3,
.reason-block h3,
.notes-block h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--muted);
}

.text-block p,
.reason-block p,
.notes-block p {
  margin: 0;
  line-height: 1.58;
}

.proposed {
  border-left: 4px solid var(--accent);
}

.current {
  border-left: 4px solid var(--accent-2);
}

.field-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.field {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

.empty-list {
  padding: 30px 12px;
  color: var(--muted);
  text-align: center;
}

.print-hint {
  color: var(--muted);
  font-size: 13px;
}

.rules-document {
  max-height: none;
  overflow: auto;
  padding: 22px 28px 34px;
  column-count: 1 !important;
  column-width: auto !important;
  columns: auto !important;
}

.section-review {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f8faf8;
  padding: 14px 18px;
}

.section-review:empty {
  display: none;
}

.section-review-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 12px;
}

.section-review-head h3 {
  margin: 0;
  font-size: 18px;
}

.section-review-head strong {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.section-chip-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.section-chip {
  min-width: 164px;
  max-width: 230px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
}

.section-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.section-chip strong {
  min-width: 28px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--accent);
  padding: 3px 7px;
  text-align: center;
  font-size: 12px;
}

.section-chip.is-active {
  border-color: var(--accent);
  background: #eef8f3;
}

.rule-document-section {
  max-width: 980px;
  margin: 0 auto 34px;
}

.rule-document-section h3 {
  break-after: avoid;
  margin: 0 0 14px;
  font-size: 20px;
}

.rule-subsection {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 22px;
}

.rule-subsection:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.rule-subsection-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 12px;
}

.rule-subsection-head h4 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.section-counts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.section-counts strong {
  color: var(--accent);
}

.rule-paragraph {
  break-inside: avoid;
  margin: 0 0 9px;
  line-height: 1.55;
}

.rule-paragraph.has-number {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.rule-paragraph.has-change {
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 7px 10px;
  background: #f4faf7;
}

.rule-number {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.55;
  white-space: nowrap;
}

.rule-text {
  min-width: 0;
}

.rule-list-block {
  display: block;
}

.rule-list-title {
  margin-bottom: 6px;
  font-weight: 800;
}

.rule-list-block ul {
  margin: 0;
  padding-left: 22px;
}

.rule-list-block li {
  margin: 2px 0;
  padding-left: 2px;
  line-height: 1.45;
}

.rule-paragraph.is-heading {
  margin-top: 18px;
  font-weight: 800;
  font-size: 17px;
}

.mark-new {
  color: #178044;
  font-weight: 700;
}

.formatted-change-text {
  white-space: pre-wrap;
}

.mark-old {
  background: #fff1a8;
  color: #483900;
}

.mark-removed {
  color: #b42318;
  font-weight: 700;
  text-decoration: line-through;
}

.rule-change {
  break-inside: avoid;
  margin: 8px 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfb;
}

.rule-change-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.rule-change p {
  margin: 6px 0;
  line-height: 1.45;
}

.change-text-row {
  margin: 6px 0;
  line-height: 1.45;
}

.youth-weight-classes {
  display: block;
  margin-top: 6px;
}

.youth-weight-title {
  margin-bottom: 8px;
  font-weight: 800;
}

.youth-weight-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.youth-weight-grid section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.youth-weight-grid h4 {
  margin: 0;
  padding: 8px 10px;
  background: #111915;
  color: #ffffff;
  font-size: 12px;
  line-height: 1.2;
  text-transform: uppercase;
}

.youth-weight-grid ul {
  margin: 0;
  padding: 7px 10px 9px 28px;
}

.youth-weight-grid li {
  margin: 3px 0;
  padding-left: 2px;
  color: #178044;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.42;
}

.youth-weight-grid p {
  margin: 0;
  padding: 7px 10px;
  border-top: 1px solid var(--line);
  color: #178044;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.42;
}

.change-explanation {
  color: var(--muted);
  font-size: 13px;
}

.print-document {
  display: none;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 250px minmax(320px, 1fr);
  }

  .detail-panel {
    grid-column: 1 / -1;
    min-height: 460px;
  }

  .change-list {
    height: 56vh;
  }
}

@media (max-width: 760px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .section-head,
  .rules-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-select select {
    width: 100%;
    min-width: 0;
  }

  .source-status {
    text-align: left;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .rules-panel {
    margin: 0 12px 12px;
  }

  .todo-section {
    margin: 0 12px 12px;
  }

  .change-list {
    height: auto;
    max-height: 58vh;
  }

  .detail-grid,
  .field-list {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    margin: 16mm;
  }

  body {
    background: #fff;
    color: #111;
  }

  .app-shell {
    display: none;
  }

  .print-document {
    display: block;
    font-family: "Segoe UI", Arial, sans-serif;
  }

  .print-cover {
    min-height: 92vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    page-break-after: always;
  }

  .print-cover h1 {
    margin: 0 0 10mm;
    font-size: 30pt;
    letter-spacing: 0;
  }

  .print-cover p {
    max-width: 150mm;
    margin: 0 0 8mm;
    font-size: 12pt;
    line-height: 1.5;
  }

  .legend {
    display: grid;
    gap: 5mm;
    max-width: 150mm;
    margin-top: 8mm;
  }

  .legend-item {
    display: grid;
    grid-template-columns: 42mm 1fr;
    gap: 6mm;
    align-items: start;
    font-size: 11pt;
  }

  .print-rules h2 {
    margin: 0 0 8mm;
    font-size: 20pt;
  }

  .print-rule {
    margin: 0 0 4mm;
    line-height: 1.45;
    page-break-inside: avoid;
  }

  .print-rule.is-heading {
    margin-top: 7mm;
    font-size: 14pt;
    font-weight: 800;
  }

  .rule-change {
    margin: 3mm 0 5mm;
    border: 0.3mm solid #cfd8d3;
    padding: 3mm;
    page-break-inside: avoid;
  }

  .rule-change-title {
    margin: 0 0 2mm;
    font-size: 9pt;
  }
}
