:root {
  --primary: #6366f1;
  --primary-d: #4f46e5;
  --primary-l: #818cf8;
  --accent: #a855f7;
  --text: #1e293b;
  --muted: #64748b;
  --muted-l: #94a3b8;
  --border: rgba(99, 102, 241, 0.12);
  --border-l: rgba(255, 255, 255, 0.6);
  --card: rgba(255, 255, 255, 0.72);
  --card-solid: rgba(255, 255, 255, 0.9);
  --hover: rgba(99, 102, 241, 0.06);
  --shadow: 0 8px 32px rgba(99, 102, 241, 0.08);
  --shadow-sm: 0 4px 20px rgba(99, 102, 241, 0.06);
  --radius: 16px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #e0e7ff 0%, #f0f4ff 45%, #fdf2f8 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ===== 布局 ===== */
.app-shell { min-height: 100vh; padding: 24px; }
.layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; max-width: 1400px; margin: 0 auto; }

/* 顶栏（跨整宽） */
.topbar {
  grid-column: 1 / -1;
  background: var(--card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-l);
  border-radius: var(--radius);
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 19px;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.2px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-user {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted); font-weight: 500;
}
.topbar-user i { font-size: 16px; }
.topbar-right .dropdown-toggle::after { display: none; }
.topbar-right .btn-link { color: var(--muted); text-decoration: none; padding: 4px 8px; }
.topbar-right .btn-link:hover { color: var(--primary); }

/* 侧边栏 */
.sidebar {
  background: var(--card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-l);
  border-radius: var(--radius);
  padding: 20px 14px;
  box-shadow: var(--shadow);
  height: fit-content;
  position: sticky;
  top: 24px;
}
.sidebar .nav { flex-direction: column; gap: 2px; }
.sidebar .nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  transition: 0.2s;
  cursor: pointer;
  text-decoration: none;
}
.sidebar .nav-item i { font-size: 17px; width: 20px; text-align: center; }
.sidebar .nav-item:hover { background: var(--hover); color: var(--primary); }
.sidebar .nav-item.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-d));
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}
.sidebar-divider { height: 1px; background: var(--border-l); margin: 14px 6px; }

/* 内容区 */
.content { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.content-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: nowrap; }
.content-header > * { flex-shrink: 0; }
.content-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
.content-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.content-body { display: flex; flex-direction: column; gap: 20px; }

/* ===== 卡片 ===== */
.card {
  background: var(--card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-l);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 16px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.card-footer {
  background: transparent;
  border-top: 1px solid var(--border);
  padding: 12px 22px;
}

/* ===== 工具栏 ===== */
.toolbar { gap: 14px; }
.toolbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
.search-box {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 240px;
  max-width: 240px;
  min-width: 140px;
  flex: 0 1 240px;
}
.search-box .input-group-text {
  background: transparent; border: 0; color: var(--muted-l);
}
.search-box .form-control {
  background: transparent; border: 0;
  box-shadow: none;
}
.search-box .form-control:focus { box-shadow: none; }
.search-box .form-control::placeholder { color: var(--muted-l); }

/* ===== 统计卡 ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card {
  background: var(--card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-l);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff; margin-bottom: 14px;
}
.stat-val { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ===== 表格 ===== */
.table { margin: 0; }
.table thead th {
  background: rgba(99, 102, 241, 0.03);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  padding: 12px 22px;
  white-space: nowrap;
}
.table tbody td {
  padding: 14px 22px;
  border-top: 1px solid rgba(99, 102, 241, 0.08);
  vertical-align: middle;
}
.table-hover tbody tr { transition: background 0.15s; }
.table-hover tbody tr:hover { background: rgba(99, 102, 241, 0.04); }

code, .code-tag {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-d);
  padding: 3px 9px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
}

