/* ============================================
   TG记账管家 - 后台管理样式
   移动端优先 / 响应式
   兼容 PHP 5.6-7.0 渲染的纯HTML
   ============================================ */

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

:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-light: #14b8a6;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  padding-bottom: 70px; /* 底部导航栏高度 */
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ========== 顶部栏 ========== */
.top-bar {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: white;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
}
.top-bar .back-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  cursor: pointer;
}
.top-bar .title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
}
.top-bar .right-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  cursor: pointer;
}

/* ========== 底部导航栏 ========== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px;
  text-decoration: none;
}
.bottom-nav a.active {
  color: var(--primary);
}
.bottom-nav .nav-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
}

/* ========== 卡片 ========== */
.card {
  background: var(--card);
  border-radius: 10px;
  margin: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-header h3 {
  font-size: 14px;
  font-weight: 600;
}
.card-body {
  padding: 16px;
}

/* ========== 统计卡片网格 ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 12px;
}
.stat-card {
  background: white;
  border-radius: 10px;
  padding: 14px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
}
.stat-card.income::before { background: var(--success); }
.stat-card.expense::before { background: var(--danger); }
.stat-card.balance::before { background: var(--primary); }
.stat-card.count::before { background: var(--warning); }
.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.stat-card .stat-value {
  font-size: 18px;
  font-weight: 700;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}
.stat-card .stat-badge {
  position: absolute;
  right: 12px;
  top: 14px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}
.stat-card.income .stat-badge { background: #d1fae5; color: var(--success); }
.stat-card.expense .stat-badge { background: #fee2e2; color: var(--danger); }
.stat-card.balance .stat-badge { background: #ccfbf1; color: var(--primary); }
.stat-card.count .stat-badge { background: #fef3c7; color: var(--warning); }

/* ========== 列表 ========== */
.list-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  margin-right: 12px;
  flex-shrink: 0;
}
.list-item .info {
  flex: 1;
  min-width: 0;
}
.list-item .info .name {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}
.list-item .info .desc {
  font-size: 12px;
  color: var(--text-secondary);
}
.list-item .amount {
  text-align: right;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-weight: 600;
  font-size: 14px;
}
.list-item .amount.income { color: var(--success); }
.list-item .amount.expense { color: var(--danger); }
.list-item .amount.payout { color: var(--warning); }

/* ========== 徽章 ========== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #e2e8f0; color: #475569; }

.role-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}
.role-admin { background: #fef3c7; color: #92400e; }
.role-operator { background: #dbeafe; color: #1e40af; }
.role-viewer { background: #e2e8f0; color: #475569; }
.role-member { background: #f1f5f9; color: #64748b; }

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.2s;
}
.btn:active { opacity: 0.8; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ========== 表单 ========== */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  -webkit-appearance: none;
  appearance: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.1);
}
.form-group .form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ========== 登录页 ========== */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-box {
  background: white;
  border-radius: 16px;
  padding: 30px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-box .logo {
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 16px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  font-weight: 700;
}
.login-box h2 {
  text-align: center;
  font-size: 18px;
  margin-bottom: 4px;
}
.login-box .sub-title {
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 24px;
}
.login-box .btn { margin-top: 8px; }

/* ========== 汇率横幅 ========== */
.rate-banner {
  margin: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #f0fdfa 0%, #ccfbf1 100%);
  border-radius: 10px;
  display: flex;
  gap: 20px;
  overflow-x: auto;
}
.rate-banner .rate-item .label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}
.rate-banner .rate-item .value {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-dark);
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ========== 搜索/筛选栏 ========== */
.filter-bar {
  background: white;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-bar select, .filter-bar input {
  flex: 1;
  min-width: 80px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: white;
}
.filter-bar .btn { padding: 7px 12px; font-size: 13px; }

/* ========== 分页 ========== */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-size: 12px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
}
.pagination-controls { display: flex; gap: 4px; }
.page-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 4px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  text-decoration: none;
}
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-dots { padding: 0 4px; color: var(--text-muted); }

/* ========== 账单明细行 ========== */
.bill-detail-row {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  padding: 4px 0;
  display: flex;
  gap: 8px;
  line-height: 1.5;
}
.bill-detail-row .time {
  color: var(--text-muted);
  flex-shrink: 0;
}
.bill-detail-row .content {
  flex: 1;
  word-break: break-all;
}

/* ========== 汇总行 ========== */
.summary-section {
  border-top: 1px dashed var(--border);
  margin-top: 10px;
  padding-top: 10px;
  font-size: 13px;
  line-height: 1.8;
}
.summary-section .row {
  display: flex;
  justify-content: space-between;
}
.summary-section .row .k { color: var(--text-secondary); }
.summary-section .row .v {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-weight: 500;
}
.summary-section .row.total .v {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}

/* ========== 切换开关 ========== */
.switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.switch-row:last-child { border-bottom: none; }
.switch-row .label { font-size: 14px; font-weight: 500; }
.switch-row .desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: #cbd5e1;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-switch.active { background: var(--primary); }
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: left 0.2s;
}
.toggle-switch.active::after { left: 22px; }

/* ========== 操作链接 ========== */
.action-links { display: flex; gap: 12px; }
.action-links a {
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
}
.action-links a.danger { color: var(--danger); }

/* ========== 提示消息 ========== */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin: 12px;
}
.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-info { background: #dbeafe; color: #1e40af; }
.alert-warning { background: #fef3c7; color: #92400e; }

/* ========== 桌面端适配（>768px） ========== */
@media (min-width: 768px) {
  body { padding-bottom: 0; padding-left: 220px; }
  
  .bottom-nav {
    top: 0;
    left: 0;
    right: auto;
    bottom: auto;
    width: 220px;
    height: 100vh;
    flex-direction: column;
    justify-content: flex-start;
    padding: 20px 0;
    border-right: 1px solid var(--border);
    border-top: none;
    box-shadow: none;
    background: var(--sidebar-bg, #0f172a);
  }
  .bottom-nav a {
    flex-direction: row;
    justify-content: flex-start;
    padding: 10px 20px;
    font-size: 13px;
    color: #94a3b8;
    gap: 10px;
  }
  .bottom-nav a.active { color: white; background: var(--primary); }
  .bottom-nav a:hover:not(.active) { background: rgba(255,255,255,0.05); color: white; }
  .bottom-nav .nav-icon { width: 20px; height: 20px; font-size: 16px; }
  
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
  .card { margin: 16px; }
  
  .content-wrap {
    max-width: 1200px;
    margin: 0 auto;
  }
}
