/* ── Reset & Base ── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0e14;
  --bg-secondary: #0f1821;
  --bg-card: #121c27;
  --bg-card-hover: #172230;
  --bg-input: #080e14;
  --border: #1e2d3a;
  --border-light: #2a3f50;
  --text-primary: #e8eef4;
  --text-secondary: #9ab0c4;
  --text-muted: #5a7085;
  --accent: #4fc3f7;
  --accent-glow: rgba(79, 195, 247, 0.15);
  --green: #66bb6a;
  --red: #ef5350;
  --yellow: #ffd54f;
  --orange: #ff9800;
  --sidebar-width: 220px;
  --header-height: 56px;
  --radius: 10px;
  --radius-sm: 6px;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── Screen switching ── */
.screen:not(#login-screen) {
  display: none;
}
.screen:not(#login-screen).active {
  display: block;
}

/* ── Login ── */
#login-screen {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at center, #0f1a25 0%, #080c12 70%);
}
#login-screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 420px;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3rem 2.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.login-card .logo {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}
.login-card h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}
.login-card .subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.8rem;
}
.login-card .form-group {
  margin-bottom: 1rem;
  text-align: left;
}
.login-card .form-group label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
  font-weight: 500;
}
.login-card input[type='password'] {
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
}
.login-card .btn {
  padding: 0.7rem;
  font-size: 0.95rem;
  margin-top: 0.5rem;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 0.5rem;
  width: fit-content;
}
.checkbox-row input[type='checkbox'] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}
#login-error {
  margin-top: 0.8rem;
  font-size: 0.85rem;
  color: var(--red);
}

/* ── Admin Layout ── */
#admin-screen {
  display: none;
  min-height: 100vh;
}
#admin-screen.active {
  display: flex;
  min-height: 100vh;
  height: auto;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  height: var(--header-height);
  flex-shrink: 0;
}
.sidebar-brand span {
  font-size: 1.4rem;
}
.sidebar-brand h1 {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
}
.sidebar-nav {
  flex: 1;
  padding: 0.8rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  background: rgba(79, 195, 247, 0.06);
  color: var(--text-secondary);
}
.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
}
.nav-item.logout {
  margin-top: auto;
  color: var(--red);
}
.nav-item.logout:hover {
  background: rgba(239, 83, 80, 0.08);
}
.nav-item .nav-icon {
  font-size: 1.1rem;
  width: 1.6rem;
  text-align: center;
  flex-shrink: 0;
}
.nav-item .nav-label {
  white-space: nowrap;
}

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 1.2rem 1.8rem;
  max-width: calc(100vw - var(--sidebar-width));
  min-height: 100vh;
  overflow-y: auto;
}

/* ── Top Bar ── */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--border);
}
.top-bar h2 {
  font-size: 1.15rem;
  font-weight: 600;
}
.top-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

/* 退出登录按钮：桌面端隐藏（底部导航已有），手机端显示 */
.logout-top-btn {
  display: none;
}
@media (max-width: 768px) {
  .logout-top-btn {
    display: inline-flex;
  }
}

/* ── Card ── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}
.card:hover {
  border-color: var(--border-light);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}
.card-header h2 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.card-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.stat-card {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.1rem 1rem 0.8rem;
  text-align: center;
  border: 1px solid var(--border);
  overflow: hidden;
  transition:
    border-color 0.15s,
    transform 0.12s,
    box-shadow 0.15s;
}
.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
/* 每个卡片顶部一条主题色装饰条 */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent);
}
.stat-card-upstream::before {
  background: linear-gradient(90deg, #66bb6a, transparent);
}
.stat-card-conc::before {
  background: linear-gradient(90deg, #ff9800, transparent);
}
.stat-card-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}
.stat-ico {
  font-size: 0.95rem;
  line-height: 1;
}
.stat-num {
  display: block;
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  background: linear-gradient(135deg, var(--accent), #2196f3);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat-card-upstream .stat-num {
  background: linear-gradient(135deg, #66bb6a, #43a047);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat-card-conc .stat-num {
  background: linear-gradient(135deg, #ffb74d, #fb8c00);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
}
.stat-pct {
  display: inline-block;
  margin-top: 0.15rem;
  font-size: 0.68rem;
  color: var(--accent);
  background: rgba(79, 195, 247, 0.12);
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
/* 活跃率进度条 */
.stat-progress {
  height: 5px;
  border-radius: 999px;
  background: var(--bg-input);
  margin-top: 0.55rem;
  overflow: hidden;
}
.stat-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #2196f3);
  transition: width 0.6s ease;
}
.stat-sublist {
  margin-top: 0.6rem;
  border-top: 1px dashed var(--border);
  padding-top: 0.3rem;
  max-height: 96px;
  overflow-y: auto;
}
.stat-subrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.7rem;
  padding: 0.24rem 0.15rem;
  gap: 0.4rem;
  border-radius: 6px;
  transition: background 0.12s;
}
.stat-subrow:hover {
  background: rgba(255, 255, 255, 0.03);
}
.stat-subrow + .stat-subrow {
  border-top: 1px solid var(--border);
}
.stat-sub-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  min-width: 0;
}
.stat-sub-val {
  white-space: nowrap;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  background: var(--bg-input);
  padding: 0.06rem 0.45rem;
  border-radius: 6px;
}
.stat-sub-live {
  color: #fff;
  background: rgba(255, 152, 0, 0.18);
  font-weight: 600;
}
.stat-sub-empty {
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.68rem;
  padding: 0.3rem 0;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 0.6rem;
}
.form-group label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  font-weight: 500;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 0.8rem;
  align-items: start;
}
.form-row .full-width {
  grid-column: 1 / -1;
}
.form-row .btn-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
}
.form-row .form-row-btn {
  grid-column: 1 / -1;
  padding-top: 0.3rem;
}

input,
select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.input-sm {
  padding: 0.35rem 0.55rem;
  font-size: 0.78rem;
  width: auto;
  min-width: 140px;
}

/* ── Input + Unit Select ── */
.input-unit-group {
  display: flex;
  gap: 0;
  align-items: stretch;
}
.input-unit-group .unit-input {
  flex: 1;
  min-width: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  border-right: none;
}
.input-unit-group .unit-input:focus {
  box-shadow: none;
  border-color: var(--accent);
}
.input-unit-group .unit-select {
  width: auto;
  min-width: 76px;
  flex-shrink: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--bg-input);
  cursor: pointer;
  padding: 0.55rem 0.35rem;
  font-size: 0.8rem;
  border-left: none;
}
.input-unit-group .unit-select:focus {
  box-shadow: none;
  border-color: var(--accent);
}
.input-unit-group .unit-input:focus + .unit-select {
  border-color: var(--accent);
}
.input-unit-group .unit-select option {
  background: var(--bg-card);
  color: var(--text-primary);
}
.unit-input[disabled] {
  opacity: 0.3;
  cursor: not-allowed;
  background: #0a131c;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  line-height: 1.4;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.btn:active {
  transform: translateY(0) scale(0.98);
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #2196f3);
  color: #080e14;
  font-weight: 600;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #6ccdf9, #42a5f5);
  box-shadow: 0 4px 15px var(--accent-glow);
  transform: translateY(-1px);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-outline:hover {
  border-color: var(--border-light);
  color: var(--text-secondary);
  background: rgba(79, 195, 247, 0.04);
}
.btn-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}
.btn-ghost:hover {
  background: var(--accent-glow);
  border-color: rgba(79, 195, 247, 0.25);
  color: var(--accent);
}
.text-danger {
  color: var(--red) !important;
}
.text-danger:hover {
  background: rgba(239, 83, 80, 0.1) !important;
  color: #ff6b6b !important;
}
.text-success {
  color: var(--green) !important;
}
.text-success:hover {
  background: rgba(102, 187, 106, 0.1) !important;
  color: #81c784 !important;
}
.btn-block {
  width: 100%;
}
.btn-sm {
  padding: 0.3rem 0.55rem;
  font-size: 0.8rem;
}
.btn-lg {
  padding: 0.6rem 1.2rem;
  font-size: 0.95rem;
}
.btn-danger {
  background: transparent;
  border: 1px solid rgba(239, 83, 80, 0.3);
  color: var(--red);
}
.btn-danger:hover {
  background: rgba(239, 83, 80, 0.12);
  border-color: rgba(239, 83, 80, 0.5);
  color: #ff6b6b;
}

