:root {
  color-scheme: light;
  --ink: #1f2937;
  --ink-heading: #111827;
  --muted: #667085;
  --subtle: #98a2b3;
  --line: #e4e7ec;
  --line-strong: #cfd5df;
  --paper: #ffffff;
  --canvas: #f4f7fb;
  --nav: #111827;
  --nav-hover: #1f2937;

  /* Primary Accent: Professional Tech Blue */
  --blue: #1677ff;
  --blue-hover: #4096ff;
  --blue-press: #0958d9;
  --blue-soft: #eaf3ff;
  --blue-soft-border: #b9d6ff;

  /* Semantic Feedback */
  --green: #079455;
  --green-press: #067647;
  --green-soft: #ecfdf3;
  --green-border: #abefc6;

  --red: #d92d20;
  --red-press: #b42318;
  --red-soft: #fef3f2;
  --red-border: #fecdca;

  --warning: #dc6803;
  --warning-press: #b54708;
  --warning-soft: #fffaeb;
  --warning-border: #fedf89;

  /* Elevation & Borders */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
  font-family: var(--font);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;

  /* Motion Tokens (from motion-web) */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-out-quart: cubic-bezier(0.76, 0, 0.24, 1);
  --spring-snappy: cubic-bezier(0.2, 0.9, 0.3, 1.2);
  --duration-instant: 90ms;
  --duration-fast: 160ms;
  --duration-standard: 280ms;
  --duration-medium: 420ms;
  --shadow-hover: 0 6px 20px rgba(16, 24, 40, 0.08), 0 2px 6px rgba(16, 24, 40, 0.04);
  --shadow-focus: 0 0 0 3px rgba(22, 119, 255, 0.2);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); letter-spacing: 0; }
a { color: inherit; text-decoration: none; text-underline-offset: 3px; }
button, input, select { font: inherit; }
button, a, input, select, label { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
button, input, select { caret-color: var(--blue); }
::selection { background: #cee3ff; color: #0c335e; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid #91caff;
  outline-offset: 2px;
}
[hidden] { display: none !important; }
.sr-only, .skip-link:not(:focus) {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link:focus {
  position: fixed; top: 8px; left: 8px; padding: 10px 14px; z-index: 200;
  background: #fff; border: 1px solid var(--blue); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); font-weight: 600;
}

.icon {
  width: 16px; height: 16px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0;
}

/* App Shell Layout */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
}

/* Sider */
.sider {
  display: flex; flex-direction: column;
  background: var(--nav); color: #d0d5dd;
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
}
.sider-brand {
  height: 64px; padding: 0 18px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 700; font-size: 16px; color: #fff;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  background: var(--blue); color: #fff; box-shadow: 0 4px 12px rgba(22, 119, 255, 0.35);
}
.brand-mark svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; }
.nav-group { padding: 18px 12px 10px; }
.nav-title { color: #8492a6; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin: 0 10px 8px; }
.nav-item {
  display: flex; align-items: center; min-height: 42px; padding: 0 12px;
  border-radius: var(--radius-sm); gap: 10px; font-size: 13px; font-weight: 600;
  color: #d0d5dd; transition: background 0.15s ease, color 0.15s ease;
  background: none; border: none; width: 100%; text-align: left; cursor: pointer;
  position: relative;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(22, 119, 255, 0.3); }
.nav-icon { width: 18px; height: 18px; display: grid; place-items: center; flex-shrink: 0; color: #8492a6; }
.nav-icon svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover .nav-icon, .nav-item.active .nav-icon { color: #fff; }
.nav-item .badge {
  margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 7px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.16); color: #e4e7ec;
}
.nav-item .badge.badge-warn { background: #f04438; color: #fff; font-weight: 700; }

.sider-rules-entry { padding: 0 12px; margin-top: 6px; }
.sider-rule-card {
  width: 100%; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04); padding: 10px 12px;
  display: flex; align-items: center; gap: 10px; text-align: left; color: #e4e7ec;
  transition: all 0.2s ease;
}
.sider-rule-card:hover {
  background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.24);
  transform: translateY(-1px);
}
.sider-rule-icon {
  width: 28px; height: 28px; border-radius: 6px; background: rgba(22, 119, 255, 0.2);
  color: #70aeff; display: grid; place-items: center; flex-shrink: 0;
}
.sider-rule-icon svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; }
.sider-rule-text strong { display: block; font-size: 12px; font-weight: 600; color: #fff; }
.sider-rule-text span { display: block; font-size: 10px; color: #98a2b3; margin-top: 2px; }

.sider-note {
  margin: auto 16px 20px; padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #98a2b3; font-size: 11px; line-height: 1.6;
}
.sider-note > span { color: #d0d5dd; font-size: 11px; font-weight: 600; display: block; margin-bottom: 4px; }
.sider-note p { margin: 0; color: #8492a6; }

/* Main Area */
.app-main { min-width: 0; display: flex; flex-direction: column; }
.header {
  height: 64px; background: var(--paper); border-bottom: 1px solid var(--line);
  padding: 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.breadcrumb .icon { width: 14px; height: 14px; color: var(--subtle); }
.breadcrumb strong { color: var(--ink-heading); font-weight: 600; }

.header-right-tools { display: flex; align-items: center; gap: 12px; }
.rule-action-btn {
  display: inline-flex; align-items: center; gap: 6px; font-weight: 600;
  border-color: #b9d6ff; background: #f5f9ff; color: var(--blue-press);
}
.rule-action-btn:hover {
  background: #eaf3ff; border-color: var(--blue); color: var(--blue-press);
}
.rule-action-btn .icon { stroke-width: 2; width: 14px; height: 14px; }

.scope {
  display: flex; gap: 12px; align-items: center; color: var(--muted);
  font-size: 12px; font-weight: 500; background: #f8fafc;
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line);
}
.scope span + span { position: relative; }
.scope span + span::before {
  content: ""; position: absolute; left: -6px; top: 3px; width: 1px; height: 11px; background: var(--line-strong);
}

.operator-badge {
  display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  color: #344054; padding: 4px 10px; border-radius: 6px; background: #f2f4f7;
}
.op-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

/* The backend controls access; these states keep permissions clear in the workbench. */
.auth-pending > .app, .auth-pending > .skip-link { visibility: hidden; }
.auth-loading { position: fixed; inset: 0; z-index: 300; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--canvas); color: var(--muted); }
.auth-loading strong { color: var(--ink-heading); font-size: 20px; }
.auth-loading p { margin: 12px 0 20px; }
.account-menu { display: flex; align-items: center; gap: 14px; padding-left: 14px; border-left: 1px solid var(--line); }
.account-identity { display: grid; gap: 1px; }
.account-identity strong { color: #344054; font-size: 12px; max-width: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-identity > span { color: var(--muted); font-size: 11px; }
.account-logout { font-size: 12px; white-space: nowrap; }
.session-notice { position: sticky; top: 0; z-index: 110; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 12px 24px; color: #854a0e; background: var(--warning-soft); border-bottom: 1px solid var(--warning-border); line-height: 1.6; }
.session-notice > span { flex: 1 1 340px; }
.session-notice .text-link { white-space: nowrap; color: #0958d9; }
.viewer-notice { color: #184b89; background: var(--blue-soft); border: 1px solid var(--blue-soft-border); padding: 12px 16px; margin: 0 0 20px; border-radius: 6px; line-height: 1.7; }
.viewer-mode .import-panel, .viewer-mode #calculation-modes, .viewer-mode #mode-single-wrap { display: none !important; }
@media (max-width: 1100px) { .account-menu { gap: 10px; padding-left: 10px; } .header-right-tools .scope { display: none; } }
@media (max-width: 650px) { .account-menu { border-left: 0; padding-left: 0; } .account-identity strong { max-width: 72px; } .session-notice { padding: 12px 16px; } }

/* Page Content */
.page { max-width: 1560px; width: 100%; margin: 0 auto; padding: 22px 24px 24px; }

/* Page Heading */
.page-heading {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px;
}
h1 { font-size: 22px; margin: 0; line-height: 1.3; font-weight: 700; color: var(--ink-heading); letter-spacing: -0.2px; }
.page-heading p { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 5px 0 0; }
h2 { font-size: 15px; line-height: 1.4; font-weight: 650; margin: 0; color: var(--ink-heading); }
h3 { font-size: 13px; line-height: 1.4; font-weight: 600; margin: 0; color: var(--ink-heading); }

/* Button Component System */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-xs);
}
.button:active:not(:disabled) { transform: translateY(1px); }
.button:hover:not(:disabled) { transform: translateY(-1px); }

.secondary {
  background: #fff; border-color: var(--line-strong); color: #344054;
}
.secondary:hover {
  border-color: #91caff; color: var(--blue-press); background: #f9fbff;
  box-shadow: 0 2px 6px rgba(22, 119, 255, 0.1);
}
.primary {
  background: var(--blue); color: #fff; border-color: var(--blue);
  min-width: 116px; box-shadow: 0 2px 8px rgba(22, 119, 255, 0.28);
}
.primary:hover:not(:disabled) {
  background: var(--blue-press); border-color: var(--blue-press);
  box-shadow: 0 4px 12px rgba(22, 119, 255, 0.38);
}
.primary:disabled {
  color: #8c9ba5; border-color: #dce3eb; background: #e8eef5;
  box-shadow: none; transform: none;
}
.compact { min-height: 30px; font-size: 12px; padding: 0 10px; border-radius: 5px; }
.compact .icon { width: 14px; height: 14px; }

/* 4-Card Metric Row (KPI 看板) */
.metric-row {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px;
}
.metric-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; box-shadow: var(--shadow-xs); transition: all 0.2s ease;
}
.metric-card:hover {
  border-color: #d0d5dd; box-shadow: var(--shadow-sm); transform: translateY(-1px);
}
.metric-info { display: flex; flex-direction: column; min-width: 0; }
.metric-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.metric-value {
  font-family: var(--mono); font-size: 22px; line-height: 1.2; font-weight: 700;
  color: var(--ink-heading); margin-top: 4px; font-variant-numeric: tabular-nums;
}
.metric-sub { font-size: 11px; color: var(--subtle); margin-top: 3px; white-space: nowrap; }

.metric-mark {
  width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center;
  flex-shrink: 0; font-weight: 700;
}
.metric-mark svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.9; }
.metric-mark.blue { background: var(--blue-soft); color: var(--blue); }
.metric-mark.green { background: var(--green-soft); color: var(--green); }
.metric-mark.red { background: var(--red-soft); color: var(--red); }
.metric-mark.orange { background: var(--warning-soft); color: var(--warning); }

.text-success { color: var(--green) !important; }
.text-danger { color: var(--red) !important; }
.text-primary { color: var(--blue) !important; }

/* Panels */
.panel {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); box-shadow: var(--shadow-xs); overflow: hidden;
}
.section-heading {
  min-height: 54px; padding: 12px 18px; display: flex; align-items: center;
  justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line);
  background: #fdfefe;
}
.section-title-wrap { display: flex; align-items: center; gap: 8px; }
.section-badge {
  font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 4px;
  background: var(--blue-soft); color: var(--blue-press); border: 1px solid var(--blue-soft-border);
}
.section-note { font-size: 12px; color: var(--muted); }

/* Import Grid */
.import-grid {
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.9fr);
  gap: 20px; padding: 18px 20px;
}
.upload-form { min-width: 0; }
.controls {
  display: grid; grid-template-columns: minmax(140px, 0.8fr) minmax(210px, 1.2fr);
  gap: 18px; margin-bottom: 14px;
}

