:root {
  color-scheme: light;
  --canvas: #f4f3ef;
  --surface: #ffffff;
  --surface-soft: #f8f8f5;
  --ink: #17201f;
  --muted: #697573;
  --line: #dfe3df;
  --line-strong: #cbd2cd;
  --brand: #087f6d;
  --brand-dark: #075e53;
  --brand-soft: #e7f4f0;
  --amber: #aa6b08;
  --amber-soft: #fff3d8;
  --coral: #bd4b3f;
  --coral-soft: #fcebe7;
  --shadow: 0 14px 35px rgba(29, 45, 41, 0.08);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a, input, select, textarea { outline-offset: 3px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(8, 127, 109, 0.22); }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.58; }

.app-header { border-bottom: 1px solid rgba(203, 210, 205, 0.9); background: rgba(255, 255, 255, 0.88); }
.header-inner { width: min(1420px, calc(100% - 48px)); height: 72px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 8px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 800; }
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-size: 15px; line-height: 1.2; }
.brand-copy span { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.header-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }

.shell { width: min(1420px, calc(100% - 48px)); margin: 0 auto; padding: 40px 0 56px; }
.page-intro { display: flex; justify-content: space-between; align-items: flex-end; gap: 48px; padding: 0 4px 30px; }
.eyebrow, .detail-kicker { margin: 0 0 10px; color: var(--brand); font-size: 11px; font-weight: 800; text-transform: uppercase; }
h1 { max-width: 760px; margin: 0; font-size: 38px; line-height: 1.2; font-weight: 760; }
.intro-copy { max-width: 720px; margin: 12px 0 0; color: var(--muted); font-size: 15px; line-height: 1.7; }
.pipeline { display: flex; gap: 0; margin: 0; padding: 0; list-style: none; }
.pipeline li { position: relative; display: grid; min-width: 94px; gap: 5px; padding-left: 30px; color: var(--ink); font-size: 13px; font-weight: 700; }
.pipeline li:not(:first-child)::before { content: ""; position: absolute; left: 0; top: 14px; width: 22px; height: 1px; background: var(--line-strong); }
.pipeline span { color: var(--brand); font-size: 10px; }

