﻿:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-blue: #f7faff;
  --border: #dbe4ee;
  --border-soft: #e8eef5;
  --text: #111827;
  --muted: #64748b;
  --subtle: #94a3b8;
  --blue: #2563eb;
  --blue-700: #1d4ed8;
  --green: #16834a;
  --red: #c0362c;
  --amber: #a15c00;
  --violet: #4f46e5;
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans SC", sans-serif;
}

body {
  font-size: 14px;
}

.app-loading {
  overflow: hidden;
}

.app-loading .app-shell {
  visibility: hidden;
}

.boot-splash {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--muted);
  font-size: 14px;
}

.app-ready .boot-splash {
  display: none;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
  padding: 20px 16px;
  border-right: 1px solid var(--border);
  background: #ffffff;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}

.brand-block strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
}

.brand-block span,
.side-status span,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.side-nav {
  display: grid;
  align-content: start;
  gap: 4px;
}

.side-nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: #334155;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.side-nav a:hover,
.side-nav a:focus {
  background: #eef4ff;
  color: var(--blue-700);
  outline: none;
}

.side-status {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

.side-status strong {
  font-size: 13px;
  font-weight: 700;
}

.main-shell {
  min-width: 0;
  display: grid;
  gap: 14px;
  padding: 18px 22px 36px;
}

#sendSection,
#queueSection,
#brandSection,
#configSection,
#historySection {
  scroll-margin-top: 82px;
}

.topbar,
.band,
.metric-tile,
.status-viz {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

.topbar h1,
.section-head h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  font-weight: 700;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions,
.section-tools,
.login-state-actions,
.inline-actions,
.pager-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.last-refresh {
  min-width: 112px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(116px, 1fr)) minmax(260px, 1.4fr);
  gap: 12px;
}

.metric-tile {
  min-height: 78px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 14px;
}

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

.metric-tile strong {
  font-size: 26px;
  line-height: 1;
  font-weight: 800;
}

.status-viz {
  min-height: 78px;
  display: grid;
  gap: 8px;
  padding: 12px 14px;
}

.status-viz-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.status-viz-row {
  display: grid;
  grid-template-columns: 74px minmax(90px, 1fr) 32px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}

.status-viz-track,
.brand-bar-track {
  height: 8px;
  border-radius: 999px;
  background: #edf2f7;
  overflow: hidden;
}

.status-viz-fill,
.brand-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.band {
  padding: 16px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 14px;
  align-items: start;
}

.secondary-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-head.compact {
  margin-bottom: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 240px);
  gap: 12px;
}

.send-form {
  grid-template-columns: minmax(0, 1fr) 150px 180px;
}

.form-grid label,
.brand-upload-field,
.brand-table-select,
.account-card {
  display: grid;
  gap: 7px;
}

.form-grid label.wide {
  grid-column: auto;
}

label span {
  color: #475569;
  font-size: 12px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  height: 38px;
  border: 1px solid #ccd7e2;
  border-radius: 7px;
  background: #fff;
  padding: 0 11px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

input[type="file"] {
  display: flex;
  align-items: center;
  padding: 7px 10px;
}

input:focus,
select:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

button {
  height: 36px;
  padding: 0 14px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

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

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

button.small {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

button.danger {
  border-color: #e7b5b0;
  color: var(--red);
  background: #fffafa;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.send-panel {
  min-height: 170px;
}

.extra-price-field {
  max-width: none;
}

.price-rule-input {
  max-width: 180px;
}

.login-grid {
  display: grid;
  gap: 10px;
}

.login-state-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

.login-state-panel .subhead,
.queue-head h3,
.subhead {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.login-state-status {
  min-height: 18px;
}

.login-state-status.success {
  color: var(--green);
}

.login-state-status.error {
  color: var(--red);
}

.queue-workspace {
  padding-bottom: 14px;
}

.queue-stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.queue-panel {
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.queue-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-soft);
  background: #fbfdff;
}

.queue-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px 9px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: top;
  font-size: 12px;
  line-height: 1.45;
}

thead th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 700;
}

tbody tr:hover td {
  background: #fbfdff;
}

.url-cell,
.path-cell {
  word-break: break-all;
}

.status {
  display: inline-flex;
  max-width: 440px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.45;
  white-space: normal;
}

.status-stack {
  display: grid;
  gap: 6px;
  align-items: start;
}

.eta-line {
  color: #475569;
  font-size: 12px;
}

.status.queued {
  background: #eef2f7;
  color: #475569;
}

.status.running {
  background: #e8f1ff;
  color: var(--blue-700);
}

.status.success {
  background: #e7f8ef;
  color: #137333;
}

.status.error {
  background: #fbe9e8;
  color: #b42318;
}

.status.needs_info {
  background: #fff4db;
  color: var(--amber);
}

.status.waiting_review,
.status.review_confirmed {
  background: #eef2ff;
  color: var(--violet);
}

.status.abandoned {
  background: #f1f5f9;
  color: #64748b;
}

.brand-offer-toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(260px, 1fr);
  gap: 12px;
  align-items: end;
  margin-bottom: 10px;
}

