:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --border: #e6e8ef;
  --text: #1f2430;
  --muted: #8a90a2;
  --accent: #4f5bd5;
  --accent-soft: #eef0ff;
  --ok: #1a9b6c;
  --ok-soft: #e6f7ef;
  --err: #d64550;
  --err-soft: #fdecee;
  --warn: #c98a1b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20, 24, 40, .06), 0 8px 24px rgba(20, 24, 40, .04);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
h1, h2 { margin: 0; font-weight: 650; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.hidden { display: none !important; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 224px; flex: 0 0 224px; background: var(--surface); border-right: 1px solid var(--border); padding: 22px 14px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 24px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px; flex: none; }
.brand-name { font-weight: 650; font-size: 14px; }
.brand-sub { color: var(--muted); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { color: #596074; padding: 10px 12px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: 12px; }
.doc-links { margin-bottom: 8px; padding-left: 12px; font-size: 13px; }

.main { flex: 1; min-width: 0; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 18px 28px; display: flex; align-items: center; justify-content: space-between; }
.topbar p { margin: 4px 0 0; }
.content { padding: 24px 28px 60px; max-width: 1280px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 30px; font-weight: 650; margin-top: 6px; letter-spacing: -.5px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card-narrow { max-width: 620px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid #f0f1f5; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-row { cursor: pointer; }
.log-row:hover { background: #fafbfe; }

.chart { display: flex; align-items: flex-end; gap: 12px; height: 190px; padding: 8px 4px 0; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.chart-bar-wrap { flex: 1; width: 100%; max-width: 60px; display: flex; align-items: flex-end; }
.chart-bar { width: 100%; background: linear-gradient(180deg, #6c76e8, var(--accent)); border-radius: 6px 6px 0 0; min-height: 4px; }
.chart-label { color: var(--muted); font-size: 11px; margin-top: 8px; }
.chart-value { font-size: 12px; font-weight: 600; margin-top: 2px; }

.filter-bar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.filter-bar label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.input { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); font: inherit; font-size: 13px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input { width: auto; min-width: 130px; }
.filter-bar input.input { min-width: 170px; }
.field-label { display: block; margin: 16px 0 6px; font-weight: 500; }
.form-error { color: var(--err); font-size: 13px; margin-top: 8px; min-height: 18px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }

.btn { border: 1px solid transparent; border-radius: 8px; padding: 9px 14px; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #414cc0; }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger-ghost { background: #fff; border-color: var(--border); color: var(--err); }
.btn-danger-ghost:hover { background: var(--err-soft); }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-block { width: 100%; }

.badge { display: inline-block; padding: 3px 8px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-err { background: var(--err-soft); color: var(--err); }
.badge-off { background: #f0f1f5; color: var(--muted); }
.key-cell { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--accent); cursor: pointer; word-break: break-all; }
.key-cell:hover { text-decoration: underline; }

.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 14px; }
.kv { display: flex; justify-content: space-between; gap: 20px; padding: 8px 0; border-bottom: 1px solid #f0f1f5; }
.kv span:first-child { color: var(--muted); flex: none; }
.kv span:last-child { text-align: right; word-break: break-all; }
.code-block { background: #f7f8fc; border: 1px solid var(--border); border-radius: 8px; padding: 14px; overflow-x: auto; font-size: 12px; line-height: 1.7; }

.modal { position: fixed; inset: 0; background: rgba(20, 24, 40, .42); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal-card { background: #fff; border-radius: 14px; padding: 24px; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(20, 24, 40, .2); }
.modal-wide { max-width: 620px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.key-display { margin-top: 14px; padding: 14px; background: #f7f8fc; border: 1px dashed var(--border); border-radius: 8px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; user-select: all; }

.toast { position: fixed; right: 24px; bottom: 24px; background: #263041; color: #fff; padding: 11px 18px; border-radius: 8px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; z-index: 100; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { background: var(--err); }

.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 380px; }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.login-card h2 { font-size: 20px; }
.login-card .muted { margin: 6px 0 4px; font-size: 13px; }

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 180px; flex-basis: 180px; }
}

/* 信息提示条 */
.notice { background: #fffaf0; border: 1px solid #f0dfb8; color: #8a6d1f; border-radius: 8px; padding: 10px 14px; font-size: 12px; line-height: 1.6; margin-bottom: 14px; }

/* 用户缓存页：操作区独占一行，搜索/导出/刷新三控件同排不换行 */
.card-head.toolbar-stacked { flex-direction: column; align-items: stretch; }
.toolbar { display: flex; gap: 8px; flex-wrap: nowrap; align-items: center; }
.toolbar .input { width: 280px; flex: 0 0 280px; }
.dept-path { max-width: 420px; word-break: break-word; line-height: 1.5; }
