/* POLI Ingeniero - Premium SaaS Shell */
:root {
  --bg-primary: #080b0d;
  --bg-secondary: rgba(20,25,28,.88);
  --bg-tertiary: rgba(31,41,45,.82);
  --bg-card: rgba(20,25,28,.78);
  --border-color: rgba(255,255,255,.105);
  --text-primary: #f5f7f6;
  --text-secondary: #a7b0ac;
  --text-muted: #727d78;
  --accent-blue: #16a34a;
  --accent-green: #16a34a;
  --accent-yellow: #d29922;
  --accent-red: #f85149;
  --accent-purple: #a371f7;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 8px rgba(0,0,0,0.4);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --transition-fast: 160ms cubic-bezier(.2,.8,.2,1);
  --transition-normal: 280ms cubic-bezier(.2,.8,.2,1);
  --sidebar-width: 240px;
  --monitoring-width: 300px;
  --header-height: 44px;
  --chat-header-height: 52px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: radial-gradient(circle at 15% 0%, rgba(22,163,74,.12), transparent 34%), var(--bg-primary);
  color: var(--text-primary);
  height: 100dvh;
  overflow: hidden;
}

/* --- App Shell --- */
.app { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* --- Header --- */
.app-header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
  backdrop-filter: blur(18px) saturate(140%);
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo { width: 27px; height: 27px; object-fit: contain; filter: drop-shadow(0 0 8px rgba(22,163,74,.25)); }
.header-title { font-weight: 600; font-size: 16px; white-space: nowrap; }
.header-title strong, .login-header h1 span { color: var(--accent-green); }
.header-right { display: flex; align-items: center; gap: 12px; }
.mobile-menu-btn {
  display: none;
  background: none; border: none; color: var(--text-secondary);
  cursor: pointer; padding: 4px;
}
.mobile-menu-btn:hover { color: var(--text-primary); }
.connection-status { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-muted); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-green); }
.status-dot.offline { background: var(--accent-red); }
.btn-refresh {
  background: none; border: 1px solid var(--border-color);
  color: var(--text-secondary); cursor: pointer;
  padding: 4px 8px; border-radius: var(--radius-sm);
  display: flex; align-items: center;
}
.btn-refresh:hover { color: var(--text-primary); border-color: var(--text-muted); }

/* Permission Badge */
.permission-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-yellow);
  color: #000;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.permission-badge svg { width: 14px; height: 14px; }
.permission-count { min-width: 12px; text-align: center; }
.permission-badge.has-pending {
  animation: permission-pulse 1.5s ease-in-out infinite;
}
@keyframes permission-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(210,153,34,0.5); }
  50% { opacity: 0.85; box-shadow: 0 0 8px 2px rgba(210,153,34,0.3); }
}

/* --- App Body: 3-Column Shell --- */
.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  height: calc(100dvh - var(--header-height));
  overflow: hidden;
}

/* --- Sidebar: Projects --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  min-height: 0;
  backdrop-filter: blur(18px);
}
.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
}
.sidebar-section-label {
  font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-muted);
}
.summary-value { font-size: 14px; font-weight: 600; }
.project-list { flex: 1; overflow-y: auto; min-height: 0; }
.project-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer;
  border-left: 3px solid transparent;
  transition: background var(--transition-fast);
}
.project-item:hover { background: var(--bg-tertiary); }
.project-item.active {
  background: var(--bg-tertiary);
  border-left-color: var(--accent-blue);
}
.project-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.project-dot.healthy { background: var(--accent-green); }
.project-dot.degraded { background: var(--accent-yellow); }
.project-dot.stopped { background: var(--text-muted); }
.project-dot.unknown { background: var(--accent-purple); }
.project-dot.starting { background: var(--accent-blue); }
.project-dot.error { background: var(--accent-red); }
.project-info { flex: 1; min-width: 0; }
.project-item-name {
  font-size: 15px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.project-item-meta {
  font-size: 13px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.loading-indicator {
  padding: 20px 14px; text-align: center;
  color: var(--text-muted); font-size: 14px;
}
.sidebar-empty {
  padding: 32px 14px; text-align: center;
  color: var(--text-muted); font-size: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}

/* --- Chat Panel (Center) --- */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-primary);
  overflow: hidden;
}
.chat-messages.initializing { visibility: hidden; scroll-behavior: auto; }
.chat-messages.initializing .chat-message { animation: none; }
.login-screen { background: radial-gradient(circle at 50% 35%, rgba(22,163,74,.2), transparent 35%), linear-gradient(145deg,#07090b,#111719); }
.login-card { backdrop-filter: blur(24px) saturate(140%); border-color: rgba(255,255,255,.13); box-shadow: 0 28px 90px rgba(0,0,0,.55), inset 0 1px rgba(255,255,255,.06); }
.login-logo { width: 92px; height: 92px; object-fit: contain; border-radius: 22px; filter: drop-shadow(0 14px 28px rgba(0,0,0,.38)); }
.resource-card, .settings-kv, .chat-input-wrapper { box-shadow: inset 0 1px rgba(255,255,255,.035); }
.settings-drawer { backdrop-filter: blur(22px) saturate(135%); }

/* Empty State */
.chat-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; flex: 1;
  color: var(--text-muted); text-align: center; padding: 40px;
}
.empty-icon { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.3; }
.chat-empty h2 { font-size: 18px; font-weight: 500; margin-bottom: 6px; color: var(--text-secondary); }
.chat-empty p { font-size: 15px; }

/* Chat View */
.chat-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Chat Header */
.chat-header {
  height: var(--chat-header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.chat-header-info { display: flex; flex-direction: column; min-width: 0; }
.chat-project-name {
  font-size: 17px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-project-meta {
  font-size: 13px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-agent-selector { flex-shrink: 0; }
.agent-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px; font-weight: 500;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
}
.agent-select:hover { border-color: var(--text-muted); }
.agent-select:focus { border-color: var(--accent-blue); }
.agent-select option { background: var(--bg-secondary); color: var(--text-primary); }

/* Messages Area */
.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: auto;
}

/* Message Bubbles */
.chat-message {
  display: flex;
  gap: 10px;
  max-width: 100%;
  animation: msgFadeIn 0.2s ease;
}
.chat-message.msg-user { align-self: flex-end; flex-direction: row-reverse; max-width: min(72%, 760px); }
.chat-message.msg-agent { align-self: stretch; }
.chat-message.msg-optimistic { opacity: .72; }

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--bg-tertiary);
}
.msg-avatar svg { width: 16px; height: 16px; }
.msg-user .msg-avatar { background: var(--accent-blue); }
.msg-agent .msg-avatar { background: var(--bg-tertiary); border: 1px solid var(--border-color); }

.msg-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.msg-agent .msg-content { flex: 1; }
.msg-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.msg-agent-name { font-weight: 600; color: var(--text-secondary); }
.msg-time { color: var(--text-muted); }
.msg-model { color: var(--accent-blue); font-family: 'SF Mono', 'Menlo', monospace; }

/* Message footer: agent · model · duration + copy button */
.msg-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  min-height: 28px;
}
.msg-footer-info {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Copy buttons */
.copy-msg-btn,
.copy-last-btn,
.copy-tool-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  line-height: 1.4;
}
.copy-msg-btn:hover,
.copy-last-btn:hover,
.copy-tool-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent-blue);
  background: rgba(88,166,255,0.1);
}
.copy-msg-btn.copied,
.copy-last-btn.copied,
.copy-tool-btn.copied {
  color: var(--accent-green);
  border-color: var(--accent-green);
}
.copy-msg-btn {
  flex-shrink: 0;
}
.copy-last-btn {
  margin-left: auto;
  font-size: 13px;
  padding: 2px 10px;
}
.copy-last-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.copy-last-btn:disabled:hover {
  color: var(--text-muted);
  border-color: var(--border);
  background: none;
}
.copy-tool-btn {
  float: right;
  font-size: 13px;
  padding: 0 4px;
  margin-top: -2px;
}

/* Mobile: larger touch targets */
@media (max-width: 768px) {
  .copy-msg-btn,
  .copy-last-btn,
  .copy-tool-btn {
    min-height: 40px;
    min-width: 40px;
    padding: 6px 10px;
    font-size: 14px;
  }
  .msg-footer {
    margin-top: 10px;
  }
}
.msg-model { color: var(--accent-blue); font-family: 'SF Mono', 'Menlo', monospace; }
.msg-status {
  font-size: 11px;
  padding: 0 4px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  font-weight: 600;
}
.msg-status.status-working { background: rgba(63,185,80,0.15); color: var(--accent-green); }
.msg-status.status-complete { background: rgba(88,166,255,0.15); color: var(--accent-blue); }
.msg-status.status-error { background: rgba(248,81,73,0.15); color: var(--accent-red); }

.msg-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}
.msg-user .msg-bubble {
  background: var(--accent-blue);
  color: #fff;
  border-bottom-right-radius: var(--radius-sm);
}
.msg-agent .msg-bubble {
  background: transparent;
  border: 0;
  border-left: 2px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 0;
  padding-left: 14px;
}

/* System Messages */
.chat-message.msg-system {
  align-self: center;
  max-width: 100%;
}
.msg-system-bubble {
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
}

/* Chat Input Area */
.chat-input-area {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  transition: border-color var(--transition-fast);
}
.chat-input-wrapper:focus-within { border-color: var(--accent-blue); }
.chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 20px;
}
.chat-input::placeholder { color: var(--text-muted); }
.chat-run-controls {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.chat-run-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  line-height: 1;
}
.chat-run-btn:hover:not(:disabled) { border-color: currentColor; background: var(--bg-hover); }
.chat-stop-btn { color: var(--accent-red); }
.chat-pause-btn { color: var(--accent-orange); }
.chat-resume-btn { color: var(--accent-green); }
.chat-abort-btn { color: var(--accent-red); }
.chat-run-btn:disabled { color: var(--text-muted); cursor: not-allowed; opacity: .45; }
.chat-send-btn {
  background: none;
  border: none;
  color: var(--accent-blue);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
  flex-shrink: 0;
}
.chat-send-btn:hover { color: var(--text-primary); }
.chat-input-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: center;
}

/* --- Monitoring Panel (Right) --- */
.monitoring-panel {
  width: var(--monitoring-width);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  min-height: 0;
  transition: width var(--transition-normal), transform var(--transition-normal);
}
.monitoring-panel.collapsed { width: 0; border-left: 0; }
.monitoring-backdrop { display: none; }
.monitoring-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Monitoring Sections */
.monitoring-section {
  border-bottom: 1px solid var(--border-color);
}
.monitoring-section:last-child { border-bottom: none; }
.monitoring-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

/* Service Cards */
.service-cards { padding: 0 10px 10px; display: flex; flex-direction: column; gap: 8px; }
.service-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.service-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}
.service-card-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.service-state {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(110,118,129,0.15);
  color: var(--text-muted);
}
.service-state.running { background: rgba(63,185,80,0.15); color: var(--accent-green); }
.service-state.stopped { background: rgba(110,118,129,0.15); color: var(--text-muted); }
.service-state.error { background: rgba(248,81,73,0.15); color: var(--accent-red); }
.service-state.unknown { background: rgba(163,113,247,0.15); color: var(--accent-purple); }
.service-card-body { padding: 0; }
.service-card-compact .service-card-header { border-bottom: 0; }
.service-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 10px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}
.service-info-row:last-child { border-bottom: none; }
.service-info-label { color: var(--text-muted); }
.service-info-value { color: var(--text-primary); }
.service-info-value.mono { font-family: 'SF Mono', 'Menlo', monospace; font-size: 12px; }
.service-card-actions {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  border-top: 1px solid var(--border-color);
}
.btn-svc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-fast);
}
.btn-svc:hover:not(:disabled) { background: var(--bg-tertiary); }
.btn-svc:disabled { opacity: 0.3; cursor: not-allowed; }
.btn-start { border-color: var(--accent-green); color: var(--accent-green); }
.btn-start:hover:not(:disabled) { background: rgba(63,185,80,0.1); }
.btn-stop { border-color: var(--accent-red); color: var(--accent-red); }
.btn-stop:hover:not(:disabled) { background: rgba(248,81,73,0.1); }
.btn-restart { border-color: var(--accent-yellow); color: var(--accent-yellow); }
.btn-restart:hover:not(:disabled) { background: rgba(210,153,34,0.1); }
.btn-open { border-color: var(--accent-blue); color: var(--accent-blue); }
.btn-open:hover { background: rgba(88,166,255,0.1); }

/* --- Observability Cards --- */
.obs-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 0 10px 10px;
}
.obs-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.obs-card:hover { border-left-color: var(--accent-blue); }
.obs-card-wide { grid-column: 1 / -1; }
.obs-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.obs-value {
  font-size: 14px;
  font-weight: 500;
}
.obs-value.placeholder {
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
  font-size: 13px;
}
.obs-value.risk-low { color: var(--accent-green); }
.obs-value.risk-medium { color: var(--accent-yellow); }
.obs-value.risk-high { color: var(--accent-red); }
.obs-value.risk-critical { color: var(--accent-red); font-weight: 600; }
.obs-value.risk-unknown { color: var(--text-muted); }
.obs-value.gate-pass { color: var(--accent-green); }
.obs-value.gate-fail { color: var(--accent-red); }

/* --- Gate Indicators (mini) --- */
.gate-indicator {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-right: 4px;
}
.gate-indicator.gate-pass {
  background: rgba(63,185,80,0.15);
  color: var(--accent-green);
}
.gate-indicator.gate-fail {
  background: rgba(248,81,73,0.15);
  color: var(--accent-red);
}
.gate-indicator.gate-waiting {
  background: rgba(210,153,34,0.15);
  color: var(--accent-yellow);
}
.gate-indicator.gate-unknown {
  background: rgba(110,118,129,0.15);
  color: var(--text-muted);
}
.gate-indicator.gate-not_required {
  background: rgba(110,118,129,0.15);
  color: var(--text-muted);
}

