:root,
html[data-theme="light"] {
  --bg-deep: #f3f6fb;
  --bg-panel: #ffffff;
  --bg-elevated: #ffffff;
  --bg-sider: rgba(255, 255, 255, 0.92);
  --bg-topbar: rgba(255, 255, 255, 0.86);
  --bg-login-card: linear-gradient(180deg, #ffffff 0%, #f7faff 100%);
  --bg-body:
    radial-gradient(1100px 520px at 8% -8%, rgba(47, 120, 239, 0.12), transparent 55%),
    radial-gradient(900px 480px at 92% 0%, rgba(20, 184, 166, 0.10), transparent 50%),
    linear-gradient(160deg, #eef3fa 0%, #f7f9fc 45%, #eef2f8 100%);
  --line: rgba(15, 23, 42, 0.08);
  --text: #1a2332;
  --muted: #6b7a90;
  --accent: #2f78ef;
  --accent-2: #14b8a6;
  --danger: #e5484d;
  --ok: #1a9d6c;
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
  --menu-hover: rgba(47, 120, 239, 0.08);
  --menu-active-bg: linear-gradient(90deg, rgba(47, 120, 239, 0.12), rgba(20, 184, 166, 0.06));
  --menu-active-border: rgba(47, 120, 239, 0.22);
  --menu-active-text: #1a2332;
  --stat-bg: rgba(47, 120, 239, 0.08);
  --stat-border: rgba(47, 120, 239, 0.18);
  --stat-text: #2a4a7a;
  --link-color: #2f6fdb;
  --input-bg: #f8fafc;
  --input-border: rgba(15, 23, 42, 0.12);
  --table-header-bg: #f4f7fb;
  --table-hover: rgba(47, 120, 239, 0.05);
  --dialog-bg: #ffffff;
  --pagination-btn: #f1f5f9;
  --theme-btn-bg: #f1f5f9;
  --theme-btn-hover: #e2e8f0;
  --radius: 14px;
  --font: "DM Sans", "Noto Sans SC", sans-serif;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg-deep: #0b1220;
  --bg-panel: #121a2b;
  --bg-elevated: #18233a;
  --bg-sider: rgba(10, 16, 28, 0.72);
  --bg-topbar: rgba(11, 18, 32, 0.55);
  --bg-login-card: linear-gradient(180deg, rgba(24, 35, 58, 0.92), rgba(18, 26, 43, 0.96));
  --bg-body:
    radial-gradient(1200px 600px at 10% -10%, rgba(61, 139, 253, 0.22), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(34, 195, 166, 0.16), transparent 50%),
    linear-gradient(160deg, #070b14 0%, #0d1526 45%, #0a101c 100%);
  --line: rgba(148, 163, 184, 0.14);
  --text: #e8eef9;
  --muted: #93a4c3;
  --accent: #3d8bfd;
  --accent-2: #22c3a6;
  --danger: #f07178;
  --ok: #3dd68c;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --menu-hover: rgba(61, 139, 253, 0.08);
  --menu-active-bg: linear-gradient(90deg, rgba(61, 139, 253, 0.22), rgba(34, 195, 166, 0.08));
  --menu-active-border: rgba(61, 139, 253, 0.28);
  --menu-active-text: #ffffff;
  --stat-bg: rgba(61, 139, 253, 0.12);
  --stat-border: rgba(61, 139, 253, 0.22);
  --stat-text: #cfe2ff;
  --link-color: #9ec5ff;
  --input-bg: rgba(8, 14, 26, 0.65);
  --input-border: rgba(148, 163, 184, 0.18);
  --table-header-bg: rgba(8, 14, 26, 0.55);
  --table-hover: rgba(61, 139, 253, 0.08);
  --dialog-bg: #121a2b;
  --pagination-btn: rgba(8, 14, 26, 0.5);
  --theme-btn-bg: rgba(24, 35, 58, 0.9);
  --theme-btn-hover: rgba(36, 50, 78, 0.95);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-body);
  transition: background .25s ease, color .2s ease;
}

a { color: inherit; text-decoration: none; }

.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
}
.login-theme-btn {
  position: absolute;
  top: 20px;
  right: 20px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--bg-login-card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 36px 32px 28px;
  backdrop-filter: blur(10px);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  font-weight: 700; color: #061018; letter-spacing: -0.02em;
}
.brand h1 {
  margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
}
.brand-sub {
  margin: 0 0 28px; color: var(--muted); font-size: 13px;
}

.layout {
  height: 100%;
  display: grid;
  grid-template-columns: 240px 1fr;
}
.sider {
  background: var(--bg-sider);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  backdrop-filter: blur(12px);
}
.sider .brand { padding: 6px 8px 18px; margin-bottom: 4px; }
.sider .brand h1 { font-size: 16px; }
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 12px;
  color: var(--muted); cursor: pointer;
  transition: all .18s ease;
  border: 1px solid transparent;
}
.menu-item:hover { color: var(--text); background: var(--menu-hover); }
.menu-item.active {
  color: var(--menu-active-text);
  background: var(--menu-active-bg);
  border-color: var(--menu-active-border);
}
.main {
  display: flex; flex-direction: column; min-width: 0;
}
.topbar {
  height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-topbar);
  backdrop-filter: blur(10px);
}
.topbar-title { font-size: 18px; font-weight: 600; }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.content { padding: 20px 24px 32px; overflow: auto; flex: 1; }

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px;
}
.toolbar .spacer { flex: 1; }
.stat-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 999px;
  background: var(--stat-bg);
  border: 1px solid var(--stat-border);
  color: var(--stat-text); font-size: 13px;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--theme-btn-bg);
  color: var(--text);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: background .18s ease, transform .18s ease, border-color .18s ease;
}
.theme-toggle:hover {
  background: var(--theme-btn-hover);
  transform: translateY(-1px);
}
.theme-toggle .el-icon {
  font-size: 18px;
}

/* Element Plus theme-aware overrides */
.el-input__wrapper, .el-textarea__inner {
  background: var(--input-bg) !important;
  box-shadow: 0 0 0 1px var(--input-border) inset !important;
}
.el-table {
  --el-table-bg-color: transparent;
  --el-table-tr-bg-color: transparent;
  --el-table-header-bg-color: var(--table-header-bg);
  --el-table-row-hover-bg-color: var(--table-hover);
  --el-table-text-color: var(--text);
  --el-table-header-text-color: var(--muted);
  --el-table-border-color: var(--line);
  width: 100% !important;
}
.el-table__inner-wrapper,
.el-table__header-wrapper,
.el-table__body-wrapper,
.el-table__header,
.el-table__body {
  width: 100% !important;
}
.el-pagination { --el-pagination-bg-color: transparent; --el-pagination-button-bg-color: var(--pagination-btn); }
.el-dialog {
  --el-dialog-bg-color: var(--dialog-bg);
  border: 1px solid var(--line);
  border-radius: 16px !important;
}
.el-form-item__label { color: var(--muted) !important; }
.el-button--primary {
  --el-button-bg-color: #2f78ef;
  --el-button-border-color: #2f78ef;
}
.link-cell {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--link-color);
}
.muted { color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sider { display: none; }
}
