/* Agent Gateway Dashboard — Component styles */

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--color-accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre {
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* === Layout === */
.layout {
  display: flex;
  min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
  width: 16rem; /* w-64 */
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  z-index: var(--z-sidebar);
}

.sidebar-branding {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  background: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.sidebar-title {
  font-weight: 700;
  font-size: 1.125rem;
  line-height: 1.25;
}

.sidebar-subtitle {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

.sidebar-nav {
  padding: 0 1rem;
  flex: 1;
  overflow-y: auto;
}

.sidebar-header {
  padding: var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 3.5rem;
}

.sidebar-logo {
  height: 1.5rem;
  width: auto;
  object-fit: contain;
}

.sidebar-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: #ffffff;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  padding: var(--space-2) var(--space-2);
  flex: 1;
}

.nav-section-label {
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-text-secondary);
  padding: var(--space-4) var(--space-3) var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: var(--text-sm);
  font-weight: 400;
  transition: background var(--transition-fast), color var(--transition-fast);
  text-decoration: none;
  cursor: pointer;
  margin-bottom: 2px;
}

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

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

.nav-item.active .nav-icon { color: var(--color-accent); }

.nav-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid var(--sidebar-border);
}

/* === Main Content === */
.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-bg);
}

.top-header {
  height: 4rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  background: rgba(var(--color-surface-rgb, 255, 255, 255), 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 30;
}

html.dark .top-header {
  background: rgba(15, 23, 42, 0.8);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-content {
  padding: var(--space-8) var(--space-8); /* Increased page padding */
  flex: 1;
}

.page-header {
  margin-bottom: var(--space-6);
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.page-description {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: var(--space-1);
}

/* === Cards === */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: var(--text-lg); /* Slightly larger card titles */
  font-weight: 500;
  color: var(--color-text);
}

.card-body {
  padding: var(--space-5);
}

/* === Agent Cards === */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  gap: var(--space-5);
}

.agent-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-base), border-color var(--transition-base), transform var(--transition-fast);
  display: flex;
  flex-direction: column;
}

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

.agent-card-inner {
  padding: var(--space-5);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.agent-card-top {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  justify-content: space-between; /* push avatar to left and actions to right if needed */
}

.agent-card-top-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.agent-avatar {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  font-weight: 500;
  flex-shrink: 0;
}

.agent-name {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  line-height: var(--leading-tight);
}

.agent-model {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: 4px;
}

.agent-description {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-normal);
  /* Truncate to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.agent-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.agent-card-actions {
  padding: var(--space-3) var(--space-5);
  background: var(--color-surface-2);
  border-top: 1px solid var(--color-border-subtle);
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}

/* === Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-gray   { background: var(--color-surface-2); color: var(--color-text-secondary); border: 1px solid var(--color-border); }
.badge-green  { background: var(--color-success-bg); color: var(--color-success-text); }
.badge-red    { background: var(--color-danger-bg); color: var(--color-danger-text); }
.badge-amber  { background: var(--color-warning-bg); color: var(--color-warning-text); }
.badge-blue   { background: var(--color-info-bg); color: var(--color-info-text); }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.badge-accent { background: var(--color-accent-muted); color: var(--color-accent-text); }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

.badge-pulse .status-dot {
  animation: pulse 1.5s cubic-bezier(0.4,0,0.6,1) infinite;
}

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

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px 16px;
  border-radius: var(--radius-sm);  
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled { 
  opacity: 0.5; 
  cursor: not-allowed; 
  transform: none; 
}

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  text-decoration: none;
  color: #fff;
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--color-surface-hover);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
  box-shadow: none;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--color-surface-2);
  color: var(--color-text);
  text-decoration: none;
}

.btn-sm { padding: 6px 12px; font-size: var(--text-xs); }
.btn-icon { padding: 8px; }

/* === Table === */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

thead {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
}

th {
  padding: var(--space-3) var(--space-5);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

td {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-border-subtle);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tbody tr {
  transition: background var(--transition-fast);
}

tbody tr:hover {
  background: var(--color-surface-hover);
}

.table-link {
  color: var(--color-text);
  font-weight: 500;
  font-size: var(--text-sm);
}
.table-link:hover { color: var(--color-accent-text); text-decoration: underline; }

/* === Filters / Tabs === */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.tab-group {
  display: flex;
  gap: 2px;
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  padding: 2px;
}

.tab {
  padding: 3px var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.tab:hover { color: var(--color-text); }
.tab.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

/* === Forms === */
.input, select.input, textarea.input {
  display: block;
  width: 100%;
  padding: 6px var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface) !important;
  color: var(--color-text) !important;
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

input[type="date"].input {
  color-scheme: dark;
  display: inline-block;
  width: auto;
}

input[type="number"].input {
  color-scheme: dark;
  display: inline-block;
  width: 6rem;
}

input[type="text"].input,
select.input {
  display: inline-block;
  width: auto;
  appearance: auto;
}

input[type="text"].input {
  width: 14rem;
}

.input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-muted);
}

.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0px 1000px var(--color-surface) inset !important;
  -webkit-text-fill-color: var(--color-text) !important;
  caret-color: var(--color-text);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

/* === Trace / Timeline === */
.trace-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}