/* --- Agents List (within monitoring) --- */
.agents-count {
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-tertiary);
  padding: 1px 6px;
  border-radius: 8px;
  color: var(--text-muted);
}
.agents-notice {
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  font-style: italic;
}
.agents-notice.active-notice {
  color: var(--accent-green);
  font-style: normal;
}
.agents-notice.stale-notice {
  color: var(--accent-yellow);
  font-style: normal;
}
.agents-list {
  max-height: 280px;
  overflow-y: auto;
  min-height: 0;
}
.agent-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border-color);
  cursor: default;
  transition: background var(--transition-fast);
  position: relative;
}
.agent-row:hover { background: var(--bg-tertiary); }
.agent-row:last-child { border-bottom: none; }
.agent-row.stale { opacity: 0.7; }
.agent-row.stale::after {
  content: '';
  position: absolute;
  right: 14px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-yellow);
}
.agent-icon {
  width: 16px; height: 16px; flex-shrink: 0;
  color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.agent-icon svg { width: 100%; height: 100%; }
.agent-info {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
}
.agent-name {
  font-size: 14px; font-weight: 500; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.agent-task {
  font-size: 12px; color: var(--text-muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.agent-task-empty { font-style: italic; }
.agent-status {
  font-size: 12px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.3px; white-space: nowrap;
}
.agent-status.state-working { color: var(--accent-green); }
.agent-status.state-idle { color: var(--accent-yellow); }
.agent-status.state-unknown { color: var(--text-muted); }
.agent-dot {
  width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0;
}
.agent-dot.state-working { background: var(--accent-green); }
.agent-dot.state-idle { background: var(--accent-yellow); }
.agent-dot.state-unknown { background: var(--text-muted); }

/* --- Agent Pulse (WORKING transition) --- */
@keyframes agent-pulse {
  0% { background: rgba(63, 185, 80, 0.08); }
  50% { background: rgba(63, 185, 80, 0.15); }
  100% { background: transparent; }
}
.agent-row.agent-pulse {
  animation: agent-pulse 2s ease-out;
}

/* --- Action Feedback --- */
.action-feedback {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.action-feedback.success { border-color: var(--accent-green); color: var(--accent-green); }
.action-feedback.error { border-color: var(--accent-red); color: var(--accent-red); }

/* --- Technical Details --- */
.technical-details { margin: 0 10px 10px; border: 1px solid var(--border-color); border-radius: var(--radius-md); overflow: hidden; }
.section-title {
  padding: 8px 12px; font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-secondary); background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}
.section-title.clickable { cursor: pointer; user-select: none; }
.technical-details[open] .section-title { border-bottom: 1px solid var(--border-color); }
.raw-json {
  padding: 10px 12px; font-size: 13px;
  font-family: 'SF Mono', 'Menlo', monospace;
  color: var(--text-secondary); background: var(--bg-primary);
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
  max-height: 200px; overflow-y: auto;
}

/* P0 live multi-agent cockpit: priority and compact scan density. */
.monitoring-scroll { display: flex; flex-direction: column; }
.monitoring-scroll > .monitoring-section:nth-child(4) { order: 1; }
.monitoring-scroll > .monitoring-section:nth-child(2) { order: 2; }
.monitoring-scroll > .monitoring-section:nth-child(3) { order: 3; }
.monitoring-scroll > .monitoring-section:nth-child(5) { order: 4; }
.monitoring-scroll > .monitoring-section:nth-child(1) { order: 5; }
.services-heading { display: none; }
.service-cards .service-card:nth-child(1) { order: 2; }
.service-cards .service-card:nth-child(2) { order: 1; }
.service-cards .service-card:nth-child(3) { order: 3; }

.work-mode { padding: 0 10px 7px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.work-mode > span { color: var(--text-muted); font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; }
.work-mode-options { display: inline-flex; padding: 2px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-primary); }
.work-mode-options button { border: 0; border-radius: 6px; padding: 4px 8px; color: var(--text-muted); background: transparent; font-size: 11px; font-weight: 700; text-transform: uppercase; cursor: pointer; }
.work-mode-options button.active { color: #fff; background: linear-gradient(135deg, #10883e, #16a34a); box-shadow: 0 0 10px rgba(22,163,74,.2); }
.agents-list { max-height: none; overflow: visible; }
.agent-card { position: relative; border-top: 1px solid var(--border-color); background: transparent; }
.agent-card > summary { position: relative; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 2px 7px; padding: 6px 10px 7px; cursor: pointer; list-style: none; overflow: hidden; }
.agent-card > summary::-webkit-details-marker { display: none; }
.agent-card-title { min-width: 0; display: flex; align-items: baseline; gap: 5px; }
.agent-card-title b { color: var(--text-primary); font-size: 12px; letter-spacing: .25px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-card-title small { color: var(--text-muted); font-size: 10px; white-space: nowrap; }
.agent-card-activity { grid-column: 1 / -1; min-width: 0; color: var(--text-muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-card-activity b { color: var(--text-secondary); }
.agent-expanded label { grid-column: 1 / -1; display: flex; align-items: center; gap: 5px; color: var(--text-muted); font-size: 11px; }
.agent-expanded select { flex: 1; min-width: 0; height: 22px; padding: 1px 22px 1px 6px; border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-secondary); background: var(--bg-primary); font-size: 11px; }
.agent-expanded em.agent-model-required { grid-column: 1 / -1; color: var(--accent-yellow); background: var(--bg-primary); padding: 2px 5px; font-size: 9px; font-style: normal; justify-self: start; }
.agent-card.state-working .agent-card-activity b { color: var(--accent-green); }
.agent-card.state-waiting_approval .agent-card-activity b,
.agent-card.state-stalled .agent-card-activity b { color: var(--accent-yellow); }
.agent-card.state-error .agent-card-activity b { color: var(--accent-red); }
.agent-card.state-completed .agent-card-activity b { color: var(--accent-blue); }
.agent-expanded { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 8px; padding: 7px 10px 9px; border-top: 1px solid var(--border-color); background: rgba(255,255,255,.015); }
.agent-expanded > span { min-width: 0; color: var(--text-secondary); font-size: 11px; overflow-wrap: anywhere; }
.agent-expanded > span b { display: block; margin-bottom: 1px; color: var(--text-muted); font-size: 9px; letter-spacing: .4px; text-transform: uppercase; }
.agent-permission-slot { grid-column: 1 / -1; }
.agent-permission { grid-column: 1 / -1; display: grid; gap: 5px; padding: 6px; border: 1px solid rgba(210,153,34,.35); border-radius: 7px; color: var(--accent-yellow); font-size: 11px; }
.agent-permission div { display: flex; gap: 5px; }
.agent-permission button { padding: 4px 7px; border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-primary); background: var(--bg-primary); font-size: 10px; cursor: pointer; }
.agent-shimmer { position: absolute; left: 10px; right: 10px; bottom: 0; height: 1px; overflow: hidden; background: rgba(22,163,74,.12); }
.agent-card.state-working .agent-shimmer::after { content: ''; position: absolute; inset: 0; width: 24%; background: linear-gradient(90deg, transparent, rgba(151,255,191,.88), transparent); animation: agent-shimmer .9s linear infinite; will-change: transform; }
@keyframes agent-shimmer { from { transform: translateX(-120%); } to { transform: translateX(460%); } }
.agent-card.state-waiting_approval > summary { background: rgba(210,153,34,.04); }
@media (prefers-reduced-motion: reduce) {
  .agent-shimmer::after { animation: none; opacity: .45; }
}

/* --- V262 Unified Workspace Controls --- */
button, input, select, textarea { font: inherit; }
button svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

/* Project actions */
.project-actions {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
}
.project-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 5px 7px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.project-action-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.project-action-btn svg { width: 15px; height: 15px; flex: 0 0 auto; }
.project-actions > .capability-badge { align-self: flex-start; margin: 3px 7px 0; }
.workspace-context {
  padding: 9px 13px 11px;
  border-top: 1px solid var(--border-color);
  background: rgba(0,0,0,0.12);
  min-width: 0;
}
.workspace-context-label {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .55px;
  margin-bottom: 3px;
}
.workspace-context-path {
  display: block;
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Shared capability state */
.capability-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 17px;
  padding: 1px 6px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .45px;
  line-height: 1.25;
  white-space: nowrap;
}
.status-connected {
  color: var(--accent-green);
  border-color: rgba(63,185,80,.28);
  background: rgba(63,185,80,.10);
}
.status-available {
  color: var(--accent-blue);
  border-color: rgba(88,166,255,.28);
  background: rgba(88,166,255,.10);
}
.status-pending {
  color: var(--accent-yellow);
  border-color: rgba(210,153,34,.28);
  background: rgba(210,153,34,.10);
}
.status-error {
  color: var(--accent-red);
  border-color: rgba(248,81,73,.28);
  background: rgba(248,81,73,.10);
}

/* Native execution state */
.execution-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--border-color);
  background: #111720;
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 13px;
  flex-wrap: wrap;
}
.execution-symbol, .execution-state { color: var(--text-muted); }
.execution-bar.state-working .execution-symbol,
.execution-bar.state-working .execution-state { color: var(--accent-blue); }
.execution-bar.state-tool .execution-symbol,
.execution-bar.state-tool .execution-state { color: var(--accent-purple); }
.execution-bar.state-waiting_approval .execution-symbol,
.execution-bar.state-waiting_approval .execution-state { color: var(--accent-yellow); }
.execution-bar.state-waiting_approval {
  background: rgba(210, 153, 34, 0.08);
  border-bottom-color: rgba(210, 153, 34, 0.3);
  animation: waiting-approval-pulse 2s ease-in-out infinite;
}
@keyframes waiting-approval-pulse {
  0%, 100% { background: rgba(210, 153, 34, 0.08); }
  50% { background: rgba(210, 153, 34, 0.14); }
}
.execution-bar.state-waiting_approval .execution-tool {
  color: var(--accent-yellow);
  font-weight: 500;
}

/* V267B: Inline Permission Card — prominent, always-visible permission UI */
.permission-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: rgba(210, 153, 34, 0.10);
  border-bottom: 1px solid rgba(210, 153, 34, 0.3);
  font-size: 14px;
  animation: waiting-approval-pulse 2s ease-in-out infinite;
}
.permission-inline-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-yellow);
  min-width: 0;
}
.permission-inline-header svg {
  flex-shrink: 0;
  color: var(--accent-yellow);
}
.permission-inline-title {
  font-weight: 600;
  white-space: nowrap;
}
.permission-inline-tool {
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 280px;
}
.permission-inline-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.permission-inline-actions .primary-btn,
.permission-inline-actions .secondary-btn {
  min-height: 28px;
  padding: 3px 10px;
  font-size: 13px;
  white-space: nowrap;
}
.permission-inline-actions .btn-approve {
  border-color: rgba(63,185,80,.55);
  color: var(--accent-green);
}
.permission-inline-actions .btn-approve:hover:not(:disabled) {
  background: rgba(63,185,80,.10);
}
.permission-inline-actions .btn-deny {
  border-color: rgba(248,81,73,.55);
  color: var(--accent-red);
}
.permission-inline-actions .btn-deny:hover:not(:disabled) {
  background: rgba(248,81,73,.10);
}
.permission-inline-actions .btn-always {
  border-color: rgba(163,113,247,.55);
  color: var(--accent-purple);
}
.permission-inline-actions .btn-always:hover:not(:disabled) {
  background: rgba(163,113,247,.10);
}
@media (max-width: 768px) {
  .permission-inline {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
  }
  .permission-inline-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .permission-inline-actions .primary-btn,
  .permission-inline-actions .secondary-btn {
    flex: 1 1 auto;
    min-height: 36px;
  }
}
.execution-bar.state-complete .execution-symbol,
.execution-bar.state-complete .execution-state { color: var(--accent-green); }
.execution-bar.state-error .execution-symbol,
.execution-bar.state-error .execution-state { color: var(--accent-red); }
.execution-separator { color: var(--border-color); }
.execution-elapsed { margin-left: auto; color: var(--text-primary); }
.execution-tool { flex: 1 0 100%; padding-left: 18px; color: var(--text-secondary); }
.execution-bar.state-error .execution-tool { color: var(--accent-red); }

.execution-summary { display: grid; padding: 0 10px 10px; }
.execution-summary > div {
  display: grid; grid-template-columns: 38% 1fr; gap: 8px;
  padding: 5px 8px; border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary); font-size: 12px;
}
.execution-summary > div:first-child { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.execution-summary > div:last-child { border-radius: 0 0 var(--radius-sm) var(--radius-sm); border-bottom: 0; }
.execution-summary dt { color: var(--text-muted); }
.execution-summary dd { min-width: 0; color: var(--text-primary); overflow-wrap: anywhere; }
.execution-value.state-working { color: var(--accent-blue); }

/* Execution control states: pause / interrupted / cancelled */
.execution-bar.state-paused .execution-symbol,
.execution-bar.state-paused .execution-state { color: var(--accent-orange); }
.execution-bar.state-interrupted .execution-symbol,
.execution-bar.state-interrupted .execution-state { color: var(--accent-red); }
.execution-bar.state-cancelled .execution-symbol,
.execution-bar.state-cancelled .execution-state { color: var(--accent-red); }
.execution-value.state-paused { color: var(--accent-orange); }
.execution-value.state-interrupted { color: var(--accent-red); }
.execution-value.state-cancelled { color: var(--accent-red); }

/* Abort mission dialog */
.abort-dialog { width: min(480px, calc(100vw - 28px)); }
.provider-dialog { width: min(480px, calc(100vw - 28px)); }
.provider-connect-fields { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.provider-connect-label { font-size: 13px; color: var(--text-muted); }
.provider-toolbar { display: flex; gap: 8px; align-items: center; }
.provider-toolbar .settings-input { flex: 1; min-width: 0; }
.provider-toolbar .secondary-btn { flex: 0 0 auto; white-space: nowrap; }
.provider-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.provider-group-title { font-size: 13px; font-weight: 600; color: var(--text-secondary); letter-spacing: .04em; text-transform: uppercase; }
.provider-group-count { color: var(--text-muted); font-weight: 400; }
.provider-card.provider-connected { border-color: rgba(63,185,80,.35); background: rgba(63,185,80,.06); }

/* OAuth device-code block — OpenAI “ChatGPT Pro/Plus (headless)” login */
.provider-oauth-steps { margin: 2px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
.provider-oauth-steps li { margin-bottom: 2px; }
.provider-help-link {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-blue);
  font-size: 12.5px;
  line-height: 1.5;
  text-align: left;
  text-decoration: underline;
  cursor: pointer;
}
.provider-help-link:hover { opacity: .85; }
.provider-help-figure { margin: 4px 0 0; }
.provider-help-figure img {
  display: block;
  width: 100%;
  max-height: 46vh;
  object-fit: contain;
  object-position: top;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
}
.provider-help-figure figcaption {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}
.provider-device-code {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border: 1px solid rgba(63,185,80,.35);
  border-radius: var(--radius-md);
  background: rgba(63,185,80,.06);
}
.provider-device-code[hidden] { display: none; }
.provider-device-code-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.provider-device-code-value {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .16em;
  color: var(--text-primary);
  word-break: break-all;
}
.provider-device-code-state { font-size: 12.5px; color: var(--text-muted); min-height: 16px; }
@media (max-width: 375px) {
  .provider-device-code-value { font-size: 20px; letter-spacing: .1em; }
}
.abort-mission-warning {
  padding: 12px 14px;
  border: 1px solid rgba(239,68,68,.35);
  border-radius: var(--radius-md);
  background: rgba(239,68,68,.08);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-primary);
  margin-bottom: 12px;
}
.abort-dialog .btn-deny {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: #fff;
}
.abort-dialog .btn-deny:hover:not(:disabled) { filter: brightness(1.08); }
.execution-value.state-tool { color: var(--accent-purple); }
.execution-value.state-complete { color: var(--accent-green); }
.execution-value.state-error { color: var(--accent-red); }
.execution-value.state-waiting_approval { color: var(--accent-yellow); }

/* Auto-scroll button */
.scroll-to-bottom {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  padding: 6px 14px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  display: none;
}
.scroll-to-bottom.visible { display: block; }
.scroll-to-bottom:hover { color: var(--text-primary); border-color: var(--text-muted); background: var(--bg-tertiary); }

/* Sticky TODO Panel */
.todo-panel {
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  max-height: 180px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.todo-panel.collapsed .todo-panel-content { display: none; }
.todo-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.todo-panel-label { flex: 1; }
.todo-panel-count {
  background: var(--bg-primary);
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 11px;
  color: var(--text-muted);
}
.todo-panel-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
  line-height: 1;
}
.todo-panel-toggle:hover { color: var(--text-primary); }
.todo-panel-content {
  overflow-y: auto;
  padding: 6px 10px;
  min-height: 0;
}
.todo-list { display: flex; flex-direction: column; gap: 3px; }
.todo-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
}
.todo-item:hover { background: var(--bg-tertiary); }
.todo-check { width: 14px; text-align: center; flex-shrink: 0; font-size: 12px; }
.todo-completed .todo-check { color: var(--accent-green); }
.todo-completed .todo-text { text-decoration: line-through; color: var(--text-muted); }
.todo-current .todo-check { color: var(--accent-blue); }
.todo-current .todo-text { color: var(--text-primary); font-weight: 500; }
.todo-pending .todo-check { color: var(--text-muted); }
.todo-item.todo-error .todo-check { color: var(--accent-red); }
.todo-item.todo-error .todo-text { color: var(--accent-red); }
.todo-item .todo-text small { display: block; margin-top: 2px; color: var(--text-muted); font-size: 11px; font-weight: 500; text-decoration: none; }
.todo-summary {
  padding: 4px 6px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
}
.todo-preparing,
.todo-no-plan {
  padding: 8px 6px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}
