:root {
    --background: 0 0% 100%;
    --foreground: 240 10% 3.9%;
    --card: 0 0% 100%;
    --card-foreground: 240 10% 3.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 240 10% 3.9%;
    --primary: 240 5.9% 10%;
    --primary-foreground: 0 0% 98%;
    --secondary: 240 4.8% 95.9%;
    --secondary-foreground: 240 5.9% 10%;
    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 46.1%;
    --accent: 240 4.8% 95.9%;
    --accent-foreground: 240 5.9% 10%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 5.9% 90%;
    --input: 240 5.9% 90%;
    --ring: 240 5.9% 10%;
    --radius: 0.625rem;
    --brand: 87 54% 53%;
    --brand-foreground: 0 0% 100%;
    --chart-1: 12 76% 61%;
    --chart-2: 173 58% 39%;
    --chart-3: 197 37% 24%;
    --chart-4: 43 74% 66%;
    --chart-5: 27 87% 67%;

    /* Color palette (for inline styles) */
    --blue-50: hsl(214 95% 93%);
    --blue-100: hsl(214 94% 87%);
    --blue-500: hsl(217 91% 60%);
    --blue-600: hsl(221 83% 53%);
    --blue-700: hsl(224 76% 48%);
    --green-50: hsl(142 76% 93%);
    --green-500: hsl(142 76% 46%);
    --green-600: hsl(142 71% 45%);
    --green-700: hsl(142 76% 36%);
    --red-50: hsl(0 93% 94%);
    --red-500: hsl(0 84% 60%);
    --red-600: hsl(0 72% 51%);
    --red-700: hsl(0 74% 42%);
    --yellow-50: hsl(48 100% 96%);
    --yellow-500: hsl(38 92% 50%);
    --yellow-600: hsl(32 95% 44%);
    --yellow-700: hsl(26 90% 37%);
    --purple-50: hsl(280 100% 98%);
    --purple-500: hsl(280 65% 60%);
    --purple-700: hsl(280 50% 50%);
}

*, *::before, *::after {
  box-sizing: border-box;
  border-color: hsl(var(--border));
}

body {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== Typography ========== */
h1 { font-size: 1.875rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.2; }
h2 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.025em; line-height: 1.3; }
h3 { font-size: 1.125rem; font-weight: 600; line-height: 1.4; }
h4 { font-size: 1rem; font-weight: 600; line-height: 1.5; }

/* ========== Card ========== */
.card {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  margin-bottom: 1rem;
}
.card h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card h3 .icon {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}
.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card-desc {
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

/* ========== Button ========== */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.625rem 1rem;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  outline: none;
  text-decoration: none;
  background: hsl(var(--brand));
  color: hsl(var(--brand-foreground));
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
button:hover, .btn:hover {
  background: hsl(var(--brand) / 0.9);
}
button:focus-visible, .btn:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}
button:disabled, .btn:disabled {
  pointer-events: none;
  opacity: 0.5;
}
button:active, .btn:active { transform: scale(0.98); }

button.ghost, .btn.ghost, a.ghost, .ghost {
  background: transparent;
  color: hsl(var(--foreground));
  box-shadow: none;
  border: 1px solid hsl(var(--border));
}
button.ghost:hover, .btn.ghost:hover, a.ghost:hover, .ghost:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

button.outline, .btn.outline {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  box-shadow: none;
}
button.outline:hover, .btn.outline:hover {
  background: hsl(var(--accent));
}

button.secondary, .btn.secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  box-shadow: none;
}
button.secondary:hover, .btn.secondary:hover {
  background: hsl(var(--secondary) / 0.8);
}

button.destructive, .btn.destructive, button.danger, .btn.danger {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}
button.destructive:hover, .btn.destructive:hover, button.danger:hover, .btn.danger:hover {
  background: hsl(var(--destructive) / 0.9);
}
button.danger.confirming {
  background: hsl(var(--destructive));
  animation: pulse-danger 1s infinite;
}
@keyframes pulse-danger { 0%,100%{opacity:1} 50%{opacity:.7} }

button.success, .btn.success {
  background: hsl(142 76% 36%);
  color: #fff;
}
button.success:hover, .btn.success:hover {
  background: hsl(142 76% 36% / 0.9);
}

button.sm, .btn.sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
button.xs, .btn.xs { padding: 0.25rem 0.5rem; font-size: 0.75rem; }

