:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --border: #e5e7eb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.55;
}
.topbar {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 14px 24px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 20; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 30px; }
.brand h1 { font-size: 20px; }
.sub { color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 6px; }
.tab {
  border: 1px solid var(--border); background: var(--card); color: var(--ink);
  padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.view { display: none; padding: 20px 24px; max-width: 1400px; margin: 0 auto; }
.view.active { display: block; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.toolbar input, .toolbar select {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: var(--card);
  min-width: 0; max-width: 100%;
}
#searchInput { flex: 1; min-width: 220px; }
.result-count { color: var(--muted); font-size: 13px; margin-left: auto; }
.table-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: fixed; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; word-wrap: break-word; }
th { background: #fafbfc; font-weight: 600; color: #374151; position: sticky; top: 0; cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { background: var(--accent-soft); color: var(--accent); }
th.sorted-asc::after { content: " ▲"; color: var(--accent); }
th.sorted-desc::after { content: " ▼"; color: var(--accent); }
tbody tr:hover { background: var(--accent-soft); cursor: pointer; }
td .pn { font-family: Consolas, monospace; font-weight: 600; color: var(--accent); white-space: nowrap; }
td .dir-badge { display: inline-block; background: var(--accent-soft); color: var(--accent); border-radius: 20px; padding: 2px 10px; font-size: 12px; white-space: nowrap; }
td .pdf-link { color: var(--accent); text-decoration: none; font-size: 13px; white-space: nowrap; }
td .pdf-link:hover { text-decoration: underline; }
/* 列宽：窄列固定不折行，宽列自适应 */
.col-pn { width: 108px; }
.col-title { width: auto; }
.col-ancs { width: 22%; }
.col-pbd { width: 96px; white-space: nowrap; }
.col-dir { width: 120px; }
.col-pdf { width: 88px; white-space: nowrap; }
.pager { display: flex; align-items: center; gap: 14px; padding: 12px 14px; justify-content: flex-end; font-size: 13px; color: var(--muted); }
.pager button { padding: 6px 14px; border: 1px solid var(--border); background: var(--card); border-radius: 6px; cursor: pointer; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* 视图切换 */
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.view-toggle button {
  border: none; background: var(--card); color: var(--ink);
  padding: 8px 12px; font-size: 14px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
}
.view-toggle button.active { background: var(--accent); color: #fff; }
.view-toggle button:hover:not(.active) { background: var(--accent-soft); }

/* 卡片列表布局 */
.hidden { display: none !important; }
.list-area { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
.card-wrap {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px; padding: 14px;
}
.card-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 40px 20px; }
.patent-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 8px;
  min-width: 0; cursor: pointer; transition: box-shadow .15s, border-color .15s;
}
.patent-card:hover, .patent-card:focus-visible { box-shadow: var(--shadow); border-color: var(--accent); outline: none; }
.card-top { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.card-top .pn { font-family: Consolas, monospace; font-weight: 700; color: var(--accent); font-size: 13px; }
.card-top .dir-badge { background: var(--accent-soft); color: var(--accent); border-radius: 20px; padding: 2px 10px; font-size: 12px; }
.card-top .pbd { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.card-title {
  font-weight: 700; font-size: 15px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-ancs { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-abs { font-size: 12.5px; color: #4b5563; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 6px; border-top: 1px dashed var(--border); }
.card-foot .pdf-link { color: var(--accent); text-decoration: none; font-size: 13px; font-weight: 600; }
.card-foot .pdf-link:hover { text-decoration: underline; }
.card-hint { color: var(--muted); font-size: 12px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 24px; }
.modal.hidden { display: none; }
.modal-content { background: var(--card); border-radius: var(--radius); max-width: 860px; width: 100%; max-height: 88vh; overflow-y: auto; padding: 28px; position: relative; }
.modal-close { position: absolute; top: 14px; right: 14px; border: none; background: var(--accent-soft); color: var(--accent); width: 32px; height: 32px; border-radius: 50%; font-size: 16px; cursor: pointer; }
.detail h2 { font-size: 19px; margin-bottom: 6px; padding-right: 40px; }
.detail .meta { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.detail .field { margin-bottom: 14px; }
.detail .field .label { font-weight: 600; color: #374151; font-size: 13px; margin-bottom: 4px; }
.detail .field .value { font-size: 14px; }
.detail .tag { display: inline-block; background: #f3f4f6; border-radius: 6px; padding: 2px 8px; font-size: 12px; margin: 2px 3px 2px 0; color: #374151; }
.detail .pdf-open { display: inline-block; margin-top: 8px; background: var(--accent); color: #fff; padding: 8px 18px; border-radius: 8px; text-decoration: none; }
.detail-hr { border: none; border-top: 1px solid var(--border); margin: 18px 0 12px; }
.detail-section { font-size: 15px; color: var(--accent); margin-bottom: 12px; }
.detail .claims-text {
  background: #fafbfc; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; max-height: 220px; overflow-y: auto; font-size: 13px; line-height: 1.7;
}
@media (max-width: 720px) { .col-ancs { width: 30%; } .col-dir { width: 96px; } }

/* stats */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; text-align: center; }
.stat-card .num { font-size: 30px; font-weight: 700; color: var(--accent); }
.stat-card .lbl { color: var(--muted); font-size: 13px; }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-box { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.chart-box.full { grid-column: 1 / -1; }
.chart-box h3 { font-size: 15px; margin-bottom: 12px; }
.chart { position: relative; }
.chart .bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; font-size: 13px; }
.chart .bar-label { width: 150px; text-align: right; color: #374151; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart .bar-track { flex: 1; background: #f3f4f6; border-radius: 4px; height: 18px; overflow: hidden; }
.chart .bar { height: 100%; background: linear-gradient(90deg, var(--accent), #60a5fa); border-radius: 4px; }
.chart .bar-val { width: 60px; font-size: 12px; color: var(--muted); }

.about { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; max-width: 900px; }
.about h2 { margin-bottom: 12px; }
.about p { margin-bottom: 10px; color: #374151; }
.about code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; font-size: 13px; }

@media (max-width: 720px) {
  .topbar { flex-direction: column; gap: 10px; align-items: flex-start; }
  .charts { grid-template-columns: 1fr; }
  .chart .bar-label { width: 90px; }
  .card-wrap { grid-template-columns: 1fr; padding: 10px; }
  .view-toggle .vt-label { display: none; }
  .view-toggle button { padding: 8px 11px; }
  .card-hint { display: none; }
}
