:root {
  --paper: #f5f1e8;
  --surface: #fffdf8;
  --surface-soft: #faf6ee;
  --ink: #24352e;
  --muted: #6c766f;
  --green: #285440;
  --green-deep: #173b2c;
  --green-soft: #e8f0e8;
  --gold: #a97832;
  --line: #ded4c3;
  --line-dark: #c9bda8;
  --danger: #a6483c;
  --shadow: 0 12px 30px rgba(50, 55, 42, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .52; }
a { color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid rgba(40, 84, 64, .25);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 68px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto;
  align-items: center;
  gap: 22px;
  padding: 11px max(24px, calc((100vw - 1280px) / 2));
  color: #fff;
  background: var(--green-deep);
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 6px 20px rgba(27, 49, 39, .16);
}
.brand { color: inherit; text-decoration: none; }
.brand strong { display: block; font-size: 19px; line-height: 1.25; }
.brand span { display: block; margin-top: 2px; color: rgba(255, 255, 255, .73); font-size: 12px; }
.topnav { display: flex; gap: 4px; }
.topnav a, .nav-action {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  color: rgba(255, 255, 255, .86);
  background: transparent;
  font-weight: 800;
  text-decoration: none;
}
.topnav a:hover, .nav-action:hover { color: var(--green-deep); background: #fff8e9; }
.health-dot { display: inline-flex; align-items: center; gap: 8px; color: rgba(255,255,255,.75); font-size: 13px; white-space: nowrap; }
.health-dot span { width: 8px; height: 8px; border-radius: 50%; background: #2bb96c; }
.user-bar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; color: rgba(255,255,255,.84); font-size: 13px; white-space: nowrap; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(40, 84, 64, .08), transparent 42%),
    var(--paper);
}
.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 13px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.login-card label, .user-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}
.login-card input, .user-form input, .user-form select, .user-controls input {
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  color: var(--ink);
  background: #fffdf8;
}
.login-notice { min-height: 20px; margin: 0; color: var(--green); font-weight: 800; }
.login-notice.error { color: var(--danger); }

