:root {
  color-scheme: light;
  --ink: #1f2d33;
  --muted: #63737a;
  --line: #c8d2d6;
  --line-soft: #e3e9eb;
  --surface: #ffffff;
  --surface-soft: #f4f7f8;
  --teal: #1e5d70;
  --teal-dark: #164653;
  --orange: #b36b16;
  --green: #1d7a57;
  --red: #b33c3c;
  font-family: "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; color: var(--ink); background: #edf2f3; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
.hidden { display: none !important; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #eaf0f1; }
.login-panel { width: min(420px, 100%); padding: 34px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 18px 45px rgba(30, 60, 70, .12); }
.brand-mark, .brand-symbol { display: grid; place-items: center; background: #fff; overflow: hidden; }
.brand-mark { width: 64px; height: 64px; margin-bottom: 22px; border: 1px solid var(--line); border-radius: 8px; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.eyebrow { margin: 0 0 8px; color: var(--orange); font-size: 12px; letter-spacing: .04em; }
h1 { margin: 0 0 24px; font-size: 25px; line-height: 1.3; font-weight: 700; }
.login-panel label { display: block; margin: 15px 0 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.login-panel input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: #fff; }
.login-panel input:focus, input:focus { outline: 3px solid rgba(36, 115, 137, .18); border-color: var(--teal); }
.form-error { min-height: 20px; margin: 12px 0 0; color: var(--red); font-size: 13px; }

.topbar { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 10px clamp(14px, 3vw, 42px); color: #fff; background: #163f4b; }
.topbar-title, .topbar-actions { display: flex; align-items: center; gap: 12px; }
.brand-symbol { width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.55); border-radius: 4px; }
.brand-symbol img { width: 100%; height: 100%; object-fit: contain; }
.topbar strong { display: block; font-size: 16px; line-height: 1.35; }
.topbar small { display: block; margin-top: 2px; color: #c1d5da; font-size: 11px; }
.user-label { color: #d3e2e5; font-size: 13px; }
.workspace { width: min(1560px, 100%); margin: 0 auto; padding: 14px clamp(10px, 2vw, 28px) 24px; }
.workflow-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.workflow-card { min-width: 0; min-height: 166px; padding: 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.workflow-card legend { padding: 0 5px; color: var(--teal-dark); font-size: 13px; font-weight: 700; }
.inline-row { display: flex; align-items: center; gap: 6px; margin: 8px 0; color: var(--muted); font-size: 12px; }
.inline-row label { flex: 0 0 auto; }
.inline-row input { min-width: 0; width: 100%; height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 3px; color: var(--ink); background: #fff; }
.inline-row span { white-space: nowrap; }
.compact-row { margin: 5px 0; }
.compact-row input { height: 28px; }
.file-button, .secondary-button, .primary-button, .ghost-button { min-height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 3px; border: 1px solid transparent; font-size: 12px; font-weight: 600; }
.file-button, .secondary-button { width: 100%; margin: 5px 0; color: var(--ink); background: #fff; border-color: #aab9be; }
.file-button:hover, .secondary-button:hover { background: #eaf1f3; border-color: var(--teal); }
.primary-button { width: 100%; margin-top: 18px; color: #fff; background: var(--teal); border-color: var(--teal); }
.primary-button:hover { background: var(--teal-dark); }
.ghost-button { padding: 0 12px; color: inherit; background: transparent; border-color: currentColor; }
.ghost-button:hover { background: rgba(255,255,255,.12); }
.login-panel .primary-button { height: 42px; }
.workflow-card input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.step-status { display: block; min-height: 18px; margin-top: 9px; color: var(--muted); font-size: 12px; }
.step-status.good { color: var(--green); }
.step-status.warn { color: var(--orange); }
.muted-note { display: block; color: var(--muted); font-size: 11px; line-height: 1.5; }

.source-strip { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 10px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); font-size: 12px; }
.strip-label { margin-right: 8px; color: var(--muted); }
.source-strip code { color: var(--teal-dark); font-size: 11px; }
.plot-panel, .history-panel, .analysis-panel { margin-top: 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.panel-heading, .results-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 13px; border-bottom: 1px solid var(--line-soft); }
h2 { margin: 0; font-size: 14px; }
.panel-heading span { color: var(--muted); font-size: 11px; }
.plot-wrap { position: relative; min-height: 460px; padding: 6px 10px 10px; }
#contour-canvas { width: 100%; height: 460px; display: block; }
.empty-state { position: absolute; inset: 0; display: grid; place-items: center; color: #8b9aa0; font-size: 13px; pointer-events: none; }
.charts-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 10px; }
.chart-card { min-width: 0; padding: 7px; border: 1px solid var(--line-soft); background: #fcfdfd; }
.chart-title { margin: 0 5px 4px; color: var(--teal-dark); font-size: 12px; font-weight: 700; }
.chart-title span { color: var(--muted); font-weight: 400; }
.chart-card canvas { width: 100%; height: 180px; display: block; }
.results-heading { border-top: 1px solid var(--line-soft); }
.result-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.compact-button { width: auto; min-height: 28px; margin: 0; padding: 0 9px; }
.debug-note { padding: 8px 13px 2px; color: var(--muted); font-size: 11px; }
.debug-table-wrap { max-height: 170px; }
.status-badge { padding: 3px 10px; border-radius: 3px; color: var(--muted); background: #edf1f2; font-size: 12px !important; }
.status-badge.pass { color: var(--green); background: #e3f2ec; }
.status-badge.fail { color: var(--red); background: #f9e6e6; }
.table-wrap { max-height: 188px; overflow: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 11px; }
th, td { height: 31px; padding: 4px 6px; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); text-align: center; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; color: #fff; background: var(--teal); font-weight: 600; }
tbody tr:nth-child(even) { background: #f5f8f8; }
td.pass { color: var(--green); background: #e5f4ed; font-weight: 700; }
td.fail { color: var(--red); background: #fae7e7; font-weight: 700; }
.history-panel { padding-bottom: 5px; }
.history-list { max-height: 160px; overflow: auto; }
.history-row { display: grid; grid-template-columns: 1.1fr 1fr .8fr .8fr; gap: 10px; padding: 8px 13px; border-bottom: 1px solid var(--line-soft); font-size: 11px; }
.history-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.footer { padding: 13px 20px; color: #cbdde1; background: #163f4b; text-align: center; font-size: 11px; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: min(420px, calc(100vw - 40px)); padding: 10px 14px; color: #fff; background: #263f46; border-radius: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 12px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1100px) {
  .workflow-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .charts-grid { grid-template-columns: 1fr; }
  .chart-card canvas { height: 160px; }
}
@media (max-width: 680px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .workflow-grid { grid-template-columns: 1fr; }
  .workflow-card { min-height: auto; }
  .plot-wrap { min-height: 330px; }
  #contour-canvas { height: 330px; }
  .source-strip { display: block; }
  .source-strip > div + div { margin-top: 8px; }
  .history-row { grid-template-columns: 1fr 1fr; }
}
