/* ════════════════════════════════════════════════
   卡密系统 · 作者端样式（暗色/亮色主题 · 无外部依赖）
   ════════════════════════════════════════════════ */
:root {
  --bg: #0f1419;
  --bg-2: #151b23;
  --panel: #1a222c;
  --panel-2: #212b38;
  --border: #2a3644;
  --text: #e6edf3;
  --text-2: #9fb0c0;
  --text-3: #6b7d90;
  --primary: #3b82f6;
  --primary-h: #2563eb;
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --teal: #14b8a6;
  --purple: #a855f7;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,.25);
  --sidebar-w: 220px;
}
:root[data-theme="light"] {
  --bg: #f4f6f9;
  --bg-2: #eef1f5;
  --panel: #ffffff;
  --panel-2: #f7f9fb;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-2: #64748b;
  --text-3: #94a3b8;
  --shadow: 0 2px 12px rgba(15,23,42,.08);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  font-size: 14px; background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--text-3); font-size: 12px; }
.mt8 { margin-top: 8px; }

/* ── 登录 ── */
#loginView {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1e3a5f 0%, var(--bg) 60%);
}
.login-box {
  width: 380px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 34px 30px; box-shadow: var(--shadow);
}
.login-logo { font-size: 34px; text-align: center; margin-bottom: 8px; }
.login-box h1 { font-size: 19px; text-align: center; margin-bottom: 4px; }
.login-box .sub { text-align: center; font-size: 12px; color: var(--text-3); margin-bottom: 22px; }
.login-box .lbl { display: block; font-size: 12px; color: var(--text-2); margin: 10px 0 5px; }
.login-box input {
  width: 100%; padding: 11px 13px; background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; outline: none;
}
.login-box input:focus { border-color: var(--primary); }
.login-err { color: var(--danger); font-size: 12px; min-height: 18px; margin-top: 8px; }
.login-tip { text-align: center; font-size: 11px; color: var(--text-3); margin-top: 14px; }

