:root {
  --bg: #11111b;
  --panel: #1e1e2e;
  --panel-2: #181825;
  --border: #313244;
  --text: #cdd6f4;
  --muted: #a6adc8;
  --blue: #89b4fa;
  --green: #a6e3a1;
  --red: #f38ba8;
  --yellow: #f9e2af;
  --peach: #fab387;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button, input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- 登录 ---------- */
#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, #1e1e3a 0, var(--bg) 60%);
}
.login-card {
  width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 34px 32px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .45);
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; color: var(--blue); }
.login-card p.sub { margin: 0 0 24px; color: var(--muted); font-size: 12px; }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); }
.login-error { color: var(--red); font-size: 12px; min-height: 18px; margin-bottom: 6px; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--border);
  background: #313244;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
}
.btn:hover { background: #45475a; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #11111b; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--red); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-link { background: none; border: none; color: var(--blue); cursor: pointer; padding: 0 6px; }

/* ---------- 应用框架 ---------- */
#app-view { display: none; min-height: 100vh; }
#app-view.active { display: flex; }
.sidebar {
  width: 210px;
  background: var(--panel-2);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  flex-shrink: 0;
}
.logo { color: var(--blue); font-weight: 700; font-size: 16px; padding: 4px 10px 20px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 4px;
  user-select: none;
}
.nav-item:hover { background: #313244; color: var(--text); }
.nav-item.active { background: #45475a; color: var(--blue); font-weight: 600; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 22px;
  gap: 12px;
}
.topbar .title { font-size: 15px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 12px; }
.content { padding: 22px; overflow: auto; flex: 1; }

/* ---------- 卡片 / 表格 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.toolbar input, .toolbar select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--blue); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
tr:hover td { background: #181825; }
td.actions { white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 34px 0; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9px;
  font-size: 11px;
  background: #313244;
  color: var(--muted);
}
.badge.green { background: rgba(166, 227, 161, .16); color: var(--green); }
.badge.red { background: rgba(243, 139, 168, .16); color: var(--red); }
.badge.yellow { background: rgba(249, 226, 175, .16); color: var(--yellow); }
.badge.blue { background: rgba(137, 180, 250, .16); color: var(--blue); }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--muted); font-size: 12px; }
.pager button { padding: 4px 10px; }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  width: 520px; max-width: calc(100vw - 40px);
  max-height: calc(100vh - 80px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
}
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.hint { color: var(--muted); font-size: 12px; }
.mono { font-family: Consolas, monospace; }
.codes { width: 100%; height: 190px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 10px; }

/* ---------- Toast ---------- */
#toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #313244; color: var(--text); border-left: 3px solid var(--blue);
  padding: 10px 16px; border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  font-size: 13px; animation: fade .2s ease;
}
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }
@keyframes fade { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; } }

@media (max-width: 860px) {
  .sidebar { width: 64px; }
  .sidebar .nav-item span.label { display: none; }
  .logo { font-size: 0; text-align: center; }
  .logo::after { content: "LY"; font-size: 14px; }
}
