:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #d9e0e8;
  --text: #17202a;
  --muted: #617080;
  --accent: #1870c7;
  --accent-dark: #0f4f90;
  --good: #0b7a4b;
  --warn: #a76300;
  --bad: #b42318;
  --soft-blue: #e8f2fb;
  --soft-green: #e8f6ee;
  --soft-warn: #fff4df;
  --soft-red: #fdecea;
  --shadow: 0 10px 30px rgba(20, 35, 55, 0.08);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body.login-mode {
  background: #eef3f8;
}

body.login-mode .shell {
  display: block;
  min-height: 100vh;
}

body.login-mode .sidebar,
body.login-mode .topbar {
  display: none;
}

body.login-mode #app {
  min-height: 100vh;
  padding: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #111c27;
  color: #f8fbff;
  padding: 22px 16px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 8px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #f4c542;
  color: #111c27;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 4px;
  color: #b7c3cf;
}

nav {
  display: grid;
  gap: 4px;
  margin-top: 18px;
}

.nav-group {
  display: grid;
  gap: 4px;
}

.nav-submenu {
  display: none;
  gap: 4px;
}

.nav-submenu.expanded {
  display: grid;
}

.nav-group-toggle {
  justify-content: space-between;
}

.nav-group-caret {
  font-size: 13px;
  opacity: 0.85;
}

.nav-sub-button {
  padding-left: 28px;
  font-size: 14px;
}

.nav-button {
  width: 100%;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #dce6f0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  text-align: left;
}

.nav-button:hover,
.nav-button.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.nav-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.09);
  font-size: 13px;
  flex: 0 0 auto;
}

.workspace {
  min-width: 0;
}

.topbar {
  min-height: 104px;
  padding: 22px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-filter {
  display: grid;
  gap: 6px;
  min-width: 180px;
}

.topbar-filter span {
  color: var(--muted);
  font-size: 12px;
}

.topbar-filter select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.operator {
  display: grid;
  gap: 4px;
  min-width: 128px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafcff;
}

.operator span {
  color: var(--muted);
  font-size: 12px;
}

#app {
  padding: 24px 28px 40px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-card .brand-mark {
  width: 48px;
  height: 48px;
}

.login-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.login-card input {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.metric .mini-text {
  font-size: 15px;
  line-height: 1.35;
  word-break: break-all;
}

.compact-metrics {
  margin-bottom: 12px;
}

.upload-box {
  display: grid;
  gap: 6px;
}

.upload-last-result {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafcff;
}

.upload-last-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.upload-batch-status {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #e8f2fb;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.upload-last-result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.upload-last-result-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 2px;
}

.upload-last-result-grid strong {
  display: block;
  font-size: 14px;
  word-break: break-all;
}

.upload-status-card {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.upload-status-card.processing,
.upload-status-card.uploading,
.upload-status-card.reading {
  background: #f8fbff;
}

.upload-status-card.success {
  background: #f1fbf5;
  border-color: #b7e0c4;
}

.upload-status-card.error {
  background: #fff5f4;
  border-color: #efc3be;
}

.upload-status-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}

.upload-status-head strong {
  font-size: 15px;
}

.upload-status-head span,
.upload-status-text,
.upload-status-hint {
  color: var(--muted);
  font-size: 13px;
}

.upload-status-hint {
  margin: 0;
}

.upload-progress {
  height: 8px;
  border-radius: 999px;
  background: #e6edf5;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: #9fb7d3;
}

.upload-progress-bar.reading {
  width: 30%;
  background: #6ea8dc;
}

.upload-progress-bar.uploading {
  width: 55%;
  background: #3e8dd8;
}

.upload-progress-bar.processing {
  width: 78%;
  background: #1870c7;
}

.upload-progress-bar.success {
  width: 100%;
  background: #1f9d63;
}

.upload-progress-bar.error {
  width: 100%;
  background: #d64545;
}

.upload-progress-bar.uploading.uploading,
.upload-progress-bar.processing.uploading,
.upload-progress-bar.reading.uploading {
  animation: upload-progress-pulse 1.2s ease-in-out infinite;
}

@keyframes upload-progress-pulse {
  0% {
    filter: brightness(0.96);
  }
  50% {
    filter: brightness(1.08);
  }
  100% {
    filter: brightness(0.96);
  }
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  font-size: 18px;
}

.panel-body {
  padding: 16px 18px;
}

.template-stack {
  display: grid;
  gap: 6px;
}

.template-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.template-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3px;
}

.is-selected-row {
  background: #f3f8ff;
}

.is-selected-row .link-button {
  font-weight: 700;
}

.pricing-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 8px;
  align-items: start;
}