.todo-no-plan { color: var(--text-muted); font-style: normal; }
.change-summary { display: flex; flex-direction: column; gap: 3px; margin: 0 10px 10px; padding: 8px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--bg-primary); font-size: 12px; }
.monitoring-section-title-inline { color: var(--text-muted); font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; }
.change-summary > span:not(.monitoring-section-title-inline) { color: var(--accent-green); font-family: 'SF Mono', 'Menlo', monospace; }
.change-files { display: flex; flex-direction: column; gap: 2px; margin-top: 3px; color: var(--text-muted); font-family: 'SF Mono', 'Menlo', monospace; }
.change-files span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Workspace toolbar */
.workspace-toolbar {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}
.workspace-toolbar-primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 54px;
  padding: 8px 16px;
}
.project-title-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-header-info { display: flex; flex-direction: column; min-width: 0; }
.toolbar-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.toolbar-btn,
.shortcut-btn,
.icon-action-btn,
.chat-icon-btn,
.secondary-btn,
.primary-btn {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 9px;
  font-size: 13px;
}
.toolbar-btn svg { width: 14px; height: 14px; }
.toolbar-btn:hover:not(:disabled),
.shortcut-btn:hover:not(:disabled),
.icon-action-btn:hover:not(:disabled),
.chat-icon-btn:hover:not(:disabled),
.secondary-btn:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--text-muted);
  background: var(--bg-tertiary);
}
button:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .52; }
.workspace-controls {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 16px 10px;
  border-top: 1px solid rgba(48,54,61,.55);
}
.control-cluster {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
  min-width: 0;
}
.control-cluster > label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .5px;
}
.session-control {
  grid-template-columns: minmax(135px, 210px) 28px;
}
.session-control > label { grid-column: 1 / -1; }
.model-control { flex: 1 1 210px; }
.model-state-select { display: none; }
.model-search-input::-webkit-calendar-picker-indicator { opacity: .65; cursor: pointer; }
.workspace-select {
  min-width: 0;
  height: 29px;
  padding: 4px 26px 4px 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  text-overflow: ellipsis;
}
.workspace-select:hover:not(:disabled) { border-color: var(--text-muted); }
.workspace-select:focus { border-color: var(--accent-blue); }
.workspace-select option,
.workspace-select optgroup { background: var(--bg-secondary); color: var(--text-primary); }
.icon-action-btn,
.chat-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 29px;
  height: 29px;
  padding: 5px;
}
.icon-action-btn svg, .chat-icon-btn svg { width: 15px; height: 15px; }
.capability-shortcuts { display: flex; gap: 4px; margin-left: auto; }
.shortcut-btn { height: 29px; padding: 4px 8px; font-size: 12px; }
.session-identity {
  min-height: 25px;
  padding: 5px 16px;
  border-top: 1px solid rgba(48,54,61,.55);
  color: var(--text-muted);
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Workspace surfaces */
.workspace-surface { display: flex; flex: 1 1 auto; min-height: 0; position: relative; overflow: hidden; }
.chat-messages { width: 100%; min-height: 0; }
.native-view { position: absolute; inset: 0; background: var(--bg-primary); }
.native-view iframe { display: block; width: 100%; height: 100%; border: 0; background: var(--bg-primary); }
.chat-view.native-active .chat-input-area { display: none; }
.surface-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 100%;
  color: var(--text-muted);
  text-align: center;
}
.surface-state p { max-width: 440px; font-size: 14px; }
.message-loading { opacity: .72; }
.msg-bubble { white-space: pre-wrap; }
.msg-parts { display: flex; flex-direction: column; gap: 5px; margin-top: 5px; }
.msg-part-file,
.msg-part-tool,
.msg-part-error {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background: rgba(13,17,23,.55);
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 12px;
}
.msg-part-tool { border-left: 2px solid var(--accent-purple); }
.msg-part-error { border-left: 2px solid var(--accent-red); color: var(--accent-red); }
.msg-part-file svg { width: 12px; height: 12px; flex: 0 0 auto; }
.activity-card {
  border: 1px solid var(--border-color);
  border-left: 2px solid var(--accent-purple);
  border-radius: var(--radius-sm);
  background: rgba(13,17,23,.55);
  color: var(--text-secondary);
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 12px;
  overflow: hidden;
}
.activity-card.state-running, .activity-card.state-pending { border-left-color: var(--accent-blue); }
.activity-card.state-completed { border-left-color: var(--accent-green); }
.activity-card.state-error { border-left-color: var(--accent-red); }
.activity-card summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px; cursor: pointer; }
.activity-card summary:hover { background: var(--bg-tertiary); }
.activity-status { color: var(--text-muted); text-transform: uppercase; }
.activity-detail { display: grid; gap: 7px; padding: 8px; border-top: 1px solid var(--border-color); overflow: auto; }
.activity-detail pre { max-height: 280px; overflow: auto; white-space: pre-wrap; word-break: break-word; color: var(--text-secondary); }
.activity-detail .tool-error { color: var(--accent-red); }
.activity-marker { display: flex; justify-content: space-between; gap: 8px; padding: 3px 8px; border-left: 2px solid var(--border-color); color: var(--text-muted); font-family: 'SF Mono', 'Menlo', monospace; font-size: 11px; text-transform: uppercase; }
.activity-finish { border-left-color: var(--accent-green); }
.rich-text { white-space: pre-wrap; }
.code-block { position: relative; margin: 8px 0; padding: 10px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: #080c12; color: #d2dae4; overflow-x: auto; white-space: pre; font: 11px/1.55 'SF Mono', 'Menlo', monospace; }
.code-block[data-language]::before { content: attr(data-language); display: block; margin-bottom: 6px; color: var(--text-muted); font-size: 11px; text-transform: uppercase; }

/* Attachments and prompt */
.chat-input-area { position: relative; }
.chat-input-wrapper { align-items: center; }
.attach-control { position: relative; flex: 0 0 auto; }
.chat-icon-btn { border: 0; background: transparent; }
.attach-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  z-index: 30;
  width: 245px;
  padding: 5px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  box-shadow: var(--shadow-md);
}
.attach-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
}
.attach-menu button:hover { background: var(--bg-tertiary); }
.attachment-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 7px;
}
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 260px;
  padding: 3px 5px 3px 8px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 12px;
}
.attachment-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}
.attachment-chip button:hover { color: var(--accent-red); background: rgba(248,81,73,.08); }
.chat-send-btn:disabled { color: var(--text-muted); }
.chat-input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 20px;
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 12px;
}

/* Dialogs */
.app-dialog {
  width: min(520px, calc(100vw - 28px));
  max-height: min(720px, calc(100vh - 36px));
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.app-dialog::backdrop { background: rgba(1,4,9,.72); backdrop-filter: blur(2px); }

/* Author layout must NEVER override UA dialog:not([open]) { display: none }.
   Without this, .permission-dialog { display: flex } keeps a closed dialog
   visible (stale APROBACIÓN REQUERIDA box with "-" body after close()). */
dialog:not([open]),
.permission-dialog:not([open]) {
  display: none !important;
}

/* Permission modal — sticky footer + scrollable body only */
.permission-dialog {
  width: min(600px, calc(100vw - 28px));
  max-height: min(82vh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.permission-dialog[open] {
  display: flex !important;
}
.permission-dialog .permission-dialog-header {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--border-color);
}
.permission-dialog .permission-dialog-body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  margin-bottom: 0;
}
.permission-dialog .permission-dialog-footer {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border-color);
  border-bottom: 0;
  background: linear-gradient(180deg, rgba(8,11,13,.35), rgba(8,11,13,.72));
  box-shadow: 0 -8px 20px rgba(0,0,0,.28);
  z-index: 1;
}
.permission-dialog .permission-question {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-primary);
  margin-bottom: 0;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.permission-dialog .permission-context {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 0;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* Permission detail rows */
.perm-detail {
  display: flex;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  align-items: flex-start;
}
.perm-label {
  font-weight: 600;
  color: var(--text-muted);
  min-width: 88px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  flex-shrink: 0;
  padding-top: 2px;
}
.perm-value {
  color: var(--text-primary);
  font-size: 14px;
  word-break: break-word;
  min-width: 0;
}
.perm-command-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
  min-width: 0;
}
.perm-command-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.perm-command {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
  margin: 0;
}
.perm-command-preview {
  max-height: calc(1.45em * 6);
  overflow: hidden;
  position: relative;
  -webkit-mask-image: linear-gradient(180deg, #000 70%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 70%, transparent 100%);
}
.perm-command-full {
  max-height: min(42vh, 360px);
  overflow: auto;
}
.perm-command-full[hidden],
.perm-command-preview[hidden] {
  display: none !important;
}
.perm-command-toggle {
  align-self: flex-start;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.perm-command-toggle:hover,
.perm-command-toggle:focus-visible {
  color: var(--text-primary);
  border-color: var(--text-muted);
  outline: none;
}
.perm-command-toggle:focus-visible {
  box-shadow: 0 0 0 2px rgba(22,163,74,.35);
}
.perm-technical {
  margin-top: 6px;
  font-size: 12px;
}
.perm-technical summary {
  color: var(--text-muted);
  cursor: pointer;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
.perm-json {
  font-size: 12px;
  max-height: 180px;
  overflow: auto;
  background: var(--bg-tertiary);
  padding: 8px;
  border-radius: 4px;
  margin-top: 4px;
}
.permission-dialog .permission-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.permission-dialog .permission-dialog-footer .btn-approve {
  border-color: rgba(63,185,80,.55);
  color: var(--accent-green);
  background: rgba(63,185,80,.06);
  font-weight: 700;
}
.permission-dialog .permission-dialog-footer .btn-approve:hover:not(:disabled) {
  background: rgba(63,185,80,.12);
}
.permission-dialog .permission-dialog-footer .btn-deny {
  border-color: rgba(248,81,73,.5);
  color: var(--accent-red);
  background: transparent;
}
.permission-dialog .permission-dialog-footer .btn-deny:hover:not(:disabled) {
  background: rgba(248,81,73,.10);
}
.permission-dialog .permission-dialog-footer .btn-always {
  border-color: rgba(210,153,34,.55);
  color: var(--accent-yellow);
  background: transparent;
  font-weight: 700;
}
.permission-dialog .permission-dialog-footer .btn-always:hover:not(:disabled) {
  background: rgba(210,153,34,.10);
}
.permission-dialog .permission-dialog-footer button {
  min-height: 36px;
  min-width: 110px;
  padding: 7px 12px;
  font-size: 13px;
  letter-spacing: .03em;
}
@media (max-width: 768px) {
  .permission-dialog {
    width: min(100vw - 16px, 600px);
    max-height: min(88vh, 720px);
  }
  .permission-dialog .permission-dialog-footer {
    justify-content: stretch;
  }
  .permission-dialog .permission-dialog-footer button {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 42px;
  }
  .perm-label { min-width: 72px; }
}
@media (max-width: 375px) {
  .permission-dialog .permission-dialog-footer {
    flex-direction: column-reverse;
  }
  .permission-dialog .permission-dialog-footer button {
    width: 100%;
  }
}

/* Native MCP OAuth fallback. Positioning/centering is inherited from the
   global dialog.app-dialog[open] golden rule. */
.mcp-auth-dialog {
  width: min(480px, calc(100vw - 28px));
}
.mcp-auth-dialog .dialog-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mcp-auth-open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  text-decoration: none;
}
@media (max-width: 375px) {
  .mcp-auth-dialog {
    width: calc(100vw - 16px);
  }
  .mcp-auth-open-link {
    min-height: 44px;
  }
}
.dialog-header,
.dialog-footer,
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--border-color);
}
.dialog-header h2, .settings-header h2 { font-size: 17px; font-weight: 600; }
.eyebrow { display: block; margin-bottom: 2px; color: var(--text-muted); font-size: 11px; font-weight: 700; letter-spacing: .65px; }
.dialog-body { display: flex; flex-direction: column; gap: 13px; padding: 16px; overflow-y: auto; }
.dialog-body > p { color: var(--text-secondary); font-size: 14px; }
.dialog-note { padding: 9px; border: 1px solid rgba(210,153,34,.22); border-radius: var(--radius-sm); background: rgba(210,153,34,.06); }
.dialog-footer { justify-content: flex-end; border-top: 1px solid var(--border-color); border-bottom: 0; }
.form-field { display: flex; flex-direction: column; gap: 5px; color: var(--text-secondary); font-size: 13px; }
.form-field input,
.file-search-row input {
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
}
.form-field input:focus, .file-search-row input:focus { border-color: var(--accent-blue); }
.secondary-btn, .primary-btn { min-height: 31px; padding: 5px 11px; font-size: 13px; }
.primary-btn { border-color: rgba(88,166,255,.55); color: var(--accent-blue); }
.primary-btn:hover:not(:disabled) { background: rgba(88,166,255,.10); }
.file-dialog { width: min(660px, calc(100vw - 28px)); }
.dialog-status-line { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 13px; }
.file-search-row { display: grid; grid-template-columns: 1fr auto; gap: 7px; }

