/* Switchyard — rail yard color palette */
:root {
  --surface: #FAFAFA;
  --steel: #1E293B;
  --ballast: #64748B;
  --signal-green: #059669;
  --signal-green-bright: #34D399; /* brighter emerald for marks on dark surfaces */
  --signal-amber: #D97706;
  --signal-red: #DC2626;
  --rail-blue: #2563EB;
  --sleeper: #0F172A;
  --radius: 6px;
  --font-sans: Inter, system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background: var(--surface);
  color: var(--steel);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.page-main { flex: 1 0 auto; padding-bottom: 2.5rem; }

a { color: var(--steel); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1440px; margin: 0 auto; padding: 0 1.5rem; }
@media (min-width: 1024px) { .container { padding: 0 2rem; } }

.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow-x: auto;
}

/* Page header */
.page-header { padding: 1.5rem 0 1rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 600; }

/* Nav */
.nav {
  background: var(--steel);
  color: var(--surface);
  padding: 0.65rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  position: relative;
}
.nav-brand {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--surface);
  letter-spacing: -0.5px;
  white-space: nowrap;
}
.nav-brand span { color: var(--signal-amber); }
.nav-brand:hover { text-decoration: none; }
.nav-links {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  flex: 1;
}
.nav-links a {
  color: var(--surface);
  opacity: 0.75;
  font-size: 0.875rem;
  padding: 0.25rem 0;
}
.nav-links a:hover { opacity: 1; text-decoration: none; }
.nav-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-left: auto;
}

/* Account dropdown */
.nav-account { position: relative; }
.nav-account > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--surface);
}
.nav-account > summary:hover { background: rgba(255,255,255,0.08); }
.nav-account > summary::-webkit-details-marker { display: none; }
.nav-account-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--rail-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
}
.nav-account-name { font-weight: 500; }
.nav-account-caret { font-size: 0.65rem; opacity: 0.6; }
.nav-account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  min-width: 200px;
  z-index: 200;
  overflow: hidden;
}
.nav-account-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f1f1;
}
.nav-account-header-name { font-weight: 600; color: var(--steel); font-size: 0.9rem; }
.nav-account-header-email { font-size: 0.78rem; color: var(--ballast); margin-top: 0.1rem; }
.nav-account-header-role {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ballast);
  margin-top: 0.3rem;
}
.nav-account-item {
  display: block;
  padding: 0.55rem 1rem;
  color: var(--steel);
  font-size: 0.85rem;
}
.nav-account-item:hover { background: #f8f8f8; text-decoration: none; }
.nav-account-divider { border-top: 1px solid #f1f1f1; }
.nav-account-logout { color: var(--signal-red); }

/* Mobile nav toggle */
.nav-toggle { display: none; }
.nav-burger { display: none; cursor: pointer; }
@media (max-width: 768px) {
  .nav-burger {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-left: auto;
  }
  .nav-burger span {
    width: 20px; height: 2px;
    background: var(--surface);
    border-radius: 1px;
  }
  .nav-links, .nav-right {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 0;
  }
  .nav-toggle:checked ~ .nav-links,
  .nav-toggle:checked ~ .nav-right { display: flex; }
  .nav-inner { flex-wrap: wrap; }
}

/* Footer */
.site-footer {
  flex-shrink: 0;
  border-top: 1px solid #e5e5e5;
  background: var(--surface);
  padding: 1rem 0 1.25rem;
  margin-top: 2rem;
}
.site-footer-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.72rem;
  color: var(--ballast);
  font-family: var(--font-mono);
  letter-spacing: 0.2px;
}
.site-footer-brand { color: var(--steel); font-weight: 600; }
.site-footer-brand span { color: var(--signal-amber); margin: 0 0.05em; }
.site-footer-spacer { flex: 1; }
.site-footer-link { color: var(--ballast); text-decoration: none; }
.site-footer-link:hover { color: var(--steel); text-decoration: underline; }

/* Auth pages — content sits in the upper third of the viewport so the
   form is reachable without scrolling on shorter laptop screens, and
   the user's eye lands on the brand + heading immediately rather than
   floating in dead space. */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 4rem 2rem 2rem;
  background: linear-gradient(135deg, #1E293B 0%, #334155 100%);
}
.auth-hero { text-align: center; margin-bottom: 2rem; }
.auth-logo {
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 700;
  color: white;
  letter-spacing: -1px;
}
.auth-logo span { color: var(--signal-amber); }

/* Rail-blue brand mark between "switch" and "yard". Rendered via CSS mask
   so the icon's color is always rail-blue regardless of the source SVG's
   internal fills. Sized via em so it scales with the surrounding font;
   slightly TALLER than the text and vertically centered to look like a
   deliberate piece of typography, not a stray icon. The default mark can
   be swapped per-page by setting --brand-mark-url on the span (used by
   /static/brand-preview.html). */
.brand-mark {
  display: inline-block;
  width: 1.3em;
  height: 1.3em;
  vertical-align: middle;
  margin: 0 0.08em;
  /* Default mark color: dark "go" green — readable on light backgrounds
     (footer, PRD share). Overridden below for dark contexts. */
  background-color: var(--signal-green);
  mask-image: var(--brand-mark-url, url("/static/brands/train-track.svg"));
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-image: var(--brand-mark-url, url("/static/brands/train-track.svg"));
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}
/* Bright emerald for marks placed on the dark auth hero and top nav. */
.auth-logo .brand-mark,
.nav-brand .brand-mark {
  background-color: var(--signal-green-bright);
}
.auth-tagline { color: rgba(255,255,255,0.6); font-size: 0.95rem; margin-top: 0.5rem; }
.auth-card {
  background: white;
  border-radius: 8px;
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
.auth-card h2 { font-size: 1.25rem; margin-bottom: 1rem; }
.auth-card-wide { max-width: 560px; }
.auth-sub { font-size: 0.88rem; color: var(--ballast); margin-bottom: 1.25rem; }
.auth-link { text-align: center; margin-top: 1rem; font-size: 0.85rem; color: var(--ballast); }
.auth-link a { color: var(--rail-blue); }
.auth-foot {
  text-align: center;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
  font-size: 0.82rem;
  color: var(--ballast);
}
.auth-foot a { color: var(--rail-blue); }

/* Invitation summary: structured label/value pairs at the top of /invite/{code}. */
.invite-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem 1.5rem;
  margin: 0 0 1.5rem;
  padding: 1rem 1.25rem;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
}
.invite-meta > div { min-width: 0; }
.invite-meta dt {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ballast);
  margin-bottom: 0.25rem;
}
.invite-meta dd {
  margin: 0;
  font-size: 0.92rem;
  color: var(--steel);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}
