:root {
  color-scheme: light;
  --bg: #f7f8f4;
  --surface: #ffffff;
  --surface-soft: #edf4ef;
  --ink: #17201c;
  --muted: #637069;
  --line: #dbe2dc;
  --primary: #216e5b;
  --primary-strong: #174e42;
  --accent: #d28b2d;
  --danger: #b94738;
  --shadow: 0 18px 45px rgba(27, 42, 35, 0.08);
  --radius: 8px;
}

* {
  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",
    "Noto Sans SC", sans-serif;
  letter-spacing: 0;
  height: 100vh;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 82px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  z-index: 20;
  backdrop-filter: blur(12px);
}

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

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(23px, 2.5vw, 32px);
  line-height: 1.16;
}

h2 {
  font-size: 16px;
  line-height: 1.25;
}

.topbar-actions,
.panel-heading,
.tabs,
.two-col {
  display: flex;
  gap: 12px;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button {
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 10px 14px;
  min-height: 42px;
  cursor: pointer;
  font-weight: 700;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease;
}

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

.button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

.button.primary {
  background: var(--primary);
  color: #fff;
}

.button.primary:hover {
  background: var(--primary-strong);
}

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

.button.full {
  width: 100%;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.file-button input {
  display: none;
}

.workspace {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  gap: 14px;
  height: calc(100vh - 82px);
  padding: 12px 20px;
  overflow: hidden;
}

.sidebar,
.content {
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

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

.panel,
.report-card {
  padding: 14px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.status-box {
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid #d4e4d8;
  border-radius: 7px;
  padding: 10px;
  line-height: 1.55;
  font-size: 13px;
}

.status-box.compact {
  padding: 8px 10px;
  line-height: 1.45;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
textarea,
.text-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
}

select:focus,
textarea:focus,
.text-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(33, 110, 91, 0.14);
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

.check-list {
  display: grid;
  gap: 6px;
  max-height: 170px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.check-row input {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
}

.score-note {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.score-note strong {
  color: var(--ink);
}

.content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: hidden;
}

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

.metric {
  padding: 12px 14px;
}

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

.metric strong {
  display: block;
  font-size: clamp(21px, 1.8vw, 28px);
  line-height: 1.1;
}

.tabs {
  align-items: center;
  flex-wrap: wrap;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tab {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  min-height: 36px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
}

.tab.active {
  background: var(--primary);
  color: #fff;
}

.tab-stage {
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.tab-panel {
  display: none;
  height: 100%;
  min-height: 0;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.two-col {
  align-items: stretch;
  min-height: 0;
  height: 100%;
}

.two-col > * {
  flex: 1;
  min-width: 0;
}

.chart-panel {
  padding: 14px;
  min-height: 0;
  height: 100%;
}

.panel-heading {
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-heading span,
.muted {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

canvas {
  width: 100% !important;
  height: calc(100% - 42px);
  max-height: none;
}

.insight-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  flex: 0 0 auto;
}

.insight {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 84px;
}

.insight strong {
  display: block;
  margin-bottom: 6px;
}

.insight span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.table-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

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

.table-wrap.embedded {
  box-shadow: none;
  flex: 1;
  min-height: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

th {
  color: var(--muted);
  background: #fbfcfa;
  font-weight: 800;
}

td.positive {
  color: var(--primary);
  font-weight: 800;
}

td.negative {
  color: var(--danger);
  font-weight: 800;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.report-card {
  min-width: 0;
}

.full-height {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.report-body {
  color: var(--ink);
  line-height: 1.75;
  overflow: auto;
  min-height: 0;
}

.report-body h3,
.report-body h4,
.report-body h5 {
  margin: 0 0 12px;
  line-height: 1.35;
}

.report-body p {
  margin: 0 0 14px;
}

.report-body ul,
.report-body ol {
  margin: 0 0 14px 22px;
  padding: 0;
}

.report-body li {
  margin: 4px 0;
}

.report-body strong {
  font-weight: 800;
}

.report-body code {
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--surface-soft);
  font-size: 0.92em;
}

.icon-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--primary);
  padding: 6px 10px;
  cursor: pointer;
  font-weight: 700;
}

@media (max-width: 1100px) {
  body {
    overflow: auto;
    height: auto;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

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

  .tab-stage,
  .tab-panel,
  .two-col,
  .chart-panel,
  .table-card {
    height: auto;
  }
}

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

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .button {
    flex: 1;
  }

  .workspace {
    padding: 12px;
  }

  .sidebar,
  .kpi-grid,
  .insight-list {
    grid-template-columns: 1fr;
  }

  .chart-panel {
    min-height: 300px;
  }
}
