:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-ink: #1e3a8a;
  --blue-soft: #eff4ff;
  --blue-line: #dbe7ff;
  --ink: #1f2937;
  --ink-2: #4b5563;
  --muted: #6b7280;
  --bg: #f5f7fb;
  --white: #ffffff;
  --line: #e5e7eb;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --green: #047857;
  --green-soft: #ecfdf5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 212px;
  flex: 0 0 212px;
  background: #0f1e3d;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(145deg, #3b82f6, #1d4ed8);
  color: #fff; font-weight: 700; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
}
.brand strong { color: #fff; font-size: 15px; display: block; letter-spacing: .5px; }
.brand small { color: #94a3b8; font-size: 11px; }

.sidebar nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  color: #cbd5e1;
  padding: 10px 12px;
  border-radius: 7px;
  font-size: 13.5px;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--blue); color: #fff; font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 16px 18px; font-size: 11px; color: #64748b; }

main { flex: 1; min-width: 0; padding: 0 28px 40px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 14px;
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 600; }
.topbar .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.userbox { display: flex; align-items: center; gap: 12px; color: var(--ink-2); font-size: 13px; }
.userbox form { margin: 0; }
button.link {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font: inherit; padding: 0;
}
button.link:hover { color: var(--red); text-decoration: underline; }

.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.flash {
  padding: 10px 14px; border-radius: 8px; font-size: 13px;
  border: 1px solid var(--blue-line); background: var(--blue-soft); color: var(--blue-ink);
}
.flash-error { border-color: #fecaca; background: var(--red-soft); color: #991b1b; }
.flash-success { border-color: #bbf7d0; background: var(--green-soft); color: var(--green); }
.flash-info { border-color: var(--blue-line); background: var(--blue-soft); color: var(--blue-ink); }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.card .label { font-size: 12px; color: var(--muted); }
.card .value { font-size: 26px; font-weight: 700; margin-top: 6px; color: var(--ink); }
.card .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.card.accent { background: linear-gradient(150deg, #2563eb, #1e40af); border: none; }
.card.accent .label, .card.accent .hint { color: #dbeafe; }
.card.accent .value { color: #fff; }

.panel {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 14.5px; font-weight: 600; }
.panel-body { padding: 16px 18px; }
.panel-body.flush { padding: 0; }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }
.grid-even { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfd; }
tbody tr:hover { background: #fafcff; }
td.nowrap, th.nowrap { white-space: nowrap; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; line-height: 18px; border: 1px solid transparent; white-space: nowrap;
}
.badge-critical { background: #fee2e2; color: #991b1b; }
.badge-high { background: #ffedd5; color: #9a3412; }
.badge-medium { background: #fef9c3; color: #854d0e; }
.badge-low { background: #e0f2fe; color: #075985; }
.badge-blue { background: var(--blue-soft); color: var(--blue-ink); }
.badge-gray { background: #f3f4f6; color: var(--ink-2); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: #991b1b; }

.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 9px; }
.bar-row .day { width: 44px; color: var(--muted); font-size: 12px; }
.bar-track { flex: 1; height: 18px; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #60a5fa, #2563eb); border-radius: 4px; }
.bar-row .num { width: 48px; text-align: right; font-size: 12.5px; color: var(--ink-2); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
input[type="text"], input[type="date"], input[type="password"], input[type="search"], select, textarea {
  border: 1px solid #d1d5db; border-radius: 7px; padding: 7px 10px; font: inherit;
  background: #fff; color: var(--ink); min-width: 0;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.btn {
  display: inline-block; border: 1px solid transparent; border-radius: 7px;
  padding: 8px 14px; font: inherit; font-size: 13px; cursor: pointer;
  background: var(--blue); color: #fff; white-space: nowrap;
}
.btn:hover { background: var(--blue-dark); text-decoration: none; }
.btn-ghost { background: #fff; color: var(--ink-2); border-color: #d1d5db; }
.btn-ghost:hover { background: #f9fafb; color: var(--ink); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-danger { background: #fff; color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: var(--red-soft); }

.pagination { display: flex; gap: 8px; align-items: center; padding: 12px 18px; color: var(--muted); font-size: 12.5px; }
.pagination a { padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 12px; }
pre.code {
  background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 14px 16px;
  overflow: auto; font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

.report-item { border: 1px solid var(--line); border-radius: 9px; padding: 14px 16px; margin-bottom: 12px; background: #fff; }
.report-item.pri-高 { border-left: 4px solid #dc2626; }
.report-item.pri-中 { border-left: 4px solid #f59e0b; }
.report-item.pri-低 { border-left: 4px solid #38bdf8; }
.report-item h3 { margin: 0 0 8px; font-size: 15px; }
.report-item h3 .badge { margin-right: 8px; vertical-align: 2px; }
.report-item .section { margin-top: 8px; font-size: 13px; line-height: 1.65; }
.report-item .section b { color: var(--ink-2); font-weight: 600; }
.report-item .meta { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); }

.token-box {
  background: #0f172a; color: #93c5fd; border-radius: 8px; padding: 12px 14px;
  font-family: Consolas, monospace; font-size: 13px; word-break: break-all; margin: 8px 0;
}

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 20% 20%, #e8efff, #f5f7fb 55%); }
.login-card { width: 360px; background: #fff; border-radius: 14px; box-shadow: 0 24px 60px rgba(30, 58, 138, .16); padding: 30px 30px 26px; }
.login-card .brand { border: none; padding: 0 0 18px; }
.login-card .brand strong { color: var(--ink); }
.login-card .brand small { color: var(--muted); }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input { width: 100%; padding: 10px 12px; }
.login-card .btn { width: 100%; padding: 10px; font-size: 14px; }

.stats-line { display: flex; flex-wrap: wrap; gap: 18px; color: var(--ink-2); font-size: 13px; }
.stats-line b { color: var(--ink); }

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

/* 经验库 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.form-grid input[type="text"], .form-grid select, .form-grid textarea { width: 100%; }
.form-grid textarea { min-height: 82px; resize: vertical; line-height: 1.6; }

.kb-section-title { font-size: 12px; color: var(--muted); font-weight: 600; margin: 14px 0 6px; }
.kb-section-title:first-child { margin-top: 0; }
.kb-text { white-space: pre-wrap; line-height: 1.75; font-size: 13.5px; color: var(--ink); }

.check-item { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.check-item:last-child { border-bottom: none; }
.check-item input[type="checkbox"] { margin-top: 3px; width: 15px; height: 15px; }
.check-item .body { flex: 1; min-width: 0; }
.check-item .title { font-size: 13.5px; font-weight: 600; }
.check-item .hint { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; white-space: pre-wrap; line-height: 1.6; }

@media (max-width: 1080px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-even { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sidebar { display: none; }
  main { padding: 0 14px 30px; }
  .cards { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

@media print {
  .sidebar, .topbar, .no-print, .flashes, .pagination { display: none !important; }
  .layout { display: block; }
  main { padding: 0; }
  body { background: #fff; }
  .panel { border: none; box-shadow: none; margin-bottom: 10px; }
  .panel-head { padding: 8px 0; }
  .panel-body { padding: 6px 0; }
}