.invite-meta-email {
  font-family: var(--font-mono);
  font-size: 0.85rem !important;
}

/* Role badge inside the invite-meta panel. */
.role-chip {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-mono);
  border-radius: 999px;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  background: #e0e7ff;
  color: #3730a3;
}
.role-chip.role-owner  { background: #fef3c7; color: #92400e; }
.role-chip.role-admin  { background: #dbeafe; color: #1e40af; }
.role-chip.role-member { background: #d1fae5; color: #065f46; }
.role-chip.role-viewer { background: #f1f5f9; color: #475569; }

/* State panel below the invite summary — varies per (mismatch / ready / sign-in / sign-up). */
.invite-state h3 {
  font-size: 1rem;
  margin: 0 0 0.5rem;
  color: var(--steel);
}
.invite-state > p,
.invite-state-hint {
  font-size: 0.88rem;
  color: var(--ballast);
  margin: 0 0 1rem;
  line-height: 1.5;
}
.invite-state-warn {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.invite-state-warn h3 { color: #991b1b; }
.invite-state-warn > p { color: #7f1d1d; }
.invite-state-ready {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.invite-state-ready h3 { color: #065f46; }
.invite-state-ready > p { color: #064e3b; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--steel);
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="url"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  background: white;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--rail-blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-group input[readonly] {
  background: #f8fafc;
  color: var(--ballast);
  cursor: not-allowed;
}
.form-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}
.form-label-row label { margin-bottom: 0 !important; }
.form-label-link {
  font-size: 0.78rem;
  color: var(--rail-blue);
  text-decoration: none;
}
.form-label-link:hover { text-decoration: underline; }
.form-group input[readonly]:focus {
  border-color: #d1d5db;
  box-shadow: none;
}
.form-hint { font-size: 0.78rem; color: var(--ballast); margin-top: 0.25rem; display: block; }
.form-section {
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.form-section legend {
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  background: var(--rail-blue);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
}
.form-section-hint {
  font-size: 0.8rem;
  color: var(--ballast);
  margin: -0.25rem 0 1rem;
  line-height: 1.5;
}

/* Composite control: static URL prefix + slug input that look like one field. */
.url-preview {
  display: flex;
  align-items: stretch;
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  background: white;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.url-preview:focus-within {
  border-color: var(--rail-blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.url-preview-prefix {
  display: inline-flex;
  align-items: center;
  padding: 0 0.6rem;
  background: #f8fafc;
  color: var(--ballast);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  border-right: 1px solid #e5e7eb;
  white-space: nowrap;
}
.form-group .url-preview .url-preview-slug {
  flex: 1;
  border: none;
  border-radius: 0;
  background: transparent;
  font-family: var(--font-mono);
}
.form-group .url-preview .url-preview-slug:focus {
  outline: none;
  box-shadow: none;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.btn-primary { background: var(--rail-blue); color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #f1f5f9; color: var(--steel); border: 1px solid #d1d5db; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-full { width: 100%; }

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}
.alert-error { background: #fef2f2; color: var(--signal-red); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--signal-green); border: 1px solid #bbf7d0; }
.alert-info { background: #f0f9ff; color: #075985; border: 1px solid #bae6fd; }
.alert-info a { color: #0369a1; font-weight: 500; }

/* PRD authoring dispatch card on the blueprint detail page. Three-column
   grid that wraps to one column on narrow viewports. */
.dispatch-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 1rem;
}
.dispatch-card-title { font-size: 1rem; margin: 0 0 0.25rem; }
.dispatch-card-sub { font-size: 0.85rem; color: var(--ballast); margin: 0 0 1rem; line-height: 1.5; }
.dispatch-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 900px) { .dispatch-grid { grid-template-columns: 1fr; } }
.dispatch-option {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}
.dispatch-option h4 {
  font-size: 0.9rem;
  margin: 0 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.dispatch-option-desc { font-size: 0.8rem; color: var(--ballast); margin: 0 0 0.75rem; line-height: 1.5; }
.dispatch-option-desc code {
  background: #e2e8f0;
  padding: 0 0.25rem;
  border-radius: 3px;
  font-size: 0.78rem;
}
.dispatch-option-disabled { opacity: 0.65; }
.dispatch-option > form,
.dispatch-option > .alert,
.dispatch-option > .dispatch-snippet,
.dispatch-option > button { margin-top: auto; }
.dispatch-snippet {
  background: var(--steel);
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.6rem;
  border-radius: 4px;
  overflow-x: auto;
  margin: 0 0 0.5rem;
  white-space: pre;
  line-height: 1.4;
}

/* Section titles */
.section-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 1rem; }

/* Mono utility */
.mono { font-family: var(--font-mono); }

/* Settings grid */
.settings-grid { max-width: 800px; }

/* Data tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 2px solid #e5e7eb; font-weight: 600; color: var(--ballast); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.5px; }
.data-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid #f1f1f1; }

/* Email-verification nag: site-wide banner shown until account.email_verified=true. */
.verify-banner {
  background: #FFFBEB;
  border-bottom: 1px solid #FDE68A;
  color: #78350F;
  font-size: 0.88rem;
}
.verify-banner-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
}
.verify-banner-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  flex-shrink: 0;
  border-radius: 999px;
  background: #F59E0B;
  color: white;
  font-weight: 700;
  font-family: var(--font-mono);
}
.verify-banner-text { flex: 1; }
.verify-banner-text strong { color: #78350F; }
.verify-banner-form { margin: 0; flex-shrink: 0; }
.verify-banner-resend { color: #78350F; font-weight: 600; }
.verify-banner-resend:hover:not([disabled]) { color: #451A03; }

/* Inline link-style button used in dense tables (resend / revoke / copy). */
.btn-link {
  background: none;
  border: none;
  padding: 0.15rem 0;
  margin: 0;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--rail-blue);
  cursor: pointer;
}
.btn-link:hover:not([disabled]) { text-decoration: underline; }
.btn-link[disabled] { color: var(--ballast); cursor: default; }
.btn-link-danger { color: var(--signal-red, #DC2626); }

.invite-table .invite-actions-col { width: 1%; white-space: nowrap; text-align: right; }
.invite-actions {
  white-space: nowrap;
  text-align: right;
}

.admin-users-table .admin-actions-col,
.admin-workspaces-table .admin-actions-col,
.admin-tokens-table .admin-actions-col { width: 1%; white-space: nowrap; text-align: right; }
.admin-actions {
  white-space: nowrap;
  text-align: right;
}
.admin-actions select {
  padding: 0.3rem 0.4rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: white;
  font-family: inherit;
}

/* Stacked link buttons in the per-row actions column. */
.row-actions {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
}
.row-actions form, .row-actions .btn-link { margin: 0; }

.numeric-col { text-align: right; }

/* Admin section shell: left rail with section links, content on the right.
   Same pattern reused by the account page so /dashboard/account and
   /dashboard/admin/* feel like one navigated experience. */
.admin-shell {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 2rem;
  max-width: 1200px;
}
@media (max-width: 800px) { .admin-shell { grid-template-columns: 1fr; } }
.admin-rail {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  padding: 1.25rem 0.75rem;
  align-self: start;
  position: sticky;
  top: 1rem;
}
.admin-rail-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ballast);
  margin: 0 0.75rem 0.75rem;
}
.admin-rail-link {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.88rem;
  color: var(--steel);
  text-decoration: none;
}
.admin-rail-link:hover { background: #f1f5f9; }
.admin-rail-link-active {
  background: rgba(37,99,235,0.08);
  color: var(--rail-blue);
  font-weight: 600;
}
.admin-rail-foot {
  font-size: 0.72rem;
  color: var(--ballast);
  line-height: 1.5;
  margin: 1rem 0.75rem 0;
}
.admin-content { min-width: 0; }
.admin-page-header { margin-bottom: 1.5rem; }
.admin-page-header h1 { margin: 0 0 0.25rem; }
.admin-page-sub {
  font-size: 0.88rem;
  color: var(--ballast);
  margin: 0;
  line-height: 1.5;
}
.invite-actions > .btn-link,
.invite-actions form { margin-left: 0.75rem; }
.invite-actions > .btn-link:first-child,
.invite-actions form:first-child { margin-left: 0; }

/* Role badges */
.role-badge { font-size: 0.72rem; padding: 0.15rem 0.5rem; border-radius: 999px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px; }
.role-owner { background: #fef3c7; color: #92400e; }
.role-admin { background: #dbeafe; color: #1e40af; }
.role-member { background: #d1fae5; color: #065f46; }
.role-viewer { background: #f1f5f9; color: #475569; }

/* Project grid */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.project-card {
  display: block;
  background: white;
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.project-card:hover { border-color: var(--rail-blue); box-shadow: 0 2px 8px rgba(37,99,235,0.1); text-decoration: none; }
.project-card-name { font-weight: 600; font-size: 1rem; color: var(--steel); }
.project-card-desc { font-size: 0.85rem; color: var(--ballast); margin-top: 0.35rem; line-height: 1.4; }

/* Project tabs */
.project-tabs { display: flex; gap: 0; border-bottom: 2px solid #e5e7eb; margin-bottom: 1rem; }
.project-tab { padding: 0.6rem 1.25rem; font-size: 0.88rem; font-weight: 500; color: var(--ballast); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.project-tab.active { color: var(--rail-blue); border-bottom-color: var(--rail-blue); }

/* Blueprint list */
.blueprint-list { display: flex; flex-direction: column; gap: 0; }
.blueprint-row {
  display: block;
  padding: 1rem 1.25rem;
  background: white;
  border-bottom: 1px solid #f1f1f1;
  transition: background 0.1s;
}
.blueprint-row:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.blueprint-row:last-child { border-radius: 0 0 var(--radius) var(--radius); border-bottom: none; }
.blueprint-row:hover { background: #f8fafc; text-decoration: none; }
.blueprint-row-title { font-weight: 500; color: var(--steel); }
.blueprint-row-meta { font-size: 0.8rem; color: var(--ballast); margin-top: 0.2rem; display: flex; gap: 0.4rem; }

/* Status badges */
.status-badge { font-size: 0.72rem; padding: 0.2rem 0.6rem; border-radius: 999px; font-weight: 500; }
.status-open { background: #dcfce7; color: #166534; }
.status-closed { background: #f1f5f9; color: var(--ballast); }

/* Blueprint thread */
.blueprint-thread { max-width: 800px; }
.message-card {
  background: white;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.message-agent { border-left: 3px solid var(--rail-blue); }
.message-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.message-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--ballast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}
.message-agent .message-avatar { background: var(--rail-blue); }
.message-author { font-weight: 600; font-size: 0.88rem; }
.message-agent-badge { font-size: 0.65rem; padding: 0.1rem 0.4rem; border-radius: 3px; background: #dbeafe; color: #1e40af; font-weight: 500; }
.message-time { font-size: 0.78rem; color: var(--ballast); margin-left: auto; }
.message-body { font-size: 0.92rem; line-height: 1.6; white-space: pre-wrap; }

/* Message compose */
.message-compose {
  margin-top: 1rem;
  padding: 1rem;
  background: white;
  border-radius: var(--radius);
  border: 2px dashed #e5e7eb;
}
.message-compose textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--font-mono);
  resize: vertical;
}
.message-compose textarea:focus {
  outline: none;
  border-color: var(--rail-blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* Summon form */
.summon-form {
  margin-top: 1rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: var(--radius);
  border: 1px solid #e5e7eb;
}
.summon-form h4 { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.5rem; }
.summon-form form { display: flex; gap: 0.5rem; }
.summon-form input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  font-size: 0.85rem;
}

/* PRD sections */
.prd-section {
  background: white;
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.prd-section h3 { font-size: 0.92rem; font-weight: 600; margin-bottom: 0.75rem; color: var(--steel); }
.prd-body { font-size: 0.9rem; line-height: 1.7; white-space: pre-wrap; color: #374151; }

/* PRD status badges */
.status-draft { background: #f3f4f6; color: var(--ballast); }
.status-review { background: #fef3c7; color: #92400e; }
.status-approved { background: #dcfce7; color: #166534; }
.status-executing { background: #dbeafe; color: #1e40af; }
.status-complete { background: #f0fdf4; color: #065f46; }
.status-ready { background: #e0e7ff; color: #3730a3; }
.status-released { background: #fef3c7; color: #92400e; }

/* Review decisions */
.prd-review { padding: 0.5rem 0; border-bottom: 1px solid #f1f1f1; }
.prd-review:last-child { border-bottom: none; }
.review-decision { font-size: 0.72rem; padding: 0.15rem 0.5rem; border-radius: 999px; font-weight: 500; }
.review-approve { background: #dcfce7; color: #166534; }
.review-request_changes { background: #fef3c7; color: #92400e; }
.review-comment { background: #f1f5f9; color: var(--ballast); }

/* Bead list */
.bead-list { display: flex; flex-direction: column; gap: 0; }
.bead-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: white;
  border-bottom: 1px solid #f1f1f1;
}
.bead-row:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.bead-row:last-child { border-radius: 0 0 var(--radius) var(--radius); border-bottom: none; }
.bead-title { font-weight: 500; font-size: 0.9rem; }
.bead-meta { display: flex; gap: 0.5rem; align-items: center; font-size: 0.8rem; color: var(--ballast); }
.bead-status { font-size: 0.68rem; padding: 0.15rem 0.5rem; border-radius: 999px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px; }
.bead-open { background: #dcfce7; color: #166534; }
.bead-in_progress { background: #dbeafe; color: #1e40af; }
.bead-closed { background: #f1f5f9; color: var(--ballast); }

/* Priority badges */
.priority-badge { font-size: 0.68rem; padding: 0.1rem 0.4rem; border-radius: 3px; font-weight: 500; }
.priority-high { background: #fef2f2; color: var(--signal-red); }
.priority-medium { background: #fef3c7; color: #92400e; }
.priority-low { background: #f1f5f9; color: var(--ballast); }

/* Convoy cards */
.convoy-card {
  background: white;
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.convoy-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.convoy-title { font-weight: 500; font-size: 0.88rem; }
.convoy-progress { display: flex; align-items: center; gap: 0.75rem; }
.convoy-bar { flex: 1; height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; }
.convoy-bar-fill { height: 100%; background: var(--signal-green); border-radius: 3px; transition: width 0.3s; }
.convoy-count { font-size: 0.78rem; color: var(--ballast); font-family: var(--font-mono); white-space: nowrap; }

/* Running/failed convoy status */
.status-queued { background: #f3f4f6; color: var(--ballast); }
.status-running { background: #dbeafe; color: #1e40af; }
.status-done { background: #dcfce7; color: #166534; }
.status-failed { background: #fef2f2; color: var(--signal-red); }

/* ============================================================
   Rendered markdown
   Applied to any .md-rendered container: blueprint messages, PRD
   sections, and the preview pane of .md-editor. The reset of
   white-space is critical — the legacy .message-body / .prd-body
   rules use pre-wrap to keep raw newlines visible, which conflicts
   with HTML paragraphs once goldmark has rendered them.
   ============================================================ */
.md-rendered { white-space: normal; }
.md-rendered > *:first-child { margin-top: 0; }
.md-rendered > *:last-child { margin-bottom: 0; }
.md-rendered p { margin: 0 0 0.7em; }
.md-rendered h1, .md-rendered h2, .md-rendered h3,
.md-rendered h4, .md-rendered h5, .md-rendered h6 {
  color: var(--steel);
  font-weight: 600;
  line-height: 1.3;
  margin: 1.2em 0 0.5em;
}
.md-rendered h1 { font-size: 1.25rem; }
.md-rendered h2 { font-size: 1.1rem; }
.md-rendered h3 { font-size: 1rem; }
.md-rendered h4 { font-size: 0.92rem; }
.md-rendered h5, .md-rendered h6 { font-size: 0.85rem; color: var(--ballast); }
.md-rendered ul, .md-rendered ol { margin: 0 0 0.7em; padding-left: 1.4em; }
.md-rendered li { margin: 0.15em 0; }
.md-rendered li > p { margin: 0.2em 0; }
.md-rendered a { color: #1e40af; text-decoration: underline; text-underline-offset: 2px; }
.md-rendered a:hover { color: var(--steel); }
.md-rendered code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: #f1f5f9;
  color: #334155;
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
.md-rendered pre {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  overflow-x: auto;
  margin: 0 0 0.7em;
}
.md-rendered pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
  color: inherit;
}
.md-rendered blockquote {
  margin: 0.6em 0;
  padding: 0.1em 0 0.1em 0.9em;
  border-left: 3px solid #e2e8f0;
  color: var(--ballast);
}
.md-rendered table {
  border-collapse: collapse;
  margin: 0 0 0.7em;
  font-size: 0.88rem;
}
.md-rendered th, .md-rendered td {
  border: 1px solid #e2e8f0;
  padding: 0.4em 0.7em;
  text-align: left;
}
.md-rendered th { background: #f8fafc; font-weight: 600; }
.md-rendered hr { border: 0; border-top: 1px solid #e2e8f0; margin: 1.2em 0; }
.md-rendered img { max-width: 100%; border-radius: var(--radius); }
.md-rendered input[type="checkbox"] { margin-right: 0.4em; }
.md-empty { color: var(--ballast); font-style: italic; font-size: 0.88rem; margin: 0; }

/* ============================================================
   In-browser markdown editor (Edit / Preview tabs)
   Toggle is driven by data-md-mode on .md-editor — CSS attribute
   selectors swap pane visibility without any inline style writes.
   ============================================================ */
.md-editor {
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  background: white;
  overflow: hidden;
}
.md-tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.5rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.md-tab {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 0.3rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ballast);
  cursor: pointer;
  font-family: inherit;
}
.md-tab:hover { color: var(--steel); }
.md-tab-active {
  background: white;
  border-color: #e2e8f0;
  color: var(--steel);
  box-shadow: 0 1px 1px rgba(0,0,0,0.03);
}
.md-hint {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--ballast);
  font-family: var(--font-mono);
}
.md-edit-pane textarea {
  display: block;
  width: 100%;
  border: 0;
  outline: none;
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.55;
  resize: vertical;
  background: transparent;
  color: var(--steel);
  box-sizing: border-box;
}
.md-preview {
  padding: 0.75rem;
  min-height: 4rem;
  font-size: 0.92rem;
  line-height: 1.6;
}
.md-editor[data-md-mode="edit"] .md-preview { display: none; }
.md-editor[data-md-mode="preview"] .md-edit-pane { display: none; }
.md-editor[data-md-mode="preview"] .md-preview { display: block; }

/* ============================================================
   Daily reports — Recent activity accordion on project page
   ============================================================ */
.recent-activity .report-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.report-row {
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  background: white;
  overflow: hidden;
}
.report-row > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.6rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.85rem;
  user-select: none;
}
.report-row > summary::-webkit-details-marker { display: none; }
.report-row > summary::before {
  content: "▸";
  color: var(--ballast);
  font-size: 0.7rem;
  width: 0.8rem;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
.report-row[open] > summary::before { transform: rotate(90deg); }
.report-row > summary:hover { background: #f8fafc; }
.report-date {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--steel);
  font-weight: 600;
  flex-shrink: 0;
  min-width: 7rem;
}
.report-rig {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  background: #dbeafe;
  color: #1e40af;
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  flex-shrink: 0;
}
.report-excerpt {
  color: var(--ballast);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.report-body {
  padding: 0 1rem 1rem;
  border-top: 1px solid #f1f5f9;
  padding-top: 0.85rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ============================================================
   Toasts — fixed top-right, slide-in, auto-dismiss
   Append .toast children to #toast-host. Variants:
     .toast-success (green), .toast-error (red), .toast-info (blue).
   ============================================================ */
.toast-host {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;  /* children re-enable */
  max-width: min(90vw, 22rem);
}
.toast {
  pointer-events: auto;
  background: white;
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  font-size: 0.85rem;
  line-height: 1.4;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.06);
  border: 1px solid #e2e8f0;
  border-left-width: 4px;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  animation: toast-in 220ms ease-out both, toast-out 250ms ease-in 3.6s both;
  cursor: pointer;
}
.toast-success { border-left-color: var(--signal-green); }
.toast-error   { border-left-color: var(--signal-red); }
.toast-info    { border-left-color: #1e40af; }
.toast-icon {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  width: 1.1rem;
  text-align: center;
}
.toast-success .toast-icon { color: var(--signal-green); }
.toast-error   .toast-icon { color: var(--signal-red); }
.toast-info    .toast-icon { color: #1e40af; }
.toast-message { flex: 1; color: var(--steel); }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(0.5rem); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(0.5rem); }
}

/* ============================================================
   Docs tab — sidebar of .md files + content pane
   ============================================================ */
.docs-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}
.docs-sidebar {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  overflow: hidden;
  position: sticky;
  top: 1rem;
}
.docs-sidebar-header {
  padding: 0.6rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ballast);
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.docs-file-list { list-style: none; margin: 0; padding: 0.3rem 0; }
.docs-file-list li { margin: 0; }
.docs-file {
  display: block;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  color: var(--steel);
  border-left: 3px solid transparent;
  text-decoration: none;
}
.docs-file:hover { background: #f8fafc; }
.docs-file.active {
  background: #eff6ff;
  border-left-color: var(--rail-blue, #1e40af);
  color: var(--steel);
  font-weight: 500;
}
.docs-content {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  min-width: 0;  /* lets pre/table children scroll inside the grid cell */
}
.docs-content-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}
.docs-content-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-family: var(--font-mono);
}

/* Collapsible PAT-setup help on the project settings form. Tight inline
   list, indented so it visually belongs to the github_token field. */
.pat-help {
  margin-top: 0.65rem;
  font-size: 0.82rem;
}
.pat-help summary {
  cursor: pointer;
  color: var(--ballast);
  user-select: none;
  padding: 0.2rem 0;
}
.pat-help summary:hover { color: var(--steel); }
.pat-help[open] summary { color: var(--steel); margin-bottom: 0.35rem; }
.pat-help-steps {
  margin: 0.25rem 0 0 1.2rem;
  padding: 0;
  line-height: 1.55;
  color: var(--steel);
}
.pat-help-steps li { margin: 0.3rem 0; }
.pat-help-steps code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: #f1f5f9;
  padding: 0.05em 0.3em;
  border-radius: 3px;
}
.pat-help a { color: #1e40af; text-decoration: underline; }
