:root {
  --bg: #f6f7f3;
  --surface: #ffffff;
  --ink: #1f2933;
  --muted: #607080;
  --line: #d9dfd6;
  --green: #2f6f5e;
  --green-dark: #214f44;
  --blue: #2c5f8a;
  --red: #a94442;
  --yellow: #c48a22;
  --shadow: 0 18px 45px rgba(32, 45, 42, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 32px clamp(18px, 4vw, 56px) 24px;
  border-bottom: 1px solid var(--line);
  background: #eef2ea;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green-dark);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.35rem;
}

.score-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 150px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--muted);
}

.score {
  color: var(--green);
  font-size: 2.15rem;
  font-weight: 800;
  line-height: 1;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 56px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 20px;
}

.search-box {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.search-box input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #e5ebe1;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.tab-button,
.icon-button {
  border: 0;
  cursor: pointer;
}

.tab-button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  background: transparent;
  color: var(--green-dark);
  font-weight: 750;
}

.tab-button.active {
  background: var(--surface);
  box-shadow: 0 3px 12px rgba(27, 51, 44, 0.12);
}

.view {
  display: none;
}

.active-view {
  display: grid;
  gap: 20px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1.2rem;
}

.metric p,
.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
}

.panel {
  padding: 18px;
}

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

.provision-list,
.bar-chart,
.problem-grid {
  display: grid;
  gap: 10px;
}

.provision-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 100px 120px 120px 120px;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.provision-row:hover,
.problem-card:hover {
  border-color: var(--green);
}

.tag {
  display: inline-flex;
  justify-content: center;
  width: fit-content;
  min-width: 80px;
  padding: 4px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
}

.tag.high {
  background: var(--green);
}

.tag.medium {
  background: var(--yellow);
}

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

.bar-row {
  display: grid;
  grid-template-columns: minmax(160px, 250px) 1fr 72px;
  gap: 12px;
  align-items: center;
}

.bar-track {
  height: 18px;
  overflow: hidden;
  background: #e8eee4;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--blue));
  border-radius: inherit;
}

.problem-grid {
  grid-template-columns: repeat(2, 1fr);
}

.problem-card {
  min-height: 150px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  text-align: left;
  cursor: pointer;
}

.problem-card h3 {
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.problem-card p {
  margin-bottom: 12px;
  color: var(--muted);
}

.linked {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.linked span {
  padding: 3px 7px;
  border-radius: 999px;
  background: #e8eee4;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 750;
}

.study-plan {
  display: grid;
  gap: 12px;
  padding-left: 22px;
  margin: 0;
}

.study-plan li {
  padding: 10px 0 10px 6px;
}

.study-plan strong,
.study-plan span {
  display: block;
}

.study-plan span {
  color: var(--muted);
}

.matrix {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.matrix-cell {
  min-height: 130px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.matrix-cell span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.high-complex {
  border-left: 6px solid var(--red);
}

.medium-complex {
  border-left: 6px solid var(--green);
}

.medium {
  border-left: 6px solid var(--yellow);
}

.lower {
  border-left: 6px solid var(--blue);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 20;
  width: min(560px, 100%);
  height: 100vh;
  padding: 24px;
  overflow: auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px rgba(31, 41, 51, 0.18);
  transform: translateX(105%);
  transition: transform 180ms ease;
}

.drawer.open {
  transform: translateX(0);
}

.icon-button {
  position: sticky;
  top: 0;
  float: right;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #eef2ea;
  color: var(--ink);
  font-size: 1.4rem;
}

.drawer h2 {
  margin-top: 28px;
}

.drawer-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.drawer-section h3 {
  margin-bottom: 8px;
  font-size: 0.95rem;
  text-transform: uppercase;
  color: var(--green-dark);
}

.drawer-section ul {
  margin: 0;
  padding-left: 18px;
}

.drawer-section li + li {
  margin-top: 8px;
}

.note-section {
  padding: 14px;
  border: 1px solid #cddbd0;
  border-radius: 8px;
  background: #f3f7f0;
}

.note-section h3 {
  margin-top: 0;
}

.note-section p {
  margin-bottom: 0;
}

.empty-state {
  padding: 16px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

@media (max-width: 860px) {
  .topbar,
  .toolbar,
  .panel-heading {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .summary-grid,
  .problem-grid,
  .matrix {
    grid-template-columns: 1fr;
  }

  .segmented {
    overflow-x: auto;
  }

  .provision-row {
    grid-template-columns: 1fr 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }
}
