/*
 * 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;
}

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;
}
.rail-queue-portrait { background: #a78bfa; }
.rail-queue-hire { background: #34d399; }
.rail-queue-execution { background: #60a5fa; }
.rail-queue-heartbeat { background: #f472b6; }
.rail-queue-active { 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;
}

.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-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  margin-bottom: 4px;
  text-decoration: none;
  color: inherit;
  border-radius: 6px;
}

a.sidebar-user:hover {
  background: var(--bg-hover);
}

.sidebar-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-user-initials {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-user-info {
  overflow: hidden;
  min-width: 0;
}

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

.sidebar-user-email {
  font-size: 11px;
  color: var(--text-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.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); }
.breadcrumb-actions { display: flex; gap: 0.5rem; }
.breadcrumb-actions form { display: inline; margin: 0; }

/* 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;
}

.main-content .notice { color: #059669; margin-bottom: 1rem; }
.main-content .alert { color: #dc2626; margin-bottom: 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; }

/* Override form max-width inside main content */
.main-content form { max-width: 600px; }

/* 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;
}

tbody tr:nth-child(even) { background: var(--bg-card); }
tbody tr:hover { 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;
}

.badge-draft {
  background-color: #6c757d;
  color: white;
}

.badge-pending {
  background-color: #ffc107;
  color: #212529;
}

.badge-active {
  background-color: #28a745;
  color: white;
}

.badge-completed {
  background-color: #17a2b8;
  color: white;
}

.badge-terminated {
  background-color: #dc3545;
  color: white;
}

.badge-expired {
  background-color: #868e96;
  color: white;
}

.badge-paused {
  background-color: #eab308;
  color: #1a1a1a;
}

.badge-founding {
  background-color: #6366f1;
  color: white;
}

/* Pause/resume on hover */
.badge-pausable {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.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;
}
.badge-pausable .badge-pause-btn {
  background: #dc3545;
  color: white;
}
.badge-pausable .badge-resume-btn {
  background: #28a745;
  color: white;
}
.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;
}

.badge-approved {
  background-color: #28a745;
  color: white;
}

.badge-rejected {
  background-color: #dc3545;
  color: white;
}

.badge-revision_requested {
  background-color: #fd7e14;
  color: white;
}

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

/* 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: #dc3545;
  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: #28a745;
  border-radius: 2px;
}

.badge-backlog {
  background-color: #6c757d;
  color: white;
}

.badge-todo {
  background-color: #ffc107;
  color: #212529;
}

.badge-in_progress {
  background-color: #007bff;
  color: white;
}

.badge-done {
  background-color: #28a745;
  color: white;
}

.badge-blocked {
  background-color: #dc3545;
  color: white;
}

.badge-cancelled {
  background-color: #868e96;
  color: white;
}

.badge-priority-urgent {
  background-color: #dc3545;
  color: white;
}

.badge-priority-high {
  background-color: #fd7e14;
  color: white;
}

.badge-priority-medium {
  background-color: #ffc107;
  color: #212529;
}

.badge-priority-low {
  background-color: #6c757d;
  color: white;
}

/* Buttons */
.btn {
  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 {
  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 {
  background-color: #007bff;
  border-color: #007bff;
}

.btn-primary: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;
}

/* Forms */
form {
  max-width: 600px;
  margin: 0 auto;
}

/* 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; }
.section-content form { max-width: none; margin: 0; }

/* 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%;
  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: 2rem;
  text-align: right;
}

.actions input[type="submit"],
.actions button {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
  color: #fff;
  background-color: #007bff;
  border: 1px solid #007bff;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

.actions input[type="submit"]:hover,
.actions button:hover {
  background-color: #0069d9;
  border-color: #0062cc;
}

.actions input[type="submit"]:focus,
.actions button:focus {
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.5);
  outline: 0;
}

/* Error messages */
#error_explanation {
  background-color: #3b1219;
  color: #fca5a5;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  border: 1px solid #7f1d1d;
  border-radius: 0.375rem;
}

#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: #dc3545;
}

.field_with_errors label {
  color: #dc3545;
}

/* 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;
}

.stat-bar-fill-mini {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.stat-bar-fill-mini.stat-high { background: #22c55e; }
.stat-bar-fill-mini.stat-mid { background: #eab308; }
.stat-bar-fill-mini.stat-low { background: #ef4444; }

.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;
}

.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;
}

.team-stat-fill.stat-high { background: #22c55e; }
.team-stat-fill.stat-mid { background: #eab308; }
.team-stat-fill.stat-low { background: #ef4444; }

.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; }

/* Activity feed */
.activity-feed { margin-bottom: 2rem; }
.activity-item {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.9rem;
}
.activity-actor { font-weight: 600; white-space: nowrap; }
.activity-body { flex: 1; }
.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: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
}
.agent-workspace-side {
  position: sticky;
  top: 12px;
}

@media (max-width: 900px) {
  .agent-workspace { grid-template-columns: 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%; 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 form {
  max-width: none;
  margin: 0;
}

/* 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: #cbd5e1;
  flex-shrink: 0;
}

.pulse-dot--ok { background: #22c55e; }
.pulse-dot--active { background: #eab308; animation: pulse-blink 1.5s infinite; }
.pulse-dot--overdue { background: #f97316; }
.pulse-dot--error { background: #ef4444; }

@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: #10b981; }
.hb-step--active .hb-icon { color: #3b82f6; }
.hb-step--fail .hb-icon { color: #ef4444; }
.hb-step--warn .hb-icon { color: #eab308; }
.hb-step--pending .hb-icon { color: #94a3b8; }
.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: #dc2626; }
.trace-tool-call--error { border-left: 2px solid #dc2626; }
.trace-tool-call--error .trace-tool-name { background: rgba(220, 38, 38, 0.15); color: #dc2626; }
.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; flex-shrink: 0; }
.activity-timeline .activity-detail { color: #64748b; }

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

/* Danger button */
.btn-danger {
  background-color: #dc3545;
  border-color: #dc3545;
  color: #fff;
}

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

.btn-warning {
  background-color: #fd7e14;
  border-color: #fd7e14;
  color: #fff;
}

.btn-warning:hover {
  background-color: #e8690b;
  border-color: #dc6009;
}

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

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

/* ===== 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: #b45309;
  background: #fef3c7;
  padding: 0.1rem 0.5rem;
  border-radius: 9999px;
}

.company-card-pending svg {
  stroke: #d97706;
}

/* "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;
}

.task-output {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
}
/* 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;
}
.context-ok::after { background: #22c55e; }
.context-warn::after { background: #eab308; }
.context-danger::after { background: #ef4444; }
.context-pct {
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.badge-executing {
  background: #0969da;
  color: white;
  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); }
}

/* Auth steps checklist */
.auth-steps {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
}
.auth-step {
  display: flex;
  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: #059669; }
.auth-step--done .auth-step-icon { font-weight: 700; }
.auth-step--active { color: #1d4ed8; font-weight: 500; }
.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;
}

/* 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: #059669; }
.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: #3b82f6; }
.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;
}
/* 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;
  }
}
