/* ==================================================================
   商户资料管理系统 - 样式
   浅色主题 / 桌面端优先
   ================================================================== */

:root {
  --green: #2b7a3d;
  --green-light: #38a169;
  --green-lighter: #f0fdf4;
  --orange: #d97706;
  --orange-light: #fffbeb;
  --red: #dc2626;
  --red-light: #fef2f2;
  --blue: #2563eb;
  --blue-light: #eff6ff;

  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e5e7eb;
  --border-light: #f3f4f6;

  --text: #1f2937;
  --text-mid: #4b5563;
  --text-muted: #9ca3af;

  --sidebar-w: 220px;
  --topbar-h: 60px;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

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

/* ================= 登录页 ================= */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2b7a3d 0%, #38a169 55%, #48bb78 100%);
}

.login-box {
  width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 48px 40px 36px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo { font-size: 48px; line-height: 1; }

.login-title {
  font-size: 22px;
  font-weight: 700;
  margin: 16px 0 4px;
}

.login-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 32px;
  letter-spacing: 0.5px;
}

.login-input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  margin-bottom: 14px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}

.login-input:focus { border-color: var(--green); }

.login-error {
  color: var(--red);
  font-size: 13px;
  min-height: 20px;
  text-align: left;
  margin-bottom: 4px;
}

.login-btn {
  width: 100%;
  height: 44px;
  background: linear-gradient(135deg, var(--green), var(--green-light));
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.login-btn:hover { opacity: 0.9; }

.login-tip {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 20px;
}

/* ================= 布局 ================= */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: #1f2937;
  color: #d1d5db;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}

.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.sb-icon { font-size: 20px; margin-right: 10px; }
.sb-name { font-size: 15px; font-weight: 600; color: #fff; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  padding: 11px 20px;
  cursor: pointer;
  font-size: 14px;
  color: #9ca3af;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

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

.nav-item.active {
  background: rgba(56, 161, 105, 0.14);
  color: #fff;
  border-left-color: var(--green-light);
  font-weight: 500;
}

.ni-icon { width: 22px; margin-right: 8px; font-size: 15px; }

.ni-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-foot {
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.admin-info { display: flex; align-items: center; margin-bottom: 12px; }

.ai-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  margin-right: 10px;
  flex-shrink: 0;
}

.ai-name { font-size: 13px; color: #e5e7eb; font-weight: 500; }
.ai-role { font-size: 11px; color: #6b7280; }

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

.mini-btn {
  flex: 1;
  height: 28px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #d1d5db;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.mini-btn:hover { background: rgba(255, 255, 255, 0.12); }
.mini-btn.danger:hover { background: rgba(220, 38, 38, 0.25); border-color: rgba(220, 38, 38, 0.4); }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-size: 17px; font-weight: 600; margin: 0; }

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

.topbar-time { font-size: 12px; color: var(--text-muted); font-family: monospace; }

.refresh-btn {
  width: 30px; height: 30px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-mid);
  transition: all 0.2s;
}

.refresh-btn:hover { background: var(--bg); transform: rotate(180deg); }

.content { flex: 1; padding: 20px 24px 40px; }

/* ================= 卡片 ================= */
.card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
}

.card-title::before {
  content: '';
  width: 3px; height: 14px;
  background: var(--green);
  border-radius: 2px;
  margin-right: 8px;
}

.card-body { padding: 18px; }
.card-body.no-pad { padding: 0; }

/* ================= 统计卡 ================= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

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

.stat-card::after {
  content: '';
  position: absolute;
  right: -20px; top: -20px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--green-lighter);
  opacity: 0.6;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
  position: relative;
  z-index: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  position: relative;
  z-index: 1;
}

.stat-green .stat-value { color: var(--green); }
.stat-orange .stat-value { color: var(--orange); }
.stat-blue .stat-value { color: var(--blue); }
.stat-red .stat-value { color: var(--red); }

.stat-orange::after { background: var(--orange-light); }
.stat-blue::after { background: var(--blue-light); }
.stat-red::after { background: var(--red-light); }

/* ================= 表单 ================= */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 14px;
}

.form-group { display: flex; flex-direction: column; }

.form-group.grow { flex: 1; min-width: 160px; }

.form-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.form-input,
.form-select {
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 10px;
  font-size: 13px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
  color: var(--text);
  font-family: inherit;
  min-width: 120px;
}

.form-input:focus, .form-select:focus { border-color: var(--green); }

.form-input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.btn {
  height: 34px;
  padding: 0 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-mid);
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

.btn:hover { background: var(--bg); border-color: #cbd5e0; }

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

.btn-danger { color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: var(--red-light); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }

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

/* ================= 表格 ================= */
.table-wrap { overflow-x: auto; }

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

table.data th {
  background: #f9fafb;
  color: var(--text-mid);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 12px;
}

table.data td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

table.data tbody tr:hover { background: #f9fafb; }
table.data tbody tr:last-child td { border-bottom: none; }

table.data .cell-no {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--green);
  font-weight: 600;
  font-size: 12px;
}

.cell-phone { font-family: ui-monospace, Menlo, monospace; }
.cell-mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.cell-id { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--text-mid); }

.cell-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ================= 标签 ================= */
.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.tag-green { background: var(--green-lighter); color: var(--green); }
.tag-orange { background: var(--orange-light); color: var(--orange); }
.tag-red { background: var(--red-light); color: var(--red); }
.tag-blue { background: var(--blue-light); color: var(--blue); }
.tag-gray { background: #f3f4f6; color: #6b7280; }

.type-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  background: var(--green-lighter);
  color: var(--green);
  white-space: nowrap;
}

/* ================= 分页 ================= */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
  gap: 10px;
}