/* ── Tables ── */
.table-wrap {
  overflow-x: hidden;
  border-radius: var(--radius-sm);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
thead {
  position: sticky;
  top: 0;
  z-index: 1;
}
th {
  text-align: left;
  padding: 0.5rem 0.6rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  background: #0b131d;
  white-space: nowrap;
}
td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid rgba(30, 45, 58, 0.5);
  vertical-align: middle;
}
tr:last-child td {
  border-bottom: none;
}
tr:hover td {
  background: rgba(79, 195, 247, 0.03);
}
.num-cell {
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.time-cell {
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 0.76rem;
  text-align: center;
}
.mono-cell {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.76rem;
}
#recent-calls-table th,
#recent-calls-table td,
#detail-logs-table th,
#detail-logs-table td,
#err-logs-table th,
#err-logs-table td {
  text-align: center;
}
.action-cell {
  white-space: nowrap;
  text-align: right;
}
.rank-num {
  font-weight: 700;
  color: var(--accent);
  width: 1.8rem;
}
.empty-row {
  text-align: center;
  color: #3a4a5a;
  padding: 2rem !important;
  font-style: italic;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem 1.1rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  background: linear-gradient(180deg, rgba(79, 195, 247, 0.02), transparent);
}
.filter-bar .filter-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.filter-bar select {
  background: #141b24;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  border-radius: 6px;
  padding: 0.32rem 0.55rem;
  font-size: 0.78rem;
  outline: none;
  transition: border-color 0.15s;
  min-width: 7rem;
}
.filter-bar select:hover,
.filter-bar select:focus {
  border-color: var(--accent, #4fc3f7);
}
.filter-bar .btn {
  margin-left: auto;
}

/* ── 错误类型徽标（按类别配色）── */
.err-type {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  white-space: nowrap;
  line-height: 1.35;
  border: 1px solid transparent;
}
.err-t--nt {
  background: rgba(244, 67, 54, 0.14);
  color: #ef5350;
  border-color: rgba(244, 67, 54, 0.25);
}
.err-t--server {
  background: rgba(224, 53, 44, 0.14);
  color: #ff6659;
  border-color: rgba(224, 53, 44, 0.25);
}
.err-t--busy {
  background: rgba(255, 152, 0, 0.14);
  color: #ffb300;
  border-color: rgba(255, 152, 0, 0.25);
}
.err-t--key {
  background: rgba(79, 195, 247, 0.14);
  color: #4fc3f7;
  border-color: rgba(79, 195, 247, 0.25);
}
.err-t--quota {
  background: rgba(255, 193, 7, 0.12);
  color: #ffd54f;
  border-color: rgba(255, 193, 7, 0.22);
}
.err-t--http {
  background: rgba(233, 30, 99, 0.12);
  color: #f06292;
  border-color: rgba(233, 30, 99, 0.22);
}
.err-t--gn {
  background: rgba(120, 144, 156, 0.14);
  color: #b0bec5;
  border-color: rgba(120, 144, 156, 0.22);
}

/* ── 状态码徽标（按范围配色）── */
.err-code {
  display: inline-block;
  padding: 0.08rem 0.45rem;
  border-radius: 5px;
  font-weight: 700;
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
  min-width: 2.3rem;
}
.err-c--c5xx {
  background: rgba(244, 67, 54, 0.16);
  color: #ff6659;
  border-color: rgba(244, 67, 54, 0.3);
}
.err-c--c429 {
  background: rgba(255, 152, 0, 0.16);
  color: #ffb300;
  border-color: rgba(255, 152, 0, 0.3);
}
.err-c--c4xx {
  background: rgba(255, 193, 7, 0.12);
  color: #ffd54f;
  border-color: rgba(255, 193, 7, 0.24);
}
.err-c--c0 {
  background: rgba(120, 144, 156, 0.14);
  color: #b0bec5;
  border-color: rgba(120, 144, 156, 0.24);
}

/* ── 错误信息、占位、空状态 ── */
.err-msg {
  display: block;
  max-width: 220px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash {
  color: #546e7a;
}
.err-empty {
  padding: 2.6rem 1rem;
  text-align: center;
  color: #78909c;
  font-style: normal;
}
.err-empty-icon {
  font-size: 2.2rem;
  margin-bottom: 0.5rem;
  opacity: 0.6;
}
.err-card {
  border-left: 3px solid rgba(244, 67, 54, 0.5) !important;
}

.muted {
  color: var(--text-muted);
}
.muted-sm {
  color: var(--text-muted);
  font-size: 0.74rem;
}

/* ── Key display ── */
.key-display {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.76rem;
  color: #7ab8d4;
  background: var(--bg-input);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  cursor: pointer;
  transition:
    background 0.12s,
    color 0.12s;
}
.key-display:hover {
  background: #0e1a24;
  color: var(--accent);
}
.key-name {
  font-weight: 500;
  color: var(--text-primary);
}
.copy-trigger {
  cursor: pointer;
}

/* ── Badge ── */
.badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.6;
}
.badge-active {
  background: rgba(67, 160, 71, 0.12);
  color: var(--green);
}
.badge-revoked {
  background: rgba(229, 57, 53, 0.12);
  color: var(--red);
}
.badge-expired {
  background: rgba(255, 193, 7, 0.12);
  color: var(--yellow);
}

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 1000;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
  backdrop-filter: blur(2px);
}
.modal-overlay.active {
  display: flex;
}
#content-modal {
  z-index: 1500;
}
.modal-content {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 1.4rem 1.6rem;
  max-width: 1100px;
  width: 100%;
  margin-top: 2vh;
  position: relative;
  border: 1px solid var(--border);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.9rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem;
  border-radius: 4px;
  transition: color 0.12s;
}
.modal-close:hover {
  color: var(--text-primary);
}
.modal-content h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.2rem;
  padding-right: 1.5rem;
}

/* ── Create API Key modal form ── */
.create-key-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 1rem;
  align-items: start;
}
.create-key-form .full-width {
  grid-column: 1 / -1;
}
.create-key-form .form-group {
  margin-bottom: 0;
}
.create-key-form .form-group label {
  font-size: 0.78rem;
  margin-bottom: 0.3rem;
}
.create-key-form .create-key-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
  margin-top: 0.2rem;
}
.create-key-form .create-key-actions .btn {
  min-width: 96px;
  justify-content: center;
}

/* ── Refresh Upstream Modal ── */
.ru-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}
.ru-result {
  margin-top: 0.8rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  line-height: 1.55;
}
.ru-summary {
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.ru-result-list {
  margin: 0;
  padding-left: 1rem;
}
.ru-result-list li {
  margin: 0.15rem 0;
}
.ru-result-list li.ok {
  color: #7ee2a8;
  list-style: none;
}
.ru-result-list li.warn {
  color: #f0c36d;
  list-style: none;
}
.ru-rebound {
  color: var(--text-secondary);
  font-size: 0.78rem;
  padding-left: 0.2rem;
}
.ru-interval-row input[type='number'] {
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 0.85rem;
}

/* ── Detail Grid ── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 0.8rem;
}
.detail-section {
  margin-bottom: 1rem;
}
.detail-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
/* ── 详情弹窗 Tab ── */
.detail-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.detail-tab {
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px 8px 0 0;
}
.detail-tab:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}
.detail-tab.active {
  color: var(--text-primary);
  background: var(--bg-card);
  border-color: var(--border);
  border-bottom-color: var(--bg-card);
  position: relative;
  top: 1px;
}
.detail-tab-panel {
  display: none;
}
.detail-tab-panel.active {
  display: block;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.logs-filter-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.info-row {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(30, 45, 58, 0.5);
  font-size: 0.84rem;
}
.info-row:last-child {
  border-bottom: none;
}
.info-label {
  color: var(--text-muted);
  min-width: 5.5rem;
  flex-shrink: 0;
  font-size: 0.8rem;
}
.info-value {
  color: var(--text-primary);
  word-break: break-all;
}
.key-value {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--accent) !important;
  word-break: break-all;
}
.copy-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── Detail Info Grid（API Key 信息紧凑排版）── */
.detail-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.15rem 1rem;
  font-size: 0.84rem;
}
.detail-info-grid .info-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.24rem 0;
  min-width: 0;
  border-bottom: 1px dashed rgba(30, 45, 58, 0.35);
}
.detail-info-grid .info-item:last-child {
  border-bottom: none;
}
.detail-info-grid .info-item.full {
  grid-column: 1 / -1;
}
.detail-info-grid .info-item .info-label {
  min-width: 4.2rem;
  font-size: 0.78rem;
}
.detail-info-grid .info-item .info-value {
  min-width: 0;
}
.detail-info-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
.detail-info-grid.cols-3 .info-item .info-label {
  min-width: auto;
  font-size: 0.76rem;
}
.detail-info-grid.cols-3 .info-item .info-value {
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.detail-section .quota-bar-wrap {
  padding: 0.1rem 0 0.45rem;
  margin-top: 0.1rem;
}

/* ── Quota Bar ── */
.quota-bar-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0 0.3rem;
}
.quota-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}
.quota-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #2196f3);
  border-radius: 3px;
  transition: width 0.4s ease;
}
.quota-fill.warning {
  background: linear-gradient(90deg, var(--orange), #fb8c00);
}
.quota-fill.danger {
  background: linear-gradient(90deg, var(--red), #e53935);
}
.quota-pct {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 600;
  min-width: 2.8rem;
  text-align: right;
}

/* ── Detail Subsection ── */
.detail-subsection {
  margin-bottom: 0.7rem;
}
.sub-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

/* ── Trend toggle buttons ── */
.trend-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 0.25rem 0.6rem;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.trend-btn-active {
  background: var(--accent);
  color: #080e14 !important;
  border-color: var(--accent);
  font-weight: 600;
}
.trend-btn-active:hover {
  background: #6ccdf9;
}

/* ── Code Blocks ── */
.code-block {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  margin-bottom: 0.6rem;
  overflow: hidden;
  border: 1px solid var(--border);
}
.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.8rem;
  background: #0b131d;
  font-size: 0.74rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.code-content {
  display: block;
  padding: 0.6rem 0.8rem;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.76rem;
  line-height: 1.6;
  word-break: break-all;
  white-space: pre-wrap;
  color: var(--text-secondary);
}
.code-pre {
  margin: 0;
  overflow-x: auto;
}

.table-sm td {
  padding: 0.35rem 0.55rem;
  font-size: 0.76rem;
}
.table-sm th {
  padding: 0.35rem 0.55rem;
  font-size: 0.7rem;
}

/* ── Chart ── */
.chart-container {
  min-height: 100px;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.5rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}
.chart-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 1.5rem;
  width: 100%;
  font-style: italic;
}
.chart-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}
.chart-bar {
  width: 60%;
  max-width: 36px;
  background: linear-gradient(to top, var(--accent), #72d0f8);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.4s ease;
}
.chart-label {
  font-size: 0.68rem;
  color: var(--text-muted);
}
.chart-count {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  z-index: 2000;
  border: 1px solid var(--border);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.25s ease;
  white-space: pre-line;
  text-align: center;
  max-width: 90vw;
  line-height: 1.5;
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}
.toast-fade {
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
  transition:
    opacity 0.25s,
    transform 0.25s;
}

/* ── Token Summary Grid ── */
.token-summary-grid {
  grid-template-columns: repeat(4, 1fr);
}
.token-summary-grid .stat-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.15;
}
.token-summary-grid .stat-card {
  padding: 0.8rem 0.6rem;
}
.stat-value.token-input {
  color: var(--accent);
}
.stat-value.token-output {
  color: var(--green);
}
.stat-value.token-total {
  color: var(--yellow);
}

/* ── Log content inline ── */
.log-content {
  display: inline-block;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.4;
}
.log-content.clickable {
  cursor: pointer;
  text-decoration: underline dotted #2a3a48;
  text-underline-offset: 2px;
  transition: color 0.12s;
}
.log-content.clickable:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}
.token-cell {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.76rem;
  color: var(--yellow);
}

