:root {
  color-scheme: light;
  --bg: #eef2f3;
  --surface: #ffffff;
  --surface-muted: #f7f8f8;
  --border: #d9e0df;
  --text: #15201e;
  --muted: #63716e;
  --primary: #0f766e;
  --primary-dark: #0b5c56;
  --ink-soft: #263331;
  --warning: #b45309;
  --radius: 8px;
  --shadow: 0 18px 40px rgba(21, 32, 30, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  width: 100%;
  max-width: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
  max-width: 100%;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
  gap: 18px;
  width: 100%;
  max-width: 1540px;
  margin: 0 auto;
}

.workspace > *,
.sidebar,
.results-area,
.panel,
.chart-panel,
.table-panel,
.notes-panel,
.summary-card {
  min-width: 0;
}

.sidebar {
  align-self: start;
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding-right: 2px;
}

.brand-block {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 18px;
  background: #12312d;
  color: #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand-block > div,
.topbar > div,
.section-title > *,
.card-topline > *,
.panel-heading > * {
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #f5c542;
  color: #12312d;
  font-weight: 800;
}

.brand-block h1,
.brand-block p,
.topbar h2,
.eyebrow,
.section-title h3,
.panel-heading h2,
.notes-panel h3 {
  margin: 0;
}

.brand-block h1 {
  font-size: 1.25rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.brand-block p {
  margin-top: 4px;
  color: #dce9e6;
  line-height: 1.4;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.form-stack {
  display: grid;
  gap: 14px;
}

.panel,
.chart-panel,
.table-panel,
.notes-panel,
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel {
  padding: 16px;
}

details.panel {
  overflow: hidden;
}

.panel-heading,
.section-title,
.topbar,
.card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel > .panel-heading {
  margin-bottom: 0;
  cursor: pointer;
  list-style: none;
}

.panel > .panel-heading::-webkit-details-marker {
  display: none;
}

.panel > .panel-heading::after {
  content: "+";
  display: grid;
  place-items: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--primary-dark);
  font-weight: 900;
}

.panel[open] > .panel-heading {
  margin-bottom: 14px;
}

.panel[open] > .panel-heading::after {
  content: "-";
}

.panel-heading h2,
.section-title h3,
.notes-panel h3 {
  font-size: 1rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.checkline {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  column-gap: 9px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #ffffff;
}

.checkline input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--primary);
}

.checkline span,
.checkline small {
  grid-column: 2;
}

.full-width {
  grid-column: 1 / -1;
}

.field-grid {
  display: grid;
  gap: 12px;
}

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

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 0.86rem;
  font-weight: 700;
}

input[type="number"] {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-muted);
  color: var(--text);
  padding: 0 10px;
}

input[type="number"]:focus {
  outline: 2px solid rgba(15, 118, 110, 0.24);
  border-color: var(--primary);
  background: #ffffff;
}

small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.25;
}

.results-area {
  display: grid;
  align-content: start;
  gap: 16px;
}

