:root {
  --canvas: #f6f5f0;
  --panel: #ffffff;
  --panel-soft: #fdfbf5;
  --ink: #172126;
  --muted: #607078;
  --line: #d9ddd8;
  --teal: #2b8791;
  --teal-dark: #155d6d;
  --forest: #2d6b54;
  --ruby: #b33a4c;
  --coral: #d56b5d;
  --amber: #bd8b2f;
  --blue: #1f5f88;
  --violet: #6f5a95;
  --shadow: 0 16px 34px rgba(31, 45, 51, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(21, 93, 109, 0.04) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(180deg, rgba(179, 58, 76, 0.035) 1px, transparent 1px) 0 0 / 34px 34px,
    var(--canvas);
  font-family: "Aptos", "Segoe UI", Tahoma, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: rgba(253, 251, 245, 0.92);
  backdrop-filter: blur(12px);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid #16324f;
  border-radius: var(--radius);
  color: #fdfbf5;
  background: #16324f;
  font-size: 13px;
  font-weight: 800;
}

.brand-name {
  font-weight: 800;
  line-height: 1.1;
}

.brand-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  width: 100%;
  min-height: 38px;
  padding: 9px 12px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: #39484f;
  background: transparent;
  text-align: left;
  font-size: 14px;
}

.nav-item:hover {
  background: rgba(43, 135, 145, 0.08);
}

.nav-item.is-active {
  border-left-color: #37b08d;
  color: var(--ink);
  background: rgba(43, 135, 145, 0.12);
  font-weight: 700;
}

.version-pill {
  margin-top: auto;
  width: fit-content;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: #fff;
  font-size: 12px;
}

.workspace {
  min-width: 0;
  padding: 26px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

h3 {
  margin-bottom: 8px;
  font-size: 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

#fileInput {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.button,
.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #16324f;
  border-radius: var(--radius);
  color: #fff;
  background: #16324f;
  font-weight: 700;
  text-decoration: none;
}

.upload-button span {
  margin-right: 6px;
  font-size: 18px;
  line-height: 1;
}

.button.secondary {
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}

.button.ghost {
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

.status-panel {
  min-height: 0;
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #d4d0c0;
  border-radius: var(--radius);
  background: #fff9e8;
  color: #5e4a19;
  font-size: 13px;
}

.notice.error {
  border-color: #efc4c4;
  background: #fff0f0;
  color: #7a1f28;
}

.view-root {
  display: grid;
  gap: 18px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  min-height: 102px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-value {
  margin-top: 8px;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}

.metric-sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 14px;
}

.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

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

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

.panel-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.chart {
  width: 100%;
  min-height: 260px;
}

.chart.short {
  min-height: 194px;
}

.chart.tall {
  min-height: 520px;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.donut {
  --yes: 0deg;
  width: 152px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--teal) 0deg var(--yes), var(--ruby) var(--yes) 360deg);
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 36px;
  border-radius: 50%;
  background: #fff;
}

.legend {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--teal);
}

.swatch.ruby {
  background: var(--ruby);
}

.swatch.blue {
  background: var(--blue);
}

.swatch.amber {
  background: var(--amber);
}

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 12px;
}

select {
  min-height: 38px;
  max-width: 100%;
  padding: 0 34px 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fff;
}

.matrix-wrap,
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 8px 10px;
  border-bottom: 1px solid #e6e9e4;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #fff;
  background: #16324f;
  font-size: 12px;
}

tr:last-child td {
  border-bottom: 0;
}

.tree-cell {
  min-width: 420px;
}

.tree-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-right: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.level-function td,
.level-category td {
  font-weight: 800;
}

.level-function td {
  background: #f3f7f5;
}

.level-category td {
  background: #fafaf5;
}

.indent-1 {
  padding-left: 26px;
}

.indent-2 {
  padding-left: 52px;
}

.heat {
  min-width: 86px;
  text-align: center;
  font-weight: 800;
}

.achieved {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  min-height: 24px;
  border-radius: 999px;
  background: #e8f3ed;
  color: var(--forest);
  font-size: 12px;
  font-weight: 800;
}

.achieved.no {
  background: #fbe8e8;
  color: var(--ruby);
}

.summary-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.summary-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #edf0ed;
  color: var(--muted);
  font-size: 13px;
}

.summary-list strong {
  color: var(--ink);
}

.empty-state {
  display: grid;
  min-height: 430px;
  place-items: center;
  padding: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  text-align: center;
  box-shadow: var(--shadow);
}

.empty-state h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.empty-state p {
  max-width: 520px;
  margin: 0 auto 18px;
  color: var(--muted);
}

.risk-critical,
.risk-high,
.risk-medium,
.risk-none {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.risk-critical {
  background: #ffe1de;
  color: #8d1f2c;
}

.risk-high {
  background: #ffeccd;
  color: #815600;
}

.risk-medium {
  background: #fff8cf;
  color: #685d00;
}

.risk-none {
  background: #e8f3ed;
  color: #2d6b54;
}

.svg-chart text {
  fill: var(--muted);
  font-size: 11px;
}

.svg-chart .axis {
  stroke: #d9ddd8;
  stroke-width: 1;
}

.svg-chart .label-dark {
  fill: var(--ink);
  font-weight: 800;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    gap: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav-item {
    border-left: 0;
    border-bottom: 3px solid transparent;
    border-radius: var(--radius) var(--radius) 0 0;
    text-align: center;
  }

  .nav-item.is-active {
    border-bottom-color: #37b08d;
  }

  .version-pill {
    display: none;
  }

  .topbar {
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
  }

  .kpi-grid,
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .workspace {
    padding: 16px;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .donut-wrap {
    grid-template-columns: 1fr;
  }
}
