:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1c2530;
  --muted: #6b7785;
  --line: #e1e6eb;
  --accent: #0f766e;       /* teal */
  --accent-ink: #ffffff;
  --ok: #15803d;
  --err: #b91c1c;
  --warn: #b45309;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .75rem 1.25rem; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: .75rem; }
.brand-mark {
  display: grid; place-items: center; width: 42px; height: 42px;
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
  border-radius: var(--radius); letter-spacing: .5px;
}
.brand h1 { font-size: 1.05rem; margin: 0; }
.subtitle { margin: 0; font-size: .8rem; color: var(--muted); }

.tabs { display: flex; gap: .25rem; }
.tab {
  border: none; background: transparent; color: var(--muted);
  padding: .5rem .9rem; border-radius: var(--radius); cursor: pointer;
  font-size: .92rem; font-weight: 600;
}
.tab:hover { background: var(--bg); color: var(--ink); }
.tab.active { background: var(--accent); color: var(--accent-ink); }

main { padding: 1.25rem; max-width: 1200px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

/* Toolbar */
.toolbar { display: flex; gap: .6rem; align-items: center; margin-bottom: .9rem; flex-wrap: wrap; }
input, select, button { font: inherit; }
input[type="search"], input[type="password"], input[type="number"], select {
  padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); outline: none;
}
input[type="search"]:focus, select:focus, input:focus { border-color: var(--accent); }
#pub-search { flex: 1; min-width: 220px; }

/* Buttons */
.btn {
  padding: .5rem .85rem; border: 1px solid var(--line); background: #fff;
  border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--ink);
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Table */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th {
  text-align: left; padding: .65rem .8rem; background: #fafbfc;
  border-bottom: 1px solid var(--line); position: sticky; top: 0;
  font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}
tbody td { padding: .6rem .8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: #f8fafa; }
td.title { font-weight: 600; max-width: 360px; }
td.person { white-space: nowrap; }
.type-badge {
  display: inline-block; padding: .12rem .5rem; border-radius: 999px;
  background: #eef2f1; color: var(--accent); font-size: .74rem; font-weight: 700;
}
a.doi { color: var(--accent); text-decoration: none; font-weight: 600; }
a.doi:hover { text-decoration: underline; }
.src-badge {
  display: inline-block; vertical-align: middle; margin-left: .4rem;
  padding: .05rem .4rem; border-radius: 999px; font-size: .66rem; font-weight: 700;
  background: #eef2ff; color: #4338ca; text-transform: uppercase; letter-spacing: .03em;
}

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }
.panel.narrow { max-width: 540px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.panel-head h2, .panel h2 { font-size: 1rem; margin: 0 0 .2rem; }
.panel-foot { display: flex; align-items: center; justify-content: space-between; margin-top: .8rem; flex-wrap: wrap; gap: .6rem; }
.row { display: flex; align-items: center; }
.row.gap { gap: .5rem; }
.muted { color: var(--muted); font-size: .85rem; }
.hidden { display: none !important; }

/* Member list */
#member-filter { width: 100%; margin: .5rem 0; }
.member-list { max-height: 420px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.member-row { display: flex; align-items: center; gap: .55rem; padding: .4rem .6rem; border-bottom: 1px solid var(--line); font-size: .9rem; }
.member-row:last-child { border-bottom: none; }
.member-row:hover { background: #f8fafa; }
.member-row .pubinfo { margin-left: auto; font-size: .76rem; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5db; display: inline-block; }
.dot.scraped { background: var(--ok); }
.check { display: flex; align-items: center; gap: .4rem; font-size: .88rem; color: var(--muted); }

/* Progress */
.progress-bar { height: 8px; background: #eef2f1; border-radius: 999px; overflow: hidden; margin-bottom: .6rem; }
#progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }
.progress-log { max-height: 360px; overflow: auto; font-size: .85rem; }
.log-row { display: flex; align-items: center; gap: .5rem; padding: .3rem .2rem; border-bottom: 1px dashed var(--line); }
.log-row .name { flex: 1; }
.badge { font-size: .72rem; font-weight: 700; padding: .1rem .45rem; border-radius: 6px; }
.badge.fetching, .badge.hunting { background: #fef3c7; color: var(--warn); }
.badge.done { background: #dcfce7; color: var(--ok); }
.badge.error { background: #fee2e2; color: var(--err); }
.badge.skip { background: #eef2f6; color: var(--muted); }

/* Fields */
.field { display: block; margin: .9rem 0; }
.field > span { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .9rem; }
.field small { display: block; margin-top: .3rem; }
.status { font-size: .85rem; min-height: 1.1em; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }
.empty { padding: 2rem; text-align: center; color: var(--muted); }

/* PDF cell — pinned to the right so its button is never cut off when the
   table is wider than the viewport (the column stays visible while the rest
   of the row scrolls horizontally underneath it). */
td.pdf-cell { white-space: nowrap; }
#pub-table th:last-child,
#pub-table td.pdf-cell {
  position: sticky; right: 0;
  background: var(--panel);
  box-shadow: -6px 0 6px -6px rgba(16, 24, 40, .12);
}
#pub-table thead th:last-child { background: #fafbfc; }
#pub-table tbody tr:hover td.pdf-cell { background: #f8fafa; }

/* PDF modal viewer */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(16, 24, 40, .55); padding: 2vh;
}
.modal-panel {
  position: relative; width: 90vw; height: 90vh;
  background: var(--panel); border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(16, 24, 40, .35); overflow: hidden;
}
.modal-close {
  position: absolute; top: .5rem; right: .5rem; z-index: 2;
  width: 34px; height: 34px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); border-radius: 50%;
  font-size: 1.2rem; line-height: 1; cursor: pointer;
}
.modal-close:hover { border-color: var(--accent); color: var(--accent); }
#pdf-frame { width: 100%; height: 100%; border: 0; display: block; }
