:root {
  --bg: #efe7da;
  --paper: rgba(255, 252, 246, 0.92);
  --paper-strong: #fffcf6;
  --ink: #1f2330;
  --muted: #5b6272;
  --line: rgba(31, 35, 48, 0.12);
  --teal: #1f676e;
  --coral: #d56d43;
  --sage: #78907c;
  --gold: #b88a19;
  --green: #2f7a44;
  --red: #9d2f22;
  --shadow: 0 24px 56px rgba(66, 47, 18, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(213, 109, 67, 0.18), transparent 26%),
    radial-gradient(circle at top right, rgba(31, 103, 110, 0.16), transparent 24%),
    radial-gradient(circle at 50% 110%, rgba(120, 144, 124, 0.16), transparent 30%),
    linear-gradient(140deg, #f6efe3 0%, #ebe0ce 42%, #d6c7ad 100%);
  background-attachment: fixed;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.hidden { display: none !important; }

.shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 24px 0 44px;
}

.home-link {
  display: inline-block;
  color: var(--teal);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 28px;
  padding: 34px 8px 22px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--coral);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.eyebrow.compact { margin-bottom: 5px; font-size: 0.66rem; }

h1 {
  margin: 0;
  font-size: clamp(2.7rem, 6vw, 5.2rem);
  line-height: 0.94;
  letter-spacing: -0.045em;
}

h2 { margin: 2px 0 5px; font-size: 1.18rem; }
h3 { margin: 0; font-size: 1.03rem; }

.lede {
  max-width: 70ch;
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.hero-actions { display: grid; justify-items: stretch; gap: 10px; min-width: 275px; }

.method-chip {
  padding: 14px 16px;
  border: 1px solid rgba(31, 103, 110, 0.18);
  border-radius: 16px;
  background: rgba(255, 252, 246, 0.68);
  box-shadow: 0 12px 28px rgba(66, 47, 18, 0.08);
}

.method-chip span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.method-chip strong { font-size: 0.92rem; }

.workflow-grid,
.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(310px, 0.88fr);
  gap: 18px;
  margin-top: 18px;
}

.card {
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.84);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.step-head { display: flex; align-items: flex-start; gap: 13px; }

.step-number {
  display: grid;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--teal);
  color: white;
  font-weight: 800;
}

.step-number.neutral { background: rgba(31, 35, 48, 0.1); color: var(--ink); }
.step-head p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

