:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-strong: #f0f4f1;
  --ink: #17211d;
  --muted: #66736d;
  --line: #d9e1dc;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --coral: #c2412d;
  --amber: #b7791f;
  --leaf: #4f7f36;
  --shadow: 0 18px 48px rgba(29, 48, 41, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 68px;
  padding: 12px clamp(16px, 4vw, 56px);
  border-bottom: 1px solid rgba(217, 225, 220, 0.9);
  background: rgba(247, 248, 245, 0.94);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border: 2px solid var(--teal);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 47%, var(--teal) 47% 53%, transparent 53%),
    linear-gradient(0deg, transparent 47%, var(--coral) 47% 53%, transparent 53%),
    var(--surface);
}

.brand strong,
.brand small {
  display: block;
  white-space: nowrap;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.nav a {
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 6px;
}

.nav a:hover {
  background: var(--surface-strong);
  color: var(--ink);
}

main {
  padding: clamp(18px, 4vw, 48px);
}

.workbench,
.paid-band,
.report-output-section,
.source-section {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: end;
  margin-bottom: 20px;
}

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

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(28px, 5vw, 52px);
  line-height: 1.08;
}

h2 {
  margin-bottom: 8px;
  font-size: 22px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 10px;
  font-size: 15px;
}

.lead {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
}

.source-pill {
  display: grid;
  gap: 2px;
  min-width: 150px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.source-pill span {
  color: var(--muted);
  font-size: 12px;
}

.source-pill strong {
  color: var(--teal-dark);
  font-size: 18px;
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(360px, 0.82fr);
  gap: 18px;
  align-items: start;
}

.tool-panel,
.result-panel,
.report-console,
.report-output,
.source-grid article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tool-panel,
.result-panel,
.report-console {
  padding: clamp(16px, 3vw, 24px);
}

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

.panel-title.compact {
  margin-bottom: 14px;
}

.panel-title p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

fieldset {
  min-width: 0;
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

legend {
  padding: 0 8px;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 700;
}

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

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

.field {
  position: relative;
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span {
  overflow-wrap: anywhere;
  color: #26352f;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #c8d3cd;
  border-radius: 6px;
  background: #fbfcfa;
  color: var(--ink);
  outline: none;
}

.field input {
  padding: 9px 11px;
}

.field select {
  padding: 9px 8px;
}

.field input:focus,
.field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.field small {
  color: var(--muted);
  font-size: 12px;
}

.field.with-unit {
  grid-template-columns: minmax(0, 1fr) 104px;
  align-items: end;
}

.field.with-unit span {
  grid-column: 1 / -1;
}

.form-actions,
.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.ghost-button {
  min-height: 42px;
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: white;
}

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

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

.ghost-button:hover {
  border-color: #b8c5be;
  background: var(--surface-strong);
}

.fine-print {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.score-box {
  min-height: 98px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
}

.score-box span {
  display: block;
  min-height: 42px;
  color: var(--teal-dark);
  font-size: clamp(26px, 4vw, 36px);
  font-weight: 900;
  line-height: 1.1;
}

.score-box.accent span {
  color: var(--coral);
}

.score-box small {
  color: var(--muted);
  font-size: 12px;
}

.age-meter {
  margin: 6px 0 16px;
  padding-top: 22px;
}

.meter-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: 16px;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(90deg, #4f7f36 0 33%, #b7791f 33% 66%, #c2412d 66% 100%);
}

.meter-track span {
  position: relative;
  top: 18px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.meter-needle {
  position: relative;
  width: 12px;
  height: 26px;
  margin-top: -22px;
  margin-left: calc(50% - 6px);
  border-radius: 999px;
  background: var(--ink);
  box-shadow: 0 4px 12px rgba(23, 33, 29, 0.24);
  transition: margin-left 220ms ease;
}

.summary-box,
.warning-box {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: #26352f;
  font-size: 14px;
}

.warning-box {
  margin-top: 12px;
  border: 1px solid rgba(194, 65, 45, 0.28);
  background: #fff7f4;
  color: #7a2c20;
}

.module-section {
  margin-top: 18px;
}

.module-bars {
  display: grid;
  gap: 10px;
}

.module-item {
  display: grid;
  gap: 6px;
}

.module-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #26352f;
  font-size: 13px;
  font-weight: 800;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: #e6ece8;
  overflow: hidden;
}

.bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
  transition: width 220ms ease;
}

.module-item.attention .bar span {
  background: var(--amber);
}

.module-item.high .bar span {
  background: var(--coral);
}

.paid-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
  gap: 18px;
  align-items: start;
  margin-top: 24px;
  padding: clamp(18px, 4vw, 28px) 0;
}

.paid-band > div:first-child {
  padding-top: 8px;
}

.paid-band p {
  color: var(--muted);
}

.report-console {
  box-shadow: none;
}

.report-output-section {
  margin-top: 12px;
}

.report-output {
  min-height: 260px;
  max-height: 560px;
  margin: 0;
  padding: 18px;
  overflow: auto;
  color: #26352f;
  font-size: 14px;
  white-space: pre-wrap;
}

.source-section {
  margin-top: 30px;
  padding-bottom: 28px;
}

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

.source-grid article {
  padding: 16px;
  box-shadow: none;
}

.source-grid p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.is-invalid {
  border-color: var(--coral) !important;
  box-shadow: 0 0 0 3px rgba(194, 65, 45, 0.13) !important;
}

@media (max-width: 980px) {
  .app-grid,
  .paid-band,
  .section-head {
    grid-template-columns: 1fr;
  }

  .source-pill {
    width: fit-content;
  }

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

@media (max-width: 680px) {
  .topbar {
    align-items: start;
    flex-direction: column;
    gap: 8px;
  }

  .nav {
    width: 100%;
    justify-content: space-between;
  }

  main {
    padding: 16px;
  }

  .field-grid,
  .field-grid.two,
  .score-row,
  .source-grid {
    grid-template-columns: 1fr;
  }

  .field.with-unit {
    grid-template-columns: minmax(0, 1fr) 96px;
  }

  .panel-title {
    align-items: stretch;
    flex-direction: column;
  }
}