.brand-offer-upload {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.brand-offer-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  min-height: 34px;
  margin: 6px 0 12px;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface-soft);
  color: #506173;
  font-size: 12px;
}

.brand-offer-status strong {
  color: var(--text);
  font-weight: 700;
}

.brand-offer-status.error {
  border-color: #f3c8c8;
  background: #fff7f7;
  color: var(--red);
}

.brand-offer-summary {
  display: grid;
  gap: 10px;
}

.brand-overview-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.brand-overview-head > div {
  display: grid;
  gap: 3px;
}

.brand-overview-head strong {
  font-size: 13px;
  font-weight: 700;
}

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

.brand-selected-pill {
  max-width: 42%;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: #405266 !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-bar-list {
  display: grid;
  gap: 6px;
}

.brand-bar-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.75fr) minmax(120px, 1fr) 48px;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  text-align: left;
  font-size: 12px;
}

.brand-bar-row:hover,
.brand-bar-row.active {
  border-color: var(--border);
  background: #fbfdff;
}

.brand-bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-bar-row strong {
  justify-self: end;
  font-weight: 700;
}

.plugin-download-list {
  display: grid;
  gap: 10px;
}

.download-link-card {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--blue-700);
  text-decoration: none;
}

.download-link-card strong {
  color: var(--text);
  font-size: 13px;
}

.download-link-card:hover {
  border-color: var(--blue);
}

.config-stack {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

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

.price-rule-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

.price-rule-card strong {
  font-size: 13px;
  font-weight: 700;
}

.price-rule-formula {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.switch-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #fff;
  color: #334155;
  font-size: 13px;
}

.switch-line input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.config-account-row {
  max-width: 320px;
  margin-top: 12px;
}

.config-note {
  margin-top: 10px;
}

.download-area {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}

.download-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.download-lock {
  grid-template-columns: minmax(220px, 320px);
}

.download-settings {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

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

.account-card {
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

.hidden {
  display: none !important;
}

.inline-panel {
  display: grid;
  gap: 10px;
  max-width: 560px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #fff;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
}

.mini-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-soft);
}

.mini-table tr:last-child td {
  border-bottom: 0;
}

.mini-table td:first-child {
  width: 140px;
  color: var(--muted);
}

.inline-input {
  height: 32px;
  font-size: 13px;
}

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

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.history-table td:nth-child(2),
.history-table td:nth-child(5) {
  max-width: 360px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.42);
}

.modal-card {
  width: min(440px, 100%);
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.modal-head,
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head {
  margin-bottom: 16px;
}

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

.choice-stack {
  display: grid;
  gap: 10px;
}

.choice-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface-soft);
}

.choice-row input[type="radio"] {
  width: 16px;
  height: 16px;
  padding: 0;
}

.choice-row span {
  min-width: 42px;
  color: var(--text);
  font-size: 13px;
}

