/* ==========================================================================
   YTFK 后台样式
   深色侧边栏 + 浅色内容区，主色 #2f6bff，正文 13-14px，表格紧凑。
   无框架、无 CDN、无图标字体，图标是 _layout.php 里内联的 SVG。
   ========================================================================== */

:root {
  --primary: #2f6bff;
  --primary-dark: #2457d6;
  --primary-soft: #eaf0ff;
  --sidebar-bg: #151b2b;
  --sidebar-bg-2: #1c2437;
  --sidebar-text: #a8b3c7;
  --sidebar-active: #ffffff;
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e5e9f2;
  --line-soft: #eef1f7;
  --text: #1f2937;
  --muted: #6b7280;
  --ok: #16803c;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fdf3e2;
  --danger: #d92d20;
  --danger-soft: #fdeceb;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
code, .mono { font-family: Consolas, "Courier New", monospace; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }

/* ---------- 布局 ---------- */

body.admin { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 208px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--sidebar-bg-2), var(--sidebar-bg));
  z-index: 30;
}

.main {
  margin-left: 208px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-text {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  display: flex;
  flex-direction: column;
}

.brand-text small {
  color: var(--sidebar-text);
  font-size: 11px;
  font-weight: 400;
  margin-top: 2px;
}

.nav { padding: 10px 9px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  margin-bottom: 2px;
  border-radius: 7px;
  color: var(--sidebar-text);
  font-size: 13px;
  text-decoration: none;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; text-decoration: none; }
.nav-item.is-active { background: var(--primary); color: #fff; }
.nav-item.is-active:hover { background: var(--primary); }
.nav-item .ico { width: 16px; height: 16px; flex: 0 0 16px; }

.sidebar-foot {
  padding: 10px 18px 14px;
  color: #5b6780;
  font-size: 11px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.whoami { color: var(--muted); font-size: 12px; }
.whoami em {
  font-style: normal;
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 20px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
}

.content { flex: 1; padding: 16px 20px 40px; }

/* ---------- 卡片 ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad { padding: 16px 18px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.card-head h2 { font-size: 13.5px; }
.card-head .head-actions { display: flex; align-items: center; gap: 8px; }

.card-body { padding: 14px 16px; }
.card-body.p0 { padding: 0; }

.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }

/* ---------- 指标卡 ---------- */

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: var(--shadow);
}

.stat .stat-label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.stat .stat-value { font-size: 26px; font-weight: 600; line-height: 1.25; margin-top: 4px; letter-spacing: -0.5px; }
.stat .stat-hint { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.stat.is-primary .stat-value { color: var(--primary); }
.stat .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  vertical-align: middle;
}

.btn:hover { border-color: #c9d2e3; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn .ico { width: 14px; height: 14px; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f1f4fa; color: var(--text); }

.btn-danger { color: var(--danger); border-color: #f2c3bf; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-xs { height: 24px; padding: 0 8px; font-size: 12px; border-radius: 5px; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }

.btn-link {
  border: 0;
  background: none;
  color: var(--primary);
  padding: 0;
  height: auto;
  font-size: 12px;
  cursor: pointer;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--danger); }

.btn-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- 表单 ---------- */

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label { font-size: 12px; color: var(--muted); }
.field .hint { font-size: 11.5px; color: var(--muted); }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="email"],
select,
textarea {
  height: 30px;
  padding: 0 9px;
  border: 1px solid #d8dfeb;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  outline: none;
}

textarea { height: auto; padding: 7px 9px; resize: vertical; line-height: 1.5; }

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.12);
}

select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #8b95a7 50%), linear-gradient(135deg, #8b95a7 50%, transparent 50%); background-position: calc(100% - 14px) 13px, calc(100% - 9px) 13px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 26px; }

