:root {
  --navy: #1b2a4a;
  --ink: #1f2933;
  --muted: #6b7280;
  --bg: #f6f7f9;
  --card: #ffffff;
  --line: #e5e7eb;
  --good: #18923f;
  --bad: #b71f36;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* the detail page fills the viewport and never scrolls the page (only the preview scrolls inside) */
.fixed-viewport {
  height: 100vh;
  overflow: hidden;
}

.fixed-viewport .site-footer {
  display: none;
}

.site-header {
  background: var(--navy);
  color: #fff;
  padding: 9px 22px;
  flex: none;
}

.brand {
  font-weight: 600;
  letter-spacing: 0.2px;
}

.brand-lab {
  opacity: 0.7;
  font-weight: 400;
}

/* default narrow column (sign-in / forbidden); the review pages use .content-full */
.content {
  flex: 1;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 40px 24px;
}

.content-full {
  max-width: 100%;
  padding: 14px 22px;
}

.detail-main {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
}

.card h1 {
  margin: 0 0 12px;
  font-size: 20px;
  color: var(--navy);
}

.card p {
  margin: 0 0 8px;
  color: var(--muted);
  line-height: 1.5;
}

.card a {
  color: var(--navy);
}

code {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 12px;
}

.muted {
  color: var(--muted);
}

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 14px;
  flex: none;
}