/* ── Upstream Status ── */
.upstream-status-card {
  border-left: 3px solid var(--accent);
  background: linear-gradient(135deg, var(--bg-card) 0%, #0d1722 100%);
}
.upstream-status-card .card-header h2 {
  color: var(--text-secondary);
}
.upstream-loading {
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 0.4rem 0;
}
.upstream-unconfigured {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}
.upstream-unconfigured a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.upstream-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.upstream-row:last-child {
  border-bottom: none;
}
.upstream-sub {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-left: 1.1rem;
}
.upstream-main {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.upstream-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-green {
  background: var(--green);
  box-shadow: 0 0 8px rgba(102, 187, 106, 0.5);
}
.dot-red {
  background: var(--red);
  box-shadow: 0 0 8px rgba(239, 83, 80, 0.5);
}
.upstream-status-text {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-primary);
}
.upstream-latency {
  font-weight: 700;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}
/* ── 上游/端点状态：一行多个的网格卡片 ── */
.up-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 6px 10px;
  padding: 8px 0 4px;
}
.up-status-cell {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 5px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
  overflow: hidden;
  cursor: help;
  transition: border-color 0.15s, background 0.15s;
}
.up-status-cell:hover {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
}
.up-status-cell .upstream-status-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
}
.up-status-name,
.ep-status-name {
  font-weight: 600;
  font-size: 0.78rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
}
.ep-status-grid {
  margin-top: 6px;
}
.up-status-flag {
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--text-muted);
}
/* 状态卡片更紧凑：减小内边距，卡片内顶部一行摘要 */
#upstream-status-card .card-header {
  padding-top: 0.55rem;
}
#upstream-status-card .card-header h2 {
  font-size: 0.95rem;
}
.up-status-summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.05rem 0 0.15rem;
  margin-bottom: 0.1rem;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.07);
}
.up-status-summary b {
  color: #cfd8dc;
  font-weight: 700;
}
.up-status-summary .s-online {
  color: #81c784;
}
.up-status-summary .s-offline {
  color: #e57373;
}
.up-status-summary .s-fast {
  color: #4fc3f7;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}
.upcfg-badge.endpoint-badge {
  background: linear-gradient(180deg, rgba(33, 150, 243, 0.28), rgba(33, 150, 243, 0.16));
  color: #90caf9;
  border: 1px solid rgba(33, 150, 243, 0.45);
}
.ep-source-badge {
  color: #90caf9;
  font-weight: 600;
}
.upstream-badge {
  display: inline-block;
  padding: 0.08rem 0.45rem;
  border-radius: 16px;
  font-size: 0.7rem;
  font-weight: 600;
}
.upstream-detail {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.3rem 0 0;
}
.upstream-field {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 0.8rem;
}
.upstream-field .info-label {
  min-width: 4.5rem;
  flex-shrink: 0;
}
.upstream-field code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.76rem;
  color: #7ab8d4;
  word-break: break-all;
}
.upstream-url {
  color: #6ab4c8 !important;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ── Section Title ── */
.section-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Responsive adjustments ── */
@media (max-width: 1200px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
  .form-row .full-width {
    grid-column: 1 / -1;
  }
}

/* ── Mobile Bottom Nav & Mobile Card Lists (hidden on desktop) ── */
.mobile-bottom-nav {
  display: none;
}
.keys-mobile-list {
  display: none;
}
.ranking-mobile-list {
  display: none;
}
.recent-mobile-list {
  display: none;
}

@media (max-width: 900px) {
  /* 手机端：侧边栏 → 底部固定导航栏 */
  .sidebar {
    display: none !important;
  }
  #admin-screen.active .sidebar {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    top: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    flex-direction: row !important;
    border-right: none !important;
    border-top: 1px solid var(--border);
    z-index: 100;
    padding: 0 !important;
    overflow: visible !important;
    background: rgba(15, 24, 33, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
  .sidebar-brand {
    display: none !important;
  }
  .sidebar-nav {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    padding: 0.2rem 0.3rem !important;
    gap: 0;
    width: 100% !important;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    justify-content: flex-start !important;
  }
  .sidebar-nav::-webkit-scrollbar {
    display: none;
  }
  /* 移动端底部导航：隐藏分组标题，直接平铺展示所有子菜单项 */
  .nav-group-head {
    display: none !important;
  }
  .nav-group {
    display: contents;
  }
  .nav-sub {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 0;
    padding: 0;
  }
  .nav-sub-item {
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.18rem 0.35rem;
    font-size: 0.5rem;
    flex: 0 0 auto;
    justify-content: center;
    text-align: center;
    border-radius: 6px;
    min-height: 44px;
    white-space: nowrap;
  }
  .nav-sub-item .nav-icon {
    font-size: 0.85rem;
    width: auto;
  }
  .nav-sub-item .nav-label {
    display: block !important;
    font-size: 0.48rem;
    line-height: 1.1;
  }
  .nav-item.logout {
    margin-top: 0;
  }

  .main-content {
    margin-left: 0 !important;
    max-width: 100vw !important;
    padding: 0.6rem;
    padding-bottom: 5.5rem !important; /* 底部导航占高约 48px + 间距 */
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.45rem;
  }
  .stat-card {
    padding: 0.7rem 0.5rem;
  }
  .stat-num {
    font-size: 1.4rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
  .form-row .full-width {
    grid-column: 1;
  }
  .form-row .form-row-btn {
    grid-column: 1;
  }
  .create-key-form {
    grid-template-columns: 1fr;
  }
  .create-key-form .full-width {
    grid-column: 1;
  }

  .card {
    padding: 0.7rem;
    margin-bottom: 0.7rem;
  }
  .card-header h2 {
    font-size: 0.72rem;
  }

  .top-bar {
    flex-direction: column;
    gap: 0.4rem;
    align-items: flex-start;
  }
  .top-bar h2 {
    font-size: 0.95rem;
  }

  .upstream-main {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .toast {
    bottom: 5rem;
    max-width: 85vw;
    font-size: 0.8rem;
    padding: 0.6rem 1.2rem;
  }

  /* ── Tables → Card lists (for 600-900px range too) ── */
  #keys-section .keys-table {
    display: none;
  }
  #keys-section .keys-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  #ranking-section table {
    display: none;
  }
  #ranking-section .ranking-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
  }
  #recent-section table {
    display: none;
  }
  #recent-section .recent-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
  }

  .chart-container {
    gap: 0.3rem;
  }
  .chart-bar {
    width: 75%;
    max-width: 28px;
  }
  .chart-count {
    font-size: 0.6rem;
  }
  .chart-label {
    font-size: 0.55rem;
  }

  .login-card {
    width: 92vw;
    padding: 2rem 1.5rem;
  }

  .modal-content {
    max-width: 96vw !important;
    padding: 1rem;
    margin-top: 1vh;
    border-radius: 10px;
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .token-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .code-content {
    font-size: 0.68rem;
    padding: 0.4rem 0.6rem;
  }

  .form-group label {
    font-size: 0.72rem;
  }
  input,
  select {
    font-size: 0.8rem;
    padding: 0.45rem 0.6rem;
  }
  .input-unit-group .unit-select {
    padding: 0.45rem 0.25rem;
    font-size: 0.7rem;
    min-width: 62px;
  }

  .btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }

  #detail-logs-filter {
    width: 100%;
  }
  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .card-header {
    flex-wrap: wrap;
    gap: 0.3rem;
  }
}

@media (max-width: 550px) {
  .sidebar-nav {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    padding: 0.25rem 0.15rem;
    gap: 0.1rem;
    overflow-x: visible !important;
  }
  .nav-sub-item {
    flex: none !important;
    padding: 0.18rem 0.08rem;
    font-size: 0.5rem;
    min-height: 34px;
    gap: 0.05rem;
    width: 100%;
  }
  .nav-sub-item .nav-icon {
    font-size: 0.9rem;
  }
  .nav-sub-item .nav-label {
    font-size: 0.48rem;
    line-height: 1.2;
  }
  /* 8 个项在 4 列 grid 中变为 2 行（4+4），导航约 70-80px */
  .main-content {
    margin-left: 0 !important;
    max-width: 100vw !important;
    padding-bottom: 6rem !important;
  }
}

/* ── Extra small: even tighter ── */
@media (max-width: 400px) {
  .sidebar-nav {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    padding: 0.15rem 0.1rem;
    gap: 0.06rem;
  }
  .nav-sub-item {
    flex: none !important;
    padding: 0.12rem 0.05rem;
    font-size: 0.42rem;
    min-height: 28px;
    gap: 0.03rem;
  }
  .nav-sub-item .nav-icon {
    font-size: 0.72rem;
  }
  .nav-sub-item .nav-label {
    font-size: 0.4rem;
    line-height: 1.1;
  }
  .main-content {
    padding-bottom: 5.5rem !important;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: 0.4rem;
    padding-bottom: 4.5rem !important;
  }
  .card {
    padding: 0.5rem;
    border-radius: 8px;
  }
  .stat-num {
    font-size: 1.1rem;
  }
  .stat-label {
    font-size: 0.6rem;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
  }
  .stat-card {
    padding: 0.5rem 0.3rem;
  }

  .nav-sub-item .nav-icon {
    font-size: 0.85rem;
  }

  .login-card {
    padding: 1.5rem 1rem;
  }
  .login-card .logo {
    font-size: 2.2rem;
  }
  .login-card h1 {
    font-size: 1.2rem;
  }

  .modal-content {
    padding: 0.8rem;
  }
  .modal-content h2 {
    font-size: 0.95rem;
  }

  .detail-grid {
    gap: 0.5rem;
  }
  .info-row {
    font-size: 0.75rem;
    flex-wrap: wrap;
  }
  .info-label {
    min-width: 4rem;
    font-size: 0.72rem;
  }

  .code-content {
    font-size: 0.62rem;
    padding: 0.3rem 0.5rem;
  }
  .code-block-header {
    font-size: 0.65rem;
    padding: 0.25rem 0.5rem;
  }

  .chart-bar {
    max-width: 20px;
  }
  .chart-bar-wrap {
    gap: 0.1rem;
  }

  .stat-value {
    font-size: 1.1rem !important;
  }
}

/* ── Updated Keys Table ── */

/* Status dot column */
.sts-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  vertical-align: middle;
}
.sts-active {
  background: var(--green);
  box-shadow: 0 0 6px rgba(102, 187, 106, 0.5);
}
.sts-revoked {
  background: var(--red);
  box-shadow: 0 0 6px rgba(239, 83, 80, 0.4);
}
.sts-expired {
  background: #5a5a5a;
  box-shadow: 0 0 4px rgba(90, 90, 90, 0.3);
}
.sts-expiring {
  background: var(--orange);
  box-shadow: 0 0 6px rgba(255, 152, 0, 0.4);
  animation: sts-pulse 1.8s ease-in-out infinite;
}
@keyframes sts-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.2);
  }
}

/* Model tag */
.model-tag {
  display: inline-block;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.74rem;
  color: var(--accent);
  background: rgba(79, 195, 247, 0.07);
  padding: 0.08rem 0.4rem;
  border-radius: 3px;
  white-space: nowrap;
}

