:root {
  --bg: #09090b; 
  --bg-elevated: #111113; 
  --bg-card: rgba(24, 24, 27, 0.6); 
  --bg-hover: rgba(255, 255, 255, 0.06); 
  --bg-input: rgba(24, 24, 27, 0.5);
  --bg-secondary: rgba(24, 24, 27, 0.85);
  --bg-sidebar: #09090b; 
  
  --border: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.12);
  
  --text: #ffffff;
  --text-secondary: #a1a1aa;
  --text-muted: #85858f;
  
  --primary: #3b82f6; 
  --primary-hover: #60a5fa; 
  --primary-light: rgba(59, 130, 246, 0.15);
  
  --success: #22c55e;
  --warning: #eab308;
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.15);
  
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255,255,255,0.05) inset;
  
  --ring: 0 0 0 3px rgba(59, 130, 246, 0.3);
  
  --transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
  --transition-spring: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  background-image: radial-gradient(circle at 50% 0%, rgba(59, 130, 246, 0.05) 0%, transparent 70%);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

a { color: var(--text); text-decoration: none; transition: var(--transition-fast); }
a:hover { color: var(--primary-hover); }

button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1.5;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.15);
}
.btn-primary:hover { 
  background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-primary:active { transform: scale(0.97); box-shadow: none; }
.btn-primary:disabled { opacity: 0.5; filter: grayscale(1); cursor: not-allowed; transform: none; }
.btn-ghost:disabled,
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

button:focus-visible,
.btn-primary:focus-visible,
.btn-ghost:focus-visible,
.btn-danger:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-ghost {
  background: rgba(255,255,255,0.03);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.btn-ghost:hover { background: rgba(255,255,255,0.08); color: var(--text); border-color: var(--border-light); }
.btn-ghost:active { transform: scale(0.97); }

.btn-danger {
  background: rgba(239, 68, 68, 0.05);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); box-shadow: 0 2px 12px rgba(239, 68, 68, 0.2); }
.btn-danger:active { transform: scale(0.97); }

.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: var(--radius-xs); }

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  width: 100%;
  transition: var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
  backdrop-filter: blur(4px);
}

input::placeholder, textarea::placeholder { color: rgba(255,255,255,0.3); }

input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  cursor: pointer;
  position: relative;
  flex: none;
  margin: 0;
  padding: 0;
  transition: var(--transition-spring);
}
input[type="checkbox"]:hover { border-color: rgba(255,255,255,0.3); }
input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}
input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 3px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  animation: checkmark 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes checkmark {
  0% { height: 0; width: 0; opacity: 0; }
  100% { height: 10px; width: 5px; opacity: 1; }
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  border: none;
  padding: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  transition: var(--transition-spring);
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 4px rgba(255,255,255,0.15);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring);
  background: rgba(24, 24, 27, 0.8);
}

textarea { resize: vertical; min-height: 80px; }

select {
  color-scheme: dark;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

select option {
  color: var(--text);
  background: #18181b;
}

label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.form-group { margin-bottom: 20px; }
.form-row { display: flex; gap: 16px; }
.form-row > * { flex: 1; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-success { background: rgba(34, 197, 94, 0.1); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.2); }
.badge-warning { background: rgba(234, 179, 8, 0.1); color: var(--warning); border: 1px solid rgba(234, 179, 8, 0.2); }
.badge-danger { background: rgba(239, 68, 68, 0.1); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-info { background: rgba(59, 130, 246, 0.1); color: #93c5fd; border: 1px solid rgba(59, 130, 246, 0.2); }

.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.01);
}
.empty-state p { margin-top: 12px; font-size: 14px; }

.error-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-lg);
  background: rgba(239, 68, 68, 0.06);
}
.error-state p { margin: 0 0 16px; font-size: 14px; color: #fca5a5; }

.toolbar-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar-row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.panel-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: overlayIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes overlayIn {
  from { opacity: 0; backdrop-filter: blur(0px); }
  to { opacity: 1; backdrop-filter: blur(8px); }
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
  outline: none;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 20px;
  position: sticky;
  bottom: -32px;
  padding-top: 16px;
  padding-bottom: 4px;
  background: linear-gradient(180deg, transparent 0%, var(--bg-elevated) 28%);
  z-index: 2;
}

.modal-tabs {
  display: flex;
  gap: 4px;
  margin: -8px 0 20px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(9, 9, 11, 0.65);
  overflow-x: auto;
}
.modal-tab {
  flex: 1 1 auto;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.modal-tab:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.modal-tab.active {
  color: #fff;
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(37, 99, 235, 0.28);
}
.modal-tab-panel[hidden] { display: none !important; }

@keyframes modalIn {
  from { transform: scale(0.9) translateY(20px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}
.modal-header h2 { font-size: 20px; font-weight: 600; letter-spacing: 0; }

.modal-close {
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
  font-size: 18px;
  padding: 0;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
}
.modal-close:hover { background: rgba(255,255,255,0.1); color: var(--text); transform: rotate(90deg); }

.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 28px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  z-index: 2000;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: toastIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 480px);
}
.toast-success { background: rgba(34, 197, 94, 0.15); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.toast-error { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.3); }
.toast-warning { background: rgba(234, 179, 8, 0.15); color: #fde047; border: 1px solid rgba(234, 179, 8, 0.3); }
.toast.toast-out { animation: toastOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards; }

.js-error-banner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(127, 29, 29, 0.92);
  color: #fff;
  font-size: 13px;
  line-height: 1.45;
  backdrop-filter: blur(8px);
}
.js-error-banner.visible { display: flex; }
.js-error-banner-body {
  min-width: 0;
  flex: 1;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 88px;
  overflow: auto;
}
.js-error-banner-close {
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 16px;
}

@keyframes toastIn {
  from { transform: translate(-50%, 30px) scale(0.9); opacity: 0; }
  to { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

@keyframes toastOut {
  from { transform: translate(-50%, 0) scale(1); opacity: 1; }
  to { transform: translate(-50%, 30px) scale(0.9); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.loading {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}
table th {
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: rgba(24, 24, 27, 0.8);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
table td {
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text);
  vertical-align: middle;
}
table tbody tr {
  transition: var(--transition-fast);
}
table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
table tbody tr:last-child td { border-bottom: none; }

.table-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: var(--shadow);
}

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  padding: 4px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: var(--transition-fast);
}
.tag:hover { background: rgba(255,255,255,0.1); color: var(--text); }

.checkbox-group { display: flex; flex-wrap: wrap; gap: 10px; }
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  font-size: 14px;
  user-select: none;
}
.checkbox-item:hover { border-color: rgba(255,255,255,0.2); background: rgba(255,255,255,0.05); }
.checkbox-item.active {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.2) inset;
}
.checkbox-item input { margin: 0; }
