:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --line: #e2e5ea;
  --line-strong: #c8ced7;
  --text: #15181e;
  --muted: #68707d;
  --subtle: #8a93a1;
  --brand: #781b1f;
  --brand-dark: #5f1518;
  --brand-soft: #f6eaeb;
  --teal: #0f766e;
  --teal-soft: #e8f5f3;
  --amber: #a16207;
  --amber-soft: #fff7e6;
  --danger: #c2413b;
  --danger-soft: #fff0ef;
  --shadow: 0 18px 45px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Microsoft YaHei UI", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 8px 8px 18px;
  border-bottom: 1px solid var(--line);
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(120, 27, 31, 0.14);
}

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

.brand strong {
  font-size: 17px;
  line-height: 1.1;
}

.brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 5px;
  margin-top: 16px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  color: #2f3540;
  background: transparent;
  text-align: left;
  padding: 0 10px;
  cursor: pointer;
}

.nav-icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 24px;
  border-radius: 7px;
  color: var(--subtle);
  background: #f1f2f4;
  font-size: 11px;
  font-weight: 700;
}

.nav.active,
.nav:hover {
  color: var(--brand);
  background: var(--brand-soft);
}

.nav.active .nav-icon,
.nav:hover .nav-icon {
  color: #fff;
  background: var(--brand);
}

.main {
  min-width: 0;
  padding: 22px 26px 34px;
}

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

.page-heading {
  min-width: 0;
}

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 16px;
  line-height: 1.3;
}

p {
  margin-top: 5px;
  color: var(--muted);
}

.top-actions,
.actions,
.inline-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 14px;
}

.notice {
  min-height: 30px;
  margin-bottom: 12px;
  padding: 0 2px;
  color: var(--muted);
}

.notice.error {
  color: var(--danger);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(148px, 1fr));
  gap: 12px;
}

.metrics.five {
  grid-template-columns: repeat(5, minmax(130px, 1fr));
}

.metrics.four {
  grid-template-columns: repeat(4, minmax(148px, 1fr));
}

.metric,
.panel,
.table-wrap,
.list-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  min-height: 104px;
  padding: 18px;
  box-shadow: 0 1px 0 rgba(17, 24, 39, 0.02);
}

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

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 32px;
  line-height: 1;
}

.panel {
  padding: 18px;
}

.compact-panel {
  padding: 14px 16px;
}

.action-panel,
.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.panel-header {
  margin-bottom: 16px;
}

.section-title {
  margin: 4px 0 -2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.field.compact {
  width: 210px;
}

.field.wide {
  grid-column: span 2;
}

.field.grow {
  flex: 1 1 260px;
}

.filter-grid,
.form-grid,
.settings-grid {
  display: grid;
  gap: 12px;
}

.filter-grid {
  grid-template-columns: minmax(240px, 2fr) repeat(5, minmax(132px, 1fr));
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.form-grid.three,
.settings-grid {
  grid-template-columns: repeat(3, minmax(190px, 1fr));
}

.btn,
.input,
select,
.textarea {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  min-width: 88px;
  padding: 0 14px;
  font-weight: 650;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  border-color: var(--brand);
  color: var(--brand);
  box-shadow: 0 4px 12px rgba(120, 27, 31, 0.08);
}

.btn.primary {
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
}

.btn.primary:hover {
  color: #fff;
  background: var(--brand-dark);
}

.btn.tiny {
  min-width: 56px;
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.input,
select {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  outline: none;
}

.textarea {
  display: block;
  width: 100%;
  min-height: 132px;
  padding: 10px 12px;
  resize: vertical;
  outline: none;
}

.input:focus,
select:focus,
.textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(120, 27, 31, 0.11);
}

.table-wrap {
  overflow: auto;
  box-shadow: var(--shadow);
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #4a5360;
  background: #f7f8fa;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

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

tbody tr:hover {
  background: #fbf7f7;
}

tbody tr.danger-row {
  background: var(--danger-soft);
}

.check-col {
  width: 42px;
}

.order-id {
  display: block;
  max-width: 150px;
  color: #111827;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.tracking {
  max-width: 150px;
  overflow-wrap: anywhere;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  padding: 14px 15px;
  box-shadow: 0 1px 0 rgba(17, 24, 39, 0.02);
}

.list-item strong {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.list-item .body-text {
  color: #2e3440;
  white-space: pre-wrap;
}

.muted {
  color: var(--muted);
}

.badge,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 8px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill,
.badge.neutral {
  color: #4d5562;
  background: #f0f2f5;
}

.badge.success {
  color: var(--teal);
  background: var(--teal-soft);
}

.badge.warning {
  color: var(--amber);
  background: var(--amber-soft);
}

.badge.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.scope-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.scope-list.tight {
  margin-top: 6px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
}

.status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.status-item span {
  color: var(--muted);
}

.status-item strong {
  font-size: 12px;
}

.status-item strong.ok {
  color: var(--teal);
}

.status-item strong.waiting {
  color: var(--amber);
}

.progress {
  width: 180px;
  height: 7px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef0f3;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--teal));
}

.creator-table {
  min-width: 1120px;
}

.creator-item label {
  display: flex;
  gap: 8px;
  align-items: center;
}

.text-link {
  color: var(--brand);
  font-weight: 700;
}

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

  .field.wide {
    grid-column: span 3;
  }

  .form-grid.three,
  .settings-grid {
    grid-template-columns: repeat(2, minmax(190px, 1fr));
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
  }

  .brand {
    min-height: 52px;
    padding-bottom: 12px;
  }

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

  .nav {
    justify-content: center;
    padding: 0 8px;
  }

  .nav-icon {
    display: none;
  }

  .main {
    padding: 16px;
  }

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

  .top-actions,
  .actions,
  .inline-controls {
    align-items: stretch;
  }

  .field.compact {
    width: 100%;
  }

  .metrics,
  .metrics.five,
  .metrics.four,
  .status-grid,
  .filter-grid,
  .form-grid.two,
  .form-grid.three,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .field.wide {
    grid-column: span 1;
  }

  .btn {
    width: 100%;
  }
}
