:root {
  color-scheme: light;
  --ink: #1d2430;
  --muted: #667085;
  --line: #d7dde7;
  --panel: #ffffff;
  --page: #f5f7fb;
  --brand: #245c8f;
  --brand-dark: #17456d;
  --price: #b42318;
  --date: #075985;
  --quote: #7a4a00;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
}

.topbar {
  min-height: 86px;
  padding: 18px 32px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  margin-bottom: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-heading h2 {
  margin-bottom: 0;
}

.topbar p {
  margin-top: 6px;
  color: var(--muted);
}

.app-switcher {
  position: relative;
  display: inline-block;
}

.app-switcher summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.app-switcher summary h1 {
  line-height: 1.15;
}

.app-switcher summary:focus {
  outline: none;
}

.app-switcher summary::-webkit-details-marker {
  display: none;
}

.app-switcher summary span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  transition: transform 0.15s ease;
}

.app-switcher[open] summary span {
  transform: rotate(180deg);
}

.app-switch-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 20;
  min-width: 180px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
}

.app-switch-menu a {
  display: block;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.app-switch-menu a:hover {
  background: #eef2f7;
}

.app-switch-menu a.active {
  color: var(--brand);
  background: #eaf2fb;
}

.operator-switch,
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  white-space: nowrap;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.operator-switch strong {
  color: var(--text);
}

.text-link {
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
}

.text-link:hover {
  color: var(--brand-dark);
  text-decoration: underline;
}

select,
input,
textarea,
button {
  font: inherit;
}

select,
input,
textarea {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

textarea {
  height: auto;
  line-height: 1.5;
  padding: 10px 12px;
  resize: vertical;
}

button,
.download {
  height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  padding: 0 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover,
.download:hover {
  background: var(--brand-dark);
}

.secondary-button {
  height: 34px;
  background: #eef2f7;
  color: #334155;
  border: 1px solid var(--line);
}

.secondary-button:hover {
  background: #dfe6ef;
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 24px 40px;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.tab.active {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.download {
  margin-left: auto;
  background: #334155;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.upload-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr);
  gap: 18px;
}

.upload-stack {
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.notice {
  border-radius: 8px;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.notice.success {
  background: #ecfdf3;
  border: 1px solid #abefc6;
  color: #067647;
}

.notice.error {
  background: #fef3f2;
  border: 1px solid #fecdca;
  color: #b42318;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-shell {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
}

.auth-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  padding: 28px;
}

.auth-card p {
  color: var(--muted);
}

.auth-card label,
.admin-form label,
.user-row label {
  display: grid;
  gap: 7px;
}

.auth-card span,
.admin-form span,
.user-row span {
  color: var(--muted);
  font-size: 14px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 18px;
}

.admin-form {
  align-self: start;
  display: grid;
  gap: 14px;
}

.user-list {
  display: grid;
  gap: 10px;
}

.user-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-areas:
    "name password save"
    "name permissions save";
  grid-template-columns: minmax(90px, 120px) minmax(260px, 1fr) auto;
  gap: 10px 16px;
  align-items: center;
  padding: 14px;
}

.user-name {
  grid-area: name;
}

.user-password {
  grid-area: password;
  max-width: 360px;
}

.user-password input {
  width: 100%;
}

.user-permissions {
  grid-area: permissions;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  min-width: 0;
}

.user-save {
  grid-area: save;
}

.checkbox-row {
  align-items: center;
  display: flex !important;
  gap: 8px !important;
}

.checkbox-row input {
  height: auto;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field label,
.search-bar span {
  color: var(--muted);
  font-size: 14px;
}

.drop-zone {
  min-height: 210px;
  border: 2px dashed #9aa8bb;
  border-radius: 8px;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  cursor: pointer;
  background: #fafcff;
}

.drop-zone.dragover {
  border-color: var(--brand);
  background: #eef6ff;
}

.drop-zone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.drop-zone strong {
  font-size: 20px;
}

.drop-zone span,
#uploadHint,
#serverImportHint,
.server-import-status,
.schedule-note {
  color: var(--muted);
}

.server-import-status {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 12px;
}

.path-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.path-browser {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 12px;
  padding: 12px;
  background: #f8fafc;
}

.manual-quote-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 0;
  min-height: 210px;
  padding: 12px;
  background: #f8fafc;
}

.path-browser-head,
.path-browser-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.path-browser-actions {
  justify-content: flex-start;
  margin-top: 10px;
}

.path-current,
.path-empty,
.manual-quote-note,
#manualQuoteHint {
  color: var(--muted);
  font-size: 14px;
  margin-top: 10px;
  overflow-wrap: anywhere;
}

.manual-quote-table-wrap {
  margin-top: 12px;
  overflow-x: hidden;
}

.manual-quote-table {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
}

.manual-quote-table th,
.manual-quote-table td {
  border: 1px solid #111827;
  height: 48px;
  padding: 0;
}

.manual-quote-table th {
  background: #12aee2;
  color: #07111f;
  font-size: 17px;
  font-weight: 800;
  padding: 0 10px;
  text-align: left;
  white-space: normal;
}

.manual-quote-table .manual-index-head {
  background: #ffffff;
  width: 48px;
}

.manual-quote-table .manual-index {
  background: #12aee2;
  color: #07111f;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  width: 48px;
}

.manual-quote-table th:nth-child(2),
.manual-quote-table td:nth-child(2) {
  width: 24%;
}

.manual-quote-table th:nth-child(3),
.manual-quote-table td:nth-child(3) {
  width: 45%;
}

.manual-quote-table th:nth-child(4),
.manual-quote-table td:nth-child(4) {
  width: 31%;
}

.manual-quote-table td:not(.manual-index) {
  background: #fde7d6;
}

.manual-quote-table input {
  background: transparent;
  border: 0;
  border-radius: 0;
  height: 48px;
  outline: 0;
  padding: 0 10px;
  width: 100%;
}

.manual-quote-table input:focus {
  background: #fff7ed;
  box-shadow: inset 0 0 0 2px var(--brand);
}

.manual-quote-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.path-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 240px;
  overflow: auto;
}

.path-list .path-item {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  display: grid;
  gap: 4px;
  text-align: left;
  overflow-wrap: anywhere;
}

.path-list .path-item:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.path-list .preset-root {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.path-list .path-item span {
  color: #b42318;
  font-size: 13px;
  font-weight: 700;
}

.path-list .path-item small {
  color: var(--muted);
  font-size: 12px;
}

.actions {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.pickers {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.pickers button,
.pickers .picker-link {
  background: #334155;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  white-space: nowrap;
}

.pickers .picker-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}

.pickers .picker-link:hover {
  background: #1f2937;
}

.result-list {
  display: grid;
  gap: 10px;
}

.empty {
  color: var(--muted);
}

.import-row {
  border: 1px solid var(--line);
  border-left: 5px solid #94a3b8;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.import-row.imported {
  border-left-color: #12805c;
}

.import-row.skipped {
  border-left-color: #d97706;
}

.import-row.failed {
  border-left-color: #b42318;
}

.search-bar {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 14px;
  align-items: end;
}

.search-bar label {
  display: grid;
  gap: 7px;
}

.clearable-input {
  position: relative;
  display: block;
}

.clearable-input input {
  width: 100%;
  padding-right: 38px;
}

.input-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  width: 20px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #c7ccd4;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  line-height: 20px;
  transform: translateY(-50%);
  cursor: pointer;
}

.input-clear:hover {
  background: #8f98a6;
}

.input-clear[hidden] {
  display: none;
}

.search-meta {
  margin: 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.summary {
  color: var(--muted);
}

.discount-control {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.discount-control select {
  height: 34px;
}

.agreement-search {
  grid-template-columns: 1fr 1fr auto auto;
}

.deal-search {
  grid-template-columns: 0.8fr 0.8fr 1.25fr 1.25fr 1fr auto;
}

.quick-price-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(340px, 0.9fr) minmax(460px, 1.4fr);
}

.quick-price-panel {
  align-self: start;
}

.quick-price-drop {
  min-height: 160px;
}

.quick-price-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.quick-download {
  height: 34px;
  margin-left: 0;
}

.disabled-link {
  opacity: 0.45;
  pointer-events: none;
}

.quick-price-table-wrap {
  overflow-x: auto;
}

.quick-price-table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

.quick-price-table th,
.quick-price-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.quick-price-table th {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.quick-price-table td small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.quick-price-table .missing-row {
  background: #fff8f7;
}

.deal-toolbar {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: 16px 0;
}

.deal-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.missing-deal-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: 8px;
  vertical-align: middle;
}

.missing-deal-pill {
  align-items: center;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 999px;
  color: #b42318;
  display: inline-flex;
  font-weight: 700;
  gap: 4px;
  line-height: 1.2;
  padding: 3px 8px;
}

.clickable-pill {
  cursor: pointer;
  font-family: inherit;
}

.clickable-pill:hover {
  filter: brightness(0.97);
}

.missing-deal-pill small {
  color: #7f1d1d;
  font-size: 11px;
  font-weight: 600;
}

.amount-mismatch-pill {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #c2410c;
}

.amount-mismatch-pill small {
  color: #9a3412;
}

.deal-download {
  height: 34px;
  margin-left: 0;
}

.deal-metrics {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.metric-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 16px;
}

.metric-card span {
  color: var(--muted);
  font-size: 14px;
}

.metric-card strong {
  color: var(--ink);
  font-size: 22px;
}

.deal-summary-panel {
  margin-bottom: 16px;
}

.deal-summary-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.deal-summary-actions select {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  height: 34px;
  padding: 0 10px;
}

.deal-table-wrap {
  overflow-x: auto;
}

.deal-table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

.deal-table th,
.deal-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.deal-table th {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.results {
  display: grid;
  gap: 12px;
}

.result-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  gap: 10px;
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.danger-button {
  height: 34px;
  background: #b42318;
}

.danger-button:hover {
  background: #8a1c13;
}

.secondary-danger {
  background: #fff1f0;
  color: #b42318;
  border: 1px solid #fecdca;
}

.secondary-danger:hover {
  background: #fee4e2;
  color: #8a1c13;
}

.result-top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
}

.quote-no {
  color: var(--quote);
  font-weight: 800;
}

.date {
  color: var(--date);
  font-weight: 800;
}

.price {
  color: var(--price);
  font-weight: 800;
}

.gm-price {
  color: #047857;
}

.estimated-price {
  color: #9f1239;
}

.agreement-card {
  gap: 12px;
}

.agreement-top {
  gap: 10px 20px;
}

.agreement-detail {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 8px 18px;
  color: var(--muted);
}

.agreement-detail strong {
  color: var(--ink);
  font-weight: 700;
}

.search-hit {
  background: #ffe66d;
  color: #111827;
  border-radius: 3px;
  padding: 0 2px;
  font-weight: 800;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 16px;
  color: var(--muted);
}

.detail-grid strong {
  color: var(--ink);
  font-weight: 600;
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  main {
    padding: 16px;
  }

  .upload-layout,
  .search-bar,
  .detail-grid,
  .agreement-detail,
  .quick-price-layout,
  .deal-metrics,
  .admin-layout,
  .user-row {
    grid-template-columns: 1fr;
  }

  .tabs {
    flex-wrap: wrap;
  }

  .pickers {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .deal-toolbar,
  .deal-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .download {
    margin-left: 0;
  }

  .user-row {
    grid-template-areas:
      "name"
      "password"
      "permissions"
      "save";
    align-items: stretch;
  }

  .user-password {
    max-width: none;
  }

  .user-permissions {
    flex-direction: column;
    align-items: flex-start;
  }

  .user-save {
    width: 100%;
  }
}
/* deal-order-collapse:start */
.deal-order-card {
  padding: 0;
}

.deal-order-summary {
  align-items: center;
  cursor: pointer;
  display: grid;
  gap: 10px 18px;
  grid-template-columns: 18px minmax(120px, 1.1fr) minmax(110px, .9fr) minmax(70px, .55fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(220px, 1.4fr) auto;
  list-style: none;
  padding: 18px;
}

.deal-order-summary::-webkit-details-marker {
  display: none;
}

.deal-order-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.deal-order-label {
  color: var(--ink);
  font-weight: 500;
  line-height: 1.2;
}

.deal-order-field strong,
.deal-order-field .price,
.deal-order-field .date {
  display: block;
  line-height: 1.25;
}

.deal-order-actions {
  display: flex;
  justify-content: flex-end;
}

.deal-edit-button,
.deal-apply-button {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  color: #c2410c;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  height: 34px;
  padding: 0 14px;
  white-space: nowrap;
}

.deal-edit-button:hover,
.deal-apply-button:hover {
  background: #ffedd5;
}

.deal-apply-button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.deal-order-toggle::before {
  color: var(--muted);
  content: "▶";
  display: inline-block;
  font-size: 12px;
  transition: transform .15s ease;
}

.deal-order-card[open] .deal-order-toggle::before {
  transform: rotate(90deg);
}

.deal-order-items {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0;
  padding: 0 18px 14px;
}

.deal-candidate-panel {
  border-top: 1px solid var(--line);
  padding: 14px 18px;
}

.deal-candidate-header {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 10px;
}

.deal-candidate-header span,
.deal-candidate-status,
.deal-candidate-main span,
.deal-candidate-main small {
  color: var(--muted);
}

.deal-candidate-status {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}

.deal-candidate-status.error,
.deal-candidate-main .error {
  color: #b42318;
}

.deal-candidate-main .ok {
  color: #047857;
}

.deal-candidate-list {
  display: grid;
  gap: 8px;
}

.deal-candidate-row {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 12px;
}

.deal-candidate-row.invalid {
  background: #fff8f7;
}

.deal-candidate-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.deal-candidate-main strong,
.deal-candidate-main span,
.deal-candidate-main small {
  overflow-wrap: anywhere;
}

.deal-order-item {
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

.deal-order-item:last-child {
  border-bottom: 0;
}

@media (max-width: 900px) {
  .deal-order-summary {
    grid-template-columns: 18px 1fr;
  }

  .deal-order-actions {
    justify-content: flex-start;
  }

  .deal-candidate-row {
    align-items: stretch;
    grid-template-columns: 1fr;
  }
}
/* deal-order-collapse:end */