.topbar {
  min-height: 92px;
  padding: 22px;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.eyebrow {
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h2 {
  margin-top: 4px;
  font-size: clamp(1.35rem, 2vw, 2.1rem);
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.ghost-button,
.primary-button {
  min-height: 40px;
  border-radius: 7px;
  padding: 0 14px;
  font-weight: 800;
}

.ghost-button {
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--ink-soft);
}

.primary-button {
  border: 1px solid var(--primary-dark);
  background: var(--primary);
  color: #ffffff;
}

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

.summary-card {
  min-height: 148px;
  padding: 16px;
  border-top: 5px solid var(--accent);
}

.card-topline span {
  color: var(--muted);
  font-weight: 800;
}

.card-topline strong {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--accent);
}

.big-number {
  margin: 20px 0 4px;
  font-size: clamp(1.35rem, 2vw, 1.9rem);
  font-weight: 850;
  line-height: 1;
  overflow-wrap: anywhere;
}

.muted {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.chart-panel,
.table-panel,
.notes-panel {
  padding: 18px;
}

.section-title {
  margin-bottom: 16px;
}

.section-title span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.bar-chart {
  display: grid;
  gap: 14px;
}

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

.bar-label {
  font-weight: 800;
}

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

.bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.bar-row strong {
  text-align: right;
}

.line-chart-wrap {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(#ffffff, #f8faf9);
}

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

.chart-axis {
  stroke: #9aa8a5;
  stroke-width: 1.2;
}

.chart-grid {
  stroke: #d8e1df;
  stroke-width: 1;
  stroke-dasharray: 5 6;
}

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

.chart-legend,
.composition-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.chart-legend span,
.composition-labels span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i,
.composition-labels i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.composition-chart {
  display: grid;
  gap: 16px;
}

.composition-row {
  display: grid;
  gap: 8px;
}

.composition-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
  min-width: 0;
}

.composition-head span {
  color: var(--muted);
  overflow-wrap: anywhere;
  text-align: right;
}

.stacked-bar {
  display: flex;
  width: 100%;
  height: 22px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7eceb;
}

.stack-segment {
  min-width: 2px;
  height: 100%;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

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

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

td {
  font-weight: 700;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  vertical-align: middle;
}

.notes-panel ul {
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.notes-panel li + li {
  margin-top: 8px;
}

.empty-state {
  grid-column: 1 / -1;
  margin: 0;
  padding: 22px;
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--muted);
}

.app-footer {
  display: flex;
  justify-content: center;
  gap: 18px;
  max-width: 1540px;
  margin: 18px auto 0;
  padding: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.app-footer a {
  color: var(--primary-dark);
  font-weight: 800;
  text-underline-offset: 0.18em;
}

.legal-shell {
  width: min(820px, calc(100% - 32px));
  max-width: 100%;
  margin: 0 auto;
  padding: 34px 0 56px;
}

.legal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
  min-width: 0;
}

.legal-nav a,
.legal-page a {
  color: var(--primary-dark);
  font-weight: 800;
  text-underline-offset: 0.18em;
  overflow-wrap: anywhere;
}

.legal-page {
  padding: 26px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
}

.legal-page header {
  margin-bottom: 26px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.legal-page h1 {
  margin: 4px 0 8px;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.08;
}

.legal-page h2 {
  margin: 28px 0 8px;
  font-size: 1.12rem;
}

.legal-page p,
.legal-page ul,
.legal-page address {
  margin: 0 0 14px;
  line-height: 1.62;
  max-width: 100%;
}

.legal-page ul {
  padding-left: 22px;
}

.legal-page address {
  font-style: normal;
}

.legal-page code {
  white-space: normal;
  word-break: break-word;
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--surface-muted);
  color: var(--ink-soft);
}

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

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    max-height: none;
    overflow: visible;
  }

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

@media (max-width: 680px) {
  .app-shell {
    padding: 8px;
  }

  .workspace {
    gap: 10px;
  }

  .brand-block,
  .topbar,
  .chart-panel,
  .table-panel,
  .notes-panel,
  .panel,
  .summary-card {
    width: 100%;
  }

  .brand-block {
    padding: 14px;
    gap: 10px;
  }

  .brand-block h1 {
    font-size: 1.08rem;
  }

  .brand-block p {
    font-size: 0.82rem;
  }

  .legal-shell {
    width: min(100%, calc(100% - 20px));
    padding: 18px 0 36px;
  }

  .legal-page {
    padding: 18px 14px;
  }

  .legal-nav {
    gap: 10px 14px;
  }

  .legal-page h1 {
    font-size: 2rem;
  }

  .field-grid.two,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-heading,
  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel > .panel-heading {
    flex-direction: row;
    align-items: center;
  }

  .top-actions {
    width: 100%;
    min-width: 0;
  }

  .ghost-button,
  .primary-button {
    flex: 1;
    min-width: 0;
  }

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

  .bar-row strong {
    text-align: left;
    overflow-wrap: anywhere;
  }

  .composition-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .composition-head span {
    text-align: left;
  }

  .composition-labels {
    display: grid;
    gap: 6px;
  }

  .app-footer {
    flex-wrap: wrap;
    margin-top: 10px;
  }
}

@media (max-width: 380px) {
  .app-shell {
    padding: 6px;
  }

  .brand-mark {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
  }

  .ghost-button,
  .primary-button {
    padding: 0 10px;
  }

  .chart-panel,
  .table-panel,
  .notes-panel,
  .panel,
  .summary-card {
    padding: 14px 12px;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .app-shell {
    padding: 0;
  }

  .workspace {
    display: block;
  }

  .sidebar,
  .top-actions {
    display: none;
  }

  .topbar,
  .chart-panel,
  .table-panel,
  .notes-panel,
  .summary-card {
    box-shadow: none;
    break-inside: avoid;
  }
}