/* ========== Input ========== */
input, textarea, select {
  display: flex;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--input));
  background: hsl(var(--background));
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: hsl(var(--foreground));
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder {
  color: hsl(var(--muted-foreground));
}
input:focus, textarea:focus, select:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.1);
}
input:disabled, textarea:disabled, select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
textarea { resize: vertical; min-height: 5rem; }
select { cursor: pointer; }

/* ========== Badge ========== */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25rem;
  border: 1px solid transparent;
  transition: colors 0.15s;
}
.badge.blue, .badge.badge-blue {
  background: hsl(214 95% 93%);
  color: hsl(221 83% 53%);
}
.badge.secondary, .badge.gray, .badge.badge-gray {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}
.badge.destructive, .badge.red, .badge.badge-red {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}
.badge.green, .badge.badge-green {
  background: hsl(142 76% 46% / 0.15);
  color: hsl(142 76% 30%);
}
.badge.yellow, .badge.badge-yellow {
  background: hsl(38 92% 50% / 0.15);
  color: hsl(32 95% 30%);
}
.badge.purple, .badge.badge-purple {
  background: hsl(280 65% 60% / 0.15);
  color: hsl(280 50% 40%);
}
.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}
.badge.green .dot { background: hsl(142 76% 46%); }
.badge.red .dot { background: hsl(var(--destructive)); }
.badge.yellow .dot { background: hsl(38 92% 50%); }

/* ========== Temp-keys tag ========== */
/* 临时密钥页两处（temp-keys / temp-keys-usage）共用的标签徽章，避免跨页手动复制 */
.tk-tag {
  display: inline-block;
  padding: 0.0625rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: 1px;
}
.tk-tag-info {
  background: hsl(217 91% 60% / 0.12);
  color: hsl(217 91% 45%);
  border: 1px solid hsl(217 91% 60% / 0.28);
}
.tk-tag-warn {
  background: hsl(38 92% 50% / 0.15);
  color: hsl(32 95% 35%);
  border: 1px solid hsl(38 92% 50% / 0.32);
}

/* ========== Table ========== */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
}
table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; caption-side: bottom; }
th {
  text-align: left;
  height: 2.75rem;
  padding: 0 1rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
  font-size: 0.8125rem;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--muted) / 0.5);
  white-space: nowrap;
}
td {
  padding: 0.625rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
  vertical-align: middle;
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: hsl(var(--muted) / 0.5); }
tr[data-state="selected"] td { background: hsl(var(--muted)); }

/* ========== Tabs ========== */
.tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  border-bottom: 1px solid hsl(var(--border));
  padding: 0 1.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  background: hsl(var(--card));
  position: sticky;
  top: 0;
  z-index: 50;
  max-width: 80rem;
  margin: 0 auto;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.tab:hover { color: hsl(var(--foreground)); }
.tab.active {
  color: hsl(var(--foreground));
  border-bottom-color: hsl(var(--brand));
  font-weight: 600;
}
.tab a { text-decoration: none; color: inherit; }

/* ========== Separator ========== */
.separator {
  height: 1px;
  width: 100%;
  background: hsl(var(--border));
  margin: 1rem 0;
}

/* ========== Dialog / Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: hsl(0 0% 0% / 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  width: 32rem;
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  padding: 1.5rem;
  transform: translateY(0.5rem);
  transition: transform 0.2s;
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 1rem;
  letter-spacing: -0.025em;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid hsl(var(--border));
}

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 28rem;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  animation: toastIn 0.2s ease-out;
  word-break: break-word;
}
.toast.success { border-left: 4px solid hsl(142 76% 46%); }
.toast.error { border-left: 4px solid hsl(var(--destructive)); }
.toast.info { border-left: 4px solid hsl(217 91% 60%); }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ========== Stat ========== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.75rem;
}
.stat {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: box-shadow 0.15s;
}
.stat:hover {
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}
.stat .label {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}
.stat .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: hsl(var(--foreground));
  margin-top: 0.25rem;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}
.stat .sub {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.25rem;
}

/* ========== Provider Cards ========== */
.provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: 0.75rem;
}
.provider-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: all 0.15s;
}
.provider-card:hover {
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}
.provider-card .provider-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--foreground));
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.provider-card .provider-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.provider-card .provider-stats .ps-item { font-size: 0.75rem; color: hsl(var(--muted-foreground)); }
.provider-card .provider-stats .ps-val { font-weight: 600; color: hsl(var(--foreground)); font-variant-numeric: tabular-nums; }
.provider-card .model-tags { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.5rem; }
.provider-card .model-tag {
  font-size: 0.6875rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius);
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  border: 1px solid hsl(var(--border));
  white-space: nowrap;
}
.provider-card .model-tag.alias {
  background: hsl(142 76% 46% / 0.1);
  color: hsl(142 76% 30%);
  border-color: hsl(142 76% 46% / 0.2);
}

