:root {
  --paper: #f6f7f4;
  --surface: #ffffff;
  --ink: #17221d;
  --muted: #647069;
  --line: #d9dfda;
  --line-strong: #b8c2bb;
  --green: #174c3c;
  --green-soft: #e8f1ed;
  --coral: #c5533f;
  --coral-soft: #f8e9e5;
  --gold: #a56a12;
  --gold-soft: #f7edda;
  --danger: #9d3027;
  --danger-soft: #fbe9e7;
  --shadow: 0 14px 40px rgba(23, 34, 29, 0.07);
  --radius: 8px;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "DM Sans", Arial, sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

button, input, select { font: inherit; letter-spacing: 0; }
button, label[for] { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.topbar {
  height: 64px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 247, 244, 0.94);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

.brand-mark {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: white;
  border-radius: 5px;
  font-family: "Newsreader", Georgia, serif;
  font-size: 14px;
}

.model-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #3b936f; box-shadow: 0 0 0 4px #deeee7; }
.status-version { padding-left: 8px; border-left: 1px solid var(--line-strong); }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 54px 0 80px; }

.page-intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 28px; margin-bottom: 46px; }
.eyebrow { margin: 0 0 10px; color: var(--coral); font-size: 12px; font-weight: 600; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-family: "Newsreader", Georgia, serif; font-size: clamp(42px, 6vw, 66px); line-height: .94; font-weight: 500; }
.lede { margin-bottom: 0; color: var(--muted); font-size: 17px; }
h2 { margin: 0; font-size: 20px; font-weight: 600; }
h3 { margin-bottom: 4px; font-size: 16px; font-weight: 600; }

.primary-button, .secondary-button, .file-button, .icon-button {
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  font-weight: 600;
}

.primary-button { background: var(--green); color: white; padding: 0 20px; }
.primary-button:hover { background: #103f31; }
.primary-button:disabled { opacity: .55; cursor: wait; }
.secondary-button, .file-button { background: var(--surface); color: var(--ink); border-color: var(--line-strong); padding: 0 15px; }
.secondary-button:hover, .file-button:hover { border-color: var(--green); color: var(--green); }
.secondary-button:disabled { opacity: .55; cursor: wait; }
.primary-button svg, .secondary-button svg, .file-button svg, .tab svg { width: 17px; height: 17px; }

.section-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 17px; }
.section-heading > div:first-child { display: flex; align-items: baseline; gap: 12px; }
.section-number { color: var(--coral); font-size: 12px; font-weight: 600; }
.section-meta { color: var(--muted); font-size: 13px; }

