:root {
  --ink: #17201a;
  --muted: #667068;
  --muted-2: #8a948c;
  --paper: #f4f6f2;
  --surface: #ffffff;
  --surface-soft: #f8faf7;
  --line: #dfe5de;
  --line-strong: #c9d1c9;
  --green: #b44d17;
  --green-deep: #78310f;
  --green-soft: #fff0e7;
  --amber: #9b6515;
  --amber-soft: #fff4de;
  --red: #a53b35;
  --red-soft: #fcedeb;
  --blue: #315c8a;
  --blue-soft: #eaf1f8;
  --shadow-sm: 0 1px 2px rgba(23, 32, 26, 0.05), 0 4px 12px rgba(23, 32, 26, 0.04);
  --shadow-lg: 0 24px 60px rgba(23, 32, 26, 0.18);
  --radius: 14px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  font: 100%/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-optical-sizing: auto;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); }
button, input, select { font: inherit; }
button, a, label[for] { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, .drop-zone:focus-within { outline: 3px solid rgba(31, 90, 61, 0.25); outline-offset: 2px; }
button:active, .button:active, .nav-item:active, .profile-button:active { transform: scale(0.97); }
[hidden] { display: none !important; }
.sr-only { 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 { position: fixed; z-index: 1000; left: 1rem; top: -4rem; padding: .65rem .9rem; border-radius: 8px; background: var(--ink); color: white; }
.skip-link:focus { top: 1rem; }

.wordmark { color: var(--ink); text-decoration: none; font-weight: 850; font-size: 1.06rem; letter-spacing: .08em; white-space: nowrap; }
.wordmark span { margin-left: .36rem; }
.eyebrow { margin: 0 0 .35rem; color: var(--green); font-size: .69rem; font-weight: 760; letter-spacing: .13em; }
.muted { color: var(--muted); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .45rem; font-size: clamp(1.72rem, 3vw, 2.25rem); line-height: 1.15; letter-spacing: -.025em; }
h2 { margin-bottom: .2rem; font-size: 1.08rem; line-height: 1.3; letter-spacing: -.01em; }
h3 { font-size: .92rem; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(280px, 1.05fr) minmax(390px, .95fr); background: var(--surface); }
.login-brand { position: relative; display: flex; flex-direction: column; justify-content: flex-end; padding: clamp(2rem, 6vw, 6rem); overflow: hidden; color: white; background: linear-gradient(145deg, #171717 0%, #292725 62%, #b44d17 160%); }
.login-brand::before { content: ""; position: absolute; width: min(48vw, 680px); aspect-ratio: 1; top: -23%; right: -25%; border: 1px solid rgba(255,255,255,.16); border-radius: 50%; box-shadow: 0 0 0 65px rgba(255,255,255,.035), 0 0 0 145px rgba(255,255,255,.025); }
.brand-mark { display: grid; place-items: center; width: 2.4rem; aspect-ratio: 1; border-radius: 10px; color: white; background: var(--green); font-size: .72rem; font-weight: 850; letter-spacing: -.04em; }
.brand-mark--large { position: relative; width: 5.4rem; border: 1px solid rgba(255,255,255,.55); background: rgba(255,255,255,.09); font-size: 1.25rem; box-shadow: inset 0 1px rgba(255,255,255,.3); }
.login-brand p { position: relative; margin: 1.35rem 0 0; max-width: 22rem; color: rgba(255,255,255,.82); font-size: clamp(1.25rem, 2.6vw, 2.1rem); line-height: 1.35; font-weight: 580; letter-spacing: -.02em; }
.login-card { align-self: center; width: min(430px, calc(100% - 3rem)); margin: 0 auto; }
.login-card .wordmark { display: block; margin-bottom: 4.5rem; }
.login-card h1 { margin-top: .2rem; }
.login-card > .muted { margin-bottom: 2rem; }
label { display: block; margin: 1rem 0 .4rem; font-size: .84rem; font-weight: 680; }
input, select { width: 100%; min-height: 44px; padding: .68rem .78rem; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--ink); background: var(--surface); transition: border-color 140ms ease, box-shadow 140ms ease; }
input:hover, select:hover { border-color: #9eaaa0; }
input::placeholder { color: #99a19a; }
.password-field { position: relative; }
.password-field input { padding-right: 4.2rem; }
.password-field .text-button { position: absolute; right: .35rem; top: .35rem; }
.text-button { border: 0; padding: .35rem .55rem; color: var(--green); background: transparent; font-weight: 680; cursor: pointer; }
.form-error { margin: .65rem 0 0; color: var(--red); font-size: .82rem; }
.login-note { margin-top: 1.3rem; color: var(--muted-2); font-size: .75rem; }

.button, .icon-button, .profile-button, .back-button, .profile-menu button { cursor: pointer; transition: transform 120ms var(--ease-out), background-color 140ms ease, border-color 140ms ease; }
.button { min-height: 42px; padding: .62rem .9rem; border: 1px solid transparent; border-radius: 9px; font-size: .85rem; font-weight: 720; }
.button--wide { width: 100%; margin-top: 1.5rem; }
.button--primary { color: white; background: var(--green); box-shadow: 0 1px 2px rgba(15,55,36,.15); }
.button--primary:hover { background: var(--green-deep); }
.button--secondary { border-color: var(--line-strong); background: var(--surface); }
.button--secondary:hover, .button--quiet:hover { background: var(--surface-soft); }
.button--quiet { border-color: transparent; color: var(--green); background: transparent; }
.button--danger { border-color: #e6c1be; color: var(--red); background: var(--red-soft); }
.icon-button { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 9px; background: transparent; font-size: 1.3rem; }

.app-shell { min-height: 100vh; }
.topbar { position: fixed; z-index: 20; top: 0; left: 0; right: 0; height: 64px; display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem; border-bottom: 1px solid rgba(201,209,201,.8); background: rgba(255,255,255,.88); backdrop-filter: blur(18px) saturate(160%); }
.topbar > .wordmark { margin-right: auto; }
.topbar-actions { position: relative; display: flex; align-items: center; gap: .9rem; }
.environment { display: inline-flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .74rem; }
.environment span { width: 7px; height: 7px; border-radius: 50%; background: #53a56f; box-shadow: 0 0 0 3px #e9f3ec; }
.profile-button { display: flex; align-items: center; gap: .55rem; padding: .25rem .4rem; border: 0; border-radius: 9px; background: transparent; text-align: left; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: white; background: var(--ink); font-size: .8rem; font-weight: 760; }
.profile-copy { display: flex; min-width: 6rem; flex-direction: column; }
.profile-copy strong { font-size: .78rem; }
.profile-copy small { color: var(--muted); font-size: .68rem; }
.profile-menu { position: absolute; z-index: 25; right: 0; top: 3.1rem; width: 150px; padding: .35rem; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: var(--shadow-lg); transform-origin: 85% 0; }
.profile-menu button { width: 100%; padding: .55rem; border: 0; border-radius: 7px; background: transparent; text-align: left; }
.profile-menu button:hover { background: var(--surface-soft); }
.mobile-menu { display: none; }

.sidebar { position: fixed; z-index: 15; top: 64px; bottom: 0; left: 0; width: 232px; display: flex; flex-direction: column; justify-content: space-between; padding: 1.3rem .9rem; border-right: 1px solid var(--line); background: #f8faf7; }
.nav-label { margin: 0 .75rem .55rem; color: var(--muted-2); font-size: .64rem; font-weight: 750; letter-spacing: .12em; }
.nav-item { display: flex; align-items: center; gap: .7rem; margin: .12rem 0; padding: .62rem .75rem; border-radius: 9px; color: #4d5850; text-decoration: none; font-size: .84rem; font-weight: 650; transition: transform 120ms var(--ease-out), background-color 130ms ease, color 130ms ease; }
.nav-item span { width: 1.1rem; font-size: .95rem; text-align: center; }
.nav-item:hover { color: var(--ink); background: #edf1ec; }
.nav-item.is-active { color: var(--green-deep); background: #e6efe8; }
.sidebar-footer { padding: .8rem .75rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .68rem; }
.sidebar-footer strong { display: block; margin-top: .2rem; color: #49534b; font-size: .72rem; }

main { min-height: 100vh; margin-left: 232px; padding-top: 64px; }
.page { display: none; width: min(1440px, 100%); margin: 0 auto; padding: clamp(1.6rem, 3vw, 2.6rem); }
.page.is-visible { display: block; }
.page-heading, .detail-heading, .section-heading, .panel-toolbar, .dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.page-heading { margin-bottom: 1.65rem; }
.page-heading p, .detail-heading p { margin-bottom: 0; color: var(--muted); font-size: .86rem; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin-bottom: .9rem; }
.metric { min-width: 0; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.metric span { display: block; color: var(--muted); font-size: .76rem; }
.metric strong { display: block; margin: .2rem 0 0; font-size: 1.65rem; line-height: 1.15; letter-spacing: -.035em; }
.metric small { color: var(--muted-2); font-size: .7rem; }
.metric--quality { border-color: #c9dccd; background: linear-gradient(130deg, #fff 0%, #f0f7f2 100%); }
.metric--quality strong { color: var(--green-deep); }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.panel-toolbar, .section-heading { padding: 1.05rem 1.15rem; }
.panel-toolbar { border-bottom: 1px solid var(--line); }
.panel-toolbar p, .section-heading p { margin-bottom: 0; font-size: .72rem; }
.filters { display: flex; gap: .55rem; }
.search-field { display: flex; align-items: center; gap: .35rem; min-width: 260px; margin: 0; padding-left: .65rem; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); }
.search-field input { min-height: 40px; padding-left: 0; border: 0; outline: 0; box-shadow: none; }
.filters select { min-height: 42px; width: 128px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: .7rem 1.15rem; color: var(--muted-2); background: var(--surface-soft); font-size: .68rem; font-weight: 720; letter-spacing: .03em; }
td { padding: .8rem 1.15rem; border-top: 1px solid #edf0ec; font-size: .78rem; vertical-align: middle; }
tr[data-job-id] { cursor: pointer; }
tr[data-job-id]:hover td { background: #fbfcfa; }
.file-cell { display: flex; align-items: center; gap: .65rem; min-width: 230px; }
.file-cell strong { display: block; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .8rem; }
.file-cell small { display: block; color: var(--muted-2); }
.file-icon { display: grid; flex: 0 0 auto; place-items: center; width: 34px; height: 38px; border: 1px solid #d5dfd6; border-radius: 7px; color: var(--green); background: #edf5ef; font-size: .55rem; font-weight: 850; }
.status-badge { display: inline-flex; align-items: center; gap: .35rem; padding: .26rem .5rem; border-radius: 999px; color: var(--blue); background: var(--blue-soft); font-size: .67rem; font-weight: 720; white-space: nowrap; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-queued { color: var(--amber); background: var(--amber-soft); }
.status-succeeded { color: var(--green); background: var(--green-soft); }
.status-failed { color: var(--red); background: var(--red-soft); }
.row-action { border: 0; color: var(--green); background: transparent; font-size: .76rem; font-weight: 720; cursor: pointer; }
.empty-state { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.empty-state p { margin: .25rem 0 0; font-size: .8rem; }
.empty-state--compact { padding: 2rem; }
.success-icon { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: .4rem; border-radius: 50%; color: white; background: var(--green); }

.back-button { margin: 0 0 1rem; padding: .35rem 0; border: 0; color: var(--green); background: transparent; font-weight: 680; }
.detail-heading { margin-bottom: 1.4rem; }
.detail-heading h1 { margin-bottom: .35rem; }
.detail-actions { display: flex; gap: .55rem; }
.detail-grid, .split-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .9rem; margin-bottom: .9rem; }
.stage-list { position: relative; margin: 0; padding: .3rem 1.2rem 1.2rem; list-style: none; }
.stage-list li { position: relative; display: grid; grid-template-columns: 25px 1fr auto; gap: .65rem; align-items: center; min-height: 41px; color: var(--muted); font-size: .76rem; }
.stage-list li:not(:last-child)::after { content: ""; position: absolute; left: 12px; top: 31px; bottom: -8px; width: 1px; background: var(--line); }
.stage-dot { z-index: 1; display: grid; place-items: center; width: 25px; height: 25px; border: 1px solid var(--line-strong); border-radius: 50%; background: white; font-size: .62rem; }
.stage-list .complete .stage-dot { border-color: var(--green); color: white; background: var(--green); }
.stage-list .current { color: var(--ink); font-weight: 680; }
.stage-list .current .stage-dot { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); box-shadow: 0 0 0 4px rgba(49,92,138,.08); }
.stage-list time { color: var(--muted-2); font-size: .65rem; }
.qa-score { color: var(--green); font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; }
.qa-panel hr { margin: .2rem 1.15rem 1rem; border: 0; border-top: 1px solid var(--line); }
.qa-panel > h3 { margin-left: 1.15rem; }
.qa-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; padding: 0 1.15rem 1rem; }
.qa-item { padding: .65rem; border-radius: 9px; background: var(--surface-soft); }
.qa-item strong, .qa-item small { display: block; }
.qa-item strong { margin-top: .15rem; color: var(--green); font-size: .85rem; }
.qa-item small { color: var(--muted); font-size: .66rem; }
.summary-list { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .75rem; margin: 0; padding: 0 1.15rem 1.15rem; list-style: none; }
.summary-list li { display: flex; align-items: center; gap: .4rem; color: var(--muted); font-size: .75rem; }
.summary-list li::before { content: "✓"; color: var(--green); font-weight: 800; }
.preview-panel, .tech-log { margin-top: .9rem; }
.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; padding: 0 1.15rem 1.15rem; }
.preview-label { display: inline-block; margin-bottom: .4rem; color: var(--muted); font-size: .7rem; font-weight: 720; }
.preview-label--after { color: var(--green); }
.pdf-preview { display: block; width: 100%; aspect-ratio: 1.42; border: 1px solid var(--line); border-radius: 9px; background: #f4f1eb; box-shadow: inset 0 0 0 1px rgba(255,255,255,.5); }
.tech-log pre { margin: 0 1.15rem 1.15rem; padding: 1rem; overflow: auto; border-radius: 9px; color: #cce4d2; background: #17201a; font: .72rem/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; }

.audit-list { margin: 0; padding: 0 1.15rem 1.15rem; list-style: none; }
.audit-list li { position: relative; padding: .65rem 0 .65rem 1.2rem; border-bottom: 1px solid #edf0ec; font-size: .75rem; }
.audit-list li::before { content: ""; position: absolute; left: 0; top: 1.05rem; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.audit-list span { display: block; color: var(--muted-2); font-size: .65rem; }
.health-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: .65rem; margin-bottom: .9rem; }
.health-card { padding: .8rem; border: 1px solid var(--line); border-radius: 11px; background: white; }
.health-card span, .health-card strong, .health-card small { display: block; }
.health-card span { float: right; width: 8px; height: 8px; margin-top: .32rem; border-radius: 50%; background: #53a56f; box-shadow: 0 0 0 3px var(--green-soft); }
.health-card strong { font-size: .78rem; }
.health-card small { margin-top: .15rem; color: var(--muted); font-size: .64rem; }
.queue-meter { height: 7px; margin: .2rem 1.15rem 1rem; overflow: hidden; border-radius: 999px; background: var(--line); }
.queue-meter span { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.definition-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; margin: 0; padding: 0 1.15rem 1.1rem; }
.definition-grid div { padding: .65rem; border-radius: 8px; background: var(--surface-soft); }
dt { color: var(--muted); font-size: .68rem; }
dd { margin: .15rem 0 0; font-size: .82rem; font-weight: 720; }
.queue-meter ~ .button { margin: 0 1.15rem 1.15rem; }
.detail-list { margin: 0; padding: 0 1.15rem 1.15rem; }
.detail-list div { display: flex; justify-content: space-between; gap: 1rem; padding: .62rem 0; border-bottom: 1px solid #edf0ec; }
.detail-list dd { text-align: right; font-size: .75rem; }

dialog { width: min(560px, calc(100% - 2rem)); padding: 0; border: 0; border-radius: 16px; color: var(--ink); background: var(--surface); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(17, 26, 20, .52); backdrop-filter: blur(3px); }
.dialog-card { padding: 1.25rem; }
.dialog-heading { margin-bottom: .5rem; }
.dialog-heading h2 { font-size: 1.25rem; }
.dialog-heading .icon-button { margin: -.5rem -.35rem 0 0; }
.drop-zone { display: grid; place-items: center; min-height: 190px; margin: 1.1rem 0; padding: 1.2rem; border: 1.5px dashed #aeb9b0; border-radius: 12px; background: var(--surface-soft); text-align: center; cursor: pointer; transition: border-color 150ms ease, background-color 150ms ease, transform 150ms var(--ease-out); }
.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--green); background: #eff6f1; }
.drop-zone.is-dragging { transform: scale(.99); }
.drop-zone strong, .drop-zone small { display: block; }
.drop-zone strong { margin-top: .65rem; font-size: .84rem; }
.drop-zone small { margin-top: .25rem; color: var(--muted); font-size: .7rem; }
.upload-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: var(--green); background: var(--green-soft); font-size: 1.3rem; }
.selected-file { display: flex; align-items: center; gap: .7rem; margin: 1rem 0; padding: .7rem; border: 1px solid var(--line); border-radius: 10px; }
.selected-file div { flex: 1; min-width: 0; }
.selected-file strong, .selected-file small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-file strong { font-size: .8rem; }
.selected-file small { color: var(--muted); font-size: .68rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .55rem; margin-top: 1.2rem; }
.one-time-secret { display: flex; align-items: center; gap: .6rem; margin: 1rem 0; padding: .75rem; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-soft); }
.one-time-secret code { flex: 1; overflow-wrap: anywhere; color: var(--green-deep); font: 720 .88rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.secret-label { margin: 1rem 0 -.65rem; color: var(--muted); font-size: .72rem; font-weight: 650; }
.confirm-secret { display: flex; align-items: center; gap: .55rem; font-weight: 550; cursor: pointer; }
.confirm-secret input { width: 18px; min-height: 18px; margin: 0; accent-color: var(--green); }
.button:disabled { cursor: not-allowed; opacity: .5; transform: none; }
.toast-region { position: fixed; z-index: 100; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; }
.toast { max-width: 360px; padding: .75rem .9rem; border: 1px solid #c9dccd; border-radius: 10px; color: var(--green-deep); background: #f3f8f4; box-shadow: var(--shadow-lg); font-size: .78rem; }

@media (max-width: 1040px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .health-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 780px) {
  .login-shell { display: block; padding: 2rem 0; }
  .login-brand { display: none; }
  .login-card { min-height: calc(100vh - 4rem); display: flex; flex-direction: column; justify-content: center; }
  .login-card .wordmark { margin-bottom: 3rem; }
  .mobile-menu { display: inline-grid; }
  .environment, .profile-copy { display: none; }
  .sidebar { transform: translateX(-100%); transition: transform 220ms var(--ease-out); box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: translateX(0); }
  main { margin-left: 0; }
  .page-heading, .detail-heading { align-items: flex-start; flex-direction: column; }
  .page-heading .button, .detail-actions { width: 100%; }
  .detail-actions .button { flex: 1; }
  .split-grid, .detail-grid { grid-template-columns: 1fr; }
  .panel-toolbar { align-items: stretch; flex-direction: column; }
  .filters { width: 100%; }
  .search-field { flex: 1; min-width: 0; }
}
@media (max-width: 520px) {
  .topbar { padding: 0 .75rem; }
  .page { padding: 1.25rem .75rem; }
  .metric-grid { gap: .55rem; }
  .metric { padding: .85rem; }
  .metric strong { font-size: 1.4rem; }
  .metric small { display: none; }
  .filters { flex-direction: column; }
  .filters select { width: 100%; }
  th, td { padding: .72rem .8rem; }
  th:nth-child(2), td:nth-child(2), th:nth-child(4), td:nth-child(4) { display: none; }
  .qa-summary, .summary-list, .preview-grid { grid-template-columns: 1fr; }
  .health-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar { background: white; backdrop-filter: none; }
  dialog::backdrop { backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --line: #89938b; --line-strong: #667168; }
  .topbar, .sidebar, .panel, .metric { border-color: var(--line-strong); }
}
