/* Warner Research Lab design system.
   Tokens first; components below. Page modules may append page-specific rules at the END of this file. */

:root {
  --navy: #1f3a5f;
  --navy-2: #2c5282;
  --accent: #b7791f;          /* academic gold */
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e1e5eb;
  --border-strong: #c9d0da;
  --text: #1a202c;
  --text-2: #4a5568;
  --muted: #718096;
  --primary: #2c5282;
  --primary-hover: #1f3a5f;
  --primary-soft: #e6eef8;
  --ok: #2f855a;   --ok-soft: #e3f4ea;
  --warn: #b7791f; --warn-soft: #fdf3e1;
  --danger: #c53030; --danger-soft: #fdeaea;
  --info: #2b6cb0; --info-soft: #e6f0fa;
  --maybe: #6b46c1; --maybe-soft: #efeafb;
  --hl-include: #c6f0d4;
  --hl-exclude: #fbd0d0;
  --sidebar-bg: #16263d;
  --sidebar-text: #c8d3e3;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Source Serif 4', Georgia, serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1520; --surface: #172131; --surface-2: #1d293b; --border: #283548; --border-strong: #36465e;
    --text: #e6ebf2; --text-2: #b5c0d0; --muted: #8796ab;
    --primary: #6aa1e0; --primary-hover: #8bb6ea; --primary-soft: #1d3150;
    --ok: #5fc98c; --ok-soft: #173326; --warn: #e3ad55; --warn-soft: #3a2c14;
    --danger: #f07a7a; --danger-soft: #3d1c1c; --info: #6aa1e0; --info-soft: #1a2c45;
    --maybe: #a98ae8; --maybe-soft: #2a2145;
    --hl-include: #1f4a32; --hl-exclude: #4f2525;
    --sidebar-bg: #0b111a; --navy: #8bb6ea;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; }
h1 { font: 700 26px/1.2 var(--serif); letter-spacing: -.01em; }
h2 { font: 600 19px/1.3 var(--serif); }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; padding: 4px 8px 18px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg, #2c5282, #1f3a5f);
  border: 1px solid rgba(255,255,255,.15); display: grid; place-items: center; font: 700 18px var(--serif); color: #fff;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font: 700 16px var(--serif); letter-spacing: .02em; }
.brand-text span { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; opacity: .7; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--sidebar-text); font-weight: 500; }
.nav-link:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav-link.active { background: rgba(255,255,255,.1); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.sidebar-foot .btn-ghost { color: var(--sidebar-text); border-color: rgba(255,255,255,.15); }
.me { display: flex; gap: 10px; align-items: center; color: #fff; padding: 4px; border-radius: 8px; }
.me:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.me-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.me-text strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text span { font-size: 11px; opacity: .65; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.main { padding: 28px 32px 60px; max-width: 1400px; width: 100%; }
.menu-toggle { background: none; border: 0; font-size: 20px; color: var(--text); cursor: pointer; }

@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 50; left: 0; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
  .topbar-title { font: 600 15px var(--serif); }
  .main { padding: 18px 16px 48px; }
}

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--muted); }

