/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

:root {
  color-scheme: dark;
  --bg: #111318;
  --bg-card: #1a1d2b;
  --bg-inset: #0e1018;
  --bg-hover: #1e2235;
  --bg-active: #252a3a;
  --border: #2a2e3f;
  --border-subtle: #222638;
  --text: #e2e4e9;
  --text-2: #a0a4b0;
  --text-3: #6b7080;
  --text-4: #4b5060;
  --link: #818cf8;
  --link-hover: #a5b4fc;
  --input-bg: #151825;
  --input-border: #2a2e3f;
  --focus-ring: rgba(99, 102, 241, 0.35);
  --focus-border: #6366f1;
  --shadow: rgba(0, 0, 0, 0.4);
  --tag-green-bg: #16382a;
  --tag-green-text: #6ee7b7;
  --tag-blue-bg: #172554;
  --tag-blue-text: #93c5fd;
  --tag-indigo-bg: #1e1b4b;
  --tag-indigo-text: #a5b4fc;
  /* The five status colours, one meaning each (.claude/skills/interface-design/SKILL.md,
     "Status colours"). A state takes one through .universe-broken etc.; never add another. */
  --broken: #ef4444;
  --board: #f59e0b;
  --waiting: #60a5fa;
  --moving: #34d399;
  --stopped: #9ca3af;
}

body { margin: 0; }
header, nav { margin: 0 !important; }

/* Base */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

/* ===== App Shell (Paperclip-style three-column layout) ===== */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Company Rail - 56px vertical icon strip */
.company-rail {
  width: 56px;
  min-width: 56px;
  background: #1a1a2e;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 8px;
  overflow-y: auto;
}

.rail-logo {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  color: #9ca3af;
}

.rail-logo a { color: inherit; text-decoration: none; }
.rail-logo a:hover { text-decoration: none; opacity: 0.85; }

.rail-companies {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.rail-company-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #2d2d44;
  color: #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-decoration: none;
  transition: background 0.1s, color 0.1s, border-radius 0.1s;
  position: relative;
}

.rail-company-icon:hover {
  background: #3d3d5c;
  color: #fff;
  text-decoration: none;
  border-radius: 12px;
}

.rail-company-icon.active {
  background: #4f46e5;
  color: #fff;
  border-radius: 12px;
}

.rail-company-icon.active::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: #fff;
  border-radius: 0 2px 2px 0;
}

.rail-add {
  padding-top: 8px;
}

.rail-queue {
  margin-top: auto;
  padding: 4px 8px;
  display: flex;
  flex-wrap: wrap-reverse;
  align-content: flex-start;
  gap: 2px;
  width: 40px;
  align-self: center;
  position: relative;
  min-height: 8px;
}
.rail-queue-block {
  width: 8px;
  height: 8px;
  border-radius: 1px;
  background: var(--text-4);
}
/* A job's kind is in its tooltip, not a colour; the one that runs now moves. */
.rail-queue-active { background: var(--moving); animation: block-pulse 1.5s ease-in-out infinite; }
@keyframes block-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.rail-queue-overflow {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  pointer-events: none;
}

.rail-bottom {
  padding-top: 8px;
}

.rail-admin-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: 50%;
  margin-bottom: 4px;
  transition: opacity 0.1s;
}

.rail-admin-icon:hover {
  opacity: 0.8;
}

.rail-user-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: opacity 0.1s;
}

.rail-user-icon:hover {
  opacity: 0.8;
  text-decoration: none;
}

.rail-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.rail-user-initials {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #2d2d44;
  color: #9ca3af;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rail-add a {
  width: 36px;
  height: 36px;
  border: 2px dashed #4b5563;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  text-decoration: none;
  transition: border-color 0.1s, color 0.1s;
}

.rail-add a:hover {
  border-color: #9ca3af;
  color: #d1d5db;
  text-decoration: none;
}

/* Sidebar - 220px navigation panel */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sidebar-header {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-company-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--universe-colour, var(--border));
}

/* A stuck company, seen from any page: a red dot on its rail icon. */
.rail-company-icon--stalled::after {
  content: '';
  position: absolute;
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--broken);
  border: 2px solid #1a1a2e;
}

.stall-panel { border: 1px solid var(--broken); border-left: 4px solid var(--broken); background: rgba(239, 68, 68, 0.1); border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 1.25rem; }
.stall-panel-title { color: var(--broken); font-size: 1rem; margin: 0 0 0.5rem; }
.stall-row { display: flex; justify-content: space-between; gap: 1rem; padding: 0.35rem 0; border-top: 1px solid rgba(239, 68, 68, 0.25); }
.stall-row a { color: var(--broken); font-weight: 600; white-space: nowrap; }

.sidebar-company-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Build Queue & Heartbeat Rings — video-game status strip */
.build-queue-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-wrap: wrap;
}

.build-queue {
  display: flex;
  gap: 4px;
}

.build-queue-item {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  opacity: 0.5;
  cursor: default;
}

.build-queue-item.active {
  opacity: 1;
  background: var(--tag-blue-bg);
  box-shadow: 0 0 0 1px var(--tag-blue-text);
}

.build-queue-icon {
  font-size: 14px;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.build-queue-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, #3b82f6 0%, #93c5fd 50%, #3b82f6 100%);
  background-size: 200% 100%;
  animation: build-shimmer 1.5s ease-in-out infinite;
}

@keyframes build-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Heartbeat cooldown rings */
a.heartbeat-ring {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  position: relative;
  cursor: pointer;
  text-decoration: none;
  display: block;
  flex-shrink: 0;
}

a.heartbeat-ring:hover {
  transform: scale(1.15);
  transition: transform 0.15s ease;
}

.heartbeat-ring-bg {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--border);
}

.heartbeat-ring-fill {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  transition: background 0.3s ease;
}

.heartbeat-ring-avatar,
.heartbeat-ring-initials {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  z-index: 1;
}

.heartbeat-ring-avatar {
  width: 26px;
  height: 26px;
  object-fit: cover;
}

.heartbeat-ring-initials {
  width: 26px;
  height: 26px;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-3);
}

.heartbeat-active {
  animation: heartbeat-pulse 1s ease-in-out infinite;
}

@keyframes heartbeat-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.4); }
  50% { box-shadow: 0 0 0 4px rgba(59,130,246,0); }
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-4);
  padding: 12px 8px 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.sidebar-item:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}

.sidebar-item.active {
  background: var(--bg-active);
  color: var(--link);
}

.sidebar-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 8px;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.sidebar-footer form {
  margin: 0;
}

.sidebar-build {
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 9px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text-4);
  pointer-events: none;
}

.sidebar-logout {
  font-size: 13px;
  color: var(--text-3);
}

