:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --soft: #eef4f8;
  --line: #d9e3ee;
  --line-strong: #bfccda;
  --text: #162033;
  --muted: #66758a;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --blue: #2563eb;
  --amber: #b45309;
  --red: #b91c1c;
  --green: #047857;
  --violet: #7c3aed;
  --shadow: 0 16px 38px rgba(22, 34, 50, 0.08);
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

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

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 22px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #10293c;
  color: #facc15;
  flex: 0 0 auto;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 760;
  line-height: 1.25;
  letter-spacing: 0;
}

.nav {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(104px, 1fr));
  min-width: min(480px, 100%);
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.nav a,
.nav button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

body[data-page="seller"] .nav a[data-page="seller"],
body[data-page="buyer"] .nav a[data-page="buyer"],
body[data-page="platform"] .nav a[data-page="platform"],
.nav a.is-active,
.nav button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(22, 34, 50, 0.08);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  min-height: 84px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(22, 34, 50, 0.04);
}

.stat span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 10px;
  font-size: 21px;
  line-height: 1.1;
  letter-spacing: 0;
}

.grid {
  display: grid;
  grid-template-columns: minmax(350px, 430px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel + .panel {
  margin-top: 14px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 10px;
  min-height: 56px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.panel-title {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  margin: 0;
  font-size: 16px;
  font-weight: 750;
  line-height: 1.25;
  white-space: nowrap;
}

.panel-body {
  padding: 14px;
}

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

.field {
  min-width: 0;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  display: block;
  margin-bottom: 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  outline: none;
  padding: 0 10px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

textarea {
  min-height: 170px;
  padding-top: 9px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.button,
.icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}

.button {
  padding: 0 12px;
}

.icon-only {
  width: 38px;
  padding: 0;
}

.button.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--teal-dark);
}

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

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

.button.ghost {
  background: #f8fafc;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
}

.search {
  position: relative;
  flex: 1 1 240px;
  min-width: 190px;
  max-width: 360px;
}

.search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.search input {
  padding-left: 34px;
}

.compact-select {
  width: auto;
  min-width: 116px;
}

.selected-box {
  display: grid;
  gap: 6px;
  min-height: 80px;
  margin-bottom: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
}

.selected-box strong {
  color: var(--text);
  font-size: 15px;
}

.selected-box .price {
  color: var(--teal);
  font-weight: 760;
}

.notice {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
  color: #7c2d12;
  line-height: 1.6;
}

.contact-card {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.contact-card strong {
  color: var(--text);
}

.summary-line {
  color: var(--muted);
  font-size: 13px;
}

.inline-price {
  color: var(--teal);
  font-weight: 760;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
}

th,
td {
  height: 44px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 750;
}

tbody tr:hover {
  background: #f8fbff;
}

.empty-row td {
  height: 150px;
  color: var(--muted);
  text-align: center;
}

.tag,
.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.tag.pc {
  background: #e0f2fe;
  color: #075985;
}

.tag.mobile {
  background: #ecfdf5;
  color: #065f46;
}

.status.sale,
.status.done,
.status.paid {
  background: #dcfce7;
  color: var(--green);
}

.status.locked,
.status.pending {
  background: #fef3c7;
  color: var(--amber);
}

.status.sold {
  background: #e0e7ff;
  color: #3730a3;
}

.status.off,
.status.cancel {
  background: #fee2e2;
  color: var(--red);
}

.status.neutral {
  background: #e2e8f0;
  color: #475569;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.row-actions .icon-only {
  width: 34px;
  min-height: 34px;
  border-color: var(--line);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  max-width: min(380px, calc(100% - 40px));
  padding: 11px 13px;
  border: 1px solid #99f6e4;
  border-radius: 8px;
  background: #f0fdfa;
  color: #134e4a;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

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

.modal {
  width: min(480px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}

svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.2;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1180px) {
  .stats {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

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

@media (max-width: 760px) {
  .shell {
    padding: 14px;
  }

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

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

  .panel-title {
    align-self: flex-start;
  }

  .nav {
    grid-template-columns: 1fr;
    width: 100%;
    min-width: 0;
  }

  .filters {
    justify-content: stretch;
  }

  .search,
  .compact-select,
  .filters .button {
    width: 100%;
    max-width: none;
  }

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

  .form-grid,
  .button-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 20px;
  }
}

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