/* ─── Jujiandan Admin Portal CSS ─────────────────────────────────────── */

:root {
  --bg-primary: #0a0c14;
  --bg-secondary: #12141e;
  --bg-card: #181b28;
  --bg-hover: #1e2235;
  --bg-input: #12141e;
  --border: rgba(255,255,255,0.06);
  --text-primary: #e8eaf0;
  --text-secondary: #8b8fa4;
  --text-muted: #5b5f73;
  --accent: #10b981;
  --accent-hover: #059669;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --amber: #f59e0b;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

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

body {
  font-family: 'Inter', -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── Login ──────────────────────────────────────────────────────────── */

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0a0c14 0%, #111827 50%, #0a0c14 100%);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 400px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--accent), #06b6d4);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  color: white;
}

.login-card h1 { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 32px; }

.input-group { text-align: left; margin-bottom: 16px; }
.input-group label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }
.input-group input, .input-group select, .input-group textarea {
  width: 100%; padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
  font-family: inherit;
}
.input-group textarea {
  resize: vertical;
  min-height: 88px;
  line-height: 1.5;
}
.input-group input:focus, .input-group select:focus, .input-group textarea:focus {
  border-color: var(--accent);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.key-pair-row {
  grid-template-columns: minmax(96px, 0.45fr) minmax(260px, 1.55fr);
}
.form-row .input-group {
  min-width: 0;
}

.error-msg { color: var(--danger); font-size: 13px; margin-bottom: 12px; }

/* ─── Buttons ────────────────────────────────────────────────────────── */

.btn-primary {
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: 10px 20px; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background .2s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-full { width: 100%; padding: 12px; font-size: 15px; margin-top: 8px; }

.btn-ghost {
  background: none; border: none;
  color: var(--text-secondary); font-size: 13px;
  cursor: pointer; padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all .2s;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-hover); }

.btn-sm {
  padding: 5px 12px; font-size: 12px;
  border: 1px solid var(--border);
  background: transparent; color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer; transition: all .2s;
}
.btn-sm:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm.danger { color: var(--danger); }
.btn-sm.danger:hover { border-color: var(--danger); }

/* ─── Layout ─────────────────────────────────────────────────────────── */

.main-app { display: flex; height: 100vh; }

.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 20px 0;
}

.sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px 24px;
  color: var(--accent);
  font-size: 18px; font-weight: 700;
}

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 14px;
  text-decoration: none; transition: all .2s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: rgba(16,185,129,.1); color: var(--accent); font-weight: 500; }