/* Main content area */
.main-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.main-content > .breadcrumbs {
  padding: 4px 16px;
  background: var(--bg-card);
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.main-content > .breadcrumbs a { color: var(--link); }
.main-content > .breadcrumbs a:hover { text-decoration: underline; }
.main-content > .breadcrumbs .current { color: var(--text-3); }

/* Search bar in breadcrumb area */
.search-bar { margin: 0; display: flex; }
.search-input {
  font-size: 13px;
  padding: 2px 8px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  width: 200px;
  outline: none;
  background: var(--input-bg);
  color: var(--text);
  transition: border-color 0.15s, width 0.2s;
}
.search-input:focus {
  border-color: var(--focus-border);
  box-shadow: 0 0 0 2px var(--focus-ring);
  width: 300px;
}

.main-content > main {
  flex: 1;
  padding: 16px 24px;
}

/* On a phone the shell stacks: rail and sidebar on top, the page below it, one scroll. */
@media (max-width: 640px) {
  .app-shell { flex-wrap: wrap; height: auto; overflow: visible; }
  .sidebar { flex: 1; width: auto; min-width: 0; height: auto; border-right: 0; }
  .sidebar-nav { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 2px; }
  .sidebar-item { width: auto; }
  .sidebar-section-label, .sidebar-footer { display: none; }
  .main-content { flex-basis: 100%; overflow: visible; }
  .main-content > main { padding: 16px; }
  .search-input, .search-input:focus { width: 140px; }
}

/* Flash, in both layouts. The alert flash is the error box (see #error_explanation). */
main > p.notice { color: var(--tag-green-text); background: var(--tag-green-bg); padding: 0.75rem 1rem; border-radius: 6px; margin: 0 0 1rem; }

/* Simple layout (logged out / no companies) */
.simple-header {
  padding: 4px 16px;
  background: var(--bg-card);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.simple-nav {
  padding: 4px 16px;
  background: var(--bg-card);
  display: flex;
  gap: 16px;
  font-size: 14px;
}

.simple-nav a {
  color: #fff;
  text-decoration: none;
}

/* Override nav defaults when inside sidebar */
.sidebar nav { background: transparent; padding: 0; margin: 0; }
.sidebar nav a { color: var(--text-2); margin-right: 0; }
.sidebar nav a:hover { opacity: 1; }

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Page Headers */
h1 {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--text);
}

/* Links */
a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Secondary Links */
.link-secondary {
  color: var(--text-3);
  font-size: 0.9rem;
  margin-top: 1rem;
  display: inline-block;
}

.link-secondary:hover {
  color: var(--text-2);
}

/* Images */
img {
  max-width: 100%;
  height: auto;
}

img.photo {
  width: 80px !important;
  height: 80px !important;
  max-width: 80px !important;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

th {
  padding: 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 2px solid var(--border);
}

td {
  padding: 10px;
  text-align: left;
  vertical-align: middle;
}

/* The speed badge's tables keep their own light rows. :where adds no specificity. */
tbody tr:nth-child(even):where(:not(.profiler-results *)) { background: var(--bg-card); }
tbody tr:hover:where(:not(.profiler-results *)) { background: var(--bg-hover); }
tr[data-href] { cursor: pointer; }

td form { display: inline; }

/* Navigation */
nav {
  background: var(--bg-card);
  padding: 10px;
  margin-bottom: 20px;
}

nav a {
  color: white;
  margin-right: 20px;
}

nav a:hover {
  opacity: 0.8;
}

/* Empty States */
.empty {
  text-align: center;
  color: var(--text-3);
  font-style: italic;
  padding: 40px;
}

/* Utility */
.center {
  text-align: center;
}

.muted {
  color: var(--text-3);
  font-size: 0.9em;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25em 0.6em;
  font-size: 0.75em;
  font-weight: 600;
  border-radius: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background-color: var(--bg-hover);
  color: var(--text-2);
}

/* A state's badge takes the colour of what it waits for (status_badge, ApplicationRecord#status_tone).
   A badge with no state (a role, a priority) stays neutral. */
.badge[class*="universe-"] {
  background-color: var(--universe-colour, var(--bg-hover));
  color: var(--bg);
}

/* Pause/resume on hover */
.badge-pausable {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}
.badge-pausable .badge-pause-btn,
.badge-pausable .badge-resume-btn {
  display: none;
  position: absolute;
  inset: 0;
  border: none;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 8px;
  white-space: nowrap;
}
/* Pausing is a choice, not a fault: grey, not red. */
.badge-pausable .badge-pause-btn {
  background: var(--bg-hover);
  color: var(--text);
}
.badge-pausable .badge-resume-btn {
  background: var(--moving);
  color: var(--bg);
}
.badge-pausable:hover .badge-pause-btn,
.badge-pausable:hover .badge-resume-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.badge-pausable:hover .badge {
  visibility: hidden;
}

.approval-comment {
  border-left: 3px solid var(--border);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

/* A page proposal: what changes first, then the whole page in a frame. The page's own
   headings are scaled down so they never outrank the approval's. */
.approval-section-title { font-size: 0.95rem; margin: 1.25rem 0 0.5rem; }
.approval-stale, .mail-held { border: 1px solid var(--board); background: rgba(245, 158, 11, 0.12); color: var(--text); border-radius: 6px; padding: 0.6rem 0.8rem; margin: 0.75rem 0; font-size: 0.85rem; }
/* An error the Board should see: a no-op proposal on the index, an error event in any activity list. */
.approval-error { border: 1px solid var(--broken); background: rgba(220, 38, 38, 0.12); color: #f87171; border-radius: 6px; padding: 0.4rem 0.6rem; margin: 0.5rem 0; font-size: 0.8rem; }
.activity-error, .activity-error td, .activity-error .activity-body, .activity-error .activity-action { color: var(--broken); }
.approval-document-toggle { margin: 1rem 0; }
.approval-document-toggle > summary, .wiki-history-entry > summary, .approval-section-title + details > summary { cursor: pointer; color: var(--text-2); font-size: 0.85rem; }
.wiki-document { border: 1px solid var(--border); border-radius: 8px; background: var(--bg-card); padding: 0.75rem 1.1rem; margin-top: 0.5rem; }
.wiki-document h1 { font-size: 1.15rem; } .wiki-document h2 { font-size: 1rem; } .wiki-document h3 { font-size: 0.9rem; }
.wiki-document h1, .wiki-document h2, .wiki-document h3 { margin: 0.9rem 0 0.35rem; }
.wiki-diff { border: 1px solid var(--border); border-radius: 8px; background: var(--bg-inset); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; line-height: 1.5; padding: 0.4rem 0; overflow-x: auto; margin: 0.4rem 0 0.75rem; }
.wiki-diff > div { white-space: pre-wrap; word-break: break-word; padding: 0 0.75rem 0 1.6rem; position: relative; }
.wiki-diff > div::before { position: absolute; left: 0.6rem; color: var(--text-4); }
.wiki-diff-same { color: var(--text-3); }
.wiki-diff-add { background: rgba(34, 197, 94, 0.14); color: var(--text); }
.wiki-diff-add::before { content: "+"; color: #4ade80 !important; }
.wiki-diff-del { background: rgba(239, 68, 68, 0.14); color: var(--text-2); text-decoration: line-through; text-decoration-color: rgba(239, 68, 68, 0.5); }
.wiki-diff-del::before { content: "−"; color: #f87171 !important; }
.wiki-diff-fold { color: var(--text-4); font-style: italic; }
.wiki-history-entry { border-top: 1px solid var(--border-subtle); padding: 0.4rem 0; }
.wiki-history-entry > summary { display: flex; gap: 0.6rem; align-items: baseline; }

/* Approvals index: the request is the loudest text; who and when are quiet. */
.approvals-toolbar { display: flex; justify-content: flex-end; gap: 0.25rem; margin-bottom: 0.5rem; }
.approvals-toolbar a { padding: 0.2rem 0.7rem; border: 1px solid var(--border); border-radius: 6px; color: var(--text-3); font-size: 0.8rem; text-decoration: none; }
.approvals-toolbar a.active { color: var(--text); background: var(--bg-active); }
.approvals-heading { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); margin: 1rem 0 0.75rem; }
.approvals-decided { opacity: 0.55; }
.approval-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.approval-card { display: flex; flex-direction: column; gap: 0.6rem; padding: 1rem 1.1rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; }
.approval-card-meta { font-size: 0.8rem; color: var(--text-3); }
.approval-card-meta a { color: var(--text-2); }
.approval-card-title { font-size: 1.15rem; font-weight: 600; color: var(--text); line-height: 1.3; }
.approval-card-fields { margin: 0; flex: 1; }
.approval-card-fields dt { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); margin-top: 0.4rem; }
.approval-card-fields dd { margin: 0.1rem 0 0; font-size: 0.9rem; color: var(--text-2); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.approval-actions { display: flex; gap: 0.5rem; align-items: center; }
.approval-actions form { margin: 0; max-width: none; }

/* Kanban board */
.kanban-board {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 1rem;
}

.kanban-column {
  min-width: 220px;
  flex: 1;
  background: var(--bg-card);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
}

.kanban-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  font-size: 0.85rem;
  border-bottom: 2px solid var(--border);
}

.kanban-column-count {
  background: var(--bg-hover);
  color: var(--text-2);
  border-radius: 10px;
  padding: 0 0.5rem;
  font-size: 0.75rem;
}

.kanban-column-cards {
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 60px;
}

.kanban-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: pointer;
}

.kanban-card:hover {
  box-shadow: 0 4px 12px var(--shadow);
  transform: translateY(-1px);
  text-decoration: none;
  color: inherit;
}

.kanban-card-title {
  font-size: 0.85rem;
  line-height: 1.3;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.kanban-card-meta {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.75rem;
}

.kanban-card-assignee {
  color: var(--text-2);
}

.kanban-card-assignee.unassigned {
  color: var(--broken);
  font-style: italic;
}

.kanban-card-subtasks {
  margin-top: 0.35rem;
  font-size: 0.7rem;
  color: var(--text-3);
}

.kanban-subtask-progress {
  display: block;
  margin-bottom: 0.2rem;
}

.kanban-subtask-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.kanban-subtask-fill {
  height: 100%;
  background: var(--text-3);
  border-radius: 2px;
}

/* Buttons */
.btn, :where(main.standard) form [type="submit"]:not([class]), .actions [type="submit"]:not([class]) {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  border-radius: 0.25rem;
  text-decoration: none;
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  background-color: #0066cc;
  color: white;
  border: 1px solid #0066cc;
  transition: all 0.15s ease-in-out;
}

.btn:hover, :where(main.standard) form [type="submit"]:not([class]):hover {
  background-color: #0056b3;
  border-color: #0056b3;
  text-decoration: none;
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  line-height: 1.5;
  border-radius: 0.2rem;
}

.btn-primary, :where(main.standard) form [type="submit"]:not([class]), .actions [type="submit"]:not([class]) {
  background-color: #007bff;
  border-color: #007bff;
}

.btn-primary:hover, :where(main.standard) form [type="submit"]:not([class]):hover, .actions [type="submit"]:not([class]):hover {
  background-color: #0069d9;
  border-color: #0062cc;
}

.btn-primary:disabled, .btn-secondary:disabled {
  background-color: #e2e8f0;
  border-color: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
  opacity: 1;
}

/* Settings sections: description left, content right */
.settings-section {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
  padding: 2rem 0;
  border-bottom: 1px solid var(--border);
}

.settings-section:last-child { border-bottom: none; }

/* Repo picker */
.repo-picker {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.repo-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.repo-picker-list {
  max-height: 320px;
  overflow-y: auto;
}
.repo-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  font-size: 0.9rem;
}
.repo-picker-item:last-child { border-bottom: none; }
.repo-picker-item:hover { background: var(--bg-hover); }
.repo-picker-item input[type="checkbox"] { flex-shrink: 0; }
.repo-picker-info { display: flex; align-items: center; gap: 8px; }
.repo-picker-name { font-family: ui-monospace, monospace; font-size: 0.85rem; }
.repo-picker-badge {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--bg-hover);
  color: var(--text-3);
  border: 1px solid var(--border);
}
.repo-picker-footer {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 0.85rem;
}

.section-desc h3 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.section-desc p {
  margin: 0;
  color: var(--text-3);
  font-size: 0.9rem;
}

.field {
  margin-bottom: 1.5rem;
}

.field label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-2);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="tel"],
.field input[type="url"],
.field textarea,
.field select {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--input-bg);
  background-clip: padding-box;
  border: 1px solid var(--input-border);
  border-radius: 0.375rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  box-sizing: border-box;
}

.field input[type="text"]:focus,
.field input[type="email"]:focus,
.field input[type="password"]:focus,
.field input[type="number"]:focus,
.field input[type="tel"]:focus,
.field input[type="url"]:focus,
.field textarea:focus,
.field select:focus {
  color: var(--text);
  background-color: var(--input-bg);
  border-color: var(--focus-border);
  outline: 0;
  box-shadow: 0 0 0 0.2rem var(--focus-ring);
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

.field input[type="file"] {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--input-bg);
  background-clip: padding-box;
  border: 1px solid var(--input-border);
  border-radius: 0.375rem;
}

.field input[type="file"]:focus {
  color: var(--text);
  background-color: var(--input-bg);
  border-color: var(--focus-border);
  outline: 0;
}

.actions {
  margin-top: 1.5rem;
}

/* Error messages */
/* The error box: form errors, failures and the alert flash. */
#error_explanation, :where(main.standard) [role="alert"], main > p.alert {
  color: var(--text);
  background: rgba(239, 68, 68, 0.1);
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
  border: 1px solid var(--broken);
  border-radius: 6px;
}
:where(main.standard) [role="alert"] pre { white-space: pre-wrap; margin: 0.25rem 0 0; font-size: 0.85rem; }

#error_explanation h2 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
}

#error_explanation ul {
  margin-bottom: 0;
  padding-left: 1.5rem;
}

#error_explanation li {
  margin-bottom: 0.25rem;
}

/* Field with errors */
.field_with_errors {
  display: contents;
}

.field_with_errors input,
.field_with_errors textarea,
.field_with_errors select {
  border-color: var(--broken);
}

.field_with_errors label {
  color: var(--broken);
}

/* Model preference badges */
.model-badge .badge {
  font-size: 0.875rem;
  padding: 0.4rem 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.model-badge .badge i {
  font-size: 1rem;
}

.model-badge .badge.bg-info {
  background-color: #0dcaf0 !important;
  color: #000;
}

.model-badge .badge.bg-warning {
  background-color: #ffc107 !important;
  color: #000;
}

.model-badge .badge.bg-success {
  background-color: #198754 !important;
  color: #fff;
}

/* Agent card enhancements */
.agent-card .model-badge {
  margin-top: 0.5rem;
}

/* Character card — agent generator */
.character-card {
  max-width: 380px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  margin: 1rem 0;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s, transform 0.2s;
}

.character-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-1px);
}

.card-hero {
  display: flex;
  justify-content: center;
  padding: 1.5rem 1.5rem 0;
}

