:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #172033;
  --muted: #667085;
  --accent: #2458d3;
  --accent-soft: #e9efff;
  --good: #0f7b4f;
  --warn: #9a5b00;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  flex: 0 0 auto;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  min-width: min(760px, 58vw);
}

input,
select,
button {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 0 11px;
}

button {
  cursor: pointer;
}

select {
  width: 178px;
}

.layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  min-height: 0;
}

.sidebar {
  min-height: 0;
  border-right: 1px solid var(--line);
  background: #f0f2f6;
  overflow: auto;
}

.sidebar-filters {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  gap: 8px;
  padding: 12px;
  background: #f0f2f6;
  border-bottom: 1px solid var(--line);
}

.sidebar-filters select {
  width: 100%;
}

.sidebar-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

.sidebar-action span {
  min-width: 28px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef2f8;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.sidebar-action.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-head {
  position: sticky;
  top: 208px;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  padding: 14px 16px;
  background: #f0f2f6;
  border-bottom: 1px solid var(--line);
}

.journal-list {
  padding: 8px;
}

.journal-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.journal-row:hover {
  background: #e6e9ef;
}

.journal-row.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.journal-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
  font-size: 13px;
}

.journal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.latest-date {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: #e6e9ef;
  color: #344054;
  font-size: 11px;
  font-weight: 700;
}

.count-pill {
  min-width: 34px;
  text-align: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.content {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.snapshot-note {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #f0d899;
  border-radius: 8px;
  background: #fff8e6;
  color: #7a4b00;
  font-size: 13px;
}

.journal-detail,
.article-toolbar,
.article-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.journal-detail {
  padding: 18px;
  margin-bottom: 12px;
}

.detail-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.detail-title h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.25;
}

.status {
  flex: 0 0 auto;
  align-self: start;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.status.good {
  background: #e7f6ef;
  color: var(--good);
}

.status.warn {
  background: #fff3d6;
  color: var(--warn);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.metric {
  padding: 10px;
  border-radius: 6px;
  background: #f7f8fb;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.article-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 14px;
  margin-bottom: 12px;
}

.article-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.period-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.period-button,
.favorite-button {
  width: auto;
  height: 32px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.period-button:hover,
.favorite-button:hover {
  border-color: #b7c1d3;
  color: var(--accent);
}

.period-button.active,
.favorite-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.article-toolbar select {
  max-width: 240px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.article-list {
  display: grid;
  gap: 10px;
}

.article-card {
  padding: 14px;
}

.article-card.is-favorite {
  border-color: #b8c7f6;
}

.article-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.article-card a {
  min-width: 0;
  color: var(--text);
  font-weight: 750;
  text-decoration: none;
}

.article-card a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.abstract {
  margin-top: 8px;
  color: #475467;
  font-size: 13px;
  line-height: 1.6;
}

.article-card footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.empty {
  padding: 40px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 860px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    min-width: 0;
  }

  .topbar-actions select {
    width: calc(50% - 5px);
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    max-height: 42vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-head {
    top: 208px;
  }

  .detail-grid {
    grid-template-columns: 1fr 1fr;
  }

  .article-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .article-controls,
  .period-filter {
    justify-content: flex-start;
  }

  .article-toolbar select {
    max-width: none;
  }

  .article-card-head {
    flex-direction: column;
  }
}
