:root {
  --ink: #182230;
  --muted: #718096;
  --line: #e6ebf2;
  --soft: #f5f7fa;
  --blue: #2764d8;
  --blue-dark: #173d8f;
  --red: #b85555;
  --green: #198754;
  --yellow: #fff7d9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: #eef2f6;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef2f6;
}

.auth-screen.is-hidden {
  display: none;
}

.auth-panel {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(35, 58, 90, 0.12);
}

.auth-panel h1 {
  margin-bottom: 8px;
  font-size: 30px;
}

.auth-panel .subtitle {
  margin-bottom: 24px;
}

.is-hidden {
  display: none !important;
}

.auth-switch {
  display: block;
  margin: 18px auto 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 13px;
  cursor: pointer;
}

.auth-input {
  width: 100%;
  height: 44px;
  margin: 8px 0 18px;
  padding: 0 12px;
  border: 1px solid #cfd8e5;
  border-radius: 6px;
  outline: 0;
}

.auth-input:focus {
  border-color: #8aaee8;
}

.auth-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--red);
  font-size: 13px;
}

.current-user {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.app-shell.is-locked {
  visibility: hidden;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1500px, calc(100% - 48px));
  margin: 0 auto;
  padding: 34px 0 54px;
}

.topbar,
.content-heading,
.panel-heading,
.import-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.topbar {
  padding: 6px 4px 30px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.6px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 3vw, 42px);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
}

.top-actions,
.content-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button,
.icon-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 16px;
  font-weight: 700;
  transition: 160ms ease;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.button-dark {
  background: var(--ink);
  color: #fff;
}

.button-muted {
  background: #fff;
  border-color: var(--line);
  color: #435066;
}

.button-blue {
  background: var(--blue);
  color: #fff;
}

.button-outline {
  background: #fff;
  border-color: #bbcae5;
  color: var(--blue);
}

.full-width {
  width: 100%;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.control-panel,
.content-panel {
  min-width: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(22, 35, 55, 0.06);
}

.control-panel {
  padding: 24px;
}

.content-panel {
  padding: 26px;
}

.status-dot,
.optional-label {
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--green);
  background: #e9f8f0;
  font-size: 12px;
  white-space: nowrap;
}

.optional-label {
  color: var(--muted);
  background: var(--soft);
}

.rule-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 28px 0 20px;
  padding: 4px;
  border-radius: 7px;
  background: var(--soft);
}

