/* 星辰电器 · 商家后台样式 */
:root {
  --bg: #f2f5f9;
  --card: #ffffff;
  --ink: #16202c;
  --ink-2: #4a5a6d;
  --ink-3: #8496a8;
  --line: #e3eaf2;
  --primary: #1e66e0;
  --primary-dark: #1650b4;
  --primary-soft: #e8f0fe;
  --accent: #f2711c;
  --accent-soft: #fdefe4;
  --green: #15915b;
  --green-soft: #e6f6ee;
  --red: #d64545;
  --red-soft: #fdecec;
  --amber: #c47f12;
  --amber-soft: #fdf3e1;
  --sidebar: #10233a;
  --sidebar-2: #17304d;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(22, 32, 44, 0.06);
  --shadow-lg: 0 12px 40px rgba(22, 32, 44, 0.16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    "PingFang SC", "Hiragino Sans GB", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  display: flex;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ============ 侧栏 ============ */
.sidebar {
  width: 232px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #fff;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 18px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.logo-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.logo-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 2px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  flex: 1;
}

.nav-item {
  all: unset;
  cursor: pointer;
  padding: 11px 14px;
  border-radius: 9px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.68);
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.nav-item.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(30, 102, 224, 0.35);
}

.sidebar-foot {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.storage-info {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.42);
  line-height: 1.4;
}

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

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px 18px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.page-sub {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 3px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.badge-soft {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.content {
  padding: 0 28px 40px;
  flex: 1;
}

/* ============ 通用卡片 ============ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

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

.section-title {
  font-size: 16px;
  font-weight: 700;
}

.section-hint {
  font-size: 12px;
  color: var(--ink-3);
}

/* ============ 概览 ============ */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.metric::after {
  content: "";
  position: absolute;
  right: -26px;
  bottom: -30px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: var(--primary-soft);
}

.metric-label {
  font-size: 12px;
  color: var(--ink-3);
  position: relative;
  z-index: 1;
}

.metric-value {
  font-size: 26px;
  font-weight: 700;
  margin-top: 6px;
  position: relative;
  z-index: 1;
  letter-spacing: 0.3px;
}

.metric-extra {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 4px;
  position: relative;
  z-index: 1;
}

.metric.green .metric-value {
  color: var(--green);
}

.metric.orange .metric-value {
  color: var(--accent);
}

.metric.red .metric-value {
  color: var(--red);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 16px;
}

/* ============ 按钮 ============ */
.btn {
  all: unset;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: filter 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  user-select: none;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn.primary:hover {
  filter: brightness(1.06);
}

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

.btn.ghost {
  background: #fff;
  color: var(--ink-2);
  border: 1px solid var(--line);
}

.btn.ghost:hover {
  background: #f7fafd;
}

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

.btn.sm {
  height: 30px;
  padding: 0 12px;
  font-size: 12px;
  border-radius: 8px;
}

.btn.tiny {
  height: 26px;
  padding: 0 9px;
  font-size: 12px;
  border-radius: 7px;
}

.btn.block {
  width: 100%;
}

/* ============ 工具条 ============ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.search-input {
  flex: 1;
  min-width: 200px;
  height: 38px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  outline: none;
  font-size: 13px;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.select-input {
  height: 38px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  outline: none;
  font-size: 13px;
  cursor: pointer;
}

/* ============ 表格 ============ */
.table-wrap {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  padding: 12px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 13px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  font-size: 13px;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: #fafcfe;
}

.product-cell {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 210px;
}

.product-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.mark-0 { background: #3b82f6; }
.mark-1 { background: #8b5cf6; }
.mark-2 { background: #0ea5e9; }
.mark-3 { background: #10b981; }
.mark-4 { background: #f59e0b; }
.mark-5 { background: #ef4444; }

.product-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.product-model {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
}

.money {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.money.price {
  color: var(--accent);
}

.money.cost {
  color: var(--ink-2);
}

.money.profit {
  color: var(--green);
}

.money.loss {
  color: var(--red);
}

.muted {
  color: var(--ink-3);
  font-size: 12px;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.tag.blue {
  background: var(--primary-soft);
  color: var(--primary);
}

.tag.green {
  background: var(--green-soft);
  color: var(--green);
}

.tag.orange {
  background: var(--accent-soft);
  color: var(--accent);
}

.tag.red {
  background: var(--red-soft);
  color: var(--red);
}

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

.tag.gray {
  background: #f1f5f9;
  color: var(--ink-3);
}

/* ============ 开关 ============ */
.switch {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #d7e0ea;
  cursor: pointer;
  transition: background 0.18s ease;
  flex-shrink: 0;
  border: none;
  padding: 0;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.18s ease;
}

.switch.on {
  background: var(--primary);
}

.switch.on::after {
  transform: translateX(18px);
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-2);
}

/* ============ 订单卡片 ============ */
.order-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.order-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.order-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.order-no {
  font-size: 14px;
  font-weight: 700;
}

.order-time {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 3px;
}

.order-body {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
}

.order-items {
  flex: 1;
  min-width: 0;
}

.order-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  font-size: 13px;
}

.order-item-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-meta {
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
}

.order-side {
  width: 168px;
  flex-shrink: 0;
  text-align: right;
}

.order-total {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.order-profit {
  font-size: 11px;
  color: var(--green);
  margin-top: 3px;
}

.order-delivery {
  margin-top: 6px;
  font-size: 11px;
  color: var(--ink-2);
  line-height: 1.45;
  word-break: break-all;
}

.order-remark {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 11px;
}

.order-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

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

/* ============ 聊天 ============ */
.chat-layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 16px;
  height: calc(100vh - 150px);
}

.chat-list {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
}

.chat-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  cursor: pointer;
  border-bottom: 1px solid #f4f7fb;
}

.chat-list-item:hover {
  background: #f8fafd;
}

.chat-list-item.active {
  background: var(--primary-soft);
}

.chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-list-name {
  font-size: 13px;
  font-weight: 600;
}

.chat-list-last {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  font-weight: 600;
}

.chat-messages {
  flex: 1;
  overflow: auto;
  padding: 18px;
  background: #f7fafd;
}

.chat-row {
  display: flex;
  margin-bottom: 14px;
}

.chat-row.mine {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: 62%;
  padding: 10px 14px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(22, 32, 44, 0.06);
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.chat-row.mine .chat-bubble {
  background: var(--primary);
  color: #fff;
}

.chat-stamp {
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 5px;
}

.chat-row.mine .chat-stamp {
  text-align: right;
}

.chat-input-bar {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

.chat-input {
  flex: 1;
  height: 40px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  outline: none;
  font-size: 13px;
}

.chat-input:focus {
  border-color: var(--primary);
}

/* ============ 空状态 ============ */
.empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--ink-3);
}

.empty-icon {
  font-size: 40px;
  margin-bottom: 10px;
  line-height: 1;
}

.empty-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}

.empty-hint {
  font-size: 12px;
  margin-top: 5px;
}

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(16, 35, 58, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 30;
  backdrop-filter: blur(2px);
}

.modal {
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 22px;
}

.modal.max-wide {
  max-width: 720px;
}

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

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  all: unset;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  font-size: 18px;
}

.modal-close:hover {
  background: #f3f6fa;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

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

.field-label {
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 600;
}

.field-input,
.field-textarea,
.field-select {
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  outline: none;
  font-size: 13px;
  width: 100%;
}

.field-textarea {
  height: 84px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}

.field-input:focus,
.field-textarea:focus,
.field-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.field-tip {
  font-size: 11px;
  color: var(--ink-3);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 42px;
  transform: translateX(-50%);
  background: rgba(22, 32, 44, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 10px 20px;
  border-radius: 999px;
  z-index: 40;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* ============ 设置页 ============ */
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 16px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.notice-box {
  padding: 12px 14px;
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  line-height: 1.6;
}

.danger-box {
  padding: 12px 14px;
  border-radius: 9px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 12px;
  line-height: 1.6;
}

/* ============ 管理员登录 ============ */
.admin-login-mask {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #10233a 0%, #17304d 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
}

.admin-login-card {
  width: 100%;
  max-width: 380px;
  padding: 28px 24px 22px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.admin-login-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-login-title {
  font-size: 18px;
  font-weight: 700;
}

.admin-login-sub {
  margin: 4px 0 18px;
  font-size: 12px;
  color: var(--ink-3);
}

.admin-login-input {
  width: 100%;
  height: 42px;
  margin-bottom: 12px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #f8fafc;
  outline: none;
  font-size: 14px;
}

.admin-login-input:focus {
  border-color: var(--primary);
  background: #fff;
}

.admin-login-btn {
  height: 44px;
}

.admin-login-tip {
  margin-top: 10px;
  min-height: 18px;
  font-size: 12px;
  color: var(--red);
}

/* ============ 响应式 ============ */
@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 900px) {
  body {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    padding: 14px;
  }

  .nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 8px;
    margin: 8px 0 0;
  }

  .nav-item {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 13px;
  }

  .sidebar-foot {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .storage-info {
    display: none;
  }

  .topbar {
    padding: 16px 18px 12px;
  }

  .content {
    padding: 0 18px 28px;
  }

  .chat-layout {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }

  .chat-list {
    max-height: 180px;
  }

  .chat-panel {
    height: 460px;
  }

  .settings-grid,
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .order-body {
    flex-direction: column;
  }

  .order-side {
    width: 100%;
    text-align: left;
  }

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

  .table {
    min-width: 760px;
  }
}