.sidebar-footer {
  padding: 16px 20px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.admin-info { display: flex; align-items: center; gap: 8px; }
.admin-avatar {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: white;
}

.content { flex: 1; padding: 28px 32px; overflow-y: auto; }

/* ─── Pages ──────────────────────────────────────────────────────────── */

.page { display: none; animation: fadeIn .3s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.page-header { margin-bottom: 24px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.page-header h2 { font-size: 22px; font-weight: 600; }
.page-actions { display: flex; gap: 10px; align-items: center; }
.text-muted { color: var(--text-muted); font-size: 13px; }

/* ─── Stats Cards ────────────────────────────────────────────────────── */

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon.blue { background: rgba(59,130,246,.15); color: var(--blue); }
.stat-icon.green { background: rgba(16,185,129,.15); color: var(--accent); }
.stat-icon.purple { background: rgba(139,92,246,.15); color: var(--purple); }
.stat-icon.amber { background: rgba(245,158,11,.15); color: var(--amber); }

.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ─── Chart ──────────────────────────────────────────────────────────── */

.chart-section {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.chart-section h3 { font-size: 15px; font-weight: 500; margin-bottom: 20px; }
.config-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}
.config-section h3 {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 14px;
}

.chart-bar { display: flex; align-items: flex-end; gap: 12px; height: 160px; padding-top: 20px; }
.chart-col {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.chart-col .bar {
  width: 100%; max-width: 48px;
  background: linear-gradient(to top, var(--accent), rgba(16,185,129,.4));
  border-radius: 6px 6px 0 0;
  min-height: 4px; transition: height .5s ease;
}
.chart-col .bar-label { font-size: 11px; color: var(--text-muted); }
.chart-col .bar-value { font-size: 12px; font-weight: 600; color: var(--accent); }

/* ─── Tables ─────────────────────────────────────────────────────────── */

.table-container { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.data-table th {
  text-align: left; padding: 12px 16px;
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: .5px;
}
.data-table td {
  padding: 12px 16px; font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }
.points-business-table {
  min-width: 1480px;
}
.points-business-table .point-status-cell {
  width: 84px;
  min-width: 84px;
  text-align: center;
  white-space: nowrap;
}
.data-table .detail-cell {
  background: rgba(255,255,255,.025);
  padding: 10px 16px 16px;
}
.point-remark {
  max-width: 260px;
  margin-bottom: 6px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nested-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.nested-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(0,0,0,.12);
}
.nested-table th,
.nested-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.nested-table th {
  color: var(--text-muted);
  background: rgba(0,0,0,.18);
  font-weight: 500;
}
.nested-table tr:last-child td { border-bottom: none; }
.data-table .official-group-row td {
  background: rgba(255,255,255,.035);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.data-table .official-group-row:hover td { background: rgba(255,255,255,.045); }
.official-group-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.official-group-count {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
}

.empty-state { text-align: center; color: var(--text-muted); padding: 40px !important; }

.search-input {
  padding: 8px 14px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 13px; outline: none;
  width: 220px; transition: border-color .2s;
}
.search-input:focus { border-color: var(--accent); }

.filter-select {
  padding: 8px 14px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 13px; outline: none;
}

/* ─── Badges ─────────────────────────────────────────────────────────── */

.badge {
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  line-height: 1.2;
  word-break: keep-all;
}
.badge-green { background: rgba(16,185,129,.15); color: #10b981; }
.badge-red { background: rgba(239,68,68,.15); color: #ef4444; }
.badge-blue { background: rgba(59,130,246,.15); color: #3b82f6; }
.badge-amber { background: rgba(245,158,11,.15); color: #f59e0b; }
.badge-purple { background: rgba(139,92,246,.15); color: #8b5cf6; }
.badge-gray { background: rgba(107,114,128,.15); color: #9ca3af; }
.text-success { color: #10b981; font-weight: 600; }
.text-danger { color: #ef4444; font-weight: 600; }

.points-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.points-summary > div {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--bg-secondary);
}
.points-summary span {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 6px;
}
.points-summary strong {
  display: block;
  color: var(--text-primary);
  font-size: 16px;
}

.profit-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.profit-summary > div,
.inspection-summary > div {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: var(--bg-card);
}
.profit-summary span,
.inspection-summary span {
  display: block;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 8px;
}
.profit-summary strong,
.inspection-summary strong {
  display: block;
  color: var(--text-primary);
  font-size: 20px;
}
.inspection-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.inspection-alerts {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.inspection-alert {
  border: 1px solid rgba(245,158,11,.25);
  background: rgba(245,158,11,.08);
  color: #fbbf24;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
}

.model-monitor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--text-muted);
  font-size: 12px;
}
.model-monitor-toolbar strong {
  color: var(--text-secondary);
  font-weight: 500;
}
.model-monitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}
.model-monitor-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  min-width: 0;
}
.monitor-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.monitor-card-title {
  min-width: 0;
}
.monitor-card-title h3 {
  font-size: 15px;
  line-height: 1.3;
  margin-bottom: 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.monitor-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
}
.monitor-rate-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}
.monitor-rate-row span {
  color: var(--text-secondary);
  font-size: 12px;
}
.monitor-rate {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.monitor-rate.normal { color: #22c55e; }
.monitor-rate.warning { color: #f59e0b; }
.monitor-rate.error { color: #ef4444; }
.monitor-counts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.monitor-counts div {
  background: rgba(0,0,0,.12);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}
.monitor-counts span {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 4px;
}
.monitor-counts strong {
  color: var(--text-primary);
  font-size: 14px;
}
.monitor-bars {
  display: grid;
  grid-template-columns: repeat(24, minmax(5px, 1fr));
  gap: 3px;
  height: 36px;
  align-items: end;
  margin: 8px 0 6px;
}
.monitor-bar {
  height: 100%;
  border-radius: 3px;
}
.monitor-bar.normal { background: #22c55e; }
.monitor-bar.warning { background: #f59e0b; }
.monitor-bar.error { background: #ef4444; }
.monitor-bar-labels {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 14px;
}
.monitor-details {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.monitor-details summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
  user-select: none;
}
.monitor-details summary:hover { color: var(--accent); }
.monitor-detail-section {
  margin-top: 12px;
}
.monitor-detail-section h4 {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 8px;
}
.monitor-list {
  display: grid;
  gap: 6px;
}
.monitor-list-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  background: rgba(0,0,0,.12);
  color: var(--text-secondary);
  font-size: 12px;
}
.monitor-list-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.monitor-list-row strong {
  flex-shrink: 0;
  color: var(--text-primary);
  font-weight: 600;
}

/* ─── Pagination ─────────────────────────────────────────────────────── */

.pagination {
  display: flex; justify-content: center; gap: 6px;
  margin-top: 16px; padding: 8px 0;
}
.pagination button {
  padding: 6px 12px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-secondary);
  border-radius: var(--radius-sm); font-size: 13px;
  cursor: pointer; transition: all .2s;
}
.pagination button:hover { border-color: var(--accent); color: var(--accent); }
.pagination button.active { background: var(--accent); color: white; border-color: var(--accent); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ─── Modal ──────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.72);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .2s ease;
}
.modal-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; width: 480px; max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-body .input-group { margin-bottom: 14px; }
.modal-body .btn-primary { margin-top: 8px; }

@media (max-width: 420px) {
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

/* ─── Settings ───────────────────────────────────────────────────────── */

.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 20px; }
.settings-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.settings-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.settings-card code { background: var(--bg-input); padding: 2px 8px; border-radius: 4px; font-size: 12px; color: var(--accent); }

.info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.info-row:last-child { border-bottom: none; }

.audit-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.audit-detail-grid div {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: rgba(0,0,0,.12);
  min-width: 0;
}
.audit-detail-grid span {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 4px;
}
.audit-detail-grid strong {
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  word-break: break-all;
}
.audit-json {
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
}

.point-ledger-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.point-ledger-step {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--bg-input);
}
.point-ledger-step-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.point-ledger-step-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 8px;
}
.point-ledger-step-grid span {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  margin-bottom: 2px;
}
.point-ledger-step-grid strong {
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
}

/* ─── Responsive ─────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 180px; }
}
@media (max-width: 640px) {
  .stats-grid { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .content { padding: 16px; }
}