.form-grid { display: grid; gap: 12px; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* hidden 属性要被作者样式压住：.field 是 flex，否则藏不住 */
[hidden] { display: none !important; }

/* 测试卡自定义时长区 */
.trial-box {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px dashed #d3ddf3;
  border-radius: 7px;
  background: #f8faff;
}

.trial-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.trial-inline input[type="number"] { width: 130px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.toolbar .field { min-width: 130px; }
.toolbar .field.grow { flex: 1 1 220px; }
.toolbar .field.w-md { width: 280px; flex: 0 0 280px; }
.toolbar .spacer { flex: 1; }

.seg { display: inline-flex; border: 1px solid #d8dfeb; border-radius: 6px; overflow: hidden; }
.seg label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  height: 30px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  background: #fff;
}
.seg label + label { border-left: 1px solid #d8dfeb; }
.seg input { margin: 0; accent-color: var(--primary); }
.seg label:has(input:checked) { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

/* ---------- 表格 ---------- */

.table-wrap { overflow-x: auto; }

table.table { width: 100%; border-collapse: collapse; font-size: 13px; }

table.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: #fafbfe;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

table.table tbody tr:hover { background: #fafcff; }
table.table tbody tr:last-child td { border-bottom: 0; }
table.table .empty td { text-align: center; color: var(--muted); padding: 28px 12px; }
table.table .cell-code { font-family: Consolas, "Courier New", monospace; font-size: 12px; letter-spacing: 0.2px; }
table.table .col-id { width: 62px; color: var(--muted); }
table.table .actions { white-space: nowrap; }
table.table .actions .btn + .btn { margin-left: 4px; }
table.table .ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

/* ---------- 徽章 ---------- */

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 11.5px;
  line-height: 18px;
  white-space: nowrap;
  background: #f1f3f7;
  color: var(--muted);
}

.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-muted { background: #f1f3f7; color: #6b7280; }

/* ---------- 分页 ---------- */

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-top: 1px solid var(--line-soft);
}

.pager .pager-info { color: var(--muted); font-size: 12px; }
.pager .pager-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.pager .pager-btns button {
  min-width: 28px;
  height: 26px;
  padding: 0 7px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 5px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.pager .pager-btns button:hover { border-color: var(--primary); color: var(--primary); }
.pager .pager-btns button.is-current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager .pager-btns button:disabled { opacity: 0.45; cursor: not-allowed; }
.pager .pager-btns button:disabled:hover { border-color: var(--line); color: var(--text); }
.pager .pager-gap { padding: 0 2px; color: var(--muted); }

/* ---------- 图表（纯 CSS，无第三方库） ---------- */

.chart { padding: 6px 4px 0; }

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 188px;
  background-image: repeating-linear-gradient(to top, var(--line-soft) 0 1px, transparent 1px 47px);
}

.bar-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.bar-pair { display: flex; align-items: flex-end; justify-content: center; gap: 4px; height: calc(100% - 22px); }
.bar { width: 11px; border-radius: 3px 3px 0 0; }
.bar-a { background: var(--primary); }
.bar-b { background: #9db7ff; }
.bar-x { height: 22px; line-height: 22px; text-align: center; font-size: 11px; color: var(--muted); white-space: nowrap; }

.legend { display: flex; gap: 16px; align-items: center; font-size: 12px; color: var(--muted); padding: 10px 4px 0; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 5px; }
.legend .l-a { background: var(--primary); }
.legend .l-b { background: #9db7ff; }

.type-list { display: flex; flex-direction: column; gap: 12px; padding: 4px 0; }
.type-row { display: grid; grid-template-columns: 48px 1fr 58px; align-items: center; gap: 10px; font-size: 12.5px; }
.type-row .type-name { color: var(--muted); }
.type-row .track { height: 9px; border-radius: 20px; background: #eef2f9; overflow: hidden; }
.type-row .track i { display: block; height: 100%; border-radius: 20px; background: var(--primary); }
.type-row .type-val { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- 提示 / 空状态 ---------- */

.notice-card { max-width: 620px; margin: 40px auto; text-align: center; padding: 30px 26px; }
.notice-icon {
  width: 42px; height: 42px; margin: 0 auto 12px; border-radius: 50%;
  background: var(--warn-soft); color: var(--warn);
  font-size: 22px; font-weight: 700; line-height: 42px;
}
.notice-card h2 { font-size: 15px; margin-bottom: 8px; }
.notice-card p { margin: 6px 0; }

.result-box { border: 1px dashed #c9d6f5; background: #f7f9ff; border-radius: 7px; padding: 12px; margin-top: 12px; }
.result-box .result-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.result-box textarea { font-family: Consolas, "Courier New", monospace; font-size: 12px; background: #fff; }
.result-box .result-meta { font-size: 12px; color: var(--muted); }

/* ---------- 弹窗 ---------- */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 16px 40px;
  z-index: 100;
  overflow-y: auto;
}

.modal {
  width: 440px;
  max-width: 100%;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}

.modal.modal-wide { width: 560px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h3 { font-size: 14px; }
.modal-head .modal-close {
  border: 0; background: none; font-size: 18px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 2px;
}

.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.modal-body p { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line-soft); background: #fafbfe; }

/* ---------- toast ---------- */

#toast-wrap {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  min-width: 180px;
  max-width: 460px;
  padding: 8px 14px;
  border-radius: 7px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
  font-size: 12.5px;
  color: var(--text);
  pointer-events: auto;
}

.toast.is-ok { border-left-color: var(--ok); }
.toast.is-error { border-left-color: var(--danger); }
.toast.is-warn { border-left-color: var(--warn); }

/* ---------- 登录页 ---------- */

body.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 20% -10%, #24407e 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 110%, #1b3fa0 0%, transparent 55%),
              linear-gradient(160deg, #0f172a 0%, #151b2b 55%, #101827 100%);
}

.login-wrap { width: 372px; max-width: 100%; }

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 28px 26px 24px;
  box-shadow: 0 24px 60px rgba(2, 8, 23, 0.45);
}

.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.login-brand .brand-mark { width: 36px; height: 36px; flex: 0 0 36px; font-size: 13px; border-radius: 9px; }
.login-brand h1 { font-size: 16px; }
.login-brand small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; margin-top: 2px; }

.login-card .field + .field { margin-top: 12px; }
.login-card input { height: 36px; font-size: 13.5px; }
.login-submit { width: 100%; height: 38px; margin-top: 18px; font-size: 14px; }

.login-error {
  display: none;
  margin-top: 14px;
  padding: 8px 11px;
  border-radius: 6px;
  background: var(--danger-soft);
  border: 1px solid #f5c2be;
  color: var(--danger);
  font-size: 12.5px;
}
.login-error.show { display: block; }

.login-foot { text-align: center; color: #7d8798; font-size: 11.5px; margin-top: 16px; }

.login-alert {
  margin-bottom: 14px;
  padding: 8px 11px;
  border-radius: 6px;
  background: var(--warn-soft);
  border: 1px solid #f0d6a8;
  color: var(--warn);
  font-size: 12px;
}

/* ---------- 响应式（窄屏：侧边栏只留图标） ---------- */

@media (max-width: 900px) {
  .sidebar { width: 58px; }
  .brand { padding: 14px 0; justify-content: center; }
  .brand-text, .sidebar-foot { display: none; }
  .nav { padding: 8px 7px; }
  .nav-item { justify-content: center; padding: 9px 0; }
  .nav-item span { display: none; }
  .main { margin-left: 58px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .form-grid.cols-3 { grid-template-columns: 1fr; }
  .content { padding: 14px 12px 32px; }
  .topbar { padding: 0 12px; }
  .whoami { display: none; }
}

/* ===== 卡密批量操作 ===== */
.chk-inline{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:#5b6270;cursor:pointer;user-select:none;margin-right:4px}
.chk-inline input{width:13px;height:13px;margin:0;accent-color:var(--primary,#f4762a);cursor:pointer}

.bulk-bar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:10px 14px;margin:0 0 12px;background:#f8f9fc;border:1px solid #eef0f6;border-radius:10px}
.bulk-count{font-size:12.5px;font-weight:600;color:#2f3542;min-width:78px}
.bulk-hint{font-size:11.5px;color:#9aa1af;margin-left:auto}

.table .col-check{width:34px;text-align:center;padding-left:8px;padding-right:0}
.table .col-check input{width:14px;height:14px;margin:0;accent-color:var(--primary,#f4762a);cursor:pointer}

/* 筛选栏：日期框收窄，保证一行放得下「查询/重置」 */
.toolbar .field.w-date{width:132px;flex:0 0 132px;min-width:0}
.toolbar .field.w-date input{width:100%}
.toolbar .field.w-batch{width:150px;flex:0 0 150px;min-width:0}
.toolbar .field.w-batch input{width:100%}

/* 卡密页筛选栏：紧凑排布，尽量一行放下 */
#rows ~ .toolbar, .toolbar.compact{ gap:8px; }
.toolbar.compact .field{ min-width:0; }
.toolbar.compact .field.grow{ flex:1 1 180px; }
.toolbar.compact .field.w-status, .toolbar.compact .field.w-type{ width:104px; flex:0 0 104px; }
.toolbar.compact .field.w-batch{ width:132px; flex:0 0 132px; }
.toolbar.compact .field.w-date{ width:126px; flex:0 0 126px; }
.toolbar.compact .field input, .toolbar.compact .field select{ width:100%; height:32px; }
.toolbar.compact .btn{ height:32px; }

/* ===== 账号安全页 ===== */
.kv-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); gap:12px; padding:4px 2px; }
.kv{ display:flex; flex-direction:column; gap:4px; padding:10px 12px; background:#fafbfd; border:1px solid #eef0f6; border-radius:10px; }
.kv span{ font-size:11.5px; color:#9aa1af; }
.kv b{ font-size:13px; color:#2f3542; font-weight:600; word-break:break-all; }

.form-narrow{ max-width:420px; display:flex; flex-direction:column; gap:14px; padding:2px; }
.form-actions{ display:flex; align-items:center; gap:12px; flex-wrap:wrap; margin-top:4px; }

.hint{ font-size:11.5px; color:#9aa1af; }
.hint.is-ok{ color:#0f9d58; }
.hint.is-error{ color:#d93025; }