/* Settings drawer */
.drawer-backdrop {
  position: fixed;
  inset: var(--header-height) 0 0;
  z-index: 250;
  border: 0;
  background: rgba(1,4,9,.68);
  cursor: default;
}
.settings-drawer {
  position: fixed;
  top: var(--header-height);
  right: 0;
  bottom: 0;
  z-index: 260;
  display: flex;
  flex-direction: column;
  width: min(720px, calc(100vw - 48px));
  border-left: 1px solid var(--border-color);
  background: var(--bg-secondary);
  box-shadow: -12px 0 30px rgba(0,0,0,.35);
}
.session-context-drawer {
  position: fixed; top: var(--header-height); right: 0; bottom: 0; z-index: 270;
  display: flex; flex-direction: column; width: min(430px, calc(100vw - 32px));
  border-left: 1px solid var(--border-color); background: var(--bg-secondary);
  box-shadow: -12px 0 30px rgba(0,0,0,.35);
}
.session-context-content { padding: 14px; overflow-y: auto; }
.settings-header { flex: 0 0 auto; min-height: 58px; }
.settings-header-actions { display: flex; align-items: center; gap: 8px; }
.settings-layout { display: grid; grid-template-columns: 145px 1fr; min-height: 0; flex: 1; }
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
  border-right: 1px solid var(--border-color);
  background: var(--bg-primary);
  overflow-y: auto;
}
.settings-nav-btn {
  min-height: 31px;
  padding: 6px 9px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
}
.settings-nav-btn:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.settings-nav-btn.active { color: var(--accent-blue); background: rgba(88,166,255,.09); }
.settings-content { min-width: 0; overflow-y: auto; }
.settings-section { display: none; padding: 18px; }
.settings-section.active { display: block; }
.settings-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 13px; }
.settings-section-heading h3 { font-size: 16px; font-weight: 600; }
.settings-data { display: grid; gap: 7px; }
.settings-kv {
  display: grid;
  grid-template-columns: minmax(100px, 34%) 1fr;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  font-size: 13px;
}
.settings-kv dt { color: var(--text-muted); }
.settings-kv dd { min-width: 0; color: var(--text-primary); overflow-wrap: anywhere; }
.resource-list { display: flex; flex-direction: column; gap: 6px; max-height: 460px; overflow-y: auto; }
.resource-card,
.file-result-btn {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
}
.file-result-btn { width: 100%; cursor: pointer; text-align: left; }
.file-result-btn:hover { border-color: var(--accent-blue); background: rgba(88,166,255,.05); }
.resource-card-main { min-width: 0; }
.resource-name { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.resource-description { margin-top: 2px; color: var(--text-muted); font-size: 12px; overflow-wrap: anywhere; }
.resource-meta { color: var(--text-muted); font-family: 'SF Mono', 'Menlo', monospace; font-size: 11px; white-space: nowrap; }
.resource-empty { padding: 22px 12px; color: var(--text-muted); text-align: center; font-size: 13px; }

/* Settings Control Plane: loading, error, info, subsection */
.settings-loading {
  padding: 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  animation: settingsPulse 1.5s ease-in-out infinite;
}
@keyframes settingsPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
.settings-error {
  padding: 14px;
  background: rgba(248,81,73,.06);
  border: 1px solid rgba(248,81,73,.2);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.settings-error-msg {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.settings-error-detail {
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
}
.settings-retry-btn {
  margin-top: 4px;
  padding: 4px 12px;
  font-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
}
.settings-retry-btn:hover { background: var(--bg-secondary); border-color: var(--accent-blue); }
.settings-info-box {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(88,166,255,.06);
  border: 1px solid rgba(88,166,255,.15);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.settings-info-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(88,166,255,.15);
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.settings-subsection {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}
.settings-subsection h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.settings-kv-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 4px;
}

/* --- Agent Admin Card (Settings → Agents) --- */
.agent-admin-card {
  flex-direction: column;
  align-items: stretch;
}
.agent-admin-card .resource-card-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.agent-role-type {
  font-size: 12px;
  color: var(--accent-blue);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.agent-native-model {
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Menlo', monospace;
}
.agent-model-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.agent-model-select,
.agent-model-id-select {
  font-size: 12px;
  padding: 2px 4px;
  border: 1px solid var(--border-color);
  border-radius: 3px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  max-width: 200px;
}
.agent-model-select:focus,
.agent-model-id-select:focus {
  border-color: var(--accent-blue);
  outline: none;
}

/* --- Responsive: Tablet (1024px) --- */
@media (max-width: 1024px) {
  .monitoring-panel { width: 270px; }
  .chat-message { max-width: 90%; }
  .workspace-controls { flex-wrap: wrap; }
  .model-control { flex-basis: 180px; }
  .capability-shortcuts { margin-left: 0; }
  .toolbar-btn span { display: none; }
}

/* --- Responsive: Mobile (768px) --- */
@media (max-width: 768px) {
  .app-body { flex-direction: column; height: auto; min-height: 0; }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-normal);
  }
  .sidebar.mobile-open { max-height: 40vh; overflow-y: auto; }
  .chat-panel { min-height: 0; flex: 1; }
  .monitoring-panel {
    position: fixed; top: var(--header-height); right: 0; bottom: 0; z-index: 230;
    width: min(340px, calc(100vw - 28px)); max-height: none;
    border-left: 1px solid var(--border-color); border-top: 0;
    transform: translateX(105%);
  }
  .monitoring-panel.mobile-open { transform: translateX(0); }
  .monitoring-panel.collapsed { width: min(340px, calc(100vw - 28px)); }
  .monitoring-backdrop:not(.hidden) { display: block; position: fixed; inset: var(--header-height) 0 0; z-index: 220; border: 0; background: rgba(1,4,9,.68); }
  .mobile-menu-btn { display: flex; }
  .workspace-toolbar-primary { padding: 8px 12px; }
  .workspace-controls { padding: 8px 12px 10px; }
  .session-control { flex: 1 1 220px; }
  .control-cluster { flex: 1 1 130px; }
  .model-control { flex: 1 1 220px; }
  .capability-shortcuts { flex: 1 0 100%; }
  .shortcut-btn { flex: 1; }
  .chat-messages { padding: 14px; }
  .chat-message.msg-user { max-width: 88%; }
  .execution-bar { padding: 7px 12px; gap: 6px; }
  .execution-separator { display: none; }
  #executionModel { flex-basis: 100%; }
  .chat-input-area { padding: 10px 14px; }
  .settings-drawer { width: 100%; }
  .session-context-drawer { width: 100%; }
  .settings-layout { grid-template-columns: 112px 1fr; }
}

/* --- Responsive: Small Mobile (375px) --- */
@media (max-width: 375px) {
  .obs-cards { grid-template-columns: 1fr; }
  .chat-message { max-width: 95%; }
  .msg-avatar { width: 24px; height: 24px; }
  .msg-avatar svg { width: 14px; height: 14px; }
  .msg-bubble { padding: 8px 12px; font-size: 14px; }
  .agents-list { max-height: 180px; }
  .agent-row { padding: 5px 12px; gap: 6px; }
  .agent-icon { width: 14px; height: 14px; }
  .agent-name { font-size: 13px; }
  .agent-status { font-size: 11px; }
  .workspace-toolbar-primary { align-items: flex-start; }
  .toolbar-actions { gap: 4px; }
  .workspace-controls { gap: 6px; }
  .session-control, .control-cluster, .model-control { flex-basis: 100%; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav {
    flex-direction: row;
    border-right: 0;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
  }
  .settings-nav-btn { flex: 0 0 auto; }
  .settings-section { padding: 13px; }
  .settings-kv { grid-template-columns: 1fr; gap: 3px; }
  .chat-input-footer { align-items: flex-start; }
}

/* --- Accessibility --- */
:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .agent-row.agent-pulse { animation: none; }
  .chat-message { animation: none; }
}

/* --- POLI LIVE WORKFLOW (namespaced overlay) --- */
.poli-live-workflow-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: rgba(22,163,74,.06);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}
.poli-live-workflow-trigger:hover,
.poli-live-workflow-trigger[aria-expanded="true"] {
  color: var(--text-primary);
  border-color: rgba(22,163,74,.45);
  background: rgba(22,163,74,.12);
}
.poli-live-workflow-trigger-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  box-shadow: none;
  flex-shrink: 0;
}
.poli-live-workflow-trigger-dot[data-live="active"] {
  background: var(--accent-green);
  box-shadow: 0 0 0 0 rgba(22,163,74,.55);
  animation: poli-live-workflow-pulse 1.4s ease-in-out infinite;
}
.poli-live-workflow-trigger-dot[data-live="attention"] {
  background: var(--accent-yellow);
  box-shadow: 0 0 0 0 rgba(210,153,34,.55);
  animation: poli-live-workflow-pulse 1.2s ease-in-out infinite;
}
.poli-live-workflow-trigger-dot[data-live="error"] { background: var(--accent-red); }
.poli-live-workflow-trigger-dot[data-live="paused"] { background: var(--accent-orange, var(--accent-yellow)); }

.poli-live-workflow-drawer {
  position: fixed;
  top: var(--header-height);
  right: 0;
  bottom: 0;
  z-index: 280;
  display: flex;
  flex-direction: column;
  width: min(410px, calc(100vw - 28px));
  border-left: 1px solid var(--border-color);
  background:
    linear-gradient(180deg, rgba(22,163,74,.04), transparent 120px),
    var(--bg-secondary);
  box-shadow: -16px 0 40px rgba(0,0,0,.45);
  backdrop-filter: blur(20px) saturate(135%);
  overflow: hidden;
}
.poli-live-workflow-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.poli-live-workflow-eyebrow {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--accent-green);
  margin-bottom: 4px;
}
.poli-live-workflow-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--text-primary);
  line-height: 1.2;
}
.poli-live-workflow-header-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.poli-live-workflow-state {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .04em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid transparent;
}
.poli-live-workflow-state[data-state="working"],
.poli-live-workflow-state[data-state="tool"] {
  color: var(--accent-green);
  background: rgba(22,163,74,.12);
  border-color: rgba(22,163,74,.35);
}
.poli-live-workflow-state[data-state="waiting_approval"] {
  color: var(--accent-yellow);
  background: rgba(210,153,34,.12);
  border-color: rgba(210,153,34,.4);
}
.poli-live-workflow-state[data-state="error"],
.poli-live-workflow-state[data-state="cancelled"] {
  color: var(--accent-red);
  background: rgba(248,81,73,.1);
  border-color: rgba(248,81,73,.35);
}
.poli-live-workflow-state[data-state="paused"] {
  color: var(--accent-orange, var(--accent-yellow));
  background: rgba(210,153,34,.1);
  border-color: rgba(210,153,34,.35);
}
.poli-live-workflow-state[data-state="interrupted"] {
  color: var(--text-secondary);
  background: var(--bg-tertiary);
}
.poli-live-workflow-state[data-state="complete"] {
  color: var(--accent-green);
  background: rgba(22,163,74,.08);
  border-color: rgba(22,163,74,.25);
}
.poli-live-workflow-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.poli-live-workflow-live-pill {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
}
.poli-live-workflow-live-pill[data-live="active"] {
  color: #052e16;
  background: var(--accent-green);
  border-color: transparent;
  animation: poli-live-workflow-pulse 1.4s ease-in-out infinite;
}
.poli-live-workflow-live-pill[data-live="attention"] {
  color: #1a1200;
  background: var(--accent-yellow);
  border-color: transparent;
}
.poli-live-workflow-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.poli-live-workflow-close:hover { color: var(--text-primary); border-color: var(--text-muted); }

.poli-live-workflow-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0,0,0,.18);
  flex-shrink: 0;
}
.poli-live-workflow-meta-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.poli-live-workflow-meta-row span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.poli-live-workflow-meta-row strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.poli-live-workflow-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 14px 18px;
}

.poli-live-workflow-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding: 36px 16px;
  color: var(--text-muted);
}
.poli-live-workflow-empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.03);
  border: 1px dashed rgba(255,255,255,.14);
  color: var(--text-muted);
  margin-bottom: 4px;
}
.poli-live-workflow-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}
.poli-live-workflow-empty-hint {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 240px;
  line-height: 1.45;
}
.poli-live-workflow-empty[data-kind="error"] .poli-live-workflow-empty-icon {
  border-color: rgba(248,81,73,.4);
  color: var(--accent-red);
}

.poli-live-workflow-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.poli-live-workflow-timeline:empty { display: none; }
.poli-live-workflow-node {
  position: relative;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  padding: 0 0 14px;
  min-width: 0;
}
.poli-live-workflow-node:last-child { padding-bottom: 0; }
.poli-live-workflow-node-rail {
  position: relative;
  display: flex;
  justify-content: center;
}
.poli-live-workflow-node:not(:last-child) .poli-live-workflow-node-rail::after {
  content: "";
  position: absolute;
  top: 16px;
  bottom: -14px;
  left: 50%;
  width: 1px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,.06));
}
.poli-live-workflow-node-dot {
  position: relative;
  z-index: 1;
  width: 14px;
  height: 14px;
  margin-top: 3px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  background: var(--bg-primary);
  flex-shrink: 0;
  box-sizing: border-box;
}
.poli-live-workflow-node[data-status="completed"] .poli-live-workflow-node-dot {
  border-color: var(--accent-green);
  background: rgba(22,163,74,.25);
  box-shadow: inset 0 0 0 2px var(--bg-primary), 0 0 0 1px rgba(22,163,74,.35);
}
.poli-live-workflow-node[data-status="active"] .poli-live-workflow-node-dot {
  border-color: var(--accent-green);
  background: radial-gradient(circle at 40% 35%, #86efac, var(--accent-green));
  box-shadow: 0 0 0 3px rgba(22,163,74,.18), 0 0 12px rgba(22,163,74,.45);
  animation: poli-live-workflow-aura 1.6s ease-in-out infinite;
}
.poli-live-workflow-node[data-status="approval"] .poli-live-workflow-node-dot {
  border-color: var(--accent-yellow);
  background: var(--accent-yellow);
  box-shadow: 0 0 0 3px rgba(210,153,34,.2);
}
.poli-live-workflow-node[data-status="error"] .poli-live-workflow-node-dot {
  border-color: var(--accent-red);
  background: rgba(248,81,73,.35);
  box-shadow: 0 0 0 3px rgba(248,81,73,.18);
}
.poli-live-workflow-node[data-status="paused"] .poli-live-workflow-node-dot {
  border-color: var(--accent-yellow);
  background: rgba(210,153,34,.3);
}
.poli-live-workflow-node[data-status="stopped"] .poli-live-workflow-node-dot {
  border-color: var(--text-secondary);
  background: rgba(255,255,255,.12);
}
.poli-live-workflow-node[data-status="cancelled"] .poli-live-workflow-node-dot {
  border-color: var(--accent-red);
  background: transparent;
}
.poli-live-workflow-node[data-status="pending"] .poli-live-workflow-node-dot {
  border-color: rgba(255,255,255,.22);
  background: transparent;
  opacity: .75;
}
.poli-live-workflow-node-card {
  min-width: 0;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.poli-live-workflow-node[data-status="active"] .poli-live-workflow-node-card {
  background: linear-gradient(100deg, rgba(22,163,74,.14), rgba(22,163,74,.04) 70%);
  border-color: rgba(22,163,74,.35);
  position: relative;
  overflow: hidden;
}
.poli-live-workflow-node[data-status="active"] .poli-live-workflow-node-card::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(151,255,191,.14), transparent);
  transform: translateX(-120%);
  animation: poli-live-workflow-shimmer 1.8s linear infinite;
  pointer-events: none;
}
.poli-live-workflow-node[data-status="approval"] .poli-live-workflow-node-card {
  background: rgba(210,153,34,.1);
  border-color: rgba(210,153,34,.35);
}
.poli-live-workflow-node[data-status="error"] .poli-live-workflow-node-card {
  background: rgba(248,81,73,.08);
  border-color: rgba(248,81,73,.3);
}
.poli-live-workflow-node-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.poli-live-workflow-node-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.poli-live-workflow-node[data-status="pending"] .poli-live-workflow-node-label,
.poli-live-workflow-node[data-status="completed"] .poli-live-workflow-node-label {
  color: var(--text-secondary);
  font-weight: 600;
}
.poli-live-workflow-node-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}
.poli-live-workflow-node[data-status="active"] .poli-live-workflow-node-badge {
  background: var(--accent-green);
  color: #052e16;
  border-color: transparent;
}
.poli-live-workflow-node[data-status="approval"] .poli-live-workflow-node-badge {
  background: var(--accent-yellow);
  color: #1a1200;
  border-color: transparent;
}
.poli-live-workflow-node[data-status="error"] .poli-live-workflow-node-badge {
  background: rgba(248,81,73,.2);
  color: #ffd7d4;
  border-color: rgba(248,81,73,.4);
}
.poli-live-workflow-node[data-status="completed"] .poli-live-workflow-node-badge {
  background: rgba(22,163,74,.14);
  color: var(--accent-green);
  border-color: rgba(22,163,74,.3);
}
.poli-live-workflow-node-detail {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
  word-break: break-word;
}
.poli-live-workflow-node-meta {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.poli-live-workflow-node-meta span {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0,0,0,.28);
  border: 1px solid rgba(255,255,255,.06);
}

.poli-live-workflow-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  border-top: 1px solid var(--border-color);
  background: rgba(0,0,0,.22);
  font-size: 11.5px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.poli-live-workflow-footer-flag {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .04em;
}

@keyframes poli-live-workflow-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22,163,74,.5); transform: scale(1); }
  50% { box-shadow: 0 0 0 5px rgba(22,163,74,0); transform: scale(.92); }
}
@keyframes poli-live-workflow-aura {
  0%, 100% { box-shadow: 0 0 0 3px rgba(22,163,74,.15), 0 0 10px rgba(22,163,74,.35); }
  50% { box-shadow: 0 0 0 5px rgba(22,163,74,.08), 0 0 16px rgba(22,163,74,.55); }
}
@keyframes poli-live-workflow-shimmer {
  from { transform: translateX(-140%); }
  to { transform: translateX(360%); }
}
@media (prefers-reduced-motion: reduce) {
  .poli-live-workflow-trigger-dot[data-live],
  .poli-live-workflow-live-pill[data-live="active"],
  .poli-live-workflow-node[data-status="active"] .poli-live-workflow-node-dot {
    animation: none !important;
  }
  .poli-live-workflow-node[data-status="active"] .poli-live-workflow-node-card::after {
    animation: none;
    opacity: .25;
    transform: none;
    width: 100%;
  }
}
@media (max-width: 768px) {
  .poli-live-workflow-drawer { width: min(100vw, calc(100vw - 8px)); }
  .poli-live-workflow-trigger-label { display: none; }
}
@media (max-width: 375px) {
  .poli-live-workflow-meta { grid-template-columns: 1fr; }
}

