:root {
  --ink: #172522;
  --ink-soft: #3e4e4a;
  --muted: #687771;
  --line: #d9e0dd;
  --line-strong: #bdcac5;
  --paper: #f4f7f5;
  --white: #ffffff;
  --green: #176b57;
  --green-dark: #114f41;
  --green-pale: #eaf4f0;
  --blue-pale: #edf3f7;
  --blue: #35677d;
  --amber-pale: #fff8e7;
  --amber: #936918;
  --red: #a33e3e;
  --shadow: 0 8px 24px rgba(25, 54, 45, 0.06);
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; min-width: 320px; color: var(--ink); }
button, input { font: inherit; }
a { color: var(--green-dark); }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.topbar { background: #173f36; color: var(--white); border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.topbar-inner { width: min(1180px, calc(100% - 48px)); height: 60px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { min-width: 0; display: inline-flex; align-items: center; gap: 11px; color: var(--white); text-decoration: none; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid rgba(255, 255, 255, 0.46); color: #dff4eb; font-size: 10px; font-weight: 800; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 700; }
.model-state { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; color: #d6e5e0; font-size: 12px; }
.status-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #66d2aa; box-shadow: 0 0 0 3px rgba(102, 210, 170, 0.12); }
.model-version { padding-left: 8px; border-left: 1px solid rgba(255, 255, 255, 0.2); color: #a9c0b8; font-variant-numeric: tabular-nums; }

main { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding-top: 34px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 48px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 10px; line-height: 1.3; font-weight: 800; letter-spacing: 0; }
h1 { margin: 0; font-size: 27px; line-height: 1.2; letter-spacing: 0; }
.page-description { margin: 9px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.model-metrics { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(112px, 1fr)); border: 1px solid var(--line); background: var(--white); }
.model-metrics div { min-width: 112px; padding: 11px 14px; display: flex; flex-direction: column-reverse; gap: 3px; border-left: 1px solid var(--line); }
.model-metrics div:first-child { border-left: 0; }
.model-metrics dt { color: var(--muted); font-size: 10px; line-height: 1.35; }
.model-metrics dd { margin: 0; color: var(--ink); font-size: 17px; line-height: 1.2; font-weight: 750; font-variant-numeric: tabular-nums; }

.workspace { overflow: hidden; background: var(--white); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); }
.workspace-toolbar { min-height: 71px; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); background: #fbfcfb; }
.workspace-toolbar h2 { margin: 0 0 5px; font-size: 15px; line-height: 1.3; }
.workspace-toolbar p { min-height: 16px; max-width: 620px; margin: 0; overflow: hidden; color: var(--muted); font-size: 11px; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.button { min-height: 40px; padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 4px; font-size: 12px; line-height: 1.2; font-weight: 700; text-decoration: none; cursor: pointer; transition: border-color 140ms ease, background 140ms ease, color 140ms ease, box-shadow 140ms ease; }
.button:focus-visible, .icon-button:focus-visible, .dropzone:focus-within { outline: 3px solid rgba(23, 107, 87, 0.2); outline-offset: 2px; }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button-secondary { border-color: var(--line-strong); background: var(--white); color: var(--ink); }
.button-secondary:hover:not(:disabled) { border-color: #8ca49a; background: #f7faf8; }
.button-primary { min-width: 132px; background: var(--green); color: var(--white); }
.button-primary:hover:not(:disabled) { background: var(--green-dark); }
.button-ghost { color: var(--ink-soft); background: transparent; border-color: transparent; }
.button-ghost:hover:not(:disabled) { background: #edf2ef; }
.button-dark { background: var(--ink); color: var(--white); }
.button-dark:hover { background: #263b35; }
.button-full { width: 100%; margin-top: 15px; }

form { padding: 22px 22px 0; }
.workbench-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(290px, 0.75fr); gap: 22px; align-items: stretch; }
.input-column { min-width: 0; }
.dropzone { min-height: 214px; padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 1px dashed #9dafaa; background: #f9fbfa; text-align: center; cursor: pointer; transition: 140ms ease; }
.dropzone:hover, .dropzone.dragging { border-color: var(--green); background: var(--green-pale); }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-icon { width: 43px; height: 43px; margin-bottom: 3px; display: grid; place-items: center; border-radius: 50%; background: var(--green-pale); color: var(--green); }
.upload-icon svg { width: 24px; height: 24px; }
.dropzone strong { font-size: 14px; line-height: 1.35; }
.dropzone > span:not(.upload-icon):not(.choose-file) { color: var(--muted); font-size: 11px; line-height: 1.5; }
.choose-file { min-height: 34px; margin-top: 6px; padding: 0 13px; display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--white); color: var(--ink); font-size: 11px; font-weight: 700; }
.file-ready-panel { min-height: 82px; padding: 14px 15px; align-items: center; gap: 13px; border: 1px solid #9bbeb2; background: var(--green-pale); }
.file-ready-panel:not([hidden]) { display: flex; }
.file-icon { width: 40px; height: 44px; flex: 0 0 auto; display: grid; place-items: center; background: var(--white); border: 1px solid #c9ddd6; color: var(--green); }
.file-ready-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 5px; }
.file-ready-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; line-height: 1.35; }
.file-ready-copy small { color: var(--muted); font-size: 11px; }
.icon-button { width: 36px; height: 36px; padding: 0; flex: 0 0 auto; display: grid; place-items: center; border: 0; border-radius: 4px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover { background: rgba(23, 107, 87, 0.1); color: var(--ink); }
.format-strip { margin-top: 10px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); }
.format-strip > div { min-width: 0; padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.format-strip > div + div { border-left: 1px solid var(--line); }
.format-label { flex: 0 0 auto; padding: 2px 5px; background: var(--blue-pale); color: var(--blue); font-size: 10px; font-weight: 700; }
code { color: #53625d; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 10px; overflow-wrap: anywhere; }
.data-notice { margin-top: 12px; padding: 11px 13px; display: flex; align-items: flex-start; gap: 9px; border-left: 3px solid #d5a947; background: var(--amber-pale); color: #66501f; }
.data-notice svg { flex: 0 0 auto; color: var(--amber); }
.data-notice p { margin: 0; font-size: 11px; line-height: 1.55; }

.preflight-panel { min-width: 0; padding: 17px; border: 1px solid var(--line); background: #fafcfb; }
.panel-heading { min-height: 42px; padding-bottom: 13px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.panel-heading h3 { margin: 0 0 4px; font-size: 13px; line-height: 1.3; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.35; }
.state-badge { min-width: 66px; min-height: 24px; padding: 4px 8px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--white); font-size: 10px; font-weight: 700; white-space: nowrap; }
.state-badge[data-state="ready"], .state-badge[data-state="success"] { border-color: #a8cbbf; background: var(--green-pale); color: var(--green-dark); }
.state-badge[data-state="warning"] { border-color: #e0c884; background: var(--amber-pale); color: #795912; }
.state-badge[data-state="error"] { border-color: #e2aaaa; background: #fff0f0; color: var(--red); }
.preflight-list { margin: 4px 0 0; }
.preflight-list > div { min-height: 43px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid #e6ebe9; }
.preflight-list dt { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.preflight-list dt svg { width: 15px; height: 15px; color: #81908a; }
.preflight-list dd { max-width: 52%; margin: 0; overflow-wrap: anywhere; text-align: right; color: var(--ink); font-size: 11px; line-height: 1.35; font-weight: 700; font-variant-numeric: tabular-nums; }
.preflight-message { min-height: 37px; margin: 12px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.preflight-message.is-error { color: var(--red); }
.preflight-message.is-success { color: var(--green-dark); }
.form-footer { min-height: 72px; margin-top: 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); }
#run-state { min-width: 0; color: var(--red); font-size: 11px; line-height: 1.45; }
#run-state.is-running { color: var(--green-dark); }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; flex: 0 0 auto; }

.result-panel { border-top: 1px solid var(--line); background: #fbfdfc; }
.result-heading { min-height: 77px; padding: 16px 22px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.result-title-group { min-width: 0; display: flex; align-items: center; gap: 12px; }
.success-mark { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--green-pale); color: var(--green); }
.result-title-group h3 { margin: 0 0 4px; font-size: 14px; line-height: 1.3; }
.result-title-group p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.result-stats { margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--white); }
.result-stats > div { min-width: 0; padding: 14px 18px; border-left: 1px solid var(--line); }
.result-stats > div:first-child { border-left: 0; }
.result-stats dt { margin-bottom: 5px; color: var(--muted); font-size: 10px; }
.result-stats dd { margin: 0; font-size: 16px; font-weight: 750; font-variant-numeric: tabular-nums; }
.preview-section { padding: 18px 22px 22px; }
.preview-heading { margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.preview-heading h4 { margin: 0; font-size: 12px; }
.preview-heading span { color: var(--muted); font-size: 10px; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); background: var(--white); }
table { width: 100%; min-width: 650px; border-collapse: collapse; table-layout: fixed; text-align: left; }
th, td { height: 38px; padding: 8px 12px; border-bottom: 1px solid var(--line); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
th { background: #f3f6f4; color: var(--ink-soft); font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }
td { color: #485650; font-variant-numeric: tabular-nums; }
.empty-cell { text-align: center; color: var(--muted); }

.scope-band { padding: 30px 2px 36px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 34px; }
.scope-band article { min-width: 0; }
.scope-band h2 { margin: 0 0 7px; font-size: 12px; line-height: 1.35; }
.scope-band p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.65; }
footer { width: min(1180px, calc(100% - 48px)); min-height: 58px; margin: 0 auto; padding: 17px 2px 24px; display: flex; justify-content: space-between; gap: 24px; border-top: 1px solid var(--line); color: #7a8782; font-size: 10px; overflow-wrap: anywhere; }

@media (max-width: 920px) {
  .page-heading { align-items: flex-start; flex-direction: column; gap: 18px; }
  .model-metrics { width: 100%; }
  .model-metrics div { min-width: 0; }
  .workbench-grid { grid-template-columns: minmax(0, 1fr); }
  .preflight-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 22px; align-items: start; }
  .panel-heading, .preflight-list { grid-column: 1 / -1; }
  .preflight-message { margin-bottom: 0; }
  .button-full { align-self: center; }
}

@media (max-width: 640px) {
  .topbar-inner, main, footer { width: calc(100% - 32px); }
  .topbar-inner { height: 56px; }
  .brand-name { font-size: 13px; }
  .model-state > span:not(.status-dot):not(.model-version) { display: none; }
  .model-version { padding-left: 0; border-left: 0; }
  main { padding-top: 24px; }
  h1 { font-size: 23px; }
  .page-description { font-size: 12px; }
  .model-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .model-metrics div { padding: 10px; }
  .model-metrics dt { min-height: 27px; }
  .model-metrics dd { font-size: 15px; }
  .workspace-toolbar { align-items: flex-start; }
  .workspace-toolbar .button { width: 40px; padding: 0; flex: 0 0 auto; font-size: 0; }
  .workspace-toolbar .button svg { width: 18px; height: 18px; }
  form { padding: 16px 16px 0; }
  .dropzone { min-height: 190px; padding: 20px 14px; }
  .format-strip { grid-template-columns: 1fr; }
  .format-strip > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .preflight-panel { display: block; padding: 15px; }
  .preflight-message { min-height: 0; margin-bottom: 12px; }
  .form-footer { min-height: 112px; padding: 15px 0; align-items: stretch; flex-direction: column; gap: 10px; }
  #run-state:empty { display: none; }
  .form-actions { width: 100%; }
  .form-actions .button-ghost { padding-left: 10px; padding-right: 10px; }
  .form-actions .button-primary { flex: 1; }
  .result-heading { padding: 15px 16px; align-items: flex-start; flex-direction: column; }
  .result-heading .button { width: 100%; }
  .result-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-stats > div:nth-child(3) { border-left: 0; }
  .result-stats > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .preview-section { padding: 16px; }
  .scope-band { grid-template-columns: 1fr; gap: 22px; }
  footer { flex-direction: column; gap: 6px; }
}

@media (max-width: 380px) {
  .topbar-inner, main, footer { width: calc(100% - 24px); }
  .brand-mark { width: 30px; height: 30px; }
  .model-metrics dt { font-size: 9px; }
  .model-metrics dd { font-size: 14px; }
  .workspace-toolbar { padding-left: 15px; padding-right: 15px; }
  .preflight-list dd { max-width: 48%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