/* ── 布局 ── */
#mainView { display: flex; height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--bg-2);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 16px 18px; font-weight: 700; font-size: 16px; border-bottom: 1px solid var(--border); }
.brand-icon { font-size: 20px; }
#nav { flex: 1; overflow-y: auto; padding: 8px 10px; }
.nav-group { font-size: 11px; color: var(--text-3); padding: 12px 10px 5px; letter-spacing: .5px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--text-2); cursor: pointer; font-size: 13.5px; margin-bottom: 2px; user-select: none;
}
.nav-item i { font-style: normal; font-size: 15px; width: 18px; text-align: center; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: var(--primary); color: #fff; }
.sidebar-foot { padding: 12px 18px; font-size: 11px; color: var(--text-3); border-top: 1px solid var(--border); }
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.app-switcher {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 10px; font-size: 13px; outline: none; max-width: 180px;
}
.icon-btn { background: transparent; border: 0; color: var(--text-2); font-size: 17px; cursor: pointer; padding: 5px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--panel-2); }
.user-menu { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.role-tag { font-size: 11px; padding: 2px 7px; border-radius: 10px; background: var(--panel-2); color: var(--text-2); }
.main-scroll { flex: 1; overflow-y: auto; padding: 20px; }
.view { max-width: 1360px; margin: 0 auto; }

/* ── 面板 ── */
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head h3 { font-size: 15px; font-weight: 600; }
.panel-head .legend { margin-left: auto; font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.dot-a { background: var(--primary); } .dot-b { background: var(--success); }

/* ── 统计卡片 ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; position: relative; overflow: hidden;
}
.stat-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--primary); }
.stat-card .num { font-size: 27px; font-weight: 700; line-height: 1.1; }
.stat-card .label { font-size: 12px; color: var(--text-2); margin-top: 5px; }
.stat-card.c-blue::before { background: var(--primary); }
.stat-card.c-green::before { background: var(--success); }
.stat-card.c-red::before { background: var(--danger); }
.stat-card.c-orange::before { background: var(--warn); }
.stat-card.c-teal::before { background: var(--teal); }
.stat-card.c-purple::before { background: var(--purple); }

/* ── 图表 ── */
.chart-row { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.chart-box { width: 100%; height: 260px; }
.chart-box svg { width: 100%; height: 100%; overflow: visible; }
@media (max-width: 900px) { .chart-row { grid-template-columns: 1fr; } }

/* ── 最近动态 ── */
.recent-list { display: flex; flex-direction: column; gap: 2px; }
.recent-item { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-bottom: 1px solid var(--border); font-size: 13px; }
.recent-item:last-child { border-bottom: 0; }

/* ── 表单 ── */
.form-grid { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.row-inline { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.grow { flex: 1; min-width: 180px; }
.field label { font-size: 12px; color: var(--text-2); }
.field input, .field select, .textarea {
  padding: 9px 11px; background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; outline: none; min-width: 120px;
}
.field input:focus, .field select:focus, .textarea:focus { border-color: var(--primary); }
.textarea { width: 100%; min-height: 90px; resize: vertical; font-family: inherit; }
.row-inline .textarea { flex: 1; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 14px; }
.batch-bar { display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin-bottom: 12px; background: var(--panel-2); border-radius: var(--radius-sm); font-size: 13px; }
.batch-bar b { color: var(--primary); }

/* ── 按钮 ── */
.btn { padding: 9px 16px; border: 0; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 500; transition: .15s; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; } .btn-primary:hover { background: var(--primary-h); }
.btn-success { background: var(--success); color: #fff; } .btn-success:hover { filter: brightness(.93); }
.btn-danger { background: var(--danger); color: #fff; } .btn-danger:hover { filter: brightness(.93); }
.btn-warn { background: var(--warn); color: #1a222c; }
.btn-plain { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); } .btn-plain:hover { border-color: var(--primary); }

/* ── 表格 ── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; font-size: 13px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-2); font-weight: 600; background: var(--panel-2); position: sticky; top: 0; }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: 0; }
.col-check { width: 36px; } .col-ops { width: 1%; }
/* 操作列固定右侧：表格横向滚动时，封/解绑/续期 等按钮始终可见 */
th:last-child { position: sticky; right: 0; z-index: 3; }
td:last-child { position: sticky; right: 0; z-index: 2; background: var(--panel); box-shadow: -8px 0 8px -8px rgba(0,0,0,.35); }
tbody tr:hover td:last-child { background: var(--panel-2); }
td .code { font-family: Consolas, monospace; letter-spacing: .5px; }
.badge { padding: 3px 9px; border-radius: 10px; font-size: 12px; display: inline-block; }
.badge-new { background: rgba(59,130,246,.16); color: #60a5fa; }
.badge-activated { background: rgba(34,197,94,.16); color: #4ade80; }
.badge-banned { background: rgba(239,68,68,.16); color: #f87171; }
.badge-permanent { background: rgba(168,85,247,.16); color: #c084fc; }
.badge-points { background: rgba(20,184,166,.16); color: #2dd4bf; }
.badge-days { background: rgba(245,158,11,.16); color: #fbbf24; }
.op-btn { font-size: 12px; padding: 4px 9px; margin-right: 4px; border-radius: 6px; border: 0; cursor: pointer; color: #fff; }
.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin-top: 14px; }
.pager span { font-size: 13px; color: var(--text-2); }

.result-box { margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; max-height: 240px; overflow-y: auto; background: var(--bg-2); white-space: pre-wrap; word-break: break-all; }
.result-box.good { background: rgba(34,197,94,.1); color: #4ade80; }
.result-box.bad { background: rgba(239,68,68,.1); color: #f87171; }

/* ── 应用/公告/黑名单卡片列表 ── */
.list-item { display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 10px; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; margin-bottom: 3px; }
.list-item .li-sub { font-size: 12px; color: var(--text-3); }

/* ── 弹窗 ── */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.modal-box { position: relative; width: 460px; max-width: 92vw; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal-body { padding: 18px; max-height: 60vh; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Toast ── */
.toast-wrap { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 11px 16px; border-radius: var(--radius-sm); background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 13px; min-width: 220px; animation: slideIn .2s ease; }
.toast.ok { border-left: 3px solid var(--success); }
.toast.err { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--primary); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
::-webkit-scrollbar-track { background: transparent; }

/* ════════════ 手机 / 窄屏适配 ════════════ */
.menu-btn { display: none; }
.sidebar-mask { display: none; }
@media (max-width: 860px) {
  #mainView { position: relative; }
  .menu-btn { display: inline-block; }
  .brand-text { display: none; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 232px; z-index: 70;
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mask { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 65; }
  .sidebar-mask.show { display: block; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-title { font-size: 15px; flex: 1; }
  .app-switcher { max-width: 110px; font-size: 12px; padding: 6px 8px; }
  .user-menu span:first-child { display: none; }
  .main-scroll { padding: 12px; }
  .panel { padding: 14px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 13px 14px; }
  .stat-card .num { font-size: 22px; }
  .chart-row { grid-template-columns: 1fr; }
  .chart-box { height: 220px; }
  .form-grid, .row-inline { flex-direction: column; align-items: stretch; }
  .field input, .field select { min-width: 0; width: 100%; }
  .btn { width: 100%; }
  .toolbar .btn, .pager .btn { width: auto; }
  .modal-box { width: 94vw; }
  table { font-size: 12px; }
  th, td { padding: 8px 8px; }
}
@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
