:root {
  --tech-blue: #2563eb;
  --tech-blue-2: #38bdf8;
  --tech-blue-deep: #1e3a8a;
  --bg: #0b1220;
  --bg-soft: #0f1830;
  --panel: rgba(255, 255, 255, 0.04);
  --panel-border: rgba(120, 160, 255, 0.14);
  --text: #e8eefc;
  --text-dim: #9fb0d0;
  --text-mute: #6b7a99;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --glow: 0 0 0 1px rgba(56, 189, 248, 0.25), 0 8px 30px rgba(37, 99, 235, 0.25);
}

/* ---------- 浅色主题 ---------- */
[data-theme="light"] {
  --bg: #eef2f8;
  --bg-soft: #e3e9f3;
  --panel: rgba(255, 255, 255, 0.85);
  --panel-border: rgba(37, 99, 235, 0.16);
  --text: #0f1830;
  --text-dim: #4b5876;
  --text-mute: #8693ad;
  --shadow: 0 18px 50px rgba(30, 58, 138, 0.12);
  --glow: 0 0 0 1px rgba(56, 189, 248, 0.25), 0 8px 30px rgba(37, 99, 235, 0.18);
}
[data-theme="light"] body {
  background:
    radial-gradient(1200px 700px at 12% -10%, rgba(37, 99, 235, 0.16), transparent 60%),
    radial-gradient(1000px 600px at 100% 0%, rgba(56, 189, 248, 0.12), transparent 55%),
    linear-gradient(160deg, var(--bg), var(--bg-soft));
}
[data-theme="light"] .input,
[data-theme="light"] .select,
[data-theme="light"] .textarea { background: rgba(15, 24, 48, 0.04); color: var(--text); }
[data-theme="light"] .btn-ghost { background: rgba(15, 24, 48, 0.04); }
[data-theme="light"] .btn-ghost:hover { background: rgba(15, 24, 48, 0.08); }
[data-theme="light"] .sidebar { background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(238,242,248,.95)); border-right-color: var(--panel-border); }
[data-theme="light"] .modal { background: linear-gradient(160deg, #ffffff, #f3f6fb); }
[data-theme="light"] .toast { background: rgba(255,255,255,.96); color: var(--text); }
[data-theme="light"] .metric .value { background: linear-gradient(135deg, var(--tech-blue-deep), var(--tech-blue)); -webkit-background-clip: text; background-clip: text; }
[data-theme="light"] .list-item:hover { background: rgba(15,24,48,.03); }
[data-theme="light"] .modal-mask { background: rgba(20, 30, 56, 0.35); }

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 主题切换平滑过渡 */
body, .sidebar, .auth-card, .card, .panel, .modal, .toast,
.input, .select, .textarea, .btn-ghost, .nav-item, .seg, .tag {
  transition: background-color .35s ease, color .35s ease, border-color .35s ease, box-shadow .35s ease;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 12% -10%, rgba(37, 99, 235, 0.28), transparent 60%),
    radial-gradient(1000px 600px at 100% 0%, rgba(56, 189, 248, 0.18), transparent 55%),
    linear-gradient(160deg, var(--bg), var(--bg-soft));
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 登录/注册 ---------- */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.auth-card {
  width: 100%; max-width: 420px; padding: 38px 34px;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  backdrop-filter: blur(20px); box-shadow: var(--shadow);
  animation: rise .5s cubic-bezier(.16,1,.3,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.brand .logo {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--tech-blue), var(--tech-blue-2));
  box-shadow: var(--glow); font-weight: 800; font-size: 20px; color: #fff;
}
.brand h1 { font-size: 19px; letter-spacing: .5px; }
.brand p { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 7px; }
.input, .select, .textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.05); border: 1px solid var(--panel-border); color: var(--text);
  font-size: 14px; outline: none; transition: border-color .2s, box-shadow .2s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--tech-blue-2); box-shadow: 0 0 0 3px rgba(56,189,248,.15); }
.textarea { min-height: 120px; resize: vertical; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%); background-position: calc(100% - 18px) 17px, calc(100% - 13px) 17px; background-size: 5px 5px; background-repeat: no-repeat; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 14px; font-weight: 600; transition: transform .15s, box-shadow .2s, background .2s;
}
.btn-primary { background: linear-gradient(135deg, var(--tech-blue), var(--tech-blue-2)); color: #fff; box-shadow: var(--glow); }
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost { background: rgba(255,255,255,.05); border-color: var(--panel-border); color: var(--text); }
.btn-ghost:hover { background: rgba(255,255,255,.09); }
.btn-danger { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.3); color: var(--danger); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.link { color: var(--tech-blue-2); font-size: 13px; cursor: pointer; }
.link:hover { text-decoration: underline; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.hint { font-size: 12px; color: var(--text-mute); margin-top: 14px; text-align: center; }

/* ---------- 布局 ---------- */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 22px 16px;
  background: linear-gradient(180deg, rgba(15,24,48,.9), rgba(11,18,32,.92));
  border-right: 1px solid var(--panel-border); backdrop-filter: blur(12px);
  display: flex; flex-direction: column;
}
.sidebar .brand { margin-bottom: 22px; padding: 0 6px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 14px; transition: background .2s, color .2s; cursor: pointer;
  border: 1px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.04); color: var(--text); }
