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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  font-size: 14px;
}

.hidden { display: none !important; }

/* 登录 */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f, #2563eb);
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-sub { color: #64748b; margin-bottom: 24px; font-size: 13px; }

.login-card label {
  display: block;
  margin-bottom: 16px;
  font-size: 13px;
  color: #475569;
}

.login-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
}

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

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

.sidebar {
  width: 220px;
  background: #1e293b;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  flex-shrink: 0;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  padding: 0 20px 24px;
  border-bottom: 1px solid #334155;
  margin-bottom: 12px;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 2px;
}

.nav-item {
  display: block;
  padding: 12px 20px;
  color: #94a3b8;
  text-decoration: none;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.nav-item:hover, .nav-item.active {
  background: #334155;
  color: #fff;
}

.nav-item.active {
  border-left-color: #2563eb;
}

.logout-btn { margin: auto 16px 0; }

.content { flex: 1; padding: 24px; overflow: auto; }

.topbar { margin-bottom: 20px; }
.topbar h2 { font-size: 20px; font-weight: 600; }

/* 组件 */
.btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
}

.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-ghost { background: transparent; color: #94a3b8; border: 1px solid #475569; }
.btn-ghost:hover { background: #334155; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 12px; margin-top: 8px; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }

.input {
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
}

.input-sm { width: 120px; }

.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.filters .input { min-width: 140px; }

.card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.card h3 { font-size: 15px; margin-bottom: 16px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.stat-card .label { font-size: 12px; color: #64748b; margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 700; color: #1e3a5f; }
.stat-card .sub { font-size: 12px; color: #94a3b8; margin-top: 4px; }

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #f1f5f9; }
th { color: #64748b; font-weight: 500; background: #f8fafc; }
tr:hover td { background: #f8fafc; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.badge-unbound { background: #f1f5f9; color: #64748b; }
.badge-bound { background: #dbeafe; color: #1d4ed8; }
.badge-activated { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 16px;
  margin-bottom: 20px;
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 160px;
  padding: 12px 4px 0;
}

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

.chart-bar {
  width: 100%;
  max-width: 48px;
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
}

.chart-label {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 6px;
}

.chart-value {
  font-size: 11px;
  color: #475569;
  margin-bottom: 4px;
}

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

.card-full { margin-bottom: 20px; }

.map-chart {
  width: 100%;
  height: 420px;
}

.monitor-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  font-size: 13px;
}

.monitor-metrics .item {
  background: #f8fafc;
  border-radius: 8px;
  padding: 12px;
}

.monitor-metrics .label { color: #64748b; font-size: 12px; margin-bottom: 4px; }
.monitor-metrics .value { font-size: 18px; font-weight: 600; color: #1e3a5f; }

.health-up { color: #15803d; }
.health-down { color: #dc2626; }
.health-skip { color: #94a3b8; }

.badge-critical { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #e0f2fe; color: #0369a1; }

.pagination {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: center;
}

.pagination button {
  padding: 6px 12px;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination button.active { background: #2563eb; color: #fff; border-color: #2563eb; }

/* 模态框 */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.modal-content {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1;
}

.modal-content h3 { margin-bottom: 16px; font-size: 16px; }

.modal-hint {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 12px;
  line-height: 1.5;
}

.text-muted { font-size: 12px; color: #94a3b8; }

.text-danger { color: #dc2626; font-size: 13px; }

.confirm-danger-box {
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.confirm-list {
  list-style-position: inside;
  margin: 8px auto 12px;
  padding: 0;
  color: #475569;
  text-align: center;
  display: inline-block;
}

.confirm-list li {
  text-align: left;
}

.confirm-danger-box .text-danger {
  margin: 0;
}

.modal-content label.confirm-check {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 16px 0 0;
  width: 100%;
  cursor: pointer;
  text-align: center;
}

.modal-content label.confirm-check input[type="checkbox"] {
  display: inline-block;
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  accent-color: #2563eb;
  cursor: pointer;
}

.link { color: #2563eb; text-decoration: none; }
.link:hover { text-decoration: underline; }

.detail-grid p { margin-bottom: 10px; font-size: 13px; line-height: 1.6; }
.detail-grid strong { display: inline-block; width: 100px; color: #64748b; font-weight: 500; }

.modal-content label:not(.confirm-check) {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: #475569;
}

.modal-content input:not([type="checkbox"]), .modal-content select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 200;
}

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

.codes-detail-toolbar {
  margin-bottom: 8px;
}

.codes-detail-title {
  font-size: 14px;
  font-weight: 600;
  color: #475569;
  margin-left: 4px;
}

.export-actions .btn-block {
  width: 100%;
  margin-top: 8px;
}

.export-actions .btn-block:first-of-type {
  margin-top: 0;
}

.logout-btn {
  margin-top: auto;
}

.sidebar-user {
  padding: 12px 20px;
  font-size: 12px;
  color: #94a3b8;
  border-top: 1px solid #334155;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-meta {
  font-size: 13px;
  color: #64748b;
}

@media (max-width: 768px) {
  .sidebar {
    width: 180px;
  }

  .nav-item {
    padding: 10px 16px;
    font-size: 13px;
  }

  .content {
    padding: 16px;
  }
}
