/**
 * harness.css
 * Evolve Digital Brand Theme & Master Dashboard Styling
 * Strict Vanilla CSS with Light/Dark Theme Root Variables
 */

:root {
  /* Evolve Digital Brand Palette */
  --brand-primary: #f41E00;
  --brand-primary-hover: #bb2004;
  --brand-primary-subtle: rgba(244, 30, 0, 0.12);
  --brand-secondary: #FFBC02;
  --brand-secondary-hover: #e5a700;
  --brand-secondary-subtle: rgba(255, 188, 2, 0.12);
  --brand-accent: #23B7D5;
  --brand-accent-hover: #199db8;
  --brand-accent-subtle: rgba(35, 183, 213, 0.12);
  --success: #20c997;
  --danger: #dc3545;
  --warning: #ffc107;
  --info: #0dcaf0;

  /* Fonts */
  --font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-family-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Theme Defaults (Dark Mode Default) */
  --bg-color: #0E0E0E;
  --bg-secondary: #161719;
  --bg-card: #1B1B1B;
  --bg-card-hover: #222222;
  --border-color: #2b3035;
  --border-focus: #f41E00;
  --text-primary: #FFFFFF;
  --text-secondary: #A7A7A7;
  --text-muted: #6c757d;
  --navbar-bg: #0E0E0E;
  --sidebar-bg: #161719;
  --input-bg: #121315;
  --input-border: #323539;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
}

[data-theme="light"] {
  --bg-color: #f8f9fa;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f3f5;
  --border-color: #dee2e6;
  --border-focus: #f41E00;
  --text-primary: #1a1e21;
  --text-secondary: #495057;
  --text-muted: #6c757d;
  --navbar-bg: #ffffff;
  --sidebar-bg: #f8f9fa;
  --input-bg: #ffffff;
  --input-border: #ced4da;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

  /* High contrast brand & status tokens for light mode */
  --brand-primary: #d31a00;
  --brand-primary-hover: #a81500;
  --brand-primary-subtle: rgba(211, 26, 0, 0.08);
  --brand-secondary: #b45309;
  --brand-secondary-hover: #92400e;
  --brand-secondary-subtle: rgba(180, 83, 9, 0.1);
  --brand-accent: #0284c7;
  --brand-accent-hover: #0369a1;
  --brand-accent-subtle: rgba(2, 132, 199, 0.1);
  --success: #198754;
  --danger: #dc3545;
  --warning: #b45309;
  --info: #0284c7;
}

code {
  font-family: var(--font-family-mono);
  font-size: 0.85em;
  padding: 0.15em 0.35em;
  border-radius: 4px;
  background-color: var(--input-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

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

body {
  font-family: var(--font-family-base);
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.25s ease, color 0.25s ease;
}

a {
  color: var(--brand-accent);
  text-decoration: none;
  transition: color 0.2s;
}
a:hover {
  color: var(--brand-primary);
}

/* App Header & Navbar */
.harness-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.5rem;
  background-color: var(--navbar-bg);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: 0.5px;
  transition: opacity 0.2s;
}
.navbar-brand:hover {
  opacity: 0.9;
  color: var(--text-primary);
}

.navbar-brand img.logo {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.brand-name {
  letter-spacing: 0.5px;
}

.brand-badge {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: white;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.navbar-divider {
  width: 1px;
  height: 20px;
  background-color: var(--border-color);
}

.navbar-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
}

.breadcrumb-section {
  color: var(--text-muted);
  font-weight: 500;
}

.breadcrumb-separator {
  color: var(--text-muted);
  opacity: 0.6;
  font-size: 0.75rem;
}

.breadcrumb-page {
  color: var(--text-primary);
  font-weight: 600;
}

.navbar-center {
  display: flex;
  align-items: center;
}

.navbar-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.2s ease;
}

.navbar-status-pill:hover {
  border-color: var(--success);
  color: var(--text-primary);
}

@keyframes pulse-status-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(32, 201, 151, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(32, 201, 151, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(32, 201, 151, 0); }
}

.status-dot-pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
  animation: pulse-status-green 2s infinite ease-in-out;
  flex-shrink: 0;
}

.navbar-project-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.project-indicator {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--brand-secondary);
}