.compact-input {
  width: 120px;
  height: 34px;
  margin-left: auto;
}

.modal-foot {
  margin-top: 16px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  padding: 10px 14px;
  border-radius: 8px;
  background: #1f2937;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 13px;
}

.toast.success {
  background: var(--green);
}

.toast.error {
  background: var(--red);
}

.toast.hidden {
  display: none;
}

.error-report-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.error-report-item {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  min-height: 146px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #fff;
}

.error-report-image {
  display: grid;
  min-height: 146px;
  place-items: center;
  border-right: 1px solid var(--border-soft);
  background: #f5f7fa;
}

.error-report-image img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 190px;
  object-fit: contain;
}

.error-report-body {
  min-width: 0;
  padding: 14px 16px;
}

.error-report-meta,
.error-report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.error-report-meta {
  justify-content: space-between;
}

.report-status {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  border-radius: 6px;
  background: #eef1f5;
  color: #4b5563;
  font-size: 12px;
  font-weight: 700;
}

.report-status.accepted {
  background: #e9f7ef;
  color: #18794e;
}

.report-status.voided {
  background: #fff0f0;
  color: #b42318;
}

.report-status.completed {
  background: #eaf2ff;
  color: #1d4ed8;
}

.error-report-reason {
  margin: 12px 0 8px;
  color: var(--text);
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.error-report-time {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

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

@media (max-width: 1180px) {
  .overview-grid {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }

  .status-viz {
    grid-column: 1 / -1;
  }

  .workspace-grid,
  .secondary-grid,
  .send-form {
    grid-template-columns: 1fr;
  }

  .price-rule-grid,
  .toggle-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 6;
    height: auto;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .brand-block {
    min-height: 40px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .side-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .side-nav a {
    flex: 0 0 auto;
    padding: 8px 10px;
    background: var(--surface-soft);
    white-space: nowrap;
  }

  .side-status {
    display: none;
  }

  #sendSection,
  #queueSection,
  #brandSection,
  #configSection,
  #historySection {
    scroll-margin-top: 126px;
  }

  .main-shell {
    padding: 12px 10px 28px;
  }

  .topbar,
  .section-head,
  .download-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    position: relative;
  }

  .topbar-actions,
  .section-tools {
    justify-content: flex-start;
  }

  .last-refresh {
    min-width: 0;
    text-align: left;
  }

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

  .status-viz {
    grid-column: 1 / -1;
  }

  .metric-tile {
    min-height: 68px;
  }

  .metric-tile strong {
    font-size: 22px;
  }

  .band {
    padding: 14px 12px;
  }

  .error-report-item {
    grid-template-columns: 1fr;
  }

  .error-report-image {
    min-height: 180px;
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
  }

  .send-panel {
    display: grid;
  }

  .send-panel .section-head {
    display: contents;
  }

  .send-panel .section-head > div {
    order: 1;
    margin-bottom: 12px;
  }

  .send-panel .send-form {
    order: 2;
  }

  .send-panel #sendTaskButton {
    order: 3;
    width: 100%;
    margin-top: 10px;
  }

  .form-grid,
  .brand-offer-toolbar,
  .brand-offer-upload,
  .account-config-grid,
  .price-rule-grid,
  .toggle-grid,
  .download-lock,
  .config-account-row {
    grid-template-columns: 1fr;
  }

  .brand-overview-head {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-selected-pill {
    max-width: none;
  }

  .brand-bar-row {
    grid-template-columns: 1fr 76px;
  }

  .brand-bar-track {
    grid-column: 1 / -1;
    order: 3;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tbody tr {
    margin-bottom: 10px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
  }

  tbody tr:hover td {
    background: transparent;
  }

  td {
    display: grid;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 9px 10px;
    border-bottom: 1px solid var(--border-soft);
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

  td.empty {
    display: block;
  }

  td.empty::before {
    display: none;
  }

  .status {
    max-width: none;
  }

  .pager {
    align-items: stretch;
    flex-direction: column;
  }

  .pager-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    left: 12px;
  }
}

