:root {
  color-scheme: light;
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-soft: #f7f9f8;
  --surface-strong: #edf2ef;
  --ink: #182320;
  --muted: #61706c;
  --faint: #8b9894;
  --line: #dbe3df;
  --line-strong: #c8d3ce;
  --green: #08705a;
  --green-dark: #075643;
  --green-soft: #e5f3ee;
  --blue: #3769b5;
  --blue-soft: #eaf0fa;
  --amber: #bd7a0e;
  --amber-soft: #fbf1dc;
  --coral: #bf544c;
  --coral-soft: #fae9e7;
  --shadow: 0 8px 28px rgba(26, 50, 42, 0.07);
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
select,
summary,
.file-button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
.file-button:focus-visible {
  outline: 3px solid rgba(55, 105, 181, 0.24);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  column-gap: 20px;
  align-items: center;
  min-height: 74px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 12px rgba(26, 50, 42, 0.04);
}

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

.brand-mark {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding-top: 9px;
  flex: 0 0 44px;
  color: white;
  background: var(--green);
  border-radius: 6px;
  font-weight: 750;
  line-height: 1;
}

.brand-mark span {
  font-size: 19px;
}

.brand-mark sup {
  margin: -2px 0 0 1px;
  font-size: 10px;
}

.brand h1 {
  margin: 0;
  overflow: hidden;
  font-size: 17px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.3;
}

.brand > div:last-child {
  min-width: 0;
}

.brand p {
  margin: 3px 0 0;
  color: var(--faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.primary-nav {
  display: flex;
  align-items: stretch;
  height: 74px;
  gap: 4px;
}

.nav-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 126px;
  padding: 0 18px;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: 14px;
  font-weight: 600;
}

.nav-tab::after {
  position: absolute;
  right: 18px;
  bottom: 0;
  left: 18px;
  height: 3px;
  background: transparent;
  border-radius: 3px 3px 0 0;
  content: "";
}

.nav-tab:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.nav-tab.active {
  color: var(--green-dark);
}

.nav-tab.active::after {
  background: var(--green);
}

.language-control {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.language-control label {
  white-space: nowrap;
}

.language-control select {
  width: auto;
  min-width: 118px;
  height: 34px;
  padding: 0 28px 0 10px;
  color: var(--ink);
  background: var(--surface-soft);
}

.nav-tab svg,
.secondary-button svg,
.primary-button svg,
.method-note svg,
.dataset-version svg,
.methodology-title svg,
.file-button svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.9;
}

.service-status {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--amber);
  border-radius: 50%;
  box-shadow: 0 0 0 4px var(--amber-soft);
}

.service-status.ready .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
}

