:root {
  --sidebar-bg: #1a1a2e;
  --sidebar-bg-deep: #141422;
  --sidebar-bg-mid: #2c3e50;
  --sidebar-text: #ecf0f1;
  --sidebar-text-muted: rgba(236, 240, 241, 0.62);
  --sidebar-active: rgba(44, 62, 80, 0.85);
  --sidebar-hover: rgba(236, 240, 241, 0.08);
  --sidebar-border: rgba(236, 240, 241, 0.1);
  --sidebar-accent: #5d6d7e;
  --primary: #2c3e50;
  --primary-soft: #eef1f4;
  --accent: #34495e;
  --bg: #f3f5f9;
  --card: #ffffff;
  --border: #e6e9f0;
  --text: #303030;
  --muted: #6b7280;
  --success: #1f9d6a;
  --success-bg: #e8f7f0;
  --warning: #c47a12;
  --warning-bg: #fff4e5;
  --info: #2b6cb0;
  --info-bg: #e8f1fb;
  --danger: #c0392b;
  --sidebar-width: 260px;
  --detail-width: 320px;
  --topbar-height: 56px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
}

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

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar — 深沉商务风 + 线型图标 */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(44, 62, 80, 0.55) 0%, transparent 55%),
    linear-gradient(180deg, #1a1a2e 0%, #151b28 48%, #2c3e50 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
  border-right: 1px solid rgba(0, 0, 0, 0.4);
  box-shadow: 6px 0 28px rgba(15, 18, 32, 0.28);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 18px;
  margin: 0 2px 8px;
  border-bottom: 1px solid rgba(236, 240, 241, 0.1);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(236, 240, 241, 0.14), rgba(236, 240, 241, 0.04));
  border: 1px solid rgba(236, 240, 241, 0.18);
  color: #ffffff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-mark svg {
  width: 20px;
  height: 20px;
}

.brand-copy {
  min-width: 0;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #ffffff;
  line-height: 1.2;
}

.brand-sub {
  margin-top: 3px;
  font-size: 11px;
  color: var(--sidebar-text-muted);
  letter-spacing: 0.06em;
}

.nav-section {
  flex: 1;
  overflow-y: auto;
  padding: 4px 2px 8px;
}

.nav-label {
  margin: 12px 12px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(236, 240, 241, 0.38);
}

.nav-item,
.nav-sub a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 450;
  margin-bottom: 2px;
  transition: background 0.15s ease, color 0.15s ease;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.nav-item.disabled,
.nav-sub a.disabled {
  color: var(--sidebar-text-muted);
  opacity: 1;
  cursor: not-allowed;
  pointer-events: none;
}

.nav-item:hover:not(.disabled),
.nav-sub a:hover:not(.disabled) {
  background: rgba(236, 240, 241, 0.08);
  color: #ffffff;
}

.nav-item.active,
.nav-sub a.active {
  background: rgba(236, 240, 241, 0.12);
  color: #ffffff;
  font-weight: 600;
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: #ecf0f1;
  opacity: 0.88;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.nav-text {
  flex: 1;
  min-width: 0;
}

.nav-item.active .nav-icon,
.nav-item:hover:not(.disabled) .nav-icon,
.nav-group-toggle:hover .nav-icon,
.nav-group.is-open > .nav-group-toggle .nav-icon {
  color: #ffffff;
  opacity: 1;
}

.nav-group {
  margin-bottom: 4px;
}

.nav-group-toggle {
  font: inherit;
}

.nav-group.is-open > .nav-group-toggle {
  color: #ffffff;
  background: rgba(236, 240, 241, 0.06);
}

.nav-chevron {
  width: 14px;
  height: 14px;
  color: rgba(236, 240, 241, 0.45);
  transition: transform 0.18s ease;
  display: grid;
  place-items: center;
  margin-left: auto;
}

.nav-chevron svg {
  width: 14px;
  height: 14px;
}

.nav-group.is-open .nav-chevron {
  transform: rotate(180deg);
  color: #ecf0f1;
}

.nav-sub {
  margin: 2px 0 6px 0;
  padding: 2px 0 2px 30px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-sub[hidden] {
  display: none;
}

.nav-sub a {
  font-size: 13px;
  padding: 9px 12px;
  color: var(--sidebar-text-muted);
  width: auto;
}

.nav-sub a.active {
  color: #ffffff;
  background: rgba(236, 240, 241, 0.14);
}

.nav-sub a:hover:not(.disabled) {
  color: #ffffff;
}

.nav-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(236, 240, 241, 0.1);
}

/* Main column */
.main-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-height);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: default;
  display: grid;
  place-items: center;
  padding: 0;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-meta strong {
  font-size: 13px;
}

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

