/* ============== 全局变量 ============== */
:root {
  --primary: #4f6ef7;
  --primary-light: #e8edff;
  --primary-dark: #3b56d4;
  --success: #22c55e;
  --success-light: #dcfce7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --text-primary: #1f2937;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --bg-primary: #f5f7fb;
  --bg-card: #ffffff;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow: 0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px -1px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --sidebar-width: 240px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

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

/* ============== 侧边栏 ============== */
.sidebar {
  width: var(--sidebar-width);
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.logo {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-light);
}

.logo-icon {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(140deg, #1e293b 0%, #334155 55%, #4f6ef7 140%);
  color: #fff;
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(30, 41, 59, 0.22);
  flex-shrink: 0;
}

.logo-text h2 {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1.6px;
  color: var(--text-primary);
  line-height: 1.2;
}

.logo-text span {
  font-size: 11px;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}

.nav {
  flex: 1;
  padding: 10px 12px 16px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav-item:hover {
  background: #f4f6fb;
  color: var(--text-primary);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(79, 110, 247, 0.1), rgba(79, 110, 247, 0.03));
  color: var(--primary);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon svg,
.btn-icon svg,
.stat-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: inherit;
}

.nav-item.active .nav-icon svg {
  stroke: var(--primary);
}

.nav-item:hover .nav-icon svg {
  stroke: var(--text-primary);
}

.sidebar-footer {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* ============== 用户栏（侧边栏底部，紧凑单行） ============== */
.user-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0 0 10px;
  background: none;
  border: none;
  border-bottom: 1px dashed var(--border-light);
  border-radius: 0;
  margin-bottom: 4px;
}

.user-avatar {
  width: 26px;
  height: 26px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(140deg, #1e293b 0%, #4f6ef7 100%);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  line-height: 1.2;
}

.user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role {
  flex: none;
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-primary, #f6f8fc);
  border: 1px solid var(--border-light);
  padding: 1px 5px;
  border-radius: 4px;
}

.user-bar .btn-icon {
  flex: none;
  width: 28px;
  height: 28px;
  padding: 5px;
}

/* ============== 表单/筛选/分页 ============== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

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

.form-item input,
.form-item select,
.filter-bar input,
.filter-bar select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

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

.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-items: center;
}

.filter-bar input {
  flex: 1;
  max-width: 240px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  padding: 0 4px;
  font-size: 13px;
}

.page-info {
  color: var(--text-muted);
  margin-right: auto;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
}

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

.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-muted { background: var(--border-light); color: var(--text-secondary); }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }

.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.text-warning { color: var(--warning); }

/* ============== 登录页 ============== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 15% 10%, #e8edff 0%, transparent 60%),
              radial-gradient(900px 500px at 85% 85%, #e7f7ef 0%, transparent 55%),
              #f5f7fb;
}

.login-card {
  width: 380px;
  padding: 36px 32px 30px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.login-brand {
  text-align: center;
  margin-bottom: 26px;
}

.login-brand .logo-icon {
  margin: 0 auto 12px;
}

.login-brand h2 {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 22px;
  letter-spacing: 3px;
  color: var(--text-primary);
}

.login-brand p {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-top: 2px;
}

.login-form .form-item {
  margin-bottom: 14px;
}

.login-form input {
  width: 100%;
}

.login-btn {
  width: 100%;
  padding: 11px;
  font-size: 14px;
  letter-spacing: 2px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.register-btn {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 6px;
  font-size: 13px;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
}

.register-btn:hover { text-decoration: underline; }

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

.login-error {
  min-height: 16px;
  font-size: 12.5px;
  color: var(--danger);
  margin-top: 8px;
  text-align: center;
}

/* ============== 待审批面板 ============== */
.pending-panel {
  margin-bottom: 18px;
  padding: 16px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
}

.pending-title {
  font-size: 13px;
  font-weight: 600;
  color: #92400e;
  margin-bottom: 10px;
}

@media (max-width: 560px) {
  .login-card { width: 100%; margin: 0 16px; padding: 28px 22px; }
  .form-grid { grid-template-columns: 1fr; }
}

.btn-icon {
  flex: 1;
  padding: 9px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.16s;
}

.btn-icon:hover {
  background: #f4f6fb;
  border-color: var(--primary);
  color: var(--primary);
}

/* ============== 主内容区 ============== */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

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

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.date-display, .base-currency-display {
  padding: 6px 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
}

.module-container {
  flex: 1;
  padding: 24px 32px;
}

.module {
  animation: fadeIn 0.25s ease;
}

.module.hidden {
  display: none;
}

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

/* ============== 模块头部 ============== */
.module-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

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

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

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

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 20px;
}

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

/* ============== 统计卡片 ============== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.stat-total-income::before { background: var(--success); }
.stat-total-expense::before { background: var(--danger); }
.stat-profit::before { background: var(--primary); }
.stat-orders::before { background: var(--warning); }

.stat-card {
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.stat-card:hover {
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.stat-icon {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.7;
}

.stat-total-income .stat-icon { background: #eafaf1; color: #16a34a; }
.stat-total-expense .stat-icon { background: #fdecec; color: #dc2626; }
.stat-profit .stat-icon { background: #eef1fe; color: var(--primary); }
.stat-orders .stat-icon { background: #fff4e5; color: #d97706; }

.stat-value {
  font-variant-numeric: tabular-nums;
}

.stat-info {
  flex: 1;
}

.stat-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-change {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 6px;
}

.stat-change.positive {
  background: var(--success-light);
  color: #16a34a;
}

.stat-change.negative {
  background: var(--danger-light);
  color: #dc2626;
}

/* ============== 图表网格 ============== */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 0;
}

/* ============== 表格 ============== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}

.table tbody tr:hover {
  background: var(--bg-primary);
}

.table tfoot td {
  padding: 14px 16px;
  background: var(--bg-primary);
  font-weight: 600;
  border-top: 2px solid var(--border);
}

.text-right {
  text-align: right;
}

.text-green { color: var(--success); }
.text-red { color: var(--danger); }
.text-blue { color: var(--primary); }

/* ============== 按钮 ============== */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-outline {
  background: #fff;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-outline:hover {
  background: var(--bg-primary);
  color: var(--primary);
  border-color: var(--primary);
}

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

.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 8px;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-link.danger {
  color: var(--danger);
}

/* ============== 表单控件 ============== */
.input, .select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: #fff;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
  min-width: 120px;
}

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

