/* ─────────────────────────────────────────────────────────────────────────
   SysRevAI — application styles. Okabe-Ito accessible palette, Inter/system.
   ───────────────────────────────────────────────────────────────────────── */

:root {
    --c-bg:        #f4f6f8;
    --c-surface:   #ffffff;
    --c-text:      #1b2733;
    --c-muted:     #5b6b7b;
    --c-border:    #dde3e9;
    --c-primary:   #0072b2;
    --c-primary-d: #005a8c;
    --c-ok:        #009e73;
    --c-warn:      #e69f00;
    --c-fail:      #d55e00;
    --radius:      10px;
    --shadow:      0 1px 3px rgba(16,35,53,.08), 0 6px 24px rgba(16,35,53,.06);
    --font:        "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    background: var(--c-bg); color: var(--c-text);
    font-family: var(--font); font-size: 16px; line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Brand */
.brand__mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--c-primary); color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .5px;
}
.brand__name { font-weight: 700; font-size: 17px; color: var(--c-text); }

/* Top bar */
.topbar {
    display: flex; align-items: center; gap: 24px;
    background: var(--c-surface); border-bottom: 1px solid var(--c-border);
    padding: 0 24px; height: 60px;
}
.topbar__brand { display: flex; align-items: center; gap: 10px; }
.topbar__brand:hover { text-decoration: none; }
.topbar__nav { display: flex; gap: 18px; flex: 1; }
.topbar__nav a { color: var(--c-muted); font-weight: 500; font-size: 15px; }
.topbar__nav a:hover { color: var(--c-text); text-decoration: none; }
.topbar__user { display: flex; align-items: center; gap: 12px; }
.topbar__name { font-size: 14px; color: var(--c-muted); }
.inline-form { display: inline; }

/* Content / page */
.content { max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }
.page__head { margin-bottom: 24px; }
.page__title { margin: 0 0 4px; font-size: 26px; }
.page__subtitle { margin: 0; color: var(--c-muted); }

