:root {
  --paper: #f3f1eb;
  --sheet: #fffefa;
  --ink: #202522;
  --muted: #6e756f;
  --line: #d8d9d2;
  --line-strong: #b9bdb7;
  --teal: #0d5c56;
  --teal-dark: #084640;
  --teal-soft: #e4efec;
  --orange: #b96027;
  --orange-soft: #fff2df;
  --red: #a73d35;
  --rail: #17201d;
  --rail-muted: #9daaa4;
  --radius: 12px;
  --shadow: 0 12px 30px rgba(29, 39, 34, .08);
  --font: "Avenir Next", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); font-family: var(--font); }
body { margin: 0; min-width: 1120px; background: var(--paper); }
button, input { font: inherit; }
button { cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.skip-link { position: fixed; left: 12px; top: -48px; z-index: 20; padding: 10px 14px; background: white; color: var(--teal); }
.skip-link:focus { top: 12px; }
.app-shell { display: grid; grid-template-columns: 208px minmax(900px, 1fr); min-height: 100vh; }

.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--rail); color: white; padding: 24px 14px 16px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 24px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: #e2b46e; }
.brand-mark svg { width: 31px; height: 31px; }
.brand strong { display: block; font-size: 15px; letter-spacing: .04em; }
.brand small { display: block; color: var(--rail-muted); font-size: 8px; letter-spacing: .17em; margin-top: 3px; }
.primary-nav { display: grid; gap: 5px; margin-top: 24px; }
.nav-item { display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 10px; width: 100%; padding: 11px 10px; color: #bac4bf; border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: 13px; }
.nav-item svg { width: 19px; }
.nav-item span { display: grid; place-items: center; min-width: 21px; height: 21px; padding: 0 6px; border-radius: 20px; background: #34403b; font-size: 10px; }
.nav-item:hover, .nav-item:focus-visible { color: white; background: #222e29; outline: none; }
.nav-item.active { color: white; background: #31413b; }
.nav-item.active::before { content: ""; position: absolute; left: 0; width: 3px; height: 25px; background: #d5a259; }
.rail-bottom { margin-top: auto; }
.archive-stat { padding: 14px 11px; border: 1px solid rgba(255,255,255,.12); border-radius: 10px; background: rgba(255,255,255,.035); }
.archive-stat span { display: block; color: #c5cec9; font-size: 11px; }
.archive-stat strong { display: block; margin: 2px 0 -1px; font: 600 28px/1.2 "SFMono-Regular", Consolas, monospace; color: #e6b873; }
.archive-stat small { color: var(--rail-muted); font-size: 10px; }
.user-row { width: 100%; display: grid; grid-template-columns: 32px 1fr auto; gap: 9px; align-items: center; margin-top: 15px; padding: 10px 7px; border: 0; border-top: 1px solid rgba(255,255,255,.1); color: white; background: transparent; text-align: left; font-size: 12px; }
.user-row small { display: block; color: var(--rail-muted); font-size: 9px; margin-top: 2px; }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #d5a259; color: #17201d; font-weight: 700; }
.rail-filing { margin-top: 8px; text-align: center; }
.rail-filing a { color: var(--rail-muted); font-size: 8px; line-height: 1.5; text-decoration: none; }
.rail-filing a:hover, .rail-filing a:focus-visible { color: white; text-decoration: underline; text-underline-offset: 3px; outline: none; }

.workspace { min-width: 0; }
.topbar { min-height: 86px; display: flex; justify-content: space-between; align-items: center; gap: 22px; padding: 15px 27px; background: var(--sheet); border-bottom: 1px solid var(--line); }
.breadcrumb { display: flex; gap: 7px; color: var(--muted); font-size: 11px; }
.breadcrumb i { font-style: normal; color: #b9bbb6; }
.title-row { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.task-name-field { display: block; min-width: 280px; }
.task-name-field input { width: min(520px, 42vw); height: 31px; padding: 0; border: 0; border-bottom: 1px solid transparent; background: transparent; color: var(--ink); font: 700 21px/1.25 "Avenir Next", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif; letter-spacing: -.015em; }
.task-name-field input::placeholder { color: var(--muted); font-weight: 600; opacity: .7; }
.task-name-field input:hover { border-bottom-color: var(--line-strong); }
.task-name-field input:focus { border-bottom-color: var(--teal); outline: 0; }
h1 { margin: 0; font-size: 21px; line-height: 1.25; letter-spacing: -.015em; }
.status-stamp { display: inline-flex; align-items: center; height: 25px; padding: 0 8px; border: 1px solid #cf7f4d; border-radius: 4px; color: #a34f1a; font-size: 11px; font-weight: 700; transform: rotate(-1.5deg); }
.top-actions { display: flex; align-items: center; gap: 9px; }
.saved { color: var(--muted); font-size: 11px; margin-right: 4px; white-space: nowrap; }
.saved i { display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: #3a8b63; }
.button { height: 36px; border-radius: 7px; padding: 0 13px; font-size: 12px; font-weight: 650; }
.button.secondary { border: 1px solid var(--line-strong); background: white; color: var(--ink); }
.button.primary { border: 1px solid var(--teal); background: var(--teal); color: white; }
.button.primary:hover { background: var(--teal-dark); }
.button.danger { border: 1px solid #d9aaa5; background: white; color: var(--red); }
.button.danger:hover { background: #f8e9e7; }

.progress-strip { display: grid; grid-template-columns: auto 1fr auto 1fr auto 1fr auto; align-items: center; padding: 13px 28px; background: #e9e7e0; border-bottom: 1px solid var(--line); }
.progress-strip > i { height: 1px; min-width: 25px; margin: 0 12px; background: #c8cac4; }
.progress-step { display: flex; align-items: center; gap: 8px; padding: 0; border: 0; color: #7c817d; background: transparent; text-align: left; }
.progress-step b { display: grid; place-items: center; width: 25px; height: 25px; border: 1px solid #b9bdb7; border-radius: 50%; font-size: 10px; }
.progress-step span { font-size: 11px; font-weight: 650; white-space: nowrap; }
.progress-step small { display: block; margin-top: 2px; font-size: 9px; font-weight: 500; color: #777d79; }
.progress-step.done { color: var(--teal); }
.progress-step.done b { background: var(--teal); border-color: var(--teal); color: white; }
.progress-step.active { color: var(--ink); }
.progress-step.active b { border: 2px solid var(--orange); color: var(--orange); background: white; }

.content-grid { display: grid; grid-template-columns: minmax(740px, 1fr) 248px; min-height: calc(100vh - 138px); }
.entry-panel { min-width: 0; padding: 20px 24px 30px; }
.customer-panel { margin-bottom: 12px; padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--sheet); }
.customer-heading { display: flex; justify-content: space-between; align-items: start; gap: 20px; margin-bottom: 13px; }
.customer-heading p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.currency-badge { min-width: 116px; padding: 6px 9px; border: 1px solid #bfd3ce; border-radius: 6px; background: var(--teal-soft); text-align: right; }
.currency-badge small { display: block; color: #64746f; font-size: 8px; }
.currency-badge strong { display: block; margin-top: 2px; color: var(--teal); font-size: 11px; }
.customer-fields { display: grid; grid-template-columns: minmax(260px, 1fr) 210px 160px; gap: 16px; align-items: start; }
.customer-select > span, .declaration-number > span, .contract-date > span, .destination-field legend { display: block; margin-bottom: 5px; color: #555c57; font-size: 9px; font-weight: 700; }
.customer-select select, .declaration-number input, .contract-date input { width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: white; color: var(--ink); font-size: 11px; }
.declaration-number input { font-family: "SFMono-Regular", Consolas, monospace; font-size: 10px; }
.declaration-number input[aria-invalid="true"], .contract-date input[aria-invalid="true"] { border-color: var(--red); background: #f8e9e7; color: #782b25; }
.customer-select > small, .declaration-number > small, .contract-date > small { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-base-fields .destination-field { grid-column: 1 / -1; width: 310px; }
.destination-field { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 0; padding: 0; border: 0; }
.destination-field legend { grid-column: 1 / -1; }
.destination-field label { position: relative; display: block; cursor: pointer; }
.destination-field input { position: absolute; opacity: 0; pointer-events: none; }
.destination-field label > span { display: block; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: white; font-size: 10px; font-weight: 700; }
.destination-field label small { display: block; margin-top: 2px; color: var(--muted); font-size: 8px; font-weight: 500; }
.destination-field input:checked + span { border-color: var(--teal); background: var(--teal-soft); color: var(--teal); box-shadow: inset 3px 0 0 var(--teal); }
.destination-field input:focus-visible + span { outline: 2px solid #d08a50; outline-offset: 2px; }
.source-banner { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid #c9d9d4; border-radius: 9px; background: var(--teal-soft); }
.source-icon { display: grid; place-items: center; width: 31px; height: 31px; color: var(--teal); }
.source-icon svg { width: 22px; }
.source-banner strong { display: block; color: #183d38; font-size: 12px; }
.source-banner small { display: block; margin-top: 2px; color: #62746f; font-size: 10px; }
.source-banner button { margin-left: auto; border: 0; background: transparent; color: var(--teal); font-size: 10px; font-weight: 650; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin: 25px 0 11px; }
h2 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.section-head p, .audit-head p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.table-tools { display: flex; align-items: center; gap: 7px; }
.table-tools button { display: flex; align-items: center; gap: 5px; height: 29px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--sheet); color: #454c48; font-size: 9px; }
.table-tools svg { width: 14px; }
.table-tools span { font-size: 16px; line-height: 1; color: var(--teal); }
.table-tools button:disabled { cursor: not-allowed; opacity: .48; }
.task-product-picker { position: relative; width: 265px; }
.task-product-picker input { width: 100%; height: 29px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--sheet); color: var(--ink); font-size: 9px; }
.task-product-picker input:focus { border-color: var(--teal); outline: 2px solid var(--orange-soft); outline-offset: 1px; }
.task-product-results { position: absolute; z-index: 20; top: 34px; right: 0; width: 330px; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--sheet); box-shadow: 0 12px 30px rgba(29,39,34,.14); }
.task-product-results button { width: 100%; height: auto; min-height: 48px; justify-content: space-between; padding: 7px 10px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; text-align: left; }
.task-product-results button:last-child { border-bottom: 0; }
.task-product-results button:hover { background: var(--teal-soft); }
.task-product-results strong, .task-product-results small { display: block; }
.task-product-results small { margin-top: 2px; color: var(--muted); font-size: 8px; }
.task-product-results em { color: var(--teal); font-size: 8px; font-style: normal; white-space: nowrap; }
.task-product-results p { margin: 0; padding: 14px; color: var(--muted); font-size: 9px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line-strong); border-radius: 9px 9px 0 0; background: var(--sheet); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 10px; }
#packingTable { min-width: 1100px; }
th { height: 41px; padding: 6px 7px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line-strong); background: #e8e8e2; color: #555c57; font-size: 9px; text-align: right; vertical-align: middle; }
th small { font-size: 7px; color: #858b87; }
#packingTable th:nth-child(1) { width: 30px; text-align: center; }
#packingTable th:nth-child(2) { width: 128px; text-align: left; }
#packingTable th:nth-child(3) { width: 135px; text-align: left; }
#packingTable th:nth-child(4) { width: 58px; }
#packingTable th:nth-child(5) { width: 58px; }
#packingTable th:nth-child(6) { width: 61px; }
#packingTable th:nth-child(7), #packingTable th:nth-child(8) { width: 72px; }
#packingTable th:nth-child(9), #packingTable th:nth-child(10) { width: 67px; }
#packingTable th:nth-child(11) { width: 112px; }
#packingTable th:nth-child(12) { width: 67px; }
#packingTable th:nth-child(13) { width: 76px; }
#packingTable th:nth-child(14) { width: 46px; }
td { height: 48px; padding: 7px; border-right: 1px solid #e4e4df; border-bottom: 1px solid #dedfd9; text-align: right; }
td:nth-child(1) { color: #8a8f8b; text-align: center; }
td:nth-child(2), td:nth-child(3) { text-align: left; }
td strong { display: block; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
td small { display: block; margin-top: 3px; color: #8b908d; font: 8px "SFMono-Regular", Consolas, monospace; }
td input { width: 100%; height: 28px; padding: 0 6px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--ink); text-align: right; font-size: 10px; }
td select { width: 100%; height: 28px; padding: 0 4px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--ink); text-align: center; font-size: 10px; }
td input:hover, td input:focus, td select:hover, td select:focus { border-color: #aeb8b4; background: white; outline: none; }
.carton-size-control { display: grid; gap: 3px; }
.carton-size-control .carton-size-preset,
.carton-size-control .carton-size { height: 23px; font-size: 9px; text-align: left; }
.carton-size-control .carton-size-preset { border-color: #c7cfcb; background: #f8faf9; }
.carton-size-control .share-carton-next { min-height: 22px; padding: 0 5px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--sheet); color: var(--muted); font-size: 8px; font-weight: 700; white-space: nowrap; }
.carton-size-control .share-carton-next[aria-pressed="true"] { border-color: var(--changed-amber); background: var(--changed-amber-soft); color: var(--changed-amber); }
.shared-carton-row td:nth-child(6), .shared-carton-row td:nth-child(11) { background: var(--changed-amber-soft); }
.shared-carton-locked .carton-size-control .carton-size-preset,
.shared-carton-locked .carton-size-control .carton-size { cursor: not-allowed; border-color: transparent; background: transparent; color: var(--muted); opacity: .72; }
.price-control { display: grid; gap: 3px; }
.price-control .price-preset,
.price-control .price { height: 23px; font-size: 9px; }
.price-control .price-preset { border-color: #c7cfcb; background: #f8faf9; text-align: left; }
td input.changed { border-color: #d38a4e; background: var(--orange-soft); color: #793b16; font-weight: 650; box-shadow: inset 3px 0 0 #b96027; }
.calculated-weight { background: var(--paper); color: var(--teal); font-family: "SFMono-Regular", Consolas, monospace; font-weight: 700; }
.row-menu { width: 36px; min-height: 27px; padding: 0; border: 1px solid transparent; border-radius: 4px; background: transparent; color: #7f8681; font-size: 0; }
.row-menu::before { content: "删除"; font-size: 8px; font-weight: 700; }
.row-menu:hover { border-color: #d9aaa5; color: var(--red); background: #f8e9e7; }
.row-menu.armed { border-color: var(--red); color: white; background: var(--red); }
.row-menu.armed::before { content: "确认"; }
tfoot td { height: 42px; border-bottom: 0; background: #f0f0eb; font-weight: 700; }
tfoot td:first-child { text-align: left; padding-left: 39px; color: var(--ink); }
tfoot span { margin-left: 6px; color: var(--muted); font-weight: 500; font-size: 9px; }
#totalAmount { color: var(--teal); }
.show-all { width: 100%; height: 31px; border: 1px solid var(--line-strong); border-top: 0; border-radius: 0 0 8px 8px; background: #e9e9e3; color: #565c58; font-size: 9px; }
.show-all span { margin-left: 5px; color: var(--teal); }
.packing-empty { display: grid; gap: 3px; padding: 17px; border: 1px dashed var(--line-strong); border-top: 0; background: var(--sheet); text-align: center; }
.packing-empty[hidden] { display: none; }
.packing-empty strong { font-size: 10px; }
.packing-empty span { color: var(--muted); font-size: 9px; }
.validation-banner { display: grid; grid-template-columns: 24px 1fr; gap: 9px; align-items: start; margin-top: 11px; padding: 10px 12px; border: 1px solid #d9aaa5; border-radius: 7px; background: #f8e9e7; color: #782b25; }
.validation-banner[hidden] { display: none; }
.validation-banner > b { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--red); color: white; font-size: 10px; }
.validation-banner strong { display: block; font-size: 10px; }
.validation-banner small { display: block; margin-top: 2px; color: #8f4a44; font-size: 9px; }
td input.invalid { border-color: var(--red); background: #f8e9e7; color: #782b25; }

.audit-panel { background: var(--sheet); border-left: 1px solid var(--line); padding: 20px 17px; }
.audit-head { display: flex; justify-content: space-between; align-items: start; }
.audit-head > span { font: 11px "SFMono-Regular", Consolas, monospace; color: var(--muted); }
.audit-head > span b { color: var(--teal); font-size: 19px; }
.audit-meter { height: 4px; margin: 12px 0 19px; border-radius: 3px; background: #e1e3de; overflow: hidden; }
.audit-meter i { display: block; width: 62.5%; height: 100%; background: var(--teal); transform-origin: left center; transition: transform .25s ease-out; }
.audit-group { padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.audit-group h3, .output-block h3 { display: flex; justify-content: space-between; margin: 0 0 10px; font-size: 10px; }
.audit-group h3 span { color: var(--teal); font-weight: 600; }
.audit-group ul { list-style: none; padding: 0; margin: 0; }
.audit-group li { display: grid; grid-template-columns: 20px 1fr; gap: 7px; align-items: start; padding: 6px 0; }
.audit-group li b { display: grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; background: #dfeee7; color: #287351; font-size: 9px; }
.audit-group li.stale b { border-radius: 4px; background: var(--orange-soft); color: var(--orange); }
.audit-group li.stale span { color: #75431f; }
.audit-group li span { font-size: 9px; font-weight: 600; }
.audit-group li small, .pending-group label small { display: block; margin-top: 2px; color: var(--muted); font-size: 8px; font-weight: 500; }
.pending-group { padding: 15px 0; }
.pending-group h3 span { color: var(--orange); }
.pending-group label { display: grid; grid-template-columns: 18px 1fr; gap: 7px; margin: 10px 0; cursor: pointer; }
.pending-group input { appearance: none; width: 16px; height: 16px; margin: 0; border: 1px solid #b7bbb6; border-radius: 4px; background: white; }
.pending-group input:checked { border-color: var(--teal); background: var(--teal); box-shadow: inset 0 0 0 3px white; }
.pending-group strong { display: block; font-size: 9px; }
.output-block { padding-top: 15px; }
.output-block > div { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; padding: 7px 0; }
.file-type { display: grid; place-items: center; width: 27px; height: 30px; border-radius: 3px; background: #dcebe3; color: #246c4e; font: 700 7px "SFMono-Regular", Consolas, monospace; }
.file-type.contract { background: #ece7d9; color: #735d25; font-size: 6px; }
.file-type.red { background: #f1dfdc; color: var(--red); }
.file-type.blue { background: #dce7ef; color: #376c8e; }
.output-block p { margin: 0; font-size: 9px; font-weight: 650; }
.output-block p small { display: block; margin-top: 2px; color: var(--muted); font-size: 8px; font-weight: 500; }
.output-block p small[data-output-filename] { max-width: 118px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.output-block div > b { color: var(--teal); font-size: 7px; font-weight: 650; }

.toast { position: fixed; right: 24px; bottom: 24px; padding: 12px 15px; border-radius: 8px; background: #17201d; color: white; box-shadow: 0 12px 30px rgba(0,0,0,.18); font-size: 11px; transform: translateY(80px); opacity: 0; transition: .25s ease-out; }
.toast.show { transform: translateY(0); opacity: 1; }
.customer-library, .product-library, .draft-library { min-height: 100vh; background: var(--paper); }
.template-library { min-height: 100vh; background: var(--paper); }
.history-library { min-height: 100vh; background: var(--paper); }
.history-body { padding: 22px 28px 36px; }
.draft-body { padding: 22px 28px 36px; }
.draft-intro { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.draft-intro strong { font-size: 13px; }
.draft-intro span { color: var(--muted); font-size: 9px; }
.draft-record { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 24px; padding: 18px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--sheet); box-shadow: var(--shadow); }
.draft-record h2 { margin: 0; font-size: 15px; }
.draft-record p { margin: 6px 0 0; color: var(--muted); font-size: 9px; }
.draft-record-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 13px; color: var(--ink); font-size: 9px; }
.draft-record-actions { display: flex; gap: 8px; }
.history-intro { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.history-intro strong { font-size: 13px; }
.history-intro span { color: var(--muted); font-size: 9px; }
.history-list { display: grid; gap: 14px; }
.history-record { overflow: hidden; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--sheet); box-shadow: var(--shadow); }
.history-record > header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.history-record > header strong { font-size: 12px; }
.history-record > header small { display: block; margin-top: 3px; color: var(--muted); font-size: 8px; }
.history-title-line { display: flex; align-items: center; gap: 9px; }
.review-status { display: inline-flex; align-items: center; min-height: 20px; padding: 0 7px; border-radius: 999px; background: #efe3c8; color: #855e16; font-size: 8px; font-weight: 750; }
.review-approved .review-status { background: var(--teal-soft); color: var(--teal); }
.review-pending { background: linear-gradient(90deg, var(--changed-amber-soft), var(--sheet) 42px); }
.history-record-actions { display: flex; align-items: center; gap: 10px; }
.history-record-actions > span { color: var(--muted); font-size: 9px; }
.history-record-actions .download-all { border-radius: 5px; background: var(--teal); color: #fff; font-size: 8px; font-weight: 700; padding: 6px 9px; text-decoration: none; }
.history-record-actions .download-all:hover { filter: brightness(.94); }
.history-record-actions button { border: 1px solid var(--line-strong); border-radius: 5px; background: transparent; color: var(--muted); font-size: 8px; font-weight: 700; padding: 5px 8px; }
.history-record-actions button:hover { border-color: #c85e4d; color: #a63f31; }
.history-record-actions .edit-archive-button { border-color: var(--teal); color: var(--teal); }
.history-record-actions .edit-archive-button:hover { background: var(--teal-soft); border-color: var(--teal); color: var(--teal-deep); }
.history-record-actions .edit-lock { color: var(--muted); font-size: 8px; white-space: nowrap; }
.history-record-actions .review-button { border-color: var(--teal); background: var(--teal); color: #fff; }
.history-record-actions .review-button:hover { filter: brightness(.94); color: #fff; }
.history-record-actions button.confirming { border-color: #b74433; background: #b74433; color: #fff; }
.history-record-actions button:disabled { cursor: wait; opacity: .65; }
.history-files { display: grid; grid-template-columns: repeat(5, minmax(145px, 1fr)); }
.history-files > div { display: grid; grid-template-columns: 35px 1fr; align-items: center; gap: 8px; min-width: 0; padding: 12px; border-right: 1px solid var(--line); }
.history-files > div:last-child { border-right: 0; }
.history-files p { min-width: 0; margin: 0; }
.history-files p strong { font-size: 9px; }
.history-files p small { display: block; overflow: hidden; margin-top: 3px; color: var(--muted); font-size: 7px; text-overflow: ellipsis; white-space: nowrap; }
.history-files a { grid-column: 2; width: max-content; color: var(--teal); font-size: 8px; font-weight: 700; text-decoration: none; }
.history-files a:hover { text-decoration: underline; }
.history-empty { display: grid; gap: 5px; padding: 58px 20px; border: 1px dashed var(--line-strong); border-radius: 9px; background: var(--sheet); text-align: center; }
.history-empty[hidden] { display: none; }
.history-empty strong { font-size: 13px; }
.history-empty span { color: var(--muted); font-size: 9px; }
.archive-output-button { width: 100%; margin-top: 11px; }
.library-topbar { min-height: 108px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 28px; border-bottom: 1px solid var(--line); background: var(--sheet); }
.library-topbar h1 { margin-top: 7px; }
.library-topbar p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.library-actions { display: flex; align-items: center; gap: 12px; }
.library-body { display: grid; grid-template-columns: minmax(680px, 1fr) auto; align-items: start; gap: 18px; padding: 22px 28px; }
.customer-list-panel { min-width: 0; }
.library-tools { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 12px; }
.library-tools > span { color: var(--muted); font-size: 10px; }
.search-box { display: flex; align-items: center; gap: 7px; width: min(390px, 55%); height: 35px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--sheet); }
.search-box svg { width: 16px; color: var(--muted); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 11px; }
.customer-table-wrap { overflow: hidden; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--sheet); box-shadow: var(--shadow); }
.customer-table { table-layout: auto; }
.customer-table th { height: 39px; text-align: left; }
.customer-table th:nth-child(1) { width: 29%; }
.customer-table th:nth-child(2) { width: 20%; }
.customer-table th:nth-child(3) { width: 70px; }
.customer-table th:nth-child(4) { width: 24%; }
.customer-table th:nth-child(5) { width: 88px; text-align: right; }
.customer-table th:nth-child(6) { width: 34px; }
.customer-table td { height: 64px; text-align: left; vertical-align: middle; }
.customer-table td:nth-child(5) { text-align: right; }
.customer-name { font-size: 11px; }
.customer-name small, .customer-contact small { max-width: 250px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.currency-tag { display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px; border-radius: 4px; background: var(--teal-soft); color: var(--teal); font-size: 8px; font-weight: 700; }
.currency-tag.usd { background: var(--orange-soft); color: #8a451a; }
.empty-customers { padding: 44px !important; color: var(--muted); text-align: center !important; }
.new-customer-panel { position: sticky; top: 18px; width: 360px; padding: 17px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--sheet); box-shadow: var(--shadow); }
.form-head { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 17px; }
.form-head p { margin: 4px 0 0; color: var(--muted); font-size: 9px; }
.form-head > button { width: 28px; height: 28px; border: 0; background: transparent; color: var(--muted); font-size: 21px; }
#newCustomerForm, #newProductForm { display: grid; gap: 12px; }
#newCustomerForm label > span, #newProductForm label > span { display: block; margin-bottom: 5px; color: #555c57; font-size: 9px; font-weight: 700; }
#newCustomerForm input, #newCustomerForm select, #newCustomerForm textarea, #newProductForm input, #newProductForm select, #newProductForm textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 6px; background: white; color: var(--ink); font-size: 11px; }
#newCustomerForm input, #newCustomerForm select, #newProductForm input, #newProductForm select { height: 35px; padding: 0 9px; }
#newCustomerForm textarea, #newProductForm textarea { resize: vertical; padding: 8px 9px; line-height: 1.45; }
#newCustomerForm input[readonly] { background: #eeeee9; color: var(--teal); font-weight: 700; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.form-actions { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; padding-top: 5px; }
.customer-row-action { border: 0; background: transparent; color: var(--teal); font-size: 9px; font-weight: 700; }
.product-body { padding: 22px 28px 32px; }
.product-category-strip { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 10px; margin-bottom: 18px; }
.product-category-strip button { display: flex; align-items: center; justify-content: space-between; min-height: 54px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--sheet); color: var(--ink); text-align: left; }
.product-category-strip button:hover { border-color: var(--teal); background: var(--teal-soft); }
.product-category-strip strong { font-size: 11px; }
.product-category-strip span { color: var(--muted); font-size: 8px; }
.product-tools { display: grid; grid-template-columns: minmax(300px, 1fr) 190px auto; gap: 12px; align-items: end; margin-bottom: 12px; }
.product-search { width: 100%; }
.product-tools > span { align-self: center; color: var(--muted); font-size: 10px; white-space: nowrap; }
.product-category-select > span { display: block; margin-bottom: 5px; color: #555c57; font-size: 9px; font-weight: 700; }
.product-category-select select { width: 100%; height: 35px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--sheet); color: var(--ink); font-size: 10px; }
.product-table-wrap { overflow: hidden; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--sheet); box-shadow: var(--shadow); }
.product-workspace { display: flex; align-items: flex-start; gap: 16px; }
.product-workspace .product-table-wrap { flex: 1; min-width: 0; }
.new-product-panel { flex: 0 0 360px; }
.product-element-panel { flex: 0 0 440px; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--sheet); box-shadow: 0 12px 30px rgba(29,39,34,.08); }
.product-element-panel .form-head { padding: 16px 17px 13px; border-bottom: 1px solid var(--line); }
.product-element-panel form { padding: 14px 17px 17px; }
.element-table-wrap { overflow: hidden; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; }
.element-editor-table { table-layout: fixed; font-size: 9px; }
.element-editor-table th { height: 34px; padding: 6px 9px; background: #e8e8e2; color: #555c57; font-size: 8px; text-align: left; }
.element-editor-table th:nth-child(1) { width: 38px; text-align: center; }
.element-editor-table th:nth-child(2) { width: 132px; }
.element-editor-table th:nth-child(3) { width: auto; }
.element-editor-table th:nth-child(4) { width: 38px; }
.element-editor-row td { height: 47px; padding: 5px 7px; text-align: left; vertical-align: middle; }
.element-editor-row td:first-child { padding-inline: 4px; color: var(--muted); font: 700 8px "SFMono-Regular", Consolas, monospace; text-align: center; }
.element-editor-row td:last-child { padding-inline: 4px; text-align: center; }
.element-editor-row input, .element-editor-row textarea { width: 100%; min-width: 0; padding: 7px 8px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--ink); font: 500 9px/1.4 inherit; }
.element-editor-row textarea { min-height: 34px; resize: vertical; }
.element-editor-row:hover input, .element-editor-row:hover textarea { border-color: var(--line); background: var(--sheet); }
.element-editor-row input:focus, .element-editor-row textarea:focus { border-color: var(--teal); outline: 2px solid var(--orange-soft); outline-offset: 1px; }
.element-editor-row button { width: 28px; height: 28px; padding: 0; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--muted); font-size: 15px; }
.element-editor-row button:hover { background: #f6e7e5; color: var(--red); }
.add-element-row { width: 100%; margin-top: 9px; padding: 8px; border: 1px dashed var(--line-strong); border-radius: 6px; background: transparent; color: var(--teal); font-size: 9px; font-weight: 700; }
.add-element-row:hover { border-style: solid; background: var(--teal-soft); }
.element-form-note { margin-top: 10px; padding: 9px 10px; border: 1px solid #dfc9a8; border-radius: 6px; background: var(--orange-soft); color: #74451f; font-size: 8px; line-height: 1.5; }
.product-table { table-layout: auto; }
.product-table th { height: 40px; text-align: left; }
.product-table th:nth-child(1) { width: 130px; }
.product-table th:nth-child(2) { width: 160px; }
.product-table th:nth-child(3) { width: 190px; }
.product-table th:nth-child(4) { width: 115px; }
.product-table th:nth-child(6) { width: 90px; text-align: right; }
.product-table th:nth-child(7) { width: 66px; text-align: right; }
.product-table td { height: 62px; text-align: left; vertical-align: middle; }
.product-table td:last-child { text-align: right; }
.product-edit-button { padding: 5px 8px; border: 1px solid #bfd3ce; border-radius: 5px; background: #fff; color: var(--teal); font-size: 8px; font-weight: 750; }
.product-edit-button:hover { border-color: var(--teal); background: var(--teal-soft); }
.product-table td small { margin-top: 4px; font-family: inherit; }
.product-table code { color: var(--teal); font: 700 9px "SFMono-Regular", Consolas, monospace; }
.product-category-tag { display: inline-flex; align-items: center; min-height: 23px; padding: 0 7px; border-radius: 4px; background: var(--teal-soft); color: var(--teal); font-size: 8px; font-weight: 700; }
.declaration-summary { color: #4f5752; font-size: 9px; line-height: 1.5; }
.product-element-link { display: block; padding: 5px 7px; border: 1px solid #bfd3ce; border-radius: 6px; background: var(--teal-soft); color: var(--teal); text-align: left; }
.product-element-link:hover { border-color: var(--teal); background: #d8e9e5; }
.product-element-link strong, .product-element-link small { display: block; }
.product-element-link strong { font-size: 9px; }
.product-element-link small { color: #59716b; font-size: 8px; font-weight: 600; }
.template-ready { display: grid; grid-template-columns: auto auto; align-items: center; gap: 7px; padding: 7px 11px; border: 1px solid #bfd3ce; border-radius: 7px; background: var(--teal-soft); color: var(--teal); }
.template-ready b { font: 700 20px "SFMono-Regular", Consolas, monospace; }
.template-ready small { max-width: 50px; font-size: 8px; line-height: 1.3; }
.template-body { padding: 22px 28px; }
.template-intro { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 13px 15px; border: 1px solid #c9d9d4; border-radius: 9px; background: var(--teal-soft); }
.template-intro strong { display: block; color: #183d38; font-size: 11px; }
.template-intro small { display: block; margin-top: 3px; color: #62746f; font-size: 9px; }
.template-intro fieldset { display: flex; gap: 6px; margin: 0; padding: 0; border: 0; }
.template-intro legend { position: absolute; width: 1px; height: 1px; overflow: hidden; }
.template-intro label { position: relative; cursor: pointer; }
.template-intro input { position: absolute; opacity: 0; }
.template-intro label span { display: block; padding: 7px 12px; border: 1px solid #b4c8c3; border-radius: 6px; background: white; color: #53635f; font-size: 9px; font-weight: 700; }
.template-intro input:checked + span { border-color: var(--teal); background: var(--teal); color: white; }
.template-grid { display: grid; grid-template-columns: repeat(3, minmax(220px, 1fr)); gap: 13px; margin-top: 16px; }
.template-card { display: grid; grid-template-rows: auto 1fr auto; min-height: 185px; padding: 16px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--sheet); }
.template-card.selected { border-color: var(--teal); box-shadow: inset 0 3px 0 var(--teal); }
.template-card-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.template-file-icon { display: grid; place-items: center; width: 37px; height: 42px; border-radius: 5px; background: #dcebe3; color: var(--teal); font: 700 8px "SFMono-Regular", Consolas, monospace; }
.template-card.selected .template-choice { color: var(--teal); }
.template-choice { color: var(--muted); font-size: 8px; font-weight: 700; }
.template-card h2 { margin-top: 12px; font-size: 13px; }
.template-card p { margin: 5px 0; color: var(--muted); font-size: 9px; line-height: 1.45; }
.template-card code { display: block; overflow: hidden; color: #727975; font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.template-card-actions { display: flex; gap: 7px; align-items: center; margin-top: 14px; padding-top: 11px; border-top: 1px solid var(--line); }
.template-card-actions a, .template-card-actions button { height: 29px; padding: 0 10px; border-radius: 6px; font-size: 9px; font-weight: 700; }
.template-card-actions a { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); background: white; color: var(--ink); text-decoration: none; }
.template-card-actions button { margin-left: auto; border: 1px solid var(--teal); background: var(--teal); color: white; }
.template-card-actions button:disabled { border-color: #b8c7c3; background: #dfe9e6; color: #58706a; cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid #d08a50; outline-offset: 2px; }

/* Internal authentication */
.login-page { min-width: 0; min-height: 100vh; background: var(--paper); }
.login-shell { display: grid; grid-template-columns: minmax(430px, 1.05fr) minmax(390px, .95fr); min-height: 100vh; }
.login-intro { display: flex; flex-direction: column; justify-content: space-between; padding: 42px 52px 36px; color: #eef3f0; background: var(--rail); }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand .brand-mark { width: 40px; height: 40px; }
.login-brand strong { display: block; font-size: 15px; }
.login-brand small { display: block; margin-top: 3px; color: var(--rail-muted); font: 8px "SFMono-Regular", Consolas, monospace; letter-spacing: .14em; }
.login-copy { max-width: 570px; margin: 70px 0; }
.internal-mark { display: inline-flex; padding: 5px 8px; border: 1px solid rgba(226,180,110,.6); border-radius: 4px; color: #e2b46e; font-size: 9px; font-weight: 700; letter-spacing: .12em; }
.login-copy h1 { margin-top: 24px; color: white; font-size: clamp(31px, 4vw, 52px); line-height: 1.15; letter-spacing: -.035em; }
.login-copy p { max-width: 440px; margin: 22px 0 0; color: #b9c6c0; font-size: 13px; line-height: 1.8; }
.login-foot { display: flex; flex-wrap: wrap; gap: 20px; color: #93a19a; font-size: 9px; }
.login-foot span::before { content: "✓"; margin-right: 6px; color: #e2b46e; }
.login-card { display: flex; flex-direction: column; justify-content: center; width: min(420px, calc(100% - 64px)); margin: auto; }
.login-seal { display: grid; place-items: center; width: 43px; height: 43px; margin-bottom: 24px; border: 2px solid var(--red); color: var(--red); font-size: 10px; font-weight: 800; transform: rotate(-4deg); }
.login-card h2 { font-size: 23px; }
.login-card > div > p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
#loginForm { display: grid; gap: 17px; margin-top: 34px; }
#loginForm label > span:first-child { display: block; margin-bottom: 7px; color: #4f5652; font-size: 10px; font-weight: 700; }
#loginForm input { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--sheet); font-size: 12px; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 58px !important; }
.password-field button { position: absolute; right: 8px; top: 7px; height: 30px; border: 0; background: transparent; color: var(--teal); font-size: 9px; font-weight: 700; }
.login-submit { width: 100%; height: 44px; margin-top: 5px; }
.login-submit:disabled { opacity: .65; }
.login-error { padding: 10px 12px; border: 1px solid #d9aaa5; border-radius: 4px; background: #f8e9e7; color: #782b25; font-size: 10px; }
.login-help { margin: 20px 0 0; color: var(--muted); font-size: 9px; }
.site-filing { margin-top: 28px; padding-top: 15px; border-top: 1px solid var(--line); }
.site-filing a { color: var(--muted); font-size: 9px; line-height: 1.5; text-decoration: none; }
.site-filing a:hover, .site-filing a:focus-visible { color: var(--teal); text-decoration: underline; text-underline-offset: 3px; outline: none; }
.account-dialog { width: min(680px, calc(100vw - 40px)); max-height: min(760px, calc(100vh - 40px)); padding: 0; border: 1px solid var(--line-strong); border-radius: 12px; color: var(--ink); background: var(--sheet); box-shadow: 0 28px 80px rgba(17,29,24,.25); }
.account-dialog::backdrop { background: rgba(15,24,21,.58); backdrop-filter: blur(3px); }
.account-dialog-head { display: flex; align-items: start; justify-content: space-between; padding: 20px 22px 16px; border-bottom: 1px solid var(--line); }
.account-dialog-head span { color: var(--teal); font-size: 8px; font-weight: 800; letter-spacing: .1em; }
.account-dialog-head h2 { margin-top: 5px; }
.account-dialog-head button { border: 0; background: transparent; color: var(--muted); font-size: 24px; }
.account-profile { display: flex; align-items: center; gap: 11px; padding: 15px 22px; background: var(--teal-soft); }
.account-profile .avatar { width: 38px; height: 38px; }
.account-profile strong { display: block; font-size: 12px; }
.account-profile small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.account-section { padding: 17px 22px; border-bottom: 1px solid var(--line); }
.account-section h3 { margin: 0 0 10px; font-size: 11px; }
.account-section-title { display: flex; justify-content: space-between; align-items: start; }
.account-section-title p { margin: 3px 0 0; color: var(--muted); font-size: 8px; }
#passwordForm { display: grid; grid-template-columns: 1fr 1.35fr auto; gap: 8px; }
.account-section input, .account-section select { height: 35px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 6px; background: white; font-size: 10px; }
#createUserForm { margin: 12px 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #f5f4ef; }
.create-user-help { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.create-user-help span { color: var(--muted); font-size: 8px; }
.create-user-help button { border: 0; background: transparent; color: var(--teal); font-size: 8px; font-weight: 700; }
.form-status { margin: 9px 0 0; padding: 8px 9px; border: 1px solid #d9aaa5; border-radius: 6px; background: #f8e9e7; color: #782b25; font-size: 9px; }
.form-status.success { border-color: #bfd3ce; background: var(--teal-soft); color: var(--teal); }
.audit-choice { display: grid !important; grid-template-columns: 1fr !important; gap: 7px; padding: 10px 0 !important; cursor: default !important; }
.audit-choice > span { display: block; }
.audit-choice input, .audit-choice select { appearance: auto; width: 100%; height: 31px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--sheet); color: var(--ink); font-size: 9px; }
.audit-choice input:focus, .audit-choice select:focus { border-color: var(--teal); outline: 2px solid var(--orange-soft); outline-offset: 1px; }
.user-list { display: grid; margin-top: 10px; }
.user-list-row { display: grid; grid-template-columns: 32px 1fr auto; gap: 9px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.user-list-row:first-child { border-top: 0; }
.user-list-row .avatar { width: 30px; height: 30px; font-size: 9px; }
.user-list-row strong { display: block; font-size: 10px; }
.user-list-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 8px; }
.user-list-row.inactive { opacity: .58; }
.user-list-row em { color: var(--teal); font-size: 8px; font-style: normal; }
.user-list-row button { border: 0; background: transparent; color: var(--red); font-size: 8px; font-weight: 700; }
.user-actions { display: flex; align-items: center; gap: 8px; }
.user-actions button:first-child { color: var(--teal); }
.user-actions .user-delete.confirming { padding: 4px 6px; border-radius: 4px; background: var(--red); color: var(--sheet); }
.account-dialog-actions { display: flex; align-items: center; justify-content: space-between; padding: 15px 22px; }
.account-dialog-actions span { color: var(--muted); font-size: 8px; }

@media (max-width: 760px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-intro { min-height: 260px; padding: 28px; }
  .login-copy { margin: 35px 0 20px; }
  .login-copy h1 { font-size: 30px; }
  .login-foot { display: none; }
  .login-card { width: calc(100% - 48px); padding: 45px 0; }
  #passwordForm { grid-template-columns: 1fr; }
}

@media (max-width: 1180px) {
  body { min-width: 820px; }
  .app-shell { grid-template-columns: 68px minmax(750px, 1fr); }
  .rail { padding-inline: 10px; }
  .brand { padding-inline: 7px; justify-content: center; }
  .brand > span:last-child { display: none; }
  .nav-item:not(.active)::after, .nav-item { font-size: 0; }
  .nav-item { grid-template-columns: 1fr; justify-items: center; padding: 12px 8px; }
  .nav-item span { position: absolute; margin: -23px 0 0 24px; font-size: 8px; }
  .archive-stat, .user-row > span:not(.avatar), .rail-filing { display: none; }
  .user-row { display: flex; justify-content: center; }
  .content-grid { grid-template-columns: minmax(680px, 1fr) 230px; }
  .customer-fields { grid-template-columns: minmax(230px, 1fr) 190px 150px; gap: 12px; }
  .saved { display: none; }
  .product-workspace:has(.product-element-panel:not([hidden])) { flex-direction: column; }
  .product-workspace:has(.product-element-panel:not([hidden])) .product-table-wrap { width: 100%; overflow-x: auto; }
  .product-workspace:has(.product-element-panel:not([hidden])) .product-element-panel { width: 100%; flex-basis: auto; }
  .product-workspace:has(.product-element-panel:not([hidden])) .element-editor-table th:nth-child(2) { width: 31%; }
}

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