/* ==========================================================================
   tklike 后台 —— 浅色主题
   不引任何 CDN，字体走系统栈，保证任何网络环境下都能正常显示
   ========================================================================== */

:root {
  --bg:        #f4f6f9;
  --card:      #ffffff;
  --border:    #e3e7ee;
  --border-2:  #eef1f6;
  --text:      #1f2430;
  --muted:     #6b7280;
  --muted-2:   #9aa3af;
  --primary:   #2f6fed;
  --primary-d: #2559c7;
  --success:   #0f9d58;
  --warn:      #d98800;
  --danger:    #e5484d;
  --pending:   #7c5cff;
  --radius:    8px;
  --shadow:    0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------------- 登录页 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eef3fb 0%, #f7f9fc 55%, #eef6f1 100%);
}
.login-box {
  width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 28px;
  box-shadow: 0 8px 30px rgba(16, 24, 40, .08);
}
.login-box h1 { margin: 0 0 4px; font-size: 20px; }
.login-box p.sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }

/* ---------------- 通用控件 ---------------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, .12);
}
textarea { resize: vertical; min-height: 60px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #f7f9fc; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn-danger { color: var(--danger); border-color: #f4c7c9; }
.btn-danger:hover { background: #fdf2f2; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- 顶部导航 ---------------- */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 22px;
  height: 56px;
}
.brand { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav button {
  border: 0;
  background: transparent;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}
.nav button:hover { background: #f2f5fa; color: var(--text); }
.nav button.active { background: #eaf1fe; color: var(--primary); font-weight: 600; }
/* 导航里的链接（如 API 文档）—— 外观与按钮一致，但点开是新窗口 */
.nav a.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.nav a.nav-link:hover { background: #f2f5fa; color: var(--text); text-decoration: none; }
.nav a.nav-link::after { content: "↗"; font-size: 11px; margin-left: 4px; opacity: .6; }
.topbar .user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }

/* ---------------- 布局 ---------------- */
.page { padding: 20px 22px 60px; max-width: 100%; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }
.card h2 .sub { font-weight: 400; color: var(--muted-2); font-size: 12px; margin-left: 8px; }

.grid { display: grid; gap: 14px; }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-5, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px)  { .grid-5, .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* KPI 卡片 */
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kpi .value { font-size: 24px; font-weight: 600; letter-spacing: -.5px; }
.kpi .value small { font-size: 12px; font-weight: 400; color: var(--muted-2); margin-left: 4px; }
.kpi .foot { font-size: 12px; color: var(--muted-2); margin-top: 6px; }
.kpi.accent .value { color: var(--primary); }
.kpi.good .value { color: var(--success); }
.kpi.bad .value { color: var(--danger); }
.kpi.warn .value { color: var(--warn); }

/* ---------------- 提示条 ---------------- */
.alerts { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px; border-radius: 6px; font-size: 13px;
  border: 1px solid;
}
.alert-warn  { background: #fff8e8; border-color: #f3e0b5; color: #7a5500; }
.alert-error { background: #fdf2f2; border-color: #f5c9cb; color: #a3161a; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-2); border-radius: 6px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; font-weight: 600; color: var(--muted);
  background: #fafbfd; padding: 9px 10px;
  border-bottom: 1px solid var(--border-2);
  position: sticky; top: 0; z-index: 2; white-space: nowrap;
}
table.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--border-2); vertical-align: top; }
/* 居中列：表头和数据一起居中。
   必须写成 table.tbl th.ctr 这种完整选择器 —— 只写 .ctr 的话权重低于
   上面的 table.tbl th{text-align:left}，根本不生效。 */
table.tbl th.ctr, table.tbl td.ctr { text-align: center; }
table.tbl th.right, table.tbl td.right { text-align: right; }
table.tbl tbody tr:hover { background: #fafbfe; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
.link-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.log-msg { max-width: 720px; word-break: break-word; }
.row-error { background: #fffafa; }
.row-warn  { background: #fffdf6; }

/* 领取人：名字长的时候用省略号收窄，鼠标悬停看完整信息 */
.claim-pill {
  display: inline-block;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* ---------------- 状态标签 ---------------- */
.pill {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 12px; line-height: 18px; white-space: nowrap;
}
.pill-0 { background: #f0edff; color: var(--pending); }
.pill-1 { background: #e8f1fe; color: var(--primary); }
.pill-2 { background: #e7f6ee; color: var(--success); }
.pill-3 { background: #f2f3f5; color: var(--muted); }
.pill-gray { background: #f2f3f5; color: var(--muted); }
.pill-warn { background: #fff4e0; color: var(--warn); }
.pill-error { background: #fdeaea; color: var(--danger); }
.pill-info { background: #e8f1fe; color: var(--primary); }

/* ---------------- 标签页 / 过滤条 ---------------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: flex; gap: 4px; background: #eef1f6; padding: 3px; border-radius: 7px; }
.tabs button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 5px;
  font-size: 13px; color: var(--muted); cursor: pointer; font-family: inherit;
}
.tabs button.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(16,24,40,.06); }
.tabs button .n { color: var(--muted-2); font-size: 12px; margin-left: 4px; }

/* ---------------- 分页 ---------------- */
.pager { display: flex; align-items: center; gap: 12px; margin-top: 12px; font-size: 13px; color: var(--muted); }

/* ---------------- 模块状态 ---------------- */
.mod-list { display: flex; flex-direction: column; gap: 1px; }
.mod-row {
  display: grid; grid-template-columns: 100px 1fr 90px 90px 1fr; gap: 10px;
  align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--border-2); font-size: 13px;
}
.mod-row:last-child { border-bottom: 0; }
.mod-row .name { font-weight: 500; }
.mod-row .note { color: var(--muted-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- 趋势图 ---------------- */
.trend { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 10px; }
.trend .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.trend .bar { width: 100%; max-width: 46px; background: linear-gradient(180deg, #6d9bf5, #2f6fed); border-radius: 4px 4px 0 0; min-height: 2px; transition: height .3s; }
.trend .bar-lbl { font-size: 11px; color: var(--muted-2); }
.trend .bar-val { font-size: 11px; color: var(--muted); }

/* ---------------- 设置页 ---------------- */
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 22px; }
@media (max-width: 900px) { .set-grid { grid-template-columns: 1fr; } }
.set-grid .full { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--muted-2); margin-top: 4px; line-height: 1.5; }
.key-box {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: #f7f9fc; border: 1px dashed var(--border);
  border-radius: 6px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px;
}
.section-title {
  font-size: 13px; font-weight: 600; color: var(--muted);
  margin: 22px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-2);
}
.section-title:first-child { margin-top: 0; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .35);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
  background: #fff; border-radius: 10px; max-width: 860px; width: 100%;
  max-height: 86vh; overflow: auto; padding: 20px 22px;
  box-shadow: 0 20px 50px rgba(16,24,40,.2);
}
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal .close { float: right; cursor: pointer; color: var(--muted-2); font-size: 20px; line-height: 1; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 14px; font-size: 13px; margin-bottom: 16px; }
.kv .k { color: var(--muted); }

/* ---------------- 提示 ---------------- */
#toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1f2430; color: #fff; padding: 10px 18px; border-radius: 6px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .22s; z-index: 200;
  max-width: 80vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: #b3261e; }

.loading { padding: 40px; text-align: center; color: var(--muted-2); }
.empty { padding: 40px; text-align: center; color: var(--muted-2); font-size: 13px; }
