:root {
  color-scheme: light;
  --bg: #eef1f4;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d7dde5;
  --strong-line: #9aa4b2;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --warn: #b54708;
  --bad: #b42318;
  --good: #087443;
  --soft: #f6f8fa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
}

p {
  margin: 0;
  color: var(--muted);
}

.endpoint {
  border: 1px solid #b8d7d1;
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--accent-dark);
  white-space: nowrap;
  background: #e8f5f2;
}

.layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
}

.panel,
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.controls {
  position: sticky;
  top: 10px;
  align-self: start;
  max-height: calc(100vh - 20px);
  overflow: auto;
  padding: 14px;
}

.workspace {
  min-width: 0;
}

.section-title {
  margin: 0 0 10px;
  font-weight: 700;
  color: #25313f;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 11px;
  color: var(--muted);
  font-size: 12px;
}

[hidden] {
  display: none !important;
}

label.disabled {
  opacity: 0.55;
}

.terminal-value-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.terminal-value-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

.security-name {
  min-height: 18px;
  color: var(--accent-dark);
  font-size: 12px;
}

.field-note {
  margin: -2px 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 9px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
}

input:focus,
select:focus {
  outline: 2px solid #9bd5ce;
  outline-offset: 1px;
}

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

.actions {
  display: flex;
  gap: 10px;
  margin: 10px 0 18px;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary,
.tab {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.status {
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #ffffff;
  color: var(--muted);
}

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

.kpi {
  min-height: 78px;
  padding: 12px;
}

.kpi span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.kpi strong {
  display: block;
  font-size: 22px;
  line-height: 1.1;
}

.kpi small {
  color: var(--muted);
}

.warnings {
  padding: 13px 15px;
  margin-bottom: 10px;
}

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

.warnings li {
  margin: 6px 0;
}

.warnings .high {
  color: var(--bad);
}

.warnings .medium {
  color: var(--warn);
}

.warnings .low {
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 10px;
}

.tab {
  color: var(--muted);
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.sheet-shell {
  overflow: auto;
  border: 1px solid #7f7f7f;
  background: #bfbfbf;
}

.valuation-sheet {
  width: max-content;
  min-width: 1680px;
  border-collapse: collapse;
  table-layout: fixed;
  background: #bfbfbf;
  color: #000000;
  font-size: 13px;
}

.valuation-sheet th,
.valuation-sheet td {
  width: 108px;
  height: 22px;
  padding: 1px 4px;
  border: 1px solid #a8a8a8;
  background: #bfbfbf;
  text-align: right;
  vertical-align: middle;
  font-weight: 400;
  white-space: nowrap;
}

.valuation-sheet th {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 188px;
  min-width: 188px;
  max-width: 188px;
  text-align: left;
  background: #bfbfbf;
}

.valuation-sheet .sheet-section th {
  position: static;
  height: 26px;
  text-align: center;
  font-weight: 700;
  font-size: 17px;
  background: #bfbfbf;
}

.valuation-sheet .red,
.valuation-sheet .red-row th,
.valuation-sheet .red-row td {
  color: #e00000;
}

.valuation-sheet .center {
  text-align: center;
}

.valuation-sheet .yellow-row th,
.valuation-sheet .yellow-row td {
  background: #d7d700;
}

.valuation-sheet .yellow-row th {
  color: #e00000;
  font-weight: 700;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.two-col .panel,
.workspace > .panel,
#sensitivityPanel,
#view-reverse > .panel {
  padding: 13px 15px;
  margin-bottom: 10px;
}

.module-note {
  margin-bottom: 14px;
  line-height: 1.6;
}

.table-scroll {
  overflow: auto;
}

.penman-table {
  min-width: 1120px;
}

.reverse-growth-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 10px;
  padding: 18px 22px;
  border: 2px solid #dc2626;
  border-radius: 12px;
  background: #fff1f2;
  box-shadow: 0 5px 16px rgba(220, 38, 38, 0.12);
}

.reverse-growth-label {
  color: #991b1b;
  font-size: 17px;
  font-weight: 800;
}

.reverse-growth-note {
  margin-top: 5px;
  color: #b91c1c;
  font-size: 13px;
  line-height: 1.5;
}

.reverse-growth-value {
  flex: 0 0 auto;
  color: #dc2626;
  font-size: clamp(34px, 4vw, 48px);
  line-height: 1;
  letter-spacing: -0.03em;
}

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

.reverse-status {
  min-height: 20px;
  color: var(--muted);
}

.reverse-status.ok {
  color: var(--good);
}

.reverse-status.bad {
  color: var(--bad);
}

.reverse-kpi-grid {
  margin-top: 0;
}

.reverse-interpretation {
  margin-top: 12px;
  border-left: 3px solid var(--accent);
  padding: 10px 12px;
  background: var(--soft);
  color: #344054;
  line-height: 1.7;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 8px 7px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: top;
}

th:first-child,
td:first-child {
  text-align: left;
}

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

td.note {
  color: var(--muted);
  text-align: left;
}

td.ok {
  color: var(--good);
}

td.warn {
  color: var(--warn);
}

td.bad {
  color: var(--bad);
}

pre {
  max-height: 300px;
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #344054;
  background: #f3f5f7;
  border-radius: 6px;
  padding: 12px;
}

@media (max-width: 1100px) {
  .reverse-growth-hero {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .layout,
  .two-col,
  .kpi-grid,
  .reverse-input-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .controls {
    position: static;
    max-height: none;
  }
}