.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.upload-card {
  min-height: 168px;
  padding: 24px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color .18s ease, transform .18s ease;
}
.upload-card.is-dragging { border-color: var(--green); transform: translateY(-2px); }
.upload-card.has-file { border-color: #8eb4a5; background: #fbfdfc; }
.upload-icon { width: 44px; height: 44px; display: grid; place-items: center; color: var(--green); background: var(--green-soft); border-radius: 7px; }
.upload-icon svg { width: 22px; height: 22px; }
.upload-copy { min-width: 0; }
.upload-copy h3 { overflow-wrap: anywhere; }
.upload-kicker { display: block; margin-bottom: 6px; color: var(--coral); font-size: 11px; font-weight: 600; text-transform: uppercase; }
.file-state { margin: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-card input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.run-bar { margin-top: 14px; padding: 13px 15px 13px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: #edf0ec; }
.pipeline { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.pipeline span { color: var(--ink); }
.pipeline svg { width: 14px; height: 14px; color: #97a099; }

.alert { margin-top: 12px; padding: 12px 14px; border: 1px solid #e4b4ae; border-radius: 6px; color: var(--danger); background: var(--danger-soft); font-size: 13px; }

.loading-section { margin-top: 30px; padding: 25px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.loading-row { display: flex; align-items: center; gap: 14px; }
.loading-row div { display: flex; flex-direction: column; gap: 3px; }
.loading-row span { color: var(--muted); font-size: 13px; }
.spinner { width: 28px; height: 28px; border: 2px solid var(--line); border-top-color: var(--coral); border-radius: 50%; animation: spin .8s linear infinite; }
.progress-track { height: 4px; margin-top: 18px; overflow: hidden; background: #dde2dd; border-radius: 2px; }
.progress-track span { display: block; width: 12%; height: 100%; background: var(--green); transition: width .5s ease; }
@keyframes spin { to { transform: rotate(360deg); } }

.results-section { margin-top: 54px; }
.sample-picker { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.sample-picker select { min-width: 156px; height: 38px; padding: 0 34px 0 11px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface); color: var(--ink); }

.summary-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(270px, .8fr); gap: 14px; }
.prediction-card { padding: 25px 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.prediction-topline { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; }
.model-chip { padding: 4px 8px; background: var(--green-soft); color: var(--green); border-radius: 4px; font-size: 11px; font-weight: 600; }
.season-result { min-height: 98px; display: flex; align-items: center; gap: 18px; border-bottom: 1px solid var(--line); }
.season-symbol { width: 14px; height: 48px; border-radius: 2px; background: var(--green); }
.season-name { margin: 0; font-family: "Newsreader", Georgia, serif; font-size: 38px; line-height: 1; }
.season-code { margin: 4px 0 0; color: var(--muted); font-size: 12px; font-weight: 600; }
.confidence-block { margin-left: auto; text-align: right; }
.confidence-block span { display: block; color: var(--muted); font-size: 12px; }
.confidence-block strong { font-size: 26px; }
.probability-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; padding-top: 18px; }
.probability-item { min-width: 0; }
.probability-label { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 7px; font-size: 12px; }
.probability-label span { color: var(--muted); }
.probability-track { height: 5px; overflow: hidden; background: #e7eae7; border-radius: 2px; }
.probability-track i { display: block; height: 100%; border-radius: 2px; }

.quality-panel { display: flex; flex-direction: column; background: #edf0ec; border: 1px solid var(--line); border-radius: var(--radius); }
.quality-item { min-height: 58px; padding: 0 18px; display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.quality-item svg { width: 17px; color: var(--green); }
.quality-item span { color: var(--muted); font-size: 12px; }
.quality-item strong { font-size: 13px; }
.quality-note { margin: auto 0 0; padding: 14px 18px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.quality-note.has-warning { color: var(--gold); background: var(--gold-soft); }

.tabs { display: flex; gap: 28px; margin-top: 35px; border-bottom: 1px solid var(--line); }
.tab { min-height: 46px; padding: 0 1px; display: inline-flex; align-items: center; gap: 8px; color: var(--muted); background: transparent; border: 0; border-bottom: 2px solid transparent; font-weight: 600; }
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--green); border-bottom-color: var(--green); }

.tab-panel { padding-top: 26px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 20px; }
.panel-heading p { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.legend { display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend-line { width: 21px; height: 2px; display: inline-block; }
.raw-line { background: var(--green); }
.sg-line { background: var(--coral); }
.legend-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }

.chart-wrap { position: relative; width: 100%; height: 390px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
#spectrum-chart { display: block; width: 100%; height: 100%; }
.chart-tooltip { position: absolute; z-index: 2; min-width: 150px; padding: 9px 11px; pointer-events: none; background: var(--ink); color: white; border-radius: 5px; font-size: 11px; line-height: 1.5; box-shadow: 0 8px 24px rgba(0,0,0,.14); }
.chart-footer { display: flex; justify-content: space-between; padding: 10px 4px 0; color: var(--muted); font-size: 11px; }

.feature-toolbar { align-items: center; }
.feature-controls { display: flex; align-items: center; gap: 10px; }
.segmented { display: inline-flex; padding: 3px; background: #e8ebe7; border-radius: 6px; }
.segmented button { min-height: 32px; padding: 0 11px; color: var(--muted); background: transparent; border: 0; border-radius: 4px; font-size: 12px; font-weight: 600; }
.segmented button.is-active { color: var(--ink); background: var(--surface); box-shadow: 0 1px 3px rgba(23,34,29,.12); }
.search-field { min-width: 210px; height: 38px; padding: 0 10px; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 5px; }
.search-field svg { width: 15px; color: var(--muted); }
.search-field input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-field input::placeholder { color: #929b95; }

.table-wrap { overflow-x: auto; border-top: 1px solid var(--line-strong); }
table { width: 100%; border-collapse: collapse; background: transparent; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; white-space: nowrap; }
td.numeric, th.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.source-tag, .season-tag { display: inline-flex; align-items: center; min-height: 23px; padding: 0 7px; border-radius: 4px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.source-tag.gc { color: var(--green); background: var(--green-soft); }
.source-tag.nir { color: var(--coral); background: var(--coral-soft); }
.season-tag.spt { color: var(--green); background: var(--green-soft); }
.season-tag.sut { color: var(--coral); background: var(--coral-soft); }
.season-tag.aut { color: var(--gold); background: var(--gold-soft); }
.sample-link { padding: 0; color: var(--ink); background: none; border: 0; font-weight: 600; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.sample-link:hover { color: var(--green); text-decoration-color: var(--green); }

.pagination { min-height: 55px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.pagination > div { display: flex; gap: 6px; }
.icon-button { width: 36px; min-height: 36px; padding: 0; color: var(--ink); background: var(--surface); border-color: var(--line-strong); }
.icon-button:hover:not(:disabled) { border-color: var(--green); color: var(--green); }
.icon-button:disabled { opacity: .4; cursor: default; }
.icon-button svg { width: 16px; height: 16px; }

footer { min-height: 68px; padding: 0 clamp(20px, 4vw, 64px); display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--muted); border-top: 1px solid var(--line); font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 860px) {
  main { width: min(100% - 28px, 720px); padding-top: 38px; }
  .page-intro { align-items: flex-start; }
  .upload-grid, .summary-grid { grid-template-columns: 1fr; }
  .quality-panel { display: grid; grid-template-columns: repeat(3, 1fr); }
  .quality-item { grid-template-columns: 20px 1fr; align-content: center; }
  .quality-item strong { grid-column: 2; }
  .quality-note { grid-column: 1 / -1; }
  .panel-heading, .feature-toolbar { align-items: flex-start; flex-direction: column; }
  .chart-wrap { height: 340px; }
}

@media (max-width: 620px) {
  .topbar { height: 58px; padding: 0 16px; }
  .status-version { display: none; }
  main { width: calc(100% - 24px); padding: 30px 0 56px; }
  .page-intro { margin-bottom: 34px; flex-direction: column; }
  h1 { font-size: 44px; }
  .secondary-button { width: 100%; }
  .section-heading { align-items: flex-start; gap: 14px; }
  .section-meta { padding-top: 4px; }
  .upload-card { min-height: 190px; padding: 20px; grid-template-columns: auto 1fr; }
  .upload-card .file-button { grid-column: 1 / -1; width: 100%; }
  .run-bar { align-items: stretch; flex-direction: column; }
  .pipeline { justify-content: space-between; gap: 4px; font-size: 11px; }
  .primary-button { width: 100%; }
  .results-section { margin-top: 44px; }
  .results-section > .section-heading { flex-direction: column; }
  .sample-picker { width: 100%; justify-content: space-between; }
  .sample-picker select { flex: 1; min-width: 0; }
  .prediction-card { padding: 22px 18px; }
  .season-result { gap: 12px; }
  .season-name { font-size: 32px; }
  .confidence-block strong { font-size: 20px; }
  .probability-list { gap: 10px; }
  .probability-label { flex-direction: column; gap: 2px; }
  .quality-panel { grid-template-columns: 1fr; }
  .quality-note { grid-column: auto; }
  .tabs { gap: 0; justify-content: space-between; }
  .tab { font-size: 12px; }
  .tab svg { display: none; }
  .legend { width: 100%; gap: 10px; flex-wrap: wrap; }
  .chart-wrap { height: 300px; }
  .chart-footer { align-items: flex-start; flex-direction: column; gap: 3px; }
  .feature-controls { width: 100%; align-items: stretch; flex-direction: column; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .search-field { width: 100%; min-width: 0; }
  th, td { padding: 11px 8px; }
  footer { padding: 17px 16px; align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
