:root {
  color-scheme: light;
  --navy: #173a63;
  --navy-2: #214f7d;
  --blue: #2d78b8;
  --blue-soft: #eaf3fb;
  --ink: #172331;
  --muted: #637083;
  --line: #d9e0e8;
  --surface: #ffffff;
  --canvas: #f2f5f8;
  --green: #147d64;
  --amber: #a25a00;
  --red: #b33a3a;
  --shadow: 0 10px 30px rgba(24, 45, 70, 0.08);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-size: 16px; line-height: 1.5; }
.login-screen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #102b4a 0%, #245b89 100%); }
.login-screen.hidden { display: none; }
.login-card { width: min(420px, 100%); display: grid; gap: 15px; padding: 30px; background: #fff; border-radius: 16px; box-shadow: 0 25px 70px rgba(0,0,0,.3); }
.login-card img { width: 150px; height: 92px; object-fit: contain; justify-self: center; background: #343633; }
.login-card h1 { margin: 2px 0 0; text-align: center; color: var(--navy); }
.login-card p { margin: -8px 0 4px; text-align: center; color: var(--muted); }
.login-card .button { width: 100%; }
.login-error { min-height: 24px; color: var(--red); text-align: center; font-size: .9rem; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.topbar { min-height: 86px; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 24px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 16px; min-width: 330px; }
.brand img { width: 108px; height: 64px; object-fit: contain; background: #343633; }
.brand h1 { margin: 0; font-size: 1.45rem; letter-spacing: .02em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: .875rem; }
.top-actions, .button-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.user-badge { padding: 7px 11px; border-radius: 8px; background: var(--navy); color: #fff; font-size: .85rem; white-space: nowrap; }
.button { border: 1px solid transparent; border-radius: 8px; padding: 9px 15px; font-weight: 700; min-height: 42px; transition: .15s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--navy); color: #fff; }
.button.secondary { background: var(--blue-soft); color: var(--navy); border-color: #c6daeb; }
.button.ghost { background: #fff; color: var(--navy); border-color: var(--line); }
.status-pill { padding: 8px 12px; border-radius: 99px; background: #eef3f6; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.status-pill.ready { background: #e5f5ef; color: var(--green); }
.status-pill.error { background: #fff0f0; color: var(--red); }
main { max-width: 1800px; margin: 0 auto; padding: 18px 24px 36px; }
.cloud-strip { display: grid; grid-template-columns: minmax(280px, 520px) auto 1fr; align-items: end; gap: 12px; margin-bottom: 12px; padding: 12px 16px; background: #e9f4fb; border: 1px solid #c6daeb; border-radius: 12px; }
.cloud-strip .muted { align-self: center; }
.project-strip { display: grid; grid-template-columns: 2fr 1.35fr 1fr 1.2fr 1fr; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
label { display: grid; gap: 6px; color: #37465a; font-size: .87rem; font-weight: 700; }
input, select { width: 100%; min-height: 42px; border: 1px solid #cbd5df; border-radius: 7px; background: #fff; color: var(--ink); padding: 8px 10px; outline: none; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(45,120,184,.12); }
.tabs { display: flex; gap: 4px; margin: 18px 0 12px; border-bottom: 1px solid #cfd8e2; }
.tab { border: 0; background: transparent; padding: 11px 18px; color: var(--muted); font-weight: 700; border-bottom: 3px solid transparent; }
.tab.active { color: var(--navy); border-bottom-color: var(--blue); }
.view { display: none; }
.view.active { display: block; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(150px,1fr)); gap: 12px; margin-bottom: 12px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; box-shadow: var(--shadow); }
.metric span { display: block; color: var(--muted); font-size: .85rem; margin-bottom: 4px; }
.metric strong { font-size: 1.65rem; color: var(--navy); }
.metric.warning strong { color: var(--amber); }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 1.08rem; }
.panel-heading p { margin: 3px 0 0; color: var(--muted); font-size: .86rem; }
.settings-panel { padding-bottom: 16px; }
.settings-panel > label { margin: 13px 16px 0; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--navy-2); color: #fff; font-weight: 700; text-align: center; padding: 11px 10px; white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:nth-child(even) td { background: #f8fafc; }
td.numeric { text-align: right; font-variant-numeric: tabular-nums; }
td.center { text-align: center; }
.qty-input { width: 80px; min-height: 36px; text-align: center; }
.match-ok { color: var(--green); font-weight: 700; }
.match-warn { color: var(--amber); font-weight: 700; }
.empty-state { min-height: 250px; display: grid; place-content: center; text-align: center; color: var(--muted); gap: 5px; }
.empty-state strong { color: var(--ink); }
.switch-row { display: flex !important; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-top: 1px solid #edf0f3; }
.switch-row span { display: grid; }
.switch-row small { color: var(--muted); font-weight: 400; }
.switch-row input { width: 46px; height: 24px; min-height: 24px; accent-color: var(--blue); }
.inline-field { grid-template-columns: 1fr 90px 20px !important; align-items: center; }
.inline-field input { min-height: 36px; }
.hidden { display: none !important; }
.scope-note { margin: 16px; padding: 12px; background: #f5f8fa; border-left: 4px solid var(--blue); color: #425267; font-size: .85rem; }
.detail-heading { align-items: flex-start; }
.file-button { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.detail-toolbar { padding: 12px 18px; display: flex; align-items: end; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.detail-toolbar label { max-width: 360px; width: 100%; }
.detail-table { min-width: 1400px; }
.detail-table input { min-height: 34px; padding: 5px 7px; min-width: 105px; }
.detail-table .type-input { min-width: 190px; }
.detail-table .product-input { min-width: 150px; }
.detail-table .code-input { min-width: 130px; }
.detail-table .small-input { min-width: 72px; width: 72px; text-align: center; }
.remove-line { border: 0; background: transparent; color: var(--red); font-weight: 700; padding: 8px; }
.muted { color: var(--muted); font-size: .86rem; }
.files-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 12px; align-items: start; }
.users-grid { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 12px; align-items: start; }
.form-stack { display: grid; gap: 13px; padding: 18px; }
.drop-zone { margin: 18px; min-height: 150px; border: 2px dashed #b8c9d8; border-radius: 10px; background: #f7fafc; place-content: center; text-align: center; cursor: pointer; }
.drop-zone span { color: var(--muted); font-weight: 400; }
.drop-zone input { display: none; }
.attachment-list { list-style: none; padding: 0 18px 18px; margin: 0; }
.attachment-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.attachment-list a { color: var(--navy); font-weight: 700; overflow-wrap: anywhere; }
.attachment-list small { color: var(--muted); text-align: right; }
.upload-category { display: flex; align-items: center; gap: 10px; margin: 16px 18px 0; font-weight: 700; }
.upload-category select { width: min(280px, 100%); }
.upload-status { display: block; padding: 0 18px; margin: 0 0 10px; }
.source-meta { margin: 14px 18px; }
.source-meta div { display: grid; grid-template-columns: 95px 1fr; padding: 8px 0; border-bottom: 1px solid var(--line); }
.source-meta dt { color: var(--muted); }
.source-meta dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.wide { margin: 12px 18px; width: calc(100% - 36px); }
.files-grid .panel > .muted { padding: 0 18px 18px; display: block; }
.rules-list { margin: 14px 22px 22px; padding-left: 18px; }
.rules-list li { margin-bottom: 10px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: 420px; padding: 12px 16px; background: #172331; color: #fff; border-radius: 8px; box-shadow: var(--shadow); opacity: 0; transform: translateY(15px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1100px) {
  .project-strip { grid-template-columns: repeat(2, 1fr); }
  .workspace-grid { grid-template-columns: 1fr; }
  .files-grid { grid-template-columns: 1fr; }
  .users-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { align-items: flex-start; padding: 12px; }
  .brand { min-width: 0; }
  .brand img { width: 80px; height: 52px; }
  .brand h1 { font-size: 1.1rem; }
  .topbar { flex-direction: column; }
  main { padding: 12px; }
  .project-strip, .metric-grid { grid-template-columns: 1fr; }
  .cloud-strip { grid-template-columns: 1fr; align-items: stretch; }
  .tabs { overflow-x: auto; }
  .tab { white-space: nowrap; }
}

@media print {
  body { background: #fff; }
  .top-actions, .tabs, .settings-panel, .project-strip label:not(:first-child), #emptySummary { display: none !important; }
  .topbar { position: static; border: 0; }
  main { padding: 0; }
  .project-strip { display: block; box-shadow: none; border: 0; padding: 0 0 12px; }
  .workspace-grid { display: block; }
  .panel { box-shadow: none; border: 0; }
  .panel-heading button { display: none; }
}