/* Month Field & Season Tag Linkage */
.month-field { display: block; font-size: 12px; font-weight: 600; color: #344054; }
.field-label-group { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.season-badge {
  font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
  border: 1px solid transparent; transition: all 0.2s ease;
}
.season-badge.season-off {
  background: #f2f4f7; color: #475467; border-color: #e4e7ec;
}
.season-badge.season-peak {
  background: var(--warning-soft); color: var(--warning-press); border-color: var(--warning-border);
  animation: pulse-badge 2s infinite ease-in-out;
}
@keyframes pulse-badge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 104, 3, 0.3); }
  50% { box-shadow: 0 0 0 3px rgba(220, 104, 3, 0.15); }
}

.required { color: var(--red); font-weight: 700; margin-left: 2px; }
select {
  width: 100%; height: 36px; background: #fff; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 0 10px; color: #344054; font-size: 13px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.14); outline: 0; }
.month-field select { display: block; margin-top: 7px; }
.field-help {
  display: block; font-size: 11px; font-weight: 400; color: var(--muted);
  margin-top: 6px; line-height: 1.5;
}

/* Mode Switch */
fieldset { padding: 0; border: 0; margin: 0; min-width: 0; }
legend { padding: 0; font-size: 12px; font-weight: 600; color: #344054; }
.mode-switch {
  display: flex; margin-top: 7px; height: 36px;
  background: #f2f4f7; padding: 2px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
}
.mode-switch label { position: relative; display: flex; cursor: pointer; flex: 1; min-width: 0; }
.mode-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
.mode-switch span {
  display: flex; align-items: center; justify-content: center; padding: 0 10px;
  border-radius: 4px; background: transparent; color: var(--muted); font-size: 12px;
  font-weight: 550; flex: 1; transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.mode-switch input:checked + span {
  background: #fff; color: var(--blue-press); font-weight: 600;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.1);
}

.notice {
  font-size: 12px; line-height: 1.6; background: #fffaeb; border: 1px solid #fedf89;
  border-radius: var(--radius-sm); color: #934a07; padding: 8px 12px; margin: 0 0 12px;
}
.maintenance-notice { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 12px 16px; margin-bottom: 20px; font-size: 13px; }
.maintenance-notice strong { flex-shrink: 0; }

/* Dropzone & Upload */
.upload-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.upload-label h3 { font-size: 12px; font-weight: 600; }
.text-link {
  display: inline-flex; align-items: center; gap: 5px; color: var(--blue-press);
  font-size: 12px; font-weight: 550; border: 0; background: transparent; padding: 2px 0;
  line-height: 1.5; text-align: left; transition: color 0.15s ease;
}
.text-link .icon { width: 14px; height: 14px; }
.text-link:hover { text-decoration: underline; color: var(--blue); }
.danger-link { color: var(--red); }
.danger-link:hover { color: var(--red-press); }

.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center;
  justify-content: center; border: 2px dashed #b9d6ff; border-radius: var(--radius);
  background: #f8fbff; min-height: 146px; cursor: pointer; gap: 6px; padding: 18px 16px;
  text-align: center; transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}
.dropzone:hover {
  background: #f0f7ff; border-color: var(--blue);
  box-shadow: 0 4px 16px rgba(22, 119, 255, 0.08);
  transform: translateY(-1px);
}
.dropzone.dragover {
  background: #eaf3ff; border-color: var(--blue); border-style: solid;
  box-shadow: 0 0 0 4px rgba(22, 119, 255, 0.18);
  transform: scale(1.008);
}
.dropzone.selected {
  border-style: solid; border-color: #70aeff; background: #f0f7ff;
}
.dropzone-icon-wrap {
  width: 44px; height: 44px; border-radius: 50%; background: #eaf3ff;
  display: grid; place-items: center; margin-bottom: 2px;
  transition: transform 0.2s ease;
}
.dropzone:hover .dropzone-icon-wrap { transform: scale(1.08); }
.upload-symbol {
  width: 26px; height: 26px; stroke: var(--blue); fill: none; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.dropzone strong {
  max-width: 100%; font-size: 13px; color: var(--blue-press); font-weight: 600;
  overflow-wrap: anywhere;
}
#file-hint { font-size: 11px; color: var(--muted); line-height: 1.5; }
#file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }

.file-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 30px; margin-top: 6px;
}
.file-actions p { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.55; }
#file-clear { flex-shrink: 0; font-weight: 600; }

.upload-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px; gap: 12px;
}
.input-tip {
  font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px;
}
.tip-icon { width: 13px; height: 13px; stroke: var(--subtle); fill: none; stroke-width: 2; }
.error-message {
  color: var(--red); font-size: 12px; line-height: 1.6; margin: 10px 0 0;
  padding: 8px 10px; background: var(--red-soft); border-radius: var(--radius-sm);
  border: 1px solid var(--red-border); overflow-wrap: anywhere;
}

/* 4-Step Pipeline Stepper */
.pipeline {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px 14px; min-width: 0; display: flex; flex-direction: column;
  background: #fafcff;
}
.pipeline-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.version-label {
  font-size: 11px; font-weight: 600; color: var(--blue-press);
  background: var(--blue-soft); padding: 1px 6px; border-radius: 4px;
}
.pipeline-task {
  margin: 8px 0 14px; color: var(--ink-heading); font-size: 12px; font-weight: 600;
  line-height: 1.5; overflow-wrap: anywhere;
}
.stage-steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.stage-steps li {
  display: flex; align-items: center; gap: 12px; position: relative;
  min-height: 46px; padding: 0 0 12px; transition: all 0.2s ease;
}
.stage-steps li:not(:last-child)::after {
  content: ""; position: absolute; left: 11px; width: 2px; top: 30px; bottom: 2px;
  background: var(--line); transition: background 0.3s ease;
}
.stage-steps li > div {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-width: 0; flex: 1;
}
.stage-indicator {
  display: flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  flex-shrink: 0; border: 1.5px solid #d0d5dd; border-radius: 50%; font-size: 11px;
  font-weight: 700; color: #667085; background: #fff; font-variant-numeric: tabular-nums;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}
.stage-label { font-size: 12px; font-weight: 550; color: #344054; }
.stage-state { font-size: 11px; color: var(--muted); text-align: right; }

/* Stepper Micro-animations */
.is-active .stage-indicator {
  background: var(--blue); color: #fff; border-color: var(--blue);
  animation: pulse-ring 1.8s infinite cubic-bezier(0.4, 0, 0.6, 1);
}
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(22, 119, 255, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(22, 119, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 119, 255, 0); }
}
.is-active .stage-label, .is-active .stage-state {
  color: var(--blue-press); font-weight: 600;
}
.is-complete .stage-indicator {
  background: var(--green-soft); color: var(--green); border-color: var(--green-border);
  animation: pop-check 0.3s ease forwards;
}
@keyframes pop-check {
  0% { transform: scale(0.85); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
.is-complete .stage-state { color: var(--green); font-weight: 500; }
.is-complete::after { background: var(--green-border) !important; }

.is-failed .stage-indicator {
  background: var(--red-soft); color: var(--red); border-color: var(--red-border);
}
.is-failed .stage-state { color: var(--red); font-weight: 600; }

.stage-summary {
  font-size: 12px; line-height: 1.65; margin: 4px 0 12px; color: var(--muted);
  overflow-wrap: anywhere;
}
.pipeline-footnote {
  display: flex; gap: 8px; align-items: center; margin-top: auto; padding-top: 12px;
  border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); line-height: 1.5;
}
.progress {
  height: 5px; background: #eef2f6; border-radius: 999px; overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}
.progress-bar {
  height: 100%; width: 0; background: var(--blue);
  border-radius: 999px;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.stage-progress-label {
  font-size: 11px; margin: 7px 0 10px; color: var(--ink); font-weight: 500;
}
.success-definition {
  font-size: 11px; line-height: 1.6; color: var(--muted); margin: 8px 0 10px;
}

/* Tasks History Panel */
.tasks-panel { margin-top: 18px; }
.tasks-heading { display: flex; align-items: center; gap: 8px; }
.count {
  font-size: 11px; font-weight: 700; line-height: 20px; min-width: 22px; text-align: center;
  border-radius: 999px; background: #f2f4f7; color: #344054; padding: 0 6px;
  font-variant-numeric: tabular-nums;
}
.task-filters {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
  border-bottom: 1px solid var(--line); background: #fff;
}
.search-field { position: relative; width: 280px; max-width: 100%; }
.search-field .icon {
  position: absolute; left: 10px; top: 9px; color: var(--subtle); width: 16px; height: 16px;
  pointer-events: none;
}
.search-field input {
  width: 100%; height: 35px; padding: 0 10px 0 34px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); font-size: 12px; color: var(--ink); background: #fff;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.search-field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12); outline: 0; }
.search-field input::placeholder { color: var(--subtle); }
.filter-field { min-width: 140px; }
.filter-field select { height: 35px; font-size: 12px; }
.filter-note { font-size: 11px; color: var(--muted); margin-left: auto; }
.tasks-panel > .notice { margin: 12px 18px; }

/* Tasks Table */
.table-wrap { width: 100%; overflow-x: auto; }
.tasks-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.tasks-table th, .tasks-table td {
  text-align: left; padding: 12px 14px; font-size: 12px; vertical-align: middle;
  border-bottom: 1px solid var(--line);
}
.tasks-table th {
  padding-top: 12px; padding-bottom: 12px; background: #f8fafc; color: #475467;
  font-weight: 600; white-space: nowrap; font-size: 12px;
}
.tasks-table th:nth-child(1) { width: 26%; }
.tasks-table th:nth-child(2) { width: 10%; }
.tasks-table th:nth-child(3) { width: 18%; }
.tasks-table th:nth-child(4) { width: 12%; }
.tasks-table th:nth-child(5) { width: 14%; }
.tasks-table th:nth-child(6) { width: 20%; }
.th-hint { font-size: 10px; font-weight: 400; color: var(--subtle); margin-left: 3px; }

.task { transition: background 0.16s ease; }
.task:hover { background: #f8fbff; }
.task.selected, .task.is-selected { background: #f0f7ff; }
.task-file-name {
  display: block; border: 0; background: transparent; font: inherit; font-weight: 600;
  color: #1d2939; padding: 1px 0; max-width: 100%; text-align: left; line-height: 1.5;
  overflow-wrap: anywhere; transition: color 0.15s ease;
}
.task-file-name:hover { color: var(--blue-press); text-decoration: underline; }
.task-meta {
  color: var(--muted); font-size: 11px; margin-top: 3px; line-height: 1.5; overflow-wrap: anywhere;
}
.task-counts {
  display: flex; gap: 10px; flex-wrap: wrap; font-size: 11px; color: var(--muted);
  line-height: 1.6; font-variant-numeric: tabular-nums;
}
.task-counts span { white-space: nowrap; }
.task-counts strong { font-weight: 650; font-size: 12px; color: var(--ink); font-family: var(--mono); }
.task-counts span:nth-child(2) strong { color: var(--green); }
.task-counts span:nth-child(3) strong { color: var(--red); }

/* Status Pills */
.status {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 20px;
  padding: 0 8px; color: #475467; background: #f2f4f7; border: 1px solid transparent;
}
.status.completed { color: var(--green); background: var(--green-soft); border-color: var(--green-border); }
.status.partial { color: var(--warning); background: var(--warning-soft); border-color: var(--warning-border); }
.status.rows_failed, .status.failed { color: var(--red); background: var(--red-soft); border-color: var(--red-border); }
.status.running, .status.queued { color: var(--blue-press); background: var(--blue-soft); border-color: var(--blue-soft-border); }

/* Task Actions - Keep pure table-cell layout on td to eliminate any deformation */
.tasks-table td.task-actions {
  display: table-cell !important;
  vertical-align: middle;
  white-space: nowrap;
  padding: 10px 14px;
}
.tasks-table td.task-actions > * {
  vertical-align: middle;
  margin-right: 6px;
}
.tasks-table td.task-actions > *:last-child {
  margin-right: 0;
}
.row-action {
  border: 1px solid var(--line-strong); padding: 0 10px; border-radius: 4px;
  font-size: 12px; font-weight: 500; white-space: nowrap; display: inline-flex;
  align-items: center; justify-content: center; gap: 4px; height: 28px; min-height: 28px;
  line-height: 26px;
  transition: all 0.16s ease; text-decoration: none; cursor: pointer;
  background: #ffffff; color: #344054; box-shadow: none; box-sizing: border-box;
}
.row-action:hover { transform: translateY(-1px); border-color: var(--blue); color: var(--blue-press); background: #f8fbff; }
.row-action:active { transform: translateY(0); }

.row-action.action-success {
  background: #edfcf2; color: #027a48; border-color: #a6f4c5;
}
.row-action.action-success:hover {
  background: #d3f8df; border-color: #73e2a3; color: #05603a;
}

.row-action.action-danger {
  background: #fef3f2; color: #b42318; border-color: #fecdca;
}
.row-action.action-danger:hover {
  background: #fee4e2; border-color: #fda29b; color: #912018;
}

.row-action.action-detail {
  background: #ffffff; color: #344054; border-color: var(--line-strong);
}
.row-action.action-detail:hover {
  background: #f8fafc; border-color: #98a2b3; color: #1d2939;
}

.task-actions .task-meta { font-size: 11px; color: var(--muted); margin: 0; }

/* Task Details Accordion Animation */
.task-detail td {
  background: #fcfcfd; padding: 0 18px 16px; border-bottom: 1px solid var(--line);
}
.task-detail.has-errors td { background: #fffdfa; border-color: #fedf89; }
.task-detail-content {
  font-size: 12px; line-height: 1.7; color: var(--ink); padding-top: 14px;
  animation: slideFadeDown 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes slideFadeDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.task-message {
  margin: 0 0 8px; font-weight: 600; font-size: 13px; color: var(--ink-heading); overflow-wrap: anywhere;
}
.task-detail.has-errors .task-message { color: #b54708; }

.task-detail-errors {
  background: #ffffff; border: 1px solid #fedf89; border-left: 3px solid var(--warning);
  border-radius: var(--radius-sm); padding: 10px 14px; margin: 8px 0 10px;
  box-shadow: 0 1px 3px rgba(220, 104, 3, 0.06);
}
.task-detail-errors ul {
  padding-left: 18px; margin: 4px 0 6px; color: #7a3e08; font-weight: 500;
}
.task-detail-errors li { margin: 3px 0; overflow-wrap: anywhere; }
.task-detail-errors .task-meta { margin: 6px 0 0; color: #8492a6; font-size: 11px; }

.task-result-amounts.single-amounts { margin: 8px 0 18px; }
.task-result-amounts dd { color: var(--ink-heading); }
.task-result-facts { display: flex; flex-wrap: wrap; gap: 12px 28px; margin: 0 0 16px; }
.task-result-facts > div { min-width: 100px; max-width: 100%; }
.task-result-facts dt { color: var(--muted); }
.task-result-facts dd { margin: 3px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.task-result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.task-result-actions .button { min-height: 36px; font-size: 12px; }
.task-recovery { list-style: none; margin: 14px 0; padding: 0; }
.task-recovery li { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 8px 0; }
.task-recovery strong { color: #934a07; }
.task-repair-note { margin: 6px 0 0; color: #7a3e08; }
.task-file-info { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; }
.task-file-info summary { cursor: pointer; color: var(--muted); width: fit-content; font-weight: 500; }
.task-file-info .task-trace { border-top: 0; }
.task-file-info .task-meta { overflow-wrap: anywhere; }
.task-file-info .task-id { color: var(--muted); }

/* Subtle Trace Footer for System Traceability */
.task-trace {
  display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 12px 0 6px; font-size: 11px;
  padding-top: 10px; border-top: 1px dashed var(--line); color: var(--subtle);
}
.task-trace > div { display: flex; gap: 6px; min-width: 0; max-width: 100%; }
.task-trace dt { color: var(--subtle); flex-shrink: 0; }
.task-trace dd { margin: 0; overflow-wrap: anywhere; font-weight: 500; color: #667085; }

.task-id {
  margin: 6px 0 0; font-size: 11px; color: var(--subtle); overflow-wrap: anywhere;
  font-family: var(--mono);
}
.copy-id-btn { font-size: 11px; color: var(--blue); padding: 0 4px; font-weight: 500; }

/* Empty Table State */
.empty-row td { padding: 0; }
.empty {
  display: flex; align-items: center; flex-direction: column; justify-content: center;
  min-height: 160px; padding: 24px 16px; text-align: center;
}
.empty-symbol {
  width: 36px; height: 36px; stroke: var(--subtle); stroke-width: 1.6; fill: #f8fafc;
  stroke-linecap: round; stroke-linejoin: round; margin-bottom: 10px;
}
.empty strong { color: #344054; font-size: 13px; font-weight: 600; }
.empty p { margin: 6px 0 0; font-size: 12px; line-height: 1.65; color: var(--muted); }

/* Table Footer & Pagination */
.table-footer {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  gap: 10px 14px; padding: 12px 18px; color: var(--muted); font-size: 12px;
}
.task-pagination { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.task-pagination .button { min-height: 30px; padding: 0 10px; font-size: 12px; }
.page-footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px;
  font-size: 11px; color: var(--subtle); padding-top: 18px; line-height: 1.6;
}

/* ==========================================================================
   Rule Caliber Drawer (规则口径滑出抽屉)
   ========================================================================== */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, 0.45);
  backdrop-filter: blur(2px); opacity: 0; pointer-events: none;
  transition: opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 120;
}
.drawer-mask.show { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(580px, 94vw); background: #ffffff;
  box-shadow: -14px 0 36px rgba(16, 24, 40, 0.16);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 121; display: flex; flex-direction: column;
}
.drawer.show { transform: translateX(0); }

.drawer-head {
  min-height: 64px; padding: 0 22px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #fdfefe;
}
.drawer-head h2 { font-size: 16px; font-weight: 700; color: var(--ink-heading); margin: 0; }
.drawer-subtitle { font-size: 11px; color: var(--muted); margin-top: 2px; display: block; }
.drawer-close-btn {
  width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--muted); font-size: 20px; line-height: 1;
  display: grid; place-items: center; padding: 0; transition: all 0.15s ease;
}
.drawer-close-btn:hover { background: #f2f4f7; color: var(--ink-heading); }

.drawer-body {
  padding: 20px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 20px;
}
.rule-section { display: flex; flex-direction: column; gap: 8px; }
.rule-title-wrap { display: flex; align-items: center; gap: 8px; }
.rule-badge {
  font-size: 10px; font-weight: 700; font-family: var(--mono);
  background: var(--blue-soft); color: var(--blue-press); padding: 1px 6px; border-radius: 4px;
}
.rule-section h3 { font-size: 14px; font-weight: 700; color: #1d2939; margin: 0; }
.rule-intro { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.6; }

.rule-box {
  background: #f8fafc; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 12px; line-height: 1.65; color: #344054;
}
.rule-box.highlight-box {
  background: #fffbf5; border-color: #fedf89; color: #7a3e08;
}
.rule-box.highlight-box p { margin: 2px 0; }
.box-hint { font-size: 11px; color: var(--muted); margin-top: 6px !important; }

.rule-list { margin: 0; padding-left: 18px; }
.rule-list li { margin: 6px 0; }
.rule-list code {
  font-family: var(--mono); background: #eef2f6; padding: 1px 4px; border-radius: 3px; font-size: 11px;
}

.rule-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
.rule-mini-table { width: 100%; border-collapse: collapse; font-size: 11px; text-align: left; }
.rule-mini-table th, .rule-mini-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.rule-mini-table th { background: #f8fafc; color: var(--muted); font-weight: 600; white-space: nowrap; }
.rule-mini-table tr:last-child td { border-bottom: 0; }

.drawer-foot {
  border-top: 1px solid var(--line); padding: 14px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #fdfefe;
}
.drawer-foot-note { font-size: 11px; color: var(--subtle); font-family: var(--mono); }

/* ==========================================================================
   Floating Toast Notification
   ========================================================================== */
.toast {
  position: fixed; right: 24px; bottom: 24px;
  min-width: 260px; max-width: 380px; background: #ffffff;
  border: 1px solid #b9d6ff; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 12px 16px;
  display: flex; align-items: center; gap: 12px; z-index: 200;
  transform: translateY(20px); opacity: 0; pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease;
}
.toast.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
.toast-icon-wrap {
  width: 28px; height: 28px; border-radius: 50%; background: var(--green-soft);
  color: var(--green); display: grid; place-items: center; flex-shrink: 0;
}
.toast-icon-wrap svg { width: 16px; height: 16px; stroke-width: 2.2; }
.toast-content { display: flex; flex-direction: column; min-width: 0; }
.toast-title { font-size: 13px; font-weight: 600; color: var(--ink-heading); }
.toast-text { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ==========================================================================
   Dual Mode & Panes Styling
   ========================================================================== */
.pane-view { display: flex; flex-direction: column; gap: 20px; }
.pane-view[hidden] { display: none !important; }

.segmented {
  position: relative;
  display: inline-flex; align-items: center; background: #eef2f6;
  padding: 3px; border-radius: var(--radius); gap: 2px; border: 1px solid var(--line);
}
.seg-indicator {
  position: absolute;
  top: 3px; left: 3px;
  height: calc(100% - 6px);
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.12), 0 1px 2px rgba(16, 24, 40, 0.06);
  transition: transform var(--duration-standard) var(--ease-out-expo), width var(--duration-standard) var(--ease-out-expo);
  pointer-events: none;
  z-index: 1;
}
.seg-btn {
  position: relative; z-index: 2;
  border: none; background: transparent !important; padding: 6px 14px; font-size: 13px; font-weight: 600;
  color: var(--muted); border-radius: var(--radius-sm); cursor: pointer;
  transition: color var(--duration-fast) ease; white-space: nowrap;
}
.seg-btn:hover:not(.active) { color: var(--ink-heading); }
.seg-btn.active { color: var(--blue-press); }

/* Value Update Pulse Animation (motion-web tactile reaction) */
@keyframes value-pulse {
  0% { transform: scale(1); filter: brightness(1); }
  35% { transform: scale(1.035); filter: brightness(1.12); }
  100% { transform: scale(1); filter: brightness(1); }
}
.val-pulsing {
  display: inline-block;
  animation: value-pulse var(--duration-standard) var(--ease-out-back);
}

/* ==========================================================================
   Single-Item Live Calculator Layout (Enhanced Handfeel)
   ========================================================================== */
.single-layout {
  display: grid; grid-template-columns: minmax(0, 1fr);
  gap: 12px; align-items: start;
}
.single-form {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 12px;
  transition: box-shadow var(--duration-standard) var(--ease-out-expo), border-color var(--duration-fast) ease;
}
.single-form:focus-within {
  border-color: #b9d6ff;
  box-shadow: var(--shadow-md);
}
.form-section { border-bottom: 1px solid #f2f4f7; padding-bottom: 16px; }
.form-section:last-of-type { border-bottom: none; padding-bottom: 0; }
.form-section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.form-section-head h3, .form-section h3 { font-size: 13px; font-weight: 700; color: var(--ink-heading); margin: 0; }
.preset-links { display: flex; gap: 6px; }
.preset-links .text-btn {
  background: #f0f4f9; border: 1px solid #e2e8f0; padding: 3px 8px; color: var(--blue-press);
  font-size: 12px; font-weight: 600; cursor: pointer; border-radius: 4px;
  transition: all var(--duration-fast) var(--ease-out-expo);
}
.preset-links .text-btn:hover {
  background: var(--blue-soft);
  border-color: var(--blue-soft-border);
  color: var(--blue-press);
  transform: translateY(-1px);
}
.preset-links .text-btn:active {
  transform: scale(0.96);
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: #344054; }
.field .req { color: var(--red); }
.field .input {
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}
.field .input:focus {
  border-color: var(--blue);
  box-shadow: var(--shadow-focus);
}
.dim-note { display: block; font-size: 11px; color: var(--muted); margin-top: 6px; }
.single-form-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 14px; border-top: 1px solid var(--line); margin-top: 4px; gap: 12px;
}
.subtle-note { font-size: 11px; color: var(--muted); }
.btn-group { display: flex; gap: 8px; }

/* Single Result Card with Fluid Elevation */
.single-result {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm); position: static;
  transition: transform var(--duration-fast) var(--ease-out-expo), box-shadow var(--duration-fast) var(--ease-out-expo);
}
.single-result-head {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 14px;
}
.verdict-tag-wrap { display: flex; align-items: center; gap: 8px; }
.verdict-tag-wrap strong { font-size: 14px; color: var(--ink-heading); }
.mono-badge {
  font-family: var(--mono); font-size: 11px; background: #f2f4f7;
  padding: 3px 8px; border-radius: 4px; color: #344054; font-weight: 600;
  transition: background var(--duration-fast) ease;
}
.single-big-num { margin-bottom: 14px; }
.single-big-num .label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.single-big-num .big-val {
  font-size: 26px; font-weight: 800; letter-spacing: -0.5px;
  transition: color var(--duration-fast) ease;
}
.single-tier-box {
  display: flex; justify-content: space-between; align-items: center;
  background: #f8fafc; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 12px; margin-bottom: 14px;
}
.single-tier-box .label { display: block; font-size: 10px; color: var(--muted); }
.single-tier-box strong { font-size: 12px; color: var(--ink-heading); }
.season-pill {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: #e0f2fe; color: #0369a1;
  transition: all var(--duration-standard) var(--ease-out-expo);
}
.season-pill.peak { background: #fef3f2; color: #b42318; }
.single-kpi-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px; margin-bottom: 16px; background: #f9fafb; padding: 10px;
  border-radius: var(--radius-sm); border: 1px solid #edf2f7;
}
.kpi-mini { display: flex; flex-direction: column; gap: 2px; }
.kpi-mini .kpi-label { font-size: 10px; color: var(--muted); }
.kpi-mini strong { font-size: 13px; font-weight: 700; color: var(--ink-heading); }
.waterfall-title, .scenarios-title { font-size: 12px; font-weight: 700; color: var(--ink-heading); margin-bottom: 8px; }

/* Waterfall Cascade Animation (motion-web pattern #tight-grid stagger) */
@keyframes wf-slide-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.waterfall-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.wf-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 8px; border-radius: 4px; background: #f8fafc; font-size: 11px;
  animation: wf-slide-in var(--duration-standard) var(--ease-out-expo) both;
  transition: transform var(--duration-fast) var(--ease-out-expo), background var(--duration-fast) ease;
}
.wf-item:hover {
  background: #f1f5f9;
  transform: translateX(2px);
}
.wf-item.wf-highlight { background: #eaf3ff; font-weight: 700; color: #0c4a6e; }
.wf-item.wf-highlight:hover { background: #e2eeff; }
.wf-item:nth-child(1) { animation-delay: 20ms; }
.wf-item:nth-child(2) { animation-delay: 45ms; }
.wf-item:nth-child(3) { animation-delay: 70ms; }
.wf-item:nth-child(4) { animation-delay: 95ms; }
.wf-item:nth-child(5) { animation-delay: 120ms; }
.wf-item:nth-child(6) { animation-delay: 145ms; }
.wf-item:nth-child(7) { animation-delay: 170ms; }
.wf-item:nth-child(8) { animation-delay: 195ms; }
.wf-name { color: #475467; }
.wf-val { font-family: var(--mono); font-weight: 600; }

.scenarios-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sc-card {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; display: flex; flex-direction: column; gap: 2px;
  transition: transform var(--duration-fast) var(--ease-out-expo), box-shadow var(--duration-fast) var(--ease-out-expo), border-color var(--duration-fast) ease;
}
.sc-card:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.06);
}
.sc-card.best { border-color: #a7f3d0; background: #f0fdf4; }
.sc-label { font-size: 11px; color: var(--muted); }
.sc-val { font-size: 14px; font-weight: 700; font-family: var(--mono); }

/* ==========================================================================
   Modals & DingTalk Mock Card (Orchestrated Overlays)
   ========================================================================== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, 0.45);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 999; opacity: 0; pointer-events: none;
  transition: opacity var(--duration-standard) var(--ease-out-expo);
}
.modal-mask.open { opacity: 1; pointer-events: auto; }
.modal-dialog {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -46%) scale(0.96);
  width: 92%; max-width: 520px; background: #fff; border-radius: var(--radius-lg);
  box-shadow: 0 20px 48px -8px rgba(16, 24, 40, 0.18), 0 8px 16px -4px rgba(16, 24, 40, 0.08);
  z-index: 1000; opacity: 0; pointer-events: none;
  transition: transform var(--duration-medium) var(--ease-out-expo), opacity var(--duration-standard) ease;
  display: flex; flex-direction: column; max-height: 90vh;
  border: 1px solid var(--line);
}
.modal-dialog.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink-heading); }
.modal-close-btn { background: none; border: none; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.modal-close-btn:hover { color: var(--ink-heading); }
.modal-body { padding: 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-field { display: flex; flex-direction: column; gap: 5px; }
.modal-field label { font-size: 12px; font-weight: 600; color: #344054; }
.toggle-group { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: #f9fafb; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.ding-card-mock { background: #f4f6fa; border: 1px solid #dcdfe6; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.ding-card-header { padding: 12px 14px; background: #fff; border-bottom: 1px solid #ebeef5; display: flex; flex-direction: column; gap: 4px; position: relative; }
.ding-card-badge { display: inline-block; width: fit-content; font-size: 10px; padding: 2px 6px; border-radius: 3px; background: #fee4e2; color: #b42318; font-weight: 700; }
.ding-card-time { position: absolute; top: 12px; right: 14px; font-size: 11px; color: #909399; }
.ding-card-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; font-size: 13px; color: #303133; }
.ding-stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; background: #fff; padding: 10px; border-radius: 6px; border: 1px solid #ebeef5; text-align: center; }
.ding-stat-row span { display: block; font-size: 11px; color: #909399; margin-bottom: 2px; }
.ding-stat-row strong { font-size: 16px; font-weight: 700; }
.ding-note-box { background: #fef0f0; border-left: 3px solid #f56c6c; padding: 8px 10px; font-size: 12px; color: #7f1d1d; border-radius: 0 4px 4px 0; }
.ding-card-footer { padding: 10px 14px; background: #fff; border-top: 1px solid #ebeef5; }

.task-filters-inline { display: flex; gap: 8px; align-items: center; }
.compact-input { padding: 5px 8px; font-size: 12px; }
.compact-select { padding: 5px 8px; font-size: 12px; }

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (min-width: 1700px) {
  .import-grid { grid-template-columns: minmax(0, 1.5fr) minmax(350px, 0.9fr); gap: 24px; }
}

@media (max-width: 1190px) {
  .app { grid-template-columns: 196px minmax(0, 1fr); }
  .sider-brand { padding: 0 14px; font-size: 15px; }
  .nav-item { padding: 0 10px; font-size: 12px; }
  .page { padding: 20px 18px 18px; }
  .header { padding: 0 18px; }
  .metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .import-grid { grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr); gap: 16px; padding: 16px; }
  .controls { gap: 14px; grid-template-columns: minmax(110px, 0.7fr) minmax(170px, 1.3fr); }
  .pipeline { padding: 14px 14px 12px; }
  .tasks-table { min-width: 820px; }
}

@media (max-width: 980px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sider { display: none; }
  .header { height: 56px; }
  .page-heading p { max-width: 580px; }
  .metric-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .import-grid { grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr); }
  .single-layout { grid-template-columns: minmax(0, 1fr); }
  .single-result { position: static; }
}

@media (max-width: 760px) {
  .header { padding: 0 16px; }
  .scope { font-size: 11px; gap: 10px; }
  .scope span:nth-child(2) { display: none; }
  .page { padding: 18px 16px; }
  .page-heading { align-items: flex-start; gap: 12px; flex-direction: column; }
  h1 { font-size: 20px; }
  .page-heading p { font-size: 12px; }
  .heading-actions { width: 100%; flex-direction: column; align-items: stretch; gap: 8px; }
  .heading-actions > .segmented { width: 100%; }
  .heading-actions > .segmented .seg-btn { flex: 1; text-align: center; }
  .heading-actions > .button { width: 100%; }
  .metric-row { grid-template-columns: minmax(0, 1fr); }
  .import-grid { grid-template-columns: minmax(0, 1fr); }
  .pipeline { padding: 14px; }
  .stage-steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; }
  .stage-steps li { padding-bottom: 2px; min-height: 40px; align-items: flex-start; }
  .stage-steps li:not(:last-child)::after { display: none; }
  .stage-steps li > div { flex-direction: column; align-items: flex-start; gap: 3px; }
  .stage-indicator { margin-top: 2px; }
  .stage-summary { margin-top: 10px; }
  .pipeline-footnote { padding-top: 9px; }
  .section-note { font-size: 11px; }
}

@media (max-width: 680px) {
  .page-heading { flex-direction: column; margin-bottom: 14px; }
  .section-heading { padding: 12px 14px; }
  .section-note { display: none; }
  .breadcrumb { font-size: 11px; gap: 5px; }
  .scope { font-size: 10px; }
  .table-wrap { overflow: visible; }
  .tasks-table, .tasks-table tbody { display: block; min-width: 0; }
  .tasks-table thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap;
  }
  .tasks-table tr.task {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 14px;
    border-bottom: 1px solid var(--line); gap: 12px 16px;
  }
  .tasks-table .task td { display: block; padding: 0; border: 0; font-size: 12px; }
  .tasks-table .task td::before {
    content: attr(data-label); display: block; color: var(--muted); font-size: 10px; margin-bottom: 4px;
  }
  .tasks-table .task td:first-child { grid-column: 1 / -1; }
  .tasks-table .task td:first-child::before, .tasks-table .task td:last-child::before { display: none; }
  .tasks-table .task td:last-child {
    grid-column: 1 / -1; border-top: 1px solid #eef1f5; padding-top: 8px;
  }
  .task-file-name { font-size: 13px; }
  .task-meta { font-size: 11px; }
  .task-counts { gap: 8px; }
  .task-actions > * { margin-right: 16px; }
  .row-action { min-height: 30px; padding-top: 5px; padding-bottom: 5px; }
  .task-detail, .task-detail td, .empty-row, .empty-row td { display: block; width: 100%; }
  .task-detail td { padding-left: 14px; padding-right: 14px; }
  .task-filters { flex-wrap: wrap; padding: 12px 14px; gap: 9px; }
  .search-field { width: 100%; flex-basis: 100%; }
  .filter-field { min-width: 150px; }
  .filter-note { font-size: 10px; }
  .table-footer { padding: 11px 14px; font-size: 10px; }
  .page-footer { font-size: 10px; }
  .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .single-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-filters-inline { flex-direction: column; align-items: stretch; width: 100%; }
  .task-filters-inline .compact-input, .task-filters-inline .compact-select { width: 100% !important; }
}

@media (max-width: 420px) {
  .page { padding: 16px 12px; }
  .header { padding: 0 12px; }
  h1 { font-size: 19px; }
  .controls { grid-template-columns: 110px minmax(0, 1fr); gap: 12px; }
  .import-grid { padding: 12px; }
  .mode-switch span { font-size: 11px; padding: 0 6px; }
  .field-help { font-size: 10px; }
  .upload-label .text-link { font-size: 11px; }
  .file-actions p { font-size: 10px; }
  .input-tip { font-size: 10px; }
  .upload-footer .button { min-width: 100px; }
  .pipeline { padding: 12px; }
  .stage-steps { gap: 8px 12px; }
  .stage-label { font-size: 11px; }
  .stage-state { font-size: 10px; }
  .stage-summary { font-size: 11px; }
  .filter-note { margin-left: 0; }
  .drawer { width: 100vw; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .scenarios-grid { grid-template-columns: minmax(0, 1fr); }
  .single-form-footer { flex-direction: column; align-items: stretch; gap: 10px; }
  .btn-group { width: 100%; justify-content: flex-end; }
}

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

/* 01: backend-driven single item form and auditable result. */
.single-form h2, .single-result h2 { margin: 0; font-size: 18px; }
.single-form .hint, .single-result .hint { color: var(--muted); font-size: 13px; line-height: 1.65; }
.single-form .form-section h3 { margin-bottom: 8px; font-size: 14px; }
.single-optional { margin: 0; }
.single-optional summary, .single-source summary, .single-input-summary summary { cursor: pointer; font-weight: 600; padding-block: 8px; }
.single-identity, .single-source, #single-status, #single-error { overflow-wrap: anywhere; line-height: 1.7; }
.single-amounts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 18px 0; font-variant-numeric: tabular-nums; border-block: 1px solid var(--line); }
.single-amounts > div { display: flex; flex-direction: column; justify-content: space-between; gap: 10px; padding: 18px 14px; }
.single-amounts > div + div { border-left: 1px solid var(--line); }
.single-amounts dd { margin: 0; font-weight: 700; font-size: 18px; overflow-wrap: anywhere; }
.single-amounts dt { color: var(--muted); font-size: 13px; }
.single-warnings { padding-left: 20px; line-height: 1.8; }
.single-source { margin-bottom: 18px; }
#single-error { padding: 12px; color: var(--red); background: var(--red-soft); border-radius: 8px; }
@media (max-width: 600px) {
  .single-form .input, .single-form .select { font-size: 16px; }
  .single-result { min-width: 0; }
}

.single-form .input {
  width: 100%; min-width: 0; min-height: 38px; padding: 8px 11px;
  color: var(--ink); background: var(--paper); border: 1px solid var(--line);
  border-radius: 6px; font: inherit; font-size: 14px; box-sizing: border-box;
}
.single-form .input::placeholder { color: #667085; opacity: 1; }
.single-form .input:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
@media (max-width: 600px) { .single-form .input { font-size: 16px; min-height: 44px; } }

/* 01 has one focused surface: inputs first, results after completion. */
/* 01 has one focused surface: inputs first, results after completion. */
#manualPane { gap: 14px; }
#manualPane > .page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin: 0 0 14px 0;
}
.calculation-modes { display: inline-flex; align-items: center; gap: 12px; margin-left: auto; }
#manual-pane-tasks-slot { width: 100%; margin-top: 14px; }
.mode-tabs {
  display: inline-flex;
  align-items: center;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 8px;
  gap: 2px;
  border: 1px solid var(--line);
}
.mode-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 96px;
  min-height: 32px;
  padding: 5px 13px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  transition: all 160ms cubic-bezier(0.16, 1, 0.3, 1);
}
.mode-tab .icon { width: 16px; height: 16px; flex-shrink: 0; }
.mode-tab:hover:not(.active) { color: var(--ink); background: rgba(255, 255, 255, 0.7); }
.mode-tab.active {
  color: var(--blue-press);
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
}
.single-form-head, .single-section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; }
.single-form-head { padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.single-form-head .hint, .single-section-heading .hint { margin: 0; }
.single-form-head h2 { font-size: 15px; font-weight: 650; margin: 0; }
.single-section-heading { margin-bottom: 8px; }
.single-form .single-section-heading h3 { font-size: 13px; font-weight: 600; color: #475467; margin: 0; }
.single-form .form-section { padding-bottom: 10px; }
.single-form .single-operating-section { padding-bottom: 0; border-bottom: 0; }
.single-form .form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 16px; }
.single-form .field label { font-size: 12px; font-weight: 600; color: #475467; margin-bottom: 4px; }
.single-form .select { width: 100%; min-width: 0; height: 38px; }
.single-form-footer { margin: 0; padding-top: 10px; display: flex; justify-content: flex-end; }
.single-form-footer .button { min-height: 36px; }
.single-feedback { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; border: 1px solid var(--blue-soft-border); background: var(--blue-soft); color: #184b89; padding: 8px 14px; border-radius: 6px; font-size: 13px; }
#single-status { margin: 0; }
.single-result-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.single-result-actions .button { min-height: 38px; }
.single-input-summary { font-size: 13px; }
#single-assumptions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 14px; background: var(--canvas); border-radius: 6px; }
#single-assumptions dt { color: var(--muted); font-size: 12px; }
#single-assumptions dd { margin: 4px 0 0; overflow-wrap: anywhere; }
@media (max-width: 1100px) {
  .single-amounts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .single-amounts > div { border-bottom: 1px solid var(--line); }
  .single-amounts > div + div { border-left: 0; }
}
@media (max-width: 760px) {
  .calculation-modes { flex-wrap: wrap; gap: 10px; }
  .mode-tabs { width: 100%; }
  .mode-tab { flex: 1; min-width: 0; min-height: 36px; padding: 6px 10px; }
  .single-form { padding: 14px; }
  .single-form .form-grid, #single-assumptions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .single-amounts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .single-result-head { align-items: flex-start; gap: 12px; }
  .single-result-head .status { flex-shrink: 0; }
  .single-form-footer { flex-direction: column; align-items: stretch; gap: 10px; }
}
@media (max-width: 420px) {
  .single-product-section .form-grid { grid-template-columns: minmax(0, 1fr); }
  .single-amounts { grid-template-columns: minmax(0, 1fr); }
  .single-amounts > div { flex-direction: row; flex-wrap: wrap; padding-inline: 0; }
  .single-result { padding: 14px; }
  .single-result-head { flex-direction: column; }
  .single-result-actions .button { flex: 1; }
}

/* Keep the working action in the first viewport; history lives in its own pane. */
.nav-state { margin-left: auto; color: #a7b0c0; font-size: 10px; white-space: nowrap; }
.nav-secondary { border-top: 1px solid rgba(255, 255, 255, 0.07); }
#manualPane .calculation-modes { gap: 10px; }
#manualPane .import-grid { padding: 14px 16px; gap: 16px; }
#manualPane .dropzone { min-height: 98px; padding: 10px 14px; }
#manualPane .dropzone-icon-wrap { width: 32px; height: 32px; }
#manualPane .upload-symbol { width: 22px; height: 22px; }
#manualPane .import-panel .section-heading { min-height: 50px; }
.source-label { display: block; font-size: 13px; color: var(--blue-press); margin-bottom: 4px; }
.source-options { font-size: 11px; color: var(--muted); margin-top: 4px; }
.source-options p { margin: 6px 0; }
.source-options .mode-switch { margin-top: 6px; }
.stage-downloads { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.stage-downloads .text-link { font-size: 12px; }
#taskPane .metric-row { margin: 0; }
#taskPane .tasks-panel { margin: 0; }
#exceptions-error, #exceptions-warning { margin: 12px 18px; }
.activity-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.activity-table th { padding: 12px 16px; text-align: left; background: #f8fafc; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); }
.activity-table td { vertical-align: top; padding: 16px; font-size: 12px; overflow-wrap: anywhere; border-bottom: 1px solid var(--line); line-height: 1.7; }
.activity-table td p { margin: 5px 0 0; }
.activity-table th:nth-child(1) { width: 23%; }
.activity-table th:nth-child(2) { width: 28%; }
.activity-table th:nth-child(3) { width: 24%; }
.activity-table th:nth-child(4) { width: 25%; }
.activity-error-code { display: inline; color: var(--red); font-size: 11px; font-weight: 600; }
.service-empty { min-height: 270px; gap: 12px; }
.service-empty p { max-width: 570px; margin: 0; }
.service-empty h2 { margin: 0; }
.single-form-head { align-items: center; }
.single-form-head > div { display: grid; gap: 2px; }
.viewer-mode #manualPane .calculation-modes { display: none; }
@media (max-width: 1100px) {
  .activity-table { min-width: 780px; }
}
@media (max-width: 760px) {
  #manualPane .import-grid { padding: 12px; }
  #manualPane .dropzone { min-height: 104px; }
  .service-empty { min-height: 240px; }
}

/* The same workspaces stay reachable when the desktop sidebar collapses. */
.mobile-workspace-nav { display: none; }
@media (max-width: 980px) {
  .mobile-workspace-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
  .mobile-workspace-nav label { flex-shrink: 0; color: var(--muted); font-size: 12px; font-weight: 600; }
  .mobile-workspace-nav .select { flex: 1; min-width: 0; max-width: 360px; min-height: 40px; font-size: 14px; background-color: var(--paper); }
}
@media (max-width: 600px) { .mobile-workspace-nav .select { font-size: 16px; min-height: 44px; } }
@media (max-width: 980px) {
  #exceptionPane .table-wrap { overflow-x: auto; max-width: 100%; }
}
