* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1f2328;
  background: #f6f7f9;
}
a { color: #1a56db; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  background: #0f172a; color: #fff; padding: 10px 20px;
  position: sticky; top: 0; z-index: 10;
}
.topbar .brand a {
  color: #fff; font-weight: 700; font-size: 16px;
  display: inline-flex; align-items: center; gap: 8px;
}
.topbar .brand a:hover { text-decoration: none; }
.brand-img { width: 24px; height: 24px; border-radius: 50%; display: block; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  color: #cbd5e1; padding: 6px 12px; border-radius: 6px; font-weight: 500;
}
.topbar nav a:hover { background: #1e293b; color: #fff; text-decoration: none; }
.topbar nav a.active { background: #2563eb; color: #fff; }

.viewer { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; color: #cbd5e1; }
.viewer-name { font-weight: 600; color: #fff; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-role { background: #f59e0b; color: #1f2937; padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.viewer-logout { color: #cbd5e1; font-size: 14px; padding: 4px 8px; border-radius: 4px; }
.viewer-logout:hover { background: #1e293b; color: #fff; text-decoration: none; }
.viewer-admin-toggle { margin: 0; padding: 0; }
.viewer-admin-toggle button {
  background: transparent; color: #cbd5e1; border: 1px solid #334155;
  padding: 4px 10px; border-radius: 4px; font-size: 11px; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.viewer-admin-toggle button:hover { background: #1e293b; color: #fff; border-color: #475569; }
.viewer-admin-toggle button.is-on {
  background: #f59e0b; color: #1f2937; border-color: #f59e0b;
}
.viewer-admin-toggle button.is-on:hover { background: #fbbf24; border-color: #fbbf24; }

main { max-width: 1200px; margin: 0 auto; padding: 24px 20px 60px; }
h2 { margin: 24px 0 12px; }
h3 { margin: 20px 0 8px; }
.muted { color: #6b7280; font-size: 12px; }
.empty { color: #6b7280; font-style: italic; }
.right { margin-left: auto; }

.user-banner { background: #eff6ff; border-left: 3px solid #2563eb; padding: 6px 12px; margin: 0 0 16px; font-size: 13px; color: #4b5563; }
.card-sub { font-size: 11px; color: #6b7280; margin-top: 4px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 16px; display: block; color: #1f2328; transition: box-shadow .15s;
}
.card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); text-decoration: none; }
.card-num { font-size: 28px; font-weight: 700; color: #2563eb; }
.card-label { font-size: 13px; color: #6b7280; margin-top: 4px; }

.status-filter {
  display: flex; align-items: center; gap: 10px; margin: 8px 0 10px;
  flex-wrap: wrap;
  padding: 8px 12px; background: #fff; border: 1px solid #e5e7eb;
  border-radius: 10px;
}
.status-filter-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: #94a3b8; letter-spacing: .06em;
  min-width: 64px;
}
.status-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600; line-height: 1.2;
  color: #334155; background: #f1f5f9;
  border: 1px solid #e2e8f0;
  text-decoration: none;
  transition: background .12s, color .12s, border-color .12s, box-shadow .12s;
}
.status-chip:hover {
  background: #e2e8f0; color: #0f172a; text-decoration: none;
  border-color: #cbd5e1;
}
.status-chip.is-active {
  background: #2563eb; color: #fff; border-color: #1d4ed8;
  box-shadow: 0 1px 2px rgba(37, 99, 235, .25), 0 0 0 3px rgba(37, 99, 235, .12);
}
.status-chip.is-active:hover {
  background: #1d4ed8; border-color: #1e40af; color: #fff;
}
.status-filter + .status-filter { margin-top: 0; }
.status-chip-count {
  display: inline-block; min-width: 18px; padding: 1px 7px;
  border-radius: 999px; font-size: 11px; font-weight: 700;
  background: #fff; color: #475569; border: 1px solid #e2e8f0;
  text-align: center; line-height: 1.4;
}
.status-chip:hover .status-chip-count { background: #fff; }
.status-chip.is-active .status-chip-count {
  background: rgba(255, 255, 255, .2); color: #fff; border-color: rgba(255, 255, 255, .3);
}

table.data { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #e5e7eb; vertical-align: top; }
table.data th { background: #f3f4f6; font-weight: 600; font-size: 12px; text-transform: uppercase; color: #4b5563; }
table.data tr:last-child td { border-bottom: none; }
table.data .sub { color: #6b7280; font-size: 12px; margin-top: 2px; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; background: #e5e7eb; color: #374151; }
.pill-blocked { background: #fee2e2; color: #991b1b; }
.pill-active { background: #dbeafe; color: #1e40af; }
.pill-done { background: #d1fae5; color: #065f46; }
.pill-open { background: #fef3c7; color: #92400e; }

/* Contested badge — additive to the status pill, coloured by severity. It
   reads as under-dispute even while the status pill still shows in_progress or
   done. Sits next to the status pill (small left gap). */
.pill-contested { margin-left: 6px; background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.pill-contested-high { background: #fee2e2; color: #991b1b; border-color: #f87171; }
.pill-contested-medium { background: #fef3c7; color: #92400e; border-color: #fbbf24; }
.pill-contested-low { background: #e5e7eb; color: #374151; border-color: #d1d5db; }

/* "⚠ Basis moved" (R4 basis-impact) — the action is building on a decision/
   option basis that was deferred/superseded/reversed. Amber by default (a
   heads-up, softer than contested's red), escalating for hard changes. */
.pill-impacted { margin-left: 6px; background: #fef3c7; color: #92400e; border: 1px solid #fbbf24; }
.pill-impacted-high { background: #ffedd5; color: #9a3412; border-color: #fb923c; }
.pill-impacted-low { background: #f3f4f6; color: #4b5563; border-color: #e5e7eb; }

.pri { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 700; background: #e5e7eb; color: #374151; }
.pri-p0 { background: #fecaca; color: #991b1b; }
.pri-p1 { background: #fed7aa; color: #9a3412; }
.pri-p2 { background: #fef3c7; color: #92400e; }

.ref { display: inline-block; font-size: 12px; color: #1a56db; }

.conflict { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.conflict header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; }
.conflict h3 { margin: 4px 0; font-size: 16px; }
.conflict .desc { color: #4b5563; }
.sev { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.sev-high { background: #fee2e2; color: #991b1b; }
.sev-medium { background: #fef3c7; color: #92400e; }
.sev-low { background: #e5e7eb; color: #374151; }
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.sides .side { border: 1px solid #e5e7eb; border-radius: 6px; padding: 12px; background: #f9fafb; }
.sides .side-title { font-weight: 600; margin-bottom: 6px; }
.sides .side-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; }

.back { display: inline-block; margin-bottom: 12px; font-size: 13px; }
.item-head { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.next-action { background: #eff6ff; border-left: 3px solid #2563eb; padding: 8px 12px; }
.rationale { color: #4b5563; font-size: 13px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
ul.refs { padding-left: 20px; margin: 0; }
ul.refs li { margin: 4px 0; }

.timeline { list-style: none; padding: 0; margin: 8px 0 0; border-left: 2px solid #e5e7eb; }
.timeline li { padding: 8px 0 12px 16px; position: relative; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 14px;
  width: 12px; height: 12px; border-radius: 50%; background: #2563eb; border: 2px solid #fff;
}
.t-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.t-when { color: #6b7280; font-family: ui-monospace, monospace; font-size: 12px; }
.t-kind { font-weight: 600; text-transform: uppercase; color: #1e40af; font-size: 11px; padding: 2px 6px; background: #dbeafe; border-radius: 4px; }
.t-transition { font-family: ui-monospace, monospace; font-size: 12px; color: #4b5563; }
.t-rationale { margin-top: 4px; color: #4b5563; font-size: 13px; }

.evidence {
  margin-top: 8px; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; padding: 10px;
}
.ev-meta { font-size: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.ev-text { font-size: 13px; color: #1f2328; white-space: pre-wrap; word-wrap: break-word; }
.src-link { font-weight: 500; }
.src-slack-bolt, .src-slack { background: #4a154b; color: #fff; padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 600; }
.src-github { background: #24292e; color: #fff; padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 600; }

/* ---------- Auth pages (login + logout) ---------- */
.auth-body {
  background: #f3f4f6; min-height: 100vh; margin: 0;
  display: flex; flex-direction: column;
}

.auth-topbar {
  padding: 24px 32px; background: transparent;
}
.auth-brand { display: inline-flex; align-items: center; gap: 8px; }
.auth-brand-mark { font-size: 20px; }
.auth-brand-img { width: 28px; height: 28px; border-radius: 50%; display: block; }
.auth-brand-name { font-weight: 700; font-size: 17px; color: #0f172a; letter-spacing: -0.01em; }

.auth-stage {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 24px 20px;
}

.auth-card {
  background: #fff; border-radius: 12px; padding: 36px 36px;
  width: 100%; max-width: 420px;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 8px 24px rgba(15,23,42,0.06);
  display: flex; flex-direction: column; gap: 14px;
  border: 1px solid #e5e7eb;
}
.auth-card-status { align-items: center; text-align: center; }
.auth-eyebrow {
  margin: 0 0 -4px; color: #64748b; font-size: 13px; font-weight: 500;
}
.auth-card h1 {
  margin: 0 0 8px; font-size: 28px; font-weight: 700; color: #0f172a;
  letter-spacing: -0.02em; line-height: 1.2;
}
.auth-sub { margin: -4px 0 8px; color: #64748b; font-size: 14px; }

.auth-card label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; color: #374151; font-weight: 500;
}
.auth-card input[type="text"],
.auth-card input[type="password"] {
  padding: 12px 14px; border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: #0f172a;
  transition: border-color .15s, box-shadow .15s;
  width: 100%; box-sizing: border-box;
}
.auth-card input::placeholder { color: #9ca3af; }
.auth-card input:hover { border-color: #9ca3af; }
.auth-card input:focus {
  outline: none; border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.auth-card button,
.auth-button {
  display: inline-block; text-align: center; margin-top: 8px; padding: 12px 16px;
  background: #2563eb; color: #fff; border: 0; border-radius: 8px;
  font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
  text-decoration: none; transition: background .15s, transform .05s;
  width: 100%; box-sizing: border-box;
}
.auth-card button:hover,
.auth-button:hover { background: #1d4ed8; text-decoration: none; }
.auth-card button:active,
.auth-button:active { transform: translateY(1px); }

.auth-slack {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 11px 16px; margin-top: 4px;
  background: #fff; color: #1d1c1d; border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 14px; font-weight: 600; text-decoration: none;
  transition: background .15s, border-color .15s;
  width: 100%; box-sizing: border-box;
}
.auth-slack:hover { background: #f9fafb; border-color: #9ca3af; text-decoration: none; }
.auth-slack svg { flex: 0 0 18px; }

.auth-divider {
  display: flex; align-items: center; gap: 8px; margin: 12px 0 4px;
  color: #9ca3af; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: #e5e7eb;
}

.auth-hint {
  color: #6b7280; font-size: 12px; margin: 8px 0 0; line-height: 1.5;
  text-align: center;
}
.auth-hint code {
  background: #f3f4f6; color: #374151; padding: 1px 6px; border-radius: 4px;
  font-size: 11px; font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.login-error {
  background: #fef2f2; color: #b91c1c; padding: 10px 12px; border-radius: 8px;
  font-size: 13px; border: 1px solid #fecaca;
}

.auth-check {
  width: 56px; height: 56px; border-radius: 50%; background: #dcfce7; color: #15803d;
  display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 700;
  margin: 0 auto 4px;
}

.auth-pagefoot {
  text-align: center; padding: 24px; font-size: 12px; color: #9ca3af;
}

.room-meta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; padding: 8px 0; }
ul.opt-list { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.opt { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px; }
.opt-closed { opacity: .6; }
.opt-chosen { border-color: #16a34a; background: #f0fdf4; }
.opt-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.opt-body { color: #4b5563; font-size: 13px; white-space: pre-wrap; word-wrap: break-word; }
.opt-endorse { color: #16a34a; font-size: 12px; margin-top: 6px; }
.opt-object { color: #b91c1c; font-size: 12px; margin-top: 6px; }
.opt-object .obj { padding: 2px 0; }

.ev-badge-endorse  { background: #d1fae5; color: #065f46; }
.ev-badge-object   { background: #fee2e2; color: #991b1b; }
.ev-badge-close    { background: #e5e7eb; color: #374151; }
.ev-badge-propose  { background: #fef3c7; color: #92400e; }
.ev-badge-choose   { background: #dcfce7; color: #15803d; }
.ev-badge-question { background: #dbeafe; color: #1e40af; }

@media (max-width: 480px) {
  .auth-card { padding: 28px 24px; border-radius: 10px; }
  .auth-card h1 { font-size: 24px; }
}

@media (max-width: 700px) {
  .sides { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  table.data th, table.data td { padding: 8px; font-size: 12px; }
}

/* ---------- Inbox ---------- */
.nav-badge {
  display: inline-block; min-width: 20px; padding: 0 6px; height: 18px;
  line-height: 18px; text-align: center; font-size: 11px; font-weight: 700;
  background: #ef4444; color: #fff; border-radius: 9px; margin-left: 4px;
  vertical-align: middle;
}
.inbox-header { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.inbox-header h2 { margin: 0; }
.inbox-readall { margin-left: auto; }
.inbox-readall .inbox-read { padding: 6px 14px; font-weight: 600; }
.inbox { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.inbox-row {
  background: #fff; border: 1px solid #e5e7eb; border-left: 3px solid #4f46e5;
  border-radius: 8px; padding: 14px 16px;
}
.inbox-row.is-read { border-left-color: #d1d5db; opacity: .7; }
.inbox-row header {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: #6b7280;
  margin-bottom: 6px;
}
.inbox-row .right { margin-left: auto; }
.inbox-row h3 { margin: 0 0 8px; font-size: 15px; }
.inbox-kind {
  background: #eef2ff; color: #4338ca; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
}
.inbox-body {
  font-size: 13px; color: #374151; white-space: pre-wrap; word-wrap: break-word;
  line-height: 1.5; padding: 6px 0;
}
.inbox-row footer { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.inbox-form { margin: 0; }
.inbox-open, .inbox-read {
  display: inline-block; padding: 4px 10px; border-radius: 6px; font-size: 12px;
  border: 1px solid #d1d5db; background: #fff; color: #111827; cursor: pointer;
  text-decoration: none;
}
.inbox-open:hover, .inbox-read:hover { background: #f3f4f6; }
.small { font-size: 11px; }
