:root {
  --bg: #f4f6f9;
  --paper: #ffffff;
  --text: #1d2736;
  --muted: #607089;
  --border: #dfe6ee;
  --green: #2f9e44;
  --green-soft: #eaf8ee;
  --red: #d93b3b;
  --red-soft: #fde9e9;
  --gray: #e9edf2;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
  padding: 24px;
}

.page-shell {
  max-width: 1100px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.8rem, 2vw, 2.5rem);
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

button {
  border: none;
  border-radius: 10px;
  padding: 0.8rem 1.2rem;
  font-size: 0.96rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

.primary-btn {
  background: #0c3b5f;
  color: white;
  box-shadow: 0 6px 16px rgba(12, 59, 95, 0.2);
}

.secondary-btn {
  background: #eef3f8;
  color: var(--text);
}

#document {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.document-header {
  display: grid;
  grid-template-columns: 1.3fr 2fr;
  gap: 24px;
  align-items: end;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.title-block h2 {
  margin: 0;
  font-size: clamp(1.7rem, 2vw, 2.3rem);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 90px;
  resize: vertical;
}

.selector-wrap {
  margin-bottom: 20px;
}

.legend {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 100px;
  background: #f7f9fb;
  border: 1px solid var(--border);
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.75rem;
  color: white;
}

.pill.green {
  background: var(--green);
}

.pill.red {
  background: var(--red);
}

.area-select-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.area-select-wrap label {
  color: var(--text);
  font-weight: 700;
}

.area-select-wrap select {
  min-width: 220px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  background: #fff;
  font: inherit;
  color: var(--text);
}

.period-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.period-tab {
  background: #eef3f8;
  color: var(--text);
  border: 1px solid var(--border);
}

.period-tab.active {
  background: #0c3b5f;
  color: white;
  border-color: #0c3b5f;
}

.matrix-wrap {
  overflow-x: auto;
  margin-bottom: 22px;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.matrix-table th,
.matrix-table td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  text-align: left;
  vertical-align: middle;
}

.matrix-table th:last-child,
.matrix-table td:last-child {
  border-right: none;
}

.matrix-table thead th {
  background: #f4f7fb;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.area-cell {
  font-weight: 700;
}

.level-cell {
  font-weight: 600;
  color: var(--text);
}

.option-cell {
  width: 150px;
}

.option-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  background: #f5f7fa;
  color: var(--text);
  font-weight: 700;
}

.option-btn.selected.green {
  background: linear-gradient(135deg, #dff7e7 0%, #b9efc9 100%);
  color: #176c2d;
  border-color: #3aab5b;
  box-shadow: inset 0 0 0 2px rgba(47, 158, 68, 0.18), 0 0 0 3px rgba(47, 158, 68, 0.08);
  font-weight: 800;
}

.option-btn.selected.red {
  background: linear-gradient(135deg, #fde9e9 0%, #f7c0c0 100%);
  color: #a02626;
  border-color: #cf4d4d;
  box-shadow: inset 0 0 0 2px rgba(217, 59, 59, 0.18), 0 0 0 3px rgba(217, 59, 59, 0.06);
  font-weight: 800;
}

.selected-path {
  font-weight: 800;
  min-width: 120px;
  padding: 0.7rem 0.8rem;
  border-radius: 0;
  background: transparent;
  border: none;
}

.selected-path.green {
  color: var(--green);
}

.selected-path.red {
  color: var(--red);
}

.questions-wrap,
.summary-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafbfc;
  padding: 18px 20px;
  margin-top: 18px;
}

.questions-wrap h3,
.summary-box h3 {
  margin: 0 0 14px;
  font-size: 1.05rem;
}

.questions-grid {
  display: grid;
  gap: 16px;
}

.question-item {
  display: grid;
  gap: 10px;
}

.question-item label {
  color: var(--text);
  font-weight: 700;
  font-size: 0.9rem;
}

.question-text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}

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

.score-btn {
  min-width: 56px;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f4f7fa;
  color: var(--text);
  font-weight: 700;
}

.score-btn[data-score="1"] { background: #fbe9e9; color: #b42318; border-color: #efb4b4; }
.score-btn[data-score="2"] { background: #ffeede; color: #b76b00; border-color: #f3c58a; }
.score-btn[data-score="3"] { background: #fff7d6; color: #8a6b00; border-color: #eddc8d; }
.score-btn[data-score="4"] { background: #eaf8ee; color: #2f9e44; border-color: #a8d9b0; }
.score-btn[data-score="5"] { background: #dff7e7; color: #1f7a32; border-color: #9dd0a8; }

.score-btn.active {
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.18), 0 0 0 3px rgba(12, 59, 95, 0.12);
  transform: translateY(-1px) scale(1.03);
  font-weight: 900;
  border-width: 2px;
}

.summary-box ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
}

.summary-box li + li {
  margin-top: 6px;
}

@media print {
  body {
    background: white;
    padding: 0;
  }

  .no-print {
    display: none !important;
  }

  #document {
    box-shadow: none;
    border: none;
    padding: 0;
    max-width: none;
    border-radius: 0;
  }

  .matrix-table {
    page-break-inside: avoid;
  }
}

@media (max-width: 720px) {
  body {
    padding: 14px;
  }

  #document {
    padding: 18px;
  }

  .document-header {
    grid-template-columns: 1fr;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }
}
