:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5f6b7a;
  --border: #dde1e7;
  --brand: #1f3a5f;
  --accent: #2563eb;
  --red: #b42318;   --red-bg: #fde8e7;
  --orange: #b54708; --orange-bg: #fef0dc;
  --blue: #1d4ed8;  --blue-bg: #e3ecfd;
  --green: #067647; --green-bg: #dcf5e7;
  --grey: #475467;  --grey-bg: #eef0f3;
  --yellow-bg: #fff7d6;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--brand); color: #fff; padding: .75rem 1.5rem;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; letter-spacing: .02em; }
.brand span { font-weight: 400; opacity: .8; }
.topbar-user { display: flex; gap: 1rem; align-items: center; font-size: .9rem; }
.topbar-user form { margin: 0; }
.link-button { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

.page { max-width: 1280px; margin: 0 auto; padding: 1.25rem 1.5rem 3rem; }
.page-head { margin: 1rem 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.break { word-break: break-all; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1.1rem 1.25rem; margin-bottom: 1rem; }

.sample-banner { background: var(--yellow-bg); border: 1px solid #f0d77a; border-radius: 6px; padding: .5rem .9rem; font-size: .9rem; margin-bottom: .75rem; }
.messages { margin-bottom: 1rem; }
.message { padding: .6rem .9rem; border-radius: 6px; margin-bottom: .5rem; }
.message-success { background: var(--green-bg); color: var(--green); }
.message-error { background: var(--red-bg); color: var(--red); }
.field-error { color: var(--red); font-size: .88rem; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; color: var(--muted); font-size: .88rem; }
.stat span { display: block; font-size: 1.6rem; font-weight: 700; color: var(--text); }
.stat-urgent span { color: var(--red); }

.filters { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: flex-end; margin-bottom: 1rem; }
.filters label { display: flex; flex-direction: column; font-size: .82rem; color: var(--muted); gap: .2rem; }
.reset { font-size: .88rem; padding-bottom: .45rem; }

select, input[type=text], input[type=password], textarea {
  font: inherit; color: var(--text); background: #fff;
  border: 1px solid var(--border); border-radius: 6px; padding: .45rem .6rem; min-width: 11rem;
}
textarea { width: 100%; resize: vertical; }
select:focus, input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.button { background: var(--brand); color: #fff; border: 0; border-radius: 6px; padding: .55rem 1rem; font: inherit; font-weight: 600; cursor: pointer; }
.button:hover { background: #2a4d7c; }

table.incidents { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.incidents th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfc; padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
.incidents td { padding: .7rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.incidents tr:last-child td { border-bottom: 0; }
.incidents tbody tr:hover { background: #f9fafb; }
.incidents .headline a { font-weight: 600; color: var(--text); text-decoration: none; }
.incidents .headline a:hover { color: var(--accent); text-decoration: underline; }
.empty { text-align: center; color: var(--muted); }

.badge { display: inline-block; font-size: .76rem; font-weight: 600; padding: .12rem .5rem; border-radius: 999px; background: var(--grey-bg); color: var(--grey); white-space: nowrap; }
.badge.sample { background: var(--yellow-bg); color: #7a5b00; margin-right: .35rem; }
.badge.live { background: var(--brand); color: #fff; margin-right: .35rem; }
.source-active { background: var(--green-bg); color: var(--green); }
.source-updated { background: var(--blue-bg); color: var(--blue); }
.source-cancelled { background: var(--grey-bg); color: var(--grey); text-decoration: line-through; }
.source-expired { background: var(--grey-bg); color: var(--grey); }
.source-cleared { background: var(--grey-bg); color: var(--grey); }
.sample-choice { display: flex; gap: .5rem; align-items: flex-start; background: var(--yellow-bg); border: 1px solid #f0d77a; border-radius: 6px; padding: .6rem .75rem; font-weight: 600; }
.sample-choice input { margin-top: .2rem; }
.facts-list { list-style: none; margin: 0 0 .75rem; padding: 0; }
.fact { border-top: 1px solid var(--border); padding: .6rem 0; }
.fact-statement { margin: .3rem 0 .1rem; }
.fact-retracted .fact-statement { text-decoration: line-through; color: var(--muted); }
.fact-badge-verified { background: var(--green-bg); color: var(--green); }
.fact-badge-unconfirmed { background: var(--orange-bg); color: var(--orange); }
.fact-badge-retracted { background: var(--grey-bg); color: var(--grey); }
.inline-form { display: flex; gap: .5rem; margin-top: .4rem; }
.inline-form input { flex: 1; }
.status-choice { border: 1px solid var(--border); border-radius: 6px; padding: .5rem .75rem; }
.status-choice legend { font-size: .88rem; font-weight: 600; padding: 0 .25rem; }
.status-choice label { font-weight: 400; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.blockers { margin: .25rem 0 0; padding-left: 1.1rem; }
.draft-list { list-style: none; margin: .75rem 0 0; padding: 0; }
.draft-list li { border-top: 1px solid var(--border); padding: .5rem 0; }
.draft-form textarea, .draft-form input[type=text] { width: 100%; }
.mono, .draft-form textarea.mono { font-family: ui-monospace, Menlo, monospace; font-size: .82rem; }
.pre-line { white-space: pre-line; }
.message-info { background: var(--blue-bg); color: var(--blue); }
.graphic-layout { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 1.6fr); gap: 1rem; align-items: start; }
.graphic-layout textarea, .graphic-layout select { width: 100%; }
.graphic-preview { width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--border); display: block; }
.graphic-list { list-style: none; padding: 0; margin: .5rem 0; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.graphic-list img, .graphic-thumb { width: 100%; height: auto; border-radius: 4px; border: 1px solid var(--border); display: block; }
.photo-list { padding-left: 1.1rem; margin: .5rem 0 0; }
@media (max-width: 900px) { .graphic-layout { grid-template-columns: 1fr; } }
.checkbox label { font-weight: inherit; font-size: inherit; cursor: pointer; }
.admin-only { border-style: dashed; }
.title-row { display: flex; align-items: center; gap: 1rem; }
.title-row .button { text-decoration: none; }
.button-danger { background: var(--red); }
.button-danger:hover { background: #8f1c13; }
.required { color: var(--red); }
details > summary { cursor: pointer; list-style-position: inside; }
.inline-h2 { display: inline; margin: 0; }
details[open] > summary { margin-bottom: .75rem; }
.add-form { max-width: 46rem; }
.add-form .field { display: flex; flex-direction: column; gap: .25rem; }
.add-form input[type=text], .add-form input[type=url], .add-form select, .add-form textarea, .add-form input[type=datetime-local] { width: 100%; }
.duplicate-warning { background: var(--yellow-bg); border-color: #f0d77a; max-width: 46rem; }
.duplicate-warning ul { margin: .25rem 0 .5rem; padding-left: 1.2rem; }
.confirm-box { background: #fff; border: 1px solid #f0d77a; border-radius: 6px; padding: .5rem .75rem; font-weight: 600; }
.lifecycle-line { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .25rem; }
.page-head-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; }
.source-check { display: flex; gap: 1rem; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem; }
.source-check form { margin: 0; }
.source-check { max-width: 40rem; border-left-width: 5px; }
.health-dot { flex: none; width: .8rem; height: .8rem; border-radius: 50%; align-self: flex-start; margin-top: .25rem; }
.health-green { border-left-color: var(--green); }
.health-green .health-dot { background: var(--green); }
.health-yellow { border-left-color: #d4a106; background: var(--yellow-bg); }
.health-yellow .health-dot { background: #d4a106; }
.health-red { border-left-color: var(--red); background: var(--red-bg); }
.health-red .health-dot { background: var(--red); }
.button-secondary { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.button-secondary:hover { background: var(--blue-bg); }
.raw { background: #f6f8fa; border: 1px solid var(--border); border-radius: 6px; padding: .75rem; font-size: .78rem; max-height: 22rem; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.priority-1 { background: var(--red-bg); color: var(--red); }
.priority-2 { background: var(--orange-bg); color: var(--orange); }
.priority-3 { background: var(--blue-bg); color: var(--blue); }
.verify-verified { background: var(--green-bg); color: var(--green); }
.verify-partially_verified { background: var(--blue-bg); color: var(--blue); }
.verify-disputed { background: var(--red-bg); color: var(--red); }
.status-new { background: var(--orange-bg); color: var(--orange); }
.status-in_review { background: var(--blue-bg); color: var(--blue); }
.status-ready_for_drafting { background: var(--green-bg); color: var(--green); }

.back { display: inline-block; margin: .5rem 0 1rem; text-decoration: none; }
.detail-head { margin-bottom: 1rem; }
.badges { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .5rem; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 1rem; align-items: start; }
.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .45rem .9rem; font-size: .92rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.stack { display: flex; flex-direction: column; gap: .45rem; margin-bottom: 1rem; }
.stack label { font-size: .88rem; font-weight: 600; }
.stack .checkbox { font-weight: 400; display: flex; gap: .4rem; align-items: center; }
.stack .button { align-self: flex-start; margin-top: .25rem; }

.note { border-top: 1px solid var(--border); padding: .75rem 0 .25rem; }
.note p { margin: .3rem 0 0; }
.note-meta { display: flex; gap: .6rem; align-items: center; font-size: .88rem; }
.note-uncertain { border-left: 3px solid var(--red); padding-left: .75rem; }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li { padding: .45rem 0; border-top: 1px solid var(--border); font-size: .92rem; }
.activity li:first-child { border-top: 0; }
.activity .muted { display: inline-block; min-width: 8.5rem; }

.login-card { max-width: 380px; margin: 3rem auto; }
.login-card form { display: flex; flex-direction: column; gap: .45rem; }
.login-card label { font-size: .88rem; font-weight: 600; margin-top: .4rem; }
.login-card .button { margin-top: .9rem; }

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .page { padding: 1rem; }
  .incidents thead { display: none; }
  table.incidents, .incidents tbody, .incidents tr, .incidents td { display: block; width: 100%; }
  .incidents tr { border-bottom: 1px solid var(--border); padding: .5rem 0; }
  .incidents td { border: 0; padding: .2rem .9rem; }
  .incidents td::before { content: attr(data-label); display: inline-block; min-width: 6.5rem; color: var(--muted); font-size: .8rem; }
  .incidents td.headline::before { display: none; }
  .filters label, select { width: 100%; }
}
.note-actions { margin-top: .3rem; }
.make-fact { font-weight: 600; }
.review-link { text-decoration: none; font-weight: 400; }
.changes-count { color: var(--orange); font-weight: 700; }
.queue-list { list-style: none; margin: 0; padding: 0; }
.queue-item { border-top: 1px solid var(--border); padding: .6rem 0; }
.queue-head { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.queue-sample { border-style: dashed; }
.review-state-requested { background: var(--blue-bg); color: var(--blue); }
.review-state-changes_requested { background: var(--orange-bg); color: var(--orange); }
.review-state-approved { background: var(--green-bg); color: var(--green); }
.changes-banner { background: var(--orange-bg); color: #7a3a04; border: 1px solid #f3c38b; }
.export-blocked { background: var(--red-bg); color: var(--red); }
.export-ok { background: var(--green-bg); color: var(--green); }
.draft-choice { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.draft-choice p { flex-basis: 100%; margin: 0; }
.covered-graphics { list-style: none; padding: 0; margin: .4rem 0; }
.covered-graphics li { margin-bottom: .4rem; }
.covered-graphics .graphic-thumb { width: 160px; display: inline-block; vertical-align: middle; }
.source-panel { display: flex; flex-direction: column; gap: .5rem; max-width: 40rem; }
.source-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.health-manual { border-left-color: var(--grey); }
.health-manual .health-dot { background: var(--grey); }
.when-happened { font-weight: 600; }
.schedule-state { border-left: 5px solid var(--grey); background: var(--surface); border-radius: 8px; padding: .4rem .75rem; }
.schedule-on { border-left-color: var(--green); }
.check-ok { color: var(--green); font-weight: 700; }
.check-failed { color: var(--red); font-weight: 700; }
.bulk-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .75rem 0; }
.bulk-bar input[type=text] { flex: 1 1 18rem; }
.bulk-bar .muted { flex-basis: 100%; }
th.pick, td.pick { width: 2rem; text-align: center; }
.bulk-list { list-style: none; margin: 0; padding: 0; }
.bulk-list li { padding: .35rem 0; border-top: 1px solid var(--border); }
.possible-duplicate { background: var(--orange-bg); color: var(--orange); text-decoration: none; }
.duplicate-card { border-left: 5px solid var(--orange); }
.inline-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.attribution-confirmed { background: var(--green-bg); color: var(--green); }
.attribution-needs { background: var(--orange-bg); color: var(--orange); }
.source-attribution-confirmed { border-left: 5px solid var(--green); }
.source-attribution-needs_verification { border-left: 5px solid var(--orange); }
.attributed-preview blockquote { margin: .4rem 0; padding: .4rem .7rem; border-left: 3px solid var(--border); background: var(--surface); }