.catalog-toolbar { margin-bottom: 10px; }
.settings-input {
  min-width: 0; width: 100%; box-sizing: border-box; padding: 9px 11px;
  color: var(--text-primary); background: rgba(5,10,12,.72);
  border: 1px solid var(--border-color); border-radius: 10px;
}
.settings-input:focus { outline: 2px solid rgba(22,163,74,.35); border-color: var(--accent-green); }
.resource-card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.inline-admin-form { display: grid; grid-template-columns: repeat(auto-fit,minmax(130px,1fr)); gap: 8px; margin: 10px 0 18px; }
.inline-admin-form button { min-height: 36px; }
.admin-metrics { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-bottom: 18px; }
.admin-metrics div { padding: 14px; border: 1px solid var(--border-color); border-radius: 14px; background: rgba(255,255,255,.025); }
.admin-metrics strong,.admin-metrics span { display: block; }
.admin-metrics strong { font-size: 24px; color: var(--accent-green); }
.admin-metrics span { margin-top: 4px; color: var(--text-muted); font-size: 12px; }
.admin-table { display: grid; gap: 7px; margin: 8px 0 20px; }
.admin-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: 12px; }
.admin-row small { display: block; margin-top: 3px; color: var(--text-muted); }
.admin-row select { color: var(--text-primary); background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: 8px; padding: 7px; }
@media (max-width: 700px) { .admin-metrics { grid-template-columns: repeat(2,1fr); } }
.admin-user-card { align-items: flex-start; }
.admin-user-actions { display:flex; gap:6px; flex-wrap:wrap; justify-content:flex-end; }
.subscription-help { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:8px; margin:8px 0 16px; }
.subscription-help div,.communication-module { border:1px solid var(--border-color); border-radius:12px; padding:12px; background:rgba(255,255,255,.02); }
.subscription-help b,.subscription-help small { display:block; }
.subscription-help small { color:var(--text-muted); margin-top:4px; }
.communication-toolbar,.communication-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.communication-form { display:grid; gap:10px; }
.communication-form label { display:grid; gap:5px; color:var(--text-muted); font-size:12px; }
.communication-form textarea { resize:vertical; min-height:90px; }
.communication-html { font-family:var(--font-mono); }
.bulk-client-list { max-height:280px; overflow:auto; display:grid; gap:5px; margin:10px 0; }
.bulk-client { display:flex; align-items:center; gap:8px; padding:8px; border:1px solid var(--border-color); border-radius:9px; }
@media (max-width:700px){.communication-grid,.communication-toolbar{grid-template-columns:1fr}.admin-user-card{display:grid}.admin-user-actions{justify-content:flex-start}}
.backup-hero { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:18px; border:1px solid rgba(22,163,74,.35); border-radius:16px; background:linear-gradient(135deg,rgba(22,163,74,.13),rgba(255,255,255,.025)); }
.backup-hero h4 { margin:5px 0; font-size:18px; }
.backup-hero p,.backup-scope-note { margin:0; color:var(--text-muted); font-size:12px; }
.backup-metrics { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin:12px 0; }
.backup-metrics div { padding:13px; border:1px solid var(--border-color); border-radius:12px; background:rgba(255,255,255,.025); }
.backup-metrics strong,.backup-metrics span { display:block; }
.backup-metrics strong { color:var(--accent-green); font-size:20px; }
.backup-metrics span { margin-top:3px; color:var(--text-muted); font-size:11px; }
.backup-actions { display:flex; flex-wrap:wrap; gap:8px; margin:12px 0; }
.backup-download { display:inline-flex; align-items:center; text-decoration:none; }
.backup-scope-note { padding:10px 12px; border-left:2px solid var(--warning-color,#d79a21); background:rgba(215,154,33,.06); }
.backup-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin:16px 0; }
.backup-grid section { min-width:0; padding:14px; border:1px solid var(--border-color); border-radius:14px; background:rgba(255,255,255,.018); }
.backup-grid h4 { margin:0 0 10px; }
.backup-chip-list { display:flex; flex-wrap:wrap; gap:6px; max-height:180px; overflow:auto; }
.backup-chip { display:inline-flex; flex-direction:column; max-width:100%; padding:7px 9px; border:1px solid var(--border-color); border-radius:9px; background:var(--bg-primary); }
.backup-chip b { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:11px; }
.backup-chip small { color:var(--text-muted); font-size:9px; text-transform:uppercase; }
.backup-history { display:grid; gap:7px; }
.backup-restore { margin:16px 0; padding:14px; border:1px solid rgba(190,55,55,.35); border-radius:14px; background:rgba(190,55,55,.045); }
.backup-restore>h4,.backup-restore h5 { margin:0 0 6px; }
.backup-restore>p { margin:0 0 12px; color:var(--text-muted); font-size:12px; }
.backup-restore-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.backup-restore-grid section { min-width:0; display:grid; align-content:start; gap:7px; }
@media (max-width:700px) { .backup-metrics,.backup-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media (max-width:700px) { .backup-restore-grid { grid-template-columns:1fr; } }
@media (max-width:480px) { .backup-hero { align-items:flex-start; flex-direction:column; } .backup-metrics,.backup-grid { grid-template-columns:1fr; } }
.remote-status-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:8px; margin-bottom:12px; }
.remote-status-grid div { padding:10px 12px; border:1px solid var(--border-color); border-radius:12px; }
.remote-status-grid span,.remote-status-grid strong { display:block; }
.remote-status-grid span { color:var(--text-muted); font-size:12px; }
.remote-status-grid strong { margin-top:4px; color:var(--accent-green); font-size:14px; }
.remote-server-form { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.remote-auth-method { grid-column:1/-1; border:1px solid var(--border-color); border-radius:12px; padding:10px 12px; margin:0; display:flex; flex-direction:column; gap:6px; min-width:0; }
.remote-auth-method legend { font-size:13px; color:var(--text-muted); padding:0 4px; }
.remote-auth-option { display:flex; align-items:center; gap:8px; font-size:14px; cursor:pointer; }
.remote-auth-option input[type="radio"] { accent-color:var(--accent-green); margin:0; }
.remote-auth-pane { grid-column:1/-1; display:flex; flex-direction:column; gap:8px; min-width:0; }
.remote-auth-pane.hidden { display:none; }
.remote-key { grid-column:auto; min-height:110px; resize:vertical; font-family:var(--font-mono); font-size:12px; }
.remote-key-file { grid-column:auto; width:100%; color:var(--text-primary); font-size:13px; }
.remote-key-filename { font-family:var(--font-mono); font-size:12px; color:var(--text-secondary); word-break:break-all; min-height:14px; }
.remote-actions { grid-column:1/-1; display:flex; flex-wrap:wrap; gap:8px; }
.remote-result { white-space:pre-wrap; max-height:260px; overflow:auto; margin:12px 0 18px; padding:12px; border-radius:12px; border:1px solid var(--border-color); background:rgba(0,0,0,.25); color:var(--text-secondary); font:10px/1.55 var(--font-mono); }
.remote-result.remote-error { border-color:rgba(248,81,73,.4); color:var(--accent-red); }
@media (max-width:600px) { .remote-server-form { grid-template-columns:1fr; } .remote-auth-method,.remote-auth-pane,.remote-actions { grid-column:1; } }

/* ─── V267 Login Screen ─────────────────────────────────────── */
.login-screen {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg-primary); font-family: var(--font-sans);
}
.login-screen.hidden { display: none; }
.login-box {
  width: 360px; max-width: 92vw;
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); padding: 32px 28px;
}
.login-box h2 { font-size: 18px; font-weight: 600; color: var(--text-primary); margin: 0 0 4px; }
.login-box .eyebrow { font-size: 12px; color: var(--text-muted); }
.login-field { margin: 14px 0 0; }
.login-field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.login-field input {
  width: 100%; box-sizing: border-box; padding: 8px 10px; font-size: 15px;
  background: var(--bg-primary); color: var(--text-primary);
  border: 1px solid var(--border-color); border-radius: var(--radius-sm);
}
.login-field input:focus { border-color: var(--accent-blue); outline: none; }
.login-btn {
  margin-top: 16px; width: 100%; padding: 9px; font-size: 14px; font-weight: 600;
  background: var(--accent-blue); color: #fff; border: none;
  border-radius: var(--radius-sm); cursor: pointer;
}
.login-btn:hover { filter: brightness(1.08); }
.login-err {
  margin-top: 10px; padding: 8px; font-size: 12px; text-align: center;
  color: #f85149; background: rgba(248,81,73,.06);
  border: 1px solid rgba(248,81,73,.15); border-radius: var(--radius-sm);
  display: none;
}
.login-err.visible { display: block; }
.login-setup { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-color); }
.login-setup p { font-size: 13px; color: var(--text-muted); margin: 0 0 12px; }
.login-screen {
  background: radial-gradient(circle at 50% 32%, rgba(22,163,74,.2), transparent 34%), linear-gradient(145deg,#07090b,#111719);
}
.login-card {
  width: min(420px, calc(100vw - 32px));
  padding: 34px;
  background: rgba(20,25,28,.78);
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 24px;
  backdrop-filter: blur(24px) saturate(140%);
  box-shadow: 0 28px 90px rgba(0,0,0,.55), inset 0 1px rgba(255,255,255,.06);
}
.login-header { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 24px; }
.login-header h1 { margin-top: 15px; font-size: 26px; letter-spacing: -.03em; }
.login-subtitle { margin-top: 5px; color: var(--text-secondary); font-size: 14px; }
.login-logo { width: 94px; height: 94px; object-fit: cover; border-radius: 24px; filter: drop-shadow(0 16px 32px rgba(0,0,0,.45)); }
.login-error { margin-top: 10px; color: var(--accent-red); font-size: 13px; }
/* V267-C: Admin identity display in login/setup */
.login-identity {
  margin-bottom: 14px; padding: 10px 12px;
  background: var(--bg-primary); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); text-align: center;
}
.login-identity-role {
  display: block; font-size: 12px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px;
}
.login-identity-email {
  display: block; font-size: 15px; color: var(--text-primary); font-weight: 500;
}

/* --- Agent Live Dock: premium large-format identity, desktop only --- */
.workspace-toolbar-primary { min-height: 126px; padding-block: 5px; }
.workspace-dock-zone { flex: 1 1 auto; min-width: 0; height: 116px; display: flex; align-items: center; }
.agent-live-dock {
  display: none;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 116px;
  min-width: 0;
  overflow: hidden;
}
.agent-live-dock.is-visible { display: flex; }
.agent-live-dock-slots { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; }

.message-preview-btn {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: none;
  color: var(--accent-green, #28d17c);
  font: 700 15px/1 sans-serif;
  cursor: pointer;
}
.message-preview-btn:hover { background: rgba(40,209,124,.15); }
.agent-live-slot {
  position: relative;
  flex: 0 0 108px;
  width: 108px;
  height: 114px;
  display: grid;
  grid-template-rows: 92px 17px 2px;
  justify-items: center;
  align-items: center;
  padding: 1px 5px 2px;
  border-radius: 13px;
  border: 1px solid transparent;
  background: linear-gradient(180deg, rgba(255,255,255,.018), rgba(255,255,255,.006));
  cursor: default;
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}
.agent-live-slot[data-state="working"] { border-color: rgba(22,163,74,.32); background: linear-gradient(180deg, rgba(22,163,74,.07), rgba(22,163,74,.018)); box-shadow: 0 0 20px rgba(22,163,74,.11), inset 0 1px rgba(255,255,255,.035); }
.agent-live-slot[data-state="waiting_approval"] { border-color: rgba(210,153,34,.35); background: rgba(210,153,34,.025); }
.agent-live-slot[data-state="error"],
.agent-live-slot[data-state="stalled"] { border-color: rgba(248,81,73,.34); background: rgba(248,81,73,.02); }
.agent-live-avatar,
.alid-live-preview {
  position: relative;
  width: 96px;
  height: 96px;
  overflow: hidden;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.agent-live-lottie-stage { position: absolute; inset: 0; transform-origin: 50% 50%; }
.agent-live-lottie-stage > svg { display: block; width: 100% !important; height: 100% !important; overflow: visible; }
.agent-live-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(248,81,73,.4);
  border-radius: 50%;
  background: rgba(248,81,73,.08);
  color: var(--accent-red);
  font-size: 13px;
  font-weight: 700;
  user-select: none;
}
.agent-live-fallback.hidden { display: none !important; }
.agent-live-name { max-width: 100%; padding-inline: 2px; font-size: 13.5px; font-weight: 600; line-height: 1.1; letter-spacing: -.01em; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.agent-live-slot[data-state="working"] .agent-live-name { color: var(--accent-green); }
.agent-live-slot[data-state="waiting_approval"] .agent-live-name { color: var(--accent-yellow); }
.agent-live-slot[data-state="error"] .agent-live-name,
.agent-live-slot[data-state="stalled"] .agent-live-name { color: var(--accent-red); }
.agent-live-bar { width: 76%; height: 2px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; }
.agent-live-bar i { display: block; width: 38%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, transparent, var(--accent-green), transparent); transform: translateX(-120%); opacity: 0; }
.agent-live-slot[data-state="working"] .agent-live-bar i { opacity: 1; animation: agent-live-indeterminate 1.1s linear infinite; }
.agent-live-dock-more { flex: 0 0 auto; min-width: 38px; height: 32px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--border-color); background: rgba(255,255,255,.035); color: var(--text-secondary); font-size: 13px; font-weight: 700; cursor: pointer; }
.agent-live-dock-more:hover { color: var(--text-primary); border-color: var(--text-muted); }
.agent-live-dock-more.hidden { display: none !important; }

