:root {
  --bg: #f4f7f9;
  --panel: #ffffff;
  --panel-soft: #f8fafb;
  --text: #1c2b33;
  --muted: #627985;
  --line: #dce6eb;
  --accent: #0f766e;
  --accent-soft: #e2f3f0;
  --accent-2: #2563a8;
  --warn: #b45309;
  --shadow: 0 1px 2px rgba(20, 50, 60, .05), 0 8px 24px rgba(20, 50, 60, .05);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }

.topbar > * { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  padding: 14px 22px;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 10px; font-size: 20px; font-weight: 700; letter-spacing: .5px; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); display: inline-block; }
.brand small { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.stat { background: var(--panel-soft); border: 1px solid var(--line); border-radius: 10px; padding: 5px 12px; font-size: 12px; color: var(--muted); }
.stat b { color: var(--text); font-size: 15px; margin-left: 4px; }
.search { position: relative; width: min(320px, 100%); }
.search input { width: 100%; padding: 9px 12px 9px 34px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); outline: none; }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search::before { content: "⌕"; position: absolute; left: 12px; top: 5px; font-size: 18px; color: var(--muted); }
.header-tools { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.tool-btn { padding: 7px 11px; border: 1px solid var(--line); background: var(--panel); border-radius: 9px; cursor: pointer; font-size: 12px; white-space: nowrap; }
.tool-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.build-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; padding: 10px 16px; background: #1c2b33; color: #fff; border-radius: 9px; box-shadow: var(--shadow); font-size: 13px; opacity: .95; transition: opacity .3s; }
.tabs { display: flex; gap: 6px; padding: 12px 22px 0; flex-wrap: wrap; }
.tab { border: 1px solid transparent; background: transparent; padding: 8px 16px; border-radius: 9px 9px 0 0; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab:hover { color: var(--text); background: var(--panel-soft); }
.tab.active { color: var(--accent); background: var(--panel); border-color: var(--line); border-bottom-color: var(--panel); }
.view { display: none; padding: 18px 22px 40px; }
.view.active { display: block; }

.case-layout > * { min-width: 0; }
.case-layout { display: grid; grid-template-columns: minmax(260px, 360px) minmax(0, 1fr); gap: 18px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.filters { padding: 14px; position: sticky; top: 74px; }
.filters .row { display: flex; gap: 8px; margin-bottom: 10px; }
.filters select, .filters input[type=text] { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.count { font-size: 12px; color: var(--muted); margin: 4px 2px 10px; }
.case-list { max-height: calc(100vh - 230px); overflow: auto; margin: 0 -6px; padding: 0 6px; }
.case-card { display: block; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; border-radius: 10px; padding: 10px 11px; margin-bottom: 6px; cursor: pointer; }
.case-card:hover { background: var(--panel-soft); }
.case-card.active { background: var(--accent-soft); border-color: #bfded8; }
.cc-top { display: flex; align-items: center; gap: 8px; }
.cc-name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-time { margin-left: auto; font-size: 11px; color: var(--accent); background: #fff; border: 1px solid #cfe3df; padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
.cc-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.cc-snippet { font-size: 12px; color: var(--muted); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.detail { padding: 22px 26px; min-height: 400px; }
.detail-head { border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 16px; }
.detail-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; }
.detail-title h2 { margin: 0; font-size: 24px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--panel-soft); border: 1px solid var(--line); color: var(--muted); }
.chip.accent { background: var(--accent-soft); border-color: #bfded8; color: var(--accent); }
.oneline { margin-top: 12px; padding: 12px 14px; background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; color: #244943; }
.visits { margin: 22px 0; }
.visits h3, .summary h3 { font-size: 16px; margin: 22px 0 10px; }
.visit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.visit { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-soft); font-size: 12px; }
.visit .vdate { font-weight: 700; white-space: nowrap; }
.visit .vrec { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visit a { margin-left: auto; white-space: nowrap; font-weight: 600; }
.pdf-icon { display: inline-block; min-width: 18px; }
.summary { border-top: 1px dashed var(--line); padding-top: 6px; }
.summary h1 { font-size: 22px; margin: 18px 0 10px; }
.summary h2 { font-size: 17px; margin: 22px 0 8px; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.summary h3 { font-size: 15px; }
.summary p { margin: 8px 0; }
.summary blockquote { margin: 12px 0; padding: 10px 14px; background: var(--panel-soft); border-left: 3px solid var(--accent-2); border-radius: 0 8px 8px 0; color: #334e5d; }
.summary ul, .summary ol { padding-left: 22px; }
.summary li { margin: 3px 0; }
.summary code { background: var(--panel-soft); padding: 1px 4px; border-radius: 4px; }
.summary .table-wrap { overflow-x: auto; margin: 10px 0; border: 1px solid var(--line); border-radius: 8px; }
.summary table { border-collapse: collapse; width: 100%; font-size: 12.5px; min-width: 480px; }
.summary th, .summary td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 7px 9px; text-align: left; vertical-align: top; }
.summary th:last-child, .summary td:last-child { border-right: 0; }
.summary th { background: var(--panel-soft); font-weight: 700; white-space: nowrap; }
.summary tr:last-child td { border-bottom: 0; }
.md-local-link { color: var(--muted); border-bottom: 1px dotted var(--muted); }
.no-summary { padding: 30px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.timeline-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; background: var(--panel); font-size: 13px; }
table.data th, table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; }
table.data th { position: sticky; top: 0; background: var(--panel-soft); font-weight: 700; z-index: 1; }
table.data tr:hover td { background: #f9fcfc; }
table.data td.date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.more { display: block; margin: 16px auto; padding: 9px 20px; border: 1px solid var(--line); background: var(--panel); border-radius: 9px; cursor: pointer; }
.report-body { padding: 24px 28px; }
.report-body h1 { font-size: 22px; }
.report-body h2 { font-size: 17px; margin-top: 24px; border-bottom: 1px solid var(--line); padding-bottom: 5px; }
.report-body .table-wrap { overflow-x: auto; }
.report-body table { border-collapse: collapse; width: 100%; min-width: 620px; font-size: 12.5px; }
.report-body th, .report-body td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; }
.report-body th { background: var(--panel-soft); }
.report-body blockquote { background: var(--panel-soft); border-left: 3px solid var(--accent); margin: 10px 0; padding: 10px 14px; }
.report-body .md-local-link { color: var(--muted); }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.footer { padding: 0 22px 26px; color: var(--muted); font-size: 12px; }

@media (max-width: 1024px) {
  .case-layout { grid-template-columns: minmax(0, 1fr); }
  .filters { position: static; }
  .case-list { max-height: 320px; }
  .stats { margin-left: 0; }
}
@media (max-width: 640px) {
  .topbar { padding: 12px 14px; gap: 10px; }
  .brand { font-size: 18px; flex: 1 1 100%; }
  .stats { flex: 1 1 100%; width: 100%; }
  .search { flex: 1 1 100%; width: 100%; }
  .header-tools { flex: 1 1 100%; flex-direction: row; align-items: center; justify-content: space-between; }
  .tabs { padding: 10px 14px 0; }
  .tab { padding: 8px 11px; font-size: 13px; }
  .view { padding: 14px; }
  .filters .row { flex-wrap: wrap; }
  .filters select { flex: 1 1 130px; }
  .detail { padding: 16px; }
  .detail-title h2 { font-size: 20px; }
  .summary table { min-width: 420px; }
}