.character-portrait {
  width: 160px;
  height: 160px;
}

.character-portrait canvas {
  width: 160px;
  height: 160px;
  border-radius: 50%;
}

.portrait-placeholder {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.75rem;
}

.portrait-image {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
}

.card-identity {
  text-align: center;
  padding: 0.75rem 1.5rem 0;
}

.character-name { margin: 0; font-size: 1.3rem; font-weight: 700; }

.character-role {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--link);
  background: var(--bg-hover);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  margin-top: 0.25rem;
}

.character-demo { font-size: 0.8rem; color: #94a3b8; margin-left: 0.35rem; }
.character-tagline { font-style: italic; color: #475569; margin: 0.35rem 0 0; font-size: 0.9rem; }

.card-body {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  border-top: 1px solid #f1f5f9;
  margin-top: 0.75rem;
}

.character-style {
  flex: 1;
  font-size: 0.82rem;
  color: var(--text-2);
  line-height: 1.5;
  margin: 0;
}

.character-stats {
  flex-shrink: 0;
  width: 130px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem 0.625rem;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.stat-abbr {
  width: 28px;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.03em;
}

.stat-bar-mini {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

/* A stat is a magnitude: its length shows it, in one neutral fill, not a status colour. */
.stat-bar-fill-mini {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
  background: var(--text-3);
}

.stat-val {
  width: 18px;
  text-align: right;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-2);
}

.card-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0 1.5rem 1rem;
}

.skeleton-text {
  display: inline-block;
  height: 1em;
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 4px;
  width: 100%;
}

.skeleton-short { width: 60%; }

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.hire-wrap {
  margin-top: 0.75rem;
  display: flex;
  justify-content: center;
  max-width: 380px;
}

.hire-wrap .btn { width: 100%; }

/* Team grid — company show */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

/* A contract that ended (terminated, completed, expired), shown under All: kept, but plainly not a
   current teammate. */
.team-card-ended, .contract-row-ended { opacity: 0.5; filter: grayscale(1); }
.team-card-ended:hover { opacity: 0.8; }

.team-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  background: var(--bg-card);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, transform 0.2s;
}

.team-card:hover {
  box-shadow: 0 4px 12px var(--shadow);
  transform: translateY(-1px);
  text-decoration: none;
  color: inherit;
}

.team-card-photo {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.team-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
}

.team-avatar-placeholder {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.25rem;
}

.team-card-info {
  text-align: center;
  margin-bottom: 0.5rem;
}

.team-card-name {
  display: block;
  font-size: 1rem;
}

.team-card-role {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--link);
  background: var(--tag-indigo-bg);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-top: 0.2rem;
}

.team-card-stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
  margin: 0.5rem 0;
}

.team-stat {
  display: flex;
  flex-direction: column;
}

.team-stat-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.team-stat-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--text-3);
}

.team-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  margin-top: 0.5rem;
}

/* "New" team card (Direct Hire) */
.team-card-new {
  border: 2px dashed var(--border);
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-4);
  min-height: 160px;
}

.team-card-new:hover {
  border-color: var(--text-3);
  color: var(--text-3);
  background: var(--bg-hover);
}

.team-card-new-icon { color: inherit; }
.team-card-new-label { font-size: 0.9rem; font-weight: 500; }