/* Settings — AGENTES / IDENTIDAD VISUAL */
.alid-settings { display: flex; flex-direction: column; gap: 11px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-color); }
.alid-settings-title { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.alid-toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-secondary); }
.alid-toggle input { accent-color: var(--accent-green); }
.alid-hint { font-size: 13px; color: var(--text-muted); line-height: 1.4; }
.alid-field { display: grid; gap: 4px; color: var(--text-muted); font-size: 12px; font-weight: 650; letter-spacing: .03em; text-transform: uppercase; }
.alid-field input, .alid-field select, .alid-tuning input { width: 100%; min-height: 31px; padding: 5px 8px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--bg-primary); color: var(--text-primary); font-size: 14px; text-transform: none; }
.alid-real-id { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: rgba(255,255,255,.02); }
.alid-real-id span { color: var(--text-muted); font-size: 11px; letter-spacing: .08em; }
.alid-real-id strong { color: var(--text-primary); font-family: 'SF Mono','Menlo',monospace; font-size: 13px; }
.alid-preview-row { display: flex; align-items: center; gap: 14px; min-height: 94px; padding: 8px 14px; border: 1px solid rgba(22,163,74,.22); border-radius: var(--radius-md); background: linear-gradient(135deg, rgba(22,163,74,.055), rgba(255,255,255,.012)); }
.alid-live-preview { width: 82px; height: 82px; }
.alid-preview-row > div:last-child { display: flex; flex-direction: column; gap: 2px; }
.alid-preview-row strong { color: var(--text-primary); font-size: 14px; }
.alid-preview-row small { color: var(--text-muted); font-size: 12px; }
.alid-catalog { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; max-height: 338px; padding: 2px 4px 2px 2px; overflow-y: auto; overscroll-behavior: contain; }
.alid-character-card { position: relative; min-height: 102px; padding: 7px 5px 8px; border: 1px solid var(--border-color); border-radius: 10px; background: linear-gradient(180deg, var(--bg-primary), rgba(255,255,255,.012)); color: var(--text-secondary); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; cursor: pointer; overflow: hidden; }
.alid-character-card:hover:not(:disabled), .alid-character-card:focus-visible { color: var(--text-primary); border-color: var(--text-muted); background: var(--bg-tertiary); }
.alid-character-card.selected { color: var(--accent-green); border-color: rgba(22,163,74,.55); background: linear-gradient(180deg, rgba(22,163,74,.09), rgba(22,163,74,.025)); box-shadow: inset 0 0 0 1px rgba(22,163,74,.08); }
.alid-character-card:disabled { cursor: wait; opacity: .56; }
.alid-character-card.is-unavailable { cursor: not-allowed; opacity: .36; filter: saturate(.45); }
.alid-card-preview { position: relative; display: grid; place-items: center; width: 62px; height: 62px; overflow: hidden; }
.alid-card-preview .agent-live-fallback { font-size: 11px; }
.alid-character-label { max-width: 100%; min-height: 22px; display: flex; align-items: center; justify-content: center; text-align: center; line-height: 1.1; }
.alid-variant { position: absolute; top: 5px; right: 5px; padding: 2px 4px; border: 1px solid rgba(255,255,255,.08); border-radius: 999px; color: var(--text-muted); background: rgba(0,0,0,.22); font-size: 9px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.alid-advanced summary { color: var(--text-muted); font-size: 13px; cursor: pointer; }
.alid-tuning { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; margin-top: 8px; }
.alid-tuning label { display: grid; gap: 3px; color: var(--text-muted); font-size: 11px; }
.alid-save { align-self: flex-start; min-height: 31px; padding: 5px 12px; }

/* ── Biblioteca de personajes (custom Lottie library) ─────────────── */
.alid-lib-header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: linear-gradient(135deg, rgba(22,163,74,.05), rgba(255,255,255,.012)); }
.alid-lib-title { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; }
.alid-lib-name { font-size: 13px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alid-lib-count { padding: 2px 7px; border-radius: 999px; border: 1px solid rgba(22,163,74,.35); background: rgba(22,163,74,.1); color: var(--accent-green); font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.alid-lib-stats { display: flex; flex-wrap: wrap; gap: 8px; font-size: 12px; color: var(--text-muted); }
.alid-upload-btn { min-height: 28px; padding: 4px 11px; border-radius: 999px; border: 1px solid rgba(22,163,74,.4); background: rgba(22,163,74,.14); color: var(--accent-green); font-size: 12px; font-weight: 750; letter-spacing: .06em; cursor: pointer; }
.alid-upload-btn:hover:not(:disabled) { background: rgba(22,163,74,.22); }
.alid-upload-btn:disabled { opacity: .4; cursor: not-allowed; }
.alid-dropzone { display: grid; place-items: center; min-height: 46px; padding: 8px; border: 1px dashed rgba(255,255,255,.16); border-radius: var(--radius-md); color: var(--text-muted); font-size: 13px; cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.alid-dropzone:hover, .alid-dropzone.is-dragover { border-color: rgba(22,163,74,.55); background: rgba(22,163,74,.06); color: var(--accent-green); }
.alid-lib-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.alid-tool-btn { min-height: 26px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border-color); background: rgba(255,255,255,.03); color: var(--text-secondary); font-size: 12px; cursor: pointer; }
.alid-tool-btn:hover { color: var(--text-primary); border-color: var(--text-muted); }
.alid-section-label { margin-top: 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.alid-card-wrap { position: relative; min-width: 0; }
.alid-card-wrap .alid-character-card { width: 100%; }
.alid-card-kind { position: absolute; left: 6px; bottom: 5px; padding: 1px 5px; border-radius: 999px; background: rgba(0,0,0,.28); color: var(--text-muted); font-size: 9px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.alid-card-kind.is-custom { color: var(--accent-green); background: rgba(22,163,74,.14); }
.alid-card-menu { position: absolute; top: 4px; right: 4px; z-index: 2; }
.alid-card-menu-btn { width: 22px; height: 22px; border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--text-muted); font-size: 16px; line-height: 1; cursor: pointer; opacity: 0; }
.alid-card-wrap:hover .alid-card-menu-btn, .alid-card-menu-btn:focus-visible { opacity: 1; border-color: var(--border-color); background: rgba(0,0,0,.35); color: var(--text-primary); }
.alid-card-menu-pop { position: absolute; top: 24px; right: 0; min-width: 148px; padding: 4px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-secondary, #111); box-shadow: 0 10px 28px rgba(0,0,0,.35); display: flex; flex-direction: column; gap: 2px; }
.alid-card-menu-pop.hidden { display: none !important; }
.alid-card-menu-pop button { border: 0; background: transparent; color: var(--text-secondary); font-size: 13px; text-align: left; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.alid-card-menu-pop button:hover { background: rgba(255,255,255,.06); color: var(--text-primary); }
.alid-card-menu-pop button.danger { color: var(--accent-red, #f85149); }
.alid-hidden-group { display: none; grid-column: 1 / -1; grid-template-columns: subgrid; gap: 8px; }
.alid-catalog.alid-show-hidden-builtins .alid-hidden-group,
#alidEditor.alid-show-hidden-builtins .alid-hidden-group { display: grid; }
#alidEditor.alid-show-hidden-builtins .alid-hidden-group { display: flex; flex-wrap: wrap; gap: 8px; }
#alidEditor.alid-show-hidden-builtins .alid-hidden-group .alid-card-wrap { width: calc(33.33% - 6px); }
.alid-upload-card { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid rgba(22,163,74,.28); border-radius: var(--radius-md); background: linear-gradient(160deg, rgba(22,163,74,.07), rgba(255,255,255,.015)); }
.alid-upload-preview { width: 100%; height: 140px; display: grid; place-items: center; border-radius: 8px; background: rgba(0,0,0,.18); overflow: hidden; }
.alid-upload-preview svg { width: 100% !important; height: 100% !important; }
.alid-upload-fallback { color: var(--text-muted); font-size: 14px; }
.alid-upload-meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--text-muted); }
.alid-upload-actions { display: flex; justify-content: flex-end; gap: 8px; }
.alid-upload-card .alid-field input { text-transform: none; }

@keyframes agent-live-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
@media (max-width: 1024px) {
  .agent-live-dock,
  .agent-live-dock.is-visible { display: none !important; }
  .workspace-dock-zone { display: none; }
}
@media (min-width: 1025px) and (max-width: 1240px) {
  .workspace-toolbar-primary { min-height: 116px; gap: 8px; padding-inline: 10px; }
  .workspace-dock-zone, .agent-live-dock { height: 106px; }
  .agent-live-slot { flex-basis: 96px; width: 96px; height: 104px; grid-template-rows: 82px 17px 2px; }
  .agent-live-avatar { width: 84px; height: 84px; }
  .toolbar-actions { gap: 4px; }
  .toolbar-btn { padding-inline: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  .agent-live-slot[data-state="working"] .agent-live-bar i { animation: none; opacity: .55; width: 100%; transform: none; }
}
.login-form.hidden { display: none; }

/* ── Login tabs (signin / register) ─────────────────────────────── */
.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 0 0 14px;
  padding: 4px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, .25);
}
.login-tab {
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.login-tab:hover { color: var(--text-primary); background: rgba(255, 255, 255, .04); }
.login-tab.active,
.login-tab[aria-selected="true"] {
  border-color: rgba(88, 166, 255, .45);
  background: rgba(88, 166, 255, .12);
  color: var(--accent-blue);
}
.login-tab:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
.login-tabs.hidden { display: none !important; }

/* ── Form select (origin, server, etc.) ─────────────────────────── */
.form-field select.form-select,
select.form-select {
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  font: inherit;
  font-size: 13px;
}
.form-field select.form-select:focus,
select.form-select:focus { border-color: var(--accent-blue); }

/* ── Project dialog advanced (remote custom workspace) ──────────── */
.project-advanced {
  margin-top: 8px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.project-advanced > summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  list-style: revert;
}
.project-advanced[open] > summary { color: var(--text-primary); margin-bottom: 8px; }
.project-advanced-check {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
}
.project-advanced-check input[type="checkbox"] { width: auto; min-height: auto; accent-color: var(--accent-blue); }

/* ── SSH host trust panel ───────────────────────────────────────── */
.remote-trust-panel {
  margin: 10px 0 14px;
  padding: 12px;
  border: 1px solid rgba(210, 153, 34, .35);
  border-radius: var(--radius-sm);
  background: rgba(210, 153, 34, .07);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.remote-trust-panel.hidden { display: none !important; }
.remote-trust-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.remote-fingerprint-full {
  display: block;
  word-break: break-all;
  white-space: pre-wrap;
  font: 10px/1.5 var(--font-mono);
  color: var(--text-secondary);
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, .3);
}
.remote-trust-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}
.remote-trust-check input[type="checkbox"] {
  width: auto;
  min-height: auto;
  margin-top: 2px;
  accent-color: var(--accent-blue);
}
.remote-trust-panel .primary-btn { align-self: flex-start; }

/* P1 SSH auth modes — deterministic UI, one pane visible */
#remoteServerForm .remote-auth-pane {
  display: none !important;
}

#remoteServerForm:has(input[name="auth_method"][value="paste"]:checked)
[data-auth-pane="paste"] {
  display: block !important;
}

#remoteServerForm:has(input[name="auth_method"][value="file"]:checked)
[data-auth-pane="file"] {
  display: block !important;
}

#remoteServerForm:has(input[name="auth_method"][value="password"]:checked)
[data-auth-pane="password"] {
  display: block !important;
}


/* MODEL ROUTING ONBOARDING V290 */
.model-onboarding-dialog {
  width: min(860px, calc(100vw - 28px));
  max-height: min(90vh, 760px);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(132, 177, 255, .22);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(15, 21, 34, .97), rgba(5, 9, 17, .96));
  color: var(--text-primary);
  box-shadow:
    0 34px 110px rgba(0, 0, 0, .62),
    inset 0 1px 0 rgba(255, 255, 255, .05);
  backdrop-filter: blur(26px) saturate(135%);
  -webkit-backdrop-filter: blur(26px) saturate(135%);
}

.model-onboarding-dialog::backdrop {
  background:
    radial-gradient(circle at 50% 35%, rgba(48, 112, 224, .15), transparent 34%),
    rgba(1, 4, 9, .82);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.model-onboarding-shell {
  position: relative;
  overflow: hidden;
}

.model-onboarding-glow {
  position: absolute;
  inset: -120px auto auto -100px;
  width: 380px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(70, 132, 255, .18), transparent 68%);
  pointer-events: none;
}

.model-onboarding-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 24px 27px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.model-onboarding-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  flex: 0 0 auto;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, .32));
}

.model-onboarding-eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--accent-blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
}

.model-onboarding-header h2 {
  margin: 0;
  max-width: 650px;
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -.025em;
}

.model-onboarding-content {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 22px 27px 25px;
  overflow-y: auto;
}

.model-onboarding-lead {
  margin: 0;
  color: var(--text-primary);
  font-size: 17px;
  line-height: 1.55;
  font-weight: 600;
}

.model-onboarding-support {
  margin: 0;
  max-width: 760px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.65;
}

.model-onboarding-note {
  padding: 11px 13px;
  border: 1px solid rgba(88, 166, 255, .18);
  border-radius: 12px;
  background: rgba(88, 166, 255, .055);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
}

.model-onboarding-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
  margin-top: 3px;
}

.model-onboarding-option {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 4px 10px;
  min-height: 126px;
  padding: 17px;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 16px;
  background: rgba(255, 255, 255, .035);
  color: var(--text-primary);
  cursor: pointer;
  transition:
    transform .16s ease,
    border-color .16s ease,
    background .16s ease,
    box-shadow .16s ease;
}

.model-onboarding-option:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(88, 166, 255, .42);
  background: rgba(88, 166, 255, .075);
  box-shadow: 0 13px 35px rgba(0, 0, 0, .22);
}

.model-onboarding-option.auto-free {
  border-color: rgba(88, 166, 255, .28);
  background:
    linear-gradient(145deg, rgba(88, 166, 255, .095), rgba(255, 255, 255, .025));
}

.model-onboarding-option.manual {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .018));
}

.model-onboarding-option:disabled {
  opacity: .55;
  cursor: wait;
}

.model-onboarding-option-icon {
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  border: 1px solid rgba(88, 166, 255, .28);
  border-radius: 10px;
  background: rgba(88, 166, 255, .08);
  color: var(--accent-blue);
  font-size: 17px;
}

.model-onboarding-option strong {
  align-self: end;
  font-size: 15px;
  line-height: 1.35;
}

.model-onboarding-option small {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
  font-weight: 500;
}

.model-onboarding-recommendation {
  padding-top: 2px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.55;
}

.model-onboarding-recommendation strong {
  color: var(--text-primary);
}

.model-onboarding-helper {
  margin: -2px 0 0;
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
}

@media (max-width: 680px) {
  .model-onboarding-dialog {
    width: calc(100vw - 16px);
    border-radius: 18px;
  }

  .model-onboarding-header {
    padding: 18px;
  }

  .model-onboarding-logo {
    width: 48px;
    height: 48px;
  }

  .model-onboarding-content {
    padding: 17px 18px 20px;
  }

  .model-onboarding-options {
    grid-template-columns: 1fr;
  }

  .model-onboarding-option {
    min-height: 108px;
  }
}

/* POLI BRAND + RAJDHANI V291 START */

/* ==========================================================
   POLI INGENIERO · TIPOGRAFÍA GLOBAL
   ========================================================== */

html,
body,
button,
input,
select,
textarea,
dialog,
option,
table,
th,
td,
h1,
h2,
h3,
h4,
h5,
h6,
p,
span,
a,
label,
small,
strong,
b,
em,
dt,
dd,
summary,
pre,
code {
  font-family: "Rajdhani", "Segoe UI", Arial, sans-serif !important;
}

:root {
  --poli-green: #26d07c;
  --poli-green-bright: #34e58d;
  --poli-green-deep: #138c53;
  --poli-green-soft: rgba(38, 208, 124, .10);
  --poli-green-border: rgba(38, 208, 124, .26);
  --poli-green-border-strong: rgba(38, 208, 124, .46);

  --poli-black: #030806;
  --poli-bg: #06100c;
  --poli-panel: #09140f;
  --poli-panel-2: #0c1913;

  --poli-text: #eefaf3;
  --poli-text-soft: #b7cbc0;
  --poli-text-muted: #788f83;
}


/* ==========================================================
   MODAL — CENTRADO REAL EN VIEWPORT
   ========================================================== */

.model-onboarding-dialog[open] {
  position: fixed !important;

  top: 50% !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;

  transform: translate(-50%, -50%) !important;

  margin: 0 !important;

  width: min(900px, calc(100vw - 40px)) !important;
  max-width: 900px !important;

  max-height: min(88vh, 780px) !important;

  padding: 0 !important;

  border: 1px solid var(--poli-green-border) !important;
  border-radius: 22px !important;

  background:
    radial-gradient(
      circle at 18% 0%,
      rgba(38, 208, 124, .075),
      transparent 34%
    ),
    linear-gradient(
      145deg,
      rgba(8, 18, 13, .995),
      rgba(3, 9, 7, .995)
    ) !important;

  color: var(--poli-text) !important;

  box-shadow:
    0 32px 100px rgba(0, 0, 0, .68),
    0 0 55px rgba(38, 208, 124, .055),
    inset 0 1px 0 rgba(255, 255, 255, .035) !important;

  backdrop-filter: blur(28px) saturate(125%);
  -webkit-backdrop-filter: blur(28px) saturate(125%);

  overflow: hidden;
}

.model-onboarding-dialog::backdrop {
  background:
    radial-gradient(
      circle at 50% 38%,
      rgba(25, 112, 70, .11),
      transparent 32%
    ),
    rgba(1, 5, 4, .84) !important;

  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}


