:root {
  --bg: #f2f4f6;
  --surface: #ffffff;
  --surface-soft: #f7f9fa;
  --ink: #17212b;
  --muted: #667085;
  --line: #d6dde5;
  --line-strong: #b8c2cc;
  --brand: #087e78;
  --brand-dark: #075e5a;
  --blue: #2563a6;
  --green: #18794e;
  --amber: #9a5b00;
  --red: #b42318;
  --sidebar: #202932;
  --radius: 6px;
  --shadow: 0 12px 32px rgba(23, 33, 43, .14);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); font-size: 14px; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(37, 99, 166, .22); outline-offset: 2px; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 24px; line-height: 1.3; }
h2 { margin-bottom: 12px; font-size: 17px; line-height: 1.4; }
h3 { margin-bottom: 8px; font-size: 15px; line-height: 1.4; }
p { line-height: 1.65; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; z-index: 30; height: 100vh; display: flex; flex-direction: column; color: #edf2f5; background: var(--sidebar); border-right: 1px solid #10171d; }
.brand { min-height: 72px; display: flex; align-items: center; gap: 11px; padding: 14px 16px; border-bottom: 1px solid #39444e; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; color: #e6fffc; background: var(--brand); border: 1px solid #28a59e; border-radius: 6px; }
.brand-mark .icon { width: 22px; height: 22px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { margin-top: 3px; color: #aeb9c3; font-size: 11px; }
.main-nav { display: grid; gap: 4px; padding: 14px 10px; }
.nav-item { min-height: 42px; display: flex; align-items: center; gap: 11px; padding: 8px 11px; color: #d9e0e6; border: 1px solid transparent; border-radius: var(--radius); }
.nav-item:hover { color: #fff; background: #2a3540; }
.nav-item.active { color: #fff; background: #304047; border-color: #496067; box-shadow: inset 3px 0 0 #42c9bf; }
.sidebar-foot { margin-top: auto; padding: 15px 16px 18px; border-top: 1px solid #39444e; color: #aeb9c3; font-size: 11px; }
.sidebar-foot strong { display: block; margin-top: 4px; color: #fff; font-size: 12px; }
.main-area { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; min-height: 62px; display: flex; align-items: center; gap: 14px; padding: 9px 26px; background: rgba(255,255,255,.97); border-bottom: 1px solid var(--line); }
.crumb { color: var(--muted); }
.top-user { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.top-user > span:nth-child(2) { min-width: 80px; }
.top-user strong, .top-user small { display: block; }
.top-user strong { font-size: 12px; }
.top-user small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.avatar { width: 31px; height: 31px; display: grid; place-items: center; color: #fff; background: var(--brand); border-radius: 50%; font-weight: 700; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; padding: 0; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: var(--radius); cursor: pointer; }
.icon-btn:hover { color: var(--ink); background: var(--surface-soft); border-color: var(--line); }
.block { display: block; margin-top: 4px; }
.row-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.narrow-form { max-width: 620px; }
.page-wrap { max-width: 1400px; margin: 0 auto; padding: 26px 30px 44px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.page-head p { margin-bottom: 0; color: var(--muted); }
.page-actions { margin-left: auto; display: flex; gap: 8px; }
.btn { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 12px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); cursor: pointer; font-weight: 650; }
.btn:hover { background: #eef2f4; }
.btn.primary { color: #fff; background: var(--brand); border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: #fff; background: var(--red); border-color: var(--red); }
.btn.ghost { color: var(--muted); background: transparent; border-color: transparent; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.form-band { margin-bottom: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.band-head { min-height: 50px; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface-soft); border-bottom: 1px solid var(--line); }
.band-head h2 { margin: 0; }
.band-head .meta { margin-left: auto; color: var(--muted); font-size: 11px; }
.band-body { padding: 17px; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; }
.field { grid-column: span 4; min-width: 0; }
.field.span-2 { grid-column: span 6; }
.field.full { grid-column: 1 / -1; }
.field label, label.field { display: grid; gap: 6px; color: #475467; font-size: 12px; font-weight: 650; }
.field input, .field select, .field textarea, label.field input, label.field select, label.field textarea { width: 100%; min-height: 39px; padding: 8px 10px; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius); }
.field textarea, label.field textarea { min-height: 92px; resize: vertical; line-height: 1.55; }
.required::after { content: " *"; color: var(--red); }
.help { color: var(--muted); font-size: 11px; line-height: 1.5; }
.segment { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: #fff; }
.segment button { min-height: 36px; padding: 7px 13px; color: var(--muted); background: transparent; border: 0; border-right: 1px solid var(--line); cursor: pointer; }
.segment button:last-child { border-right: 0; }
.segment button.active { color: #fff; background: var(--brand); }
.toolbar { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; flex-wrap: wrap; }
.customer-search-toolbar { margin-top: 14px; }
.new-customer-grid { margin-top: 15px; }
.search-box { position: relative; min-width: 260px; flex: 1 1 360px; }
.search-box .icon { position: absolute; left: 10px; top: 10px; color: var(--muted); }
.search-box input { width: 100%; height: 40px; padding: 8px 11px 8px 37px; border: 1px solid var(--line-strong); border-radius: var(--radius); }
.result-list { display: grid; gap: 7px; margin-top: 10px; }
.result-item { width: 100%; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.result-item:hover, .result-item.selected { border-color: var(--brand); background: #f0fbfa; }
.result-item strong, .result-item small { display: block; }
.result-item small { margin-top: 4px; color: var(--muted); }
.selected-customer { display: none; align-items: center; gap: 10px; margin-top: 10px; padding: 11px 12px; color: #155b3b; background: #edf8f2; border: 1px solid #a9d3bb; border-radius: var(--radius); }
.selected-customer.show { display: flex; }
.selected-customer button { margin-left: auto; }
.warning-box { display: none; margin-top: 10px; padding: 11px 12px; color: #7a4a00; background: #fff7dd; border: 1px solid #e5cc7d; border-radius: var(--radius); }
.warning-box.show { display: block; }
.material-warning { color: var(--red) !important; border-color: #e49b94 !important; background: #fff5f3 !important; font-weight: 700; }
.check-row { display: inline-flex; align-items: center; gap: 8px; min-height: 39px; color: #475467; font-weight: 650; }
.check-row input { width: 18px; height: 18px; accent-color: var(--brand); }
.rush-check { color: var(--red); }
.paste-zone { min-height: 110px; display: grid; place-items: center; padding: 18px; color: var(--muted); background: var(--surface-soft); border: 1px dashed var(--line-strong); border-radius: var(--radius); text-align: center; cursor: text; }
.paste-zone:focus { color: var(--ink); border-color: var(--brand); background: #f1fbfa; }
.paste-icon { width: 24px; height: 24px; margin-bottom: 8px; }
.paste-title { display: block; color: #344054; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 12px; }
.preview-item { position: relative; min-width: 0; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.preview-item img { width: 100%; aspect-ratio: 4/3; display: block; object-fit: cover; border-radius: 4px; }
.preview-item small { display: block; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-item .icon-btn { position: absolute; top: 10px; right: 10px; color: #fff; background: rgba(28,36,43,.8); }
.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.summary-cell { min-width: 0; padding: 13px 15px; border-right: 1px solid var(--line); }
.summary-cell:last-child { border-right: 0; }
.summary-cell span, .summary-cell strong { display: block; }
.summary-cell span { color: var(--muted); font-size: 11px; }
.summary-cell strong { margin-top: 5px; overflow-wrap: anywhere; font-size: 15px; }
.total-preview { display: block; margin-top: 10px; font-size: 17px; }
.submit-bar { position: sticky; bottom: 0; z-index: 8; display: flex; align-items: center; gap: 12px; margin-top: 18px; padding: 12px 14px; background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 -8px 24px rgba(23,33,43,.07); }
.submit-bar .status { color: var(--muted); font-size: 12px; }
.submit-bar .btn { margin-left: auto; min-width: 150px; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.flush-table { border: 0; border-radius: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; line-height: 1.5; }
th { color: #475467; background: var(--surface-soft); font-size: 11px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfd; }
.row-link { color: var(--blue); font-weight: 700; }
.muted { color: var(--muted); }
.red-text { color: var(--red) !important; font-weight: 700; }
.tag { display: inline-flex; align-items: center; min-height: 23px; padding: 2px 7px; color: #475467; background: #f7f9fa; border: 1px solid var(--line); border-radius: 5px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.tag.green { color: #17633f; background: #eaf7ef; border-color: #a8d3b8; }
.tag.blue { color: #1e5a8a; background: #eaf4ff; border-color: #a9c9e8; }
.tag.amber { color: #7a4a00; background: #fff6dc; border-color: #e7cd82; }
.tag.red { color: #8e2018; background: #fff0ee; border-color: #efb4ae; }
.empty { padding: 48px 20px; color: var(--muted); text-align: center; }
.detail-grid { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(300px,.7fr); gap: 18px; align-items: start; }
.definition-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 24px; }
.definition-list.single-column { grid-template-columns: 1fr; }
.definition-item { min-height: 62px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.definition-item span, .definition-item strong { display: block; }
.definition-item span { color: var(--muted); font-size: 11px; }
.definition-item strong { margin-top: 5px; overflow-wrap: anywhere; }
.attachment-list { display: grid; gap: 8px; }
.attachment-link { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius); }
.attachment-link:hover { border-color: var(--blue); }
.action-stack { display: grid; gap: 9px; }
dialog { width: min(560px, calc(100vw - 28px)); padding: 0; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(18,26,33,.52); }
.dialog-head { min-height: 58px; display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; }
.dialog-head .icon-btn { margin-left: auto; }
.dialog-body { padding: 15px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 80; max-width: min(440px, calc(100vw - 32px)); padding: 11px 14px; color: #fff; background: #25313b; border: 1px solid #455563; border-radius: var(--radius); box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity .16s ease, transform .16s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #8e2018; border-color: #c76057; }
.login-body { display: grid; place-items: center; padding: 28px; background: #e9edf0; }
.login-layout { width: min(900px, 100%); min-height: 520px; display: grid; grid-template-columns: minmax(0,1.15fr) minmax(340px,.85fr); overflow: hidden; background: #fff; border: 1px solid #cbd3db; border-radius: 8px; box-shadow: 0 20px 50px rgba(22,31,40,.16); }
.login-brand { display: flex; flex-direction: column; justify-content: center; padding: 54px; color: #f4f8fa; background: #202a32; }
.login-mark { width: 70px; height: 70px; display: grid; place-items: center; margin-bottom: 28px; color: #fff; background: var(--brand); border: 1px solid #32a9a2; border-radius: 7px; font-weight: 800; }
.login-brand h1 { font-size: 30px; }
.login-brand p { color: #b9c5ce; }
.login-flow { display: flex; align-items: center; gap: 8px; margin-top: 36px; color: #dce5ea; font-size: 12px; }
.login-flow i { width: 24px; height: 1px; background: #5a6974; }
.login-panel { position: relative; display: flex; flex-direction: column; justify-content: center; padding: 44px; }
.login-head { display: flex; align-items: center; gap: 7px; margin-bottom: 18px; color: var(--muted); font-size: 11px; font-weight: 700; }
.status-dot { width: 8px; height: 8px; background: var(--green); border-radius: 50%; }
.login-panel h2 { margin-bottom: 22px; font-size: 23px; }
.login-panel form { display: grid; gap: 15px; }
.login-panel label { display: grid; gap: 7px; color: #475467; font-size: 12px; font-weight: 700; }
.login-panel input { height: 42px; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: var(--radius); }
.form-error { min-height: 20px; margin: -4px 0 0; color: var(--red); font-size: 12px; }
.dev-label { position: absolute; right: 16px; bottom: 14px; color: #98a2b3; font-size: 9px; font-weight: 800; }
[data-theme="dark"] {
  --bg: #151a1e;
  --surface: #22292f;
  --surface-soft: #293138;
  --ink: #edf2f5;
  --muted: #aab5be;
  --line: #3b464f;
  --line-strong: #52606b;
  --brand: #16a39a;
  --brand-dark: #11847d;
  --blue: #72aee6;
  --green: #5cc58e;
  --amber: #e7ad52;
  --red: #ed766d;
  --sidebar: #11171b;
}
[data-theme="dark"] .topbar,
[data-theme="dark"] .submit-bar { background: rgba(34,41,47,.97); }
[data-theme="dark"] .form-band,
[data-theme="dark"] .summary-strip,
[data-theme="dark"] .table-wrap,
[data-theme="dark"] .result-item,
[data-theme="dark"] .preview-item,
[data-theme="dark"] dialog { background: var(--surface); }
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea,
[data-theme="dark"] .segment { color: var(--ink); background: #1b2227; }
[data-theme="dark"] tbody tr:hover { background: #293138; }
[data-theme="dark"] .btn { color: var(--ink); background: #293138; }
[data-theme="dark"] .btn:hover { background: #35414a; }
[data-theme="dark"] .btn.primary,
[data-theme="dark"] .btn.danger { color: #fff; }
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 200px minmax(0,1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .field { grid-column: span 6; }
}
@media (max-width: 700px) {
  .app-shell { display: block; }
  .sidebar { position: sticky; width: 100%; height: auto; }
  .brand { min-height: 56px; padding: 8px 11px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand small, .sidebar-foot { display: none; }
  .main-nav { display: flex; gap: 5px; padding: 7px 8px 9px; overflow-x: auto; }
  .nav-item { min-width: 122px; min-height: 38px; padding: 7px 9px; white-space: nowrap; }
  .topbar { display: none; }
  .page-wrap { padding: 17px 13px 32px; }
  .page-head { display: block; }
  .page-actions { margin-top: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .field, .field.span-2, .field.full { grid-column: 1; }
  .summary-strip { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .summary-cell { border-bottom: 1px solid var(--line); }
  .summary-cell:nth-child(2n) { border-right: 0; }
  .summary-cell:nth-last-child(-n+2) { border-bottom: 0; }
  .table-wrap table { min-width: 760px; }
  .definition-list { grid-template-columns: 1fr; }
  .submit-bar { position: static; align-items: stretch; flex-direction: column; }
  .submit-bar .btn { width: 100%; margin-left: 0; }
  .toast { right: 8px; bottom: 8px; }
  .login-body { padding: 12px; }
  .login-layout { min-height: 0; grid-template-columns: 1fr; }
  .login-brand { padding: 30px 28px; }
  .login-mark { width: 52px; height: 52px; margin-bottom: 18px; }
  .login-brand h1 { font-size: 24px; }
  .login-flow { margin-top: 18px; }
  .login-panel { padding: 32px 28px 40px; }
}