.project-title {
  color: var(--text-primary);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.navbar-quick-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  text-decoration: none;
  transition: all 0.2s ease;
}
.navbar-quick-link:hover {
  border-color: var(--brand-accent);
  color: var(--brand-accent);
}

.theme-toggle-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 500;
  transition: all 0.2s ease;
}
.theme-toggle-btn:hover {
  border-color: var(--brand-secondary);
  color: var(--brand-secondary);
  background: var(--bg-card-hover);
}

.navbar-user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0.3rem 0.2rem 0.45rem;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}

.user-avatar-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  font-weight: 700;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.user-display-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role-tag {
  font-size: 0.62rem;
  color: var(--text-muted);
}

.user-logout-btn {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  color: var(--text-secondary);
  padding: 0.2rem 0.45rem;
  border-radius: 12px;
  text-decoration: none;
  transition: all 0.2s ease;
  margin-left: 0.2rem;
}
.user-logout-btn:hover {
  color: var(--danger);
  background: rgba(220, 53, 69, 0.12);
}

/* Layout Grid */
.harness-app-container {
  display: flex;
  flex: 1;
  min-height: calc(100vh - 58px);
}

.harness-sidebar {
  width: 260px;
  min-width: 260px;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  padding: 1rem 0.65rem 1.25rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex-shrink: 0;
  overflow-y: auto;
  height: calc(100vh - 58px);
  position: sticky;
  top: 58px;
  scrollbar-width: thin;
}

.harness-sidebar::-webkit-scrollbar {
  width: 4px;
}
.harness-sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.harness-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.sidebar-section-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.65rem 0.75rem 0.25rem 0.75rem;
  font-weight: 700;
  margin-top: 0.5rem;
}
.sidebar-section-title:first-of-type {
  margin-top: 0;
  padding-top: 0.25rem;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.88rem;
  text-decoration: none;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  border-left: 3px solid transparent;
  position: relative;
}
.sidebar-nav-item:hover {
  background-color: var(--bg-card);
  color: var(--text-primary);
  transform: translateX(2px);
}
.sidebar-nav-item.active {
  background-color: var(--brand-primary-subtle);
  color: var(--brand-primary);
  border-left-color: var(--brand-primary);
  font-weight: 600;
}

.sidebar-nav-item .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: currentColor;
  transition: transform 0.2s ease;
}
.sidebar-nav-item:hover .nav-icon {
  transform: scale(1.08);
}

.sidebar-nav-item .nav-text-group {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.sidebar-nav-item .nav-title {
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav-item .nav-subtitle {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.2;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-nav-item.active .nav-subtitle {
  color: var(--brand-primary);
  opacity: 0.75;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.sidebar-node-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.node-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
}

.node-meta {
  display: flex;
  align-items: center;
}

.node-version {
  color: var(--text-muted);
  font-size: 0.68rem;
  font-family: var(--font-family-mono);
}

.sidebar-copyright {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0 0.25rem;
}

.harness-main-content {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-y: auto;
  background-color: var(--bg-color);
}

/* Typography & Cards */
h1, h2, h3, h4, h5 {
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  font-weight: 700;
}
h1 { font-size: 1.85rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }

.page-header {
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}
.page-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.harness-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.harness-card:hover {
  border-color: rgba(244, 30, 0, 0.3);
  box-shadow: var(--shadow-md);
}

.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  text-decoration: none;
}
.btn-primary {
  background-color: var(--brand-primary);
  color: #FFFFFF;
}
.btn-primary:hover {
  background-color: var(--brand-primary-hover);
  color: #FFFFFF;
}
.btn-secondary {
  background-color: var(--brand-secondary);
  color: #000000;
}
.btn-secondary:hover {
  background-color: var(--brand-secondary-hover);
  color: #000000;
}
.btn-accent {
  background-color: var(--brand-accent);
  color: #000000;
}
.btn-accent:hover {
  background-color: var(--brand-accent-hover);
  color: #000000;
}
.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-primary);
}
.btn-outline:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}
.btn-danger {
  background-color: var(--danger);
  color: #FFFFFF;
}
.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.25rem;
}
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}
.form-control, .form-select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}
.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--brand-primary-subtle);
}
select.form-control option,
select.form-select option,
select option {
  background-color: var(--bg-card);
  color: var(--text-primary);
}
::placeholder {
  color: var(--text-muted);
  opacity: 0.75;
}
textarea.form-control {
  min-height: 120px;
  resize: vertical;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}
