/* ==========================================================================
   CF AI Proxy · 管理控制台样式
   ========================================================================== */

:root {
  color-scheme: dark;
  --bg: #080c17;
  --bg-soft: #0d1424;
  --panel: #111a2e;
  --panel-2: #16213a;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e7eefb;
  --text-dim: #93a5c4;
  --text-faint: #64748b;
  --accent: #5b8cff;
  --accent-2: #22d3ee;
  --success: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 48px rgba(2, 6, 23, 0.55);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(1100px 520px at 12% -8%, rgba(91, 140, 255, 0.16), transparent 62%),
    radial-gradient(900px 460px at 96% 4%, rgba(34, 211, 238, 0.12), transparent 58%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', 'Noto Sans CJK SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

code,
.mono {
  font-family: ui-monospace, 'SF Mono', Consolas, 'Courier New', monospace;
  font-size: 12.5px;
}

/* ----------------------------- 登录页 ----------------------------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 34px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.5px;
  color: #06101f;
  margin-bottom: 18px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 21px;
  letter-spacing: 0.3px;
}

.login-card p.hint {
  margin: 0 0 24px;
  color: var(--text-dim);
  font-size: 13px;
}

/* ----------------------------- 布局 ----------------------------- */

.layout {
  display: grid;
  grid-template-columns: 236px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 55%);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 6px;
}

.sidebar .brand .logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  color: #06101f;
  flex: none;
}

.sidebar .brand .title {
  font-weight: 650;
  font-size: 14.5px;
  line-height: 1.3;
}

.sidebar .brand .sub {
  font-size: 11.5px;
  color: var(--text-faint);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav button {
  all: unset;
  cursor: pointer;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav button:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.nav button.active {
  background: linear-gradient(90deg, rgba(91, 140, 255, 0.22), rgba(91, 140, 255, 0.06));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(91, 140, 255, 0.32);
}

.nav .ico {
  width: 16px;
  text-align: center;
  opacity: 0.85;
  font-size: 13px;
}

.sidebar .foot {
  margin-top: auto;
  font-size: 11.5px;
  color: var(--text-faint);
  padding: 0 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.main {
  padding: 26px 30px 60px;
  min-width: 0;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.page-head h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.3px;
}

.page-head p {
  margin: 3px 0 0;
  color: var(--text-dim);
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
}

/* ----------------------------- 组件 ----------------------------- */

.btn {
  all: unset;
  cursor: pointer;
  padding: 8px 15px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 13px;
  transition: all 0.16s ease;
  white-space: nowrap;
  text-align: center;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.28);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #4f7ff5);
  border-color: transparent;
  color: #fff;
  font-weight: 560;
  box-shadow: 0 8px 22px rgba(91, 140, 255, 0.28);
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn.danger {
  color: #ffd9d9;
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.1);
}

.btn.danger:hover {
  background: rgba(248, 113, 113, 0.2);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-dim);
  padding: 6px 10px;
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}

.btn.sm {
  padding: 5px 11px;
  font-size: 12.5px;
  border-radius: 8px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: rgba(6, 11, 22, 0.65);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(91, 140, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.16);
}

textarea {
  resize: vertical;
  min-height: 84px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
}

label.field {
  display: block;
  margin-bottom: 14px;
}

label.field > span,
.field > label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--text-dim);
}

label.field .desc {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 5px;
  line-height: 1.55;
}

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

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 16px;
}

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
}

.card h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.card > p.sub {
  margin: 0 0 16px;
  color: var(--text-dim);
  font-size: 12.5px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.stat .k {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat .v {
  font-size: 25px;
  font-weight: 640;
  letter-spacing: 0.4px;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.stat .x {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 2px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  font-weight: 560;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

.table-wrap {
  overflow-x: auto;
  margin: 0 -22px;
  padding: 0 22px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 560;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill.ok {
  color: #a7f3d0;
  background: rgba(52, 211, 153, 0.13);
  border-color: rgba(52, 211, 153, 0.3);
}

.pill.off {
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 0.26);
}

.pill.err {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.14);
  border-color: rgba(248, 113, 113, 0.32);
}

.pill.warn {
  color: #fde68a;
  background: rgba(251, 191, 36, 0.13);
  border-color: rgba(251, 191, 36, 0.3);
}

.pill.info {
  color: #bfdbfe;
  background: rgba(91, 140, 255, 0.15);
  border-color: rgba(91, 140, 255, 0.32);
}

.switch {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.28);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  transition: background 0.18s ease;
  flex: none;
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e2e8f5;
  transition: transform 0.18s ease;
}

.switch.on {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}

.switch.on::after {
  transform: translateX(18px);
  background: #fff;
}

.empty {
  padding: 42px 0;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 132px;
  padding: 8px 0 0;
}

.chart .bar {
  flex: 1;
  min-width: 3px;
  background: linear-gradient(180deg, rgba(91, 140, 255, 0.95), rgba(91, 140, 255, 0.28));
  border-radius: 4px 4px 2px 2px;
  position: relative;
  transition: filter 0.15s ease;
  min-height: 2px;
}

.chart .bar:hover {
  filter: brightness(1.25);
}

.chart .bar.has-err {
  background: linear-gradient(180deg, rgba(248, 113, 113, 0.95), rgba(248, 113, 113, 0.3));
}

.chart-axis {
  display: flex;
  justify-content: space-between;
  color: var(--text-faint);
  font-size: 11px;
  margin-top: 8px;
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 16, 0.72);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 60;
  animation: fade 0.14s ease;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.modal {
  width: min(680px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.modal header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--bg-soft);
  z-index: 2;
}

.modal header h3 {
  margin: 0;
  font-size: 15.5px;
}

.modal .body {
  padding: 22px 24px;
}

.modal footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  position: sticky;
  bottom: 0;
  background: var(--bg-soft);
}

.toast-host {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 90;
  max-width: min(400px, calc(100vw - 44px));
}

.toast {
  padding: 12px 16px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: var(--panel-2);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: slide 0.2s ease;
  word-break: break-word;
}

.toast.ok {
  border-color: rgba(52, 211, 153, 0.4);
}

.toast.err {
  border-color: rgba(248, 113, 113, 0.45);
}

.toast .t {
  font-weight: 600;
  margin-bottom: 2px;
}

.toast .m {
  color: var(--text-dim);
  font-size: 12.5px;
}

@keyframes slide {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

.kv {
  display: grid;
  grid-template-columns: 172px 1fr;
  gap: 10px 16px;
  font-size: 13px;
  align-items: center;
}

.kv .k {
  color: var(--text-dim);
}

.copy-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.copy-row input {
  flex: 1;
}

.banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 18px;
  border-radius: 12px;
  border: 1px solid rgba(251, 191, 36, 0.32);
  background: rgba(251, 191, 36, 0.09);
  color: #fde68a;
  font-size: 13px;
  margin-bottom: 18px;
}

.banner.info {
  border-color: rgba(91, 140, 255, 0.3);
  background: rgba(91, 140, 255, 0.09);
  color: #c7dcff;
}

.loading {
  padding: 40px;
  text-align: center;
  color: var(--text-faint);
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
  }

  .sidebar .foot,
  .sidebar .brand .sub {
    display: none;
  }

  .nav {
    flex-direction: row;
    gap: 2px;
  }

  .nav button {
    padding: 7px 11px;
    font-size: 12.5px;
  }

  .nav .ico {
    display: none;
  }

  .main {
    padding: 18px 16px 48px;
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .kv {
    grid-template-columns: 1fr;
    gap: 3px 0;
  }

  .kv .k {
    font-size: 12px;
    margin-top: 8px;
  }
}