.trace-step {
  display: flex;
  gap: var(--space-3);
  position: relative;
}

.trace-step + .trace-step .trace-connector { display: block; }

.trace-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 2rem;
  flex-shrink: 0;
}

.trace-node {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 1;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
}

.trace-node-llm { border-color: var(--color-accent); background: var(--color-accent-muted); color: var(--color-accent-text); }
.trace-node-tool_call { border-color: var(--color-warning); background: var(--color-warning-bg); color: var(--color-warning-text); }
.trace-node-tool_result { border-color: var(--color-success); background: var(--color-success-bg); color: var(--color-success-text); }

.trace-line {
  width: 2px;
  flex: 1;
  background: var(--color-border);
  min-height: var(--space-3);
}

.trace-body {
  flex: 1;
  padding-bottom: var(--space-4);
}

.trace-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.trace-card-header {
  padding: var(--space-2) var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast);
}

.trace-card-header:hover { background: var(--color-surface-2); }

.trace-card-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.trace-card-body {
  padding: var(--space-3);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
  overflow: hidden;
  transition: max-height var(--transition-slow);
}

.trace-card-body.hidden { display: none; }

/* === Premium Trace Styles (Phase 3) === */
.glass-card {
  background: rgba(22, 27, 38, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(45, 51, 59, 0.5);
}

html.light .glass-card {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.timeline-line {
  background: linear-gradient(to bottom, var(--color-accent) 0%, var(--color-accent) 50%, rgba(13, 127, 242, 0.2) 100%);
}

.code-syntax-key { color: #9cdcfe; }
.code-syntax-string { color: #ce9178; }
.code-syntax-number { color: #b5cea8; }

/* === Code blocks === */
.code-block {
  background: var(--color-surface-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  overflow-x: auto;
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 20rem;
}

/* === Chat === */
.chat-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 3rem - var(--space-12));
}

.chat-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-3);
}

.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  scroll-behavior: smooth;
}

.message {
  display: flex;
  gap: var(--space-2);
  max-width: 80%;
  animation: fadeInUp var(--transition-base) ease;
}

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

.message-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-assistant { align-self: flex-start; }
.message-error { align-self: flex-start; }
.message-system { align-self: center; }

.message-avatar {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 600;
  flex-shrink: 0;
}

.message-user .message-avatar { background: var(--color-accent); color: #fff; }
.message-assistant .message-avatar { background: var(--color-surface-2); color: var(--color-text-secondary); }

.message-bubble {
  padding: var(--space-3) var(--space-4);
  border-radius: 12px;
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.message-user .message-bubble {
  background: var(--color-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message-assistant .message-bubble {
  background: var(--color-surface-2);
  color: var(--color-text);
  border-bottom-left-radius: 4px;
}

.message-assistant .message-bubble p { margin-bottom: var(--space-2); }
.message-assistant .message-bubble p:last-child { margin-bottom: 0; }
.message-assistant .message-bubble code {
  background: var(--color-surface-2);
  padding: 0.125rem 0.25rem;
  border-radius: var(--radius-sm);
}
.message-assistant .message-bubble pre {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  overflow-x: auto;
  margin: var(--space-2) 0;
}
.message-assistant .message-bubble ul, .message-assistant .message-bubble ol {
  padding-left: var(--space-5);
  margin-bottom: var(--space-2);
}

.message-error .message-bubble { background: var(--color-danger-bg); color: var(--color-danger-text); }
.message-system .message-bubble { background: var(--color-surface-2); color: var(--color-text-secondary); font-size: var(--text-xs); padding: var(--space-1) var(--space-3); border-radius: var(--radius-full); }

.chat-input-area {
  border-top: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-4);
  flex-shrink: 0;
}

.chat-input-row {
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
}

.chat-textarea {
  flex: 1;
  resize: none;
  min-height: 2.5rem;
  max-height: 8rem;
  overflow-y: auto;
  padding: 8px var(--space-4);
  border-radius: var(--radius-lg);
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: var(--space-1) 0;
}

.typing-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--color-text-tertiary);
  animation: bounce 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* === Analytics === */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

@media (max-width: 768px) {
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  transition: box-shadow var(--transition-base), border-color var(--transition-base);
}

.stat-card:hover {
  border-color: color-mix(in srgb, var(--color-accent) 16%, var(--color-border));
  box-shadow: var(--shadow-md);
}

.stat-label {
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.stat-value {
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.02em;
  line-height: 1;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-5);
  min-width: 0;
}

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

.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: box-shadow var(--transition-base), border-color var(--transition-base);
  min-width: 0;
  overflow: hidden;
}

.chart-card:hover {
  border-color: color-mix(in srgb, var(--color-accent) 12%, var(--color-border));
  box-shadow: var(--shadow-md);
}

.chart-title {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
  letter-spacing: -0.01em;
}

.chart-container {
  position: relative;
  height: 18rem;
  min-height: 18rem;
}

#analytics-content {
  min-height: 24rem;
  min-width: 0;
}

/* === Empty state === */
.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-8);
  color: var(--color-text-secondary);
}