.mode-button {
  min-height: 36px;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.mode-button.is-active {
  color: var(--blue-dark);
  background: #fff;
  box-shadow: 0 2px 8px rgba(29, 60, 117, 0.1);
}

.field-label {
  display: block;
  margin: 14px 0 8px;
  color: #49566c;
  font-size: 13px;
  font-weight: 700;
}

.input-with-suffix {
  display: flex;
  align-items: center;
  border: 1px solid #cfd8e5;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.input-with-suffix input {
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  border: 0;
  outline: 0;
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
}

.input-with-suffix span {
  padding: 0 12px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

select,
textarea {
  width: 100%;
  border: 1px solid #cfd8e5;
  border-radius: 6px;
  outline: 0;
  background: #fff;
}

select {
  min-height: 42px;
  padding: 0 10px;
  color: #45526a;
}

.switch-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 22px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.switch-row strong,
.switch-row small {
  display: block;
}

.switch-row strong {
  font-size: 13px;
}

.switch-row small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.switch-row input {
  position: absolute;
  opacity: 0;
}

.switch-ui {
  flex: 0 0 auto;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #c9d1de;
  transition: 160ms ease;
}

.switch-ui::after {
  display: block;
  width: 18px;
  height: 18px;
  margin: 2px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: 160ms ease;
}

.switch-row input:checked + .switch-ui {
  background: var(--blue);
}

.switch-row input:checked + .switch-ui::after {
  transform: translateX(18px);
}

.formula-card {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #dfe8f6;
  border-radius: 7px;
  background: #f7faff;
}

.formula-card span,
.formula-card strong {
  display: block;
}

.formula-card span {
  color: var(--muted);
  font-size: 11px;
}

.formula-card strong {
  margin-top: 5px;
  color: var(--blue-dark);
  font-size: 13px;
}

.panel-divider {
  height: 1px;
  margin: 26px 0;
  background: var(--line);
}

.helper-text,
.table-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.helper-text {
  margin: 16px 0 10px;
}

textarea {
  min-height: 136px;
  padding: 11px 12px;
  resize: vertical;
  color: #344054;
  font-size: 12px;
  line-height: 1.6;
}

.import-block .button {
  margin-top: 10px;
}

.stack-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.stack-actions .button {
  margin-top: 0;
}

.legacy-import {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.legacy-import summary {
  color: var(--blue);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.legacy-import textarea {
  margin-top: 12px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 26px 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.summary-item {
  min-height: 78px;
  padding: 15px 17px;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
}

.summary-item:last-child {
  border-right: 0;
}

.summary-item span,
.summary-item strong {
  display: block;
}

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

.summary-item strong {
  margin-top: 8px;
  font-size: 20px;
}

.summary-item.highlight {
  background: #f1f6ff;
}

.summary-item.highlight strong {
  color: var(--blue);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid var(--line);
  height: 58px;
  box-sizing: border-box;
  padding: 9px 14px;
  text-align: left;
  vertical-align: middle;
}

thead th {
  background: #3b609f;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

tbody tr:nth-child(even) {
  background: #fbfcfe;
}

tbody tr.is-missing {
  background: #fff2f2;
}

tbody tr.is-missing .book-input,
tbody tr.is-missing .price-input {
  color: var(--red);
}

td {
  color: #283548;
  font-size: 13px;
}

tfoot td {
  border-bottom: 0;
  background: var(--yellow);
  color: #3e3a29;
  font-weight: 800;
}

.index-col {
  width: 52px;
  text-align: center;
}

.book-col {
  width: 32%;
}

.condition-col {
  width: 15%;
}

.markup-col {
  width: 15%;
}

.money-col {
  width: 20%;
  text-align: right;
}

.action-col {
  width: 52px;
  text-align: center;
}

thead th:nth-child(4),
tbody td:nth-child(4),
tfoot td:nth-child(4) {
  text-align: right;
}

thead th:first-child,
tbody td:first-child,
tfoot td:last-child {
  text-align: center;
}

.table-input {
  width: 100%;
  min-width: 0;
  height: 36px;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 7px 0;
  background: transparent;
  color: inherit;
  outline: 0;
}

.book-cell {
  padding-top: 8px;
  padding-bottom: 8px;
}

.book-input,
.table-input:not(.price-input) {
  text-align: left;
}

.book-input {
  display: block;
  min-height: 36px;
  height: auto;
  overflow: hidden;
  padding: 7px 0;
  resize: none;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.book-isbn {
  display: block;
  margin: 1px 0 0;
  color: #718096;
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.book-meta {
  display: block;
  margin-top: 2px;
  color: #8a96a8;
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.price-input {
  text-align: right;
}

.markup-input {
  text-align: right;
  color: var(--blue-dark);
  font-weight: 700;
}

.table-input:focus {
  border-color: #b7c9e8;
  background: #fff;
}

.price-input {
  text-align: right;
}

.deal-price {
  color: var(--red);
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-align: right;
}

.cost-price {
  color: #1f2a3d;
  font-weight: 800;
  text-align: right;
}

.remove-row {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 5px;
  color: #9aa5b5;
  background: transparent;
  font-size: 18px;
}

.remove-row:hover {
  color: var(--red);
  background: #fff0f0;
}

.detail-button {
  display: block;
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 11px;
  cursor: pointer;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(24, 34, 48, 0.42);
}

.modal-panel {
  width: min(920px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  padding: 24px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(20, 35, 55, 0.22);
}

.modal-heading,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.offer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.offer-card {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfe;
}

.offer-image {
  width: 76px;
  height: 100px;
  border-radius: 4px;
  object-fit: cover;
  background: #e9eef5;
}

.offer-image.is-empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
}

.offer-title {
  margin: 0 0 7px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.offer-meta {
  margin: 3px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.offer-price {
  margin-top: 7px;
  color: var(--red);
  font-weight: 800;
}

.offer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
}

.small-button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid #bbcae5;
  border-radius: 5px;
  color: var(--blue);
  background: #fff;
  font-size: 11px;
  cursor: pointer;
}

.purchase-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.purchase-item strong,
.purchase-item small {
  display: block;
}

.purchase-item small {
  margin-top: 4px;
  color: var(--muted);
}

.table-note {
  margin: 12px 0 0;
}

.note-mark {
  display: inline-grid;
  width: 16px;
  height: 16px;
  margin-right: 4px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #aab4c3;
  font-size: 10px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 10;
  transform: translate(-50%, 18px);
  padding: 10px 15px;
  border-radius: 6px;
  color: #fff;
  background: #172234;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100% - 28px, 720px);
    padding-top: 20px;
  }

  .topbar,
  .content-heading {
    flex-direction: column;
  }

  .top-actions,
  .content-actions {
    width: 100%;
  }

  .top-actions .button,
  .content-actions .button,
  .content-actions .icon-button {
    flex: 1;
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: calc(100% - 20px);
  }

  .control-panel,
  .content-panel {
    padding: 18px;
  }

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

  .summary-item:nth-child(2) {
    border-right: 0;
  }

  .summary-item:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .topbar,
  .control-panel,
  .content-actions,
  .table-note {
    display: none;
  }

  .content-panel {
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .content-heading {
    display: block;
    margin-bottom: 18px;
  }

  .content-heading::after {
    display: block;
    margin-top: 6px;
    color: #687386;
    content: "图书报价单";
    font-size: 12px;
  }

  .summary-strip {
    margin-top: 0;
  }

  .remove-row,
  .action-col {
    display: none;
  }

  table {
    min-width: 0;
  }
}

/* 服务告警条：孔网登录态失效时置顶显示 */
.service-banner {
  position: sticky;
  top: 0;
  z-index: 60;
  padding: 12px 18px;
  background: #b3261e;
  color: #fff;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  font-weight: 600;
}
.service-banner.is-hidden {
  display: none;
}