.ingest-panel { padding: 24px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.section-heading h2, .sidebar-head h2, .empty-state h2 { margin: 0; font-size: 16px; line-height: 1.3; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.upload-form { display: grid; grid-template-columns: minmax(340px, 1.5fr) minmax(250px, 0.8fr) 152px; gap: 14px; align-items: stretch; }
.file-drop { position: relative; min-width: 0; }
.file-drop input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.file-drop-label { display: grid; height: 100%; min-height: 84px; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 14px 16px; border: 1px dashed var(--line-strong); border-radius: 7px; background: var(--surface-soft); cursor: pointer; transition: border-color 160ms ease, background 160ms ease; }
.file-drop-label:hover, .file-drop.is-dragging .file-drop-label { border-color: var(--brand); background: var(--brand-soft); }
.file-drop.has-file .file-drop-label { border-style: solid; border-color: var(--brand); }
.file-symbol { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 7px; background: var(--brand-soft); color: var(--brand-dark); font-size: 24px; font-weight: 400; }
.file-copy { display: grid; min-width: 0; gap: 5px; }
.file-copy strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.file-copy span, .field-help { color: var(--muted); font-size: 11px; line-height: 1.4; }
.choose-file { color: var(--brand-dark); font-size: 12px; font-weight: 700; }
.field { display: grid; grid-template-rows: auto 42px minmax(22px, auto); gap: 7px; align-content: center; padding: 6px 0; }
.field-label { color: var(--ink); font-size: 12px; font-weight: 700; }
select, input[type="search"], textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink); }
select { padding: 0 12px; }
.primary-action { display: flex; min-height: 84px; align-items: center; justify-content: space-between; align-self: stretch; gap: 12px; border: 1px solid var(--brand); border-radius: 7px; background: var(--brand); color: #fff; padding: 18px; font-size: 14px; font-weight: 750; transition: background 160ms ease, transform 160ms ease; }
.primary-action:hover { background: var(--brand-dark); transform: translateY(-1px); }
.primary-action span:last-child { font-size: 18px; }
.inline-status { min-height: 18px; margin-top: 10px; color: var(--muted); font-size: 12px; }

.workspace { display: grid; grid-template-columns: 330px minmax(0, 1fr); min-height: 680px; margin-top: 20px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.sidebar { min-width: 0; padding: 22px 18px; border-right: 1px solid var(--line); background: var(--surface-soft); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 4px 16px; }
.record-count { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.icon-action, .secondary-action, .primary-small, .copy-action { border-radius: 6px; padding: 8px 11px; font-size: 12px; font-weight: 700; }
.icon-action, .secondary-action, .copy-action { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); }
.icon-action:hover, .secondary-action:hover, .copy-action:hover { border-color: var(--brand); color: var(--brand-dark); }
.search-field { display: block; margin-bottom: 14px; }
input[type="search"] { height: 38px; padding: 0 12px; font-size: 12px; }
.job-list { display: grid; gap: 8px; max-height: 610px; overflow-y: auto; padding-right: 3px; scrollbar-width: thin; }
.job-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; border: 1px solid transparent; border-radius: 7px; background: transparent; transition: border-color 140ms ease, background 140ms ease; }
.job-row:hover { border-color: var(--line); background: var(--surface); }
.job-row.selected { border-color: #b7d8d1; background: var(--surface); box-shadow: inset 3px 0 0 var(--brand); }
.job-open { display: grid; min-width: 0; gap: 9px; padding: 13px 6px 13px 13px; border: 0; background: transparent; color: var(--ink); text-align: left; }
.job-delete { align-self: start; margin: 9px 8px 0 0; border: 0; border-radius: 5px; background: transparent; color: var(--muted); padding: 5px 7px; font-size: 10px; font-weight: 700; }
.job-delete:hover { background: var(--coral-soft); color: var(--coral); }
.job-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.status-badge { display: inline-flex; width: fit-content; align-items: center; border-radius: 999px; padding: 4px 8px; background: var(--amber-soft); color: var(--amber); font-size: 10px; font-weight: 800; line-height: 1; }
.status-completed { background: var(--brand-soft); color: var(--brand-dark); }
.status-failed { background: var(--coral-soft); color: var(--coral); }
.job-date, .job-template { color: var(--muted); font-size: 10px; }
.filename { display: -webkit-box; overflow: hidden; font-size: 13px; font-weight: 720; line-height: 1.45; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.error { color: var(--coral); font-size: 11px; line-height: 1.45; }
.list-empty { padding: 28px 12px; color: var(--muted); font-size: 12px; line-height: 1.6; text-align: center; }

.detail { min-width: 0; padding: 26px 30px 38px; }
.detail-panel { display: grid; gap: 22px; }
.detail-head { display: flex; justify-content: space-between; gap: 28px; align-items: flex-start; min-width: 0; }
.detail-identity { min-width: 0; }
.detail-kicker { margin-bottom: 7px; }
.detail-title { max-width: 720px; margin: 0; font-size: 20px; line-height: 1.35; overflow-wrap: anywhere; }
.detail-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 10px; color: var(--muted); font-size: 11px; }
.download-group { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.download-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.download-links a { border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink); padding: 7px 9px; font-size: 11px; font-weight: 700; text-decoration: none; }
.download-links a:hover { border-color: var(--brand); color: var(--brand-dark); }
.no-download { padding: 6px 0; }
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); }
.tab { position: relative; border: 0; background: transparent; color: var(--muted); padding: 0 1px 12px; font-size: 13px; font-weight: 700; }
.tab::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: transparent; }
.tab:hover, .tab.active { color: var(--ink); }
.tab.active::after { background: var(--brand); }
.tab-panel { display: grid; gap: 12px; }
.output-summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; color: var(--muted); font-size: 11px; }
.output-summary span:first-child { color: var(--ink); font-weight: 750; }
.content-section { overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.content-section header { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.section-index { color: var(--brand); font-size: 10px; font-weight: 800; }
.content-section h3 { margin: 0; font-size: 13px; line-height: 1.35; }
.content-section pre { margin: 0; padding: 17px 18px 20px; white-space: pre-wrap; overflow-wrap: anywhere; color: #2c3634; font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif; font-size: 14px; line-height: 1.8; }
.editor-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.editor-toolbar > div:first-child { display: grid; gap: 3px; }
.editor-toolbar strong { font-size: 13px; }
.editor-toolbar span { color: var(--muted); font-size: 11px; }
.editor-actions { display: flex; gap: 8px; }
.primary-small { border: 1px solid var(--brand); background: var(--brand); color: #fff; }
.primary-small:hover { background: var(--brand-dark); }
.final-editor { min-height: 480px; padding: 18px; resize: vertical; color: #2c3634; font-size: 14px; line-height: 1.8; }
.save-status { min-height: 20px; color: var(--brand-dark); font-size: 11px; }

.empty-state { display: grid; min-height: 560px; place-content: center; justify-items: center; padding: 40px; text-align: center; }
.empty-number { display: grid; width: 54px; height: 54px; margin-bottom: 18px; place-items: center; border: 1px solid #b7d8d1; border-radius: 8px; background: var(--brand-soft); color: var(--brand-dark); font-size: 13px; font-weight: 800; }
.empty-state p { max-width: 420px; margin: 9px 0 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.content-empty { display: grid; justify-items: center; gap: 6px; padding: 80px 24px; border: 1px dashed var(--line-strong); border-radius: 7px; color: var(--muted); text-align: center; }
.content-empty strong { color: var(--ink); font-size: 14px; }
.content-empty span { font-size: 12px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; max-width: min(360px, calc(100vw - 32px)); border: 1px solid #afd5cc; border-radius: 7px; background: var(--ink); color: #fff; box-shadow: 0 16px 34px rgba(23, 32, 31, 0.2); padding: 12px 15px; font-size: 12px; line-height: 1.45; }
.toast-error { border-color: #e1a59d; background: #762f2a; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.hidden { display: none !important; }

@media (max-width: 1020px) {
  .upload-form { grid-template-columns: minmax(0, 1fr) minmax(230px, 0.7fr); }
  .primary-action { min-height: 52px; grid-column: 1 / -1; }
  .workspace { grid-template-columns: 290px minmax(0, 1fr); }
  .detail-head { display: grid; }
  .download-group, .download-links { justify-content: flex-start; }
}

@media (max-width: 760px) {
  .header-inner, .shell { width: min(100% - 24px, 1420px); }
  .header-inner { height: 62px; }
  .header-status { display: none; }
  .shell { padding: 28px 0 38px; }
  .page-intro { display: grid; gap: 22px; padding-bottom: 24px; }
  h1 { font-size: 30px; }
  .pipeline li { min-width: 82px; padding-left: 26px; }
  .pipeline li:not(:first-child)::before { width: 18px; }
  .ingest-panel { padding: 18px; }
  .upload-form { grid-template-columns: 1fr; }
  .primary-action { grid-column: auto; }
  .workspace { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .job-list { max-height: 330px; }
  .detail { padding: 22px 18px 30px; }
  .detail-title { font-size: 18px; }
  .tabs { gap: 18px; overflow-x: auto; }
  .tab { flex: 0 0 auto; }
  .editor-toolbar { display: grid; }
  .editor-actions { justify-content: flex-start; }
}

@media (max-width: 480px) {
  .file-drop-label { grid-template-columns: 38px minmax(0, 1fr); }
  .choose-file { display: none; }
  .pipeline { width: 100%; }
  .pipeline li { min-width: 0; flex: 1; }
  .download-group { display: grid; }
  .output-summary { align-items: flex-start; }
}

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