.nav-item.active { background: rgba(37,99,235,.16); color: #fff; border-color: rgba(56,189,248,.3); box-shadow: inset 0 0 0 1px rgba(56,189,248,.12); }
.nav-item .ic { width: 18px; text-align: center; }
.sidebar .me { margin-top: auto; padding: 12px; border-radius: var(--radius-sm); background: rgba(255,255,255,.04); border: 1px solid var(--panel-border); }
.sidebar .me .name { font-size: 13px; font-weight: 600; }
.sidebar .me .role { font-size: 11px; color: var(--text-mute); }

.main { padding: 28px 34px 60px; overflow-x: hidden; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.page-head h2 { font-size: 22px; letter-spacing: .5px; }
.page-head .sub { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

/* ---------- 卡片/网格 ---------- */
.grid { display: grid; gap: 18px; }
.cards-4 { grid-template-columns: repeat(4, 1fr); }
.cards-3 { grid-template-columns: repeat(3, 1fr); }
.cards-2 { grid-template-columns: repeat(2, 1fr); }
.card {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius);
  padding: 20px; backdrop-filter: blur(14px); transition: transform .25s cubic-bezier(.16,1,.3,1), box-shadow .25s, border-color .25s;
}
.card.hover:hover { transform: translateY(-3px); border-color: rgba(56,189,248,.35); box-shadow: var(--shadow); }
.metric .label { font-size: 13px; color: var(--text-dim); }
.metric .value { font-size: 30px; font-weight: 800; margin-top: 8px; letter-spacing: .5px;
  background: linear-gradient(135deg, #fff, var(--tech-blue-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.metric .delta { font-size: 12px; margin-top: 6px; color: var(--text-mute); }

/* ---------- 表格/列表 ---------- */
.panel { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); padding: 6px; backdrop-filter: blur(14px); }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius-sm); transition: background .18s; border: 1px solid transparent; }
.list-item:hover { background: rgba(255,255,255,.03); }
.list-item + .list-item { border-top: 1px solid rgba(255,255,255,.05); }
.list-item .title { font-size: 14px; font-weight: 600; }
.list-item .meta { font-size: 12px; color: var(--text-mute); margin-top: 3px; }
.list-item .grow { flex: 1; min-width: 0; }
.tag { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: rgba(56,189,248,.14); color: var(--tech-blue-2); border: 1px solid rgba(56,189,248,.25); }
.tag.gray { background: rgba(255,255,255,.06); color: var(--text-dim); border-color: rgba(255,255,255,.1); }
.tag.green { background: rgba(52,211,153,.14); color: var(--ok); border-color: rgba(52,211,153,.3); }
.tag.amber { background: rgba(251,191,36,.14); color: var(--warn); border-color: rgba(251,191,36,.3); }
.tag.red { background: rgba(248,113,113,.14); color: var(--danger); border-color: rgba(248,113,113,.3); }

/* ---------- tabs/seg ---------- */
.seg { display: inline-flex; padding: 4px; gap: 4px; background: rgba(255,255,255,.05); border: 1px solid var(--panel-border); border-radius: 12px; }
.seg button { padding: 7px 14px; border-radius: 9px; border: none; background: transparent; color: var(--text-dim); font-size: 13px; font-weight: 600; transition: background .2s, color .2s; }
.seg button.active { background: linear-gradient(135deg, var(--tech-blue), var(--tech-blue-2)); color: #fff; }

/* ---------- 主题切换 ---------- */
.theme-sw { display: flex; gap: 4px; padding: 4px; background: rgba(255,255,255,.05); border: 1px solid var(--panel-border); border-radius: 12px; margin-top: 12px; }
.theme-sw button { flex: 1; padding: 7px 4px; border-radius: 9px; border: none; background: transparent; color: var(--text-dim); font-size: 12px; font-weight: 600; transition: background .2s, color .2s; cursor: pointer; }
.theme-sw button .ic { margin-right: 3px; }
.theme-sw button.active { background: linear-gradient(135deg, var(--tech-blue), var(--tech-blue-2)); color: #fff; }
.theme-label { font-size: 11px; color: var(--text-mute); margin-top: 10px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

/* ---------- modal ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(5,8,16,.6); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 50; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { width: 100%; max-width: 560px; max-height: 86vh; overflow: auto; padding: 26px; background: linear-gradient(160deg, #122042, #0d1730); border: 1px solid var(--panel-border); border-radius: var(--radius); box-shadow: var(--shadow); }
.modal h3 { font-size: 17px; margin-bottom: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- 图表（CSS 柱状） ---------- */
.bars { display: flex; align-items: flex-end; gap: 12px; height: 180px; padding: 10px 4px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar { width: 60%; border-radius: 8px 8px 0 0; background: linear-gradient(180deg, var(--tech-blue-2), var(--tech-blue)); transition: height .6s cubic-bezier(.16,1,.3,1); position: relative; }
.bar.alt { background: linear-gradient(180deg, #a78bfa, #7c3aed); }
.bar-col .bl { font-size: 11px; color: var(--text-mute); }

/* ---------- toast ---------- */
.toast { position: fixed; top: 22px; left: 50%; transform: translateX(-50%) translateY(-20px); background: rgba(15,24,48,.96); border: 1px solid var(--panel-border); color: var(--text); padding: 12px 20px; border-radius: 12px; font-size: 13px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .3s; z-index: 100; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(248,113,113,.4); }
.toast.ok { border-color: rgba(52,211,153,.4); }

.empty { text-align: center; padding: 50px 20px; color: var(--text-mute); font-size: 14px; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -3px; }
@keyframes sp { to { transform: rotate(360deg); } }

.section-title { font-size: 14px; color: var(--text-dim); margin: 26px 0 12px; font-weight: 600; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar .me { margin: 0; }
  .cards-4, .cards-3, .cards-2 { grid-template-columns: 1fr 1fr; }
}