/* ==========================================================
   CONTENEDOR
   ========================================================== */

.model-onboarding-shell {
  position: relative;
  width: 100%;
  overflow: hidden;

  background:
    linear-gradient(
      180deg,
      rgba(11, 23, 17, .92),
      rgba(5, 12, 9, .96)
    );
}

.model-onboarding-glow {
  position: absolute;

  top: -140px;
  left: -90px;

  width: 410px;
  height: 300px;

  border-radius: 50%;

  background:
    radial-gradient(
      circle,
      rgba(38, 208, 124, .14),
      transparent 68%
    ) !important;

  pointer-events: none;
}


/* ==========================================================
   CABECERA
   ========================================================== */

.model-onboarding-header {
  position: relative;

  display: flex;
  align-items: center;

  gap: 16px;

  padding: 25px 28px 19px !important;

  border-bottom:
    1px solid rgba(38, 208, 124, .11) !important;

  background:
    linear-gradient(
      90deg,
      rgba(38, 208, 124, .035),
      transparent 55%
    );
}

.model-onboarding-logo {
  width: 58px !important;
  height: 58px !important;

  object-fit: contain;

  flex: 0 0 auto;

  filter:
    drop-shadow(0 0 14px rgba(38, 208, 124, .18))
    drop-shadow(0 8px 16px rgba(0, 0, 0, .38)) !important;
}

.model-onboarding-eyebrow {
  display: block;

  margin-bottom: 5px;

  color: var(--poli-green) !important;

  font-size: 13px !important;
  font-weight: 700 !important;

  letter-spacing: .12em !important;

  text-transform: uppercase;
}

.model-onboarding-header h2 {
  margin: 0 !important;

  max-width: 700px;

  color: var(--poli-text) !important;

  font-size: clamp(28px, 3vw, 37px) !important;

  line-height: 1.04 !important;

  font-weight: 700 !important;

  letter-spacing: -.018em !important;
}


/* ==========================================================
   CONTENIDO
   ========================================================== */

.model-onboarding-content {
  position: relative;

  display: flex;
  flex-direction: column;

  gap: 14px !important;

  padding: 22px 28px 26px !important;

  overflow-y: auto;
}

.model-onboarding-lead {
  margin: 0 !important;

  color: var(--poli-text) !important;

  font-size: 19px !important;
  line-height: 1.45 !important;

  font-weight: 600 !important;
}

.model-onboarding-support {
  margin: 0 !important;

  max-width: 780px;

  color: var(--poli-text-soft) !important;

  font-size: 16px !important;
  line-height: 1.55 !important;

  font-weight: 500;
}


/* ==========================================================
   NOTA
   ========================================================== */

.model-onboarding-note {
  padding: 13px 15px !important;

  border:
    1px solid rgba(38, 208, 124, .17) !important;

  border-radius: 13px !important;

  background:
    linear-gradient(
      90deg,
      rgba(38, 208, 124, .055),
      rgba(38, 208, 124, .025)
    ) !important;

  color: var(--poli-text-soft) !important;

  font-size: 15px !important;
  line-height: 1.5 !important;
}


/* ==========================================================
   BOTONES DE DECISIÓN
   ========================================================== */

.model-onboarding-options {
  display: grid !important;

  grid-template-columns:
    repeat(2, minmax(0, 1fr)) !important;

  gap: 14px !important;

  margin-top: 3px;
}

.model-onboarding-option {
  position: relative;

  display: grid !important;

  grid-template-columns: auto 1fr !important;
  grid-template-rows: auto auto !important;

  gap: 5px 12px !important;

  min-height: 130px !important;

  padding: 18px !important;

  text-align: left !important;

  border:
    1px solid var(--poli-green-border) !important;

  border-radius: 16px !important;

  color: var(--poli-text) !important;

  cursor: pointer;

  transition:
    transform .16s ease,
    border-color .16s ease,
    background .16s ease,
    box-shadow .16s ease !important;
}

.model-onboarding-option.auto-free {
  background:
    linear-gradient(
      145deg,
      rgba(19, 67, 43, .72),
      rgba(8, 29, 19, .82)
    ) !important;

  border-color:
    rgba(38, 208, 124, .34) !important;
}

.model-onboarding-option.manual {
  background:
    linear-gradient(
      145deg,
      rgba(13, 27, 20, .96),
      rgba(7, 16, 12, .98)
    ) !important;
}

.model-onboarding-option:hover:not(:disabled) {
  transform: translateY(-2px) !important;

  border-color:
    var(--poli-green-border-strong) !important;

  background:
    linear-gradient(
      145deg,
      rgba(23, 79, 51, .82),
      rgba(9, 32, 21, .92)
    ) !important;

  box-shadow:
    0 13px 36px rgba(0, 0, 0, .28),
    0 0 22px rgba(38, 208, 124, .055) !important;
}

.model-onboarding-option:focus-visible {
  outline:
    2px solid var(--poli-green-bright) !important;

  outline-offset: 3px;
}

.model-onboarding-option:disabled {
  opacity: .5 !important;
}


/* ==========================================================
   ICONOS
   ========================================================== */

.model-onboarding-option-icon {
  grid-row: 1 / span 2;

  display: grid !important;
  place-items: center;

  width: 36px !important;
  height: 36px !important;

  border:
    1px solid rgba(38, 208, 124, .28) !important;

  border-radius: 10px !important;

  background:
    rgba(38, 208, 124, .09) !important;

  color:
    var(--poli-green-bright) !important;

  font-size: 18px !important;
}


/* ==========================================================
   TEXTO DE BOTONES
   ========================================================== */

.model-onboarding-option strong {
  align-self: end;

  color: var(--poli-text) !important;

  font-size: 17px !important;
  line-height: 1.3 !important;

  font-weight: 700 !important;
}

.model-onboarding-option small {
  color:
    var(--poli-text-muted) !important;

  font-size: 14px !important;
  line-height: 1.45 !important;

  font-weight: 500 !important;
}


/* ==========================================================
   RECOMENDACIÓN / PIE
   ========================================================== */

.model-onboarding-recommendation {
  padding: 12px 14px !important;

  border:
    1px solid rgba(38, 208, 124, .11);

  border-radius: 12px;

  background:
    rgba(38, 208, 124, .025);

  color:
    var(--poli-text-soft) !important;

  font-size: 14px !important;
  line-height: 1.5 !important;
}

.model-onboarding-recommendation strong {
  color:
    var(--poli-green-bright) !important;
}

.model-onboarding-helper {
  margin: -2px 0 0 !important;

  color:
    var(--poli-text-muted) !important;

  font-size: 13px !important;

  text-align: center;
}


/* ==========================================================
   RESPONSIVE
   ========================================================== */

@media (max-width: 720px) {

  .model-onboarding-dialog[open] {
    width:
      calc(100vw - 18px) !important;

    max-height:
      calc(100vh - 18px) !important;

    border-radius:
      17px !important;
  }

  .model-onboarding-header {
    padding:
      19px 18px 16px !important;
  }

  .model-onboarding-logo {
    width: 47px !important;
    height: 47px !important;
  }

  .model-onboarding-header h2 {
    font-size:
      clamp(25px, 7vw, 31px) !important;
  }

  .model-onboarding-content {
    padding:
      18px 18px 20px !important;
  }

  .model-onboarding-options {
    grid-template-columns:
      1fr !important;
  }

  .model-onboarding-option {
    min-height:
      108px !important;
  }
}

/* POLI BRAND + RAJDHANI V291 END */

/* POLI CHAT TYPOGRAPHY V292 START */

/* POLI general continúa usando Rajdhani.
   Conversación prioriza legibilidad tipo chat moderno. */
.chat-messages,
.chat-message,
.msg-bubble,
.rich-text,
.chat-input,
.chat-input::placeholder,
.chat-input-hint,
#chatInputHint,
.msg-part-error {
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif !important;
}

/* Cuerpo de mensajes */
.chat-message,
.msg-bubble,
.rich-text {
  font-size: 16px;
  line-height: 1.58;
  letter-spacing: 0;
}

/* Caja de escritura */
.chat-input {
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: 0;
}

/* Código, JSON y salidas técnicas permanecen monospace */
.code-block,
.chat-messages pre,
.chat-messages code,
.activity-detail pre,
.raw-json,
pre.raw-json {
  font-family:
    ui-monospace,
    "SFMono-Regular",
    "SF Mono",
    Consolas,
    "Liberation Mono",
    Menlo,
    monospace !important;

  letter-spacing: 0;
}

/* Evitar que el override global Rajdhani contamine código inline */
.rich-text code,
.msg-bubble code {
  font-family:
    ui-monospace,
    "SFMono-Regular",
    "SF Mono",
    Consolas,
    "Liberation Mono",
    Menlo,
    monospace !important;
}

/* POLI CHAT TYPOGRAPHY V292 END */


/* POLI SIDEBAR LOGOUT V268 */
.sidebar-logout-btn {
  flex: 0 0 auto;
  width: calc(100% - 24px);
  min-height: 36px;
  margin: 4px 12px 10px;
  padding: 7px 10px;

  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;

  border: 1px solid rgba(248, 81, 73, 0.18);
  border-radius: 6px;

  background: rgba(248, 81, 73, 0.025);
  color: rgba(210, 218, 226, 0.72);

  font: inherit;
  font-size: 12px;
  cursor: pointer;

  transition:
    color 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

.sidebar-logout-btn svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;

  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-logout-btn:hover {
  color: #ff7b72;
  border-color: rgba(248, 81, 73, 0.42);
  background: rgba(248, 81, 73, 0.08);
}

.sidebar-logout-btn:focus-visible {
  outline: 2px solid rgba(88, 166, 255, 0.7);
  outline-offset: 2px;
}

.logout-confirm-dialog {
  width: min(430px, calc(100vw - 32px));
  max-width: 430px;
}

/* Centrado absoluto del modal de logout */
dialog#logoutConfirmDialog.logout-confirm-dialog[open] {
  position: fixed;
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;

  margin: 0;
  transform: translate(-50%, -50%);

  width: min(430px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);

  z-index: 10000;
}

.logout-confirm-text {
  margin: 2px 0 4px;
  line-height: 1.55;
}

/* Mantener el botón de logout unido al footer del sidebar */
#workspaceContext {
  flex-shrink: 0;
}

#btnLogoutSidebar {
  flex-shrink: 0;
}

/* POLI DELETE PROJECT */
.project-danger-zone {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid rgba(248, 81, 73, .28);
  border-radius: var(--radius-md);
  background: rgba(248, 81, 73, .05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.project-danger-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.project-danger-copy strong {
  color: var(--accent-red);
  font-size: 13px;
}

.project-danger-copy span {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

.project-danger-zone .btn-deny {
  flex: 0 0 auto;
  border-color: rgba(248, 81, 73, .55);
  color: var(--accent-red);
}

.delete-project-dialog {
  width: min(520px, calc(100vw - 28px));
}

.delete-project-dialog .btn-deny {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: #fff;
}

.delete-project-warning {
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid rgba(248, 81, 73, .35);
  border-radius: var(--radius-md);
  background: rgba(248, 81, 73, .08);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.45;
}

.delete-project-summary {
  display: grid;
  gap: 1px;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--border-color);
}

.delete-project-summary > div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 11px;
  background: var(--bg-primary);
}

.delete-project-summary span {
  color: var(--text-muted);
  font-size: 12px;
}

.delete-project-summary strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text-primary);
  font-size: 12px;
}

.delete-project-remote-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.delete-project-remote-option input {
  margin-top: 3px;
}

.delete-project-remote-option span {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.delete-project-remote-option strong {
  color: var(--text-primary);
  font-size: 13px;
}

.delete-project-remote-option small {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.delete-project-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.45;
}

.delete-project-status.success {
  border: 1px solid rgba(63, 185, 80, .35);
  background: rgba(63, 185, 80, .08);
  color: var(--accent-green);
}

.delete-project-status.error {
  border: 1px solid rgba(248, 81, 73, .35);
  background: rgba(248, 81, 73, .08);
  color: var(--accent-red);
}

@media (max-width: 640px) {
  .project-danger-zone {
    align-items: stretch;
    flex-direction: column;
  }

  .project-danger-zone .btn-deny {
    width: 100%;
  }

  .delete-project-summary > div {
    grid-template-columns: 82px minmax(0, 1fr);
  }
}

/* PROJECT SIDEBAR DELETE */
.project-item {
  position: relative;
}

.project-info {
  min-width: 0;
  padding-right: 30px;
}

.project-delete-btn {
  position: absolute;
  top: 50%;
  right: 7px;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  padding: 5px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: .35;
  transition:
    opacity var(--transition-fast),
    color var(--transition-fast),
    background var(--transition-fast);
}

.project-delete-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.project-item:hover .project-delete-btn,
.project-delete-btn:focus-visible {
  opacity: 1;
}

.project-delete-btn:hover {
  color: var(--accent-red);
  background: rgba(248, 81, 73, .10);
}

@media (max-width: 768px) {
  .project-delete-btn {
    opacity: .72;
    width: 30px;
    height: 30px;
  }
}


/* GOLDEN RULE — ALL MODALS ALWAYS CENTERED */
dialog.app-dialog[open] {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  margin: 0 !important;
  transform: translate(-50%, -50%) !important;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

@media (max-width: 640px) {
  dialog.app-dialog[open] {
    width: min(calc(100vw - 24px), 520px) !important;
    max-height: calc(100dvh - 24px);
  }
}


/* ===========================================================================
   Native OpenCode `question` tool UI
   Centering comes from the GOLDEN RULE above (dialog.app-dialog[open]) and is
   NOT redefined here. Only the internal layout and the options are added.
   =========================================================================== */
.question-dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: min(86vh, 760px);
}
.question-dialog[open] {
  display: flex !important;
  flex-direction: column;
}
.question-dialog .question-dialog-header {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--border-color);
}
.question-dialog .question-dialog-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
}
.question-dialog .question-dialog-footer {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border-color);
  background: linear-gradient(180deg, rgba(8,11,13,.35), rgba(8,11,13,.92));
  box-shadow: 0 -8px 20px rgba(0,0,0,.28);
  z-index: 1;
}

.question-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
}
.question-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent-blue);
}
.question-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
}
.question-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.question-option {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.question-option:hover:not(:disabled) {
  border-color: var(--accent-blue);
}
.question-option:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.question-option.selected {
  border-color: var(--accent-blue);
  background: rgba(22,163,74,.14);
}
.question-option-label {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}
.question-option-description {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-secondary);
}
.question-custom {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.question-custom-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.question-custom-input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font: inherit;
  font-size: 14px;
  min-height: 40px;
}
.question-custom-input:focus {
  outline: 2px solid var(--accent-blue);
  outline-offset: 1px;
}