/* ========== Login ========== */
.login-overlay {
  position: fixed;
  inset: 0;
  background: hsl(var(--background));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.login-box {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 2rem;
  width: 24rem;
  max-width: calc(100vw - 2rem);
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}
.login-box h2 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin-bottom: 0.5rem;
}
.login-box .login-sub {
  text-align: center;
  margin-bottom: 1.5rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
}
.login-box input {
  margin-bottom: 1rem;
}
.login-box button {
  width: 100%;
  margin-top: 0.25rem;
}
.login-box .login-hint {
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  text-align: center;
}

/* ========== Logo ========== */
.logo-img { height: 2rem; width: auto; object-fit: contain; }
.login-box .logo-img { height: 3rem; margin-bottom: 0.5rem; }

/* ========== Header ========== */
.header {
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 80rem;
  margin: 0 auto;
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 51;
}
.header-left { display: flex; align-items: center; gap: 0.75rem; }
.header h1 { font-size: 1rem; font-weight: 600; letter-spacing: -0.025em; }
.header .ver {
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted));
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-weight: 500;
}
.header .logout-btn {
  font-size: 0.75rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--destructive) / 0.3);
  background: transparent;
  cursor: pointer;
  color: hsl(var(--destructive));
  font-weight: 500;
  transition: all 0.15s;
}
.header .logout-btn:hover { background: hsl(var(--destructive) / 0.1); }

/* ========== Content ========== */
.content { padding: 1.5rem; max-width: 80rem; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }

/* ========== Flex Utilities ========== */
.flex { display: flex; align-items: center; }
.gap-sm { gap: 0.375rem; }
.gap-md { gap: 0.75rem; }
.gap-lg { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: hsl(var(--muted-foreground)); }
.font-mono { font-family: 'SF Mono', Monaco, 'Cascadia Code', 'JetBrains Mono', monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }

/* ========== Keys List ========== */
.keys-list { display: flex; flex-direction: column; gap: 0.375rem; }
.key-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  transition: all 0.15s;
}
.key-item:hover { background: hsl(var(--muted) / 0.5); }
.key-item .key-val { font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-item .key-actions { display: flex; gap: 0.375rem; flex-shrink: 0; margin-left: 0.5rem; }

/* ========== Provider Selector ========== */
.provider-selector { display: flex; gap: 0.375rem; flex-wrap: wrap; margin-bottom: 1rem; }
.provider-btn {
  padding: 0.375rem 0.875rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  cursor: pointer;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  transition: all 0.15s;
  font-weight: 500;
}
.provider-btn:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.provider-btn.active {
  background: hsl(var(--brand) / 0.1);
  border-color: hsl(var(--brand));
  color: hsl(var(--brand));
  font-weight: 600;
}

/* ========== Fallback Chain ========== */
.fallback-chain { display: flex; flex-direction: column; gap: 0.375rem; }
.fallback-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  font-size: 0.8125rem;
}
.fallback-item .drag-handle { cursor: grab; color: hsl(var(--muted-foreground)); font-size: 1rem; }
.fallback-item .fallback-name { flex: 1; font-weight: 500; }
.fallback-arrow { color: hsl(var(--muted-foreground)); font-size: 1.125rem; text-align: center; padding: 0.125rem 0; }

