/* TitanClaw Web Gateway — Premium Design System */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Core palette */
  --bg: #0a0a0c;
  --bg-secondary: #111118;
  --bg-tertiary: #1a1a24;
  --bg-elevated: rgba(20, 20, 30, 0.7);
  --border: rgba(255, 255, 255, 0.07);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --text: #e8e8ed;
  --text-secondary: #8b8b9e;
  --text-muted: #5a5a6e;

  /* Accent — refined crimson */
  --accent: #dc2626;
  --accent-hover: #ef4444;
  --accent-subtle: rgba(220, 38, 38, 0.12);
  --accent-glow: rgba(220, 38, 38, 0.25);

  /* Semantic */
  --success: #22c55e;
  --success-subtle: rgba(34, 197, 94, 0.12);
  --warning: #eab308;
  --warning-subtle: rgba(234, 179, 8, 0.12);
  --danger: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.12);

  /* Surfaces */
  --code-bg: #12121a;
  --glass-bg: rgba(16, 16, 24, 0.65);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-blur: blur(20px);

  /* Geometry */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Elevation */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);

  /* Transitions */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --duration: 200ms;
  --duration-slow: 350ms;
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  letter-spacing: -0.01em;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px circle at 10% 10%, rgba(220, 38, 38, 0.08), transparent 50%),
    radial-gradient(1100px circle at 90% 80%, rgba(99, 102, 241, 0.05), transparent 50%),
    radial-gradient(600px circle at 50% 50%, rgba(220, 38, 38, 0.03), transparent 40%);
  z-index: 0;
}

/* Auth Screen */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.auth-card-login {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 44px 40px 36px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  animation: authCardIn 600ms var(--ease) both;
}

@keyframes authCardIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-brand {
  text-align: center;
}

.auth-brand h1 {
  font-size: 32px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 4px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.auth-tagline {
  font-size: 14px;
  color: var(--text-secondary);
}

#auth-screen .auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#auth-screen .auth-form label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

#auth-screen input {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#auth-screen input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.16);
}

#auth-screen button {
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  margin-top: 4px;
}

#auth-screen button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

#auth-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 20px;
  text-align: center;
}

.auth-hint {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.4;
}

/* Main App */
#app {
  display: none;
  flex-direction: column;
  height: 100vh;
}

/* Tab Bar */
.tab-bar {
  display: flex;
  background: var(--glass-bg);
  backdrop-filter: blur(32px) saturate(1.2);
  -webkit-backdrop-filter: blur(32px) saturate(1.2);
  border-bottom: 1px solid var(--glass-border);
  padding: 0 24px;
  gap: 0;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02), var(--shadow-sm);
  position: relative;
  z-index: 10;
}

.tab-bar button {
  padding: 12px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: color var(--duration) var(--ease), border-color var(--duration) var(--ease), background var(--duration) var(--ease);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  margin-top: 4px;
  position: relative;
}

.tab-bar button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.tab-bar button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-bar button.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  box-shadow: 0 0 8px var(--accent-glow);
}

.tab-bar .spacer {
  flex: 1;
}

.tab-bar .status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  position: relative;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  margin: 7px 0 7px 12px;
}

.tab-bar .status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.tab-bar .status .dot.disconnected {
  background: var(--danger);
}

/* Tab Panels */
.tab-panel {
  display: none;
  flex: 1;
  overflow: hidden;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
  animation: panelFadeIn 160ms ease;
}

@keyframes panelFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Chat Tab */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px calc(50% - 400px) 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