/* 绑定的上游标签 */
.key-upstream-tag {
  display: inline-block;
  font-size: 0.72rem;
  color: #81c784;
  background: rgba(129, 199, 132, 0.1);
  padding: 0.08rem 0.4rem;
  border-radius: 3px;
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

/* API Keys 列表：上游API 内联下拉列 */
.upstream-cell {
  vertical-align: middle;
}
.upstream-inline-select {
  width: 100%;
  max-width: 118px;
  font-size: 0.72rem;
  padding: 0.2rem 0.3rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  background: var(--bg-2, #1e2530);
  color: #d8e1ec;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.upstream-inline-select:hover:not(:disabled) {
  border-color: var(--accent, #4fc3f7);
}
.upstream-inline-select:disabled {
  opacity: 0.55;
  cursor: wait;
}
.upstream-inline-select option {
  color: #d8e1ec;
  background: #1e2530;
}

/* API Keys 列表：特级上游超时 内联数字输入 */
.premium-timeout-inline {
  width: 100%;
  max-width: 76px;
  font-size: 0.72rem;
  padding: 0.2rem 0.3rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  background: var(--bg-2, #1e2530);
  color: #d8e1ec;
  transition: border-color 0.15s ease;
}
.premium-timeout-inline:hover:not(:disabled) {
  border-color: var(--accent, #4fc3f7);
}
.premium-timeout-inline:disabled {
  opacity: 0.55;
  cursor: wait;
}

/* Mini quota bar */
.ql-mini-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 160px;
  width: 100%;
}
.ql-mini-bar {
  flex: 1;
  height: 5px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
  min-width: 40px;
}
.ql-mini-bar .quota-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.ql-mini-bar .quota-fill.warning {
  background: linear-gradient(90deg, var(--orange), #fb8c00);
}
.ql-mini-bar .quota-fill.danger {
  background: linear-gradient(90deg, var(--red), #e53935);
}

.ql-mini-pct {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.ql-indicator.unlimited {
  color: var(--text-muted);
  font-size: 0.76rem;
}

.muted-xs {
  display: block;
  color: var(--text-muted);
  font-size: 0.68rem;
  margin-top: 0.15rem;
}

/* Action group */
.action-group {
  display: inline-flex;
  gap: 1px;
  align-items: center;
}
.action-group .btn-ghost {
  padding: 0.15rem 0.25rem;
  font-size: 0.85rem;
  line-height: 1;
}

/* Key row hover */
.key-row td {
  vertical-align: middle;
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

/* Expiry never */
.expiry-never {
  color: var(--text-muted);
  font-size: 0.76rem;
}

/* ── Name + Status merged (横排：状态点 + 名称 + badge) ── */
.ns-wrap {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
.ns-wrap .key-name {
  font-size: 0.84rem;
  font-weight: 600;
}

/* ── Key + Model inline ── */
.key-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.key-wrap .key-display {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.key-wrap .key-model {
  display: inline-block;
}
.key-wrap .key-model .model-tag {
  font-size: 0.7rem;
  padding: 0.04rem 0.32rem;
}

/* ── Wrap cell for expiry+concurrency ── */
.wrap-cell {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.ee-row {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ── Last used inline ── */
.last-used {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ── Keys table tighter padding ── */
.keys-table th,
.keys-table td {
  padding: 0.45rem 0.5rem;
  text-align: center;
}
.keys-table td.num-cell {
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}
.keys-table th {
  font-size: 0.68rem;
  white-space: nowrap;
  text-align: center;
}
.keys-table th.sortable {
  cursor: pointer;
  user-select: none;
}
.keys-table th.sortable:hover {
  color: var(--accent, #4fc3f7);
}
.keys-table th .sort-arrow {
  font-size: 0.6rem;
  margin-left: 2px;
  opacity: 0.8;
}

/* ── Keys table: 列宽按内容动态分配（table-layout auto），长文本列保底截断 ── */
.keys-table {
  table-layout: auto;
  width: 100%;
}
.keys-table td:first-child,
.keys-table th:first-child {
  text-align: center;
}

/* Prevent content from pushing column widths */
.keys-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}
.keys-table td.num-cell {
  overflow: visible;
}
.keys-table .key-display {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 长文本列（Key / 名称）保底 max-width，避免 auto 布局下撑破表格 */
.keys-table td:has(.key-wrap),
.keys-table td:has(.ns-wrap) {
  max-width: 220px;
  white-space: nowrap;
}

/* ── Action group positioning ── */
.keys-table .action-cell .action-group {
  display: inline-flex;
  gap: 0;
  align-items: center;
  flex-wrap: nowrap;
}
.keys-table .action-cell .action-group .btn-ghost {
  padding: 0.1rem 0.2rem;
  font-size: 0.82rem;
}

/* ── 清空并发按钮：醒目的橙色边框 + 轻背景 — 在表格 / 卡片上都更显眼 ── */
.btn-clear-conc {
  border: 1px solid rgba(255, 87, 34, 0.35) !important;
  border-radius: 4px !important;
  background: rgba(255, 87, 34, 0.05);
  transition:
    background 0.12s,
    border-color 0.12s;
}
.btn-clear-conc:hover {
  background: rgba(255, 87, 34, 0.18) !important;
  border-color: rgba(255, 87, 34, 0.7) !important;
}
.btn-clear-conc:active {
  background: rgba(255, 87, 34, 0.28) !important;
}
.btn-clear-conc:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Smooth scroll ── */
html {
  scroll-behavior: smooth;
}

/* ── Mobile card list for keys (≤600px) ── */
@media (max-width: 600px) {
  .km-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    transition: border-color 0.12s;
    position: relative;
  }
  .km-card:active {
    border-color: var(--border-light);
  }
  .km-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
  }
  .km-card-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    font-size: 0.82rem;
    min-width: 0;
    flex: 1;
  }
  .km-card-title .key-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .km-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
  }
  .km-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.74rem;
    color: var(--text-secondary);
    gap: 0.4rem;
  }
  .km-row .km-label {
    color: var(--text-muted);
    flex-shrink: 0;
  }
  .km-row .km-value {
    text-align: right;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }
  .km-key-code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
    font-size: 0.68rem;
    color: #7ab8d4;
    background: var(--bg-input);
    padding: 0.08rem 0.35rem;
    border-radius: 3px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
  }
  .km-model-tag {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
    font-size: 0.62rem;
    color: var(--accent);
    background: rgba(79, 195, 247, 0.07);
    padding: 0.04rem 0.3rem;
    border-radius: 3px;
  }
  .km-card-actions {
    display: flex;
    gap: 0.15rem;
    align-items: center;
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 60vw;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .km-card-actions::-webkit-scrollbar {
    display: none;
  }
  .km-card-actions .btn-ghost {
    padding: 0.1rem 0.18rem;
    font-size: 0.75rem;
    flex-shrink: 0;
  }
  .km-quota {
    display: flex;
    align-items: center;
    gap: 0.4rem;
  }
  .km-quota .ql-mini-wrap {
    max-width: 120px;
  }
  .km-quota .ql-mini-pct {
    font-size: 0.62rem;
  }

  /* Ranking mobile card */
  .rm-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.6rem;
  }
  .rm-rank {
    font-weight: 700;
    color: var(--accent);
    width: 1.2rem;
    text-align: center;
    flex-shrink: 0;
    font-size: 0.75rem;
  }
  .rm-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
  }
  .rm-body .km-row {
    font-size: 0.7rem;
  }
  .rm-name {
    font-weight: 500;
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Recent calls mobile card */
  .rc-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.6rem;
  }
  .rc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
  }
  .rc-header .rc-time {
    color: var(--text-muted);
  }
  .rc-body {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
  }
  .rc-body .km-row {
    font-size: 0.7rem;
  }
  .rc-content {
    font-size: 0.67rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    padding: 0.1rem 0;
  }
  .rc-content:hover {
    color: var(--accent);
  }
}

/* ── ===== MOBILE ENHANCEMENTS ===== ── */

/* Better login screen on mobile */
@media (max-width: 768px) {
  #login-screen {
    padding: 1rem;
  }
  .login-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem 1.5rem;
  }
}

@media (max-width: 480px) {
  .login-card {
    padding: 1.5rem 1rem;
    border-radius: 16px;
  }
  .login-card .logo {
    font-size: 2.2rem;
  }
  .login-card h1 {
    font-size: 1.3rem;
  }
  .login-card .subtitle {
    font-size: 0.82rem;
    margin-bottom: 1.2rem;
  }
  .login-card input[type='password'] {
    padding: 0.65rem 0.8rem;
    font-size: 16px; /* prevent iOS zoom */
  }
}

/* Modal full-screen on small devices */
@media (max-width: 600px) {
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal-content {
    margin-top: auto;
    max-width: 100vw !important;
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.2rem 1rem 1.5rem;
    animation: modalSlideUp 0.25s ease;
  }
  @keyframes modalSlideUp {
    from {
      transform: translateY(100%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }
  #edit-modal .modal-content {
    max-width: 100vw !important;
    border-radius: 16px 16px 0 0;
  }
}

/* Better detail modal on mobile */
@media (max-width: 600px) {
  .detail-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  .info-row {
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.35rem 0;
    font-size: 0.8rem;
  }
  .info-label {
    min-width: 4rem;
    font-size: 0.75rem;
  }
  .info-value {
    font-size: 0.8rem;
  }
  .token-summary-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
  }
  .token-summary-grid .stat-value {
    font-size: 1.15rem !important;
  }
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }
  .logs-filter-wrap {
    width: 100%;
  }
  .logs-filter-wrap .input-sm {
    width: 100%;
  }
  .code-block-header {
    flex-direction: column;
    gap: 0.3rem;
    align-items: flex-start;
  }
  .table-sm {
    font-size: 0.68rem;
  }
  .table-sm td,
  .table-sm th {
    padding: 0.25rem 0.35rem;
    font-size: 0.65rem;
  }
  .table-sm td:first-child {
    white-space: nowrap;
  }
}

/* Content preview modal on mobile */
@media (max-width: 600px) {
  #content-modal .modal-content {
    max-height: 85vh;
  }
  #content-modal .modal-content > div:first-of-type {
    max-height: 55vh !important;
    font-size: 0.75rem !important;
  }
}

/* Upstream status better mobile wrapping */
@media (max-width: 600px) {
  .upstream-main {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .upstream-status-text {
    font-size: 0.85rem;
  }
  .upstream-latency {
    font-size: 0.78rem;
  }
  .upstream-badge {
    font-size: 0.65rem;
  }
  .upstream-field {
    flex-wrap: wrap;
    font-size: 0.75rem;
  }
  .upstream-field .info-label {
    min-width: 3.5rem;
  }
}

/* Card hover/active feedback for touch devices */
@media (max-width: 768px) {
  .stat-card:active,
  .km-card:active,
  .rm-card:active,
  .rc-card:active {
    transform: scale(0.98);
    transition: transform 0.08s;
  }
  .card:active {
    border-color: var(--border-light);
  }
}

/* Prevent text size auto-adjust on orientation change */
html {
  -webkit-text-size-adjust: 100%;
}

/* Better input touch targets on mobile */
@media (max-width: 600px) {
  input,
  select,
  .btn {
    font-size: 16px; /* prevent iOS zoom on focus */
  }
  .btn {
    min-height: 38px;
  }
  .btn-sm {
    min-height: 32px;
  }
  .nav-sub-item {
    min-height: 44px; /* Apple HIG minimum */
  }
}

/* Extra small: iPhone SE / 5.8" and below */
@media (max-width: 375px) {
  .main-content {
    padding: 0.3rem;
    padding-bottom: 5rem !important;
  }
  .card {
    padding: 0.4rem;
    margin-bottom: 0.45rem;
  }
  .stat-num {
    font-size: 0.95rem;
  }
  .stat-label {
    font-size: 0.5rem;
  }
  .stats-grid {
    gap: 0.2rem;
  }
  .stat-card {
    padding: 0.35rem 0.2rem;
  }
  .nav-sub-item {
    padding: 0.15rem 0.08rem;
    font-size: 0.45rem;
    min-height: 40px;
  }
  .nav-sub-item .nav-icon {
    font-size: 0.75rem;
  }
  .nav-sub-item .nav-label {
    font-size: 0.42rem;
  }

  .km-card {
    padding: 0.35rem;
  }
  .km-card-title {
    font-size: 0.7rem;
  }
  .km-row {
    font-size: 0.62rem;
  }
  .km-key-code {
    font-size: 0.58rem;
  }
  .km-card-actions .btn-ghost {
    font-size: 0.72rem;
    padding: 0.1rem 0.15rem;
  }

  .rm-card {
    padding: 0.35rem;
  }
  .rm-name {
    font-size: 0.7rem;
  }

  .rc-card {
    padding: 0.35rem;
  }
  .rc-header {
    font-size: 0.6rem;
  }

  .chart-bar {
    max-width: 16px;
  }

  .modal-content {
    padding: 0.8rem 0.6rem;
  }
  .modal-content h2 {
    font-size: 0.85rem;
  }

  .login-card {
    padding: 1.2rem 0.8rem;
  }
  .login-card .logo {
    font-size: 1.8rem;
  }
  .login-card h1 {
    font-size: 1.1rem;
  }

  .form-group label {
    font-size: 0.65rem;
  }
  input,
  select {
    font-size: 14px;
    padding: 0.35rem 0.45rem;
  }
  .input-unit-group .unit-select {
    min-width: 50px;
    font-size: 0.6rem;
  }
  .btn {
    font-size: 0.72rem;
    min-height: 34px;
  }
  .card-header h2 {
    font-size: 0.65rem;
  }
  .top-bar h2 {
    font-size: 0.85rem;
  }

  .upstream-status-text {
    font-size: 0.78rem;
  }
  .upstream-latency {
    font-size: 0.7rem;
  }
  .upstream-badge {
    font-size: 0.6rem;
  }
  .upstream-main {
    gap: 0.3rem;
  }

  .code-content {
    font-size: 0.55rem;
    padding: 0.2rem 0.35rem;
  }
}

/* ── Pagination (inspired by Ant Design / Element UI) ── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 12px 0 4px;
  flex-wrap: nowrap;
}
.pagination .page-size-select {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 2px;
  font-size: 0.76rem;
  cursor: pointer;
  outline: none;
  width: 40px;
  text-align: center;
  text-align-last: center;
  flex-shrink: 0;
}
.pagination .page-size-select:hover {
  border-color: var(--border-light);
  color: var(--text-primary);
}
.page-btn-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  background: transparent;
  color: #b0bec5;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  line-height: 1;
}
.page-btn:hover:not(:disabled) {
  background: rgba(79, 195, 247, 0.08);
  border-color: var(--accent);
  color: var(--accent);
}
.page-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  border-color: var(--border);
}
.page-btn.active {
  background: var(--accent);
  color: #0a1628;
  border-color: var(--accent);
  font-weight: 700;
}
.page-btn.active:hover {
  background: #6ccdf9;
}
.page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  color: #607d8b;
  font-size: 0.8rem;
  letter-spacing: 1px;
  user-select: none;
}

/* ── Mobile pagination ── */
@media (max-width: 700px) {
  .pagination {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    padding: 10px 0 4px;
  }
  .page-btn-group {
    flex-wrap: wrap;
    justify-content: center;
  }
  .page-btn {
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    font-size: 0.75rem;
    border-radius: 5px;
  }
  .page-ellipsis {
    min-width: 18px;
    font-size: 0.75rem;
  }
}

/* ── Quick Create Buttons ── */
.btn-quick {
  background: linear-gradient(135deg, #1a2332, #1e2a3d);
  border: 1px solid #2a3a55;
  color: #e0e6ed;
  padding: 0.6rem 1.2rem;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1 1 auto;
  white-space: nowrap;
  text-align: center;
}
.btn-quick:hover {
  border-color: #4fc3f7;
  background: linear-gradient(135deg, #1e2d45, #243650);
  box-shadow: 0 2px 12px rgba(79, 195, 247, 0.15);
  transform: translateY(-1px);
  color: #fff;
}
.btn-quick:active {
  transform: translateY(0);
}
.btn-quick-green {
  border-color: #2a5540;
  background: linear-gradient(135deg, #14281e, #1a3328);
}
.btn-quick-green:hover {
  border-color: #66bb6a;
  background: linear-gradient(135deg, #1a3328, #204030);
  box-shadow: 0 2px 12px rgba(102, 187, 106, 0.15);
}
.quick-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  grid-column: 1 / -1;
  width: 100%;
}

/* ── Upstream Call Stats ── */
#upstream-stats-card {
  border-left: 3px solid var(--green);
  background: linear-gradient(135deg, var(--bg-card) 0%, #0d1a12 100%);
}
#upstream-stats-card .card-header h2 {
  color: var(--text-secondary);
}
.stats-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-wrap: wrap;
}
.stats-start-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.stats-start-value {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.upstream-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}
.ustat-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 0.8rem 0.6rem;
  text-align: center;
}
.ustat-num {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  word-break: break-all;
}
.ustat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.upstream-stats-note {
  margin-top: 0.8rem;
  font-size: 0.74rem;
  color: var(--text-muted);
  padding: 0.4rem 0.6rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  border-left: 2px solid var(--accent);
}

@media (max-width: 768px) {
  .upstream-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
  }
  .ustat-item {
    padding: 0.6rem 0.4rem;
  }
  .ustat-num {
    font-size: 1rem;
  }
  .stats-meta {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 400px) {
  .page-btn {
    min-width: 26px;
    height: 26px;
    padding: 0 4px;
    font-size: 0.7rem;
  }
}

/* ─────────────────────────────────────────────
   方案 B · 多页面布局补充样式
   ───────────────────────────────────────────── */

/* 折叠菜单：统一分组标题 + 子菜单结构 */
.nav-group-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem 0.3rem;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}
.nav-group-head .nav-group-arrow {
  transition: transform 0.15s;
  font-size: 0.7rem;
  color: var(--text-muted);
  width: 1rem;
  text-align: center;
}
.nav-group:not(.expanded) .nav-group-head .nav-group-arrow {
  transform: rotate(-90deg);
}
.nav-group-head.group-active {
  color: var(--accent);
}

.nav-sub {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.15rem 0 0.4rem;
}
.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition:
    background 0.12s,
    color 0.12s;
}
.nav-sub-item:hover {
  background: rgba(79, 195, 247, 0.06);
  color: var(--text-secondary);
}
.nav-sub-item.active {
  background: var(--accent-glow);
  color: var(--accent);
}
.nav-sub-item .nav-icon {
  font-size: 1.1rem;
  width: 1.6rem;
  text-align: center;
  flex-shrink: 0;
}