.pricing-meta-inline {
  display: grid;
  gap: 4px;
  padding: 6px 8px 4px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}

.pricing-header-actions {
  align-self: center;
}

.summary-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 5px 8px;
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 2px;
}

.summary-item strong {
  display: block;
  font-size: 15px;
}

.pricing-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.pricing-single-template {
  max-width: 860px;
}

.pricing-side .pricing-sheet {
  width: 100%;
}

.pricing-side .pricing-table-wrap {
  padding-right: 4px;
}

.pricing-block-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px 5px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.pricing-block-header h3 {
  margin: 0;
  font-size: 16px;
}

.pricing-block-header p {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.pricing-side-actions {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.pricing-side-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px 0;
  flex-wrap: wrap;
}

.pricing-side-sections {
  display: grid;
  gap: 6px;
}

.pricing-single-special {
  display: grid;
  gap: 4px;
}

.pricing-subsection {
  display: grid;
  gap: 3px;
  padding: 0 8px 4px;
}

.pricing-subsection h4 {
  margin: 0;
  font-size: 13px;
}

.pricing-sheet .size-name {
  font-weight: 700;
  background: #f8fafc;
  white-space: nowrap;
}

.price-input {
  width: 52%;
  min-width: 72px;
  max-width: 140px;
  border: 1px solid #f0b8b1;
  border-radius: 7px;
  padding: 5px 8px;
  font-weight: 700;
  color: #b42318;
  background: #fff;
  line-height: 1.2;
}

.price-input:focus {
  outline: none;
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.toolbar-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.toolbar-actions select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
}

.toolbar-actions input[type="search"] {
  width: min(240px, 100%);
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
}

.button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 9px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button.emphasis {
  font-weight: 700;
  padding: 11px 16px;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.22);
}

.button.full-width {
  width: 100%;
  justify-content: center;
}

.button.danger {
  border-color: #f0b8b1;
  color: var(--bad);
}

.button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.link-button {
  border: none;
  background: transparent;
  color: var(--accent-dark);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 28, 39, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-card {
  width: min(560px, calc(100vw - 24px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(17, 28, 39, 0.25);
}

.modal-card.modal-wide {
  width: min(980px, calc(100vw - 24px));
}

.modal-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 14px 16px;
  display: grid;
  gap: 10px;
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.detail-toolbar {
  justify-content: flex-end;
  margin-bottom: 6px;
}

.detail-sections {
  display: grid;
  gap: 12px;
}

.detail-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 12px;
}

.detail-section h4 {
  margin-bottom: 10px;
  font-size: 15px;
}

.modal-body label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.modal-body input,
.modal-body select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
}

.autocomplete {
  position: relative;
}

.autocomplete.disabled {
  opacity: 0.56;
}

.autocomplete-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  display: none;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  z-index: 20;
}

.autocomplete-menu.open {
  display: grid;
}

.autocomplete-option {
  border: 0;
  border-bottom: 1px solid #eef2f6;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.autocomplete-option:last-child {
  border-bottom: 0;
}

