/* FRP 管理面板样式 */
:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text2: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-grad: linear-gradient(135deg, #3b82f6, #2563eb);
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #d97706;
  --sidebar: #0f172a;
  --sidebar2: #1e293b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .16);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
.hidden { display: none !important; }
a { color: var(--primary); text-decoration: none; }
code { background: #eef2ff; border-radius: 4px; padding: 1px 6px; font-size: 12.5px; word-break: break-all; }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.sidebar ::-webkit-scrollbar-thumb { background: #334155; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block; border: 1px solid var(--border); background: #fff;
  color: var(--text); border-radius: 8px; padding: 7px 14px; font-size: 13.5px;
  cursor: pointer; transition: all .15s; line-height: 1.4;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn.primary { background: var(--primary-grad); border-color: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(37, 99, 235, .25); }
.btn.primary:hover { background: linear-gradient(135deg, #2f74ed, var(--primary-dark)); box-shadow: 0 4px 12px rgba(37, 99, 235, .35); transform: translateY(-1px); }
.btn.primary:active { transform: translateY(0); }
.btn.danger { color: var(--red); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; border-color: var(--red); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.block { display: block; width: 100%; margin-top: 18px; }
.btn.ghost { background: transparent; border-color: #334155; color: #cbd5e1; }
.btn.ghost:hover { background: var(--sidebar2); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.link { border: none; background: none; color: var(--primary); padding: 2px 6px; }
.btn.link:hover { text-decoration: underline; background: none; }
.btn.link.danger { color: var(--red); }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(600px 400px at 15% 20%, rgba(37, 99, 235, .35), transparent 60%),
    radial-gradient(500px 360px at 85% 80%, rgba(14, 165, 233, .28), transparent 60%),
    linear-gradient(135deg, #0b1220 0%, #0f172a 45%, #1e3a5f 100%);
}
.login-card {
  width: 380px; max-width: 100%; background: #fff; border-radius: 16px;
  padding: 40px 36px 30px; box-shadow: 0 24px 60px rgba(0, 0, 0, .4);
  animation: rise .45s cubic-bezier(.2, .8, .3, 1);
}
.login-logo { display: flex; align-items: center; gap: 12px; }
.login-badge {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  background: var(--primary-grad); display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(37, 99, 235, .35);
}
.login-logo-text { font-size: 24px; font-weight: 800; letter-spacing: .5px; color: var(--sidebar); }
.login-logo-text em { font-style: normal; color: var(--primary); }
.login-sub { color: var(--text2); margin: 6px 0 24px; font-size: 13px; }
.login-card label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--text2); }
.login-err { color: var(--red); font-size: 13px; min-height: 20px; margin: 10px 0 0; text-align: center; }

/* 验证码行 */
.captcha-row { display: flex; gap: 10px; align-items: stretch; }
.captcha-row input { flex: 1; letter-spacing: 2px; }
.captcha-img {
  width: 130px; height: 42px; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; flex-shrink: 0; display: block; background: #f1f5f9;
  transition: border-color .15s, opacity .15s;
}
.captcha-img:hover { border-color: var(--primary); opacity: .9; }

/* ---------- 布局 ---------- */
.layout { display: flex; flex-direction: column; min-height: 100vh; }
.layout-body { display: flex; flex: 1; align-items: stretch; }
.topbar { display: none; }
.sidebar {
  width: 210px; flex-shrink: 0; color: #cbd5e1;
  background: linear-gradient(180deg, #0f172a 0%, #111c33 60%, #132038 100%);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.logo { display: flex; align-items: center; gap: 9px; font-size: 20px; font-weight: 700; color: #fff; padding: 22px 22px 18px; }
.logo span { color: #60a5fa; }
.logo-badge {
  width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  background: var(--primary-grad); display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 8px rgba(37, 99, 235, .4);
}
#nav { flex: 1; padding: 6px 12px; overflow-y: auto; }
#nav a {
  position: relative; display: flex; align-items: center; gap: 10px; color: #94a3b8;
  padding: 10px 14px; border-radius: 8px; margin-bottom: 4px; font-size: 14px;
  transition: color .15s, background .15s;
}
#nav a:hover { color: #e2e8f0; background: var(--sidebar2); }
#nav a.active { color: #fff; background: rgba(37, 99, 235, .85); }
#nav a.active::before {
  content: ""; position: absolute; left: 0; top: 20%; bottom: 20%; width: 3px;
  border-radius: 3px; background: #93c5fd;
}
#nav .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .5; }
.sidebar-foot { padding: 16px 20px 20px; border-top: 1px solid #1e293b; }
.whoami { font-size: 13px; color: #e2e8f0; margin-bottom: 10px; }
.main { flex: 1; min-width: 0; padding: 26px 30px 50px; }
.page { max-width: 1100px; }
.page > * { animation: fadein .25s ease-out; }
.page-title { font-size: 20px; margin: 0 0 18px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-head .page-title { margin: 0; }

/* ---------- 卡片 / 统计 ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.card h3 { margin: 0 0 14px; font-size: 15px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-num { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-num.green { color: var(--green); }
.stat-num.red { color: var(--red); }
.stat-label { color: var(--text2); font-size: 13px; margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; }
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- 条形图 ---------- */
.bars { display: flex; align-items: flex-end; gap: 14px; height: 170px; padding-top: 8px; }
.bar-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar {
  width: 60%; max-width: 46px; background: linear-gradient(180deg, #60a5fa, var(--primary));
  border-radius: 6px 6px 2px 2px; min-height: 3px; transition: filter .15s;
}
.bar-item:hover .bar { filter: brightness(1.1); }
.bar-label { font-size: 12px; color: var(--text2); }
.top-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.top-name { width: 90px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-bar { flex: 1; height: 12px; background: #eef2f7; border-radius: 6px; overflow: hidden; }
.top-bar i { display: block; height: 100%; background: linear-gradient(90deg, #34d399, var(--green)); border-radius: 6px; }
.top-val { width: 86px; font-size: 12.5px; color: var(--text2); }

/* ---------- 表格 ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #f1f5f9; font-size: 13.5px; vertical-align: middle; }
.tbl th { color: var(--text2); font-weight: 500; font-size: 12.5px; white-space: nowrap; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: #f8fafc; }
.tbl .actions { white-space: nowrap; }
.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 7px 4px; border-bottom: 1px solid #f1f5f9; }
.kv td:first-child { color: var(--text2); width: 160px; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500; line-height: 1.6;
}
.badge.green { background: #dcfce7; color: var(--green); }
.badge.gray { background: #f1f5f9; color: var(--text2); }
.badge.yellow { background: #fef3c7; color: var(--yellow); }
.badge.red { background: #fee2e2; color: var(--red); }
.badge.blue { background: #dbeafe; color: var(--primary); }

/* ---------- 表单 ---------- */
label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--text2); }
label.chk { display: flex; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }
input, select, textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px #dbeafe; }
input[type="checkbox"] { width: auto; }
.hint { font-size: 12px; color: var(--text2); margin-top: 4px; }
.form-actions { margin-top: 22px; display: flex; gap: 10px; justify-content: flex-end; }
.form-row { display: flex; gap: 12px; }
.form-row > div { flex: 1; }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  display: flex; align-items: flex-start; justify-content: center; z-index: 100;
  padding: 60px 16px 30px; overflow-y: auto;
}
.modal {
  width: 520px; max-width: 100%; background: #fff; border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
  animation: rise .3s cubic-bezier(.2, .8, .3, 1);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); font-size: 15px; font-weight: 600;
}
.modal-x { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--text2); line-height: 1; padding: 0 2px; }
.modal-body { padding: 6px 20px 22px; }

/* ---------- Toast ---------- */
#toast-box { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; }
.toast {
  background: #0f172a; color: #fff; border-radius: 8px; padding: 10px 20px;
  margin-bottom: 10px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  animation: toast-in .2s ease-out; max-width: 480px;
}
.toast.err { background: #b91c1c; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- 动画 ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 其他 ---------- */
.empty { color: var(--text2); text-align: center; padding: 36px 0; }
.loading { color: var(--text2); text-align: center; padding: 60px 0; }
.info-bar { display: flex; flex-wrap: wrap; gap: 22px; margin-bottom: 6px; }
.info-item { font-size: 13px; color: var(--text2); }
.info-item b { color: var(--text); font-weight: 600; margin-left: 4px; }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 14px; font-size: 13px; color: var(--text2); }
.mono { font-family: Consolas, Monaco, monospace; font-size: 12.5px; }
.download-list a { display: inline-block; margin: 2px 8px 2px 0; }
.section-title { font-size: 13px; font-weight: 600; color: var(--text2); margin: 18px 0 8px; }
ol.steps { margin: 6px 0 0; padding-left: 20px; }
ol.steps li { margin-bottom: 4px; }

/* ================= 移动端适配（≤768px） ================= */
@media (max-width: 768px) {
  /* 顶部栏 */
  .topbar {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 60;
    height: 52px; padding: 0 14px; flex-shrink: 0;
    background: linear-gradient(180deg, #0f172a, #111c33);
  }
  .topbar-logo { font-size: 17px; font-weight: 700; color: #fff; }
  .topbar-logo span { color: #60a5fa; }
  .topbar-user {
    margin-left: auto; font-size: 13px; color: #cbd5e1;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .menu-btn {
    width: 36px; height: 36px; flex-shrink: 0; position: relative;
    border: none; border-radius: 8px; background: rgba(255, 255, 255, .08);
    cursor: pointer;
  }
  .menu-btn::before {
    content: ""; position: absolute; left: 9px; right: 9px; top: 12px; height: 2px;
    border-radius: 2px; background: #fff;
    box-shadow: 0 5px 0 #fff, 0 10px 0 #fff;
  }
  body.sidebar-open { overflow: hidden; }

  /* 侧栏 → 抽屉 */
  .sidebar {
    position: fixed; top: 52px; bottom: 0; left: 0; height: auto; width: 240px;
    transform: translateX(-100%); transition: transform .25s ease; z-index: 90;
  }
  body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 10px 0 30px rgba(0, 0, 0, .35); }
  .sidebar-mask { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 80; }

  /* 主区与通用间距 */
  .main { padding: 16px 14px 44px; }
  .page-head { flex-wrap: wrap; gap: 10px; }
  .card { padding: 14px; }
  .info-bar { gap: 8px 16px; }
  .form-row { flex-direction: column; gap: 0; }
  .form-actions { flex-wrap: wrap; }
  .pager { justify-content: center; flex-wrap: wrap; }
  .toast { max-width: calc(100vw - 40px); }

  /* 含表格的卡片：容器透明化，让行卡片直接展示 */
  .card:has(> table.tbl) { border: none; background: transparent; padding: 0 !important; box-shadow: none; margin-bottom: 0; }

  /* 表格卡片化 */
  .tbl thead { display: none; }
  .tbl, .tbl tbody { display: block; }
  .tbl tr {
    display: block; margin-bottom: 10px; padding: 4px 12px;
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    box-shadow: var(--shadow);
  }
  .tbl td {
    display: block; position: relative; padding: 8px 2px 8px 92px;
    border-bottom: 1px dashed #eef2f7; text-align: left;
    min-height: 20px; word-break: break-all;
  }
  .tbl td:last-child { border-bottom: none; }
  .tbl td::before {
    content: attr(data-label);
    position: absolute; left: 2px; top: 8px;
    max-width: 84px; color: var(--text2); font-size: 12.5px;
  }
  .tbl td.actions { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; }
  /* 兜底：漏加 data-label 的单元格不显示伪标签 */
  .tbl td:not([data-label])::before { content: none; }
  .tbl td:not([data-label]) { padding-left: 2px; }

  /* kv 信息表 */
  .kv td:first-child { width: 104px; }
  .kv td { word-break: break-all; }

  /* 图表 */
  .bars { gap: 8px; height: 150px; }
  .top-row .top-name { width: 72px; }
  .top-row .top-val { width: 72px; font-size: 12px; }

  /* 模态框 */
  .modal-mask { padding: 20px 12px 24px; }
  .modal { width: 100%; }
  .modal-body { padding: 6px 16px 20px; }

  /* 登录页 */
  .login-card { padding: 30px 22px 24px; border-radius: 14px; }
  .login-wrap { padding: 16px; }
}

/* 超小屏（≤400px）微调 */
@media (max-width: 400px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-num { font-size: 22px; }
  .tbl td { padding-left: 80px; }
  .tbl td::before { max-width: 72px; }
}