.service-status.error .status-dot {
  background: var(--coral);
  box-shadow: 0 0 0 4px var(--coral-soft);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.prediction-workspace {
  display: grid;
  grid-template-columns: 384px minmax(0, 1fr);
  min-height: calc(100vh - 74px);
}

.input-panel {
  position: sticky;
  top: 74px;
  align-self: start;
  height: calc(100vh - 74px);
  overflow-y: auto;
  padding: 28px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.panel-title-row,
.page-heading,
.section-title,
.chart-title-row,
.result-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h2,
h3,
p {
  letter-spacing: 0;
}

.panel-title-row h2,
.page-heading h2,
.result-heading h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.icon-button:hover {
  color: var(--green-dark);
  background: var(--green-soft);
  border-color: #bcd9cf;
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

form {
  margin-top: 28px;
}

fieldset {
  min-width: 0;
  margin: 0 0 24px;
  padding: 0;
  border: 0;
}

legend,
details summary {
  width: 100%;
  margin-bottom: 14px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
}

legend {
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.field-stack {
  min-width: 0;
  margin-bottom: 14px;
}

.field-stack label {
  display: block;
  margin-bottom: 6px;
  color: #3e4b47;
  font-size: 12px;
  font-weight: 650;
}

.field-stack label span {
  color: var(--coral);
}

input,
select,
textarea {
  width: 100%;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

input,
select {
  height: 41px;
  padding: 0 11px;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #aab9b2;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(55, 105, 181, 0.12);
}

input::placeholder,
textarea::placeholder {
  color: #a1aca8;
}

.input-with-unit {
  position: relative;
}

.input-with-unit input {
  padding-right: 52px;
}

.input-with-unit span {
  position: absolute;
  top: 50%;
  right: 10px;
  color: var(--faint);
  font-size: 11px;
  pointer-events: none;
  transform: translateY(-50%);
}

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

.field-context {
  min-height: 16px;
  margin-top: 6px;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.45;
}

#material-name-label { color: #3e4b47; }
#material-name { height: auto; min-height: 44px; padding: 10px 11px; }
#material-matches {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
}
#material-matches li {
  cursor: pointer;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
#material-matches li:last-child { border-bottom: 0; }
#material-matches li:hover, #material-matches li[aria-selected="true"] { background: var(--green-soft); }
#material-matches strong { display: block; font-size: 12px; line-height: 1.5; }
#material-matches span { display: block; font-size: 11px; color: var(--muted); line-height: 1.5; }
#material-selection { color: var(--green-dark); overflow-wrap: anywhere; }

details {
  margin-bottom: 21px;
}

details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 9px;
  border-bottom: 1px solid var(--line);
  list-style: none;
}

details summary::-webkit-details-marker {
  display: none;
}

details summary svg {
  width: 15px;
  height: 15px;
  transition: transform 160ms ease;
}

details[open] summary svg {
  transform: rotate(180deg);
}

.details-grid {
  padding-top: 14px;
}

.primary-button,
.secondary-button,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.primary-button {
  color: white;
  background: var(--green);
  border: 1px solid var(--green);
  box-shadow: 0 4px 12px rgba(8, 112, 90, 0.16);
}

.primary-button:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button,
.file-button {
  color: #35433f;
  background: var(--surface);
  border: 1px solid var(--line-strong);
}

.secondary-button:hover,
.file-button:hover {
  color: var(--green-dark);
  background: var(--green-soft);
  border-color: #b9d7cd;
}

.full-width {
  width: 100%;
}

.form-message {
  min-height: 20px;
  margin: 0 0 8px;
  color: var(--coral);
  font-size: 12px;
  line-height: 1.45;
}

.results-panel {
  min-width: 0;
  padding: 30px clamp(24px, 4vw, 58px) 52px;
}

.empty-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 158px);
  text-align: center;
}

.empty-visual {
  position: relative;
  width: min(390px, 70%);
  height: 180px;
  margin-bottom: 24px;
  border-left: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}

.empty-visual svg {
  position: absolute;
  inset: 15px 0 0 8px;
  width: calc(100% - 14px);
  height: calc(100% - 20px);
  overflow: visible;
}

.empty-visual polyline {
  fill: none;
  stroke: var(--green);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.empty-visual circle {
  fill: var(--surface);
  stroke: var(--blue);
  stroke-width: 3;
}

.empty-result h2 {
  margin: 0;
  font-size: 24px;
}

.empty-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  gap: 1px;
  margin-top: 28px;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.empty-stats div {
  display: flex;
  flex-direction: column;
  min-width: 120px;
  padding: 15px 20px;
  background: var(--surface);
}

.empty-stats strong {
  color: var(--green-dark);
  font-size: 19px;
}

.empty-stats span {
  margin-top: 3px;
  color: var(--faint);
  font-size: 11px;
}

.result-content {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}

.result-heading {
  align-items: center;
  margin-bottom: 22px;
}

.result-kicker {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.separator {
  margin: 0 7px;
  color: var(--line-strong);
}

.domain-badge {
  display: inline-grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  color: var(--green-dark);
  background: var(--green-soft);
  border: 1px solid #bfddd2;
  border-radius: 6px;
  font-size: 12px;
}

.domain-badge strong {
  padding-left: 7px;
  border-left: 1px solid currentColor;
  font-variant-numeric: tabular-nums;
}

.domain-dot {
  width: 7px;
  height: 7px;
  background: currentColor;
  border-radius: 50%;
}

.domain-badge.medium {
  color: #7b530e;
  background: var(--amber-soft);
  border-color: #ead3a7;
}

.domain-badge.low {
  color: #8e3933;
  background: var(--coral-soft);
  border-color: #ecc6c2;
}

.primary-result-band {
  display: grid;
  grid-template-columns: minmax(220px, 1.55fr) repeat(3, minmax(130px, 1fr));
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  box-shadow: var(--shadow);
}

.primary-result-band > div {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 112px;
  padding: 20px 22px;
  border-right: 1px solid var(--line);
}

.primary-result-band > div:last-child {
  border-right: 0;
}

.primary-result-band span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.primary-value {
  background: #f0f7f4;
}

.primary-value strong {
  margin-top: 7px;
  color: var(--green-dark);
  font-size: 29px;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.primary-value small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.result-stat strong {
  margin-top: 8px;
  font-size: 21px;
  font-variant-numeric: tabular-nums;
}

.interval-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

.interval-strip div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 0 18px;
  border-right: 1px solid var(--line);
}

.interval-strip div:last-child {
  border-right: 0;
}

.interval-strip span {
  color: var(--faint);
  font-size: 10px;
}

.interval-strip strong {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.chart-grid,
.model-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.chart-panel,
.analysis-panel,
.batch-editor,
.batch-reference,
.batch-results,
.model-detail-panel,
.feature-table-section,
.methodology {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.chart-panel,
.analysis-panel {
  min-width: 0;
  padding: 20px;
}

.chart-title-row {
  align-items: flex-start;
  margin-bottom: 15px;
}

.chart-title-row h3,
.section-title h3,
.methodology h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.3;
}

.chart-title-row p,
.section-title p,
.methodology-title p {
  margin: 4px 0 0;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.4;
}

.chart-unit {
  flex: 0 0 auto;
  color: var(--faint);
  font-size: 9px;
  font-weight: 650;
}

canvas {
  display: block;
  width: 100%;
  height: 260px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 18px;
  margin-top: 18px;
}

.analysis-panel canvas {
  height: 340px;
}

.analysis-note {
  margin: 8px 0 0;
  color: var(--faint);
  font-size: 10px;
}

.domain-meter {
  height: 8px;
  margin: 25px 0 18px;
  overflow: hidden;
  background: var(--surface-strong);
  border-radius: 4px;
}

.domain-meter div {
  width: 0;
  height: 100%;
  background: var(--green);
  border-radius: 4px;
  transition: width 300ms ease;
}

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

.domain-facts div {
  min-width: 0;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.domain-facts dt {
  color: var(--faint);
  font-size: 9px;
}

.domain-facts dd {
  margin: 5px 0 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.warning-list {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.warning-list li {
  position: relative;
  margin-top: 8px;
  padding-left: 13px;
  color: #6e5442;
  font-size: 10px;
  line-height: 1.45;
}

.warning-list li::before {
  position: absolute;
  top: 5px;
  left: 0;
  width: 5px;
  height: 5px;
  background: var(--amber);
  border-radius: 50%;
  content: "";
}

.warning-list .no-warning {
  color: var(--green-dark);
}

.warning-list .no-warning::before {
  background: var(--green);
}

.method-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 18px;
  padding: 13px 15px;
  color: #4f5f5a;
  background: var(--blue-soft);
  border: 1px solid #d2ddf0;
  border-radius: 6px;
}

.method-note svg {
  flex: 0 0 17px;
  color: var(--blue);
}

.method-note p {
  margin: 0;
  font-size: 10px;
  line-height: 1.55;
}

.page-container {
  width: min(1440px, calc(100% - 56px));
  margin: 0 auto;
  padding: 36px 0 56px;
}

.page-heading {
  align-items: center;
  margin-bottom: 24px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
}

.batch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(270px, 0.55fr);
  gap: 18px;
}

.batch-editor,
.batch-reference,
.batch-results,
.model-detail-panel,
.feature-table-section {
  padding: 20px;
}

.section-title {
  align-items: center;
  margin-bottom: 14px;
}

#batch-csv {
  min-height: 380px;
  padding: 14px;
  resize: vertical;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 11px;
  line-height: 1.65;
  white-space: pre;
}

.batch-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 14px;
}

.batch-actions .form-message {
  margin: 0;
}

.reference-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.reference-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.reference-item:last-child {
  border-bottom: 0;
}

.reference-item strong {
  display: block;
  font-size: 11px;
}

.reference-item span {
  color: var(--faint);
  font-size: 9px;
}

.reference-item code {
  align-self: center;
  color: var(--blue);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 9px;
}

.batch-results {
  margin-top: 18px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #45534f;
  background: var(--surface-strong);
  font-size: 10px;
  font-weight: 750;
}

td {
  color: #40504b;
  font-variant-numeric: tabular-nums;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #fafcfb;
}

.status-cell {
  font-weight: 700;
}

.status-cell.ok {
  color: var(--green);
}

.status-cell.error {
  color: var(--coral);
}

.dataset-version {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.model-stat-band {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  overflow: hidden;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.model-stat-band div {
  display: flex;
  flex-direction: column;
  min-height: 88px;
  padding: 18px 20px;
  border-right: 1px solid var(--line);
}

.model-stat-band div:last-child {
  border-right: 0;
}

.model-stat-band span {
  color: var(--faint);
  font-size: 10px;
}

.model-stat-band strong {
  margin-top: 8px;
  font-size: 21px;
  font-variant-numeric: tabular-nums;
}

.model-chart-grid {
  margin-top: 0;
}

.model-chart-grid canvas {
  height: 290px;
}

.model-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.weight-list {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.weight-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 12px;
}

.weight-row span,
.weight-row strong {
  font-size: 11px;
}

.weight-row strong {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.weight-track {
  height: 7px;
  overflow: hidden;
  background: var(--surface-strong);
  border-radius: 4px;
}

.weight-track div {
  height: 100%;
  background: var(--blue);
  border-radius: 4px;
}

.metric-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.metric-list div {
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.metric-list dt {
  color: var(--faint);
  font-size: 9px;
}

.metric-list dd {
  margin: 5px 0 0;
  font-size: 15px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.feature-table-section {
  margin-top: 18px;
}

.feature-table-section td:not(:first-child),
.feature-table-section th:not(:first-child) {
  text-align: right;
}

.methodology {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 28px;
  margin-top: 18px;
  padding: 24px;
}

.methodology-title {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.methodology-title svg {
  color: var(--green);
}

.methodology ol {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 6px;
  counter-reset: method;
  list-style: none;
}

.methodology li {
  position: relative;
  min-height: 112px;
  padding: 16px;
  background: var(--surface);
  counter-increment: method;
}

.methodology li::before {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-bottom: 10px;
  color: var(--green-dark);
  background: var(--green-soft);
  border-radius: 50%;
  content: counter(method);
  font-size: 10px;
  font-weight: 800;
}

.methodology li strong {
  display: block;
  font-size: 11px;
}

.methodology li span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.loading-overlay {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(244, 247, 245, 0.72);
  backdrop-filter: blur(3px);
}

.loading-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.loading-indicator span {
  width: 18px;
  height: 18px;
  border: 2px solid #c8dcd5;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.loading-indicator p {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toast-region {
  position: fixed;
  z-index: 60;
  right: 22px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 44px));
}

.toast {
  padding: 12px 14px;
  color: white;
  background: #26332f;
  border-radius: 6px;
  box-shadow: var(--shadow);
  font-size: 11px;
  line-height: 1.5;
  animation: toast-in 180ms ease-out;
}

.toast.error {
  background: #8f3e38;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Keep English labels readable at desktop zoom and intermediate widths. */
.chart-title-row {
  flex-wrap: wrap;
  gap: 8px 16px;
}

.chart-title-row > div {
  min-width: 0;
  flex: 1 1 180px;
}

.chart-unit {
  white-space: normal;
}

@media (max-width: 1400px) and (min-width: 861px) {
  .topbar {
    position: static;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 24px;
    padding-top: 12px;
  }
  .brand { grid-column: 1; grid-row: 1; }
  .language-control { grid-column: 2; grid-row: 1; }
  .primary-nav { grid-column: 1 / -1; grid-row: 2; height: 48px; }
  .service-status { display: none; }
  .input-panel { top: 0; height: 100vh; }
  .analysis-grid, .chart-grid { grid-template-columns: minmax(0, 1fr); }
  .primary-result-band { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .primary-value { grid-column: 1 / -1; }
  .interval-strip { grid-template-columns: minmax(0, 1fr); }
}

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

  .service-status {
    display: none;
  }

  .prediction-workspace {
    grid-template-columns: 340px minmax(0, 1fr);
  }

  .input-panel {
    padding: 24px 22px;
  }

  .primary-result-band {
    grid-template-columns: repeat(3, 1fr);
  }

  .primary-value {
    grid-column: 1 / -1;
    min-height: 100px !important;
    border-right: 0 !important;
    border-bottom: 1px solid var(--line);
  }

  .interval-strip {
    grid-template-columns: 1fr;
  }

  .interval-strip div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .interval-strip div:last-child {
    border-bottom: 0;
  }

  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .methodology {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .topbar {
    position: static;
    grid-template-columns: 1fr;
    padding: 13px 18px 12px;
  }

  .brand {
    padding-bottom: 12px;
  }

  .primary-nav {
    width: 100%;
    height: 48px;
    overflow-x: auto;
  }

  .language-control {
    justify-self: stretch;
    justify-content: flex-end;
    padding-top: 10px;
    border-top: 1px solid var(--line);
  }

  .nav-tab {
    min-width: 120px;
    padding: 0 11px;
    font-size: 12px;
  }

  .nav-tab::after {
    right: 10px;
    left: 10px;
  }

  .prediction-workspace {
    display: block;
  }

  .input-panel {
    position: static;
    width: 100%;
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .results-panel {
    padding: 26px 18px 42px;
  }

  .empty-result {
    min-height: 420px;
  }

  .chart-grid,
  .model-chart-grid,
  .model-detail-grid,
  .batch-layout {
    grid-template-columns: 1fr;
  }

  .page-container {
    width: min(100% - 32px, 720px);
    padding-top: 28px;
  }

  .model-stat-band {
    grid-template-columns: repeat(2, 1fr);
  }

  .model-stat-band div {
    border-bottom: 1px solid var(--line);
  }

  .model-stat-band div:nth-child(2n) {
    border-right: 0;
  }

  .model-stat-band div:last-child {
    grid-column: 1 / -1;
    border-bottom: 0;
  }

  .methodology ol {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .brand h1 {
    font-size: 15px;
  }

  .nav-tab {
    min-width: 104px;
    gap: 6px;
    font-size: 11px;
  }

  .nav-tab svg {
    width: 15px;
    height: 15px;
  }

  .input-panel {
    padding: 22px 17px;
  }

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

  .result-heading,
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .primary-result-band {
    grid-template-columns: 1fr;
  }

  .primary-value {
    grid-column: auto;
  }

  .primary-result-band > div {
    min-height: 82px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .primary-result-band > div:last-child {
    border-bottom: 0;
  }

  .empty-stats {
    grid-template-columns: 1fr;
  }

  .empty-stats div {
    min-width: 180px;
  }

  .domain-facts,
  .metric-list {
    grid-template-columns: 1fr;
  }

  .toolbar {
    width: 100%;
    flex-wrap: wrap;
  }

  .secondary-button,
  .file-button {
    flex: 1 1 auto;
  }

  .batch-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .model-stat-band {
    grid-template-columns: 1fr;
  }

  .model-stat-band div,
  .model-stat-band div:nth-child(2n) {
    grid-column: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .methodology ol {
    grid-template-columns: 1fr;
  }

  .weight-row {
    grid-template-columns: 92px minmax(0, 1fr) 42px;
  }

  canvas {
    height: 230px;
  }
}
/* Compact, scrollable database reference; names remain canonical model inputs. */
#material-reference { margin: 0 0 16px; border: 1px solid #cbded8; border-radius: 6px; padding: 10px 12px; background: #f5faf8; }
#material-reference summary { cursor: pointer; font-size: 14px; font-weight: 600; color: #096b58; }
.reference-controls { display: grid; gap: 8px; margin-top: 12px; }
.reference-controls input, .reference-controls select { width: 100%; min-width: 0; font-size: 14px; }
#reference-count { font-size: 12px; margin: 10px 0; }
#reference-list { max-height: 280px; overflow-y: auto; overflow-x: hidden; }
#reference-list button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid #dce7e3; border-radius: 0; padding: 10px 4px; background: transparent; color: #18352c; cursor: pointer; white-space: normal; overflow-wrap: anywhere; }
#reference-list button:hover, #reference-list button:focus-visible { background: #e1f2ec; }
#reference-list strong, #reference-list span { display: block; }
#reference-list span { font-size: 12px; margin-top: 4px; color: #536b63; }