.empty-icon {
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto var(--space-3);
  opacity: 0.35;
}

.empty-title {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.empty-desc {
  font-size: var(--text-sm);
  max-width: 24rem;
  margin: 0 auto;
}

/* === Alert / Banner === */
.alert {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.alert-warning { background: var(--color-warning-bg); color: var(--color-warning-text); border: 1px solid var(--color-warning); }
.alert-danger  { background: var(--color-danger-bg);  color: var(--color-danger-text);  border: 1px solid var(--color-danger); }
.alert-info    { background: var(--color-info-bg);    color: var(--color-info-text);    border: 1px solid var(--color-info); }

/* === Login page === */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  background-image: radial-gradient(ellipse at top, color-mix(in srgb, var(--color-accent) 3%, transparent), transparent 60%);
  padding: var(--space-6);
}

.login-card {
  width: 100%;
  max-width: 22rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: var(--space-8);
}

.login-logo {
  display: block;
  margin: 0 auto var(--space-5);
  max-height: 2rem;
  width: auto;
}

.login-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
  margin-bottom: var(--space-1);
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  text-align: center;
  margin-bottom: var(--space-5);
}

.form-group {
  margin-bottom: var(--space-3);
}

/* === Pagination === */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
}

.pagination-info {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* === HTMX loading states === */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-flex; }
.htmx-request.htmx-indicator { display: inline-flex; }

/* Fade-in for HTMX swapped content */
.htmx-added { animation: fadeIn var(--transition-base) ease; }
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* === Theme toggle button === */
.theme-toggle {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 6px;
  cursor: pointer;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.theme-toggle:hover { background: var(--color-surface-2); color: var(--color-text); }

.icon-sun  { display: none; }
.icon-moon { display: block; }
html.dark .icon-sun  { display: block; }
html.dark .icon-moon { display: none; }

/* === Mobile sidebar toggle === */
.sidebar-toggle { display: none; }
.sidebar-overlay { display: none; }

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--color-text-secondary);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast), color var(--transition-fast);
  }
  .sidebar-toggle:hover { background: var(--color-surface-2); color: var(--color-text); }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: calc(var(--z-sidebar) - 1);
  }
  .sidebar.open ~ .sidebar-overlay { display: block; }
}

/* === Copy-on-click tooltip === */
.copyable {
  position: relative;
  cursor: pointer;
}

.copy-toast {
  position: absolute;
  top: -1.75rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--palette-slate-900);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  animation: fadeInOut 1.2s ease forwards;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(4px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* === Toggle Switch === */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.toggle-switch input[type="checkbox"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  width: 2.25rem;
  height: 1.25rem;
  background: var(--color-surface-3);
  border-radius: var(--radius-full);
  position: relative;
  transition: background var(--transition-fast);
  border: 1px solid var(--color-border);
}

.toggle-switch input:checked + .toggle-track {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.toggle-track::after {
  content: '';
  position: absolute;
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 50%;
  background: #fff;
  top: 50%;
  left: 2px;
  transform: translateY(-50%);
  transition: left var(--transition-fast);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle-switch input:checked + .toggle-track::after {
  left: calc(100% - 16px);
}

/* === Stats bar (executions/schedules) === */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

@media (max-width: 768px) {
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
}

.stats-bar-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}

.stats-bar-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-1);
}

.stats-bar-value {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
}

/* === Cron chip === */
.cron-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-accent-text);
  font-weight: 600;
}

/* === Focus rings === */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* === Misc === */
.text-right { text-align: right; }
.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--color-text-secondary); }
.text-xs  { font-size: var(--text-xs); }
.text-sm  { font-size: var(--text-sm); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-5) 0;
}

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.w-full { width: 100%; }