.harness-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.harness-table th {
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
}
.harness-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
}
.harness-table tr:hover td {
  background-color: var(--bg-secondary);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 4px;
  text-transform: uppercase;
}
.badge-primary { background: var(--brand-primary-subtle); color: var(--brand-primary); }
.badge-secondary { background: var(--brand-secondary-subtle); color: var(--brand-secondary); }
.badge-accent { background: var(--brand-accent-subtle); color: var(--brand-accent); }
.badge-success { background: rgba(32, 201, 151, 0.15); color: var(--success); }
.badge-danger { background: rgba(220, 53, 69, 0.15); color: var(--danger); }

/* Grid Utilities */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }

@media (max-width: 900px) {
  .harness-app-container { flex-direction: column; }
  .harness-sidebar { width: 100%; height: auto; position: static; min-width: 0; }
  .navbar-breadcrumbs, .navbar-center, .quick-link-text, .user-role-tag { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .harness-navbar { padding: 0.5rem 0.85rem; }
  .navbar-actions { gap: 0.4rem; }
  .user-display-name { display: none; }
}

/* Pulse animation for live recording */
@keyframes pulse-red {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(244, 30, 0, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(244, 30, 0, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(244, 30, 0, 0); }
}
.recording-pulse {
  animation: pulse-red 1.5s infinite;
  background-color: var(--danger);
  color: #fff;
}

/* ==========================================================================
   Live Meeting Room Styling
   ========================================================================== */
.meeting-room-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
}

.meeting-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: stretch;
}

@media (max-width: 1024px) {
  .meeting-grid {
    grid-template-columns: 1fr;
  }
}

.meeting-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.md-toolbar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.btn-tool {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-tool:hover {
  background: var(--brand-primary-subtle);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.editor-split-container {
  display: flex;
  flex: 1;
  min-height: 520px;
  position: relative;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}

.code-editor {
  flex: 1;
  width: 100%;
  height: 100%;
  background: transparent;
  color: var(--text-primary);
  border: none;
  outline: none;
  padding: 1rem;
  font-family: var(--font-family-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  resize: none;
}
.code-editor:focus {
  outline: none;
}

.markdown-preview {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.7;
}
.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4 {
  color: var(--brand-secondary);
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.35rem;
}
.markdown-preview h1 { font-size: 1.4rem; color: var(--brand-primary); }
.markdown-preview h2 { font-size: 1.2rem; }
.markdown-preview h3 { font-size: 1.05rem; }
.markdown-preview p { margin-bottom: 0.75rem; color: var(--text-primary); }
.markdown-preview ul, .markdown-preview ol { margin-left: 1.5rem; margin-bottom: 0.75rem; }
.markdown-preview li { margin-bottom: 0.25rem; }
.markdown-preview code {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: var(--font-family-mono);
  font-size: 0.85em;
  color: var(--brand-accent);
}
.markdown-preview pre {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  margin-bottom: 0.75rem;
}
.markdown-preview pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text-primary);
}
.markdown-preview blockquote {
  border-left: 3px solid var(--brand-accent);
  padding-left: 0.75rem;
  color: var(--text-secondary);
  margin: 0.75rem 0;
}
.markdown-preview hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 1.25rem 0;
}

/* Copilot Chat */
.chat-message {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}
.chat-message.assistant {
  align-items: flex-start;
}
.chat-message.user {
  align-items: flex-end;
}
.chat-bubble {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  max-width: 90%;
  font-size: 0.875rem;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
}
.chat-message.user .chat-bubble {
  background: var(--brand-primary);
  border-color: var(--brand-primary-hover);
  color: #FFFFFF;
}
.chat-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0 0.25rem;
}

.chip-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.chip-btn:hover {
  background: var(--bg-secondary);
  border-color: var(--brand-accent);
  color: var(--brand-accent);
}

/* ==========================================================================
   Visual Schema Builder Styling
   ========================================================================== */