.dropzone {
  display: grid;
  min-height: 208px;
  margin-top: 20px;
  padding: 28px;
  place-items: center;
  align-content: center;
  gap: 8px;
  border: 2px dashed rgba(31, 103, 110, 0.34);
  border-radius: 19px;
  background: rgba(255, 255, 255, 0.42);
  text-align: center;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.dropzone:hover,
.dropzone.over { border-color: var(--teal); background: rgba(31, 103, 110, 0.07); }
.dropzone.loaded { min-height: 122px; border-style: solid; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone span:not(.drop-icon) { color: var(--muted); font-size: 0.88rem; }

.drop-icon {
  display: inline-flex;
  padding: 7px 11px;
  border-radius: 8px;
  background: rgba(31, 103, 110, 0.12);
  color: var(--teal);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.07em;
}

.upload-foot,
.inline-actions,
.column-actions,
.run-row,
.result-head,
.panel-title,
.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.privacy-note { display: flex; gap: 8px; margin: 14px 0 0; color: var(--muted); font-size: 0.82rem; }
.privacy-note span { color: var(--green); }

.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.sheet-row { grid-template-columns: minmax(0, 1fr) 105px; }

.field { display: grid; gap: 6px; margin-top: 16px; }
.field span { color: var(--muted); font-size: 0.78rem; font-weight: 800; }
.field small { font-weight: 600; }

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus { border-color: rgba(31, 103, 110, 0.55); box-shadow: 0 0 0 3px rgba(31, 103, 110, 0.1); }

.field-hint { min-height: 1.25em; margin: 8px 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.45; }

.primary-button,
.secondary-button,
.text-button,
.icon-button {
  border-radius: 999px;
  font-weight: 800;
}

.primary-button { padding: 11px 18px; border: 1px solid var(--teal); color: white; background: var(--teal); box-shadow: 0 10px 22px rgba(31, 103, 110, 0.24); }
.secondary-button { padding: 10px 14px; border: 1px solid rgba(31, 103, 110, 0.22); color: var(--teal); background: rgba(31, 103, 110, 0.08); }
.text-button { padding: 5px 1px; border: 0; color: var(--teal); background: transparent; font-size: 0.8rem; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); color: var(--ink); background: rgba(31, 35, 48, 0.05); font-size: 1.35rem; line-height: 1; }
button:hover:not(:disabled) { transform: translateY(-1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.inline-actions { align-items: flex-end; margin-top: 17px; }
.library-status { color: var(--muted); font-size: 0.75rem; text-align: right; }
.library-status.online { color: var(--green); }
.library-status.offline { color: var(--gold); }

.method-card { background: rgba(255, 252, 246, 0.78); }
.method-list { margin: 18px 0 0; padding-left: 21px; color: var(--muted); font-size: 0.86rem; line-height: 1.55; }
.method-list li + li { margin-top: 7px; }

.handling-info {
  display: grid;
  grid-template-columns: minmax(220px, 0.34fr) minmax(0, 1fr);
  gap: 22px;
  margin-top: 18px;
  padding: 22px;
  border: 1px solid rgba(31, 103, 110, 0.18);
  border-radius: 24px;
  background: rgba(239, 248, 244, 0.82);
  box-shadow: 0 18px 42px rgba(66, 47, 18, 0.08);
}
.handling-intro { display: flex; align-items: flex-start; gap: 13px; }
.handling-intro p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 0.82rem; line-height: 1.5; }
.handling-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.handling-grid div { padding: 13px 14px; border: 1px solid rgba(31, 103, 110, 0.12); border-radius: 13px; background: rgba(255, 255, 255, 0.48); }
.handling-grid strong { display: block; margin-bottom: 5px; color: var(--teal); font-size: 0.79rem; }
.handling-grid span { display: block; color: var(--muted); font-size: 0.76rem; line-height: 1.48; }

.mapping-card { margin-top: 18px; }
.mapping-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 20px; }
.mapping-panel { padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 255, 255, 0.36); }

.mini-badge {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(31, 35, 48, 0.06);
  font-size: 0.69rem;
  font-weight: 800;
  white-space: nowrap;
}

.column-actions { justify-content: flex-start; margin-top: 9px; }
.column-list { max-height: 260px; margin-top: 9px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, 0.58); }

.column-option { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px; padding: 8px 10px; border-bottom: 1px solid rgba(31, 35, 48, 0.08); font-size: 0.79rem; cursor: pointer; }
.column-option:last-child { border-bottom: 0; }
.column-option:hover { background: rgba(31, 103, 110, 0.05); }
.column-option input { accent-color: var(--teal); }
.column-option em { color: var(--muted); font-size: 0.68rem; font-style: normal; }
.empty-state { margin: 0; padding: 18px; color: var(--muted); font-size: 0.8rem; text-align: center; }

.run-row { margin-top: 20px; padding-top: 17px; border-top: 1px solid var(--line); }
.run-title { margin: 0; font-weight: 800; }

.message { margin-top: 14px; padding: 11px 13px; border: 1px solid rgba(31, 103, 110, 0.17); border-radius: 12px; color: var(--muted); background: rgba(31, 103, 110, 0.06); font-size: 0.82rem; line-height: 1.5; }
.message.error { border-color: rgba(157, 47, 34, 0.22); color: var(--red); background: rgba(157, 47, 34, 0.07); }
.message.warn { border-color: rgba(184, 138, 25, 0.25); color: #7a5b0c; background: rgba(184, 138, 25, 0.09); }
.message.success { border-color: rgba(47, 122, 68, 0.22); color: var(--green); background: rgba(47, 122, 68, 0.07); }

#resultsPanel { margin-top: 28px; }
.result-head { align-items: end; padding: 4px 8px 0; }
.result-head h2 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.3rem); }
.result-downloads { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }

