:root {
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  color: #172e2b;
  background: #f2f7f5;
  font-synthesis: none;
  --card: #fff;
  --ink: #172e2b;
  --muted: #526863;
  --line: #dbe7e1;
  --primary: #176454;
  --primary-dark: #124d41;
  --soft: #e8f5ef;
  --danger: #8e302b;
  --amber: #784917;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; line-height: 1.55; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
button, input, select, textarea, a { outline-offset: 3px; }
:focus-visible { outline: 2px solid #137c66; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 3rem); line-height: 1.15; letter-spacing: -.045em; }
h2 { font-size: 1.12rem; line-height: 1.35; }
h3 { font-size: .98rem; }
.muted, .lead, .help, .optional { color: var(--muted); }
.muted, .help, .optional { font-size: .83rem; }
.eyebrow { color: var(--primary); font-size: .81rem; font-weight: 750; letter-spacing: .12em; margin-bottom: .55rem; }
.lead { margin-top: .68rem; }
.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: absolute; top: -100px; left: 1rem; z-index: 2; background: #fff; padding: .5rem; }
.skip-link:focus { top: 1rem; }

.site-header { background: #fff; border-bottom: 1px solid var(--line); }
.header-inner { max-width: 1360px; min-height: 64px; margin: auto; padding: .6rem clamp(1rem, 4vw, 3rem); display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.brand, .account { display: flex; align-items: center; gap: .7rem; }
.brand { font-weight: 750; text-decoration: none; color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: #fff; font-size: .94rem; }
.account { color: var(--muted); font-size: .84rem; }
.page { max-width: 1360px; margin: auto; padding: clamp(1.2rem, 4vw, 3rem); }
.site-footer { border-top: 1px solid var(--line); text-align: center; padding: .85rem 1rem; font-size: .8rem; }
.site-footer a { color: var(--muted); }
.startup { color: var(--muted); }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 1.3rem; margin: .2rem 0 1.35rem; }
.mode-strip { display: flex; gap: .5rem 1.25rem; flex-wrap: wrap; padding: .75rem .95rem; margin-bottom: 1.1rem; border: 1px solid #d3e8df; background: var(--soft); border-radius: 10px; color: #27574e; font-size: .85rem; }
.mode-strip strong { font-weight: 750; }
.workspace { display: grid; grid-template-columns: minmax(220px, 290px) minmax(0, 1fr); align-items: start; gap: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 2px 7px #18363208; padding: clamp(.85rem, 2.2vw, 1.35rem); min-width: 0; }
.panel-heading, .detail-summary, .section-heading { display: flex; justify-content: space-between; align-items: start; gap: .7rem; }
.panel-heading { align-items: center; margin-bottom: .8rem; }
.detail-panel, .detail-stack { min-width: 0; display: grid; gap: .8rem; }
.detail-summary h2 { overflow-wrap: anywhere; font-size: clamp(1.15rem, 2.5vw, 1.4rem); }
.summary-meta { display: flex; flex-wrap: wrap; gap: .3rem .8rem; margin-top: .32rem; color: var(--muted); font-size: .83rem; overflow-wrap: anywhere; }
.section-heading { margin-bottom: .65rem; }
.section-heading h2 { margin-bottom: .2rem; }
.request-list { display: grid; gap: .35rem; margin-top: .7rem; }
.request-entry { width: 100%; background: #fff; border: 1px solid transparent; border-radius: 8px; color: var(--ink); text-align: left; padding: .58rem .62rem; display: grid; gap: .25rem; }
.request-entry:hover { background: #f5faf8; }
.request-entry[aria-current="true"] { background: var(--soft); border-color: #afd8c7; }
.request-entry strong { overflow-wrap: anywhere; }
.entry-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .5rem; color: var(--muted); font-size: .73rem; }
.badge { display: inline-flex; width: max-content; max-width: 100%; align-items: center; padding: .19rem .53rem; border-radius: 999px; background: #edf2f0; color: #36554e; white-space: nowrap; font-weight: 700; font-size: .75rem; }
.badge[data-status="review"], .badge[data-status="recognition_failed"], .badge[data-status="uncertain"], .badge[data-status="blocked"] { background: #fcf1df; color: var(--amber); }
.badge[data-status="approved"], .badge[data-status="draft_saved"], .badge[data-status="issued"] { background: #dff3e9; color: #155440; }
.badge[data-status="running"], .badge[data-status="queued"], .badge[data-status="recognizing"] { background: #e6eefb; color: #244c80; }
.empty { padding: 1.1rem .25rem; color: var(--muted); font-size: .9rem; }
.detail-panel > .empty { padding: 2.8rem 1rem; text-align: center; }

.button { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: .2rem; padding: .36rem .72rem; font-size: .85rem; font-weight: 700; text-decoration: none; border-radius: 7px; border: 1px solid var(--line); background: #fff; color: var(--primary-dark); }
.button:hover { background: #f2f8f5; }
.button.primary { background: var(--primary); color: #fff; border-color: var(--primary); padding-inline: .9rem; }
.button.primary:hover { background: var(--primary-dark); }
.button.quiet { background: transparent; white-space: nowrap; }
.button.remove { color: var(--danger); }
label { display: block; margin: .65rem 0 .26rem; font-size: .84rem; font-weight: 700; }
input:not([type="checkbox"]), select, textarea { width: 100%; background: #fff; color: var(--ink); border: 1px solid #cbdcd4; border-radius: 7px; min-height: 38px; padding: .44rem .57rem; font-size: .88rem; }
input::placeholder, textarea::placeholder { color: #63756f; }
textarea { resize: vertical; }
input[type="file"] { font-size: .79rem; }
input[type="file"]::file-selector-button { background: var(--soft); border: 0; margin-right: .45rem; border-radius: 4px; color: var(--primary-dark); padding: .22rem .35rem; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: .75rem; }
.field-span { grid-column: 1 / -1; }
.help { margin-top: .3rem; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-top: .95rem; }
.notice { padding: .62rem .75rem; margin: .55rem 0; background: #edf7f2; color: #245848; border: 1px solid #d2e9dd; border-radius: 8px; font-size: .86rem; overflow-wrap: anywhere; }
.notice.error { background: #fcefed; border-color: #f2d0cc; color: var(--danger); }
.notice.warning { background: #fcf4e6; border-color: #ead7b9; color: var(--amber); }
.notice.progress { background: #f1f5fb; border-color: #d8e4f1; color: #244c80; }
.source-copy { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 16rem; overflow: auto; background: #f6f9f7; padding: .7rem .8rem; border-radius: 7px; font-size: .86rem; }
.file-list, .issue-list { margin: .45rem 0 0; padding-left: 1.3rem; }
.file-list li, .issue-list li { margin: .22rem 0; overflow-wrap: anywhere; font-size: .84rem; }
.issue-list { color: var(--amber); }
.issue-field { font-weight: 700; margin-inline-end: .5rem; }
.selected-files { margin: .45rem 0 .65rem; padding: 0; list-style: none; }
.selected-files li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .25rem 0; border-bottom: 1px solid var(--line); }
.selected-files li > span { min-width: 0; overflow-wrap: anywhere; font-size: .84rem; }
.selected-files .button { flex: none; min-height: 30px; padding-block: .2rem; }
#create-mode { margin-top: .7rem; }
details { font-size: .88rem; margin-top: .6rem; }
summary { color: var(--primary-dark); cursor: pointer; font-weight: 700; }
.items { display: grid; gap: .55rem; margin-top: .65rem; }
.item-fields { margin: 0; padding: .42rem .7rem .65rem; min-width: 0; border: 1px solid var(--line); border-radius: 8px; }
.item-fields legend { color: #36554e; font-size: .78rem; font-weight: 750; padding-inline: .25rem; }
.item-fields .field-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.items-heading { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .8rem; }
.item-actions { display: flex; justify-content: end; margin-top: .65rem; }
.read-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem .8rem; margin: .4rem 0 0; }
.read-fields div { display: grid; grid-template-columns: minmax(4.5rem, auto) 1fr; gap: .45rem; align-items: start; }
.read-fields dt { color: var(--muted); font-size: .8rem; }
.read-fields dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; font-size: .86rem; }
.table-wrap { overflow: auto; margin-top: .65rem; }
table { width: 100%; border-collapse: collapse; font-size: .79rem; text-align: left; }
th, td { padding: .44rem .46rem; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
th { white-space: nowrap; color: #34534b; background: #f4f8f5; }
.confirmation { display: flex; align-items: start; gap: .45rem; }
.confirmation input { margin-top: .25rem; }

.login-layout { display: grid; grid-template-columns: 1fr minmax(260px, 380px); align-items: center; gap: clamp(1rem, 5vw, 4.8rem); max-width: 880px; margin: clamp(1.5rem, 10vw, 7rem) auto; }
.login-intro > p:last-child { margin-top: 1rem; color: var(--muted); max-width: 30rem; }
.login-card > .muted { margin: .35rem 0 .95rem; }
.login-card .button { margin-top: 1rem; width: 100%; }
dialog { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 12px; width: min(94%, 520px); max-height: 90vh; padding: 1.25rem; box-shadow: 0 14px 50px #102f29a0; }
dialog::backdrop { background: #132d2999; }
.dialog-actions { display: flex; justify-content: end; margin-top: .9rem; }

@media (max-width: 780px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .request-list { max-height: 16rem; overflow-y: auto; }
  .item-fields .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 540px) {
  .login-layout { grid-template-columns: 1fr; }
  .page-heading { align-items: start; flex-direction: column; }
  .field-grid, .read-fields { grid-template-columns: 1fr; }
  .account { gap: .35rem; }
  .account button { padding-inline: .36rem; }
}