.page-info { font-size: 13px; color: var(--text-muted); }

.page-btns { display: flex; gap: 6px; align-items: center; }

.page-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-mid);
  transition: all 0.15s;
}

.page-btn:hover:not(:disabled) { border-color: var(--green); color: var(--green); }
.page-btn.active { background: var(--green); border-color: var(--green); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

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

.empty-icon { font-size: 44px; margin-bottom: 12px; }
.empty-text { font-size: 14px; }

/* ================= 加载 ================= */
.loading-box { padding: 50px; text-align: center; color: var(--text-muted); }

.spinner {
  display: inline-block;
  width: 26px; height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ================= 图片 ================= */
.img-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.img-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  background: #f9fafb;
}

.img-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-item:hover img { transform: scale(1.05); }
.img-item img { transition: transform 0.2s; }

.img-actions {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 14px 4px 5px;
  opacity: 0;
  transition: opacity 0.2s;
}

.img-item:hover .img-actions { opacity: 1; }

.img-btn {
  background: rgba(255, 255, 255, 0.92);
  border: none;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}

.img-btn:hover { background: #fff; }

/* 详情里的资料字段 */
.detail-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 24px; }

.detail-field {
  display: flex;
  padding: 11px 0;
  border-bottom: 1px dashed var(--border-light);
  align-items: flex-start;
}

.df-label {
  width: 130px;
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.df-value {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
}

.df-value.empty-val { color: #d1d5db; }

/* ================= 弹窗 ================= */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fade 0.15s;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #fff;
  border-radius: 12px;
  width: 560px;
  max-width: 92vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal.wide { width: 860px; }
.modal.xwide { width: 1100px; }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header h3 { margin: 0; font-size: 16px; font-weight: 600; }

.modal-close {
  font-size: 24px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 0 4px;
}

.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ================= 图片查看器 ================= */
.viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.viewer-img {
  max-width: 88vw;
  max-height: 84vh;
  object-fit: contain;
  border-radius: 6px;
}

.viewer-close {
  position: absolute;
  top: 20px; right: 24px;
  font-size: 34px;
  color: #fff;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.14);
  width: 42px; height: 42px;
  border-radius: 50%;
  border: none;
  line-height: 1;
}

.viewer-close:hover { background: rgba(255, 255, 255, 0.25); }

.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 44px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  width: 48px; height: 68px;
  cursor: pointer;
  border-radius: 6px;
}

.viewer-nav:hover { background: rgba(255, 255, 255, 0.24); }
.viewer-prev { left: 24px; }
.viewer-next { right: 24px; }

.viewer-toolbar {
  position: absolute;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  color: #fff;
  font-size: 13px;
}

.viewer-btn {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  padding: 7px 18px;
  border-radius: 6px;
  font-size: 13px;
  transition: all 0.15s;
}

.viewer-btn:hover { background: rgba(255, 255, 255, 0.28); }

/* ================= Toast ================= */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(31, 41, 55, 0.95);
  color: #fff;
  padding: 11px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 3000;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s;
  max-width: 80vw;
}

.toast.error { background: rgba(220, 38, 38, 0.95); }
.toast.success { background: rgba(43, 122, 61, 0.95); }

/* ================= 图表（纯 CSS） ================= */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 160px;
  padding-top: 12px;
}

.bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  position: relative;
}

.bar {
  width: 100%;
  max-width: 42px;
  background: linear-gradient(180deg, var(--green-light), var(--green));
  border-radius: 5px 5px 0 0;
  transition: opacity 0.15s;
  min-height: 3px;
}

.bar-item:hover .bar { opacity: 0.8; }

.bar-value {
  font-size: 11px;
  color: var(--text-mid);
  margin-bottom: 5px;
  font-weight: 600;
}

.bar-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 7px;
  white-space: nowrap;
  transform: rotate(-35deg);
  transform-origin: center;
}

.hbar-row {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.hbar-label {
  width: 90px;
  font-size: 13px;
  color: var(--text-mid);
  flex-shrink: 0;
}

.hbar-track {
  flex: 1;
  height: 22px;
  background: var(--border-light);
  border-radius: 11px;
  overflow: hidden;
}

.hbar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green-light), var(--green));
  border-radius: 11px;
  transition: width 0.4s;
  display: flex;
  align-items: center;
  padding-left: 9px;
  color: #fff;
  font-size: 11px;
  min-width: 26px;
}

/* ================= 配置页 ================= */
.config-section { margin-bottom: 24px; }

.config-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.config-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.6;
}

.switch { display: flex; align-items: center; gap: 8px; }

.switch input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--green); }

/* ================= 字段配置 ================= */
.field-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  margin-bottom: 8px;
  gap: 10px;
  background: #fff;
}

.field-item:hover { border-color: #cbd5e0; }

.fi-drag { color: var(--text-muted); cursor: grab; font-size: 15px; }
.fi-key { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--text-muted); width: 130px; }
.fi-label { font-weight: 500; width: 150px; }
.fi-type { width: 90px; }
.fi-flex { flex: 1; }

/* ================= 响应式 ================= */
@media (max-width: 900px) {
  .sidebar { width: 62px; }
  .sb-name, .ni-icon + span:not(.ni-badge), .ai-body, .ai-actions { display: none; }
  .main { margin-left: 62px; }
  .sidebar-brand { justify-content: center; padding: 0; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .ni-icon { margin: 0; }
  .ni-badge { position: absolute; margin: 0; }
  .nav-item { position: relative; }
}