.input::placeholder {
  color: var(--text-muted);
}

.select-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-input {
  width: 100%;
}

textarea.input {
  min-height: 80px;
  resize: vertical;
}

/* ============== 状态标签 ============== */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.status-pending { background: var(--warning-light); color: #d97706; }
.status-shipped { background: #dbeafe; color: #2563eb; }
.status-delivered { background: var(--success-light); color: #16a34a; }
.status-cancelled { background: var(--danger-light); color: #dc2626; }
.status-refunded { background: #e5e7eb; color: #6b7280; }

/* ============== 分页 ============== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}

.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
}

.pagination button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.pagination button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

/* ============== 弹窗 ============== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2600; /* 必须高于登录页(2000)，否则登录页点“申请开通”看不到弹窗 */
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}

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

/* ============== 备份与恢复弹窗 ============== */
.backup-hero {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  margin-bottom: 18px;
  background: linear-gradient(135deg, #f5f7fb 0%, #eef2ff 100%);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
}

.backup-stat {
  flex: 1;
  text-align: center;
  padding: 2px 4px;
}

.backup-num {
  display: block;
  font-size: 21px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.2px;
  line-height: 1.25;
}

.backup-label {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.backup-size {
  flex-shrink: 0;
  margin-left: 6px;
  padding: 5px 10px;
  font-size: 11.5px;
  color: var(--primary-dark);
  background: #fff;
  border: 1px solid #dbe3ff;
  border-radius: 20px;
  white-space: nowrap;
}

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

.backup-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 16px 16px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.backup-card:hover {
  border-color: #cdd7f7;
  box-shadow: var(--shadow-sm);
}

.backup-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--primary-light);
  color: var(--primary);
  margin-bottom: 10px;
}

.backup-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.backup-card h4 {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.backup-card p {
  flex: 1;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.backup-card .btn {
  padding: 6px 14px;
  font-size: 12.5px;
}

.backup-card-warn .backup-icon {
  background: var(--warning-light);
  color: #b45309;
}

.backup-tip {
  margin-top: 14px;
  padding: 9px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  background: #fafbfd;
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

@media (max-width: 560px) {
  .backup-hero {
    flex-wrap: wrap;
  }

  .backup-stat {
    flex: 1 0 40%;
  }

  .backup-size {
    margin-left: 0;
  }

  .backup-grid {
    grid-template-columns: 1fr;
  }
}

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

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

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

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

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

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

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

/* ============== Toast ============== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
  min-width: 280px;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info { border-left: 4px solid var(--primary); }

/* ============== 报表 ============== */
.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.report-section h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.report-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}

.report-row.total {
  border-top: 2px solid var(--border);
  margin-top: 8px;
  padding-top: 12px;
  font-weight: 600;
}

.report-row.total .amount {
  font-size: 15px;
}

.amount {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.report-profit {
  display: flex;
  gap: 24px;
  margin-top: 24px;
  padding: 20px;
  background: var(--bg-primary);
  border-radius: var(--radius);
}

.profit-item {
  flex: 1;
  text-align: center;
}

.profit-item span:first-child {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.profit-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

/* ============== 设置 ============== */
.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
  gap: 16px;
  flex-wrap: wrap;
}

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

.setting-item.danger .setting-desc h4 {
  color: var(--danger);
}

.setting-desc h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.setting-desc p {
  font-size: 12px;
  color: var(--text-muted);
}

.setting-action {
  display: flex;
  gap: 10px;
  align-items: center;
}

.platform-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.platform-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  font-size: 13px;
}

.platform-tag button {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}

.platform-tag button:hover {
  color: var(--danger);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.info-grid div {
  padding: 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.info-grid .label {
  color: var(--text-muted);
  margin-right: 6px;
}

.base-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ============== 导航分组 ============== */
.nav-group {
  margin-bottom: 4px;
}
.nav-group-title {
  display: block;
  padding: 14px 16px 6px;
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============== 进度条 ============== */
.progress-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  min-width: 80px;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}
.progress-bar-fill.normal { background: #22c55e; }
.progress-bar-fill.warning { background: #f59e0b; }
.progress-bar-fill.danger { background: #ef4444; }

/* ============== 模块操作按钮组 ============== */
.module-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

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

.import-actions .btn {
  font-size: 13px;
  padding: 7px 12px;
}

/* 导入预览表 */
.import-preview {
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  margin-top: 12px;
}

.import-preview table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.import-preview th,
.import-preview td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-light);
  text-align: left;
  white-space: nowrap;
}

.import-preview th {
  background: #f7f8fc;
  font-weight: 600;
  color: var(--text-secondary);
  position: sticky;
  top: 0;
}

.import-hint {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
  background: #f7f8fc;
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
  padding: 12px 16px;
}

.import-hint code {
  background: #eef1fe;
  color: var(--primary);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}

/* ============== 高级质感微调 ============== */
.header {
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.card {
  border: 1px solid rgba(15, 23, 42, 0.045);
}

.table th {
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0.2px;
}

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

.table td {
  font-variant-numeric: tabular-nums;
}

/* ============== 审批中心 · 飞书集成 ============== */
.feishu-status {
  display: flex;
  align-items: center;
  gap: 14px;
}

.feishu-status .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.feishu-status.connected .status-dot {
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, .12);
}

.feishu-status.disconnected .status-dot {
  background: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, .12);
}

.status-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.status-title .status-sub {
  font-size: 12px;
  font-weight: 400;
  color: #9ca3af;
}

.status-desc {
  margin-top: 4px;
  font-size: 12.5px;
  color: #6b7280;
}

.status-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.approval-summary {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin: 16px 0;
}

.sum-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}

.sum-num {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.sum-label {
  margin-top: 2px;
  font-size: 12px;
  color: #6b7280;
}

.sum-card.warning .sum-num { color: #d97706; }
.sum-card.success .sum-num { color: #16a34a; }
.sum-card.primary .sum-num { color: var(--primary); }

@media (max-width: 1200px) {
  .approval-summary { grid-template-columns: repeat(3, 1fr); }
}

/* ============== 云端更新提示条 ============== */
.cloud-banner {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 640px);
  padding: 10px 12px 10px 14px;
  background: #1f2937;
  color: #f9fafb;
  border-radius: 10px;
  box-shadow: 0 10px 24px -6px rgba(15, 23, 42, 0.45);
  font-size: 13px;
  line-height: 1.4;
}

.cloud-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
  flex-shrink: 0;
  animation: cloudPulse 1.6s ease-in-out infinite;
}

@keyframes cloudPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.cloud-text {
  flex: 1;
  color: #e5e7eb;
}

.cloud-go {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 12.5px;
}

.cloud-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: #9ca3af;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.cloud-close:hover {
  color: #fff;
}

@media (max-width: 640px) {
  .cloud-banner {
    left: 12px;
    right: 12px;
    bottom: 12px;
    transform: none;
    max-width: none;
    flex-wrap: wrap;
  }
}

/* ============== 响应式 ============== */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .report-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { width: 60px; overflow: hidden; }
  .sidebar .logo-text, .sidebar .nav-item span:not(.nav-icon) { display: none; }
  .main { margin-left: 60px; }
  .module-container { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .report-profit { flex-direction: column; gap: 16px; }
}

/* ================================================================
   视觉升级 v4.0 —— 企业级看板质感（仅样式，不改结构与功能）
   ================================================================ */
:root {
  --primary: #4f6ef7;
  --primary-light: #edf1ff;
  --primary-dark: #3a51d0;
  --text-primary: #0f172a;
  --text-secondary: #52627a;
  --text-muted: #8b98ab;
  --bg-primary: #f4f7fc;
  --bg-card: #ffffff;
  --border: #e4eaf4;
  --border-light: #eef2f9;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 6px 18px -8px rgba(16, 24, 40, 0.10);
  --shadow-md: 0 2px 4px rgba(16, 24, 40, 0.04), 0 12px 28px -14px rgba(16, 24, 40, 0.16);
  --shadow-lg: 0 20px 48px -18px rgba(16, 24, 40, 0.22);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
}

body {
  background:
    radial-gradient(1100px 480px at 100% -10%, #e9efff 0%, rgba(233, 239, 255, 0) 60%),
    linear-gradient(180deg, #f7f9fd 0%, #f2f5fb 100%);
  background-attachment: fixed;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
  border-right: 1px solid var(--border);
  box-shadow: 1px 0 0 rgba(15, 23, 42, 0.02);
}

.logo {
  padding: 20px 18px;
  border-bottom: 1px solid var(--border-light);
}

.logo-text h2 {
  font-size: 17px;
  letter-spacing: 1.8px;
  color: #101b32;
}

.nav {
  padding: 8px 10px 14px;
}

.nav-group-title {
  padding: 14px 12px 6px;
  font-size: 10.5px;
  color: #a2aec2;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.nav-item {
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  color: #5b6b81;
  gap: 10px;
}

.nav-item:hover {
  background: #f4f7fe;
  color: #1c2a3f;
}

.nav-item.active {
  background: #eef2ff;
  color: #3a51d0;
  font-weight: 600;
}

.nav-item.active::before {
  width: 3px;
  top: 9px;
  bottom: 9px;
  border-radius: 0 3px 3px 0;
  background: #4f6ef7;
}

.nav-item.active .nav-icon svg { stroke: #3a51d0; }

.sidebar-footer { border-top: 1px solid var(--border-light); }

/* ---------- 顶部栏 ---------- */
.header {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 14px 30px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header-left h1 {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: 0.2px;
  color: #0f172a;
  line-height: 1.25;
}

.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.2px;
}

.header-right { gap: 10px; font-size: 12.5px; }

.date-display,
.base-currency-display {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 12px;
  color: #5b6b81;
  font-size: 12.5px;
}

.base-currency-display strong { color: #0f172a; }

.module-container { padding: 26px 30px 40px; }

/* ---------- 统计卡片 ---------- */
.stats-grid { gap: 18px; margin-bottom: 22px; }

.stat-card {
  padding: 20px 22px;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.stat-card::before { display: none; }

.stat-card:hover {
  transform: translateY(-2px);
  border-color: #dbe4f5;
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 14px;
}

.stat-icon svg { width: 24px; height: 24px; }

.stat-label {
  font-size: 12px;
  color: #7b8794;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.6px;
  color: #0f172a;
}

.stat-change {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 8px;
  margin-top: 8px;
}

/* ---------- 卡片 / 图表区 ---------- */
.charts-grid { gap: 22px; }

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}

.card-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-light);
}

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: #101b32;
}

.card-body { padding: 18px 22px 22px; }

/* ---------- 表格 ---------- */
.table { font-size: 13px; }

.table th {
  padding: 11px 16px;
  background: #f8fafd;
  border-bottom: 1px solid var(--border-light);
  color: #6b7a90;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-transform: none;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f4f7fc;
  color: #33415a;
}

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

/* ---------- 表单控件 ---------- */
.form-item label { color: #66758c; font-weight: 500; }

.form-item input,
.form-item select,
.filter-bar input,
.filter-bar select {
  height: 36px;
  padding: 0 11px;
  border: 1px solid #dee5f1;
  border-radius: 9px;
  font-size: 13px;
  color: var(--text-primary);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-item input:focus,
.form-item select:focus,
.filter-bar input:focus,
.filter-bar select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.12);
  outline: none;
}

.filter-bar {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

/* ---------- 按钮 ---------- */
.btn {
  border-radius: 9px;
  padding: 8px 15px;
  font-weight: 500;
}

.btn-primary {
  background: linear-gradient(135deg, #5569f2 0%, #4156e6 100%);
  border-color: transparent;
  box-shadow: 0 8px 18px -10px rgba(65, 86, 230, 0.75);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4a5fe8 0%, #364bd2 100%);
  border-color: transparent;
}

.btn-outline {
  background: #fff;
  border-color: #dee5f1;
  color: #5b6b81;
}

.btn-outline:hover {
  background: #f7f9ff;
  border-color: #b9c8ee;
  color: #3a51d0;
}

.page-btn {
  border-radius: 8px;
  border-color: #dee5f1;
  color: #5b6b81;
  transition: all 0.15s ease;
}

.page-btn:hover { border-color: #b9c8ee; color: #3a51d0; }

.page-btn.active {
  background: #4f6ef7;
  border-color: #4f6ef7;
  box-shadow: 0 6px 14px -8px rgba(79, 110, 247, 0.8);
}

/* ---------- 滚动条 ---------- */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #d7dfec; border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: #c2cde0; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- 登录页（浅色干净底 + 白色卡片） ---------- */
.login-screen {
  background: linear-gradient(180deg, #f8fafd 0%, #eff4fb 100%);
  overflow: hidden;
  isolation: isolate;
}

.login-screen::before {
  content: '';
  position: absolute;
  inset: -25%;
  z-index: 0;
  background:
    radial-gradient(560px 440px at 18% 20%, rgba(79, 110, 247, 0.14), transparent 62%),
    radial-gradient(520px 420px at 84% 76%, rgba(56, 189, 248, 0.12), transparent 62%),
    radial-gradient(420px 340px at 70% 10%, rgba(16, 185, 129, 0.08), transparent 60%);
  filter: blur(20px);
}

.login-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.032) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 45%, #000 30%, transparent 80%);
  mask-image: radial-gradient(ellipse at 50% 45%, #000 30%, transparent 80%);
}

.login-card {
  position: relative;
  z-index: 1;
  width: 400px;
  padding: 40px 36px 34px;
  background: #ffffff;
  border: 1px solid #e6ecf7;
  border-radius: 20px;
  box-shadow:
    0 1px 2px rgba(16, 24, 40, 0.04),
    0 28px 60px -30px rgba(15, 23, 42, 0.28);
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 24px;
  right: 24px;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, #4f6ef7, #8b5cf6 55%, #22c55e);
}

.login-brand { margin-bottom: 28px; }

.login-brand .logo-icon {
  width: 48px;
  height: 48px;
  font-size: 24px;
  border-radius: 13px;
  margin-bottom: 14px;
}

.login-brand h2 {
  font-size: 24px;
  letter-spacing: 5px;
  color: #0f172a;
}

.login-brand p {
  font-size: 11.5px;
  letter-spacing: 3px;
  color: #8b98ab;
  margin-top: 4px;
}

.login-form input {
  height: 44px;
  padding: 0 13px;
  border-radius: 10px;
  font-size: 13.5px;
}

.login-btn {
  height: 46px;
  border-radius: 10px;
  letter-spacing: 3px;
  font-size: 14px;
  box-shadow: 0 14px 26px -14px rgba(65, 86, 230, 0.9);
}

.login-btn:hover { transform: translateY(-1px); }

.register-btn { padding: 8px; font-weight: 500; }

.login-tip { color: #98a4b7; }

/* ---------- 视觉升级后的响应式兜底 ---------- */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .report-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { width: 60px; overflow: hidden; }
  .sidebar .logo-text, .sidebar .nav-item span:not(.nav-icon) { display: none; }
  .main { margin-left: 60px; }
  .module-container { padding: 16px; }
  .header { padding: 14px 18px; }
  .stats-grid { grid-template-columns: 1fr; }
  .form-row, .info-grid { grid-template-columns: 1fr; }
  .report-profit { flex-direction: column; gap: 16px; }
  .user-bar { justify-content: center; gap: 4px; border-bottom: none; padding-bottom: 6px; }
  .user-bar .user-info { display: none; }
}

@media (max-width: 560px) {
  .login-card { width: 100%; margin: 0 16px; padding: 30px 22px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ---------- 结算单详情 ---------- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 24px;
}

.detail-grid > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed #eef2f9;
  font-size: 13px;
}

.detail-grid span { color: #6b7a90; }
.detail-grid strong { color: #0f172a; font-weight: 600; }

@media (max-width: 560px) {
  .detail-grid { grid-template-columns: 1fr; }
}