.logout-link {
  font-size: 12px;
  color: #2c3e50;
}

.content-with-detail {
  flex: 1;
  display: flex;
  min-height: 0;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 18px 20px 24px;
  overflow: auto;
}

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

.page-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.page-actions {
  display: flex;
  gap: 8px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  background: var(--card);
  color: var(--text);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: #2c3e50;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #1a1a2e;
}

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

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 16px;
  flex-shrink: 0;
}

.stat-icon.green {
  background: var(--success-bg);
  color: var(--success);
}
.stat-icon.blue {
  background: var(--info-bg);
  color: var(--info);
}
.stat-icon.orange {
  background: var(--warning-bg);
  color: var(--warning);
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  margin-top: 2px;
}

.stat-value.empty {
  color: #9ca3af;
  font-weight: 600;
}

/* Filters */
.filter-bar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  align-items: center;
}

.filter-bar select,
.filter-bar input {
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--muted);
  min-width: 120px;
}

.filter-bar input[type="search"] {
  margin-left: auto;
  min-width: 200px;
}

/* Table */
.table-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

table.orders-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.orders-table th,
.orders-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.orders-table th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  background: #fafbfd;
}

.orders-table tbody tr {
  cursor: pointer;
  transition: background 0.12s ease;
}

.orders-table tbody tr:hover,
.orders-table tbody tr.is-active {
  background: #f4f6f8;
}

.order-sn {
  color: #2c3e50;
  font-weight: 600;
}

.platform-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f3f4f6;
  font-size: 12px;
}

.platform-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e02e24;
}

.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge.s1 {
  background: var(--warning-bg);
  color: var(--warning);
}
.status-badge.s2 {
  background: var(--info-bg);
  color: var(--info);
}
.status-badge.s3 {
  background: var(--success-bg);
  color: var(--success);
}
.status-badge.s0 {
  background: #f3f4f6;
  color: var(--muted);
}

.link-action {
  color: #2c3e50;
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.footer-actions {
  display: flex;
  gap: 8px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.pagination a {
  color: #2c3e50;
}

.empty-table {
  text-align: center;
  color: var(--muted);
  padding: 36px 12px !important;
}

/* Detail panel */
.detail-panel {
  width: var(--detail-width);
  flex-shrink: 0;
  background: var(--card);
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.22s ease, padding 0.22s ease;
  position: relative;
}

.detail-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.detail-panel h2 {
  margin: 0;
  font-size: 15px;
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}

.detail-toggle {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.detail-toggle:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: #c5cae8;
}

.detail-panel.is-collapsed {
  width: 40px;
  padding: 12px 6px;
  overflow: hidden;
}

.detail-panel.is-collapsed .detail-panel-header {
  flex-direction: column;
  align-items: center;
  margin-bottom: 0;
}

.detail-panel.is-collapsed h2,
.detail-panel.is-collapsed #detail-empty,
.detail-panel.is-collapsed #detail-body {
  display: none !important;
}

.detail-panel.is-collapsed .detail-toggle {
  width: 28px;
}

.detail-expand-rail {
  display: none;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.12em;
  margin-top: 12px;
  cursor: pointer;
  user-select: none;
  padding: 8px 0;
  text-align: center;
}

.detail-panel.is-collapsed .detail-expand-rail {
  display: block;
}

.detail-expand-rail:hover {
  color: var(--primary);
}

.detail-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 24px 8px;
  text-align: center;
  line-height: 1.6;
}

.detail-section {
  margin-bottom: 16px;
}

.detail-section h3 {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: none;
}

.detail-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.detail-item:last-child {
  border-bottom: none;
}

.detail-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #eef0f6;
  flex-shrink: 0;
}

.detail-item-meta {
  flex: 1;
  min-width: 0;
}

.detail-item-meta strong {
  display: block;
  font-size: 13px;
}

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

.detail-price {
  font-weight: 600;
  white-space: nowrap;
}

.detail-block {
  background: #f8f9fc;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
}

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

.timeline-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 0;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #1a1a2e 0%, #1e2a38 48%, #2c3e50 100%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 14px;
  padding: 28px 28px 24px;
  box-shadow: 0 18px 50px rgba(16, 24, 40, 0.22);
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.login-card p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
}

.form-field {
  margin-bottom: 14px;
}

.form-field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.form-field input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
}

.form-error {
  background: #fdecea;
  color: var(--danger);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  margin-bottom: 12px;
}

.login-card .btn-primary {
  width: 100%;
  height: 40px;
  margin-top: 6px;
}

@media (max-width: 1200px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .detail-panel {
    display: none;
  }
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }
  .stats-row {
    grid-template-columns: 1fr;
  }
}