.shell { max-width: 1280px; margin: 0 auto; padding: 0 24px 54px; }
.notice { min-height: 24px; margin: 17px 0 0; color: var(--green); font-weight: 800; }
.notice.error { color: var(--danger); }
.workspace { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(330px, .82fr); gap: 22px; align-items: start; }
.main-column, .side-column { display: grid; gap: 16px; }
.card {
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.hidden { display: none !important; }

.section-heading { margin-bottom: 19px; }
.section-heading.compact { margin-bottom: 14px; }
.eyebrow { margin: 0 0 4px; color: var(--gold); font-size: 12px; font-weight: 900; letter-spacing: .07em; }
h1, h2 { margin: 0; color: var(--ink); line-height: 1.32; }
h1 { font-size: 27px; }
h2 { font-size: 20px; }
.section-heading p:not(.eyebrow), .muted { color: var(--muted); }
.section-heading p:not(.eyebrow) { margin: 7px 0 0; }
.small { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

.upload-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 14px 0 18px; }
.upload-grid.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.source-update-form { display: grid; justify-items: start; }
.upload-slot {
  position: relative;
  min-height: 156px;
  display: grid;
  align-content: start;
  gap: 7px;
  padding: 16px;
  overflow: hidden;
  border: 1.5px dashed var(--line-dark);
  border-radius: 8px;
  background: var(--surface-soft);
  cursor: pointer;
}
.upload-slot:hover { border-color: var(--green); background: #f4f8f2; }
.upload-slot.required strong::after { content: " 必传"; margin-left: 5px; color: var(--danger); font-size: 11px; }
.upload-slot strong { color: var(--green); font-size: 16px; }
.upload-slot em { color: var(--gold); font-size: 12px; font-style: normal; }
.upload-slot span { color: var(--muted); font-size: 12px; }
.upload-slot input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-name { min-height: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.upload-action {
  width: fit-content;
  min-height: 31px;
  display: inline-flex;
  align-items: center;
  margin-top: auto;
  padding: 0 10px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  color: var(--green) !important;
  background: #fffdf8;
  font-weight: 900;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 900;
}
.button.primary { color: #fff; background: var(--green); border-color: var(--green); box-shadow: 0 8px 18px rgba(40, 84, 64, .15); }
.button.primary:hover:not(:disabled) { background: var(--green-deep); }
.button.secondary { color: var(--green); background: #fffdf8; border-color: var(--line-dark); }
.button.secondary:hover:not(:disabled) { background: var(--green-soft); }
.button.wide { min-width: 236px; }

.progress-head, .generation-layout, .download-layout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.package-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.package-actions .action-button { min-width: 168px; }
.progress-head > strong { color: var(--green); font-size: 22px; }
.progress-track { height: 10px; overflow: hidden; border-radius: 8px; background: #e4ebe4; }
.progress-fill { width: 0; height: 100%; background: var(--green); transition: width .28s ease; }
.progress-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 15px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.progress-stat { min-width: 0; display: grid; gap: 2px; padding: 10px 12px; border-right: 1px solid var(--line); }
.progress-stat:first-child { padding-left: 0; }
.progress-stat:last-child { padding-right: 0; border-right: 0; }
.progress-stat span { color: var(--muted); font-size: 12px; }
.progress-stat strong { overflow-wrap: anywhere; color: var(--ink); font-size: 14px; }
.progress-issues { margin-top: 13px; padding: 11px 13px; border-left: 3px solid var(--danger); background: #fbf2ef; color: #783c34; }
.progress-issues > strong { font-size: 13px; }
.progress-issues ul { margin: 5px 0 0; padding-left: 19px; }
.progress-issues li { margin-top: 3px; font-size: 13px; }
.source-files { margin: 8px 0 12px; color: var(--green); font-size: 13px; font-weight: 800; overflow-wrap: anywhere; }
.profile-correction { display: grid; gap: 14px; margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.profile-correction > p { margin: 0; color: var(--muted); }
.profile-correction-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.profile-correction-grid label { display: grid; gap: 5px; color: var(--muted); font-size: 13px; font-weight: 900; }
.profile-correction-grid input { min-width: 0; min-height: 42px; padding: 0 11px; border: 1px solid var(--line-dark); border-radius: 6px; color: var(--ink); background: #fffdf8; }

.direction-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.direction-option {
  min-height: 100px;
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 15px;
  border: 1px solid var(--line-dark);
  border-radius: 7px;
  color: var(--ink);
  background: #fffdf8;
  text-align: left;
}
.direction-option:hover { border-color: var(--green); background: #f2f7f0; }
.direction-option strong { color: var(--green); font-size: 17px; }
.direction-option span { color: var(--muted); font-size: 13px; }
.action-button { min-width: 178px; white-space: nowrap; }
.generation-note {
  display: flex;
  gap: 13px;
  margin-top: 18px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.generation-note span { color: var(--gold); font-weight: 900; }
.generation-note strong { color: var(--ink); }

.recent-card { position: sticky; top: 91px; }
.recent-list { display: grid; gap: 10px; }
.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}
.recent-main { min-width: 0; display: grid; gap: 3px; }
.recent-main strong { font-size: 17px; }
.recent-main span, .recent-main em { overflow: hidden; color: var(--muted); font-size: 13px; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.recent-main em { color: var(--green); font-weight: 900; }
.item-actions { flex: 0 0 auto; display: flex; gap: 7px; align-items: center; }
.item-actions button, .library-item > button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  color: var(--green);
  background: #fffdf8;
  font-weight: 800;
}
.text-button, .library-packages a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  color: var(--green);
  background: #fffdf8;
  font-weight: 800;
  font-size: 13px;
  text-decoration: none;
}
.text-button:hover, .library-packages a:hover { background: var(--green-soft); }

.library-section { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line-dark); }
.library-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.search-field { display: grid; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 800; }
.search-field input {
  width: 285px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
}
.library-list { display: grid; gap: 10px; }
.library-item {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(290px, 1.35fr) auto;
  align-items: center;
  gap: 16px;
  padding: 17px 18px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}
.library-main { display: grid; gap: 3px; }
.library-main strong { font-size: 18px; }
.library-main span, .library-main em { color: var(--muted); font-size: 13px; font-style: normal; }
.library-main em { color: var(--green); font-weight: 900; }
.library-packages { display: flex; flex-wrap: wrap; gap: 7px; }
.empty-library { margin: 0; padding: 20px; border: 1px dashed var(--line-dark); border-radius: 7px; color: var(--muted); background: var(--surface-soft); }
.admin-section { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line-dark); }
.user-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto auto auto;
  align-items: end;
  gap: 12px;
}
.check-row {
  min-height: 40px;
  display: inline-flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 7px !important;
  color: var(--ink) !important;
  white-space: nowrap;
}
.check-row input { width: 16px; height: 16px; min-height: 0; padding: 0; }
.user-list { display: grid; gap: 10px; margin-top: 14px; }
.version-history { width: 100%; margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.version-history summary { color: var(--green); font-weight: 800; cursor: pointer; }
.version-list { display: grid; gap: 8px; margin-top: 10px; }
.version-row { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 8px; align-items: start; }
.version-row strong { color: var(--ink); font-size: 13px; }
.version-links { display: flex; flex-wrap: wrap; gap: 6px; }
.version-links .text-button { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-item {
  display: grid;
  grid-template-columns: minmax(180px, .7fr) minmax(0, 1.7fr);
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}
.user-main { display: grid; gap: 3px; }
.user-main strong { font-size: 17px; }
.user-main span { color: var(--muted); font-size: 13px; }
.user-controls { display: grid; grid-template-columns: auto auto auto minmax(150px, 1fr) auto; gap: 10px; align-items: center; }
footer { padding: 20px 24px 28px; color: var(--muted); text-align: center; font-size: 13px; }

@media (max-width: 980px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; }
  .health-dot, .user-bar > span { display: none; }
  .workspace { grid-template-columns: 1fr; }
  .side-column { order: 2; }
  .recent-card { position: static; }
  .upload-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .library-item { grid-template-columns: 1fr auto; }
  .library-packages { grid-column: 1 / -1; }
  .user-form, .user-item, .user-controls { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; padding: 10px 16px; }
  .topnav { grid-column: 1 / -1; justify-content: space-between; }
  .brand span { display: none; }
  .brand strong { font-size: 16px; }
  .topnav a, .nav-action { padding: 0 8px; font-size: 13px; }
  .shell { padding: 0 14px 36px; }
  .card { padding: 18px; }
  h1 { font-size: 23px; }
  .progress-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .progress-stat:nth-child(2) { border-right: 0; }
  .progress-stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .upload-grid, .direction-grid, .profile-correction-grid { grid-template-columns: 1fr; }
  .generation-layout, .download-layout, .library-heading { align-items: stretch; flex-direction: column; }
  .package-actions { justify-content: stretch; }
  .package-actions .action-button { width: 100%; }
  .action-button, .button.wide { width: 100%; }
  .search-field input { width: 100%; }
  .library-item { grid-template-columns: 1fr; gap: 10px; }
  .library-item > button { width: 100%; }
  .version-row { grid-template-columns: 1fr; }
}

/* V4.7 operational workspace */
.brand {
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.topnav .active { color: var(--green-deep); background: #fff8e9; }
.shell { max-width: 1180px; padding-bottom: 52px; }
.app-view { display: grid; gap: 16px; }
.page-title-row, .view-toolbar, .project-identity, .status-table-heading, .form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.page-title-row { align-items: flex-start; }
.page-title-row .section-heading { max-width: 620px; }
.step-strip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.step-strip li { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.step-strip li + li::before { content: ""; width: 22px; height: 1px; margin-right: 9px; background: var(--line-dark); }
.step-strip span {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-dark);
  border-radius: 50%;
  background: var(--surface-soft);
}
.step-strip .active { color: var(--green); }
.step-strip .active span { color: #fff; border-color: var(--green); background: var(--green); }
.form-actions { padding-top: 4px; border-top: 1px solid var(--line); }
.view-toolbar { min-height: 38px; }
.plain-action {
  padding: 0;
  border: 0;
  color: var(--green);
  background: transparent;
  font-weight: 900;
}
.plain-action::before { content: "‹"; margin-right: 7px; font-size: 20px; vertical-align: -1px; }
.project-identity {
  padding: 22px 25px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: var(--surface);
}
.project-identity p { margin: 5px 0 0; }
.status-badge, .task-status {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--line-dark);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.status-badge.ready, .task-status.done { color: var(--green); border-color: #9fb7a8; background: var(--green-soft); }
.status-badge.running, .task-status.running { color: #8a611f; border-color: #d8bf8e; background: #fff6df; }
.status-badge.attention, .task-status.attention { color: var(--danger); border-color: #ddb0a9; background: #fbefed; }
.status-table-heading { align-items: end; margin-bottom: 14px; }
.status-table-wrap { max-height: 520px; overflow: auto; border: 1px solid var(--line); border-radius: 7px; }
.status-table { width: 100%; border-collapse: collapse; background: var(--surface); }
.status-table th, .status-table td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; }
.status-table th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: var(--surface-soft); font-size: 12px; }
.status-table tr:last-child td { border-bottom: 0; }
.status-table th:first-child, .status-table td:first-child { width: 86px; }
.status-table th:last-child, .status-table td:last-child { width: 125px; }
.task-id { color: var(--green); font-weight: 900; }
.source-update-panel summary { color: var(--green); font-weight: 900; cursor: pointer; }
.source-update-panel[open] summary { margin-bottom: 8px; }

#libraryCard { gap: 14px; }
.library-heading { align-items: center; margin: 0; padding: 8px 0 4px; }
.library-heading p { margin: 6px 0 0; }
.filter-bar { display: flex; gap: 7px; padding-bottom: 2px; }
.filter-button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface);
  font-weight: 800;
}
.filter-button.active { color: #fff; border-color: var(--green); background: var(--green); }
.library-table-head, .library-item {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(105px, .45fr) minmax(280px, 1.3fr) 72px;
  align-items: center;
  gap: 16px;
}
.library-table-head {
  padding: 0 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.library-item { padding: 16px 18px; }
.library-status { display: flex; align-items: center; gap: 8px; }
.library-status small { color: var(--muted); }
.library-packages { display: flex; flex-wrap: wrap; gap: 7px; }
.library-item > button { width: 72px; }

@media (max-width: 860px) {
  .page-title-row { display: grid; }
  .step-strip { justify-content: space-between; width: 100%; gap: 5px; }
  .step-strip li + li::before { width: 12px; margin-right: 3px; }
  .library-table-head { display: none; }
  .library-item { grid-template-columns: 1fr auto; }
  .library-packages { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .page-title-row, .view-toolbar, .project-identity, .status-table-heading, .form-actions { align-items: stretch; flex-direction: column; }
  .view-toolbar { flex-direction: row; align-items: center; }
  .step-strip { overflow-x: auto; justify-content: flex-start; padding-bottom: 4px; }
  .step-strip li + li::before { display: none; }
  .project-identity { gap: 12px; }
  .project-identity .status-badge { align-self: flex-start; }
  .status-table th, .status-table td { padding: 10px 9px; }
  .status-table th:first-child, .status-table td:first-child { width: 65px; }
  .status-table th:last-child, .status-table td:last-child { width: 95px; }
  .filter-bar { overflow-x: auto; }
  .filter-button { flex: 0 0 auto; }
  .library-item { grid-template-columns: 1fr; }
  .library-packages { grid-column: auto; }
  .library-item > button { width: 100%; }
}