/* ---------- Cards & layout ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 16px 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-main-side { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font: 700 28px/1.2 var(--serif); margin-top: 4px; }
.stat-danger .stat-value { color: var(--danger); }
.stat-warn .stat-value { color: var(--warn); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 500 13px var(--font); cursor: pointer;
  white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.92); background: var(--danger); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.icon-btn { background: none; border: 0; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
/* Screening decision buttons */
.btn-include { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-exclude { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-maybe { background: var(--maybe); border-color: var(--maybe); color: #fff; }
.btn-include:hover, .btn-exclude:hover, .btn-maybe:hover { filter: brightness(.92); }
.btn-outline-include { color: var(--ok); border-color: var(--ok); }
.btn-outline-exclude { color: var(--danger); border-color: var(--danger); }
.btn-outline-maybe { color: var(--maybe); border-color: var(--maybe); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field-hint { font-size: 12px; color: var(--muted); }
input, select, textarea {
  font: 14px var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 90px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.form-error { background: var(--danger-soft); color: var(--danger); padding: 8px 12px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 13px; }
.search { max-width: 280px; }
.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; font-size: 13px; }

/* ---------- Badges & pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.badge-neutral { background: var(--primary-soft); color: var(--primary); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-maybe { background: var(--maybe-soft); color: var(--maybe); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill-planning { background: var(--surface-2); color: var(--text-2); }
.pill-active, .pill-in_progress { background: var(--info-soft); color: var(--info); }
.pill-data_collection, .pill-analysis { background: var(--primary-soft); color: var(--primary); }
.pill-writing, .pill-revision { background: var(--maybe-soft); color: var(--maybe); }
.pill-submitted { background: var(--warn-soft); color: var(--warn); }
.pill-published, .pill-done { background: var(--ok-soft); color: var(--ok); }
.pill-on_hold, .pill-blocked { background: var(--danger-soft); color: var(--danger); }
.pill-archived, .pill-todo { background: var(--surface-2); color: var(--muted); }
.priority-high { color: var(--danger); font-weight: 600; }
.priority-low { color: var(--muted); }

/* ---------- Avatars ---------- */
.avatar { display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 600; flex-shrink: 0; letter-spacing: .02em; }
.avatar-empty { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--border-strong); }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -7px; width: 26px; height: 26px; font-size: 10px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.avatar-more { background: var(--surface-2); color: var(--text-2); }
.person { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.clickable { cursor: pointer; }
.cell-title { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--muted); }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; gap: 12px; align-items: center; padding: 11px 20px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub { font-size: 12px; color: var(--muted); }

/* Progress */
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; min-width: 60px; }
.progress-fill { height: 100%; background: var(--ok); border-radius: 999px; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 10px 14px; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; cursor: pointer; background: none; border-top: 0; border-left: 0; border-right: 0; font-size: 14px; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab .count { margin-left: 6px; font-size: 11px; background: var(--surface-2); padding: 1px 6px; border-radius: 999px; color: var(--muted); }

/* Segmented filter */
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; font: 500 12.5px var(--font); color: var(--text-2); cursor: pointer; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

/* Activity feed */
.feed-item { display: flex; gap: 10px; padding: 10px 20px; border-bottom: 1px solid var(--border); font-size: 13px; }
.feed-item:last-child { border-bottom: 0; }
.feed-time { font-size: 11.5px; color: var(--muted); }

/* Empty / loading */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty p { margin-bottom: 12px; }
.loading { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 48px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(10, 18, 30, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal-wide { max-width: 820px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font: 600 17px var(--serif); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }

/* ---------- Toasts ---------- */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: 13px; transition: opacity .3s, transform .3s; }
.toast-error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- Login ---------- */
.login { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.login-hero { background: radial-gradient(1200px 600px at 0% 0%, #2c5282 0%, #16263d 60%); color: #e6edf7; display: flex; align-items: center; padding: 48px; }
.login-hero-inner { max-width: 480px; }
.login-hero h1 { font-size: 36px; color: #fff; margin: 36px 0 14px; }
.login-hero p { color: #c8d3e3; font-size: 15px; }
.login-points { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 10px; }
.login-points li { padding-left: 26px; position: relative; color: #dbe4f0; }
.login-points li::before { content: '✓'; position: absolute; left: 0; color: var(--accent); font-weight: 700; }
.brand-lg .brand-mark { width: 44px; height: 44px; font-size: 22px; }
.login-panel { display: grid; place-items: center; padding: 32px 16px; background: var(--bg); }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 26px; }
.login-help { font-size: 12px; color: var(--muted); margin-top: 16px; text-align: center; }
@media (max-width: 860px) { .login { grid-template-columns: 1fr; } .login-hero { padding: 32px 20px; } .login-hero h1 { font-size: 26px; margin-top: 22px; } .login-points { display: none; } }

/* ===== Page-specific rules appended below this line ===== */
