/* ============================================================
   外贸询盘中心 · 设计系统（浅色主题 / 响应式）
   ============================================================ */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0891b2;
  --info-light: #cffafe;
  --purple: #7c3aed;
  --purple-light: #ede9fe;

  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 14px rgba(15, 23, 42, .05);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .14);
  --sidebar-w: 232px;
  --topbar-h: 60px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 通用组件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 8px 16px; font-size: 14px; font-weight: 500;
  transition: all .18s ease; white-space: nowrap; line-height: 1.4;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text-2); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger-outline { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger-outline:hover { background: var(--danger-light); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.icon-btn {
  border: none; background: transparent; font-size: 18px; color: var(--text-2);
  width: 36px; height: 36px; border-radius: 8px; display: inline-flex;
  align-items: center; justify-content: center; transition: all .15s;
}
.icon-btn:hover { background: var(--primary-light); color: var(--primary); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
}
.badge-new { background: var(--danger-light); color: var(--danger); }
.badge-processing { background: var(--warning-light); color: var(--warning); }
.badge-handled { background: var(--success-light); color: var(--success); }
.badge-ignored { background: #f1f5f9; color: var(--text-3); }
.badge-active { background: var(--success-light); color: var(--success); }
.badge-paused, .badge-disabled { background: #f1f5f9; color: var(--text-3); }
.badge-admin { background: var(--purple-light); color: var(--purple); }
.badge-operator { background: var(--info-light); color: var(--info); }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ---------- 登录页 ---------- */
.login-view {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%);
  padding: 24px; position: relative; overflow: hidden;
}
.login-view::before {
  content: ''; position: absolute; inset: 0; opacity: .12;
  background-image: radial-gradient(circle at 1px 1px, #fff 1px, transparent 0);
  background-size: 26px 26px;
}
.login-card {
  position: relative; width: 100%; max-width: 400px; background: #fff;
  border-radius: 18px; box-shadow: var(--shadow-lg); padding: 38px 36px 28px;
}
.login-brand { text-align: center; margin-bottom: 26px; }
.login-logo {
  width: 170px; height: 60px; margin: 0 auto; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.login-logo img { display: block; width: 100%; height: auto; }
.login-brand h1 { font-size: 22px; margin-top: 10px; font-weight: 700; }
.login-brand p { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.input-wrap { position: relative; }
.input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 15px; opacity: .7; }
.input-wrap input, .input-wrap select, .input-wrap textarea {
  width: 100%; padding: 10px 12px 10px 36px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
  background: #f8fafc; transition: all .15s; color: var(--text);
}
.input-wrap input:focus, .input-wrap select:focus, .input-wrap textarea:focus {
  outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.login-error {
  background: var(--danger-light); color: var(--danger); font-size: 13px;
  padding: 8px 12px; border-radius: 8px; margin-bottom: 14px;
}
.login-hint { text-align: center; color: var(--text-3); font-size: 12px; margin-top: 16px; }
.login-footer { position: relative; color: rgba(255,255,255,.75); font-size: 12.5px; margin-top: 22px; }

/* ---------- 主布局 ---------- */
.app-view { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 50;
  transition: transform .25s ease;
}
.sidebar-brand {
  height: var(--topbar-h); display: flex; align-items: center; gap: 10px;
  padding: 0 18px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-logo { font-size: 22px; }
.brand-name { font-weight: 700; color: #fff; font-size: 15px; }
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border-radius: 9px; color: #cbd5e1; margin-bottom: 3px; transition: all .15s; font-size: 14px;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 500; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 11px;
  min-width: 18px; height: 18px; border-radius: 999px; display: none;
  align-items: center; justify-content: center; padding: 0 5px; font-weight: 600;
}
.sidebar-user {
  padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 15px; flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { color: #fff; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: #94a3b8; font-size: 12px; }
.logout-btn { color: #94a3b8; }
.logout-btn:hover { background: rgba(220,38,38,.18); color: #fca5a5; }
.sidebar-mask {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5);
  z-index: 45; opacity: 0; transition: opacity .25s;
}

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 22px;
  position: sticky; top: 0; z-index: 40;
}
.page-title { font-size: 17px; font-weight: 600; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.hamburger { display: none; }
.content { padding: 22px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* ---------- 统计卡片 ---------- */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px;
}
.stat-card { padding: 18px 20px; display: flex; align-items: center; gap: 14px; }
.stat-icon {
  width: 46px; height: 46px; border-radius: 12px; display: flex;
  align-items: center; justify-content: center; font-size: 21px; flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary-light); }
.stat-icon.green { background: var(--success-light); }
.stat-icon.orange { background: var(--warning-light); }
.stat-icon.red { background: var(--danger-light); }
.stat-icon.purple { background: var(--purple-light); }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-label { color: var(--text-3); font-size: 12.5px; }

/* ---------- 看板 ---------- */
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.dash-grid-2 { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; }
.chart-box { position: relative; height: 260px; }
.rank-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border);
}
.rank-item:last-child { border-bottom: none; }
.rank-no {
  width: 22px; height: 22px; border-radius: 6px; background: #f1f5f9; color: var(--text-2);
  font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.rank-no.top { background: var(--warning); color: #fff; }
.rank-info { flex: 1; min-width: 0; }
.rank-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-domain { font-size: 11.5px; color: var(--text-3); }
.rank-count { font-weight: 700; color: var(--primary); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.data-table th {
  text-align: left; padding: 11px 14px; font-size: 12.5px; color: var(--text-2);
  background: #f8fafc; border-bottom: 1px solid var(--border); font-weight: 600; white-space: nowrap;
}
.data-table td { padding: 11px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table .cell-main { font-weight: 600; }
.data-table .cell-sub { color: var(--text-3); font-size: 12px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.action-btn {
  border: 1px solid var(--border); background: #fff; color: var(--text-2);
  border-radius: 6px; padding: 4px 8px; font-size: 12px; transition: all .15s; white-space: nowrap;
}
.action-btn:hover { border-color: var(--primary); color: var(--primary); }
.action-btn.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-light); }
.action-btn.success:hover { border-color: var(--success); color: var(--success); background: var(--success-light); }
.empty-tip { text-align: center; padding: 46px 0; color: var(--text-3); font-size: 13px; }
.empty-tip .empty-icon { font-size: 40px; display: block; margin-bottom: 10px; opacity: .5; }

/* ---------- 筛选条 ---------- */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 14px 16px; margin-bottom: 16px;
}
.filter-bar input, .filter-bar select {
  padding: 7px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; background: #fff; color: var(--text); min-height: 34px;
}
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--primary); }
.filter-input { width: 200px; }
.filter-bar .grow { flex: 1; }
.table-toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.table-toolbar .toolbar-left { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.total-tip { color: var(--text-3); font-size: 12.5px; }

/* ---------- 分页 ---------- */
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 14px 16px; flex-wrap: wrap; }
.page-btn {
  min-width: 32px; height: 32px; border-radius: 7px; border: 1px solid var(--border);
  background: #fff; color: var(--text-2); font-size: 13px; display: inline-flex; align-items: center; justify-content: center; padding: 0 9px;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.page-btn[disabled] { opacity: .45; cursor: not-allowed; }
.page-info { color: var(--text-3); font-size: 12.5px; margin-right: 6px; }

/* ---------- 弹窗 / 抽屉 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(2px); animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 620px; max-height: 90vh; overflow-y: auto;
  animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal.wide { max-width: 860px; }
.modal-head {
  padding: 16px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px 22px; }
.modal-foot {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: #fff;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.field-item {
  display: flex; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 10px; background: #f8fafc; position: relative;
}
.field-item .field-drag { cursor: grab; color: var(--text-3); font-size: 16px; }
.field-item .field-info { flex: 1; min-width: 0; }
.field-item .field-title { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field-item .field-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.required-tag { background: var(--danger-light); color: var(--danger); font-size: 10.5px; padding: 1px 6px; border-radius: 4px; font-weight: 600; }
.field-type-tag { background: var(--primary-light); color: var(--primary); font-size: 10.5px; padding: 1px 6px; border-radius: 4px; }

/* ---------- 表单编辑 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 16px; align-items: start; }
.form-side { position: sticky; top: calc(var(--topbar-h) + 20px); }
.small-label { font-size: 12px; color: var(--text-3); font-weight: 500; }
.kv-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.kv-row:last-child { border-bottom: none; }
.kv-row .kv-label { color: var(--text-3); }
.kv-row .kv-value { font-weight: 500; word-break: break-all; text-align: right; }

/* ---------- 详情抽屉 ---------- */
.drawer-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 90; animation: fadeIn .18s; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 480px; max-width: 92vw;
  background: #fff; z-index: 95; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: slideLeft .24s ease;
}
@keyframes slideLeft { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.drawer-head h3 { font-size: 16px; flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; flex-wrap: wrap; }
.drawer-foot .grow { flex: 1; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #0f172a; color: #fff; padding: 10px 20px; border-radius: 10px;
  font-size: 13.5px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px;
  animation: toastIn .25s ease; max-width: 90vw;
}
.toast.success { background: #15803d; }
.toast.error { background: #b91c1c; }
.toast.info { background: #0f172a; }
@keyframes toastIn { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
  .dash-grid, .dash-grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-side { position: static; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mask.show { display: block; opacity: 1; }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .content { padding: 14px; }
  .topbar { padding: 0 14px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .filter-input { width: 100%; }
  .filter-bar input, .filter-bar select { flex: 1 1 100%; }
}
@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 14px; }
}