/* 面包屑 */
.breadcrumb {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.breadcrumb span + span::before {
  content: ' / ';
  margin: 0 0.35rem;
  opacity: 0.5;
}

/* 总览页快速入口卡片 */
.quick-entries {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.quick-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-primary);
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.15s;
}
.quick-entry:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.quick-entry-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}
.quick-entry-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 2px;
}
.quick-entry-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* 移动端：侧边栏顶到顶部，按钮式折叠 */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -260px;
    transition: left 0.25s;
    z-index: 100;
    height: 100vh;
  }
  .sidebar.open {
    left: 0;
  }
  .main-content {
    margin-left: 0 !important;
  }
  .quick-entries {
    grid-template-columns: 1fr;
  }
}

/* modal-large: 大尺寸弹窗（详情页） */
.modal-content.modal-large {
  max-height: 90vh;
  overflow-y: auto;
}

/* 通用 toast 样式（如果还没） */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 20, 28, 0.95);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 9999;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.2s ease;
  white-space: pre-wrap;
  max-width: 80vw;
  text-align: center;
}
.toast.toast-fade {
  opacity: 0;
  transition: opacity 0.3s;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }
}

/* ════════════════════════════════════════════════════════
   手机端 UI 适配 (≤ 600px)
   在已有的 768px / 900px / 550px 适配之上，
   针对小屏手机做更精细的调整
   ════════════════════════════════════════════════════════ */