/* ========== Chart ========== */
.chart-container {
  position: relative;
  width: 100%;
  height: 17.5rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  overflow: hidden;
}
.chart-container canvas { width: 100% !important; height: 100% !important; }
.chart-controls { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.chart-range-btn {
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  cursor: pointer;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  transition: all 0.15s;
  font-weight: 500;
}
.chart-range-btn:hover { background: hsl(var(--accent)); }
.chart-range-btn.active {
  background: hsl(var(--brand) / 0.1);
  border-color: hsl(var(--brand));
  color: hsl(var(--brand));
}

/* ========== Key Result ========== */
.key-result {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 0.75rem;
}
.key-result code {
  display: block;
  word-break: break-all;
  font-size: 0.75rem;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  padding: 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  line-height: 1.5;
}
.key-result .key-meta {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ========== Custom Provider Grid ========== */
.cp-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
@media (max-width: 640px) {
  .cp-grid { grid-template-columns: 1fr; }
}

/* ========== Webhook ========== */
.webhook-item {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.625rem;
}
.webhook-item .wh-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.webhook-item .wh-name { font-weight: 600; font-size: 0.875rem; }
.webhook-item .wh-url { font-size: 0.75rem; color: hsl(var(--muted-foreground)); font-family: monospace; word-break: break-all; }

/* ========== Priority Rule ========== */
.rule-item {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.875rem;
  margin-bottom: 0.625rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.rule-item .rule-num {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}
.rule-item .rule-content { flex: 1; min-width: 0; }
.rule-item .rule-pattern { font-family: monospace; font-size: 0.8125rem; font-weight: 600; color: hsl(var(--foreground)); }
.rule-item .rule-providers { font-size: 0.75rem; color: hsl(var(--muted-foreground)); margin-top: 0.25rem; }
.rule-item .rule-actions { display: flex; gap: 0.375rem; flex-shrink: 0; }

/* ========== Conflict Alert ========== */
.conflict-alert {
  background: hsl(38 92% 50% / 0.1);
  border: 1px solid hsl(38 92% 50% / 0.3);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  color: hsl(32 95% 30%);
  margin-bottom: 0.75rem;
}

/* ========== Form ========== */
.form-group { margin-bottom: 0.875rem; }
.form-group label { display: block; font-size: 0.8125rem; font-weight: 500; color: hsl(var(--foreground)); margin-bottom: 0.375rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

/* ========== Capability Tags ========== */
.capability-tag {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1.5px solid hsl(var(--border));
  background: hsl(var(--card));
  cursor: pointer;
  font-size: 0.8125rem !important;
  font-weight: 400 !important;
  color: hsl(var(--muted-foreground));
  transition: all 0.15s ease;
  user-select: none;
  margin-bottom: 0 !important;
}
.capability-tag:hover { border-color: hsl(var(--primary)); color: hsl(var(--foreground)); }
.capability-tag input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--primary, #2563eb);
  cursor: pointer;
  margin: 0;
}
.capability-tag:has(input:checked) {
  border-color: color-mix(in srgb, hsl(var(--primary)) 45%, hsl(var(--border)));
  background: color-mix(in srgb, hsl(var(--primary)) 4%, hsl(var(--card)));
  color: hsl(var(--foreground));
}
.capability-tag span { display: inline-flex; align-items: center; gap: 4px; }
/* ========== Route Badge (主/备) ========== */
.model-tag { position: relative; }
.route-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  margin-right: 4px;
  vertical-align: middle;
  line-height: 1.4;
}
.route-badge.primary {
  background: hsl(142 76% 46% / 0.15);
  color: hsl(142 76% 30%);
}
.route-badge.standby {
  background: hsl(215 16% 47% / 0.15);
  color: hsl(215 20% 35%);
}

/* ========== Empty & Loading ========== */
.empty-state { text-align: center; padding: 2.5rem 1.25rem; color: hsl(var(--muted-foreground)); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.5; }
.empty-state .empty-text { font-size: 0.875rem; }
.loading { text-align: center; padding: 2rem; color: hsl(var(--muted-foreground)); }
.empty { text-align: center; padding: 1.25rem; color: hsl(var(--muted-foreground)); }

/* ========== Loading Spinner ========== */
.loading-spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid hsl(var(--border));
  border-top-color: hsl(var(--primary));
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Copy Button ========== */
.copy-btn { position: relative; cursor: pointer; }
.copy-btn::after {
  content: attr(data-copied);
  position: absolute;
  top: -1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: hsl(var(--foreground));
  color: hsl(var(--background));
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.6875rem;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
  pointer-events: none;
}
.copy-btn.copied::after { opacity: 1; }

/* ========== Standalone Page Layout ========== */
.standalone-container { max-width: 72rem; margin: 0 auto; padding: 2rem 1.5rem; }
.standalone-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.standalone-header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.025em; }
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--muted-foreground));
  font-size: 0.8125rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}
.back-btn:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 0.5rem; height: 0.5rem; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 0.25rem; }
::-webkit-scrollbar-thumb:hover { background: hsl(var(--muted-foreground) / 0.5); }

/* ========== Responsive ========== */
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .card { padding: 1rem; }
}
@media (max-width: 768px) {
  .header { padding: 0.75rem 1rem; flex-wrap: wrap; gap: 0.5rem; }
  .header h1 { font-size: 0.9375rem; }
  .content { padding: 1rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .provider-grid { grid-template-columns: 1fr; }
  .tabs { padding: 0 0.75rem; }
  .tab { padding: 0.625rem 0.875rem; font-size: 0.8125rem; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .stat .value { font-size: 1.25rem; }
}
