:root {
  --bg-page: #f5f7fb;
  --bg-card: #ffffff;
  --bg-subtle: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --brand: #1d4ed8;
  --brand-hover: #1e40af;
  --brand-soft: #eff6ff;
  --brand-border: #bfdbfe;
  --ok-bg: #ecfdf5;
  --ok-text: #047857;
  --warn-bg: #fffbeb;
  --warn-text: #b45309;
  --err-bg: #fef2f2;
  --err-text: #b91c1c;
  --info-bg: #f0f9ff;
  --info-text: #0369a1;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 4px 12px rgba(15, 23, 42, 0.04);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.text-right { text-align: right; }
.muted { color: var(--muted); font-size: 12.5px; }
code {
  font-family: var(--mono);
  font-size: 12px;
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 4px;
  color: #1e293b;
}

/* Login */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 20% 20%, #e0e7ff 0%, #f5f7fb 55%);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}
.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.font-luoshen {
  font-family: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "SimSun", Georgia, serif;
  letter-spacing: 0.12em;
  font-weight: 600;
}
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: linear-gradient(145deg, #f8fbff, #eaf2fa);
  border: 1px solid rgba(30, 70, 114, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-mark img { display: block; }
.brand-mark.sm { width: 34px; height: 34px; border-radius: 9px; }
.brand-mark.dark {
  background: rgba(30, 70, 114, 0.24);
  border-color: rgba(127, 178, 232, 0.24);
}
.brand-title { margin: 0; font-size: 16.5px; font-weight: 700; color: var(--ink); }
.brand-title-sep { margin: 0 5px; color: #94a3b8; font-weight: 400; }
.brand-sub { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); }
.login-foot {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

/* Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: #0f172a;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}
.sidebar-title { font-size: 15px; font-weight: 700; color: #fff; display: flex; align-items: baseline; gap: 6px; }
.sidebar-title-en { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; color: #7fb2e8; font-weight: 500; }
.sidebar-sub { font-size: 11px; color: #94a3b8; margin-top: 1px; }

.nav-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}
.nav-divider {
  margin: 14px 10px 6px;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: 0;
  background: transparent;
  color: #cbd5e1;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-item.active {
  background: rgba(59, 130, 246, 0.22);
  color: #fff;
  font-weight: 600;
}
.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.55;
}
.nav-item.active .nav-dot { opacity: 1; background: #60a5fa; }

.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 6px;
}
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #1e293b;
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: #93c5fd;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.user-name { font-size: 12.5px; font-weight: 600; color: #f8fafc; }
.user-role { font-size: 11px; color: #94a3b8; }

.main-area {
  flex: 1;
  min-width: 0;
  padding: 20px 26px 32px;
  overflow-x: auto;
}
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.page-desc { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; white-space: nowrap; }

/* Cards & Grids */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}
.card-head h3 { margin: 0; font-size: 14px; font-weight: 650; }
.card-body { padding: 16px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 12px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--ink);
}
.kpi-sub { margin-top: 4px; font-size: 11.5px; color: var(--muted); }

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
}
.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.project-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.project-title { margin: 0; font-size: 15.5px; font-weight: 700; }
.project-id { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.token-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.token-input-row {
  display: flex;
  gap: 6px;
}
.token-input-row input {
  flex: 1;
  min-width: 0;
  padding: 6px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 12.5px;
  font-family: var(--mono);
}

/* Tables */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.filter-row { display: flex; gap: 8px; align-items: center; }
.btn-group { display: flex; gap: 8px; align-items: center; }
.table-wrap { width: 100%; overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: #fafcff; }
.mono { font-family: var(--mono); font-size: 12px; }

/* Pills & Badges */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.pill-ok { background: var(--ok-bg); color: var(--ok-text); }
.pill-warn { background: var(--warn-bg); color: var(--warn-text); }
.pill-err { background: var(--err-bg); color: var(--err-text); }
.pill-info { background: var(--info-bg); color: var(--info-text); }
.pill-neutral { background: #f1f5f9; color: #475569; }
.acl-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* Buttons & Forms */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn-secondary { background: #fff; color: var(--ink-2); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-subtle); border-color: #94a3b8; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-ghost { background: rgba(255, 255, 255, 0.08); color: #e2e8f0; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.16); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11.5px; border-radius: 6px; }
.btn-full { width: 100%; }

.form-stack { display: flex; flex-direction: column; gap: 13px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .select-sm {
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 13px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
.select-sm { padding: 5px 9px; font-size: 12px; }
.field input:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.12); }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; color: var(--ink-2); }
.checkbox-row label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

.kv-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kv-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.code-chip { padding: 4px 8px; font-size: 12px; border: 1px solid var(--border); }

.alert { padding: 9px 12px; border-radius: 8px; font-size: 12.5px; }
.alert-error { background: var(--err-bg); color: var(--err-text); border: 1px solid #fecaca; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: #0f172a;
  color: #fff;
  padding: 10px 15px;
  border-radius: 9px;
  font-size: 12.5px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
  z-index: 200;
}
.toast.error { background: #b91c1c; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-card {
  width: 100%;
  max-width: 540px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.18);
  padding: 20px 22px;
}
.modal-card.sm { max-width: 400px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-head h3 { margin: 0; font-size: 15.5px; font-weight: 700; }
.icon-close {
  border: 0;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}
