:root {
  --ink: #172033;
  --muted: #64748b;
  --line: #e4e9f2;
  --surface: #ffffff;
  --canvas: #f5f7fb;
  --blue: #2563eb;
  --blue-dark: #1e40af;
  --blue-soft: #eef4ff;
  --violet: #7c3aed;
  --green: #0f9f6e;
  --red: #c2414c;
  font-family: Inter, "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.topbar { height: 72px; padding: 0 32px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 24px; position: sticky; top: 0; z-index: 20; }
.brand { color: var(--blue-dark); font-weight: 900; font-size: 20px; letter-spacing: -.04em; white-space: nowrap; }
.topbar-meta { margin-left: auto; display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: 12px; }
.source-pill { background: #ecfdf5; color: var(--green); padding: 7px 11px; border-radius: 999px; font-weight: 800; }
.mobile-nav-button { display: none; border: 0; background: transparent; color: var(--ink); font-size: 23px; padding: 4px; }
.app-shell { min-height: calc(100vh - 72px); display: flex; }
.sidebar { width: 232px; flex: 0 0 232px; padding: 28px 18px; background: #172033; color: #dbe5f4; display: flex; flex-direction: column; }
.sidebar-title { color: #fff; font-size: 13px; font-weight: 800; letter-spacing: .08em; padding: 0 13px 20px; }
.nav-list { display: grid; gap: 5px; }
.nav-link { border-radius: 10px; padding: 12px 13px; font-size: 13px; color: #a9b8cf; transition: .15s; }
.nav-link:hover, .nav-link.active { background: #2b66d9; color: #fff; }
.sidebar-help { margin-top: auto; padding: 16px 13px; border: 1px solid #ffffff1c; border-radius: 13px; color: #b6c4d8; font-size: 12px; line-height: 1.7; }
.sidebar-help strong { color: #fff; }
.sidebar-help p { margin: 7px 0; }
.sidebar-help a { color: #8eb3ff; }
.nav-backdrop { display: none; }
.content { width: min(100%, 1240px); margin: 0 auto; padding: 34px 38px 60px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 26px; }
.page-head h1 { margin: 7px 0 8px; font-size: clamp(25px, 3vw, 36px); letter-spacing: -.045em; }
.page-lead { margin: 0; color: var(--muted); line-height: 1.7; max-width: 720px; }
.page-actions, .inline-actions, .dialog-actions, .filter-actions, .pagination { display: flex; align-items: center; gap: 9px; }
.eyebrow { margin: 0; color: var(--blue); text-transform: uppercase; letter-spacing: .13em; font-size: 11px; font-weight: 900; }
.button { display: inline-flex; justify-content: center; align-items: center; border: 0; border-radius: 9px; padding: 10px 15px; font-weight: 800; font-size: 13px; cursor: pointer; transition: .15s; white-space: nowrap; }
.button:hover { transform: translateY(-1px); box-shadow: 0 6px 16px #1e293b14; }
.button:disabled { cursor: not-allowed; opacity: .45; transform: none; box-shadow: none; }
.button.primary { background: var(--blue); color: #fff; }
.button.secondary { background: var(--blue-soft); color: var(--blue-dark); }
.button.ghost { background: #fff; border: 1px solid var(--line); color: var(--muted); }
.button.danger { background: var(--red); color: #fff; }
.text-link { color: var(--blue); font-size: 12px; font-weight: 800; }
.hidden { display: none !important; }

.status-banner { margin: -8px 0 18px; padding: 12px 15px; border-radius: 10px; color: #26415c; background: #eaf2ff; border: 1px solid #cfe0ff; font-size: 13px; line-height: 1.6; }
.status-banner.error { color: #8e2e3b; background: #fff1f2; border-color: #fecdd3; }
.status-banner.success { color: #126b4f; background: #ecfdf5; border-color: #bbf7d0; }
.status-banner.loading { color: #475569; background: #f1f5f9; border-color: #e2e8f0; }
.panel, .stat-card, .empty-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 7px 22px #18203408; }
.panel { padding: 22px; margin-bottom: 18px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 17px; }
.panel-heading h2 { margin: 5px 0 0; font-size: 20px; letter-spacing: -.025em; }
.panel-note, .metric-note { margin: -5px 0 16px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.metric-note { margin: 5px 0 0; white-space: nowrap; }
.stats-grid { display: grid; gap: 13px; }
.overview-stats { grid-template-columns: repeat(5, 1fr); margin-bottom: 18px; }
.stat-card { min-height: 130px; padding: 19px; display: flex; flex-direction: column; gap: 8px; }
.stat-card span { color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-card strong { font-size: clamp(22px, 3vw, 30px); letter-spacing: -.05em; }
.stat-card small { color: #94a3b8; font-size: 11px; margin-top: auto; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.chart-card { min-width: 0; }
.chart { height: 330px; width: 100%; }
.chart-small { height: 280px; }
.chart-analysis { height: 520px; }
.trend-chart { height: 500px; }
.ranking-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.ranking-list li { min-height: 35px; padding: 8px 10px; border-radius: 8px; background: #f8fafc; display: flex; align-items: center; gap: 10px; }
.ranking-list li.clickable-keyword { cursor: pointer; }
.ranking-list li.clickable-keyword:hover, .ranking-list li.clickable-keyword:focus { background: var(--blue-soft); outline: none; }
.ranking-list .rank { color: var(--blue); width: 25px; font-weight: 900; }
.ranking-list .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.topic-label { min-width: 0; display: flex; flex-direction: column; gap: 1px; line-height: 1.25; }
.topic-label strong { color: var(--blue); font-size: 13px; overflow-wrap: anywhere; }
.topic-label small { color: #94a3b8; font-size: 10px; font-weight: 600; overflow-wrap: anywhere; }
.large-ranking li { min-height: 45px; font-size: 14px; }
.compact-table table { min-width: 0; }
.table-wrap { overflow: auto; }
table { width: 100%; min-width: 760px; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 11px; font-weight: 900; white-space: nowrap; }
td { font-size: 12px; line-height: 1.6; }
.compact-table th, .compact-table td { padding: 10px 7px; }
.title-cell { max-width: 300px; font-weight: 800; }
.paper-title { font-weight: 800; }
.paper-title a { display: inline-block; margin-top: 3px; color: var(--blue); font-size: 11px; font-weight: 600; }
.tag { display: inline-block; margin: 2px 3px 2px 0; padding: 3px 6px; border-radius: 5px; background: #f1f5f9; color: #475569; font-size: 10px; }
.tag.original { background: #fff7ed; color: #9a4c09; }
.tag.extracted { background: #eef4ff; color: #2a5bc0; }
.table-action { border: 0; background: none; color: var(--blue); font-size: 12px; font-weight: 800; cursor: pointer; margin-right: 8px; padding: 0; }
.table-action.delete { color: var(--red); }
.pagination { justify-content: flex-end; margin-top: 16px; }
.pagination span { color: var(--muted); font-size: 12px; }

.badge { border-radius: 999px; padding: 7px 10px; font-size: 11px; font-weight: 900; white-space: nowrap; }
.badge.blue { color: var(--blue-dark); background: var(--blue-soft); }
.badge.purple { color: #6d28d9; background: #f3e8ff; }
.stack-form { display: grid; gap: 14px; }
.filter-grid, .filter-bar { display: grid; grid-template-columns: minmax(230px, 1fr) 170px 150px auto; gap: 12px; align-items: end; }
.filter-bar { grid-template-columns: repeat(3, minmax(120px, 1fr)) auto; }
.trend-filter { grid-template-columns: 180px 150px 150px minmax(200px, 1fr) auto; }
.keyword-filter { min-width: 180px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 800; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px; outline: none; color: var(--ink); background: #fff; }
input:focus, select:focus, textarea:focus { border-color: #8fb2ff; box-shadow: 0 0 0 3px #2563eb15; }
.form-hint { color: var(--muted); font-size: 11px; margin: -4px 0 0; }
.result-box { margin-top: 17px; padding: 13px; border-radius: 10px; min-height: 75px; font-size: 12px; line-height: 1.7; }
.muted-box { color: var(--muted); background: #f8fafc; }
.result-box.success-box { color: #126b4f; background: #ecfdf5; }
.result-box.error-box { color: #8e2e3b; background: #fff1f2; }
.preview-table { max-height: 260px; overflow: auto; margin: 10px 0 14px; }
.import-status { display: inline-block; padding: 2px 6px; border-radius: 5px; font-size: 11px; font-weight: 800; }
.import-status-ready, .import-status-added { color: #126b4f; background: #dcfce7; }
.import-status-duplicate { color: #9a4c09; background: #ffedd5; }
.import-status-error, .import-status-incomplete { color: #8e2e3b; background: #ffe4e6; }
.inline-notice { margin: 16px 0 -2px; padding: 12px; border-radius: 9px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #8e2e3b; background: #fff1f2; font-size: 12px; }
.import-rules { margin-top: 0; }
.rule-grid, .info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.rule-grid > div { padding: 14px; border-radius: 11px; background: #f8fafc; }
.rule-grid strong { font-size: 13px; }
.rule-grid p, .info-card p, .declaration p { color: var(--muted); font-size: 12px; line-height: 1.75; margin: 7px 0 0; }
.related-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.related-item { padding: 12px; border-radius: 9px; background: #f8fafc; font-size: 12px; line-height: 1.6; }
.related-item a { color: var(--blue); font-weight: 800; }
.paper-meta { color: var(--muted); font-size: 11px; }
.paper-meta.warning { color: #b45309; }
.empty { color: #94a3b8; text-align: center; padding: 22px 8px; }
.empty-panel { margin-top: 18px; padding: 45px 20px; text-align: center; }
.empty-panel h2 { margin: 8px 0; font-size: 21px; }
.empty-panel p { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.empty-icon { color: #8fb2ff; font-size: 42px; }
.info-card { position: relative; min-height: 195px; }
.info-number { color: #c9d7fa; font-weight: 900; font-size: 30px; letter-spacing: -.07em; }
.info-card h2 { margin: 14px 0 0; font-size: 18px; }
.workflow-list { margin: 0; padding-left: 22px; color: var(--ink); font-size: 13px; line-height: 2.1; }
.declaration { border-left: 4px solid var(--blue); }

dialog { width: min(620px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 16px; box-shadow: 0 20px 80px #17203340; }
dialog::backdrop { background: #17203380; backdrop-filter: blur(3px); }
.dialog-form { padding: 23px; display: grid; gap: 14px; }
.dialog-form .panel-heading { margin-bottom: 0; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.icon-button { border: 0; background: transparent; color: var(--muted); font-size: 26px; cursor: pointer; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 390px; padding: 13px 16px; border-radius: 10px; background: #172033; color: #fff; font-size: 12px; opacity: 0; transform: translateY(15px); pointer-events: none; transition: .2s; z-index: 40; }
.toast.show { opacity: 1; transform: translateY(0); }
.delete-warning { padding: 15px; border: 1px solid #fecdd3; border-radius: 11px; background: #fff1f2; color: #8e2e3b; display: grid; gap: 6px; line-height: 1.6; }
.delete-warning strong { font-size: 15px; overflow-wrap: anywhere; }
.delete-warning span { color: #b45309; font-size: 12px; }
.delete-warning p { margin: 3px 0 0; font-size: 12px; }

@media (max-width: 1100px) {
  .content { padding-left: 25px; padding-right: 25px; }
  .overview-stats { grid-template-columns: repeat(3, 1fr); }
  .trend-filter, .filter-grid, .filter-bar { grid-template-columns: repeat(2, 1fr); }
  .filter-actions { justify-content: flex-start; }
}
@media (max-width: 760px) {
  .topbar { height: 62px; padding: 0 16px; }
  .mobile-nav-button { display: block; }
  .topbar-meta { display: none; }
  .app-shell { display: block; }
  .sidebar { position: fixed; top: 62px; left: -245px; height: calc(100vh - 62px); z-index: 30; transition: left .2s; }
  .sidebar.open { left: 0; box-shadow: 12px 0 30px #17203340; }
  .nav-backdrop { display: block; position: fixed; inset: 62px 0 0; z-index: 25; background: #17203366; }
  .content { padding: 24px 15px 45px; }
  .page-head { display: block; }
  .page-actions { margin-top: 17px; flex-wrap: wrap; }
  .two-column, .chart-grid, .info-grid, .rule-grid, .related-list { grid-template-columns: 1fr; }
  .overview-stats { grid-template-columns: repeat(2, 1fr); }
  .filter-grid, .filter-bar, .trend-filter { grid-template-columns: 1fr; }
  .filter-actions { justify-content: stretch; }
  .filter-actions .button { flex: 1; }
  .chart-analysis, .trend-chart { height: 460px; }
  .inline-notice { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 430px) {
  .overview-stats { grid-template-columns: 1fr; }
  .panel { padding: 17px; }
  .page-head h1 { font-size: 26px; }
  .stat-card { min-height: 105px; }
  .two-columns { grid-template-columns: 1fr; }
  .page-actions .button { flex: 1; }
}
