* { 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: #f5f7fa;
  color: #1f2937;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ========== 登录页 ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}

.login-container {
  background: white;
  border-radius: 20px;
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-logo {
  margin-bottom: 16px;
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 28px;
}

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

.login-form input {
  padding: 12px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.login-form input:focus {
  border-color: #3b82f6;
}

.btn-primary {
  padding: 12px 20px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

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

.login-error {
  color: #ef4444;
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
}

/* ========== 后台布局 ========== */
.admin-page {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: #1e293b;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px;
  font-size: 15px;
  font-weight: 600;
  color: white;
  border-bottom: 1px solid #334155;
  line-height: 1.3;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.show {
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  color: #cbd5e1;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 4px;
}

.nav-item:hover {
  background: #334155;
  color: white;
}

.nav-item.active {
  background: #3b82f6;
  color: white;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid #334155;
}

.btn-ghost {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: #94a3b8;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  width: 100%;
  transition: all 0.2s;
}

.btn-ghost:hover {
  background: #334155;
  color: white;
}

/* 移动端顶栏 */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: #1e293b;
  color: white;
  align-items: center;
  padding: 0 16px;
  z-index: 99;
}

.menu-toggle {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  margin-right: 12px;
}

/* 主内容区 */
.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 24px;
  max-width: 1400px;
}

.page { display: none; }
.page.active { display: block; }

.page-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 24px;
  color: #1f2937;
}

/* 统计卡片 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.bg-blue-100 { background: #dbeafe; }
.bg-green-100 { background: #dcfce7; }
.bg-purple-100 { background: #f3e8ff; }
.bg-amber-100 { background: #fef3c7; }
.text-blue-600 { color: #2563eb; }
.text-green-600 { color: #16a34a; }
.text-purple-600 { color: #9333ea; }
.text-amber-600 { color: #d97706; }

.stat-label {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 2px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: #1f2937;
}

/* 卡片 */
.card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  margin-bottom: 24px;
  overflow: hidden;
}

.card-body {
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid #f1f5f9;
  flex-wrap: wrap;
  gap: 12px;
}

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

.text-sm { font-size: 13px; }
.text-gray-400 { color: #9ca3af; }
.text-center { text-align: center; }

/* 搜索框 */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 200px;
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  width: 100%;
}

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

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

.data-table th {
  text-align: left;
  padding: 12px 20px;
  background: #f8fafc;
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
}

.data-table td {
  padding: 12px 20px;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap;
}

.data-table tr:hover {
  background: #f8fafc;
}

.data-table tbody tr {
  cursor: pointer;
}

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

.status-normal { background: #dcfce7; color: #16a34a; }
.status-banned { background: #fee2e2; color: #dc2626; }
.status-inactive { background: #f1f5f9; color: #64748b; }

/* 操作按钮 */
.btn-action {
  padding: 5px 10px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  margin-right: 6px;
}

.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }
.btn-warning { background: #fef3c7; color: #d97706; }
.btn-warning:hover { background: #fde68a; }

/* Tab */
.tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-btn {
  padding: 8px 18px;
  border: 1px solid #e5e7eb;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.tab-btn.active {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

/* 激活码生成 */
.code-generate {
  padding: 20px;
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row label {
  font-size: 13px;
  color: #6b7280;
}

.form-row input {
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}

.generated-codes {
  padding: 0 20px 20px;
}

.code-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 8px;
  font-family: monospace;
  font-size: 14px;
}

/* 弹窗 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid #f1f5f9;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #9ca3af;
}

.modal-body {
  padding: 20px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.detail-item {
  padding: 12px;
  background: #f8fafc;
  border-radius: 10px;
}

.detail-label {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
}

.detail-value {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

/* ========== 响应式 ========== */
/* 平板端（768px - 1024px） */
@media (max-width: 1024px) {
  .sidebar {
    width: 200px;
  }
  
  .main-content {
    margin-left: 200px;
  }
  
  .sidebar-logo {
    font-size: 13px;
  }
}

/* 手机端（<768px） */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 260px;
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .mobile-header {
    display: flex;
    align-items: center;
  }
  
  .mobile-header span {
    flex: 1;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .main-content {
    margin-left: 0;
    padding: 72px 14px 14px;
  }
  
  .page-title {
    font-size: 20px;
    margin-bottom: 16px;
  }
  
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  
  .stat-card {
    padding: 14px;
  }
  
  .stat-value {
    font-size: 20px;
  }
  
  .stat-icon {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
  
  .card {
    border-radius: 12px;
  }
  
  .card-header {
    padding: 14px;
  }
  
  .card-header h3 {
    font-size: 15px;
  }
  
  .search-box {
    min-width: 140px;
    padding: 6px 10px;
  }

  /* 表格转卡片 */
  .table-wrapper {
    overflow: visible;
  }

  .data-table thead {
    display: none;
  }

  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }

  .data-table tr {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 12px;
    padding: 4px 0;
    cursor: default;
  }

  .data-table tr:hover {
    background: white;
  }

  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    border-bottom: 1px solid #f1f5f9;
    white-space: normal;
    word-break: break-all;
    text-align: right;
    font-size: 13px;
  }

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

  .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #6b7280;
    text-align: left;
    flex-shrink: 0;
    margin-right: 10px;
    font-size: 12px;
  }

  .data-table td code {
    font-size: 12px;
  }

  /* 空数据行（加载中/暂无数据） */
  .data-table tr.empty-row td {
    display: block;
    text-align: center;
    border: none;
    padding: 16px;
  }

  .data-table tr.empty-row td::before {
    display: none;
  }
  
  .detail-grid {
    grid-template-columns: 1fr;
  }
  
  .code-generate {
    flex-direction: column;
    align-items: stretch;
  }
  
  .code-generate .btn-primary {
    width: 100%;
  }

  /* 弹窗移动端 */
  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal-content {
    border-radius: 16px 16px 0 0;
    max-height: 85vh;
  }
}

/* 超小屏（<480px） */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .mobile-header span {
    font-size: 13px;
  }

  .login-container {
    padding: 28px 20px;
  }
}

/* ========== 消息通知 ========== */
.page-desc {
  color: #6b7280;
  font-size: 13px;
  margin: -8px 0 16px;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
  box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

/* 平板端（≤1024px） */
@media (max-width: 1024px) {
  .form-grid {
    gap: 14px;
  }
}

/* 手机端（≤768px）：表单单列 */
@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .card-body {
    padding: 16px;
  }
}

/* 超小屏（≤480px） */
@media (max-width: 480px) {
  .card-body {
    padding: 14px;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    padding: 8px 10px;
    font-size: 13px;
  }
}

/* 通知列表项 */
.notif-item {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  background: #fff;
}

.notif-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.notif-item-title {
  font-weight: 600;
  font-size: 14px;
}

.notif-item-content {
  color: #4b5563;
  font-size: 13px;
  margin-bottom: 8px;
  word-break: break-all;
}

.notif-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.notif-item-time {
  font-size: 12px;
  color: #9ca3af;
}

.notif-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.notif-tag-info { background: #dbeafe; color: #1d4ed8; }
.notif-tag-success { background: #d1fae5; color: #047857; }
.notif-tag-warning { background: #fef3c7; color: #b45309; }
.notif-tag-important { background: #fee2e2; color: #b91c1c; }

/* 时段活跃图表 */
.hourly-chart {
  padding: 20px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 180px;
  overflow-x: auto;
}

.hourly-bar {
  flex: 1;
  min-width: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  position: relative;
  height: 100%;
}

.hourly-bar-fill {
  width: 100%;
  background: linear-gradient(to top, #3b82f6, #60a5fa);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height 0.3s ease;
  position: relative;
}

.hourly-bar:hover .hourly-bar-fill {
  background: linear-gradient(to top, #2563eb, #3b82f6);
}

.hourly-bar-value {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: #374151;
  font-weight: 600;
  white-space: nowrap;
}

.hourly-bar-label {
  font-size: 9px;
  color: #9ca3af;
  margin-top: 4px;
}

.hourly-empty {
  color: #9ca3af;
  text-align: center;
  padding: 40px 0;
  font-size: 14px;
}
