:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --ink: #1a2233;
  --muted: #5b6577;
  --line: #e3e8f0;
  --brand: #0b3d91;        /* deep astronomy blue */
  --brand-2: #1565c0;
  --accent: #00a3a3;       /* teal */
  --chip: #eef2fb;
  --shadow: 0 1px 3px rgba(16, 30, 70, .08), 0 8px 24px rgba(16, 30, 70, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body { max-width: 100%; overflow-x: hidden; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* never let a long word/URL force horizontal scrolling */
.brand-text, .paper-title, .abstract-full, .cite-apa, .card h3, .mi-title { overflow-wrap: anywhere; }

/* ---------- top bar ---------- */
.topbar {
  background: linear-gradient(120deg, var(--brand) 0%, #12489f 55%, var(--brand-2) 100%);
  color: #fff;
  padding: 22px clamp(16px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
}
.brand { display: flex; align-items: center; gap: 16px; }
.logo-link { display: inline-flex; line-height: 0; border-radius: 50%; transition: transform .12s; }
.logo-link:hover { transform: scale(1.05); }
.logo-link:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.logo-img {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #fff;
  padding: 3px;
  object-fit: contain;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
}
.brand-text h1 { margin: 0; font-size: 22px; font-weight: 700; }
.brand-text p { margin: 2px 0 0; font-size: 13px; opacity: .85; }

.header-right { display: flex; align-items: center; gap: 26px; }
.top-nav a {
  color: #fff; text-decoration: none; font-weight: 600; font-size: 14px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.3);
  padding: 9px 16px; border-radius: 9px;
}
.top-nav a:hover { background: rgba(255,255,255,.22); }
.stats { display: flex; gap: 26px; }
.stat { text-align: center; }
.stat .num { font-size: 26px; font-weight: 800; line-height: 1; }
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; opacity: .8; margin-top: 4px; }

/* ---------- search ---------- */
.searchbar {
  background: linear-gradient(180deg, #12489f, transparent);
  padding: 0 clamp(16px, 4vw, 48px) 26px;
  margin-top: -2px;
}
.search-wrap {
  max-width: 720px;
  margin: 0 auto;
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute; left: 18px; width: 20px; height: 20px;
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round;
}
#search {
  width: 100%;
  padding: 16px 18px 16px 50px;
  border: none;
  border-radius: 999px;
  font-size: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  outline: none;
  color: var(--ink);
}
#search:focus { box-shadow: 0 0 0 3px rgba(0, 163, 163, .35), var(--shadow); }
.clear-btn {
  position: absolute; right: 14px;
  border: none; background: var(--chip); color: var(--muted);
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 18px; cursor: pointer; line-height: 1;
}
.clear-btn:hover { background: #e0e6f2; color: var(--ink); }

/* ---------- intro note ---------- */
.intro-note {
  max-width: 1240px;
  margin: 22px auto 0;
  padding: 14px clamp(16px, 4vw, 48px);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.intro-note > p {
  margin: 0;
  background: #eef3fc;
  border: 1px solid #d8e3f7;
  border-left: 4px solid var(--brand);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13.5px;
  color: #2c3850;
  line-height: 1.55;
}
.intro-note .note-icon {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 14px;
  fill: none;
  stroke: var(--brand);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@media (max-width: 880px) { .intro-note .note-icon { display: none; } }

/* ---------- layout ---------- */
.layout {
  max-width: 1240px;
  margin: 24px auto;
  padding: 0 clamp(16px, 4vw, 48px);
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
  align-items: start;
}

/* ---------- sidebar ---------- */
.sidebar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sidebar-head h2 { font-size: 15px; margin: 0; }
.link-btn { background: none; border: none; color: var(--brand-2); cursor: pointer; font-size: 13px; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }

.dept-group { border-top: 1px solid var(--line); padding: 8px 0; }
.dept-group:first-child { border-top: none; }
.dept-row {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 6px 4px; border-radius: 8px;
  font-weight: 600; font-size: 14px;
}
.dept-row:hover { background: var(--chip); }
.dept-row .caret { transition: transform .15s; color: var(--muted); font-size: 11px; width: 12px; }
.dept-row.open .caret { transform: rotate(90deg); }
.dept-row .name { flex: 1; }
.count-badge {
  background: var(--chip); color: var(--muted);
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
}
.dept-row.active { color: var(--brand); }
.dept-row.active .count-badge { background: var(--brand); color: #fff; }

.lab-list { margin: 2px 0 6px 22px; display: none; }
.lab-list.show { display: block; }
.lab-row {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 5px 8px; border-radius: 8px;
  font-size: 13px; color: var(--muted);
}
.lab-row:hover { background: var(--chip); }
.lab-row.active { background: var(--brand); color: #fff; }
.lab-row.active .count-badge { background: rgba(255, 255, 255, .25); color: #fff; }
.lab-row .name { flex: 1; }

/* ---------- results ---------- */
.results-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 12px; flex-wrap: wrap;
}
.result-count { font-size: 14px; color: var(--muted); }
.result-count b { color: var(--ink); }
.bar-controls { display: flex; align-items: center; gap: 12px; }
.sort-wrap { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

.export-wrap { position: relative; }
.export-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 6px; min-width: 200px;
}
.export-menu[hidden] { display: none; }
.export-menu button {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 9px 12px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--ink);
}
.export-menu button:hover { background: var(--chip); color: var(--brand-2); }
#sort {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
  background: var(--surface); color: var(--ink); font-size: 13px; cursor: pointer;
}

.active-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #e7f0ff; color: var(--brand);
  border: 1px solid #cfe0ff; border-radius: 999px;
  padding: 5px 10px; font-size: 12px; font-weight: 600;
}
.filter-chip button { border: none; background: none; cursor: pointer; color: var(--brand); font-size: 14px; line-height: 1; }

/* ---------- cards ---------- */
.cards { display: flex; flex-direction: column; gap: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  transition: transform .12s, box-shadow .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(16, 30, 70, .12); }
.card .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--chip); color: var(--muted); cursor: pointer;
}
.tag.dept { background: #e7f0ff; color: var(--brand); }
.tag.lab { background: #e3f7f5; color: #08807e; }
.tag.year { background: #fff3e0; color: #b3640a; cursor: default; }

.card h3 { margin: 0 0 8px; font-size: 17px; line-height: 1.35; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card h3 a:hover { color: var(--brand-2); }

.authors { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.meta { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.meta .journal { font-style: italic; color: #3a4458; }

.abstract { font-size: 14px; color: #2c3850; }
.abstract .body { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.abstract.expanded .body { -webkit-line-clamp: unset; }
.toggle-abs { background: none; border: none; color: var(--brand-2); cursor: pointer; font-size: 13px; font-weight: 600; padding: 4px 0 0; }
.no-abstract { font-size: 13px; color: #97a0b3; font-style: italic; }

.card-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border-radius: 9px; padding: 8px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  text-decoration: none;
}
.btn:hover { border-color: var(--brand-2); color: var(--brand-2); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: #0a3680; color: #fff; }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- pagination ---------- */
.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; margin: 26px 0 10px; flex-wrap: wrap; }
.pagination button {
  min-width: 38px; height: 38px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 9px; cursor: pointer; font-size: 14px; color: var(--ink);
}
.pagination button:hover:not(:disabled) { border-color: var(--brand-2); color: var(--brand-2); }
.pagination button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination .ellipsis { color: var(--muted); padding: 0 4px; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(16, 25, 55, .5);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal[hidden] { display: none; }
.clear-btn[hidden] { display: none; }
.modal-box {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  width: min(680px, 100%); max-height: 85vh; overflow-y: auto; padding: 22px 24px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 18px; }
.cite-block { margin-bottom: 18px; }
.cite-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 6px; }
.cite-block pre {
  white-space: pre-wrap; word-break: break-word; background: #f7f9fd; border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; font-size: 13px; margin: 0 0 8px; font-family: ui-monospace, Menlo, Consolas, monospace;
}
.copy-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--brand-2);
}
.copy-btn:hover { border-color: var(--brand-2); }
.copy-btn.copied { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- footer ---------- */
.footer {
  text-align: center; padding: 30px 16px; color: var(--muted); font-size: 13px;
  display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
}
.footer .dot { opacity: .5; }
.footer-link { color: var(--brand-2); text-decoration: none; font-weight: 600; }
.footer-link:hover { text-decoration: underline; }
.copyright { flex-basis: 100%; text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 4px; }

/* ---------- loading skeleton ---------- */
.skeleton { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.skeleton .line { height: 12px; background: linear-gradient(90deg, #eef1f7, #f7f9fd, #eef1f7); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; margin-bottom: 10px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---------- admin ---------- */
.admin-top-actions { display: flex; gap: 10px; }
.btn.ghost-on-dark { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.3); }
.btn.ghost-on-dark:hover { background: rgba(255,255,255,.22); color: #fff; }

.login-screen { display: flex; justify-content: center; padding: 60px 20px; }
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px; width: min(420px, 100%); text-align: center;
}
.login-card h2 { margin: 0 0 6px; }
.login-card p { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
#login-form { display: flex; flex-direction: column; gap: 12px; }
#login-key { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; }
#login-key:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(21,101,192,.15); }

.admin-wrap { max-width: 920px; margin: 26px auto; padding: 0 clamp(16px,4vw,48px); }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tab {
  border: none; background: none; padding: 12px 18px; font-size: 15px; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 20px;
}
.panel h2 { margin: 0 0 4px; font-size: 18px; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 14px; }

.doi-row { display: flex; gap: 10px; flex-wrap: wrap; }
.doi-row input { flex: 1; min-width: 220px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; }
.doi-row input:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(21,101,192,.15); }

.paper-form label { display: block; font-weight: 600; font-size: 13px; color: var(--ink); margin-bottom: 14px; }
.paper-form input, .paper-form select, .paper-form textarea {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px; font-size: 14px; font-family: inherit; color: var(--ink); background: var(--surface);
}
.paper-form textarea { resize: vertical; }
.paper-form input:focus, .paper-form select:focus, .paper-form textarea:focus {
  outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(21,101,192,.15);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.req { color: #d23; }
.muted-label { color: var(--muted); font-weight: 400; font-size: 12px; }
.advanced { margin-bottom: 14px; }
.advanced summary { cursor: pointer; color: var(--brand-2); font-weight: 600; font-size: 13px; }
.advanced label { margin-top: 12px; }

.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.form-status { font-size: 13px; color: var(--muted); }
.form-msg, .form-error, .form-warn {
  border-radius: 9px; padding: 10px 14px; font-size: 14px; margin-top: 12px;
}
.form-error { background: #fdecea; color: #b3261e; border: 1px solid #f6c9c4; }
.form-msg.ok { background: #e6f6ee; color: #18794e; border: 1px solid #b7e4c7; }
.form-msg.err { background: #fdecea; color: #b3261e; border: 1px solid #f6c9c4; }
.form-warn { background: #fff7e6; color: #9a6700; border: 1px solid #ffe2a8; }

.manage-bar { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
#manage-search { flex: 1; min-width: 220px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
#manage-search:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(21,101,192,.15); }

.manage-list { display: flex; flex-direction: column; }
.manage-item { display: flex; align-items: center; gap: 14px; padding: 14px 6px; border-top: 1px solid var(--line); }
.manage-item:first-child { border-top: none; }
.manage-item .mi-main { flex: 1; min-width: 0; }
.manage-item .mi-title { font-weight: 600; font-size: 15px; }
.manage-item .mi-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.manage-item .mi-actions { display: flex; gap: 8px; }
.btn.small { padding: 6px 12px; font-size: 12px; }
.btn.danger { color: #b3261e; border-color: #f0c6c1; }
.btn.danger:hover { background: #fdecea; border-color: #b3261e; color: #b3261e; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; box-shadow: var(--shadow); z-index: 100;
}
.toast[hidden] { display: none; }
.toast.error { background: #b3261e; }
.tab-panel[hidden], .login-screen[hidden], #workspace[hidden], #paper-form[hidden],
#logout-btn[hidden], .form-msg[hidden], .form-error[hidden], .form-warn[hidden], #dup-warn[hidden] { display: none; }

/* ---------- SJR quartile badge ---------- */
.q-badge {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  text-decoration: none; border: 1px solid transparent; letter-spacing: .2px;
}
.q-badge.q1 { background: #e3f6ea; color: #137a3b; border-color: #b6e3c6; }
.q-badge.q2 { background: #e4eefc; color: #1559b8; border-color: #c3d9f6; }
.q-badge.q3 { background: #fff2db; color: #9a6206; border-color: #ffdfa6; }
.q-badge.q4 { background: #f0f1f4; color: #5a6373; border-color: #dde0e8; }
.q-badge:hover { filter: brightness(0.96); }

/* ---------- keyword chips (cards) ---------- */
.card .keywords { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.kw-chip {
  font-size: 11.5px; font-weight: 500; padding: 3px 9px; border-radius: 999px;
  background: #f0f1f6; color: #4a5366; cursor: pointer; border: 1px solid #e3e6ee;
}
.kw-chip:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- server-rendered paper detail page ---------- */
.paper-page { max-width: 820px; margin: 26px auto; padding: 0 clamp(16px, 4vw, 40px); }
.back-link { display: inline-block; margin-bottom: 16px; color: var(--brand-2); text-decoration: none; font-weight: 600; font-size: 14px; }
.back-link:hover { text-decoration: underline; }
.paper-detail {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px 30px;
}
.paper-detail .tag { text-decoration: none; }
.paper-title { font-size: 25px; line-height: 1.3; margin: 12px 0 10px; }
.paper-detail .authors { font-size: 15px; color: var(--muted); margin-bottom: 6px; }
.paper-detail .meta { font-size: 14px; color: var(--muted); margin-bottom: 18px; }
.paper-detail h2 { font-size: 15px; margin: 22px 0 8px; color: var(--brand); }
.abstract-full { font-size: 15px; line-height: 1.65; color: #2c3850; }
.cite-apa { font-size: 14px; color: #2c3850; background: #f7f9fd; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.kw-list { display: flex; flex-wrap: wrap; gap: 7px; }
.kw-list .kw {
  font-size: 12.5px; padding: 4px 11px; border-radius: 999px; text-decoration: none;
  background: #f0f1f6; color: #4a5366; border: 1px solid #e3e6ee;
}
.kw-list .kw:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- statistics page ---------- */
.stats-page { max-width: 1100px; margin: 26px auto; padding: 0 clamp(16px, 4vw, 48px); }
.stats-page h2 { font-size: 20px; margin: 0 0 4px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 26px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.kpi .num { font-size: 30px; font-weight: 800; color: var(--brand); line-height: 1; }
.kpi .label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-top: 6px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 820px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-card h3 { font-size: 15px; margin: 0 0 16px; }
.bar-row { display: grid; grid-template-columns: 190px 1fr 42px; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13px; }
.bar-row .bl { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bl a { color: inherit; text-decoration: none; }
.bar-row .bl a:hover { color: var(--brand-2); }
.bar-track { background: var(--chip); border-radius: 6px; height: 18px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 6px; }
.bar-fill.q-q1 { background: linear-gradient(90deg, #137a3b, #1ea35a); }
.bar-fill.q-q2 { background: linear-gradient(90deg, #1559b8, #2e7bd6); }
.bar-fill.q-q3 { background: linear-gradient(90deg, #9a6206, #d68f1e); }
.bar-fill.q-q4 { background: linear-gradient(90deg, #5a6373, #828b9c); }
.bar-fill.q-unranked { background: linear-gradient(90deg, #b6bcc8, #cdd2dc); }
.card-sub { font-weight: 400; font-size: 12px; color: var(--muted); }
.kpi-sub { font-size: 14px; color: var(--muted); font-weight: 700; }
.muted-note { color: var(--muted); font-size: 13.5px; line-height: 1.6; }
.muted-note code { background: var(--chip); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }
.bar-row .bv { text-align: right; color: var(--muted); font-weight: 600; }
.year-chart { display: flex; align-items: flex-end; gap: 6px; height: 200px; padding-top: 10px; }
.year-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.year-col .yc-bar { width: 70%; background: linear-gradient(180deg, var(--brand-2), var(--brand)); border-radius: 5px 5px 0 0; min-height: 3px; }
.year-col .yc-num { font-size: 11px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.year-col .yc-label { font-size: 10.5px; color: var(--muted); margin-top: 6px; transform: rotate(-45deg); transform-origin: top left; white-space: nowrap; }
.kw-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.kw-cloud a {
  text-decoration: none; background: #eef2fb; color: var(--brand); border: 1px solid #d8e3f7;
  border-radius: 999px; padding: 5px 12px; font-weight: 600;
}
.kw-cloud a:hover { background: var(--brand); color: #fff; }

/* ---------- responsive ---------- */
.topbar { flex-wrap: wrap; }
.brand-text { min-width: 0; }
.header-right { flex-wrap: wrap; }
.stats { flex-wrap: wrap; }

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .stats { gap: 18px; }
  .stat .num { font-size: 20px; }
}

/* ---------- phones ---------- */
@media (max-width: 560px) {
  .topbar { padding: 16px; gap: 12px; }
  .brand { gap: 12px; }
  .logo-img { width: 46px; height: 46px; }
  .brand-text h1 { font-size: 18px; }
  .brand-text p { font-size: 12px; }
  /* hide the redundant header stat tiles on phones (same numbers live on the
     Statistics page); keep just the brand + Statistics button */
  .header-right { width: auto; }
  .stats { display: none; }
  .top-nav a { padding: 8px 14px; }

  .searchbar { padding-bottom: 20px; }
  #search { font-size: 16px; }            /* keeps iOS from zooming on focus */

  .intro-note { padding-top: 16px; }
  .intro-note > p { font-size: 13px; }

  .results-bar { gap: 10px; }
  .bar-controls { width: 100%; justify-content: space-between; }

  .card { padding: 16px; }
  .card h3 { font-size: 16px; }
  .card-actions .btn { flex: 1 1 auto; justify-content: center; }

  .admin-wrap, .stats-page, .paper-page { margin-top: 16px; }
  .paper-detail { padding: 20px 18px; }
  .paper-title { font-size: 21px; }

  /* compact bar charts so labels + bars fit narrow screens */
  .bar-row { grid-template-columns: 96px 1fr 32px; gap: 8px; font-size: 12px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi { padding: 14px 16px; }
  .kpi .num { font-size: 24px; }
  .year-chart { height: 170px; }

  .admin-top-actions { flex-wrap: wrap; }
  .tabs { overflow-x: auto; }
  .manage-item { flex-wrap: wrap; }
  .grid-2 { grid-template-columns: 1fr; }
}