@media (max-width: 600px) {
  /* ── Top bar：标题 + 操作按钮 ── */
  .top-bar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0;
  }
  .top-bar h2 {
    font-size: 0.9rem;
  }
  .breadcrumb {
    font-size: 0.7rem;
    flex: 1 1 100%;
    order: 2;
  }
  .top-actions {
    display: flex;
    gap: 0.3rem;
    margin-left: auto;
  }
  .top-actions .btn {
    font-size: 0.7rem;
    padding: 0.3rem 0.5rem;
  }
  .top-actions .btn-outline {
    padding: 0.3rem 0.5rem;
  }

  /* ── Stat cards ── */
  .stat-num {
    font-size: 1.2rem;
  }
  .stat-label {
    font-size: 0.65rem;
  }

  /* ── Forms：更紧凑 ── */
  .form-group label {
    font-size: 0.68rem;
    margin-bottom: 0.2rem;
  }
  input,
  select,
  textarea {
    font-size: 0.82rem;
    padding: 0.4rem 0.55rem;
  }
  .input-unit-group {
    flex-wrap: nowrap;
  }
  .input-unit-group .unit-input {
    min-width: 0;
    flex: 1;
  }
  .input-unit-group .unit-select {
    min-width: 56px;
    padding: 0.4rem 0.2rem;
    font-size: 0.66rem;
  }

  /* 快捷按钮组：竖排或更紧凑 */
  .quick-btn-group {
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
  }
  .quick-btn-group .btn {
    width: 100%;
    padding: 0.5rem;
  }

  /* ── Cards ── */
  .card {
    padding: 0.6rem 0.7rem;
    margin-bottom: 0.6rem;
  }
  .card-header h2 {
    font-size: 0.7rem;
  }
  .card-header {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  /* ── API Keys 列表行（key-row）：变小 ── */
  .keys-table {
    display: none;
  }
  .keys-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }
  .km-card {
    padding: 0.6rem;
    font-size: 0.75rem;
  }
  .km-card .km-row {
    font-size: 0.72rem;
    padding: 2px 0;
  }
  .km-card .km-row .km-label {
    width: 65px;
    font-size: 0.66rem;
  }
  .km-card .km-actions {
    flex-wrap: wrap;
    gap: 0.25rem;
  }
  .km-card .km-actions .btn {
    padding: 0.25rem 0.4rem;
    font-size: 0.7rem;
  }

  /* 通用 action-group：换行 */
  .action-group {
    flex-wrap: wrap;
    gap: 0.2rem;
    max-width: 100%;
  }
  .action-group .btn {
    padding: 0.25rem 0.4rem;
    font-size: 0.75rem;
    flex: 0 0 auto;
  }
  .action-group .btn-ghost {
    min-width: 30px;
  }

  /* ── 表格转卡片列表 ── */
  #ranking-section table,
  #recent-section table {
    display: none;
  }
  #ranking-section .ranking-mobile-list,
  #recent-section .recent-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
  }
  .rm-card,
  .rc-card {
    padding: 0.5rem 0.6rem;
    font-size: 0.72rem;
    border-radius: 8px;
  }
  .rm-row,
  .rc-row {
    font-size: 0.7rem;
    padding: 2px 0;
  }

  /* ── Chart ── */
  .chart-container {
    gap: 0.2rem;
    padding: 0.4rem 0.2rem;
  }
  .chart-bar-wrap {
    min-width: 12px;
  }
  .chart-bar {
    width: 70%;
    max-width: 22px;
  }
  .chart-count {
    font-size: 0.55rem;
  }
  .chart-label {
    font-size: 0.5rem;
    writing-mode: horizontal-tb;
  }

  /* ── Modal：内容挤 ── */
  .modal-content {
    max-width: 100vw !important;
    width: 100vw !important;
    height: 100vh;
    max-height: 100vh !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0.8rem !important;
  }
  .modal-overlay {
    padding: 0 !important;
    align-items: stretch !important;
  }
  .modal-close {
    font-size: 1.3rem;
    padding: 0.2rem 0.5rem;
  }
  .modal-content h2 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
  }

  /* Detail modal：section padding 缩小 */
  .detail-section {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
  }
  .detail-section h3 {
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
  }
  .info-row {
    font-size: 0.72rem;
    padding: 0.25rem 0;
    flex-wrap: wrap;
    gap: 0.3rem;
  }
  .info-label {
    width: 80px;
    flex: 0 0 80px;
    font-size: 0.68rem;
  }
  .info-value {
    font-size: 0.72rem;
    word-break: break-all;
  }
  .code-block {
    font-size: 0.65rem;
  }
  .code-content {
    font-size: 0.62rem;
    padding: 0.4rem 0.5rem;
    word-break: break-all;
  }
  .code-pre {
    font-size: 0.6rem;
    white-space: pre-wrap;
    word-break: break-all;
  }

  /* stats-grid 内的 token 用量明细 */
  .token-summary-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
  }
  .token-summary-grid .stat-card {
    padding: 0.5rem 0.3rem;
  }
  .token-summary-grid .stat-value {
    font-size: 0.95rem;
  }
  .token-summary-grid .stat-label {
    font-size: 0.6rem;
  }

  /* 调用记录表格 */
  .table-sm {
    font-size: 0.7rem;
  }
  .table-sm th,
  .table-sm td {
    padding: 0.25rem 0.3rem;
  }

  /* Pagination：紧凑 */
  .pagination {
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.4rem 0;
  }
  .page-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.72rem;
  }

  /* 上游 API 状态行 */
  .upstream-main {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .upstream-status-text {
    font-size: 0.85rem;
  }
  .upstream-latency {
    font-size: 0.78rem;
  }
  .upstream-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
  }

  /* 上游统计 grid */
  .upstream-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
  }
  .ustat-item {
    padding: 0.5rem 0.4rem;
  }
  .ustat-num {
    font-size: 0.95rem;
  }
  .ustat-label {
    font-size: 0.6rem;
  }

  /* 输入框 placeholder 调整 */
  input::placeholder {
    font-size: 0.72rem;
  }

  /* toast：往上挪，避免被底部导航挡住 */
  .toast {
    bottom: 4.5rem;
    max-width: 92vw;
    font-size: 0.78rem;
    padding: 0.5rem 0.9rem;
  }

  /* Quick entries：单列 */
  .quick-entries {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  .quick-entry {
    padding: 0.7rem 0.8rem;
  }
  .quick-entry-icon {
    font-size: 1.3rem;
  }
  .quick-entry-title {
    font-size: 0.85rem;
  }
  .quick-entry-desc {
    font-size: 0.7rem;
  }

  /* Login card */
  .login-card {
    padding: 1.5rem 1.2rem;
  }
  .login-card h1 {
    font-size: 1.2rem;
  }
  .login-card .logo {
    font-size: 2.5rem;
  }

  /* 趋势范围按钮组 */
  .trend-range-btns {
    gap: 0.2rem;
    flex-wrap: wrap;
  }
  .trend-range-btns .btn {
    padding: 0.3rem 0.5rem;
    font-size: 0.72rem;
  }
}

/* ════════════════════════════════════════════════════════
   超窄屏 (≤ 380px)：进一步压缩
   ════════════════════════════════════════════════════════ */

@media (max-width: 380px) {
  .top-actions .btn {
    font-size: 0.62rem;
    padding: 0.22rem 0.4rem;
  }
  .top-actions .btn-outline .icon-keep {
    display: none;
  }
  .stat-num {
    font-size: 1rem;
  }
  .stat-label {
    font-size: 0.55rem;
  }
  .upstream-stats-grid {
    grid-template-columns: 1fr;
  }
  .token-summary-grid {
    grid-template-columns: 1fr;
  }
  .action-group .btn {
    padding: 0.2rem 0.35rem;
    font-size: 0.7rem;
  }
  .info-label {
    width: 70px;
    flex: 0 0 70px;
  }
}

/* ════════════════════════════════════════════════════════
   横向手机 / 平板小屏 (481px - 768px)
   介于手机和桌面之间
   ════════════════════════════════════════════════════════ */

@media (min-width: 481px) and (max-width: 768px) {
  /* 中等屏：3 列 stat */
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  /* token 配额 grid 4 列 */
  .token-summary-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .upstream-stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  /* modal 不要全屏 */
  .modal-content {
    max-width: 90vw !important;
    height: auto !important;
    max-height: 90vh !important;
    border-radius: 10px !important;
    margin: 2vh auto !important;
  }
  .modal-overlay {
    padding: 1rem !important;
  }
}