.schema-builder-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.schema-workspace-wrapper {
  position: relative;
  width: 100%;
  min-height: 650px;
  height: calc(100vh - 210px);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: auto;
  background-color: var(--bg-secondary);
  background-image: radial-gradient(var(--border-color) 1px, transparent 1px);
  background-size: 20px 20px;
}

.schema-workspace {
  position: relative;
  width: 3000px;
  height: 2500px;
  min-width: 100%;
  min-height: 100%;
}

.schema-svg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.schema-table-card {
  position: absolute;
  width: 290px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  z-index: 5;
  user-select: none;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.schema-table-card:hover {
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-lg);
}

.schema-table-header {
  background: var(--bg-secondary);
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  border-radius: 8px 8px 0 0;
  cursor: grab;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.9rem;
}
.schema-table-header:active {
  cursor: grabbing;
}

.table-title {
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-family-mono);
  font-size: 0.85rem;
}

.btn-card-action {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-secondary);
  transition: all 0.15s ease;
}
.btn-card-action:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.schema-table-fields {
  padding: 0.25rem 0;
  display: flex;
  flex-direction: column;
}

.schema-field-row {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.schema-field-row:last-child {
  border-bottom: none;
}
.schema-field-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.field-name {
  font-family: var(--font-family-mono);
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.field-type {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--brand-accent);
  background: var(--brand-accent-subtle);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: var(--font-family-mono);
}

.field-pk {
  color: var(--brand-secondary);
  font-size: 0.7rem;
  font-weight: 800;
  margin-right: 2px;
}

.connector-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--brand-accent);
  border: 2px solid var(--bg-card);
  cursor: crosshair;
  z-index: 10;
  transition: transform 0.15s ease, background 0.15s ease;
}
.connector-dot.left {
  left: -6px;
  top: calc(50% - 6px);
}
.connector-dot.right {
  right: -6px;
  top: calc(50% - 6px);
}
.connector-dot:hover {
  transform: scale(1.4);
  background: var(--brand-primary);
}

/* ==========================================================================
   Time Machine Timeline Styling
   ========================================================================== */