/* Metrics */
.metrics {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px; margin-bottom: 32px;
}
.metric {
    background: var(--c-surface); border: 1px solid var(--c-border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px; display: flex; flex-direction: column; gap: 6px;
}
.metric__value { font-size: 30px; font-weight: 700; line-height: 1; }
.metric__label { font-size: 13px; color: var(--c-muted); }

.page--narrow { max-width: 760px; }
.page__head--row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.breadcrumb { font-size: 13px; margin-bottom: 4px; }
.breadcrumb a { color: var(--c-muted); }

/* Review cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.review-card {
    display: block; background: var(--c-surface); border: 1px solid var(--c-border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; color: inherit;
}
.review-card:hover { text-decoration: none; border-color: var(--c-primary); }
.review-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.review-card__title { margin: 0; font-size: 17px; }
.review-card__q { color: var(--c-muted); font-size: 14px; margin: 8px 0 12px; }
.review-card__meta { display: flex; gap: 8px; flex-wrap: wrap; }

/* Tags */
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag--active { background: #e6f6f1; color: #06624a; }
.tag--archived { background: #eef1f4; color: var(--c-muted); }
.tag--completed { background: #eaf4fb; color: #1b3a4d; }
.tag--soft { background: #eef1f4; color: var(--c-muted); }

/* Review detail */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2 .section-card p { font-size: 14px; }
.member-list, .reason-list { list-style: none; margin: 0; padding: 0; }
.member-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--c-border); font-size: 14px; }
.member-list li:last-child { border-bottom: 0; }
.reason-list li { padding: 5px 0; font-size: 14px; border-bottom: 1px solid var(--c-border); }
.reason-list li:last-child { border-bottom: 0; }

@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }

/* Empty state */
.empty-state {
    background: var(--c-surface); border: 1px dashed var(--c-border);
    border-radius: var(--radius); padding: 48px 24px; text-align: center;
}
.empty-state p { color: var(--c-muted); margin: 0 0 16px; }

/* Auth + error pages */
.auth-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.auth-wrap { width: 100%; max-width: 380px; padding: 24px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; }
.auth-card {
    background: var(--c-surface); border: 1px solid var(--c-border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px;
}
.auth-card--center { text-align: center; }
.auth-card__title { margin: 0 0 18px; font-size: 22px; }
.error-code { font-size: 56px; font-weight: 800; color: var(--c-primary); line-height: 1; margin-bottom: 8px; }
.lead { color: var(--c-muted); }

/* Forms */
.form-grid { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; }
.field-label { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.input {
    width: 100%; padding: 10px 12px; font-size: 15px; font-family: inherit;
    border: 1px solid var(--c-border); border-radius: 8px;
    background: var(--c-surface); color: var(--c-text);
}
.input:focus { outline: 2px solid var(--c-primary); outline-offset: 1px; }

/* Alerts */
.alert { border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; font-size: 14px; }
.alert--error { background: #fdeee6; border: 1px solid #f6cdb5; color: #9c3b00; }
.alert--success { background: #e6f6f1; border: 1px solid #b7e6d6; color: #06624a; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 11px 20px; border-radius: 8px; border: 1px solid transparent;
    font-family: inherit; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none;
    transition: background .15s ease, border-color .15s ease, opacity .15s ease;
}
.btn:hover { text-decoration: none; }
.btn--sm { padding: 7px 12px; font-size: 13px; }
.btn--block { width: 100%; }
.btn--primary { background: var(--c-primary); color: #fff; }
.btn--primary:hover { background: var(--c-primary-d); }
.btn--ghost { background: var(--c-surface); border-color: var(--c-border); color: var(--c-text); }
.btn--ghost:hover { border-color: var(--c-muted); }

/* Footer + donate */
.appfooter {
    display: flex; align-items: center; justify-content: center; gap: 14px;
    padding: 20px; color: var(--c-muted); font-size: 13px;
    border-top: 1px solid var(--c-border);
}
.donate { color: #c2487f; font-weight: 600; }
.donate:hover { color: #a23667; }

.topbar__nav a.is-active { color: var(--c-text); font-weight: 600; }

/* Exports */
.prisma-preview { background: #fff; border: 1px solid var(--c-border); border-radius: 8px; padding: 14px; overflow: auto; margin: 8px 0 14px; }
.prisma-preview svg { display: block; max-width: 100%; height: auto; }

/* Summaries + translation */
.translate-block { }
.translate-block__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.translate-controls { display: flex; gap: 8px; align-items: center; }
.translate-result { margin-top: 12px; padding: 12px 14px; background: #eaf4fb; border: 1px solid #cfe6f5; border-radius: 8px; white-space: pre-wrap; font-size: 14px; }
.summary-dl dt { font-weight: 600; margin-top: 10px; font-size: 14px; }
.summary-dl dd { margin: 4px 0 0; }
.small { font-size: 12px; }

/* Risk of bias */
.rob-summary { max-width: 720px; margin: 8px 0 16px; }
.rob-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--c-muted); }
.rob-legend__item { display: inline-flex; align-items: center; gap: 6px; }
.rob-cell { display: inline-block; width: 16px; height: 16px; border-radius: 50%; vertical-align: middle; border: 1px solid rgba(0,0,0,.08); }
.rob-cell-td { text-align: center; }
.rob-table th { white-space: nowrap; }
.rob-domain { padding: 14px 0; border-bottom: 1px solid var(--c-border); }
.rob-domain:last-child { border-bottom: 0; }
.rob-domain__title { margin: 0 0 8px; font-size: 15px; }
.rob-domain__actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }

/* Full-text retrieval — references list + queue */
.ft-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; margin-right: 6px; border: 1px solid rgba(0,0,0,.1); cursor: help; }
.ft-dot--ok { background: var(--c-ok); }
.ft-dot--none { background: var(--c-warn); }
.ft-dot--queued { background: var(--c-primary); }
.ft-dot--never { background: #dde3e9; }
.tag--pending { background: #eef1f4; color: var(--c-muted); }
.tag--processing { background: #eaf4fb; color: #1b3a4d; }
.tag--completed { background: #e6f6f1; color: #06624a; }
.tag--failed { background: #fbe9e1; color: var(--c-fail); }

/* Full-text retrieval admin */
.ft-source { padding: 14px 0; border-bottom: 1px solid var(--c-border); }
.ft-source:last-of-type { border-bottom: 0; }
.ft-source__actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.ft-source__status { font-size: 13px; }
.ft-test-result { margin-top: 14px; padding: 12px 14px; background: #0f1b26; color: #d6e2ec; border-radius: 8px; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12px; white-space: pre-wrap; max-height: 320px; overflow: auto; }

/* Extraction template editor */
.tpl-row { border: 1px solid var(--c-border); border-radius: 8px; padding: 14px; margin-bottom: 12px; background: var(--c-surface); }
.tpl-row__actions { margin-top: 8px; }
.tpl-options { margin-top: 10px; }
.compare-row { padding: 8px 0; border-bottom: 1px solid var(--c-border); }
.compare-row summary { cursor: pointer; display: flex; gap: 8px; align-items: center; font-size: 14px; }
.compare-row .kv { margin-top: 8px; font-size: 13px; }
.tag--draft { background: #eef1f4; color: var(--c-muted); }
.tag--submitted { background: #eaf4fb; color: #1b3a4d; }
.tag--approved { background: #e6f6f1; color: #06624a; }

/* Full-text screening */
.ft-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.ft-main { min-width: 0; }
.ft-aside { display: flex; flex-direction: column; gap: 14px; }
.pdf-viewer { margin: 16px 0; border: 1px solid var(--c-border); border-radius: 8px; overflow: hidden; }
.pdf-viewer iframe { display: block; border: 0; background: #f0f3f6; }
.chat-panel { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 18px; }
.chat-history { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px 0; margin-bottom: 10px; }
.chat-msg { padding: 8px 12px; border-radius: 10px; font-size: 14px; max-width: 92%; white-space: pre-wrap; }
.chat-msg--user { background: var(--c-primary); color: #fff; align-self: flex-end; }
.chat-msg--assistant { background: var(--c-bg); color: var(--c-text); align-self: flex-start; border: 1px solid var(--c-border); }
.chat-form { display: flex; flex-direction: column; gap: 8px; }
.chat-form .btn { align-self: flex-end; }
@media (max-width: 880px) { .ft-layout { grid-template-columns: 1fr; } }

/* AI suggestion panel */
.ai-suggest { margin-top: 16px; }
.ai-suggest__panel { margin-top: 10px; padding: 12px 14px; border-radius: 8px; font-size: 14px; background: var(--c-bg); border: 1px solid var(--c-border); }
.ai-suggest__panel.is-include { background: #e6f6f1; border-color: #b7e6d6; }
.ai-suggest__panel.is-exclude { background: #fbe9e1; border-color: #f3c4a9; }
.ai-suggest__panel.is-maybe { background: #fdf2dc; border-color: #f4dca0; }

/* Screening */
.screen-progress { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.screen-progress .progress { flex: 1; }
.screen-grid { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
.screen-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.screen-card__title { margin: 0 0 8px; font-size: 21px; line-height: 1.3; }
.screen-card__meta { margin: 0 0 18px; }
.screen-card__abstract { font-size: 15px; line-height: 1.65; max-height: 50vh; overflow-y: auto; }
.screen-actions { margin-top: 22px; border-top: 1px solid var(--c-border); padding-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.screen-reason { display: flex; flex-direction: column; }
.decision-buttons { display: flex; gap: 10px; }
.decision-buttons .btn { flex: 1; justify-content: center; }
.btn--include { background: var(--c-ok); color: #fff; }
.btn--include:hover { background: #007a59; }
.btn--maybe { background: var(--c-warn); color: #fff; }
.btn--maybe:hover { background: #c98a00; }
.btn--exclude { background: var(--c-fail); color: #fff; }
.btn--exclude:hover { background: #b34e00; }
kbd { background: rgba(255,255,255,.25); border-radius: 4px; padding: 1px 5px; font-size: 11px; margin-left: 4px; }
.screen-protocol { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); padding: 18px; font-size: 14px; }
.screen-protocol p { margin: 0 0 10px; }
.screen-legend { margin-top: 14px; font-size: 12px; }
.decision-rows { list-style: none; margin: 12px 0; padding: 0; }
.decision-rows li { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 14px; flex-wrap: wrap; }
.tag--include { background: #e6f6f1; color: #06624a; }
.tag--exclude { background: #fbe9e1; color: var(--c-fail); }
.tag--maybe { background: #fdf2dc; color: #8a6100; }
.alert--warn { background: #fdf2dc; border: 1px solid #f4dca0; color: #8a6100; }
.coord-banner { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
@media (max-width: 760px) { .screen-grid { grid-template-columns: 1fr; } }

/* Import / references */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .input { max-width: 280px; }
.pager { display: flex; gap: 14px; align-items: center; justify-content: center; margin-top: 18px; }

/* Duplicate resolution */
.dup-pair { display: grid; grid-template-columns: 1fr 1fr auto; gap: 18px; align-items: center; }
.dup-side { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.dup-side strong { font-size: 15px; }
.dup-meta { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
@media (max-width: 700px) { .dup-pair { grid-template-columns: 1fr; } .dup-meta { align-items: flex-start; } }

/* Notification bell */
.bell { position: relative; }
.bell__btn { position: relative; display: inline-flex; align-items: center; color: var(--c-muted); padding: 6px; }
.bell__btn:hover { color: var(--c-text); }
.bell__badge {
    position: absolute; top: -2px; right: -4px; min-width: 16px; height: 16px;
    padding: 0 4px; border-radius: 999px; background: var(--c-fail); color: #fff;
    font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.bell__dropdown {
    position: absolute; right: 0; top: 40px; width: 320px; max-width: 90vw;
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
    box-shadow: var(--shadow); z-index: 50; overflow: hidden;
}
.bell__head { padding: 10px 14px; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--c-border); }
.bell__list { max-height: 320px; overflow-y: auto; }
.bell__item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--c-border); color: inherit; font-size: 13px; }
.bell__item:hover { background: var(--c-bg); text-decoration: none; }
.bell__item.is-unread { background: #eaf4fb; }
.bell__item strong { display: block; }
.bell__item span { color: var(--c-muted); }
.bell__empty { padding: 18px; text-align: center; color: var(--c-muted); }
.bell__all { display: block; padding: 10px 14px; text-align: center; font-size: 13px; font-weight: 600; }

/* Notifications page */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--c-border); }
.tab { padding: 8px 14px; color: var(--c-muted); font-weight: 500; border-bottom: 2px solid transparent; }
.tab:hover { text-decoration: none; color: var(--c-text); }
.tab.is-active { color: var(--c-primary); border-bottom-color: var(--c-primary); }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-item { border-bottom: 1px solid var(--c-border); }
.notif-item.is-unread { background: #eaf4fb; }
.notif-item__form { margin: 0; }
.notif-item__btn { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 14px 18px; cursor: pointer; font: inherit; }
.notif-item__msg { display: block; color: var(--c-muted); font-size: 14px; margin: 2px 0; }
.notif-item__time { font-size: 12px; }

/* Comments */
.comment-list { list-style: none; margin: 0 0 18px; padding: 0; }
.comment { padding: 12px 0; border-bottom: 1px solid var(--c-border); }
.comment__head { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 4px; }
.comment__del { margin-left: auto; }
.link-del { background: none; border: 0; color: var(--c-muted); cursor: pointer; font-size: 18px; line-height: 1; }
.link-del:hover { color: var(--c-fail); }
.comment__body { font-size: 14px; }
.invite-link { display: inline-block; word-break: break-all; background: var(--c-bg); padding: 4px 8px; border-radius: 6px; font-size: 13px; }

/* Admin layout */
.admin { display: flex; max-width: 1080px; margin: 0 auto; gap: 28px; padding: 28px 24px 64px; }
.admin__sidebar { flex: 0 0 220px; }
.admin__title { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--c-muted); margin: 4px 0 12px; }
.admin__nav { display: flex; flex-direction: column; gap: 2px; }
.admin__link {
    padding: 9px 12px; border-radius: 8px; color: var(--c-muted);
    font-weight: 500; font-size: 15px;
}
.admin__link:hover { background: var(--c-surface); color: var(--c-text); text-decoration: none; }
.admin__link.is-active { background: var(--c-surface); color: var(--c-primary); box-shadow: var(--shadow); }
.admin__content { flex: 1; min-width: 0; }

.section__title { margin: 0 0 16px; font-size: 22px; }
.section__subtitle { margin: 0 0 8px; font-size: 17px; }
.section__intro { color: var(--c-muted); margin: 0 0 18px; }
.section-card {
    background: var(--c-surface); border: 1px solid var(--c-border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 24px; margin-bottom: 20px;
}
.section-card--inline { display: flex; align-items: center; gap: 16px; }

.form-row { display: flex; }
.form-row--split { gap: 16px; }
.form-row--split > .field { flex: 1; }
.select {
    width: 100%; padding: 10px 12px; font-size: 15px; font-family: inherit;
    border: 1px solid var(--c-border); border-radius: 8px; background: var(--c-surface); color: var(--c-text);
}
.select:focus { outline: 2px solid var(--c-primary); outline-offset: 1px; }
.input--color { padding: 4px; height: 42px; }
.field-help { font-size: 12px; color: var(--c-muted); margin-top: 4px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; }

.toggles { border: 1px solid var(--c-border); border-radius: 8px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.toggles legend { font-weight: 600; font-size: 14px; padding: 0 6px; }

.actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.actions--start { justify-content: flex-start; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0; }
.kv dt { color: var(--c-muted); font-weight: 600; }
.kv dd { margin: 0; }
.link-ext { font-size: 14px; }

.field--narrow { max-width: 130px; }
textarea.input { resize: vertical; font-family: inherit; line-height: 1.5; }
.input--color { padding: 4px; height: 42px; width: 80px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.api-block { padding: 14px 0; border-bottom: 1px solid var(--c-border); }
.api-block:last-of-type { border-bottom: 0; }
.api-block .section__subtitle { margin: 0 0 10px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.muted { color: var(--c-muted); font-size: 13px; }

/* Buttons: danger */
.btn--danger { background: #fbe9e1; border-color: #f3c4a9; color: var(--c-fail); }
.btn--danger:hover { background: #f7d8c8; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--c-border); vertical-align: top; }
.table th { color: var(--c-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.row-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-actions { display: flex; gap: 8px; align-items: center; }
.select--sm { width: auto; padding: 6px 10px; font-size: 13px; }

@media (max-width: 640px) {
    .topbar { gap: 12px; padding: 0 14px; }
    .topbar__nav { gap: 12px; }
    .topbar__name { display: none; }
    .admin { flex-direction: column; gap: 16px; }
    .admin__sidebar { flex: none; }
    .admin__nav { flex-direction: row; flex-wrap: wrap; }
    .form-row--split { flex-direction: column; gap: 16px; }
}