/* ═══════════ 上游配置管理面板（calls-upstream） ═══════════ */
.upcfg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.upcfg-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.upcfg-item {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  padding: 10px 14px 12px 18px;
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s, transform 0.2s;
}
.upcfg-item:hover {
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.24);
}
/* 左侧状态色条：激活为渐变绿，未激活为灰 */
.upcfg-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: rgba(158, 158, 158, 0.35);
  border-radius: 14px 0 0 14px;
}
.upcfg-item.active {
  border-color: rgba(76, 175, 80, 0.5);
  background: linear-gradient(180deg, rgba(76, 175, 80, 0.08), rgba(76, 175, 80, 0.03));
  box-shadow: inset 0 0 0 1px rgba(76, 175, 80, 0.16), 0 4px 18px rgba(0, 0, 0, 0.18);
}
.upcfg-item.active::before {
  background: linear-gradient(180deg, #66bb6a, #43a047);
}
.upcfg-row1 {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.upcfg-name {
  font-weight: 700;
  color: #f0f0f0;
  font-size: 14px;
  letter-spacing: 0.3px;
}
.upcfg-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.upcfg-meta-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
  font-size: 12.5px;
  line-height: 1.3;
}
.upcfg-meta-label {
  color: #8f8f8f;
  flex-shrink: 0;
  min-width: 82px;
  font-weight: 500;
}
.upcfg-meta-item > span:last-child {
  color: #ddd;
  word-break: normal;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* 宽屏：卡片内 信息区 + 配置/操作区 横向两栏 */
.upcfg-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(430px, 620px);
  gap: 14px;
  margin-top: 8px;
  align-items: start;
}
.upcfg-info {
  min-width: 0;
}
.upcfg-aside {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding-left: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}
@media (max-width: 860px) {
  .upcfg-body {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .upcfg-aside {
    padding-left: 0;
    border-left: none;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
  .upcfg-meta-item {
    flex-direction: column;
    gap: 2px;
  }
  .upcfg-meta-label {
    min-width: 0;
  }
}
.upcfg-badge {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 12px;
  font-weight: 600;
}
.upcfg-badge.active-badge {
  background: linear-gradient(180deg, rgba(76, 175, 80, 0.28), rgba(76, 175, 80, 0.18));
  color: #81c784;
  border: 1px solid rgba(76, 175, 80, 0.4);
}
.upcfg-badge.inactive-badge {
  background: rgba(158, 158, 158, 0.15);
  color: #9e9e9e;
  border: 1px solid rgba(158, 158, 158, 0.25);
}
.upcfg-badge.primary-badge {
  background: linear-gradient(180deg, rgba(66, 133, 244, 0.28), rgba(66, 133, 244, 0.18));
  color: #82b1ff;
  border: 1px solid rgba(66, 133, 244, 0.4);
}
.upcfg-badge.backup-badge {
  background: linear-gradient(180deg, rgba(255, 152, 0, 0.28), rgba(255, 152, 0, 0.18));
  color: #ffb74d;
  border: 1px solid rgba(255, 152, 0, 0.4);
}
.upcfg-badge.persona-badge {
  background: linear-gradient(180deg, rgba(186, 104, 200, 0.3), rgba(186, 104, 200, 0.18));
  color: #ce93d8;
  border: 1px solid rgba(186, 104, 200, 0.45);
}
/* 上游卡片编辑表单：人设开关行 */
.upcfg-form-checkbox {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.upcfg-form-checkbox input[type='checkbox'] {
  accent-color: var(--accent, #4caf50);
  width: 16px;
  height: 16px;
}
/* ── 上游配置管理 主/备 Tab ── */
.upcfg-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin: 0 1rem 1rem;
  padding: 0;
}
.upcfg-tab {
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px 8px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.upcfg-tab:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}
.upcfg-tab.active {
  color: var(--text-primary);
  background: var(--bg-card);
  border-color: var(--border);
  border-bottom-color: var(--bg-card);
  position: relative;
  top: 1px;
}
.upcfg-tab-cnt {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(127, 127, 127, 0.18);
  color: var(--text-secondary);
  font-weight: 600;
}
.upcfg-tab.active .upcfg-tab-cnt {
  background: rgba(66, 133, 244, 0.25);
  color: #82b1ff;
}
.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: auto;
  box-shadow: none;
}

.upcfg-detail {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.upcfg-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 6px;
}
.upcfg-detail-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 4px 9px;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.upcfg-detail-item:hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}
.upcfg-detail-label {
  color: #a0a0a0;
  flex-shrink: 0;
  font-weight: 500;
  white-space: nowrap;
}
.upcfg-detail-value {
  color: #ececec;
  word-break: normal;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.upcfg-detail-value.upcfg-url {
  color: #4fc3f7;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  word-break: break-all;
}
.upcfg-detail-missing {
  color: #e57373;
  font-weight: 500;
}
.upcfg-mult-value {
  color: #ffd54f;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.upcfg-mult-btn {
  padding: 2px 9px;
  font-size: 11px;
  line-height: 1.45;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  color: #ccc;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.upcfg-mult-btn:hover {
  background: var(--accent-glow, rgba(102, 126, 234, 0.25));
  border-color: rgba(102, 126, 234, 0.5);
  color: #fff;
}
.upcfg-quick-input {
  width: 84px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(102, 126, 234, 0.4);
  color: #eee;
  font-size: 12px;
}
.upcfg-quick-input:focus {
  outline: none;
  border-color: #667eea;
}
.upcfg-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 7px 10px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}
.upcfg-actions .btn-sm {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.3rem 0.6rem;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
}
.upcfg-actions .btn-sm:hover {
  background: var(--accent-glow);
  transform: translateY(-1px);
}
.upcfg-form {
  margin-top: 14px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.upcfg-form label {
  font-size: 12px;
  color: #aaa;
  margin-bottom: 2px;
  display: block;
}
.upcfg-form-hint {
  font-size: 12px;
  line-height: 1.6;
  color: #9bb8d3;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(33, 150, 243, 0.08);
  border: 1px dashed rgba(33, 150, 243, 0.35);
}
.upcfg-form-hint .upcfg-url {
  color: #4fc3f7;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  word-break: break-all;
}
.upcfg-form input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #eee;
  font-size: 13px;
}
.upcfg-form input:focus {
  outline: none;
  border-color: #667eea;
}
.upcfg-form-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.upcfg-form-row .grow {
  flex: 1;
  min-width: 180px;
}
.upcfg-empty {
  padding: 24px;
  text-align: center;
  color: #888;
}
.upcfg-test-result {
  font-size: 12px;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
}
.upcfg-test-result.ok {
  background: rgba(76, 175, 80, 0.12);
  color: #81c784;
}
.upcfg-test-result.err {
  background: rgba(244, 67, 54, 0.12);
  color: #e57373;
}
.upcfg-note {
  font-size: 11px;
  color: #8a8a8a;
  margin-top: 12px;
  line-height: 1.7;
  padding: 10px 12px;
  background: rgba(79, 195, 247, 0.06);
  border-left: 3px solid rgba(79, 195, 247, 0.5);
  border-radius: 6px;
}

/* 上游卡片内独立调用统计 */
.upcfg-stats {
  margin-top: 6px;
  padding: 7px 11px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 12px;
  color: #888;
}
.upcfg-stats-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  color: #aaa;
  cursor: pointer;
  user-select: none;
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: 8px;
  transition: background 0.15s;
}
.upcfg-stats-head:hover {
  background: rgba(255, 255, 255, 0.04);
}
.upcfg-stats-arrow {
  transition: transform 0.15s;
  font-size: 13px;
  color: #999;
}
.upcfg-stats-title {
  font-weight: 600;
  font-size: 12px;
}
.upcfg-stats-hint {
  font-size: 11px;
  color: #666;
  margin-right: auto;
}
.upcfg-stats-head .btn {
  margin-left: 0;
}
.upcfg-stats-body {
  margin-top: 8px;
}
.upcfg-stats-grid {
  margin-bottom: 0;
}
.upcfg-stats-meta {
  font-size: 11px;
  color: #777;
  margin-top: 4px;
  padding-top: 5px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.upcfg-stats-err {
  color: #e57373;
  font-size: 12px;
}

/* 卡片内统计网格（列数与列宽随内容/容器宽度自动变化） */
.upcfg-stats .upstream-stats-grid {
  grid-template-columns: repeat(auto-fill, minmax(min-content, max-content));
  grid-auto-flow: dense;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}
.upcfg-stats .ustat-item {
  padding: 0.35rem 0.25rem;
  border-radius: 7px;
}
.upcfg-stats .ustat-num {
  font-size: 0.85rem;
}
.upcfg-stats .ustat-label {
  font-size: 0.55rem;
  margin-top: 0.1rem;
}

@media (max-width: 640px) {
  .upcfg-stats .upstream-stats-grid {
    grid-template-columns: repeat(auto-fill, minmax(min-content, max-content));
    grid-auto-flow: dense;
    justify-content: space-between;
    gap: 0.4rem 0.8rem;
  }
  .upcfg-stats-hint {
    display: none;
  }
}

/* ═══════════ 独立端点配置区（上游 API 管理页）    ═══════════ */
.ep-status-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0 0.1rem;
}
.ep-status-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}
.ep-status-wrap {
  padding: 0.3rem 0;
}
.ep-status-empty {
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 0.3rem 0;
}
.ep-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 6px;
}
.ep-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 14px;
  transition: border-color 0.2s, background 0.2s;
}
.ep-item:hover {
  border-color: rgba(33, 150, 243, 0.35);
}
.ep-row1 {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.ep-name {
  font-weight: 700;
  color: #f0f0f0;
  font-size: 14px;
}
.ep-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  font-size: 13px;
}
/* 端点选择弹层（上游卡片「切换端点」） */
.ep-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  padding: 20px;
}
.ep-picker {
  width: 100%;
  max-width: 460px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.ep-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.ep-picker-title {
  font-weight: 700;
  color: #f0f0f0;
  font-size: 14px;
}
.ep-picker-list {
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ep-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.ep-picker-item:hover {
  border-color: rgba(33, 150, 243, 0.5);
  background: rgba(33, 150, 243, 0.1);
}
.ep-picker-item .ep-name {
  font-weight: 600;
  font-size: 13px;
}
.ep-picker-item .ep-url {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 12px;
}
.ep-picker-item .ep-key {
  font-size: 11px;
  flex-shrink: 0;
  color: #90caf9;
}
.ep-picker-foot {
  padding: 10px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: var(--text-muted);
}
/* 表单中的下拉框统一样式（base/端点绑定等） */
.upcfg-form select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #eee;
  font-size: 13px;
}
.upcfg-form select:focus {
  outline: none;
  border-color: #667eea;
}

/* ═══════════ 系统配置页（sysconfig） ═══════════ */
#syscfg-body .card {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
#syscfg-body .card:hover {
  border-color: var(--border-light);
}

/* 顶部版本卡片 */
.syscfg-version {
  margin-bottom: 18px;
  background: linear-gradient(
    135deg,
    var(--bg-card-hover) 0%,
    var(--bg-card) 100%
  );
}
.syscfg-version .card-header h2 .syscfg-ver-badge {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.04em;
}
.syscfg-versionspan {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--accent-glow);
  box-shadow: inset 0 0 0 1px rgba(79, 195, 247, 0.25);
}
.syscfg-versionspan .syscfg-ver-badge {
  font-size: 15px;
}
.syscfg-ip {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 8px;
  background: var(--bg-card-hover);
  box-shadow: inset 0 0 0 1px var(--border-light);
}

.syscfg-loading,
.syscfg-err {
  padding: 28px 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}
.syscfg-loading {
  letter-spacing: 0.02em;
}
.syscfg-err {
  color: var(--red);
}

/* 状态徽章 */
.syscfg-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1;
}
.syscfg-status.on {
  background: var(--accent-glow);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(79, 195, 247, 0.25);
}
.syscfg-status.off {
  background: rgba(158, 158, 158, 0.12);
  color: var(--text-muted);
  box-shadow: inset 0 0 0 1px rgba(158, 158, 158, 0.18);
}

/* 全局限流卡片 —— 头部状态组 */
.syscfg-rate-head {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
/* 配置来源徽章 */
.syscfg-rate-source {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1;
}
.syscfg-rate-source.db {
  background: rgba(102, 187, 106, 0.14);
  color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(102, 187, 106, 0.3);
}
.syscfg-rate-source.env {
  background: rgba(255, 152, 0, 0.13);
  color: var(--orange);
  box-shadow: inset 0 0 0 1px rgba(255, 152, 0, 0.3);
}
.syscfg-rate-source.def {
  background: rgba(158, 158, 158, 0.1);
  color: var(--text-muted);
  box-shadow: inset 0 0 0 1px rgba(158, 158, 158, 0.18);
}
/* 来源说明行 */
.syscfg-rate-scope {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.7;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
/* 限流命中计数 */
.syscfg-rate-hit {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.syscfg-rate-hit b {
  color: var(--orange);
  font-weight: 700;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}

/* 卡片说明文字 */
.syscfg-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
  margin: 12px 0 18px;
  padding: 10px 14px;
  border-left: 3px solid var(--accent);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.syscfg-desc code,
.syscfg-note-warn code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* 表单字段行 */
.syscfg-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 4px;
  border-top: 1px solid var(--border);
  transition: background 0.15s;
}
.syscfg-field:first-child {
  border-top: none;
}
.syscfg-field:hover {
  background: rgba(255, 255, 255, 0.015);
}
.syscfg-field-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}
.syscfg-field-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.6;
  margin-top: 1px;
}