.timeline-container {
  position: relative;
  padding: 1.5rem 0 1rem 2rem;
  border-left: 2px solid var(--border-color);
  margin-left: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.timeline-item {
  position: relative;
  display: flex;
  align-items: flex-start;
}

.timeline-badge {
  position: absolute;
  left: -2.85rem;
  top: 0.25rem;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  box-shadow: 0 0 0 4px var(--bg-card);
}
.timeline-badge.auto {
  background: var(--brand-accent);
  color: #000;
}
.timeline-badge.manual {
  background: var(--brand-secondary);
  color: #000;
}

.timeline-content {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.timeline-content:hover {
  border-color: rgba(244, 30, 0, 0.4);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Universal Modal & Dialog Styling
   ========================================================================== */
.modal-overlay,
.harness-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-card,
.modal-content,
.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
  animation: modal-zoom 0.2s ease-out;
}

@keyframes modal-zoom {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}
.modal-header h3 {
  margin: 0;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  transition: color 0.15s ease;
}
.btn-close:hover {
  color: var(--brand-primary);
}

.modal-body {
  margin-bottom: 1.25rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ==========================================================================
   Time Machine Interactive File Editor & Markdown Preview UI
   ========================================================================== */
.tm-file-editor-split {
  display: flex;
  min-height: 520px;
  background: var(--bg-card);
}

@media (max-width: 960px) {
  .tm-file-editor-split {
    flex-direction: column;
  }
}

.tm-file-editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-card);
}

.tm-file-textarea {
  width: 100%;
  flex: 1;
  min-height: 500px;
  padding: 1.25rem;
  font-family: var(--font-mono, monospace);
  font-size: 0.88rem;
  line-height: 1.6;
  background: var(--bg-card);
  color: var(--text-primary);
  border: none;
  outline: none;
  resize: vertical;
  box-sizing: border-box;
}

.tm-file-textarea:focus {
  outline: none;
}

.tm-file-preview-pane {
  flex: 1;
  border-left: 1px solid var(--border-color);
  background: var(--bg-secondary);
  overflow-y: auto;
  padding: 1.5rem 1.75rem;
  min-width: 0;
  max-height: 800px;
  font-size: 0.92rem;
  line-height: 1.6;
}

@media (max-width: 960px) {
  .tm-file-preview-pane {
    border-left: none;
    border-top: 1px solid var(--border-color);
  }
}

.tm-file-preview-pane h1,
.tm-file-preview-pane h2,
.tm-file-preview-pane h3 {
  margin-top: 1.25rem;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.tm-file-preview-pane p {
  margin-bottom: 1rem;
}

.tm-file-preview-pane code {
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono, monospace);
  font-size: 0.85em;
  border: 1px solid var(--border-color);
}

.tm-file-preview-pane pre {
  background: var(--bg-card);
  padding: 1rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  overflow-x: auto;
  margin-bottom: 1rem;
}

.tm-file-preview-pane pre code {
  background: transparent;
  padding: 0;
  border: none;
}

.tm-file-preview-pane blockquote {
  border-left: 4px solid var(--brand-accent);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

.tm-file-preview-pane ul,
.tm-file-preview-pane ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.tm-file-preview-pane hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 1.5rem 0;
}

.tm-file-editor-footer {
  padding: 0.6rem 1.25rem;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Universal Floating Explanatory Tooltip */
.harness-tooltip {
  position: fixed;
  z-index: 99999;
  background: #121316;
  color: #f1f3f5;
  border: 1px solid var(--brand-accent);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  max-width: 300px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  white-space: normal;
  text-align: left;
}

.harness-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

[data-theme="light"] .harness-tooltip {
  background: #212529;
  color: #ffffff;
  border-color: var(--brand-primary);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Client Dashboard & Hosted Applications Responsive Cards
   ========================================================================== */
.portal-nav {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.portal-logo-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.portal-logo {
  height: 38px;
  width: auto;
  object-fit: contain;
}

.portal-container {
  max-width: 1280px;
  margin: 1.5rem auto;
  padding: 0 1.5rem 4rem;
}

.portal-header-banner {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.portal-header-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

/* Grids */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 1.5rem;
}

.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

/* Application Card */
.app-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.35rem 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.app-card:hover {
  border-color: var(--brand-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.app-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.app-card-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  word-break: break-word;
  line-height: 1.3;
}

.app-meta-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.app-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.app-meta-row code {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: var(--brand-accent);
  word-break: break-all;
}

.app-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.app-actions .btn {
  flex: 1 1 calc(50% - 0.35rem);
  min-width: 140px;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
}

/* Status Pills */
.status-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-staging {
  background: rgba(255, 188, 2, 0.12);
  color: #FFBC02;
  border: 1px solid rgba(255, 188, 2, 0.3);
}

.status-prod {
  background: rgba(40, 167, 69, 0.12);
  color: #51cf66;
  border: 1px solid rgba(40, 167, 69, 0.3);
}

[data-theme="light"] .status-staging {
  background: rgba(180, 83, 9, 0.12);
  color: #b45309;
  border: 1px solid rgba(180, 83, 9, 0.35);
}

[data-theme="light"] .status-prod {
  background: rgba(25, 135, 84, 0.12);
  color: #198754;
  border: 1px solid rgba(25, 135, 84, 0.35);
}

/* Hosted Application Items in Master Client Admin */
.hosted-app-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  transition: border-color 0.15s ease;
}

.hosted-app-card:hover {
  border-color: rgba(35, 183, 213, 0.4);
}

.hosted-app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.hosted-app-btn-group {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.hosted-app-btn-group .btn {
  padding: 5px 9px;
  font-size: 0.75rem;
  flex: 1 1 auto;
  justify-content: center;
}

/* Responsiveness Media Queries */
@media (max-width: 900px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .portal-nav {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .portal-container {
    padding: 0 1rem 3rem;
    margin: 1rem auto;
  }

  .portal-header-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .portal-header-actions {
    width: 100%;
  }

  .portal-header-actions .btn {
    flex: 1 1 100%;
    justify-content: center;
  }

  .apps-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .clients-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .app-actions .btn {
    flex: 1 1 100%;
  }

  .hosted-app-card {
    padding: 0.75rem;
  }

  .hosted-app-btn-group {
    width: 100%;
  }

  .hosted-app-btn-group .btn {
    flex: 1 1 calc(50% - 0.2rem);
  }
}

@media (max-width: 576px) {
  .grid-4, .grid-3, .grid-2 {
    grid-template-columns: 1fr;
  }

  .hosted-app-btn-group .btn {
    flex: 1 1 100%;
  }
}

/* ==========================================================================
   Brain Editor & Time Machine GitHub-Style File Browser & Diff Viewer
   ========================================================================== */

/* Toggleable History Pane in .brain Editor */
.brain-history-pane {
  width: 320px;
  border-left: 1px solid var(--border-color);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, opacity 0.2s ease;
}

.brain-history-pane.collapsed {
  display: none !important;
}

.brain-history-header {
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.brain-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.history-commit-item {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.history-commit-item:hover {
  border-color: var(--brand-accent);
  background: rgba(35, 183, 213, 0.08);
}

.history-commit-item.active {
  border-color: var(--brand-accent);
  background: rgba(35, 183, 213, 0.15);
  box-shadow: 0 0 0 1px var(--brand-accent);
}

.history-commit-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.history-commit-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.history-commit-hash {
  font-family: var(--font-mono, monospace);
  background: var(--bg-card);
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid var(--border-color);
  color: var(--brand-accent);
  font-weight: 600;
}

/* Historical Snapshot Banner */
.history-revision-banner {
  background: rgba(255, 193, 7, 0.12);
  border-bottom: 1px solid rgba(255, 193, 7, 0.35);
  padding: 0.6rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  color: #ffc107;
  font-size: 0.82rem;
}

/* Diff Viewer Styling */
.diff-viewer-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-card);
  font-family: var(--font-mono, monospace);
  font-size: 0.82rem;
}

.diff-header {
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
}

.diff-content-scroll {
  flex: 1;
  overflow: auto;
  padding: 0.5rem 0;
  background: #0d1117;
  color: #c9d1d9;
}

[data-theme="light"] .diff-content-scroll {
  background: #f6f8fa;
  color: #24292f;
}

.diff-line {
  display: flex;
  line-height: 1.45;
  padding: 0 0.75rem;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

.diff-line.diff-add {
  background: rgba(46, 160, 67, 0.18);
  color: #3fb950;
  border-left: 3px solid #2ea043;
}

[data-theme="light"] .diff-line.diff-add {
  background: #e6ffec;
  color: #1a7f37;
  border-left: 3px solid #2da44e;
}

.diff-line.diff-del {
  background: rgba(248, 81, 73, 0.18);
  color: #f85149;
  border-left: 3px solid #da3633;
}

[data-theme="light"] .diff-line.diff-del {
  background: #ffebe9;
  color: #cf222e;
  border-left: 3px solid #cf222e;
}

.diff-line.diff-chunk {
  background: rgba(56, 139, 253, 0.15);
  color: #58a6ff;
  font-weight: 600;
  padding: 2px 0.75rem;
  margin: 4px 0;
}

.diff-line.diff-meta {
  color: #8b949e;
  font-style: italic;
}

/* GitHub Style Repository File Table in Time Machine */
.gh-repo-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.gh-repo-commit-bar {
  padding: 0.75rem 1.25rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.gh-repo-table {
  width: 100%;
  border-collapse: collapse;
}

.gh-repo-table tr {
  border-bottom: 1px solid var(--border-color);
  transition: background 0.12s ease;
}

.gh-repo-table tr:last-child {
  border-bottom: none;
}

.gh-repo-table tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .gh-repo-table tr:hover {
  background: rgba(0, 0, 0, 0.02);
}

.gh-repo-table td {
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  vertical-align: middle;
}

.gh-repo-item-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
}

.gh-repo-item-link:hover {
  color: var(--brand-accent);
  text-decoration: underline;
}

.gh-repo-commit-msg {
  color: var(--text-secondary);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 450px;
}

.gh-repo-age {
  color: var(--text-muted);
  font-size: 0.78rem;
  white-space: nowrap;
  text-align: right;
}

/* GitHub File View Toolbar & Header */
.gh-file-header {
  padding: 0.75rem 1.25rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.gh-file-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.gh-file-code-container {
  padding: 1.25rem;
  overflow: auto;
  font-family: var(--font-mono, monospace);
  font-size: 0.84rem;
  line-height: 1.5;
  background: var(--bg-card);
  min-height: 400px;
  white-space: pre-wrap;
  word-break: break-all;
}