/* === Premium Polish (Final) === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(45, 51, 59, 0.5); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(13, 127, 242, 0.5); }

.glass-card { box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37); }

html.dark body { background-color: #101922; color: #e2e8f0; }

/* === Light Mode Structural Overrides === */
html.light body { background-color: #f1f5f9; color: #0f172a; }
html.light .layout { background-color: #f1f5f9; }

/* Sidebar */
html.light aside { background-color: rgba(255,255,255,0.9) !important; border-right-color: #e2e8f0 !important; }
html.light aside h1 { color: #0f172a !important; }
html.light aside .sidebar-branding p { color: #64748b !important; }
html.light aside nav a { color: #334155 !important; }
html.light aside nav a span.text-slate-500 { color: #475569 !important; }
html.light aside nav a:hover { background-color: rgba(0,0,0,0.04) !important; color: #0f172a !important; }
html.light aside nav a.bg-primary\/10 { color: #0d7ff2 !important; }
html.light aside .sidebar-footer { border-top-color: #e2e8f0 !important; }
html.light aside .sidebar-footer button { background-color: rgba(0,0,0,0.04) !important; color: #334155 !important; border-color: rgba(0,0,0,0.08) !important; }
html.light aside .sidebar-footer button:hover { background-color: rgba(0,0,0,0.08) !important; color: #0f172a !important; }

/* Main area */
html.light main { background-color: #f8fafc !important; }
html.light .topbar { background-color: #ffffff !important; border-bottom-color: #e2e8f0 !important; }
html.light .topbar h2 { color: #475569 !important; }
html.light .topbar input { background-color: rgba(0,0,0,0.04) !important; border-color: rgba(0,0,0,0.06) !important; color: #0f172a !important; }
html.light .topbar button { color: #475569 !important; }
html.light .topbar button:hover { background-color: rgba(0,0,0,0.04) !important; }

/* Cards & surfaces */
html.light .card, html.light [class*="bg-surface"], html.light [class*="bg-background-surface"] { background-color: #ffffff !important; border-color: #e2e8f0 !important; }
html.light .bg-white\/5, html.light .hover\:bg-white\/5:hover { background-color: rgba(0,0,0,0.04) !important; }
html.light .bg-white\/10, html.light .hover\:bg-white\/10:hover { background-color: rgba(0,0,0,0.08) !important; }
html.light .bg-background-dark { background-color: #ffffff !important; }
html.light .bg-background-dark\/50 { background-color: rgba(255,255,255,0.8) !important; }

/* Text: remap muted slate shades to have proper contrast on white */
html.light .text-slate-300 { color: #334155 !important; }
html.light .text-slate-400 { color: #475569 !important; }
html.light .text-slate-500 { color: #475569 !important; }
html.light .text-slate-600 { color: #64748b !important; }
html.light .text-white { color: #0f172a !important; }

/* Borders */
html.light .border-border-dark, html.light .border-border-dark\/30 { border-color: #e2e8f0 !important; }
html.light .border-white\/5 { border-color: rgba(0,0,0,0.06) !important; }

/* Tables */
html.light table { background-color: #ffffff !important; }
html.light thead { background-color: #f8fafc !important; }
html.light th { color: #475569 !important; border-bottom-color: #e2e8f0 !important; }
html.light td { border-bottom-color: #f1f5f9 !important; color: #0f172a !important; }
html.light td * { color: inherit; }
html.light td .text-slate-400, html.light td .text-slate-500 { color: #475569 !important; }
html.light td .text-slate-600 { color: #64748b !important; }
html.light tbody tr:hover { background-color: #f8fafc !important; }

/* Stats bar cards */
html.light .stats-bar-card { background-color: #ffffff !important; border-color: #e2e8f0 !important; }
html.light .stats-bar-card .text-slate-400,
html.light .stats-bar-card .text-slate-500 { color: #475569 !important; }

/* Tag / cron chips */
html.light .cron-chip { background-color: #f1f5f9 !important; border-color: #e2e8f0 !important; color: #334155 !important; }
html.light [class*="rounded"][class*="bg-white\/5"],
html.light [class*="rounded"][class*="bg-white\/10"] { color: #334155 !important; }

/* Inputs */
html.light .input { background-color: #ffffff !important; border-color: #cbd5e1 !important; color: #0f172a !important; }
html.light .input:focus { border-color: #0d7ff2 !important; }
html.light .input::placeholder { color: #94a3b8 !important; }

/* Scrollbar */
html.light ::-webkit-scrollbar-thumb { background: rgba(203,213,225,0.8); }

.material-symbols-outlined { font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