/* 数字/文本输入 */
.syscfg-num {
  width: 150px;
  text-align: right;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 14px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.syscfg-num:hover {
  border-color: var(--border-light);
}
.syscfg-num:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* 汇总信息条 */
.syscfg-summary {
  margin-top: 16px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-glow);
  border: 1px solid rgba(79, 195, 247, 0.18);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
}
.syscfg-summary b {
  color: var(--accent);
  font-weight: 700;
}

/* 按钮操作区 */
.syscfg-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
  flex-wrap: wrap;
}
.syscfg-actions .btn {
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* 上游 400 上下文修复卡片 —— 分组面板（①② 两类场景） */
#syscfg-repair-card .syscfg-group {
  margin-top: 18px;
  padding: 15px 18px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.015);
}
#syscfg-repair-card .group-tool {
  border-top: 2px solid rgba(102, 187, 106, 0.55);
}
#syscfg-repair-card .group-thinking {
  border-top: 2px solid rgba(79, 195, 247, 0.55);
}
#syscfg-repair-card .syscfg-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
#syscfg-repair-card .syscfg-group-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}
#syscfg-repair-card .syscfg-group-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 800;
  color: var(--bg-primary);
  flex-shrink: 0;
}
#syscfg-repair-card .group-tool .syscfg-group-num {
  background: var(--green);
}
#syscfg-repair-card .group-thinking .syscfg-group-num {
  background: var(--accent);
}
#syscfg-repair-card .syscfg-group-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1;
}
#syscfg-repair-card .syscfg-group-badge.on {
  background: rgba(102, 187, 106, 0.14);
  color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(102, 187, 106, 0.3);
}
#syscfg-repair-card .syscfg-group-badge.off {
  background: rgba(158, 158, 158, 0.1);
  color: var(--text-muted);
  box-shadow: inset 0 0 0 1px rgba(158, 158, 158, 0.18);
}
#syscfg-repair-card .syscfg-group-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 8px 0 14px;
  padding: 10px 12px;
  border-left: 3px solid var(--border-light);
  background: rgba(255, 255, 255, 0.015);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
#syscfg-repair-card .syscfg-group-desc code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 11.5px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
#syscfg-repair-card .syscfg-err-chip {
  display: inline-block;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 11.5px;
  background: rgba(239, 83, 80, 0.08);
  color: var(--red);
  border: 1px solid rgba(239, 83, 80, 0.22);
  padding: 1px 6px;
  border-radius: 4px;
}
/* 分组内表单行紧凑化 + 修复 global select width:100% 过宽问题 */
#syscfg-repair-card .syscfg-field {
  padding: 12px 4px;
}
#syscfg-repair-card select {
  width: min(460px, 62%);
  flex-shrink: 0;
  padding: 9px 12px;
  font-size: 13px;
  text-align: left;
}

/* 流式大卡片 —— 分组面板（①②③ 收尾 / 输出 / 重试） */
#syscfg-stream-card .syscfg-group {
  margin-top: 16px;
  padding: 15px 18px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.015);
}
#syscfg-stream-card .syscfg-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
#syscfg-stream-card .syscfg-group-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}
#syscfg-stream-card .syscfg-group-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 800;
  color: var(--bg-primary);
  flex-shrink: 0;
  background: var(--accent);
}
#syscfg-stream-card .syscfg-group-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1;
}
#syscfg-stream-card .syscfg-group-badge.on {
  background: rgba(102, 187, 106, 0.14);
  color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(102, 187, 106, 0.3);
}
#syscfg-stream-card .syscfg-group-badge.off {
  background: rgba(158, 158, 158, 0.1);
  color: var(--text-muted);
  box-shadow: inset 0 0 0 1px rgba(158, 158, 158, 0.18);
}
#syscfg-stream-card .syscfg-group-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 8px 0 14px;
  padding: 10px 12px;
  border-left: 3px solid var(--border-light);
  background: rgba(255, 255, 255, 0.015);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
#syscfg-stream-card .syscfg-group-desc code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 11.5px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
#syscfg-stream-card .syscfg-field {
  padding: 12px 4px;
}

/* 分区小标题 */
.syscfg-section-title {
  margin: 22px 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.syscfg-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
  margin-left: 6px;
}

/* 环境变量警告条 */
.syscfg-note-warn {
  margin-top: 16px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 152, 0, 0.08);
  border: 1px solid rgba(255, 152, 0, 0.22);
  font-size: 13px;
  color: var(--orange);
  line-height: 1.7;
}
.syscfg-note-warn code {
  color: var(--orange);
}

/* 记录区图表标题行 */
#syscfg-retry-card h3 {
  letter-spacing: 0.05em;
}
#syscfg-retry-card .btn-sm {
  font-weight: 500;
}
#syscfg-retry-card h3.syscfg-section-title[style*="margin:0"]::after {
  display: none;
}

/* 记录区表格精致化 */
#syscfg-retry-card .table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-input);
}
#syscfg-retry-card .table-sm {
  width: 100%;
  border-collapse: collapse;
}
#syscfg-retry-card .table-sm thead th {
  background: var(--bg-card-hover);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: center;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
#syscfg-retry-card .table-sm tbody td {
  padding: 0.5rem 0.6rem;
  font-size: 0.76rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  text-align: center;
}
#syscfg-retry-card .table-sm tbody tr:last-child td {
  border-bottom: none;
}
#syscfg-retry-card .table-sm tbody tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}
#syscfg-retry-card .time-cell {
  color: var(--text-muted);
  white-space: nowrap;
  font-size: 0.72rem;
}
#syscfg-retry-card .num-cell {
  color: var(--text-secondary);
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}

/* 开关 switch */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid var(--border-light);
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.switch .slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s;
}
.switch input:checked + .slider {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.switch input:checked + .slider::before {
  transform: translateX(22px);
}
.switch input:disabled + .slider {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (max-width: 640px) {
  .syscfg-field {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .syscfg-num {
    width: 100%;
    text-align: left;
  }
  .syscfg-actions {
    flex-direction: column;
  }
  .syscfg-actions .btn {
    width: 100%;
  }
}

/* ── 报错管理：手机端表格转卡片 ── */
@media (max-width: 900px) {
  #err-logs-table {
    display: none;
  }
  #err-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 0.3rem;
  }
  #err-mobile-list .err-card .rc-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
  }
  #err-mobile-list .err-card .rc-row > span:first-child {
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 2.2rem;
  }
  #err-mobile-list .err-card .rc-row > span:last-child {
    text-align: right;
    word-break: break-all;
    color: var(--text);
    flex: 1;
  }
}

/* ── 系统配置：顶部 Tab 页切换 ── */
.syscfg-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  margin: 0 1rem 1rem;
  padding-bottom: 0;
}
.syscfg-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px 8px 0 0;
  white-space: nowrap;
}
.syscfg-tab:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}
.syscfg-tab.active {
  color: var(--text-primary);
  background: var(--bg-card);
  border-color: var(--border);
  border-bottom-color: var(--bg-card);
  position: relative;
  top: 1px;
}

/* ═══════════ 数据库监控卡片（sysconfig 系统信息） ═══════════ */
#syscfg-dbmon-card .dbmon-badge {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
}
#syscfg-dbmon-card .dbmon-badge--ok {
  color: var(--green);
  background: rgba(102, 187, 106, 0.12);
  box-shadow: inset 0 0 0 1px rgba(102, 187, 106, 0.3);
}
#syscfg-dbmon-card .dbmon-badge--warn {
  color: var(--orange);
  background: rgba(255, 152, 0, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 152, 0, 0.35);
}
.dbmon-val--warn {
  color: var(--orange) !important;
}

/* 概览横幅 */
.dbmon-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--bg-card-hover), var(--bg-card));
  margin-bottom: 10px;
}
#syscfg-dbmon-card .dbmon-hero--ok {
  border-color: rgba(102, 187, 106, 0.35);
}
#syscfg-dbmon-card .dbmon-hero--warn {
  border-color: rgba(255, 152, 0, 0.45);
}
.dbmon-hero__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}
.dbmon-hero__title b {
  color: var(--accent);
  font-family: 'SFMono-Regular', Consolas, monospace;
}
.dbmon-hero__sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.dbmon-hero__right {
  text-align: right;
  flex-shrink: 0;
}
.dbmon-hero__ping {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.dbmon-hero__ping b {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'SFMono-Regular', Consolas, monospace;
}

/* 占用进度条 */
.dbmon-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 14px;
}
.dbmon-bar__fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* 分组标题 */
.dbmon-group {
  margin-top: 14px;
}
.dbmon-group__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.dbmon-group__hint {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
}

/* 连接池建议提示条 */
.dbmon-tip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  margin-top: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card-hover);
  line-height: 1.5;
}
.dbmon-tip--solid {
  border-color: rgba(102, 187, 106, 0.35);
  background: rgba(102, 187, 106, 0.06);
}
.dbmon-tip--tight {
  border-color: rgba(255, 152, 0, 0.5);
  background: rgba(255, 152, 0, 0.08);
}
.dbmon-tip__icon {
  font-size: 1.05rem;
  line-height: 1.3;
  flex-shrink: 0;
}
.dbmon-tip__body {
  font-size: 0.82rem;
  color: var(--text-primary);
}
.dbmon-tip__body code {
  color: var(--accent);
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.75rem;
}
.dbmon-tip__body b {
  color: var(--accent);
  font-family: 'SFMono-Regular', Consolas, monospace;
}
.dbmon-tip--tight .dbmon-tip__body b {
  color: var(--orange);
}
.dbmon-tip__hint {
  display: block;
  margin-top: 4px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* 指标小方块 */
.dbmon-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.dbmon-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  transition: border-color 0.15s, transform 0.15s;
}
.dbmon-tile:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
}
.dbmon-tile__label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 3px;
  white-space: nowrap;
}
.dbmon-tile__value {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'SFMono-Regular', Consolas, monospace;
  line-height: 1.3;
  word-break: break-all;
}
.dbmon-tile__sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 3px;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .dbmon-tiles {
    grid-template-columns: repeat(2, 1fr);
  }
  .dbmon-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .dbmon-hero__right {
    text-align: left;
  }
}