/* ── the status chip (green / yellow / red / wait) — a fixed, centered pill ────────────────── */
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 104px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.chip-ok { color: #166534; background: #dcfce7; border-color: #bbf7d0; }
.chip-edit { color: #92400e; background: #fef3c7; border-color: #fde68a; }
.chip-reject { color: #991b1b; background: #fee2e2; border-color: #fecaca; }
.chip-wait { color: var(--muted); background: var(--bg); border-color: var(--line); }

/* ── the color-coded surface badge (sits right before the subject) ─────────────────────────── */
.badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  padding: 1px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-crit { background: #fde2e2; color: var(--bad); }
.badge-alert { background: #e5ebf5; color: var(--navy); }
.badge-nudge { background: #fef0d8; color: #92400e; }
.badge-daily { background: #eceff3; color: var(--muted); }

/* ── the morning-pipeline status banner (front page, above the queue head) ──────────────────── */
.pipeline-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13.5px;
}
.pipeline-label { font-weight: 600; }
.pipeline-detail { color: var(--muted); }
.pipeline-status-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
}
.pipeline-status-dot.is-live { animation: pipeline-pulse 1.4s ease-in-out infinite; }
@keyframes pipeline-pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
/* tones reuse the chip palette: ok=green, wait=neutral, reject=red */
.pipeline-ok { color: #166534; background: #dcfce7; border-color: #bbf7d0; }
.pipeline-wait { color: var(--muted); background: var(--bg); border-color: var(--line); }
.pipeline-reject { color: #991b1b; background: #fee2e2; border-color: #fecaca; }
.pipeline-ok .pipeline-detail, .pipeline-reject .pipeline-detail { color: inherit; opacity: 0.85; }

/* ── the daily review queue (front page) ──────────────────────────────────────────────────── */
.queue-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.queue-head h1 {
  margin: 0;
  font-size: 20px;
  color: var(--navy);
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 9px;
}

.date-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--navy);
  font-size: 17px;
  text-decoration: none;
}

.date-arrow:hover { border-color: #c3ccd9; }

.date-form { margin: 0; }

.date-form input[type="date"] {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px;
  font: inherit;
  color: var(--ink);
  background: var(--card);
}

.date-label {
  color: var(--muted);
  font-size: 12.5px;
}

.tenant-columns {
  column-count: 2;
  column-gap: 22px;
}

@media (max-width: 900px) {
  .tenant-columns { column-count: 1; }
}

.tenant-group {
  break-inside: avoid;
  margin-bottom: 16px;
}

.tenant-name {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--navy);
  border-bottom: 1px solid var(--line);
  padding-bottom: 5px;
}

.review-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.review-link {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 11px;
  text-decoration: none;
  color: inherit;
}

.review-link:hover {
  border-color: #c3ccd9;
  box-shadow: 0 1px 3px rgba(27, 42, 74, 0.1);
}

.review-entity {
  flex: none;
  width: 92px;
  font-weight: 700;
  color: var(--navy);
}

.review-subject {
  flex: 1;
  min-width: 0;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── the draft detail (full viewport, no page scroll) ─────────────────────────────────────── */
.detail {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-bar {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.back-link {
  flex: none;
  color: var(--navy);
  text-decoration: none;
  font-weight: 600;
}

.back-link:hover { text-decoration: underline; }

.detail-h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-sub {
  flex: none;
  color: var(--muted);
  font-size: 12.5px;
}

.detail-bar .chip {
  margin-left: auto;
}

.detail-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(780px, 1.45fr) 1fr;
  gap: 14px;
}

.detail-left {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.preview-frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: #fff;
}

.detail-right {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.why-panel,
.edit-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}

.why-panel {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 36%;          /* capped — scroll if the reasoning runs long (not taller than now) */
  overflow: auto;
}

.edit-panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.quad-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 0 0 8px;
}

/* ── "why it surfaced" content — simple: a lead line + bullets ──────────────────────────────── */
.why-read {
  margin: 0 0 7px;
  line-height: 1.45;
  color: var(--ink);
}

.why-list {
  margin: 0;
  padding-left: 16px;
}

.why-list li {
  margin-bottom: 5px;
  line-height: 1.45;
  color: var(--ink);
}

.why-list strong { color: var(--navy); }
.why-list em { color: var(--muted); }

/* ── Doug's Daily slots (the left preview when it's a Daily, not an email) ─────────────────── */
.daily { padding: 12px 14px; }

.daily-slot {
  display: flex;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.daily-slot:last-child { border-bottom: none; }

.daily-slot-name {
  font-weight: 600;
  color: var(--navy);
  font-size: 12.5px;
  margin-bottom: 2px;
}

.daily-slot-text { color: var(--ink); line-height: 1.5; }

.dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--muted);
}

.dot-green { background: var(--good); }
.dot-yellow { background: #d97706; }
.dot-red { background: var(--bad); }

/* ── banners ──────────────────────────────────────────────────────────────────────────────── */
.banner {
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 10px;
  font-size: 12.5px;
  line-height: 1.5;
}

.banner-locked { background: #eef2f7; border: 1px solid var(--line); color: var(--ink); }
.banner-error { background: #fee2e2; border: 1px solid #fecaca; color: #991b1b; }

/* ── the review action form (the big middle panel) ─────────────────────────────────────────── */
.review-form {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.field-label {
  flex: none;
  display: block;
  font-weight: 600;
  color: var(--navy);
  font-size: 12.5px;
  margin: 6px 0 4px;
}

.field-label:first-child { margin-top: 0; }

.field-label .hint,
.hint {
  flex: none;
  font-weight: 400;
  color: var(--muted);
  font-size: 11px;
}

.editor {
  flex: 1 1 auto;
  min-height: 90px;
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  resize: none;
}

.comment-input {
  flex: none;
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  resize: none;
  margin-bottom: 10px;
}

.editor:focus,
.comment-input:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(27, 42, 74, 0.1);
}

.actions {
  flex: none;
  display: flex;
  gap: 10px;
}

.btn {
  font-size: 14.5px;
  font-weight: 600;
  padding: 11px 30px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-send { background: var(--navy); color: #fff; }
.btn-reject { background: #fff; color: #991b1b; border-color: #fecaca; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── comments ─────────────────────────────────────────────────────────────────────────────── */
.comments { margin-top: 10px; }

.comment {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  margin-bottom: 6px;
}

.comment-head { font-size: 12px; color: var(--navy); margin-bottom: 2px; }
.comment-ts { color: var(--muted); font-weight: 400; margin-left: 6px; }
.comment-text { color: var(--ink); line-height: 1.45; }

/* ── recent alerts — a full-width row of little cards, below the preview ───────────────────── */
.recent-row {
  flex: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  max-height: 150px;
  overflow: auto;
}

.recent-cards {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.recent-card {
  flex: 1 1 0;
  min-width: 150px;
  max-width: 33%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
}

.recent-card-date {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 2px;
}

.recent-card-desc {
  color: var(--ink);
  font-weight: 600;
  text-transform: capitalize;
}