.autocomplete-option:hover {
  background: #f5f9ff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.pricing-sheet th,
.pricing-sheet td {
  padding: 2px 2px;
}

.pricing-block .eyebrow {
  margin: 2px 8px;
}

.pricing-table-wrap {
  overflow-x: auto;
  padding: 0 4px 2px;
}

.pricing-sheet {
  width: auto;
  min-width: 0;
  table-layout: fixed;
}

.pricing-sheet th:first-child,
.pricing-sheet td:first-child {
  padding-left: 4px;
}

.pricing-sheet th:last-child,
.pricing-sheet td:last-child {
  padding-right: 4px;
}

.pricing-sheet .price-input {
  width: 78px;
  min-width: 78px;
  max-width: 78px;
  min-height: 28px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: #f8fafc;
}

tbody tr:hover {
  background: rgba(99, 102, 241, 0.06);
}

tbody tr.selected-row {
  background: rgba(99, 102, 241, 0.12);
}

td.amount {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.warehouse-bills-table {
  table-layout: fixed;
}

.warehouse-bills-table th,
.warehouse-bills-table td {
  vertical-align: middle;
}

.warehouse-bills-table .toolbar-actions {
  justify-content: flex-start;
}

.warehouse-bills-summary-table th:nth-child(1),
.warehouse-bills-summary-table td:nth-child(1) {
  width: 120px;
}

.warehouse-bills-summary-table th:nth-child(2),
.warehouse-bills-summary-table td:nth-child(2) {
  width: 120px;
}

.warehouse-bills-summary-table th:nth-child(3),
.warehouse-bills-summary-table td:nth-child(3),
.warehouse-bills-summary-table th:nth-child(4),
.warehouse-bills-summary-table td:nth-child(4),
.warehouse-bills-summary-table th:nth-child(5),
.warehouse-bills-summary-table td:nth-child(5) {
  width: 220px;
}

.warehouse-bills-summary-table th:nth-child(3),
.warehouse-bills-summary-table th:nth-child(4),
.warehouse-bills-summary-table th:nth-child(5),
.warehouse-bills-summary-table td:nth-child(3),
.warehouse-bills-summary-table td:nth-child(4),
.warehouse-bills-summary-table td:nth-child(5),
.warehouse-bills-pending-table th:nth-child(4),
.warehouse-bills-pending-table td:nth-child(4),
.warehouse-bills-reviewed-table th:nth-child(4),
.warehouse-bills-reviewed-table td:nth-child(4) {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  padding-right: 18px;
}

.warehouse-bills-summary-table th:nth-child(6),
.warehouse-bills-summary-table td:nth-child(6) {
  width: 240px;
}

.warehouse-bills-summary-table th:nth-child(6),
.warehouse-bills-summary-table td:nth-child(6),
.warehouse-bills-pending-table th:nth-child(7),
.warehouse-bills-pending-table td:nth-child(7) {
  text-align: left;
}

.warehouse-bills-pending-table th:nth-child(1),
.warehouse-bills-pending-table td:nth-child(1),
.warehouse-bills-reviewed-table th:nth-child(1),
.warehouse-bills-reviewed-table td:nth-child(1) {
  width: 120px;
}

.warehouse-bills-pending-table th:nth-child(2),
.warehouse-bills-pending-table td:nth-child(2),
.warehouse-bills-reviewed-table th:nth-child(2),
.warehouse-bills-reviewed-table td:nth-child(2) {
  width: 90px;
}

.warehouse-bills-pending-table th:nth-child(3),
.warehouse-bills-pending-table td:nth-child(3),
.warehouse-bills-reviewed-table th:nth-child(3),
.warehouse-bills-reviewed-table td:nth-child(3) {
  width: 100px;
}

.warehouse-bills-pending-table th:nth-child(4),
.warehouse-bills-pending-table td:nth-child(4),
.warehouse-bills-reviewed-table th:nth-child(4),
.warehouse-bills-reviewed-table td:nth-child(4) {
  width: 170px;
}

.warehouse-bills-pending-table th:nth-child(5),
.warehouse-bills-pending-table td:nth-child(5),
.warehouse-bills-reviewed-table th:nth-child(5),
.warehouse-bills-reviewed-table td:nth-child(5) {
  width: 120px;
}

.warehouse-bills-pending-table th:nth-child(6),
.warehouse-bills-pending-table td:nth-child(6),
.warehouse-bills-reviewed-table th:nth-child(6),
.warehouse-bills-reviewed-table td:nth-child(6) {
  width: 110px;
}

.warehouse-bills-pending-table th:nth-child(7),
.warehouse-bills-pending-table td:nth-child(7),
.warehouse-bills-reviewed-table th:nth-child(7),
.warehouse-bills-reviewed-table td:nth-child(7) {
  width: auto;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}

.status-good {
  background: var(--soft-green);
  color: var(--good);
}

.status-warn {
  background: var(--soft-warn);
  color: var(--warn);
}

.status-bad {
  background: var(--soft-red);
  color: var(--bad);
}

.status-info {
  background: var(--soft-blue);
  color: var(--accent-dark);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
}

.flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}

.flow-step {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 13px;
}

.flow-step strong {
  display: block;
  margin-bottom: 6px;
}

.flow-step span {
  color: var(--muted);
  font-size: 12px;
}

.notice {
  border-left: 4px solid var(--accent);
  background: #eef6ff;
  color: #123a5c;
  padding: 12px 14px;
  border-radius: 6px;
  margin-bottom: 14px;
}

.split {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.agent-grid {
  display: grid;
  gap: 16px;
}

.finding-detail {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.empty {
  padding: 34px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics,
  .grid,
  .split,
  .form-grid,
  .flow,
  .template-summary,
  .pricing-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .pricing-block-header,
  .template-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .detail-summary {
    grid-template-columns: 1fr;
  }
}