/* Read-only `question` card inside the conversation */
.question-card .question-card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.question-card-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}
.question-card-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.question-card-text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-primary);
}
.question-card-options {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.question-card-option {
  display: flex;
  flex-direction: column;
}
.question-card-option-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.question-card-option-description {
  font-size: 12px;
  color: var(--text-secondary);
}
.question-card-custom,
.question-card-multiple {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Mobile: keep every option reachable and tappable */
@media (max-width: 768px) {
  .question-dialog {
    width: min(calc(100vw - 24px), 620px);
    max-height: calc(100dvh - 24px);
  }
  .question-option {
    min-height: 44px;
  }
  .question-dialog .question-dialog-footer {
    justify-content: stretch;
  }
  .question-dialog .question-dialog-footer .primary-btn,
  .question-dialog .question-dialog-footer .secondary-btn {
    flex: 1 1 140px;
    min-height: 44px;
  }
}

@media (max-width: 375px) {
  .question-dialog {
    width: calc(100vw - 16px);
  }
  .question-dialog .question-dialog-body {
    padding: 12px 12px;
  }
  .question-text {
    font-size: 14px;
  }
  .question-option-label {
    font-size: 13.5px;
  }
}
/* GitHub control plane */
.github-toolbar-btn svg { fill: currentColor; stroke: none; }
.global-github-btn { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; padding: 0 10px; border: 1px solid var(--border, #293238); border-radius: 9px; background: rgba(255,255,255,.025); color: inherit; cursor: pointer; }
.global-github-btn:hover { border-color: #3fb950; color: #3fb950; }
.global-github-btn svg { width: 16px; height: 16px; fill: currentColor; }
.connection-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted, #667); }
.connection-dot.connected { background: #28d17c; box-shadow: 0 0 10px rgba(40,209,124,.6); }
.github-dialog { width: min(780px, calc(100vw - 28px)); max-height: min(760px, calc(100vh - 28px)); padding: 0; }
.github-content { display: grid; gap: 16px; padding: 18px; overflow: auto; }
.github-connect, .github-repo-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.github-connect, .github-setup, .github-project-actions, .github-repo-card {
  border: 1px solid var(--border, #293238); border-radius: 14px;
  background: rgba(255,255,255,.025); padding: 14px;
}
.github-connect p, .github-repo-card p, .github-setup p { margin: 5px 0; color: var(--text-muted, #8b969c); }
.github-repositories { display: grid; gap: 9px; max-height: 390px; overflow: auto; margin-top: 10px; }
.github-selection-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; color: var(--text-muted, #8b969c); }
.github-repo-select { display: grid; place-items: center; flex: 0 0 auto; }
.github-repo-select input { width: 17px; height: 17px; accent-color: #2ea043; }
.github-repo-card small { color: var(--text-muted, #8b969c); }
.github-action-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.github-output { min-height: 72px; max-height: 180px; overflow: auto; white-space: pre-wrap; padding: 12px; border-radius: 10px; background: #090d0f; color: #b7c2c8; }
@media (max-width: 600px) {
  .github-connect, .github-repo-card { align-items: stretch; flex-direction: column; }
  .github-connect button, .github-repo-card button { width: 100%; }
}
.project-organizer { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--border, #293238); }
.project-organizer input, .project-organizer select { width: 100%; min-width: 0; padding: 7px 9px; border: 1px solid var(--border, #293238); border-radius: 8px; background: rgba(255,255,255,.025); color: inherit; font: inherit; }
.project-group-label { display: flex; justify-content: space-between; padding: 10px 12px 5px; color: var(--text-muted, #8b969c); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.project-group-label b { font-weight: 600; }
.project-item.project-github { border-left: 2px solid #3fb950; }
.project-item[draggable="true"] { cursor: grab; }
.project-item.dragging { opacity: .45; }

/* Isolated, optional project frontend preview */
.frontend-preview-panel {
  --preview-width: 520px;
  position: fixed;
  z-index: 380;
  top: 42px;
  right: 0;
  bottom: 0;
  width: min(var(--preview-width), calc(100vw - 260px));
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  background: color-mix(in srgb, var(--bg-primary, #0c1114) 96%, transparent);
  border-left: 1px solid var(--border, #293238);
  box-shadow: -18px 0 45px rgba(0,0,0,.34);
  backdrop-filter: blur(16px);
}
.frontend-preview-panel.hidden { display: none; }
.frontend-preview-panel.maximized { width: calc(100vw - 260px); }
.frontend-preview-resize {
  position: absolute;
  inset: 0 auto 0 -5px;
  width: 10px;
  cursor: ew-resize;
  touch-action: none;
}
.frontend-preview-resize:hover::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 4px;
  width: 2px;
  background: var(--accent-green, #28d17c);
}
.frontend-preview-header,
.frontend-preview-location {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border, #293238);
}
.frontend-preview-header { justify-content: space-between; }
.frontend-preview-eyebrow { display: block; margin-bottom: 3px; color: var(--accent-green, #28d17c); font-size: 9px; letter-spacing: .14em; }
.frontend-preview-actions { display: flex; gap: 6px; }
.frontend-preview-actions button,
.frontend-preview-actions a,
.frontend-preview-location button {
  min-width: 32px;
  min-height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border, #293238);
  border-radius: 8px;
  background: rgba(255,255,255,.035);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.frontend-preview-actions [aria-disabled="true"] { opacity: .4; pointer-events: none; }
.frontend-preview-location input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border, #293238);
  border-radius: 8px;
  background: #080c0e;
  color: inherit;
}
.frontend-preview-status { margin: 0; padding: 8px 14px; color: var(--text-muted, #8b969c); font-size: 10px; border-bottom: 1px solid var(--border, #293238); }
.frontend-preview-frame { display: block; width: 100%; height: 100%; min-height: 0; border: 0; background: #fff; }
.frontend-preview-open:not(:disabled) { color: var(--accent-green, #28d17c); }
@media (max-width: 700px) {
  .frontend-preview-panel { top: 42px; width: 100vw; }
  .frontend-preview-panel.maximized { width: 100vw; }
  .frontend-preview-resize { display: none; }
}
.access-matrix { overflow:auto; margin:10px 0; border:1px solid var(--border); border-radius:12px; }
.access-matrix table { border-collapse:collapse; min-width:900px; width:100%; }
.access-matrix th,.access-matrix td { padding:8px; border-bottom:1px solid var(--border); text-align:center; }
.access-matrix th:first-child { position:sticky; left:0; text-align:left; background:var(--bg-secondary); z-index:1; }
.ticket-card { margin:10px 0; padding:12px; border:1px solid var(--border); border-radius:12px; background:rgba(255,255,255,.02); }
.ticket-card summary { display:flex; justify-content:space-between; gap:12px; cursor:pointer; }
.ticket-thread { display:grid; gap:8px; margin:12px 0; }
.ticket-message { max-width:85%; padding:10px; border-radius:10px; background:var(--bg-secondary); }
.ticket-message.from-admin { margin-left:auto; border:1px solid var(--accent); }
.ticket-message p { margin:4px 0; white-space:pre-wrap; }
.ticket-admin-actions { display:flex; justify-content:flex-end; margin:6px 0 16px; }


/* === POLI UI refinement 2026-10-05: compact 2x9 agents + readable typography === */
@media (min-width: 1025px) {
  :root { --monitoring-width: 390px; }
  body { font-family: Roboto, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; }
  .header-logo { width: 54px; height: 54px; }
  .header-title { font-size: 28px; font-weight: 650; letter-spacing: -.025em; }
  .app-header { min-height: 60px; height: 60px; }

  .agents-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    padding: 5px 7px 8px;
    align-items: start;
  }
  .agent-card {
    min-width: 0;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 9px;
    background: rgba(255,255,255,.014);
    overflow: hidden;
  }
  .agent-card[open] { grid-column: 1 / -1; }
  .agent-card > summary { padding: 7px 8px 8px; gap: 3px 5px; min-height: 58px; }
  .agent-card-title { align-items: center; gap: 4px; }
  .agent-card-title b { font-size: 13px; letter-spacing: 0; }
  .agent-card-title small { font-size: 10.5px; }
  .agent-card-activity { font-size: 11.5px; }
  .agent-expanded { padding: 9px 10px 10px; }
  .agent-expanded > span, .agent-expanded label { font-size: 12px; }
  .agent-expanded select { height: 30px; font-size: 12px; }
  .agents-notice { font-size: 12.5px; padding: 6px 10px; }
  .work-mode > span, .work-mode-options button { font-size: 12px; }

  .workspace-toolbar-primary { min-height: 142px; }
  .workspace-dock-zone, .agent-live-dock { height: 134px; }
  .agent-live-dock { gap: 0; overflow: visible; }
  .agent-live-dock-slots { gap: 0; overflow: visible; flex: 1 1 auto; justify-content: flex-start; }
  .agent-live-slot {
    flex: 0 0 92px;
    width: 92px;
    height: 132px;
    grid-template-rows: 106px 15px 14px;
    padding: 0;
    border: 0 !important;
    border-radius: 0;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible;
  }
  .agent-live-avatar { width: 106px; height: 106px; }
  .agent-live-name { font-size: 12.5px; max-width: 96px; }
  .agent-live-status { font-size: 11px; line-height: 1; color: var(--text-muted); font-weight: 650; text-align: center; white-space: nowrap; }
  .agent-live-slot[data-state="working"] .agent-live-status { color: var(--accent-green); }
  .agent-live-slot[data-state="waiting_approval"] .agent-live-status { color: var(--accent-yellow); }
  .agent-live-slot[data-state="error"] .agent-live-status,
  .agent-live-slot[data-state="stalled"] .agent-live-status { color: var(--accent-red); }
  .agent-live-slot[data-state="completed"] .agent-live-status { color: var(--accent-blue); }
  .agent-live-bar { display: none !important; }
}

/* Fine tuning: header geometry + free/paid visual distinction. */
@media (min-width: 1025px) {
  :root { --header-height: 60px; }
  .header-title { font-size: 32px; }
  #agentSelect optgroup[label="Agentes gratis"] { color: #86d7a8; }
  #agentSelect optgroup[label="Agentes pago"] { color: #d6b36a; }
  #modelSelect optgroup[data-tier="free"],
  .live-agent-model optgroup[data-tier="free"] { color: #86d7a8; font-weight: 700; }
  #modelSelect optgroup[data-tier="paid"],
  .live-agent-model optgroup[data-tier="paid"] { color: #d6b36a; font-weight: 700; }
  #agentSelect option,
  #modelSelect option,
  .live-agent-model option { color: var(--text-primary); background: #111618; }
}

/* Free-quota + model capability intelligence (selected model only). */
.agent-model-intel {
  margin-top: 6px;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  background: rgba(255,255,255,.025);
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
}
.agent-model-intel.quota-available {
  color: var(--accent-green);
  border-color: rgba(63,185,80,.32);
  background: rgba(63,185,80,.055);
}
.agent-model-intel.quota-limited {
  color: var(--accent-red);
  border-color: rgba(239,68,68,.32);
  background: rgba(239,68,68,.055);
}
.agent-model-intel.quota-checking {
  color: var(--accent-blue);
}
.agent-model-intel.quota-paid,
.agent-model-intel.quota-unknown {
  color: var(--text-muted);
}

/* Información completa del modelo seleccionado en las cards derechas. */
.agent-model-intel {
  grid-column: 1 / -1;
}
.model-intel-title {
  margin-bottom: 6px;
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2px;
}
.model-intel-grid {
  display: grid;
  grid-template-columns: minmax(88px, .8fr) minmax(0, 1.7fr);
  gap: 3px 8px;
}
.model-intel-key {
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .28px;
  text-transform: uppercase;
}
.model-intel-value {
  min-width: 0;
  color: var(--text-secondary);
  font-size: 10px;
  overflow-wrap: anywhere;
}
.agent-model-intel.quota-available .model-intel-value:last-of-type {
  color: var(--accent-green);
}
.agent-model-intel.quota-limited .model-intel-value:last-of-type {
  color: var(--accent-red);
}
.quota-refresh-btn {
  width: 100%;
  margin-top: 7px;
  padding: 5px 7px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-secondary);
  background: var(--bg-primary);
  font-size: 10px;
  cursor: pointer;
}
.quota-refresh-btn:hover {
  color: var(--text-primary);
  border-color: rgba(22,163,74,.48);
}

/* POLI outbound conversational MCP server */
.mcp-server-card{display:block;padding:18px;margin-bottom:18px}
.mcp-server-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:16px}
.mcp-connection-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin:14px 0}
.mcp-connection-grid label,.mcp-server-card>label{display:grid;gap:6px;font-size:12px;color:var(--text-secondary)}
.mcp-secret-line{display:flex;gap:8px;align-items:center}
.mcp-secret-line .settings-input{flex:1;min-width:0;font-family:'SF Mono','Menlo',monospace}
.mcp-server-actions{display:flex;flex-wrap:wrap;gap:8px;margin:14px 0}
.mcp-manual-config{margin:14px 0}
.mcp-manual-config summary{cursor:pointer;font-weight:600;margin-bottom:10px}
.mcp-manual-config textarea{width:100%;font-family:'SF Mono','Menlo',monospace;resize:vertical}
.mcp-token-list{display:grid;gap:8px;margin-top:14px}
.mcp-token-row{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:10px 0;border-top:1px solid var(--border-color)}
.mcp-token-row div{display:grid;gap:3px;min-width:0}
.mcp-token-row small{color:var(--text-secondary);font-family:'SF Mono','Menlo',monospace}
.mcp-consumed-title{margin-top:18px;padding-top:14px;border-top:1px solid var(--border-color)}
@media(max-width:760px){
  .mcp-connection-grid{grid-template-columns:1fr}
  .mcp-secret-line{align-items:stretch;flex-direction:column}
  .mcp-token-row{align-items:stretch;flex-direction:column}
}

/* POLI MCP contextual help */
.mcp-help-link{
  appearance:none;
  border:0;
  background:transparent;
  padding:5px 0 0;
  color:var(--accent-green);
  font:inherit;
  font-size:12px;
  font-weight:600;
  cursor:pointer;
  text-decoration:underline;
  text-underline-offset:3px;
}
.mcp-help-link:hover{opacity:.82}
.poli-mcp-help-dialog{
  width:min(780px,calc(100vw - 28px));
  max-height:min(88vh,820px);
}
.poli-mcp-help-dialog[open]{
  display:flex !important;
  flex-direction:column;
}
.poli-mcp-help-dialog .dialog-header{
  flex:0 0 auto;
  border-bottom:1px solid var(--border-color);
}
.poli-mcp-help-dialog .dialog-header p{
  margin:5px 0 0;
  color:var(--text-secondary);
  font-size:12px;
}
.poli-mcp-help-body{
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  padding:16px 18px 18px;
  display:grid;
  gap:18px;
}
.poli-mcp-help-body h3{
  margin:0 0 10px;
  font-size:14px;
}
.poli-mcp-direction-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
}
.poli-mcp-direction-grid article{
  display:grid;
  gap:7px;
  padding:14px;
  border:1px solid var(--border-color);
  border-radius:var(--radius-md);
  background:var(--bg-tertiary);
}
.poli-mcp-direction-grid article>span{
  width:max-content;
  padding:2px 7px;
  border:1px solid var(--border-color);
  border-radius:999px;
  color:var(--accent-green);
  font-size:10px;
  font-weight:700;
}
.poli-mcp-direction-grid p,
.poli-mcp-help-section>p{
  margin:0;
  color:var(--text-secondary);
  line-height:1.55;
}
.poli-mcp-direction-grid code,
.poli-mcp-flow code{
  display:block;
  white-space:normal;
  line-height:1.5;
  color:var(--text-primary);
}
.poli-mcp-help-section{
  padding-top:2px;
}
.poli-mcp-help-list{
  display:grid;
  gap:0;
  margin:0;
  border:1px solid var(--border-color);
  border-radius:var(--radius-md);
  overflow:hidden;
}
.poli-mcp-help-list>div{
  display:grid;
  grid-template-columns:minmax(160px,210px) 1fr;
  gap:16px;
  padding:11px 13px;
  border-bottom:1px solid var(--border-color);
}
.poli-mcp-help-list>div:last-child{border-bottom:0}
.poli-mcp-help-list dt{
  font-weight:650;
  color:var(--text-primary);
}
.poli-mcp-help-list dd{
  margin:0;
  color:var(--text-secondary);
  line-height:1.5;
}
.poli-mcp-help-list code{
  font-size:11px;
}
.poli-mcp-flow{
  margin-top:10px;
  padding:12px 13px;
  border:1px dashed var(--border-color);
  border-radius:var(--radius-md);
  background:var(--bg-tertiary);
}
.poli-mcp-help-note{
  margin:0;
}
@media(max-width:680px){
  .poli-mcp-direction-grid{grid-template-columns:1fr}
  .poli-mcp-help-list>div{grid-template-columns:1fr;gap:5px}
  .poli-mcp-help-body{padding:14px}
}