.message {
  max-width: 90%;
  padding: 16px 20px;
  border-radius: var(--radius);
  font-size: 14.5px;
  line-height: 1.7;
  word-wrap: break-word;
  animation: messageIn 350ms var(--ease) both;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(145deg, rgba(220, 38, 38, 0.12), rgba(220, 38, 38, 0.06));
  color: var(--text);
  border-radius: var(--radius-xl);
  border-bottom-right-radius: 6px;
  border: 1px solid rgba(220, 38, 38, 0.15);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  white-space: pre-wrap;
  max-width: 70%;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.message.assistant {
  align-self: flex-start;
  background: rgba(18, 18, 28, 0.4);
  border-radius: var(--radius-lg);
  border-bottom-left-radius: 6px;
  border: 1px solid var(--border-subtle);
  width: 100%;
  max-width: 100%;
  padding: 14px 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.message.system {
  align-self: center;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 6px 12px;
}

.message code {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 13px;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.message pre {
  background: var(--code-bg);
  padding: 14px 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 8px 0;
  border: 1px solid var(--border);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.message pre code {
  background: none;
  padding: 0;
  border: none;
  font-size: 13px;
  line-height: 1.6;
}

.message p {
  margin: 0 0 8px 0;
}

.message p:last-child {
  margin-bottom: 0;
}

.message ul,
.message ol {
  margin: 4px 0;
  padding-left: 20px;
}

.message li {
  margin: 2px 0;
}

.message blockquote {
  margin: 6px 0;
  padding: 4px 12px;
  border-left: 3px solid var(--border);
  color: var(--text-secondary);
}

.message h1,
.message h2,
.message h3,
.message h4,
.message h5,
.message h6 {
  margin: 8px 0 4px 0;
  line-height: 1.3;
}

.message h1 {
  font-size: 1.3em;
}

.message h2 {
  font-size: 1.2em;
}

.message h3 {
  font-size: 1.1em;
}

.message a {
  color: var(--accent);
}

.message hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 8px 0;
}

.message table {
  border-collapse: collapse;
  margin: 6px 0;
}

.message th,
.message td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  font-size: 13px;
}

.message th {
  background: var(--bg-tertiary);
}

/* Status bar */
.chat-status {
  padding: 6px 20px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.chat-status .spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.scroll-load-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  color: var(--text-secondary);
  font-size: 12px;
}

.scroll-load-spinner .spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Approval card (inline in chat) */
.approval-card {
  align-self: flex-start;
  max-width: 80%;
  background: var(--bg-secondary);
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.approval-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--warning);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.approval-tool-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.approval-description {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.approval-params-toggle {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  text-align: left;
}

.approval-params-toggle:hover {
  text-decoration: underline;
}

.approval-params {
  background: var(--code-bg);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  line-height: 1.4;
  overflow-x: auto;
  color: var(--text-secondary);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

.approval-card .approval-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.approval-card .approval-actions button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  background: var(--bg-secondary);
  color: var(--text);
}

.approval-card .approval-actions button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.approval-card .approval-actions button.approve {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.approval-card .approval-actions button.always {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.approval-card .approval-actions button.deny {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.approval-resolved {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  font-style: italic;
}

/* Auth card (inline in chat) */
.auth-card {
  align-self: flex-start;
  max-width: 80%;
  background: var(--bg-secondary);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-card .auth-header {
  font-weight: 600;
  color: var(--accent);
  font-size: 13px;
}

.auth-card .auth-instructions {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}

.auth-card .auth-links {
  display: flex;
  gap: 8px;
  align-items: center;
}

.auth-card .auth-links a {
  color: var(--accent);
  font-size: 13px;
  text-decoration: underline;
}

.auth-card .auth-token-input {
  display: flex;
  gap: 8px;
  align-items: center;
}

.auth-card .auth-token-input input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: monospace;
}

.auth-card .auth-token-input input:focus {
  outline: none;
  border-color: var(--accent);
}

.auth-card .auth-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.auth-card .auth-actions button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  background: var(--bg-secondary);
  color: var(--text);
}

.auth-card .auth-actions button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.auth-card .auth-actions button.auth-submit {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.auth-card .auth-actions button.auth-cancel {
  background: var(--bg-secondary);
  border-color: var(--border);
}

.auth-card .auth-actions button.auth-oauth {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.auth-card .auth-error {
  color: var(--danger);
  font-size: 12px;
}

/* Chat input */
.chat-input {
  display: flex;
  padding: 20px calc(50% - 400px) 28px;
  gap: 12px;
  background: linear-gradient(0deg, var(--bg) 50%, transparent);
  border-top: none;
  align-items: flex-end;
  position: relative;
  z-index: 5;
}

.chat-input textarea {
  flex: 1;
  padding: 14px 22px;
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(1.1);
  -webkit-backdrop-filter: blur(24px) saturate(1.1);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
  resize: none;
  min-height: 52px;
  max-height: 200px;
  line-height: 1.5;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: border-color var(--duration-slow) var(--ease), box-shadow var(--duration-slow) var(--ease), background var(--duration-slow) var(--ease);
}

.chat-input textarea:focus {
  outline: none;
  background: rgba(20, 20, 30, 0.8);
  border-color: rgba(220, 38, 38, 0.3);
  box-shadow: var(--shadow), 0 0 0 1px rgba(220, 38, 38, 0.2), 0 0 20px rgba(220, 38, 38, 0.06);
}

.chat-input textarea::placeholder {
  color: var(--text-muted);
}

.chat-input button {
  padding: 12px 16px;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent), #991b1b);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.3);
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease), filter var(--duration) var(--ease);
}

.chat-input button:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.45);
  filter: brightness(1.15);
}

.chat-input button:active {
  transform: translateY(0) scale(0.97);
}

.chat-input button:disabled {
  background: rgba(40, 40, 50, 0.4);
  color: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

/* Memory Tab */
.memory-container {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.memory-sidebar {
  width: 280px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}

.memory-sidebar .search-box {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.memory-sidebar input {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
}

.memory-sidebar input:focus {
  outline: none;
  border-color: var(--accent);
}

.memory-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* Tree view */
.tree-row {
  display: flex;
  align-items: center;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  gap: 4px;
  min-height: 26px;
}

.tree-row:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}

.expand-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 8px;
  color: var(--text-secondary);
  transition: transform 0.15s ease;
  flex-shrink: 0;
  cursor: pointer;
}

.expand-arrow.expanded {
  transform: rotate(90deg);
}

.expand-arrow-spacer {
  display: inline-block;
  width: 16px;
  flex-shrink: 0;
}

.tree-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-label.dir {
  color: var(--text);
  font-weight: 500;
}

.tree-label.file {
  color: var(--text-secondary);
}

.tree-label.file:hover {
  color: var(--accent);
}

.tree-children {
  /* Rendered inline, indentation handled by padding-left on tree-row */
  display: contents;
}

/* Legacy tree-item (search results) */
.tree-item {
  padding: 4px 12px 4px 16px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tree-item:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}

.tree-item.active {
  background: var(--bg-tertiary);
  color: var(--accent);
}

.tree-item .icon {
  font-size: 12px;
  width: 16px;
  text-align: center;
}

.memory-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.memory-breadcrumb {
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.memory-breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.memory-breadcrumb a:hover {
  text-decoration: underline;
}

.memory-viewer {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.memory-viewer .empty {
  color: var(--text-secondary);
  font-style: italic;
}

.search-results {
  padding: 8px 0;
}

.search-result {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.search-result:hover {
  background: var(--bg-tertiary);
}

.search-result .path {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 4px;
}

.search-result .snippet {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Jobs Tab */
.jobs-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.jobs-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.jobs-create {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  margin-bottom: 14px;
}

.jobs-create input,
.jobs-create select {
  padding: 9px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text);
}

.summary-card {
  padding: 16px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.summary-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.summary-card .count {
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
}

.summary-card .label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-card.active .count {
  color: var(--accent);
}

.summary-card.completed .count {
  color: var(--success);
}

.summary-card.failed .count {
  color: var(--danger);
}

.summary-card.stuck .count {
  color: var(--warning);
}

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

.jobs-table th,
.jobs-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.jobs-table th {
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.jobs-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.badge.pending {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.badge.in_progress {
  background: rgba(239, 68, 68, 0.16);
  color: var(--accent);
}

.badge.completed {
  background: rgba(63, 185, 80, 0.15);
  color: var(--success);
}

.badge.failed {
  background: rgba(248, 81, 73, 0.15);
  color: var(--danger);
}

.badge.stuck {
  background: rgba(210, 153, 34, 0.15);
  color: var(--warning);
}

.badge.cancelled {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.badge.interrupted {
  background: rgba(210, 153, 34, 0.15);
  color: var(--warning);
}

.badge.source-sandbox {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

.badge.source-direct {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.btn-cancel {
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  cursor: pointer;
  font-size: 12px;
}

.btn-cancel:hover {
  background: rgba(248, 81, 73, 0.15);
}

.btn-restart {
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
}

.btn-restart:hover {
  background: rgba(239, 68, 68, 0.15);
}

.btn-browse {
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--success);
  border-radius: var(--radius);
  color: var(--success);
  cursor: pointer;
  font-size: 12px;
  text-decoration: none;
}

.btn-browse:hover {
  background: rgba(63, 185, 80, 0.15);
}

/* Job started card in chat */
.job-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  margin: 8px 0;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
  animation: messageIn 350ms var(--ease) both;
  transition: border-color var(--duration) var(--ease);
}

.job-card-icon {
  font-size: 20px;
}

.job-card-info {
  flex: 1;
}

.job-card-title {
  font-weight: 600;
  font-size: 14px;
}

.job-card-id {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: monospace;
}

.job-card-view,
.job-card-browse {
  padding: 4px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
}

.job-card-view {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
}

.job-card-view:hover {
  background: rgba(239, 68, 68, 0.15);
}

.job-card-browse {
  background: none;
  border: 1px solid var(--success);
  color: var(--success);
}

.job-card-browse:hover {
  background: rgba(63, 185, 80, 0.15);
}

/* Clickable job rows */
.job-row {
  cursor: pointer;
}

/* Job Detail View */
.job-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.job-detail-header h2 {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-back {
  padding: 6px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  flex-shrink: 0;
}

.btn-back:hover {
  background: var(--bg-tertiary);
}

.job-detail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.job-detail-tabs button {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
}

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

.job-detail-tabs button.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.job-detail-content {
  flex: 1;
  overflow-y: auto;
}

/* Metadata grid */
.job-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.meta-item {
  background: linear-gradient(180deg, #171922, #12141a);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.meta-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.meta-value {
  font-size: 14px;
  color: var(--text);
  word-break: break-all;
}

/* Job description */
.job-description {
  margin-bottom: 20px;
}

.job-description h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.job-description-body {
  background: linear-gradient(180deg, #171922, #12141a);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.6;
}

/* State transitions timeline */
.job-timeline-section {
  margin-bottom: 20px;
}

.job-timeline-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.timeline {
  position: relative;
  padding-left: 20px;
  border-left: 2px solid var(--border);
}

.timeline-entry {
  position: relative;
  padding: 8px 0 8px 16px;
}

.timeline-dot {
  position: absolute;
  left: -27px;
  top: 14px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

.timeline-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.timeline-time {
  color: var(--text-secondary);
  font-size: 12px;
  margin-left: 8px;
}

.timeline-reason {
  width: 100%;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Action cards */
.action-card {
  background: linear-gradient(180deg, #171922, #12141a);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  border-left: 3px solid var(--success);
}

.action-card.failure {
  border-left-color: var(--danger);
}

.action-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
}

.action-header:hover {
  background: var(--bg-tertiary);
}

.action-tool {
  font-weight: 600;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.action-seq {
  color: var(--text-secondary);
  font-size: 11px;
}

.action-duration {
  color: var(--text-secondary);
  font-size: 12px;
}

.action-time {
  color: var(--text-secondary);
  font-size: 12px;
  margin-left: auto;
}

.action-toggle {
  color: var(--text-secondary);
  font-size: 10px;
  flex-shrink: 0;
}

.action-detail {
  padding: 0 12px 12px;
}

.action-section {
  margin-top: 8px;
}

.action-section strong {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 4px;
}

.action-json {
  background: var(--code-bg);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  line-height: 1.4;
  overflow-x: auto;
  color: var(--text-secondary);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow-y: auto;
}

.action-error {
  background: rgba(248, 81, 73, 0.1);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  line-height: 1.4;
  color: var(--danger);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Conversation messages */
.conv-message {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.5;
}

.conv-role {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.conv-body {
  word-wrap: break-word;
}

.conv-system {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
}

.conv-system .conv-role {
  color: var(--text-secondary);
}

.conv-system .conv-body {
  color: var(--text-secondary);
  font-size: 13px;
}

.conv-user {
  background: rgba(88, 166, 255, 0.08);
  border: 1px solid rgba(88, 166, 255, 0.2);
}

.conv-user .conv-role {
  color: var(--accent);
}

.conv-assistant {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.conv-assistant .conv-role {
  color: var(--success);
}

.conv-tool {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
}

.conv-tool .conv-role {
  color: var(--warning);
}

.conv-tool .conv-body {
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
}

.conv-tc-id {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.conv-tool-calls {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.conv-tc-entry {
  margin-bottom: 6px;
}

.conv-tc-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.conv-tc-args {
  background: var(--code-bg);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 11px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  line-height: 1.4;
  margin: 4px 0 0;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 150px;
  overflow-y: auto;
}

/* Job files browser */
.job-files {
  display: flex;
  height: calc(100vh - 280px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.job-files-sidebar {
  width: 240px;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
  overflow-y: auto;
}

.job-files-tree {
  padding: 8px 0;
}

.job-files-viewer {
  flex: 1;
  overflow: auto;
  padding: 12px 16px;
}

.job-files-path {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 8px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.job-files-content {
  font-size: 13px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
  margin: 0;
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* Routines Tab */
.routines-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.routines-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

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

.routines-table th,
.routines-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.routines-table th {
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.routines-table tr:hover td {
  background: var(--bg-secondary);
}

.routine-row {
  cursor: pointer;
}

.routine-detail {
  padding: 16px 0;
}

.badge.enabled {
  background: rgba(63, 185, 80, 0.15);
  color: var(--success);
}

.badge.disabled {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.badge.failing {
  background: rgba(248, 81, 73, 0.15);
  color: var(--danger);
}

.btn-trigger {
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
}

.btn-trigger:hover {
  background: rgba(88, 166, 255, 0.15);
}

.btn-toggle {
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  color: var(--warning);
  cursor: pointer;
  font-size: 12px;
}

.btn-toggle:hover {
  background: rgba(210, 153, 34, 0.15);
}

/* Logs Tab */
.logs-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.logs-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logs-toolbar select,
.logs-toolbar input {
  padding: 5px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
}

.logs-toolbar select {
  min-width: 100px;
}

.logs-toolbar input {
  flex: 1;
  max-width: 240px;
}

.logs-toolbar select:focus,
.logs-toolbar input:focus {
  outline: none;
  border-color: var(--accent);
}

.logs-checkbox {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.logs-toolbar button {
  padding: 5px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}

.logs-toolbar button:hover {
  background: var(--border);
}

.logs-output {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
  background: var(--bg);
}

.log-entry {
  display: flex;
  gap: 8px;
  padding: 1px 12px;
  white-space: nowrap;
  cursor: pointer;
}

.log-entry:hover {
  background: var(--bg-secondary);
}

.log-ts {
  color: var(--text-secondary);
  flex-shrink: 0;
  width: 80px;
}

.log-level {
  flex-shrink: 0;
  width: 44px;
  font-weight: 600;
}

.log-target {
  color: var(--text-secondary);
  flex-shrink: 0;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-msg {
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-entry.expanded {
  white-space: normal;
}

.log-entry.expanded .log-msg {
  white-space: pre-wrap;
  word-break: break-all;
  overflow: visible;
  text-overflow: unset;
}

/* Log level coloring */
.log-entry.level-ERROR .log-level {
  color: var(--danger);
}

.log-entry.level-ERROR .log-msg {
  color: var(--danger);
}

.log-entry.level-WARN .log-level {
  color: var(--warning);
}

.log-entry.level-WARN .log-msg {
  color: var(--warning);
}

.log-entry.level-INFO .log-level {
  color: var(--text);
}

.log-entry.level-DEBUG .log-level {
  color: var(--text-secondary);
}

.log-entry.level-DEBUG .log-msg {
  color: var(--text-secondary);
}

/* Extensions Tab */
.extensions-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.extensions-section {
  margin-bottom: 24px;
}

.extensions-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.extensions-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.ext-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.ext-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.ext-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ext-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.ext-kind {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ext-kind.kind-mcp_server {
  background: rgba(88, 166, 255, 0.15);
  color: var(--accent);
}

.ext-kind.kind-wasm_tool {
  background: rgba(63, 185, 80, 0.15);
  color: var(--success);
}

.ext-kind.kind-wasm_channel {
  background: rgba(210, 153, 34, 0.15);
  color: var(--warning);
}

.ext-auth-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ext-auth-dot.authed {
  background: var(--success);
}

.ext-auth-dot.unauthed {
  background: var(--danger);
}

.ext-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.ext-url {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ext-tools {
  font-size: 12px;
  color: var(--text-secondary);
}

.ext-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}

.ext-active-label {
  font-size: 12px;
  color: var(--success);
  font-weight: 500;
}

.btn-ext {
  padding: 4px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--bg-tertiary);
  color: var(--text);
}

.btn-ext:hover {
  background: var(--border);
}

.btn-ext.activate {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ext.activate:hover {
  background: rgba(88, 166, 255, 0.15);
}

.btn-ext.remove {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-ext.remove:hover {
  background: rgba(248, 81, 73, 0.15);
}

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

.tools-table th,
.tools-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.tools-table th {
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.tools-table tr:hover td {
  background: var(--bg-secondary);
}