:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --ink: #18212b;
  --muted: #66717e;
  --muted-2: #8a949f;
  --line: #e3e7eb;
  --line-strong: #d7dce1;
  --orange: #f05a24;
  --orange-dark: #d94813;
  --orange-soft: #fff1eb;
  --blue: #2e6ddb;
  --blue-soft: #edf4ff;
  --green: #27805b;
  --green-soft: #eaf7f0;
  --amber: #a96308;
  --amber-soft: #fff5dd;
  --red: #c83d3d;
  --red-soft: #fff0f0;
  --navy: #263748;
  --shadow: 0 10px 32px rgba(32, 43, 55, .07);
  --radius: 14px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); }
.auth-screen { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg,#eef2f5,#f8fafb); }
.auth-screen[hidden] { display: none; }
.auth-card { width: min(410px,100%); padding: 34px; border: 1px solid var(--line); border-radius: 18px; background: white; box-shadow: 0 24px 70px rgba(25,37,48,.15); }
.auth-card .brand-mark { margin-bottom: 22px; }
.auth-card h1 { margin: 4px 0 7px; font-size: 25px; }
.auth-card > p:not(.eyebrow):not(.auth-message) { margin: 0 0 26px; color: var(--muted); font-size: 13px; }
.auth-card .field { margin-top: 15px; }
.auth-card .button { width: 100%; margin-top: 22px; }
.auth-message { min-height: 20px; margin: 12px 0 0; color: var(--red); font-size: 12px; text-align: center; }
.user-badge { color: var(--muted); font-size: 12px; white-space: nowrap; }
.finance-restricted { display: none !important; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.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; }

.app-shell { min-height: 100vh; }
.topbar { min-height: 76px; padding: 13px clamp(20px, 4vw, 58px); background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 42px; height: 42px; border-radius: 10px; background: var(--navy); display: grid; grid-template-columns: repeat(3, 6px); gap: 3px; place-content: center; box-shadow: inset 0 -2px 0 rgba(0,0,0,.13); }
.brand-mark span { width: 6px; border-radius: 2px; background: var(--orange); }
.brand-mark span:nth-child(1) { height: 12px; }
.brand-mark span:nth-child(2) { height: 22px; }
.brand-mark span:nth-child(3) { height: 16px; }
.brand h1 { margin: 0 0 2px; font-size: 18px; letter-spacing: .02em; }
.brand p { margin: 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.today { color: var(--muted); font-size: 13px; margin-right: 8px; }

.button { min-height: 40px; border: 1px solid transparent; border-radius: 9px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 650; font-size: 13px; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: white; background: var(--orange); box-shadow: 0 5px 15px rgba(240, 90, 36, .2); }
.button-primary:hover { background: var(--orange-dark); }
.button-ghost { color: #3d4854; background: var(--surface); border-color: var(--line-strong); }
.button-ghost:hover { border-color: #bbc3ca; background: var(--surface-soft); }
.button-danger { color: white; background: var(--red); }
.button-danger-text { color: var(--red); background: transparent; border-color: transparent; }
.icon-button { width: 40px; height: 40px; border-radius: 9px; border: 1px solid var(--line-strong); color: var(--muted); background: var(--surface); display: inline-grid; place-items: center; transition: .18s ease; }
.icon-button:hover { color: var(--ink); border-color: #b7c0c9; background: var(--surface-soft); }
.text-button { padding: 5px 0; border: 0; background: transparent; color: var(--orange-dark); font-size: 13px; font-weight: 650; }

main { width: min(1500px, calc(100% - clamp(32px, 7vw, 110px))); margin: 0 auto; padding: 34px 0 60px; }
section + section { margin-top: 34px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading.compact { margin-bottom: 14px; }
.eyebrow { margin: 0 0 4px; color: var(--orange); font-size: 10px; line-height: 1.2; font-weight: 800; letter-spacing: .16em; }
.section-heading h2, .drawer-header h2 { margin: 0; font-size: 22px; line-height: 1.25; letter-spacing: -.02em; }
.sync-hint { margin: 0 0 2px; color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 7px; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: #30a46c; box-shadow: 0 0 0 4px #e8f7ef; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card { min-height: 118px; padding: 19px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 3px 14px rgba(32,43,55,.035); display: flex; justify-content: space-between; gap: 12px; }
.metric-label { color: var(--muted); font-size: 12px; font-weight: 650; }
.metric-value { margin-top: 10px; font-size: 30px; line-height: 1; font-weight: 760; letter-spacing: -.04em; }
.metric-foot { margin-top: 10px; color: var(--muted-2); font-size: 11px; }
.metric-icon { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--navy); background: #eef1f4; }
.metric-card.warning .metric-icon { color: var(--amber); background: var(--amber-soft); }
.metric-card.danger .metric-icon { color: var(--red); background: var(--red-soft); }
.metric-card.accent .metric-icon { color: var(--orange-dark); background: var(--orange-soft); }

.status-panel { margin-top: 14px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 3px 14px rgba(32,43,55,.035); }
.panel-title-row { display: flex; justify-content: space-between; align-items: start; gap: 20px; }
.panel-title-row h3 { margin: 0 0 4px; font-size: 14px; }
.panel-title-row p { margin: 0; color: var(--muted); font-size: 11px; }
.status-strip { margin-top: 18px; display: grid; grid-template-columns: repeat(7, minmax(88px, 1fr)); gap: 8px; }
.status-item { position: relative; min-height: 68px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); padding: 12px 12px 10px; text-align: left; color: var(--ink); overflow: hidden; transition: .16s ease; }
.status-item:hover, .status-item.active { border-color: #f3a787; background: #fff9f6; }
.status-name { position: relative; z-index: 1; display: block; color: var(--muted); font-size: 11px; white-space: nowrap; }
.status-count { position: relative; z-index: 1; display: block; margin-top: 6px; font-size: 21px; font-weight: 760; }
.status-bar { position: absolute; bottom: 0; left: 0; height: 3px; background: var(--orange); }

.result-count { margin: 0 0 3px; color: var(--muted); font-size: 12px; }
.filter-bar { display: grid; grid-template-columns: minmax(280px, 1fr) repeat(3, minmax(130px, 170px)) 40px; gap: 9px; margin-bottom: 12px; }
.filter-bar select, .search-field { height: 42px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); }
.filter-bar select { width: 100%; padding: 0 34px 0 12px; color: #46515c; outline: none; }
.filter-bar select:focus, .search-field:focus-within { border-color: #f39a77; box-shadow: 0 0 0 3px var(--orange-soft); }
.search-field { display: flex; align-items: center; gap: 9px; padding: 0 13px; }
.search-field svg { width: 18px; color: var(--muted-2); }
.search-field input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 13px; }
.search-field input::placeholder { color: #9aa3ad; }

.table-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 1050px; border-collapse: collapse; }
thead { background: #f8f9fa; }
th { padding: 12px 15px; border-bottom: 1px solid var(--line); color: #77818c; font-size: 10px; text-align: left; font-weight: 750; letter-spacing: .05em; white-space: nowrap; }
td { padding: 14px 15px; border-bottom: 1px solid #edf0f2; font-size: 12px; vertical-align: middle; }
tbody tr { transition: .14s ease; }
tbody tr:hover { background: #fffaf7; }
tbody tr:last-child td { border-bottom: 0; }
.order-name { max-width: 260px; font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-sub { margin-top: 4px; color: var(--muted); font-size: 11px; }
.type-chip { display: inline-flex; padding: 5px 8px; border-radius: 6px; font-size: 11px; font-weight: 650; white-space: nowrap; }
.type-结构件 { color: #426378; background: #edf4f7; }
.type-机加工件 { color: #6b55a0; background: #f2effb; }
.type-成套设备 { color: #a14b1f; background: #fff0e8; }
.project-code { font-family: "SFMono-Regular", Consolas, monospace; font-weight: 700; color: #34414e; }
.project-parts { margin-top: 4px; display: flex; gap: 5px; color: var(--muted); font-size: 10px; }
.project-parts span { padding: 2px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-soft); }
.due-date { font-weight: 650; white-space: nowrap; }
.risk-label { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.risk-label.overdue { color: var(--red); font-weight: 650; }
.risk-label.soon { color: var(--amber); font-weight: 650; }
.status-select { min-width: 112px; height: 32px; padding: 0 24px 0 9px; border-radius: 7px; border: 1px solid var(--line); color: #43505d; background: var(--surface-soft); font-size: 11px; outline: none; }
.status-select:focus { border-color: #f19a76; }
.owner { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--navy); color: white; display: inline-grid; place-items: center; font-size: 10px; font-weight: 700; }
.row-action { border: 0; color: var(--muted); background: transparent; border-radius: 7px; width: 32px; height: 32px; display: grid; place-items: center; }
.row-action:hover { color: var(--orange-dark); background: var(--orange-soft); }
.empty-state { padding: 64px 20px; text-align: center; }
.empty-icon { margin: 0 auto 12px; width: 48px; height: 48px; border-radius: 50%; background: #f0f2f4; display: grid; place-items: center; color: var(--muted); font-size: 24px; }
.empty-state h3 { margin: 0 0 6px; font-size: 15px; }
.empty-state p { margin: 0 0 18px; color: var(--muted); font-size: 12px; }

.drawer-backdrop, .dialog-backdrop { position: fixed; inset: 0; background: rgba(23, 30, 37, .42); backdrop-filter: blur(2px); z-index: 60; }
.drawer { position: fixed; top: 0; right: 0; z-index: 70; width: min(620px, 100vw); height: 100vh; background: var(--surface); box-shadow: -16px 0 48px rgba(20, 28, 36, .18); transform: translateX(104%); transition: transform .25s ease; display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
.drawer-header { padding: 22px 24px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: start; }
.drawer form { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.form-scroll { min-height: 0; flex: 1; overflow-y: auto; padding: 22px 24px 30px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 14px; }
.form-grid.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { color: #5b6671; font-size: 11px; font-weight: 650; }
.field b { color: var(--orange); }
.field-span-2 { grid-column: span 2; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; color: var(--ink); outline: 0; padding: 10px 11px; font-size: 13px; transition: .15s ease; }
.field input, .field select { height: 42px; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #f29470; box-shadow: 0 0 0 3px var(--orange-soft); }
.form-divider { margin: 24px 0 15px; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .08em; }
.form-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.code-preview { margin-top: 11px; padding: 9px 11px; border-radius: 7px; color: var(--muted); background: var(--surface-soft); border: 1px dashed var(--line-strong); font-size: 11px; }
.code-preview strong { color: var(--orange-dark); font-family: "SFMono-Regular", Consolas, monospace; }
.drawer-footer { padding: 14px 24px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 9px; background: #fbfcfc; }
.footer-spacer { flex: 1; }

.dialog-backdrop { display: grid; place-items: center; z-index: 90; padding: 20px; }
.dialog-backdrop[hidden] { display: none; }
.dialog { width: min(390px, 100%); padding: 26px; text-align: center; border-radius: 16px; background: var(--surface); box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.dialog-icon { margin: 0 auto 14px; width: 42px; height: 42px; border-radius: 50%; color: var(--red); background: var(--red-soft); display: grid; place-items: center; font-weight: 800; }
.dialog h2 { margin: 0 0 7px; font-size: 18px; }
.dialog p { margin: 0; color: var(--muted); font-size: 12px; }
.dialog-actions { margin-top: 22px; display: flex; justify-content: center; gap: 9px; }
.toast { position: fixed; z-index: 110; left: 50%; bottom: 28px; transform: translate(-50%, 20px); padding: 11px 16px; border-radius: 9px; color: white; background: #273542; box-shadow: 0 12px 30px rgba(15, 25, 35, .2); font-size: 12px; opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1080px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .status-strip { grid-template-columns: repeat(4, 1fr); }
  .filter-bar { grid-template-columns: 1fr repeat(3, 140px) 40px; }
}
@media (max-width: 780px) {
  .topbar { position: static; align-items: flex-start; padding: 14px 18px; }
  .brand p, .today, #exportButton { display: none; }
  .brand h1 { font-size: 16px; }
  .topbar-actions .button { padding: 0 12px; }
  main { width: calc(100% - 28px); padding-top: 24px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-card { min-height: 105px; padding: 16px; }
  .metric-value { font-size: 26px; }
  .status-strip { display: flex; overflow-x: auto; padding-bottom: 3px; }
  .status-item { flex: 0 0 118px; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .filter-bar .icon-button { width: 100%; }
  .form-grid.three-col { grid-template-columns: 1fr; }
  .section-heading h2, .drawer-header h2 { font-size: 20px; }
}
@media (max-width: 520px) {
  .brand-mark { width: 36px; height: 36px; }
  #addOrderButton svg { display: none; }
  .metric-grid { gap: 9px; }
  .metric-card { padding: 14px; }
  .metric-icon { display: none; }
  .metric-foot { font-size: 10px; }
  .status-panel { padding: 16px; }
  .sync-hint { display: none; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .filter-bar label:nth-of-type(4) { grid-column: 1 / -1; }
  .filter-bar .icon-button { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: span 1; }
  .drawer-header, .form-scroll, .drawer-footer { padding-left: 18px; padding-right: 18px; }
  .drawer-footer .button { padding: 0 11px; }
}

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

.drawer { width: min(1240px, 100vw); }
.parts-section { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 22px; }
.parts-section p { font-size: 12px; color: var(--muted); line-height: 1.7; }
.parts-table-wrap { overflow: auto; margin-top: 14px; max-height: 430px; border: 1px solid var(--line); border-radius: 8px; }
.parts-table { min-width: 1090px; }
.parts-table th { position: sticky; top: 0; background: #f8f9fa; z-index: 1; }
.parts-table td { padding: 8px 5px; }
.parts-table input { width: 100%; min-width: 78px; padding: 8px; border: 1px solid var(--line-strong); border-radius: 5px; font-size: 12px; }
.parts-table td:nth-child(2) input, .parts-table td:nth-child(3) input { min-width: 145px; }
.parts-table output { display: block; min-width: 75px; text-align: right; }
.parts-table button { white-space: nowrap; }
.parts-table input:focus { outline: 2px solid #f39a77; }

.vendor-row {display:grid;grid-template-columns:1fr 2fr 1fr auto;gap:10px;margin:12px 0;align-items:end;}
@media(max-width:600px){.vendor-row{grid-template-columns:1fr; padding-bottom:14px;border-bottom:1px solid var(--line);}}

.import-actions{display:flex;gap:10px;flex-wrap:wrap;margin-top:12px}.import-actions a{text-decoration:none}.import-actions input{max-width:220px;font-size:12px}#importPreview{padding:12px;background:var(--surface-soft);border:1px solid var(--line);border-radius:8px}#importPreview .button{margin:12px 8px 0 0}

.parts-table {min-width:1580px;}

.parts-table{min-width:1900px}.parts-table select{min-width:70px;padding:8px;border:1px solid var(--line);border-radius:5px}
