:root {
  --ink: #14251f;
  --muted: #65736d;
  --line: #dce5df;
  --surface: #ffffff;
  --canvas: #f4f7f5;
  --green: #176b4d;
  --green-dark: #0e5139;
  --green-pale: #e8f4ee;
  --amber: #a25d0b;
  --amber-pale: #fff4dc;
  --red: #a93232;
  --red-pale: #fdecec;
  --blue: #2d5e9d;
  --shadow: 0 10px 32px rgba(20, 37, 31, .07);
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body { min-height: 100vh; margin: 0; background: radial-gradient(circle at 80% -10%, #e7f2eb 0, transparent 34rem), var(--canvas); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--green); }
img { max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .55rem; font-size: clamp(1.65rem, 3vw, 2.35rem); line-height: 1.15; letter-spacing: -.025em; }
h2 { margin-bottom: .45rem; font-size: 1.18rem; }
p { color: var(--muted); line-height: 1.65; }
code { border: 1px solid var(--line); border-radius: 5px; background: #f7faf8; padding: .12rem .36rem; }

.skip-link { position: fixed; z-index: 100; top: -5rem; left: 1rem; padding: .7rem 1rem; background: var(--ink); color: white; }
.skip-link:focus { top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; clip: rect(0, 0, 0, 0); overflow: hidden; white-space: nowrap; }
.muted { color: var(--muted); }
.min-width-zero { min-width: 0; }
.span-2 { grid-column: 1 / -1; }

.topbar { position: sticky; z-index: 30; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 68px; padding: .7rem clamp(1rem, 4vw, 3rem); border-bottom: 1px solid rgba(220,229,223,.9); background: rgba(255,255,255,.9); backdrop-filter: blur(12px); }
.brand { display: inline-flex; align-items: center; gap: .7rem; color: var(--ink); text-decoration: none; }
.brand > span:last-child { display: grid; }
.brand small { color: var(--muted); font-size: .72rem; }
.brand-mark { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 11px; background: var(--green); color: white; font-size: .78rem; font-weight: 800; letter-spacing: .05em; }
.topnav { display: flex; align-items: center; gap: .4rem; }
.topnav > a:not(.button) { padding: .5rem .7rem; color: var(--muted); text-decoration: none; }
.inline-form { display: inline-flex; margin: 0; }

.page-shell { width: min(1520px, 100%); margin: 0 auto; padding: clamp(1rem, 3vw, 2.5rem); }
.page-heading, .section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.page-heading p, .section-heading p { margin-bottom: 0; }
.section-heading.compact { align-items: center; margin-bottom: 1rem; }
.section-heading.compact h2 { margin-bottom: 0; }
.eyebrow { margin-bottom: .35rem !important; color: var(--green); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.stack { display: grid; gap: 1rem; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: .55rem .9rem; border: 1px solid #b9c8c0; border-radius: 9px; background: white; color: var(--ink); cursor: pointer; font-weight: 700; line-height: 1.2; text-decoration: none; transition: border-color .15s, background .15s, transform .15s; }
.button:hover { border-color: #7b9689; background: #f7faf8; }
.button:active { transform: translateY(1px); }
.button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid rgba(45,94,157,.28); outline-offset: 2px; }
.button:disabled { opacity: .5; cursor: not-allowed; }
.button-primary { border-color: var(--green); background: var(--green); color: white; }
.button-primary:hover { border-color: var(--green-dark); background: var(--green-dark); }
.button-danger { border-color: #e7b7b7; color: var(--red); }
.button-quiet { border-color: transparent; background: transparent; }
.button-small { min-height: 34px; padding: .4rem .65rem; font-size: .82rem; }
.button-large { min-height: 50px; padding: .75rem 1.2rem; }
.button-wide { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.text-button { padding: .2rem; border: 0; background: transparent; color: var(--green); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

label { display: grid; gap: .4rem; color: #33463e; font-size: .86rem; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 42px; padding: .62rem .7rem; border: 1px solid #bbc9c1; border-radius: 8px; background: white; color: var(--ink); }
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"] { width: 17px; min-height: 17px; accent-color: var(--green); }

.flash { width: min(900px, calc(100% - 2rem)); margin: 1rem auto 0; padding: .75rem 1rem; border-radius: 8px; }
.flash-info { border: 1px solid #b9d8c8; background: var(--green-pale); }
.flash-error { border: 1px solid #efb9b9; background: var(--red-pale); color: var(--red); }
.inline-alert { padding: .72rem .8rem; border-radius: 7px; font-size: .88rem; }
.inline-alert.danger { border: 1px solid #efb9b9; background: var(--red-pale); color: var(--red); }

.auth-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(340px, .8fr); align-items: center; gap: clamp(2rem, 8vw, 8rem); min-height: calc(100vh - 145px); max-width: 1120px; margin: auto; }
.auth-intro h1 { max-width: 650px; font-size: clamp(2rem, 5vw, 3.8rem); }
.auth-intro > p { max-width: 650px; font-size: 1.03rem; }
.trust-list { display: grid; gap: .65rem; padding: 0; list-style: none; color: #455850; }
.trust-list li::before { content: "✓"; margin-right: .65rem; color: var(--green); font-weight: 900; }
.auth-card { display: grid; gap: 1rem; padding: clamp(1.4rem, 4vw, 2.3rem); }

.hero { display: flex; align-items: center; justify-content: space-between; gap: 2rem; padding: clamp(1.4rem, 4vw, 2.5rem); background: linear-gradient(135deg, white 0%, #edf7f1 100%); }
.hero p { max-width: 720px; margin-bottom: 0; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin: 1rem 0 2rem; }
.metric-grid.compact { margin: 0; }
.metric { display: grid; gap: .35rem; padding: 1.1rem 1.2rem; border: 1px solid var(--line); border-radius: 12px; background: white; }
.metric span { color: var(--muted); font-size: .82rem; }
.metric strong { overflow: hidden; font-size: 1.55rem; text-overflow: ellipsis; white-space: nowrap; }
.metric-warn { border-color: #efd3aa; background: #fffaf2; }

.table-card { overflow: hidden; }
.table-scroll { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { position: sticky; z-index: 2; top: 0; padding: .7rem .8rem; border-bottom: 1px solid var(--line); background: #f5f8f6; color: #506058; text-align: left; white-space: nowrap; }
td { padding: .75rem .8rem; border-bottom: 1px solid #e8eeea; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfb; }
.actions { display: flex; gap: .35rem; justify-content: flex-end; min-width: 180px; }
.strong-link { color: var(--ink); font-weight: 800; text-decoration: none; }
.cell-primary { display: block; min-width: 130px; font-weight: 700; }
td small { display: block; margin-top: .2rem; color: var(--muted); }
.check-cell { width: 36px; min-width: 36px; padding-right: .25rem; }
.result-table { min-width: 1120px; }
.confirmed { color: var(--green); }

.empty-state { padding: clamp(2rem, 8vw, 5rem); text-align: center; }
.empty-state.compact { padding: 1.4rem; }
.empty-state p { margin: .4rem 0 1rem; }

.status { display: inline-flex; align-items: center; width: max-content; min-height: 26px; padding: .25rem .55rem; border-radius: 999px; background: #e8edeb; color: #53645c; font-size: .75rem; font-weight: 800; white-space: nowrap; }
.status-ready, .status-completed, .status-finalized, .status-confirmed { background: var(--green-pale); color: var(--green-dark); }
.status-needs_review, .status-pending, .status-draft { background: var(--amber-pale); color: var(--amber); }
.status-conflict, .status-failed, .status-rejected, .status-blocked { background: var(--red-pale); color: var(--red); }
.status-processing, .status-uploading, .status-running { background: #e9f0fb; color: var(--blue); }

.picker-card, .defaults-card { display: flex; align-items: center; justify-content: space-between; gap: 2rem; padding: clamp(1.2rem, 3vw, 2rem); }
.picker-card p, .defaults-card p { margin-bottom: 0; }
.directory-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.issue-list { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.issue-list:empty::after { content: "未发现异常"; display: block; padding: .8rem; color: var(--green); }
.issue-list li { padding: .7rem .8rem; border-radius: 7px; background: #f5f8f6; color: #45564e; }
.issue-list li.blocking { background: var(--red-pale); color: var(--red); }
.issue-list li.warning { background: var(--amber-pale); color: #80500d; }
.tree-card, #manifest-issues-card, .upload-panel { padding: clamp(1rem, 2.5vw, 1.5rem); }
.manifest-tree { display: grid; gap: .45rem; max-height: 520px; overflow: auto; }
.manifest-tree details { border: 1px solid var(--line); border-radius: 8px; }
.manifest-tree summary { display: flex; gap: .6rem; justify-content: space-between; padding: .7rem .8rem; cursor: pointer; font-weight: 800; }
.manifest-tree ul { display: grid; gap: .35rem; margin: 0; padding: 0 .8rem .8rem 2.2rem; color: #53645c; font-size: .85rem; }
.manifest-tree li { overflow-wrap: anywhere; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
.defaults-card > div { flex: 1; }
.sticky-actions { position: sticky; z-index: 10; bottom: 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.2rem; border: 1px solid #c7d8ce; border-radius: 12px; background: rgba(255,255,255,.95); box-shadow: 0 14px 35px rgba(20,37,31,.15); backdrop-filter: blur(10px); }
.sticky-actions p { margin: 0; }

.progress-line { height: 12px; overflow: hidden; border-radius: 999px; background: #e4ebe7; }
.progress-line span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green), #2d9970); transition: width .2s; }
.upload-summary { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .7rem; margin: .8rem 0; color: var(--muted); }
.pool-progress-list, .file-progress-list { display: grid; gap: .45rem; margin-top: 1rem; }
.pool-progress { display: grid; grid-template-columns: 100px minmax(120px,1fr) 100px; align-items: center; gap: .8rem; font-size: .84rem; }
.pool-progress .mini-track { height: 7px; overflow: hidden; border-radius: 99px; background: #e6ece8; }
.pool-progress .mini-track span { display: block; height: 100%; background: var(--green); }
.file-progress { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem .6rem; border-bottom: 1px solid var(--line); font-size: .8rem; }
.file-progress.failed { color: var(--red); }

.workspace { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: start; gap: 1rem; }
.pool-sidebar { position: sticky; top: 88px; overflow: hidden; }
.sidebar-heading { display: flex; justify-content: space-between; padding: .85rem 1rem; border-bottom: 1px solid var(--line); }
.pool-sidebar nav { display: grid; max-height: calc(100vh - 170px); overflow: auto; }
.pool-sidebar a { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 .5rem; padding: .7rem 1rem; border-bottom: 1px solid #edf1ee; color: var(--ink); text-decoration: none; }
.pool-sidebar a:hover { background: #f2f7f4; }
.pool-sidebar a small { color: var(--muted); }
.status-dot { grid-column: 2; grid-row: 1 / span 2; width: 8px; height: 8px; border-radius: 50%; background: #87968f; }
.status-dot.status-completed, .status-dot.status-ready { background: var(--green); }
.status-dot.status-processing, .status-dot.status-running { background: var(--blue); }
.status-dot.status-failed, .status-dot.status-conflict { background: var(--red); }
.workspace-main > .card, .process-card { padding: 1rem; }
.pipeline { display: grid; grid-template-columns: repeat(10, minmax(65px, 1fr)); gap: .35rem; margin: 0; padding: 0; list-style: none; }
.pipeline li { display: grid; gap: .35rem; justify-items: center; color: var(--muted); font-size: .72rem; text-align: center; }
.pipeline li span { display: grid; width: 28px; height: 28px; place-items: center; border: 2px solid #ced8d2; border-radius: 50%; background: white; font-weight: 800; }
.pipeline li.done { color: var(--green); }
.pipeline li.done span { border-color: var(--green); background: var(--green); color: white; }
.pipeline li.active { color: var(--blue); font-weight: 800; }
.pipeline li.active span { border-color: var(--blue); }
.filterbar { display: flex; gap: .5rem; margin-bottom: .7rem; }
.filterbar label { width: auto; min-width: 160px; }
.filterbar .search-field { flex: 1; }
.pagination { display: flex; justify-content: center; gap: .35rem; margin-top: .9rem; }

.pool-layout { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0,1fr); align-items: start; gap: 1rem; }
.source-panel { position: sticky; top: 88px; padding: 1rem; }
.source-list { display: grid; gap: .5rem; max-height: calc(100vh - 230px); margin: 0; padding: 0; overflow: auto; list-style: none; }
.source-list li { display: grid; gap: .55rem; padding: .65rem; border: 1px solid var(--line); border-radius: 7px; }
.source-list strong, .source-list small { display: block; overflow-wrap: anywhere; }
.source-list small { margin-top: .2rem; color: var(--muted); }
.pool-layout .stack > .card { padding: 1rem; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 1rem; }
.image-grid article { display: grid; gap: .6rem; padding: .7rem; border: 1px solid var(--line); border-radius: 9px; }
.image-grid img { width: 100%; height: 130px; border-radius: 6px; background: #edf1ef; object-fit: contain; }

.drawer-backdrop { position: fixed; z-index: 49; inset: 0; background: rgba(13,24,19,.32); }
.drawer { position: fixed; z-index: 50; top: 0; right: 0; width: min(500px, 100%); height: 100vh; overflow: auto; border-left: 1px solid var(--line); background: white; box-shadow: -20px 0 50px rgba(20,37,31,.18); transform: translateX(102%); transition: transform .2s ease; }
.drawer.open { transform: translateX(0); }
.drawer-heading, .dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.drawer-heading h2, .dialog-heading h2 { margin: 0; }
.drawer-heading button, .dialog-heading > button { width: 36px; height: 36px; border: 0; border-radius: 50%; background: #eef3f0; cursor: pointer; font-size: 1.5rem; }
.drawer-content { display: grid; gap: 1rem; padding: 1.2rem; }
.evidence-card { padding: .8rem; border: 1px solid var(--line); border-radius: 8px; }
.evidence-card dl { display: grid; grid-template-columns: 90px 1fr; gap: .35rem .6rem; margin: .7rem 0 0; font-size: .85rem; }
.evidence-card dt { color: var(--muted); }
.evidence-card dd { margin: 0; overflow-wrap: anywhere; }
.excerpt { margin: .7rem 0 0; padding: .7rem; border-left: 3px solid var(--green); background: #f4f8f5; color: #33463e; white-space: pre-wrap; }

dialog { width: min(760px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); padding: 0; overflow: auto; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 24px 80px rgba(20,37,31,.28); }
dialog::backdrop { background: rgba(13,24,19,.45); }
.edit-dialog form { padding-bottom: 1rem; }
.row-form { padding: 1rem 1.2rem; }
.dialog-actions { display: flex; justify-content: end; gap: .5rem; padding: .5rem 1.2rem; }
.preview-dialog { width: min(1000px, calc(100% - 2rem)); }
.preview-content { min-height: 180px; padding: 1rem; }
.preview-content img, .preview-content iframe { display: block; width: 100%; max-height: 75vh; border: 0; object-fit: contain; }
.preview-content pre { overflow: auto; white-space: pre-wrap; }
.toast-region { position: fixed; z-index: 100; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; width: min(360px, calc(100% - 2rem)); }
.toast { padding: .8rem 1rem; border: 1px solid #bdd5c8; border-radius: 9px; background: white; box-shadow: var(--shadow); }
.toast.error { border-color: #e8b8b8; color: var(--red); }

@media (max-width: 980px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .workspace, .pool-layout { grid-template-columns: 1fr; }
  .pool-sidebar, .source-panel { position: static; }
  .pool-sidebar nav { display: flex; max-height: none; overflow-x: auto; }
  .pool-sidebar a { min-width: 120px; border-right: 1px solid var(--line); }
  .pipeline { grid-template-columns: repeat(5, 1fr); gap: .8rem .25rem; }
}

@media (max-width: 720px) {
  .topbar { align-items: flex-start; }
  .topnav > a:not(.button) { display: none; }
  .topnav { flex-wrap: wrap; justify-content: end; }
  .auth-layout { grid-template-columns: 1fr; min-height: 0; }
  .auth-intro { display: none; }
  .hero, .picker-card, .defaults-card, .sticky-actions, .page-heading, .section-heading { align-items: stretch; flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .filterbar { flex-wrap: wrap; }
  .filterbar label { flex: 1 1 100%; }
  .pipeline { grid-template-columns: repeat(2, 1fr); }
  .actions { min-width: 260px; }
}

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

