:root {
  --bg: #0d1117;
  --panel: #131820;
  --panel-2: #171e29;
  --border: #232b39;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --ok: #34d399;
  --warn: #f5b544;
  --danger: #f0616d;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(79, 140, 255, 0.18), transparent 60%), var(--bg);
}

.login-card {
  width: 340px;
  padding: 32px 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }

input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.hint { min-height: 16px; color: var(--danger); font-size: 12px; }

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.brand .logo {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #7c5cff);
  font-weight: 700; font-size: 13px; color: #fff;
}
.brand strong { display: block; font-size: 14px; }
.brand small { color: var(--muted); font-size: 11px; }

#nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
#nav a {
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  transition: background 0.15s ease, color 0.15s ease;
}
#nav a:hover { background: var(--panel-2); color: var(--text); }
#nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.sidebar-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 6px; font-size: 12px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 26px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(23, 30, 41, 0.85), rgba(13, 17, 23, 0.6));
}
.topbar h2 { margin: 0; font-size: 17px; font-weight: 600; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.content { padding: 22px 26px 46px; overflow: auto; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  font-family: inherit;
}
.btn:hover { border-color: #33405a; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #3f7cf0; }
.btn.danger { color: var(--danger); border-color: rgba(240, 97, 109, 0.4); }
.btn.danger:hover { background: rgba(240, 97, 109, 0.12); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; }

.icon-btn {
  border: none; background: transparent; color: var(--muted);
  font-size: 15px; cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card {
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card .label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.card .value { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 6px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
  overflow: hidden;
}
.panel > header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 13px;
}
.panel > .body { padding: 16px 18px; }

.chart { display: flex; align-items: flex-end; gap: 12px; height: 160px; padding: 8px 4px 0; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart .bar {
  width: 100%;
  max-width: 46px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--accent), rgba(79, 140, 255, 0.25));
  min-height: 3px;
  transition: height 0.3s ease;
}
.chart .bar.zero { background: var(--border); }
.chart .cap { color: var(--muted); font-size: 11px; }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
td.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500;
  background: rgba(139, 152, 168, 0.15); color: var(--muted);
}
.tag.ok { background: rgba(52, 211, 153, 0.14); color: var(--ok); }
.tag.warn { background: rgba(245, 181, 68, 0.14); color: var(--warn); }
.tag.danger { background: rgba(240, 97, 109, 0.14); color: var(--danger); }
.tag.info { background: var(--accent-soft); color: var(--accent); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }

.empty { padding: 34px; text-align: center; color: var(--muted); font-size: 13px; }

.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.pager .btns { display: flex; gap: 6px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }

.modal {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 7, 12, 0.66);
  backdrop-filter: blur(2px);
}
.modal-card {
  width: min(560px, 92vw);
  max-height: 86vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.modal-card > header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-card > header h3 { margin: 0; font-size: 15px; }
.modal-card > #modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-card > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.modal-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.modal-card.wide { width: min(940px, 96vw); }

.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  padding: 11px 16px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: 360px;
}
.toast.error { border-color: rgba(240, 97, 109, 0.5); color: #ffb3b9; }
.toast.ok { border-color: rgba(52, 211, 153, 0.4); }

.code-block {
  background: #0b0f16;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 220px;
  overflow: auto;
}

/* ---- Token 配额与计费 ---- */
.bar-track { height: 6px; background: rgba(139, 152, 168, 0.18); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.2s ease; }
.bar-fill.warn { background: var(--warn); }
.bar-fill.danger { background: var(--danger); }
.quota-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.quota-item { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.quota-item .k { font-size: 11.5px; color: var(--muted); }
.quota-item .v { font-size: 15px; font-weight: 600; margin: 4px 0 8px; }
.quota-item .v small { font-size: 11px; color: var(--muted); font-weight: 400; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.stat-inline { display: flex; gap: 22px; flex-wrap: wrap; }
.stat-inline div { font-size: 12px; color: var(--muted); }
.stat-inline strong { display: block; font-size: 16px; color: var(--text); margin-top: 3px; }
.table-scroll { overflow: auto; }
.mini-chart { display: flex; align-items: flex-end; gap: 3px; height: 90px; padding: 6px 2px 0; }
.mini-chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.mini-chart .bar { width: 100%; min-height: 2px; background: linear-gradient(180deg, var(--accent), rgba(79, 140, 255, 0.35)); border-radius: 3px 3px 0 0; }
.mini-chart .bar.zero { background: rgba(139, 152, 168, 0.2); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; overflow-x: auto; }
  #nav { flex-direction: row; }
  .sidebar-footer { display: none; }
  .content { padding: 16px; }
}