/* ===== 徽章 ===== */
.badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.type-string { background: #dbeafe; color: #1e40af; }
.type-json { background: #dcfce7; color: #166534; }
.type-number { background: #fef3c7; color: #92400e; }
.type-boolean { background: #f3e8ff; color: #6b21a8; }
.action-create { background: #dcfce7; color: #166534; }
.action-update { background: #dbeafe; color: #1e40af; }
.action-delete { background: #fee2e2; color: #991b1b; }

/* ===== 配置页 ===== */
.config-back { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.config-app-name { display: flex; align-items: center; gap: 10px; }
.config-app-name h5 { margin: 0; font-weight: 700; }
.cfg-value {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  color: var(--muted);
}
.cfg-editor {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.6;
  min-height: 180px;
}
.env-select { width: 170px; }

/* ===== 行操作按钮：编辑/删除同行不换行 ===== */
.row-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.row-actions .btn-sm { white-space: nowrap; }

/* ===== 按钮 ===== */
.btn { font-weight: 600; font-size: 13px; border-radius: var(--radius-sm); transition: 0.2s; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-d));
  border: 0;
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-l), var(--primary));
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.45);
}
.btn-outline-primary { color: var(--primary); border-color: rgba(99, 102, 241, 0.4); background: rgba(255,255,255,0.4); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-outline-secondary { color: var(--muted); border-color: var(--border); background: rgba(255,255,255,0.4); }
.btn-outline-secondary:hover { color: var(--primary); border-color: var(--primary); background: rgba(99,102,241,0.08); }
.btn-outline-info { color: #0891b2; border-color: rgba(8,145,178,0.4); background: rgba(255,255,255,0.4); }
.btn-outline-info:hover { background: #0891b2; border-color: #0891b2; color: #fff; }
.btn-outline-danger { color: #e11d48; border-color: rgba(225,29,72,0.4); background: rgba(255,255,255,0.4); }
.btn-outline-danger:hover { background: #e11d48; border-color: #e11d48; color: #fff; }
.btn-ghost { background: rgba(255,255,255,0.5); border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-light { background: rgba(255,255,255,0.6); border: 1px solid var(--border); color: var(--muted); }
.btn-sm { font-size: 13px; }

/* ===== 表单 ===== */
.form-control, .form-select {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-sm);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary-l);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.form-label { font-weight: 500; color: var(--text); }
.form-text { color: var(--muted-l); }
.input-group-text {
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--border);
  color: var(--muted);
}

/* ===== 模态框 ===== */
.modal-content {
  border: 1px solid var(--border-l);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(99, 102, 241, 0.2);
  border: 0;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px);
}
.modal-header { border-bottom: 1px solid var(--border); padding: 18px 22px; }
.modal-title { font-weight: 700; }
.modal-body { padding: 22px; }
.modal-footer { border-top: 1px solid var(--border); padding: 16px 22px; }
.modal-fullscreen .modal-body { padding-bottom: 80px; }

/* ===== 登录页 ===== */
.login-page {
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(255,255,255,0.15), transparent 70%);
  top: -100px; left: -100px;
  border-radius: 50%;
}
.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(255,255,255,0.1), transparent 70%);
  bottom: -50px; right: -50px;
  border-radius: 50%;
}
.login-wrapper { width: 100%; max-width: 400px; padding: 20px; position: relative; z-index: 1; }
.login-card {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 24px;
  padding: 40px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand .brand-icon { width: 56px; height: 56px; margin: 0 auto 14px; font-size: 26px; }
.login-brand h4 { margin: 0 0 4px; font-weight: 700; letter-spacing: -0.3px; }
.login-footer { text-align: center; margin-top: 20px; font-size: 12px; color: var(--muted-l); }
.login-card .input-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.6);
  transition: 0.2s;
  overflow: hidden;
}
.login-card .input-group:focus-within {
  border-color: var(--primary-l);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.login-card .input-group-text {
  border: 0;
  background: transparent;
  color: var(--muted-l);
  padding-right: 4px;
}
.login-card .form-control {
  border: 0;
  background: transparent;
  box-shadow: none;
}
.login-card .form-control:focus { box-shadow: none; }

/* ===== 通用 ===== */
.text-muted { color: var(--muted) !important; }
.text-break { word-break: break-word; }
a { text-decoration: none; }
.text-center { text-align: center; }
.alert { border-radius: var(--radius-sm); border: 0; }
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }

@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
