:root {
  --bg: #ffffff;
  --panel: #fff;
  --text: #101828;
  --muted: #667085;
  --line: #e6e8ef;
  --soft: #f2f4f7;
  --accent: #d63a3a;
  --accent-dark: #b92f2f;
  --radius: 18px;
  --radius-sm: 14px;
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
  --shadow-sm: 0 6px 18px rgba(16, 24, 40, 0.06);
  --focus: 0 0 0 4px rgba(214, 58, 58, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: #ffffff;
  line-height: 1.35;
}

/* Legacy standalone header bits kept only in case any JS still touches them */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1150px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 850;
}

.brand-logo {
  height: 28px;
  width: auto;
  display: block;
}

.brand-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-title .name {
  font-weight: 900;
  letter-spacing: -0.2px;
}

.brand-title .sub {
  color: var(--muted);
  font-weight: 650;
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow-sm);
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* Hero aligned to site shell */
.toolkit-hero.codn-hero {
  background: #ffffff;
}

.toolkit-hero.codn-hero .container {
  text-align: center;
}

.codn-hero h1 {
  margin: 0;
  font-size: 2.75rem;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.codn-hero p {
  font-size: 1rem;
  line-height: 1.6;
}

/* Main layout */
.codn-main {
  padding-top: 14px;
  padding-bottom: 40px;
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 18px;
}

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-h {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-h .title {
  font-weight: 900;
  font-size: 14px;
  margin: 0;
}

.card-h .desc {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.card-b {
  padding: 14px 16px 16px;
}

label.small {
  width: 100%;
  font-size: 12px;
  color: var(--muted);
  font-weight: 750;
  margin-bottom: 6px;
  display: block;
}

select,
input[type="number"],
input[type="text"] {
  width: 100%;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  outline: none;
  font-weight: 650;
}

select:focus,
input[type="number"]:focus,
input[type="text"]:focus {
  box-shadow: var(--focus);
  border-color: rgba(214, 58, 58, 0.55);
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.badge {
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--muted);
  white-space: nowrap;
  font-weight: 850;
}

.badge.good {
  border-color: rgba(18, 183, 106, 0.25);
  background: rgba(18, 183, 106, 0.1);
  color: #067647;
}

.badge.warn {
  border-color: rgba(247, 144, 9, 0.25);
  background: rgba(247, 144, 9, 0.1);
  color: #b54708;
}

.badge.bad {
  border-color: rgba(240, 68, 56, 0.25);
  background: rgba(240, 68, 56, 0.1);
  color: #b42318;
}

.progress {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.bar {
  height: 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(214, 58, 58, 0.95), rgba(240, 107, 107, 0.95));
}

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 14px;
  font-weight: 900;
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s ease, filter 0.12s ease;
}

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

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none;
}

button.primary {
  border-color: rgba(214, 58, 58, 0.35);
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 12px 24px rgba(214, 58, 58, 0.18);
}

.hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.hint ul {
  margin: 8px 0 0 18px;
  padding: 0;
}

.callout {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(214, 58, 58, 0.06), rgba(255, 255, 255, 0));
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.footer-actions {
  padding: 0 16px 16px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.submit-wrap {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 10px 0;
}

.muted {
  color: var(--muted);
  font-weight: 650;
}

.results-grid {
  padding: 16px;
  display: grid;
  gap: 14px;
}

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

.kpi.hero {
  background: linear-gradient(180deg, rgba(214, 58, 58, 0.08), #fff);
  border-color: rgba(214, 58, 58, 0.25);
  box-shadow: 0 12px 28px rgba(214, 58, 58, 0.12);
}

.kpi .label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.kpi .sub {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 650;
}

.kpi .big {
  margin-top: 8px;
  font-size: 34px;
  font-weight: 950;
  letter-spacing: -0.6px;
}

.kpi .meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 900px) {
  .kpi-row {
    grid-template-columns: 1fr;
  }
}

.kpi {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fff;
}

.kpi h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 900;
}

.kpi p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.kpi .big {
  margin-top: 10px;
  font-size: 28px;
  font-weight: 950;
  letter-spacing: -0.4px;
}

.chart-wrap {
  width: 100%;
  overflow: hidden;
  display: flex;
  justify-content: center;
}

#cumulativeValueChart {
  display: block;
  width: 520px;
  max-width: 100%;
  height: 320px;
  margin: 0 auto;
  overflow: visible;
}

.chart-axis {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
  stroke-dasharray: 4 6;
}

.chart-area {
  fill: rgba(214, 58, 58, 0.1);
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
}

.chart-point {
  fill: var(--accent);
}

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

.chart-value {
  fill: var(--text);
  font-size: 12px;
  font-weight: 800;
}

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

@media (max-width: 900px) {
  .formula-grid {
    grid-template-columns: 1fr;
  }
}

.formula {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fff;
}

.formula h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 900;
}

.formula p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

@media print {
  .topbar,
  button {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .card {
    box-shadow: none;
  }

  .codn-main {
    grid-template-columns: 1fr;
  }

  .bar {
    display: none;
  }
}