:root {
  /* Phase 1.2: JADA brand palette, per docs/jada-brand-audit.md §12
     (canonical orange #E85E08, dark text #1F1F1F, white backgrounds --
     NOT dark navy, which the audit found was never actually JADA's own
     brand). The app shell's dark header bar is an application-chrome
     choice, not a reproduction of deck content -- it uses --text-dark as
     its background rather than an arbitrary navy, for brand consistency. */
  color-scheme: light;
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --text: #1a1d23;
  --muted: #666b75;
  --border: #e1e4e9;
  --accent: #1f1f1f;
  --accent-contrast: #ffffff;
  --brand-orange: #e85e08;
  --draft-label: #9a6400;
  --warn: #9a6400;
  --warn-bg: #fff5de;
  --error: #9a1b1b;
  --error-bg: #fdecec;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body { overflow-x: hidden; max-width: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: break-word;
}

code { overflow-wrap: anywhere; }

img { max-width: 100%; }
[hidden] { display: none !important; }

.topbar {
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
}

.brand { color: var(--accent-contrast); text-decoration: none; font-weight: 600; font-size: 1.05rem; display: inline-flex; align-items: center; gap: 8px; }
.brand-logo { height: 16px; width: auto; max-width: none; }
.phase-tag { font-weight: 400; opacity: 0.75; font-size: 0.8rem; margin-left: 6px; }
.topbar-badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.env-tag { font-size: 0.75rem; opacity: 0.85; background: rgba(255,255,255,0.12); padding: 4px 8px; border-radius: 4px; }

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

h1 { font-size: 1.4rem; margin: 0 0 8px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
h3 { font-size: 0.95rem; margin: 14px 0 6px; }
.muted { color: var(--muted); }
code { background: #eef0f3; padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }

.back-link { display: inline-block; margin-bottom: 12px; color: var(--accent); text-decoration: none; }

.fixture-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.fixture-form select {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 1rem;
  min-width: 220px;
  max-width: 100%;
}

a.primary, button.primary {
  background: var(--brand-orange);
  color: var(--accent-contrast);
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
a.primary:hover, button.primary:hover { opacity: 0.9; }

.draft-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--draft-label);
  background: var(--warn-bg);
  border: 1px solid #f0dca8;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
}

.content-origin-legend { margin: 10px 0; line-height: 1.9; }

.synthetic-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #1e40af;
  background: #dbeafe;
  border: 1px solid #bfdbfe;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
}

.runs-table, .sources-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.runs-table th, .runs-table td,
.sources-table th, .sources-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.sources-table { display: block; overflow-x: auto; white-space: nowrap; }
.sources-table .excerpt { white-space: normal; min-width: 260px; max-width: 420px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  background: #e5e7eb;
  color: #374151;
}
.badge.running { background: #dbeafe; color: #1e40af; }
.badge.pending { background: #e5e7eb; color: #374151; }
.badge.completed { background: #dcfce7; color: #166534; }
.badge.failed { background: #fee2e2; color: #991b1b; }
.badge.needs_confirmation { background: #fef3c7; color: #92400e; }
.badge.cancelled { background: #e5e7eb; color: #4b5563; }

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #166534;
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
}

.confirmation-card { border: 1px solid #f0dca8; }
.candidate-row { display: block; padding: 8px 0; border-bottom: 1px solid var(--border); }
.candidate-row input { margin-right: 8px; }
.confirmation-actions { margin-top: 12px; display: flex; gap: 10px; }

a.secondary, button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
a.secondary:hover, button.secondary:hover { background: #f3f4f6; }

.inline-form { display: inline-block; margin-left: 10px; }

.live-form, .fixture-form { display: flex; flex-direction: column; gap: 6px; max-width: 480px; }
.live-form label, .fixture-form label { font-weight: 600; font-size: 0.85rem; margin-top: 6px; }
.live-form input, .live-form select, .live-form textarea,
.fixture-form select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}
.live-form details { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
.live-form button { margin-top: 14px; align-self: flex-start; }

.run-header-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.event-feed {
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: #fafbfc;
  font-size: 0.85rem;
}
.event { padding: 3px 0; border-bottom: 1px dashed #eceef1; }
.event:last-child { border-bottom: none; }
.event .stage { color: var(--accent); font-weight: 600; margin-right: 6px; }
.event.warning { color: var(--warn); }
.event.error { color: var(--error); }

.warning { background: var(--warn-bg); color: var(--warn); padding: 10px 12px; border-radius: 6px; font-size: 0.9rem; }
.error { background: var(--error-bg); color: var(--error); padding: 10px 12px; border-radius: 6px; font-size: 0.9rem; }

.slide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.slide-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fafbfc;
}
.slide-card img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.slide-meta { padding: 8px 10px; font-size: 0.85rem; display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.layout-tag { font-size: 0.7rem; color: var(--muted); white-space: nowrap; }

.slide-citations { padding: 0 10px 10px; font-size: 0.78rem; }
.citation-row { display: flex; gap: 6px; color: var(--muted); overflow-wrap: anywhere; }
.citation-num { flex-shrink: 0; }

.topbar, .brand, .run-header-row, .fixture-form, .runs-table td, .runs-table th {
  min-width: 0;
}

@media (max-width: 640px) {
  .container { padding: 14px 10px 50px; }
  .card { padding: 14px; }
  .fixture-form { flex-direction: column; align-items: stretch; }
  .fixture-form select { min-width: 0; width: 100%; }
  .run-header-row { flex-direction: column; align-items: flex-start; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 6px; }
  .env-tag { white-space: normal; }
  .runs-table { display: block; overflow-x: auto; white-space: nowrap; }
}