/* Hire presets */
.hire-presets {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.hire-preset-card {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.hire-preset-card:hover { border-color: #a5b4fc; box-shadow: 0 2px 8px rgba(0,0,0,0.06); text-decoration: none; color: inherit; }
.hire-preset-card--active { border-color: #6366f1; box-shadow: 0 0 0 1px #6366f1; }
.hire-preset-icon { color: #6366f1; flex-shrink: 0; }
.hire-preset-info { display: flex; flex-direction: column; }
.hire-preset-info strong { font-size: 0.9rem; }
.hire-preset-desc { font-size: 0.75rem; color: #64748b; }
@media (max-width: 640px) { .hire-presets { flex-direction: column; } }

/* Wiki grid */
.wiki-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.wiki-card {
  display: block;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.wiki-card:hover { border-color: #a5b4fc; box-shadow: 0 2px 8px rgba(0,0,0,0.06); text-decoration: none; color: inherit; }
.wiki-card-title { display: block; font-size: 0.95rem; margin-bottom: 0.3rem; }
.wiki-card-excerpt { display: block; font-size: 0.8rem; color: #64748b; line-height: 1.4; }
.wiki-card-children { display: block; font-size: 0.7rem; color: #94a3b8; margin-top: 0.4rem; }
.wiki-card-new {
  border: 2px dashed #d1d5db;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: #9ca3af;
  min-height: 160px;
  cursor: pointer;
  font-family: inherit;
}
.wiki-card-new:hover { border-color: #9ca3af; color: #6b7280; background: #f9fafb; }

/* Dashboard team: one compact row a teammate — face, name, role, state */
.teammate-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.4rem 0; color: inherit; text-decoration: none; }
.teammate-row:hover { text-decoration: none; }
.teammate-row:hover .teammate-row-name { color: var(--link-hover); }
.teammate-row .teammate-row-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; font-size: 0.7rem; }
.teammate-row-name { font-size: 0.9rem; color: var(--text); }
.teammate-row-role { font-size: 0.7rem; color: var(--link); text-transform: uppercase; letter-spacing: 0.06em; }
.teammate-row-status { margin-left: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.68rem; letter-spacing: 0.04em; color: var(--text-3); }

/* Dashboard pulse: an hour a cell, so the gaps read as loudly as the work */
.pulse-row { display: flex; align-items: center; gap: 1rem; padding: 0.35rem 0; }
.pulse-cells { display: flex; gap: 2px; flex: 1; }
.pulse-cell { flex: 1; height: 18px; min-width: 4px; border-radius: 2px; background: var(--bg-inset); border: 1px solid var(--border-subtle); }
.pulse-cell--quiet { background: #166534; border-color: #166534; }
.pulse-cell--busy { background: #4ade80; border-color: #4ade80; }
.pulse-row--axis { padding: 0.1rem 0 0; }
.pulse-axis { display: flex; flex: 1; justify-content: space-between; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.62rem; color: var(--text-3); }
.pulse-legend { display: flex; gap: 1.25rem; margin-top: 0.7rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.65rem; color: var(--text-3); }
.pulse-legend-key { display: inline-flex; align-items: center; gap: 0.35rem; }
.pulse-legend-key .pulse-cell { flex: 0 0 12px; height: 12px; }

/* Dashboard console panels: one dark card a subject, an all-caps title, and
   a right-aligned count. Rows read as a label beside a status bar. */
.console-panel { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 8px; padding: 1rem 1.1rem 1.2rem; margin-bottom: 1.25rem; }
.console-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; }
.console-panel-title { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text); margin: 0; }
.console-panel-meta { font-size: 0.75rem; color: var(--text-3); white-space: nowrap; }

.console-row { display: flex; align-items: center; gap: 1rem; padding: 0.45rem 0; color: inherit; text-decoration: none; }
.console-row:hover { text-decoration: none; }
.console-row:hover .console-track { border-color: var(--border); }
.console-row-label { flex: 0 0 34%; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.console-row-label strong { font-size: 0.9rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.console-row-sub { font-size: 0.72rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.console-track { position: relative; flex: 1; height: 26px; border: 1px solid var(--border-subtle); border-radius: 3px; background: var(--bg-inset); overflow: hidden; }
.console-fill { position: absolute; inset: 0 auto 0 0; background: #15803d; }
.console-fill--in_progress { background: #b45309; }
.console-track-text { position: absolute; left: 0.5rem; top: 50%; transform: translateY(-50%); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.68rem; letter-spacing: 0.04em; color: var(--text); white-space: nowrap; }
.console-empty { font-size: 0.8rem; color: var(--text-3); margin: 0; }

/* Pace: the rate reads first, the estimate sits beside it */
.console-figure { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.console-figure-value { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 2.6rem; font-weight: 700; line-height: 1; color: #f0b429; }
.console-figure-unit { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-2); }
.console-figure-note { font-size: 0.75rem; color: var(--text-3); }
.console-note { font-size: 0.7rem; color: var(--text-3); margin: 0.4rem 0 0; max-width: 60ch; }
.console-more { font-size: 0.8rem; }

.burndown-figure { margin: 0; max-width: 680px; }
.burndown { width: 100%; height: auto; display: block; }
.burndown-grid { stroke: var(--border); stroke-width: 1; }
.burndown-line { fill: none; stroke: #4ade80; stroke-width: 2; stroke-linejoin: round; }
.burndown-projection { stroke: var(--text-3); stroke-width: 2; stroke-dasharray: 3 4; }
.burndown-dot { fill: #4ade80; stroke: var(--bg-card); stroke-width: 2; pointer-events: none; }
.burndown-hit { fill: transparent; }
.burndown-point:hover .burndown-dot { r: 6; }
.burndown-axis { fill: var(--text-3); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; letter-spacing: 0.04em; }

/* Lifecycle: the curve and the stage names are quiet context; the approved stage is the one
   bright mark, and a proposal is a hollow amber mark (waits for the Board). */
.lifecycle { margin-top: 1rem; }
.lifecycle-lead { margin: 0 0 0.3rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); }
.lifecycle-body { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 2rem; }
.lifecycle-figure { margin: 0; flex: 1 1 280px; max-width: 460px; }
.lifecycle-chart { width: 100%; height: auto; display: block; overflow: visible; }
.lifecycle-curve { fill: none; stroke: var(--text-4); stroke-width: 2; stroke-linejoin: round; }
.lifecycle-dot { fill: var(--text-3); }
.lifecycle-mark--approved { fill: var(--text); }
.lifecycle-mark--proposed { fill: var(--bg-card); stroke: var(--board); stroke-width: 2; }
.lifecycle-hit { fill: transparent; }
.lifecycle-waits { fill: var(--board); font-size: 10px; paint-order: stroke; stroke: var(--bg-card); stroke-width: 3px; }
.lifecycle-name { fill: var(--text-2); font-size: 11px; }
.lifecycle-stage--approved .lifecycle-name { fill: var(--text); font-weight: 700; }
.lifecycle-step { fill: var(--text-3); font-size: 9px; }
.lifecycle-text { flex: 1 1 220px; }
.lifecycle-criteria { margin: 0; padding-left: 1.1rem; font-size: 0.9rem; color: var(--text); }
.lifecycle-criteria li + li { margin-top: 0.2rem; }
/* Activity feed, on the dashboard and wherever else it is listed */
.activity-feed { display: flex; flex-direction: column; }
.activity-item { display: flex; gap: 0.6rem; align-items: baseline; padding: 0.35rem 0; border-bottom: 1px solid var(--border-subtle); font-size: 0.85rem; }
.activity-item:last-child { border-bottom: none; }
.activity-actor { font-weight: 600; white-space: nowrap; }
.activity-body { flex: 1; color: var(--text-2); }
.activity-time { white-space: nowrap; font-size: 0.8rem; }

/* Agent detail page */
/* ===== Agent Detail Page ===== */
.agent-detail {
  max-width: 660px;
}

/* Workspace: main content + terminal sidebar */
.agent-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1.5rem;
  align-items: start;
}
.agent-workspace-side {
  position: sticky;
  top: 12px;
}

@media (max-width: 900px) {
  .agent-workspace { grid-template-columns: minmax(0, 1fr); }
  .agent-workspace-side { position: static; }
}

/* Sidebar cards */
.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  overflow: hidden;
}
.agent-card-title {
  font-size: 0.85rem;
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.agent-card-count {
  background: #4f46e5;
  color: #fff;
  font-size: 0.55rem;
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 700;
}
.agent-card .task-checklist { margin: 0; padding: 0.4rem 0.75rem; }
.agent-card-more { margin: 0; padding: 0.3rem 0.75rem; font-size: 0.75rem; }
.agent-card-action { padding: 0.5rem 0.75rem; border-top: 1px solid var(--border); }
.agent-card-action .btn { width: 100%; box-sizing: border-box; text-align: center; }
.agent-card-section {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  line-height: 1.6;
}
.agent-card-section:last-child { border-bottom: none; }
.agent-card-section p { margin: 0.1rem 0; font-size: 0.8rem; color: var(--text); }
.agent-card-section .muted { margin-right: 0.3rem; }

/* Inbox messages */
.agent-inbox-list { }
.agent-inbox-msg {
  display: block;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}
.agent-inbox-msg:last-child { border-bottom: none; }
.agent-inbox-msg:hover { background: var(--bg-hover); text-decoration: none; color: inherit; }
.agent-inbox-msg-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-3);
  margin-bottom: 1px;
}
.agent-inbox-msg-from { font-weight: 600; color: var(--text-2); }
.agent-inbox-msg-subj { font-size: 0.8rem; font-weight: 500; color: var(--text); }
.agent-inbox-msg-preview {
  font-size: 0.72rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-detail h3 {
  font-size: 1rem;
  margin: 0 0 0.5rem;
  color: var(--text);
}

/* Hero */
.agent-detail-hero {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  margin-bottom: 1.25rem;
}

.agent-photo-lg {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.agent-photo-placeholder-lg {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.75rem;
  flex-shrink: 0;
}

.agent-detail-identity {
  flex: 1;
  min-width: 0;
}

.agent-detail-name {
  margin: 0 0 0.2rem;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.agent-detail-name .badge {
  font-size: 0.6rem;
}

.agent-detail-desc {
  color: var(--text-2);
  font-size: 0.85rem;
  margin: 0.35rem 0 0;
  line-height: 1.4;
}

.agent-detail-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.agent-detail-actions {
  flex-wrap: wrap;
  align-items: center;
}

.agent-detail-actions form {
  max-width: none;
  margin: 0;
}

/* Pause, Fire and Edit change the contract, so they sit apart from Message and Meet */
.agent-detail-actions-manage {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.btn-outline, :where(main.standard) form.button_to [type="submit"]:not([class]) {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
}
.btn-outline:hover, :where(main.standard) form.button_to [type="submit"]:not([class]):hover { background: var(--bg-hover); color: var(--text); }
.btn:disabled { opacity: 0.6; pointer-events: none; }
.btn-outline-danger { color: #f87171; }
.btn-outline-danger:hover { border-color: #dc3545; background: #dc3545; color: #fff; }

.agent-detail-subline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.15rem;
}
.agent-detail-model { font-size: 0.8rem; color: var(--text-3); }
/* What a task or teammate executes on (execution_runtime_label); red when it cannot */
.agent-detail-subline .execution-runtime { font-size: 0.8rem; color: var(--text-3); }
.execution-runtime--refused { color: var(--broken); }

/* Admin-only: a small round button on the photo, not a second call to action */
.agent-detail-photo { position: relative; flex-shrink: 0; }
.agent-photo-regenerate-form { position: absolute; right: -2px; bottom: -2px; margin: 0; max-width: none; }
.agent-photo-regenerate {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--bg);
  background: var(--bg-active);
  color: var(--text-2);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.agent-detail-photo:hover .agent-photo-regenerate,
.agent-photo-regenerate:focus-visible { opacity: 1; }
.agent-photo-regenerate:hover { color: var(--text); background: var(--bg-hover); }
@media (hover: none) { .agent-photo-regenerate { opacity: 1; } }

.agent-card-approvals { display: flex; flex-direction: column; }
.agent-card-approvals .approval-card { border: none; border-radius: 0; background: none; }
.agent-card-approvals .approval-card + .approval-card { border-top: 1px solid var(--border-subtle); }

/* Heartbeat pulse bar */
.heartbeat-pulse {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 1.25rem;
}

.heartbeat-pulse-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.heartbeat-pulse-action {
  margin-left: auto;
}

.heartbeat-pulse-action form {
  max-width: none;
  margin: 0;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--universe-colour, var(--border));
  flex-shrink: 0;
}

.pulse-dot--active { animation: pulse-blink 1.5s infinite; }

@keyframes pulse-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.pulse-label {
  font-size: 0.85rem;
  color: var(--text-2);
}

.heartbeat-pulse .heartbeat-actions {
  margin: 0.4rem 0 0;
  padding-left: 1rem;
}

/* Heartbeat actions list */
.heartbeat-actions {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.8rem;
}
.heartbeat-actions li {
  padding: 0.15rem 0;
  color: var(--text-2);
}
.heartbeat-actions li::before {
  content: ">";
  margin-right: 0.35rem;
  color: var(--text-4);
  font-weight: 600;
}
.heartbeat-actions a {
  color: var(--link);
  text-decoration: none;
}
.heartbeat-actions a:hover {
  text-decoration: underline;
}

/* Action toolbar (RPG-style) */
.action-toolbar {
  background: linear-gradient(180deg, #2a1f14 0%, #1a1209 100%);
  border: 2px solid #5c4033;
  border-radius: 5px;
  padding: 6px 10px;
  display: flex;
  gap: 5px;
  align-items: center;
  margin-top: 0.75rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 2px 8px rgba(0,0,0,0.3);
}
.action-tile {
  width: 36px;
  height: 36px;
  background: #1a1a2e;
  border: 2px solid #5c4033;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d4a853;
  cursor: default;
  transition: border-color 0.15s;
  position: relative;
}
.action-tile:hover { border-color: #d4a853; }
.action-tile svg { stroke: #d4a853; }
.action-tile--dim {
  opacity: 0.25;
  filter: grayscale(1);
}
.action-tile--dim:hover { border-color: #5c4033; }
.action-toolbar-sep {
  width: 1px;
  height: 24px;
  background: #5c4033;
  margin: 0 2px;
}
a.action-tile { text-decoration: none; cursor: pointer; }

/* Action form (manual action execution) */
.action-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  margin-top: 0.75rem;
}
.action-form-title {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
}
.action-form .form-group { margin-bottom: 0.6rem; }
.action-form .form-label { display: block; font-size: 0.75rem; font-weight: 500; margin-bottom: 0.2rem; color: var(--text-3); }
.action-form .form-control { width: 100%; padding: 0.35rem 0.5rem; font-size: 0.85rem; border: 1px solid var(--input-border); border-radius: 4px; box-sizing: border-box; background: var(--input-bg); color: var(--text); }
.action-form textarea.form-control { resize: vertical; }
.form-row { display: flex; gap: 0.75rem; }
.form-row .form-group { flex: 1; }
.action-form-buttons { margin-top: 0.75rem; display: flex; gap: 0.5rem; }

/* Sections */
.agent-detail-section {
  margin-bottom: 1.25rem;
}

.agent-detail-section strong {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  margin-bottom: 0.1rem;
}

.agent-detail-section p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-2);
  line-height: 1.4;
}

/* Org chart */
.agent-detail-org p {
  margin: 0 0 0.15rem;
}

/* About (collapsible) */
.agent-detail-about {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 1.25rem;
}

.agent-detail-about > summary {
  cursor: pointer;
  list-style: none;
}

.agent-detail-about > summary::-webkit-details-marker { display: none; }

.agent-detail-about > summary h3 {
  display: inline;
  font-size: 0.9rem;
}

.agent-detail-about > summary::before {
  content: "\25B6";
  font-size: 0.6rem;
  margin-right: 0.4rem;
  color: var(--text-4);
}

.agent-detail-about[open] > summary::before {
  content: "\25BC";
}

.agent-detail-about .agent-detail-stats {
  margin-top: 0.75rem;
}

.agent-detail-about .agent-detail-profile {
  margin-top: 0.75rem;
}

.agent-detail-about .agent-detail-meta {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-3);
}

.agent-detail-about .agent-detail-meta p {
  margin: 0.15rem 0;
  font-size: 0.8rem;
  color: var(--text-3);
}

.agent-detail-about .agent-detail-meta strong {
  display: inline;
  font-size: 0.8rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text-3);
  margin-right: 0.25rem;
}

/* Stats */
.agent-detail-stats {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  max-width: 200px;
}

.agent-detail-profile {
  margin-bottom: 0;
}

/* Debug panel (tabbed) */
.agent-detail-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1.25rem;
}

.agent-detail-panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.agent-detail-panel-tabs button {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-3);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.agent-detail-panel-tabs button:hover { color: var(--text); }

.agent-detail-panel-tabs button.active {
  color: var(--text);
  border-bottom-color: #6366f1;
}

.agent-detail-panel-body {
  padding: 0.75rem 0.8rem;
  font-size: 0.85rem;
  color: var(--text);
}

.agent-detail-panel-body .detail-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
  line-height: 1.4;
}

.agent-detail-panel-body .detail-row strong {
  display: inline;
  font-size: 0.8rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text-2);
  min-width: 120px;
  flex-shrink: 0;
}

.agent-detail-panel-body ul {
  margin: 0.25rem 0;
  padding-left: 1.2rem;
  font-size: 0.8rem;
}

.agent-detail-panel-body ul li { margin-bottom: 0.15rem; }

.agent-detail-panel-body .detail-response {
  font-size: 0.75rem;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 0.25rem;
}

.hb-checklist { list-style: none; padding: 0; margin: 0 0 0.75rem 0; font-size: 0.8rem; }
.hb-step { padding: 0.3rem 0 0.3rem 0.25rem; }
.hb-icon { display: inline-block; width: 1.1rem; text-align: center; margin-right: 0.25rem; }
.hb-step--done .hb-icon { color: var(--stopped); }
.hb-step--active .hb-icon { color: var(--moving); }
/* A run cut off at its round limit left work undone, as out_of_attempts does: broken. */
.hb-step--fail .hb-icon, .hb-step--warn .hb-icon { color: var(--broken); }
.hb-step--pending .hb-icon { color: var(--text-4); }
.hb-label { font-weight: 500; }

.heartbeat-trace { font-size: 0.8rem; }
.trace-header { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 0.5rem; }
.trace-model { font-weight: 600; }
.trace-meta { color: var(--text-3); font-size: 0.75rem; }
.trace-tools { color: var(--text-3); font-size: 0.7rem; margin-bottom: 0.75rem; word-break: break-word; }
.trace-round { margin-bottom: 0.5rem; padding: 0.4rem 0.5rem; background: var(--bg-inset); border: 1px solid var(--border); border-radius: 4px; }
.trace-round-header { display: flex; justify-content: space-between; margin-bottom: 0.25rem; }
.trace-tool-call { padding: 0.15rem 0 0.15rem 0.75rem; font-size: 0.75rem; line-height: 1.4; }
.trace-tool-name { background: var(--tag-indigo-bg); padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.7rem; }
.trace-tool-args { color: var(--text-3); }
.trace-tool-result { color: #047857; }
.trace-tool-result--error { color: var(--broken); }
.trace-tool-call--error { border-left: 2px solid var(--broken); }
.trace-tool-call--error .trace-tool-name { background: rgba(220, 38, 38, 0.15); color: var(--broken); }
.trace-summary { margin-top: 0.5rem; font-size: 0.75rem; }

.activity-timeline {
  list-style: none;
  padding: 0;
  margin: 0;
}

.activity-timeline li {
  display: flex;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.8rem;
}

.activity-timeline li:last-child { border-bottom: none; }
.activity-timeline .activity-time { color: #94a3b8; min-width: 90px; flex-shrink: 0; }
.activity-timeline .activity-action { font-weight: 500; min-width: 110px; }
.activity-timeline .activity-detail { color: #64748b; }

.badge-sm { font-size: 0.6rem; padding: 0.1rem 0.35rem; }

/* Danger button */
.btn-danger {
  background-color: var(--broken);
  border-color: var(--broken);
  color: #fff;
}

.btn-danger:hover {
  background-color: #c82333;
  border-color: #bd2130;
}

.btn-secondary {
  background-color: #6c757d;
  border-color: #6c757d;
  color: #fff;
}

.btn-secondary:hover {
  background-color: #5a6268;
  border-color: #545b62;
}

/* ===== Clean-up: settings and teammates ===== */
/* A settings page (Settings, Account): each section card has its description on the left and
   its controls on the right. The page opts in with content_for :main_class, "standard settings".
   main.settings is not in :where(), so these win over the standard section rules above. */
main.settings > section { display: grid; grid-template-columns: 1fr 2fr; gap: 1rem 2rem; align-items: start; }
main.settings > section > header { display: block; padding: 0; }
main.settings > section > header h2 { margin: 0; }
main.settings > section > header p { margin: 0.25rem 0 0; color: var(--text-3); font-size: 0.9rem; }
main.settings > section > :not(header) { grid-column: 2; min-width: 0; }
main.settings > section > :not(header) > :last-child { margin-bottom: 0; }
/* A button_to in a button row is as big as the row's other buttons. */
main.settings .actions form.button_to { margin: 0; }
main.settings .actions form.button_to > [type="submit"] { padding: 0.75rem 1.5rem; font-weight: 500; border-radius: 0.375rem; }
/* Two danger zones sit together; the button sits flush at the right. */
:where(main.standard) > footer + footer { margin-top: 1rem; }
main.standard > footer > form.button_to { margin: 0; }
/* A danger zone with a form of its own (Clear parts) reads like a section: its words on the
   left, its controls on the right, so the text of the summary never moves the columns. */
main.settings > footer:has(> form:not(.button_to)) { display: grid; grid-template-columns: 1fr 2fr; gap: 1rem 2rem; align-items: start; }
main.settings > footer > form:not(.button_to) { margin: 0; }
@media (max-width: 640px) {
  main.settings > section, main.settings > footer:has(> form:not(.button_to)) { grid-template-columns: 1fr; }
  main.settings > section > :not(header) { grid-column: 1; }
  /* The 48 hourly cells share the row's width instead of pushing the page wide. */
  .pulse-cells, .pulse-cell { min-width: 0; }
}
/* hidden means hidden: a component's own display rule (the hire button's form, the terminal's
   CONNECTION LOST overlay) must not show what the JS has hidden. */
[hidden] { display: none !important; }
.account-identity { display: flex; align-items: center; gap: 0.75rem; margin: 0; }
.account-identity img { width: 3rem; height: 3rem; border-radius: 50%; }
.agent-card-empty { margin: 0; padding: 0.5rem 0.75rem; }
.terminal-widget__connect { background: color-mix(in srgb, var(--crt-green) 12%, transparent); color: var(--crt-green); border-color: var(--crt-green); }
.profile-photo { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; }

/* ===== Dashboard: active first ===== */
/* The one rail icon for every stopped company: grey, as stopped on purpose. */
.rail-stopped {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #2d2d44;
  color: var(--stopped);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.rail-stopped:hover { background: #3d3d5c; color: #fff; text-decoration: none; }
.company-group-heading { margin: 2.5rem 0 0.25rem; font-size: 1.1rem; color: var(--text-3); }
.company-group-note { margin: 0 0 1rem; font-size: 0.85rem; color: var(--text-3); }
/* The footer wraps instead of pushing the approvals count past the card's edge. */
.company-card-footer { flex-wrap: wrap; row-gap: 0.5rem; }
.company-card-stat { white-space: nowrap; display: inline-flex; align-items: center; gap: 0.25rem; }
.icon { flex: none; }
/* Read out by a screen reader, not drawn. */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ===== Company Cards (cross-company dashboard) ===== */
.company-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.company-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  background: var(--bg-card);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, transform 0.2s;
  min-height: 160px;
}

.company-card:hover {
  box-shadow: 0 4px 12px var(--shadow);
  transform: translateY(-1px);
  text-decoration: none;
  color: inherit;
}

.company-card-link {
  display: flex;
  flex-direction: column;
  flex: 1;
  text-decoration: none;
  color: inherit;
}
.company-card-link:hover { text-decoration: none; color: inherit; }

.company-card-icon {
  margin-bottom: 0.75rem;
}

.company-card-initials {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #4f46e5;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.company-card-body {
  flex: 1;
}

.company-card-name {
  display: block;
  font-size: 1.1rem;
  color: var(--text);
}

.company-card-mission {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--text-3);
  line-height: 1.4;
}

.company-card-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.company-card-stat {
  font-size: 0.8rem;
  color: var(--text-3);
}

.company-card-pending {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--board);
  padding: 0.1rem 0.5rem;
  border-radius: 9999px;
}

.company-card-pending svg {
  stroke: currentColor;
}

/* "New company" card */
.company-card-new {
  border: 2px dashed var(--border);
  background: transparent;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--text-4);
}

.company-card-new:hover {
  border-color: var(--text-3);
  color: var(--text-3);
  background: var(--bg-hover);
}

.company-card-new-icon {
  color: inherit;
}

.company-card-new-label {
  font-size: 0.9rem;
  font-weight: 500;
}

/* Context window bar */
.context-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 80px;
}
.context-bar-fill {
  height: 6px;
  border-radius: 3px;
  flex: 1;
  background: var(--border);
  position: relative;
  overflow: hidden;
}
.context-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 3px;
  background: var(--text-3);
}
/* Plan limits: one track per window, its used part, and a tick at how far through the window
   now is: neutral, taller than the track, and ringed so it reads over any fill. */
.usage-track { position: relative; height: 6px; background: var(--border); border-radius: 3px; }
.usage-track span { display: block; height: 100%; background: var(--universe-colour); min-width: 2px; border-radius: inherit; }
.usage-track .usage-tick { position: absolute; top: -3px; bottom: -3px; width: 2px; height: auto; min-width: 0; margin-left: -1px; background: var(--text-2); box-shadow: 0 0 0 1px var(--bg); border-radius: 1px; }
/* The account page: one bar, the session window thick on top, the week thin under it; each
   tick stands out on its own side. */
.usage-bar { display: grid; grid-template-rows: 10px 4px; gap: 2px; background: var(--border); border-radius: 4px; margin: 0.5rem 0; }
.usage-bar .usage-track { height: auto; background: none; border-radius: 4px 4px 0 0; }
.usage-bar .usage-track + .usage-track { border-radius: 0 0 4px 4px; }
.usage-bar .usage-track .usage-tick { top: -4px; bottom: 0; }
.usage-bar .usage-track + .usage-track .usage-tick { top: 0; bottom: -5px; }
.usage-windows { display: grid; grid-template-columns: auto 1fr auto; gap: 0.1rem 1rem; margin: 0; }
.usage-windows dt { font-weight: 600; }
.usage-windows dd { margin: 0; font-variant-numeric: tabular-nums; }
.usage-windows strong { color: var(--universe-colour); margin-left: 0.5rem; }
td .usage-windows { grid-template-columns: auto auto; white-space: nowrap; } td .usage-windows dd.muted { grid-column: 2; }
@media (max-width: 640px) { .usage-windows { grid-template-columns: auto 1fr; } .usage-windows dd.muted { grid-column: 2; } }
/* The list of accounts: the CLI's mark and name over a muted line, and per pool one small bar
   per window with its short name; the numbers are in the pool's tooltip. */
.accounts-table .muted { font-size: 0.75rem; white-space: nowrap; margin-top: 0.15rem; }
.account-name { display: flex; align-items: center; gap: 0.4rem; white-space: nowrap; }
.provider-icon { width: 1rem; height: 1rem; flex: none; color: var(--text-2); }
.usage-pools { display: grid; gap: 0.4rem; max-width: 26rem; }
.usage-pool { display: grid; grid-template-columns: 4.5rem 1.25rem minmax(6rem, 1fr) 1.75rem; gap: 2px 0.35rem; align-items: center; font-size: 0.68rem; line-height: 1; color: var(--text-3); }
.usage-pool-name { grid-column: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usage-key { grid-column: 2; }
.usage-pool .usage-track { grid-column: 3; }
.usage-note { grid-column: 4; color: var(--universe-colour); font-weight: 700; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form.button_to + form.button_to { margin-left: 0.35rem; }
/* On a phone each account stacks, so its limits and actions show without a sideways scroll. */
@media (max-width: 640px) {
  .accounts-table thead { display: none; }
  .accounts-table tbody { display: block; }
  .accounts-table tr { display: grid; padding: 0.5rem 0; }
  .accounts-table td { padding: 0.2rem 10px; }
  .accounts-table .row-actions { text-align: left; }
}
.context-pct {
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.badge-executing {
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Contracts toolbar */
.contracts-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.contracts-filters { display: flex; gap: 0.5rem; }
.filter-pill { padding: 0.25rem 0.75rem; border-radius: 1rem; font-size: 0.8rem; font-weight: 500; text-decoration: none; color: var(--text-3); border: 1px solid var(--border); transition: all 0.15s; }
.filter-pill:hover { color: var(--text-2); border-color: var(--text-3); }
.filter-pill-active { background: #6366f1; color: #fff; border-color: #6366f1; }
.filter-pill-active:hover { background: #5558e6; color: #fff; }
.contracts-views { display: flex; gap: 0.25rem; }
.view-icon { padding: 0.3rem 0.5rem; border-radius: 0.375rem; font-size: 1rem; text-decoration: none; color: var(--text-3); border: 1px solid transparent; transition: all 0.15s; }
.view-icon:hover { color: var(--text-2); background: var(--bg-hover); }
.view-icon-active { color: var(--link); background: var(--tag-indigo-bg); border-color: var(--border); }
.empty-state { text-align: center; padding: 3rem; color: var(--text-4); }

/* Contracts list view */
.contracts-list { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.contracts-list th { text-align: left; padding: 0.5rem 0.75rem; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); border-bottom: 2px solid var(--border); }
.contracts-list td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.contracts-list tbody tr:hover { background: var(--bg-hover); }
.contracts-list-name { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; color: inherit; font-weight: 500; }
.contracts-list-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.contracts-list-avatar-placeholder { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--bg-hover); color: var(--text-3); font-size: 0.65rem; font-weight: 700; }

/* Org tree view */
.org-tree { display: flex; flex-direction: column; align-items: center; padding: 1rem 0; overflow-x: auto; }
.org-tree-branch { display: flex; flex-direction: column; align-items: center; position: relative; }
.org-tree-node { display: flex; flex-direction: column; align-items: center; gap: 0.25rem; padding: 0.75rem 1rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: inherit; transition: box-shadow 0.15s; min-width: 100px; text-align: center; }
.org-tree-node:hover { box-shadow: 0 2px 8px var(--shadow); text-decoration: none; }
.org-tree-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.org-tree-avatar-placeholder { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: var(--bg-hover); color: var(--text-3); font-size: 0.75rem; font-weight: 700; }
.org-tree-name { font-size: 0.8rem; font-weight: 600; }
.org-tree-role { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--link); }
.org-tree-level { display: flex; justify-content: center; gap: 2rem; position: relative; padding-top: 3rem; }
.org-tree-level::before { content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 2px; height: 1.5rem; background: var(--border); }
.org-tree-level > .org-tree-branch::before { content: ""; position: absolute; top: -1.5rem; left: 50%; transform: translateX(-50%); width: 2px; height: 1.5rem; background: var(--border); }
.org-tree-level > .org-tree-branch:not(:only-child)::after { content: ""; position: absolute; top: -1.5rem; height: 2px; background: var(--border); }
.org-tree-level > .org-tree-branch:first-child:not(:only-child)::after { left: 50%; right: calc(-1rem - 1px); }
.org-tree-level > .org-tree-branch:last-child:not(:only-child)::after { right: 50%; left: calc(-1rem - 1px); }
.org-tree-level > .org-tree-branch:not(:first-child):not(:last-child)::after { left: calc(-1rem - 1px); right: calc(-1rem - 1px); }
.org-tree > .org-tree-branch + .org-tree-branch { margin-top: 1.5rem; }
.org-tree-section { margin-top: 2rem; width: 100%; }
.org-tree-section-title { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-4); margin-bottom: 0.75rem; text-align: center; }
@media (max-width: 640px) {
  .org-tree { align-items: flex-start; min-width: min-content; }
  .org-tree-level { gap: 1rem; }
  .org-tree-level > .org-tree-branch:first-child:not(:only-child)::after { right: calc(-0.5rem - 1px); }
  .org-tree-level > .org-tree-branch:last-child:not(:only-child)::after { left: calc(-0.5rem - 1px); }
  .org-tree-level > .org-tree-branch:not(:first-child):not(:last-child)::after { left: calc(-0.5rem - 1px); right: calc(-0.5rem - 1px); }
}

/* ===== Standard page =====
   Plain elements in main.standard get the house structure, so a view needs no classes:
   header (the layout's h1 and a nav of actions), section cards, a footer danger zone, dl, table
   and form. The rules sit in :where(), so any class on an element still wins over them; a dl
   with a class is its own component and keeps its own layout. */
:where(main) > header { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; padding-bottom: 1.5rem; }
:where(main) > header h1 { margin: 0; font-size: 1.6rem; }
:where(main.standard) nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; background: none; padding: 0; }
/* The layout draws the header on full pages too, so its rules are not limited to main.standard.
   Its actions may shrink, so a wide bar (the universe views) scrolls inside itself on a phone. */
:where(main) > header > nav, :where(main) > header > nav > * { min-width: 0; max-width: 100%; }
:where(main) > header > nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; background: none; padding: 0; margin-left: auto !important; }
:where(main.standard) nav a { margin-right: 0; }
:where(main.standard) nav a:not([class]) { color: var(--link); }
:where(main.standard) > header + p { color: var(--text-3); margin: -0.75rem 0 1.5rem; }
/* A card. A section inside a card is not a card again. */
:where(main.standard) section:not(section section) { background: var(--bg-card); border-radius: 8px; padding: 1.25rem 1.5rem; margin-bottom: 1rem; }
:where(main.standard) section h2 { font-size: 1.05rem; margin: 0 0 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
:where(main.standard) section h3 { font-size: 0.95rem; margin: 1.25rem 0 0.5rem; }
:where(main.standard) section > :last-child { margin-bottom: 0; }
:where(main.standard) section > header { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; flex-wrap: wrap; padding-bottom: 0.75rem; }
:where(main.standard) section > header h2 { margin: 0; }
/* Removing something is a choice, not a fault, so it is not red: space and a confirm set it apart. */
:where(main.standard) > footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 2.5rem; background: var(--bg-card); border-radius: 8px; padding: 1.25rem 1.5rem; }
:where(main.standard) > footer h2 { font-size: 1.05rem; margin: 0; }
:where(main.standard) > footer p { color: var(--text-3); font-size: 0.9rem; margin: 0.25rem 0 0; }
:where(main.standard) dl:not([class]) { display: grid; grid-template-columns: 10rem 1fr; gap: 0.5rem 1rem; margin: 0; }
:where(main.standard) dl:not([class]) > dt { color: var(--text-3); }
:where(main.standard) dl:not([class]) > dd { margin: 0; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
/* Forms sit left under the text they belong to, not centred in the column. */
:where(main.standard) form { margin: 0 0 1rem; }
:where(main.standard) form > div { margin-bottom: 1rem; }
:where(main.standard) form > div > label { display: block; margin-bottom: 0.35rem; font-weight: 500; color: var(--text-2); }
:where(main.standard) form :is(input:is([type="text"], [type="email"], [type="password"], [type="number"], [type="tel"], [type="url"], [type="search"], [type="date"], [type="datetime-local"], :not([type])), textarea, select) {
  width: 100%; box-sizing: border-box; padding: 0.5rem 0.75rem; font: inherit; color: var(--text);
  background: var(--input-bg); border: 1px solid var(--input-border); border-radius: 0.375rem;
}
:where(main.standard) form :is(input, textarea, select):focus { outline: 0; border-color: var(--focus-border); box-shadow: 0 0 0 0.2rem var(--focus-ring); }
/* The last of several submit buttons (Reject, Cancel) sits at the far end, away from the first. */
/* A form's submit row is its last div: big buttons at the right, where the form ends. */
:where(main) form:not(.button_to) > div:last-child:has(> [type="submit"]), .actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }
:where(main) form:not(.button_to) > div:last-child > :is([type="submit"], .btn), .actions :is([type="submit"], .btn) { padding: 0.75rem 1.5rem; font-weight: 500; border-radius: 0.375rem; }
:where(main.standard) form > div:has(> [type="submit"] + [type="submit"]) { display: flex; flex-wrap: wrap; gap: 0.5rem; }
:where(main.standard) form > div:has(> [type="submit"] + [type="submit"]) > [type="submit"]:last-child { margin-left: auto; }
/* button_to: inline, so several in a row are a button row. */
/* A form with one field and no field divs puts its button on the input's row. */
:where(main.standard) form:not(.button_to):not(:has(> div)):has(> [type="submit"]) { display: flex; gap: 0.5rem; align-items: stretch; }
:where(main.standard) form:not(.button_to):not(:has(> div)) > :is(input, select):not([type="hidden"], [type="submit"]) { flex: 1; min-width: 0; width: auto; }
:where(main.standard) form.button_to { display: inline-block; max-width: none; margin: 0 0.5rem 0.5rem 0; }
:where(main.standard) nav form.button_to, :where(main.standard) td form.button_to { margin: 0; }
@media (max-width: 640px) {
  :where(main) > header, :where(main.standard) > footer { flex-direction: column; align-items: stretch; }
  :where(main) > header > nav { margin-left: 0 !important; }
  :where(main.standard) dl:not([class]) { grid-template-columns: 1fr; gap: 0; }
  :where(main.standard) dl:not([class]) > dd { margin-bottom: 0.5rem; }
  /* A wide table scrolls inside itself, not the page. */
  :where(main.standard) table { display: block; overflow-x: auto; }
  .settings-section { grid-template-columns: 1fr; gap: 1rem; }
}

/* Auth steps checklist */
.auth-steps {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
}
.auth-step {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  font-size: 0.9rem;
  color: var(--text-3);
}
.auth-step-icon {
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
  font-size: 0.95rem;
}
.auth-step--done { color: var(--stopped); }
.auth-step--done .auth-step-icon { font-weight: 700; }
.auth-step--active { color: var(--link-hover); font-weight: 500; }
.auth-step-body { flex-basis: 100%; padding: 0.25rem 0 0.5rem 1.75rem; color: var(--text); font-weight: 400; }
.auth-step-body p { margin: 0 0 0.75rem; }
.auth-step-spinner { animation: auth-spin 1.2s linear infinite; display: inline-block; }
@keyframes auth-spin { to { transform: rotate(360deg); } }
.auth-step--pending { color: var(--text-4); }
.auth-step-timer {
  font-size: 0.8rem;
  color: var(--text-3);
  font-weight: 400;
  margin-left: 0.25rem;
  font-variant-numeric: tabular-nums;
}

/* ===== Clean-up: Board pages ===== */
/* Rendered text (Markdown, simple_format) starts at the top of its card or its detail. */
:where(main.standard) :is(section, dd) > :first-child { margin-top: 0; }
:where(main.standard) dd > :last-child { margin-bottom: 0; }
/* Markdown source is edited as code. */
.wiki-source { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8125rem; }
/* Reject is the last decision on a card, at the far end, away from Approve. */
.approval-actions > :last-child { margin-left: auto; }
/* The replies in a profile conversation, one under the other. */
.response + .response { border-top: 1px solid var(--border-subtle); margin-top: 1rem; padding-top: 1rem; }
:where(main.standard) section .response h3 { margin-top: 0; }
/* The context bar is a full-width track; its fill is the share of the window the run used. */
.context-bar-fill::after { right: auto; width: var(--pct, 100%); }

/* Task checklist on contract show */
.task-checklist {
  list-style: none;
  padding: 0;
  margin: 0;
}
.task-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.85rem;
  color: var(--text-secondary, #9ca3af);
}
.task-check-icon {
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
  font-size: 0.95rem;
}
.task-check--done { color: var(--text-secondary, #6b7280); }
.task-check--done .task-check-icon { color: var(--stopped); }
.task-check--done .task-check-title { text-decoration: line-through; opacity: 0.6; }
.task-check--in_progress { color: var(--text-primary, #e2e8f0); font-weight: 500; }
.task-check--in_progress .task-check-icon { color: var(--moving); }
.task-check-spinner { animation: auth-spin 1.2s linear infinite; display: inline-block; }
.task-check-title { color: inherit; text-decoration: none; }
.task-check-title:hover { text-decoration: underline; }
.task-check-meta {
  font-size: 0.75rem;
  color: var(--text-secondary, #6b7280);
  margin-left: auto;
  flex-shrink: 0;
}

.terminal-output {
  background: #1a1b26;
  color: #a9b1d6;
  font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 0.8rem;
  line-height: 1.4;
  padding: 0.75rem;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-y: auto;
  height: 24em;
  margin: 0;
}

/* Profile grid */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.profile-card, .profile-card * {
  text-decoration: none;
}
.profile-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  color: inherit;
  transition: box-shadow 0.2s, transform 0.2s;
  min-height: 200px;
}
.profile-card:hover {
  box-shadow: 0 4px 12px var(--shadow);
  transform: translateY(-1px);
}
.profile-card-avatar {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
}
.profile-card-photo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
}
.profile-card-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-4);
  font-size: 1.1rem;
}
.profile-card-name {
  font-weight: 600;
  font-size: 1rem;
  text-align: center;
  margin-bottom: 0.4rem;
}
.profile-card-desc {
  font-size: 0.85rem;
  color: var(--text-3);
  line-height: 1.4;
  flex: 1;
  margin-bottom: 0.5rem;
}
.profile-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.profile-tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
}
.profile-tag-strength {
  background: var(--tag-green-bg);
  color: var(--tag-green-text);
}
.profile-tag-interest {
  background: var(--tag-blue-bg);
  color: var(--tag-blue-text);
}

/* Homepage */
.home-hero {
  text-align: center;
  padding: 3rem 1.5rem 1.5rem;
}
.home-headline {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 0.5rem;
}
.home-subtext {
  font-size: 1rem;
  color: var(--text-3);
  margin: 0 auto 1.5rem;
  max-width: 420px;
}
.home-google-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1.75rem;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 2px 8px var(--shadow);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.home-google-btn:hover {
  box-shadow: 0 4px 12px var(--shadow);
  border-color: #4285F4;
}
.home-header-google-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 1px 2px var(--shadow);
}
.home-header-google-btn:hover {
  box-shadow: 0 2px 6px var(--shadow);
  border-color: #4285F4;
}
.home-reassurance {
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-4);
}
.home-profiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  padding: 1rem 2rem 1.5rem;
  max-width: 640px;
  margin: 0 auto;
}
.home-profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  transition: box-shadow 0.15s;
}
.home-profile-card:hover {
  box-shadow: 0 2px 8px var(--shadow);
}
.home-profile-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  margin: 0 auto 0.5rem;
  overflow: hidden;
}
.home-profile-photo {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 50%;
}
.home-profile-initials {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e1b4b, #312e81);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--link);
  font-weight: 700;
}
.home-profile-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.home-profile-role {
  font-size: 0.7rem;
  color: var(--text-3);
  margin-top: 0.15rem;
}
.home-profile-tags {
  display: flex;
  gap: 0.25rem;
  justify-content: center;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.home-profile-tag {
  font-size: 0.6rem;
  background: var(--tag-indigo-bg);
  color: var(--tag-indigo-text);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}
.simple-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Content container for the no-company layout. Without a max-width, main spans
   the viewport, and a short form or heading is lost at the left of a wide screen. */
.simple-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0.25rem 1rem 1rem;
  box-sizing: border-box;
}

/* Site footer (logged-out pages only) */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 1.5rem 1rem;
  text-align: center;
}
.site-footer-inner {
  max-width: 540px;
  margin: 0 auto;
}
.site-footer-copy {
  font-size: 0.8rem;
  color: var(--text-3);
  margin: 0 0 0.75rem;
}
.site-footer-legal {
  font-size: 0.7rem;
  color: var(--text-4);
  line-height: 1.5;
  margin: 0 0 0.75rem;
}
.site-footer-links {
  font-size: 0.75rem;
  margin: 0;
}
.site-footer-links a {
  color: var(--text-3);
  text-decoration: none;
}
.site-footer-links a:hover {
  text-decoration: underline;
}
.site-footer-sep {
  color: var(--text-4);
  margin: 0 0.4rem;
}
/* Legal pages */
.legal-page {
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
}
.legal-page h1 {
  font-size: 1.4rem;
  margin: 0 0 0.25rem;
}
.legal-page h2 {
  font-size: 1rem;
  margin: 1.5rem 0 0.5rem;
  color: var(--text);
}
.legal-page p, .legal-page ul {
  font-size: 0.85rem;
  color: var(--text-2);
}
.legal-page ul {
  padding-left: 1.25rem;
}
.legal-effective {
  font-size: 0.8rem;
  color: var(--text-4);
  margin: 0 0 1.5rem;
}
@media (max-width: 600px) {
  .home-profiles {
    grid-template-columns: 1fr;
    max-width: 300px;
  }
  .home-headline {
    font-size: 1.4rem;
  }
}

/* Optional-section checkboxes beside the company export button */
.export-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.export-option {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--text-2);
}
.export-option input { margin-top: 0.2rem; }
.export-option-body { display: block; }

/* Label and cost share a line — that pair is the decision. The description
   sits underneath so the two never run together. */
.export-option-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.export-option-name { color: var(--text); }
.export-option-meta {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}
.export-option-hint {
  display: block;
  margin-top: 0.1rem;
  color: var(--text-3, var(--text-2));
  opacity: 0.7;
  font-size: 0.8rem;
}

/* Sortable table headers and pagination */
.activity-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  color: var(--text-2);
  font-size: 0.85rem;
}
.sort-header {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.sort-header:hover { color: var(--text); }
.sort-header--active { color: var(--text); }
.sort-header-marker { font-size: 0.7em; opacity: 0.7; }

.pagy-nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  font-size: 0.85rem;
}
.pagy-nav a,
.pagy-nav span {
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-2);
  text-decoration: none;
}
.pagy-nav a:hover { color: var(--text); border-color: var(--text-2); }
.pagy-nav .current {
  color: var(--text);
  background: var(--bg-card);
  border-color: var(--text-2);
}
.pagy-nav .gap { border-color: transparent; }


/* ===== Mailbox: conversations as an email client =====
   One surface, not a stack of panels. The thread list and the reading pane are
   two regions of the same screen, split by a single hairline, each scrolling on
   its own. Same tokens and type scale as the rest of the app; none of the
   dashboard's panel frame, because a mail client is mostly content.
   The negative margin cancels the padding on <main> so the surface reaches the
   window edges and fills the height. */
.mailbox { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: calc(100% + 32px); margin: -16px -24px; background: var(--bg); }

.mailbox-list { border-right: 1px solid var(--border); overflow-y: auto; min-height: 0; }
.mailbox-empty { font-size: 0.8rem; color: var(--text-3); padding: 1rem 0.9rem; margin: 0; }

.mail-row { display: flex; gap: 0.6rem; padding: 0.6rem 0.9rem 0.6rem 0.75rem; border-bottom: 1px solid var(--border-subtle); border-left: 2px solid transparent; color: inherit; text-decoration: none; }
.mail-row-text { flex: 1; min-width: 0; }
.mail-row:hover { background: var(--bg-hover); text-decoration: none; }
.mail-row--open { background: var(--bg-active); border-left-color: var(--focus-border); }
.mail-row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.mail-row-from { font-size: 0.82rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row-time { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.62rem; letter-spacing: 0.04em; color: var(--text-3); white-space: nowrap; }
.mail-row-subject { font-size: 0.78rem; color: var(--text-2); margin-top: 0.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row-preview { display: flex; align-items: baseline; gap: 0.4rem; margin-top: 0.1rem; }
.mail-row-snippet { flex: 1; min-width: 0; font-size: 0.72rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row-count { flex: 0 0 auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.6rem; color: var(--text-3); border: 1px solid var(--border); border-radius: 8px; padding: 0 0.32rem; }

.mailbox-reading { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.mail-thread-head { padding: 0.8rem 1.4rem 0.7rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.mail-thread-subject { font-size: 1.05rem; font-weight: 600; margin: 0; color: var(--text); }
.mail-thread-meta { font-size: 0.72rem; color: var(--text-3); margin: 0.15rem 0 0; }
.mail-thread-empty { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 0.82rem; color: var(--text-3); }
.mail-thread-body { flex: 1; overflow-y: auto; min-height: 0; padding: 0.4rem 1.4rem 1.4rem; }

/* A Board message sits flush left; a teammate reply is inset. The two never
   read the same, without either being boxed. */
.mail-message { border-left: 2px solid var(--border); padding: 0.7rem 0 0.7rem 0.85rem; border-bottom: 1px solid var(--border-subtle); }
.mail-message--board { border-left-color: var(--focus-border); }
.mail-message--teammate { border-left-color: #4ade80; margin-left: 2rem; }
.mail-message-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.3rem; }
/* A face, a name, a time. No card, no border. */
.mail-avatar { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.mail-avatar--initials { display: flex; align-items: center; justify-content: center; background: var(--bg-hover); color: var(--text-3); font-size: 0.6rem; font-weight: 700; letter-spacing: 0.02em; }
.mail-row .mail-avatar { width: 26px; height: 26px; margin-top: 0.1rem; }
.mail-message-from { font-size: 0.82rem; color: var(--text); }
.mail-message-role { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.58rem; letter-spacing: 0.08em; color: var(--text-3); }
.mail-message-time { margin-left: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.62rem; color: var(--text-3); white-space: nowrap; }
.mail-message-body { font-size: 0.86rem; line-height: 1.55; color: var(--text-2); }
.mail-message-body p { margin: 0 0 0.6rem; }
.mail-message-body p:last-child { margin-bottom: 0; }
.mail-attachments { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }
.mail-attachment { display: inline-flex; align-items: baseline; gap: 0.45rem; font-size: 0.74rem; color: var(--link); border: 1px solid var(--border); border-radius: 3px; padding: 0.2rem 0.5rem; text-decoration: none; }
.mail-attachment:hover { border-color: var(--focus-border); text-decoration: none; }
.mail-attachment-meta { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.62rem; letter-spacing: 0.03em; color: var(--text-3); }

/* The reply is the next message in the thread, so it wears the same left rule
   as a Board message and names who it goes to. */
.mailbox-reading .mail-reply { max-width: none; margin: 0; padding: 0.7rem 0 0 0.85rem; border-left: 2px solid var(--focus-border); }
.mail-held { display: flex; align-items: center; gap: 0.8rem; } .mail-held p { margin: 0; flex: 1; }
.mail-reply-to { font-size: 0.82rem; color: var(--text); margin-bottom: 0.35rem; }
.mail-reply-box { display: block; box-sizing: border-box; width: 100%; resize: vertical; font-family: inherit; font-size: 0.86rem; line-height: 1.55; color: var(--text); background: var(--input-bg); border: 1px solid var(--input-border); border-radius: 4px; padding: 0.5rem 0.6rem; }
.mail-reply-box:focus { outline: none; border-color: var(--focus-border); box-shadow: 0 0 0 3px var(--focus-ring); }
.mail-reply-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 0.8rem; margin-top: 0.5rem; }
.mail-reply-file { font-size: 0.7rem; color: var(--text-3); max-width: 16rem; }
.mail-reply-file::file-selector-button { font-family: inherit; font-size: 0.7rem; color: var(--text-2); background: var(--bg-hover); border: 1px solid var(--border); border-radius: 3px; padding: 0.2rem 0.55rem; margin-right: 0.5rem; cursor: pointer; }
.mail-reply-send { font-size: 0.78rem; font-weight: 600; color: #fff; background: var(--focus-border); border: none; border-radius: 4px; padding: 0.3rem 1rem; cursor: pointer; }
.mail-reply-send:hover { background: var(--link); }
.mail-reply-note { font-size: 0.68rem; color: var(--text-3); }

@media (max-width: 900px) {
  .mailbox { grid-template-columns: 1fr; height: auto; }
  .mailbox-list { border-right: none; border-bottom: 1px solid var(--border); max-height: 40vh; }
}

/* Universe: the company's work under its charter. The colour says what kind of step moves it. */
.universe-charter { border-left: 4px solid var(--border); padding-left: 1rem; margin-bottom: 1.5rem; }
.universe-causes, .universe-tree, .universe-tree ul { list-style: none; padding-left: 0; }
.universe-tree ul { padding-left: 1.25rem; border-left: 1px solid var(--border-subtle); margin-left: 0.4rem; }
.universe-tree summary { cursor: pointer; padding: 0.25rem 0; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.universe-hold { border-left: 3px solid var(--universe-colour, var(--border)); padding: 0.2rem 0 0.2rem 0.6rem; margin: 0.2rem 0 0.2rem 1rem; font-size: 0.9em; }
.universe-broken { --universe-colour: var(--broken); }
.universe-board { --universe-colour: var(--board); }
.universe-waiting { --universe-colour: var(--waiting); }
.universe-stopped { --universe-colour: var(--stopped); }
.universe-moving { --universe-colour: var(--moving); }
.universe-node > details > summary::before { content: ''; width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--universe-colour, var(--border)); }
.universe-done > details > summary, .universe-closed > details > summary { opacity: 0.55; }
.universe-views { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.universe-views a { padding: 0.5rem 1rem; border-bottom: 2px solid transparent; color: var(--text-3); white-space: nowrap; }
.universe-views a.active { color: var(--text); border-bottom-color: #6366f1; }
/* Causes: one row per cause, the bar on one scale, the whole row a target. */
.universe-causes summary { display: grid; grid-template-columns: minmax(14rem, 34%) 1fr 3ch; gap: 0.75rem; align-items: center; padding: 0.5rem; border-radius: 6px; cursor: pointer; list-style: none; }
.universe-causes summary:hover { background: var(--bg-hover); }
.universe-cause-label { font-weight: 600; }
.universe-cause-label small { display: block; font-weight: 400; }
.universe-bar span { display: block; height: 14px; min-width: 2px; border-radius: 2px; background: var(--universe-colour); }
.universe-count { text-align: right; font-variant-numeric: tabular-nums; }
.universe-held { margin: 0 0 0.5rem calc(34% + 1.25rem); font-size: 0.9em; }
.universe-held ul { padding-left: 1rem; }
/* Outline: a word-sized bar of the open work under each parent; a picked cause dims the rest. */
.universe-stack { display: inline-flex; width: 8rem; height: 8px; border-radius: 2px; overflow: hidden; background: var(--bg-inset); margin-left: auto; }
.universe-stack span { background: var(--universe-colour); }
.universe-dim > details > summary { opacity: 0.35; }
.universe-chip { display: inline-block; border: 1px solid var(--universe-colour); color: var(--universe-colour); border-radius: 12px; padding: 0.1rem 0.6rem; margin: 0.15rem; font-size: 0.8rem; }
.universe-chip.active { background: color-mix(in srgb, var(--universe-colour) 25%, transparent); }
/* Matrix: counts with an aligned bar; empty cells fade. */
.universe-matrix-wrap { overflow-x: auto; }
.universe-matrix { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.universe-matrix th, .universe-matrix td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); text-align: right; position: relative; }
.universe-matrix th:first-child, .universe-matrix td:first-child { text-align: left; }
.universe-matrix thead th { color: var(--text-3); font-weight: 500; font-size: 0.75rem; vertical-align: bottom; }
.universe-matrix thead th span { border-top: 3px solid var(--universe-colour); padding-top: 0.25rem; display: inline-block; }
.universe-matrix td i { position: absolute; left: 0.5rem; bottom: 0.25rem; height: 3px; background: var(--universe-colour); }
.universe-matrix td.zero { color: var(--border); }
/* Icicle: width is open work, colour the worst standing below. */
.universe-icicle { position: relative; height: 480px; background: var(--bg-inset); border-radius: 8px; overflow: hidden; }
.universe-icicle a { position: absolute; box-sizing: border-box; height: 33.333%; border: 1px solid var(--bg-inset); padding: 0.25rem 0.4rem; overflow: hidden; color: var(--text); font-size: 0.75rem; background: color-mix(in srgb, var(--universe-colour, var(--border)) 30%, var(--bg-card)); }
.universe-icicle a:hover { background: color-mix(in srgb, var(--universe-colour, var(--border)) 50%, var(--bg-card)); }
.universe-icicle b, .universe-icicle small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.universe-icicle small { color: var(--text-3); }
.universe-crumbs { color: var(--text-3); }
@media (max-width: 720px) {
  .universe-causes summary { grid-template-columns: 1fr 3ch; }
  .universe-bar { grid-column: 1 / -1; grid-row: 2; }
  .universe-held { margin-left: 0; }
}
.universe-graph { position: relative; }
.universe-graph svg { width: 100%; height: 75vh; display: block; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-inset); cursor: grab; touch-action: none; }
.universe-link { fill: none; stroke: var(--border); stroke-width: 1.5px; }
.universe-cause-link { fill: none; stroke: var(--broken); stroke-width: 1.5px; stroke-dasharray: 5 4; opacity: 0.7; }
.universe-graph-node { cursor: pointer; }
.universe-graph-node circle { fill: var(--universe-colour, var(--border)); stroke: var(--bg-inset); stroke-width: 2px; }
.universe-graph-node text { fill: var(--text); font-size: 12px; }
.universe-graph-node .universe-graph-owner { fill: var(--text-3); font-size: 11px; }
.universe-graph-node.universe-done, .universe-graph-node.universe-closed { opacity: 0.5; }
.universe-graph-detail { position: absolute; right: 1rem; bottom: 1rem; width: 22rem; max-width: calc(100% - 2rem); background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem 1rem; box-shadow: 0 4px 16px var(--shadow); }
.universe-graph-detail .universe-hold { margin-left: 0; }

/* ===== Clean-up: admin pages ===== */
/* A field's hint sits under its input, quiet. */
:where(main.standard) form > div > small { display: block; margin-top: 0.25rem; color: var(--text-3); }
/* A checkbox inside its label sits on the label's line, before the words. */
:where(main.standard) form > div > label > input[type="checkbox"] { margin: 0 0.5rem 0 0; }
/* The current filter in a row of filter links reads as text, not a link. */
:where(main.standard) nav a[aria-current="page"] { color: var(--text); font-weight: 600; }
/* System checks: one card per check, side by side where they fit. */
.system-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.system-checks > section { margin-bottom: 0; }
/* A check's state in the universe palette: green works, red is broken and needs a fix. */
.check-tone { color: var(--universe-colour); font-weight: 600; }

/* A terminal on a teammate's photo while an execution runs for them; red once it hung. */
.photo-with-badge { position: relative; display: inline-block; }
/* Hidden until a state class says an execution runs; the empty span stays for the next broadcast. */
.execution-badge { display: none; position: absolute; right: -3px; bottom: -3px; width: 18px; height: 18px; border-radius: 50%; place-items: center; background: var(--moving); color: var(--bg); border: 2px solid var(--bg); z-index: 1; }
.execution-badge-running, .execution-badge-hung { display: grid; }
.execution-badge svg { width: 11px; height: 11px; }
.execution-badge-running { animation: execution-badge-pulse 2s ease-in-out infinite; }
.execution-badge-hung { background: var(--broken); }
@keyframes execution-badge-pulse { 50% { box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.25); } }
@media (prefers-reduced-motion: reduce) { .execution-badge-running { animation: none; } }

/* Recordings: one player per execution attempt. */
.cast { border: 1px solid var(--border); border-radius: 8px; margin: 0.75rem 0; overflow: hidden; }
.cast-bar { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; padding: 0.5rem 0.75rem; background: var(--bg-card); }
.cast-screen { background: #0a0a0a; padding: 0.5rem; overflow-x: auto; }
.cast-screen:empty { display: none; }

/* Code: what needs the Board first, each line marked in the colour of what it waits for. */
.code-attention ul, .code-milestones, .code-commits, .code-comments ul { list-style: none; padding: 0; margin: 0; }
.code-attention li, .github-permissions { border-left: 4px solid var(--universe-colour); padding: 0.3rem 0.75rem; margin-bottom: 0.3rem; background: var(--bg-card); border-radius: 0 6px 6px 0; }
.code-repo h2 small { font-size: 0.75rem; font-weight: normal; margin-left: 0.75rem; }
.code-repo h3 { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); margin: 1.25rem 0 0.5rem; }
/* A milestone's progress is a length in one neutral fill, not a colour. */
.code-milestones li { display: grid; grid-template-columns: minmax(8rem, 16rem) minmax(6rem, 1fr) auto; gap: 0.75rem; align-items: center; padding: 0.2rem 0; }
.code-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.code-bar-fill { height: 100%; background: var(--text-3); }
.code-commits li, .code-comments li { padding: 0.35rem 0; border-top: 1px solid var(--border-subtle); }
.code-commits li .muted { margin-left: 0.5rem; }
.code-comments blockquote { margin: 0.35rem 0; padding-left: 0.75rem; border-left: 2px solid var(--border); color: var(--text-2); white-space: pre-wrap; }
.code-comments p { margin: 0.35rem 0; }