.qc-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.qc-card { display: grid; gap: 5px; padding: 17px; border: 1px solid rgba(255, 255, 255, 0.8); border-radius: 17px; background: rgba(255, 252, 246, 0.86); box-shadow: 0 14px 32px rgba(66, 47, 18, 0.09); }
.qc-card span { color: var(--muted); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.qc-card strong { font-size: 1.24rem; font-variant-numeric: tabular-nums; }
.qc-card em { color: var(--muted); font-size: 0.7rem; font-style: normal; }
.qc-card em.pass { color: var(--green); font-weight: 800; }
.qc-card em.review { color: var(--gold); font-weight: 800; }
.qc-card em.warn { color: var(--red); font-weight: 800; }

.curve-card svg { display: block; width: 100%; height: auto; margin-top: 10px; }
.curve-card svg text { fill: var(--muted); font-family: inherit; font-size: 11px; }
.curve-card svg .gridline { stroke: rgba(31, 35, 48, 0.1); stroke-width: 1; }
.curve-card svg .axis { stroke: rgba(31, 35, 48, 0.3); stroke-width: 1.2; }
.curve-card svg .fit-line { fill: none; stroke: var(--teal); stroke-width: 3; }
.curve-card svg .point { fill: var(--coral); stroke: white; stroke-width: 2; }

.table-wrap { max-width: 100%; margin-top: 13px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-size: 0.68rem; letter-spacing: 0.05em; text-transform: uppercase; }
th:first-child, td:first-child { text-align: left; }
tbody tr:last-child td { border-bottom: 0; }

.preview-card { margin-top: 18px; }

footer { width: min(1180px, calc(100vw - 28px)); margin: 0 auto 26px; color: rgba(31, 35, 48, 0.72); font-size: 0.82rem; line-height: 1.55; }
footer p { margin: 0; }
footer p + p { margin-top: 4px; }

dialog { width: min(700px, calc(100vw - 24px)); max-height: calc(100vh - 28px); overflow: auto; padding: 22px; border: 1px solid rgba(255, 255, 255, 0.88); border-radius: 22px; color: var(--ink); background: #fffaf2; box-shadow: 0 30px 90px rgba(31, 35, 48, 0.28); }
dialog::backdrop { background: rgba(31, 35, 48, 0.46); backdrop-filter: blur(4px); }
.dialog-copy { margin: 10px 0 3px; color: var(--muted); font-size: 0.84rem; line-height: 1.5; }
.dialog-actions { justify-content: flex-end; margin-top: 20px; }

.toast { position: fixed; right: 18px; bottom: 18px; z-index: 1000; max-width: min(390px, calc(100vw - 36px)); padding: 12px 15px; border-radius: 13px; color: white; background: var(--ink); box-shadow: 0 18px 45px rgba(31, 35, 48, 0.28); font-size: 0.84rem; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; align-items: start; }
  .hero-actions { min-width: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workflow-grid, .result-grid, .mapping-grid, .handling-info { grid-template-columns: 1fr; }
  .qc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .shell, footer { width: calc(100vw - 18px); }
  .card { padding: 18px; border-radius: 20px; }
  .hero { padding-top: 26px; }
  .hero-actions, .form-grid.two { grid-template-columns: 1fr; }
  .dropzone { min-height: 178px; padding: 20px; }
  .qc-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .qc-card { padding: 13px; }
  .result-head, .run-row, .upload-foot { align-items: stretch; flex-direction: column; }
  .result-downloads { width: 100%; align-items: stretch; flex-direction: column; }
  .result-downloads button, .run-row .primary-button { width: 100%; }
  .panel-title { align-items: flex-start; }
}
