/* PulsarCD - Professional Docker Log Analytics Dashboard */

:root {
    /* Color Palette - Deep Ocean Theme */
    --bg-primary: #0a0e14;
    --bg-secondary: #0f1419;
    --bg-tertiary: #151b23;
    --bg-card: #1a222d;
    --bg-elevated: #1e2733;
    
    --text-primary: #e6e6e6;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    
    --accent-primary: #00d4aa;
    --accent-secondary: #0ea5e9;
    --accent-tertiary: #8b5cf6;
    
    --status-success: #22c55e;
    --status-warning: #f59e0b;
    --status-error: #ef4444;
    --status-info: #3b82f6;
    
    --border-color: #21262d;
    --border-light: #30363d;
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    /* Spacing */
    --topbar-height: 64px;
    
    /* Effects */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(0, 212, 170, 0.15);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --transition: all 0.2s ease;
}

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

html, body {
    height: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    /* Allow scrolling on mobile via main-content */
}

/* App Layout */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-primary);
}

/* Top Bar */
.topbar {
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-inner {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 16px;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

@media (min-width: 640px) {
    .topbar-inner {
        padding: 0 24px;
    }
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.topbar-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.topbar-btn.logout-btn:hover {
    color: var(--status-error);
}

.topbar-btn svg {
    width: 16px;
    height: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0;
    margin: 0;
    border: none;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.2);
}

.logo-icon svg {
    width: 20px;
    height: 20px;
    color: var(--bg-primary);
}

.logo-text {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #f1f5f9;
    font-family: var(--font-sans);
}

.logo-info {
    display: flex;
    flex-direction: column;
}

.logo-subtitle {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: -2px;
    font-weight: 400;
}

/* Navigation */
.nav {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    margin-left: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--transition);
    white-space: nowrap;
    cursor: pointer;
}

.nav-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

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

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

/* Mobile nav dropdown */
.mobile-nav-dropdown {
    display: none;
    flex-direction: column;
    border-top: 1px solid var(--border-color);
    padding: 8px 16px;
    background: var(--bg-secondary);
}

.mobile-nav-dropdown.open {
    display: flex;
}

.mobile-nav-dropdown .nav-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status-success);
    box-shadow: 0 0 8px var(--status-success);
    animation: pulse 2s infinite;
}

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

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 16px;
    max-width: 1800px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* Views */
.view {
    display: none;
}

.view.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.view-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: var(--bg-primary);
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 30px rgba(0, 212, 170, 0.3);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.btn-secondary:hover {
    background: var(--bg-elevated);
    border-color: var(--accent-primary);
}

.btn-success {
    background: var(--status-success);
    color: white;
}

.btn-warning {
    background: var(--status-warning);
    color: var(--bg-primary);
}

.btn-danger {
    background: var(--status-error);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-ghost:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

a.btn {
    text-decoration: none;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-md);
}

.stat-card[onclick]:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-tertiary);
}

.stat-icon svg {
    width: 20px;
    height: 20px;
}

.stat-icon.running {
    background: rgba(34, 197, 94, 0.15);
    color: var(--status-success);
}

.stat-icon.hosts {
    background: rgba(14, 165, 233, 0.15);
    color: var(--accent-secondary);
}

.stat-icon.cpu {
    background: rgba(0, 212, 170, 0.15);
    color: var(--accent-primary);
}

.stat-icon.memory {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-tertiary);
}

.stat-icon.gpu {
    background: rgba(251, 146, 60, 0.15);
    color: #fb923c;
}

.stat-card.warning .stat-icon {
    background: rgba(245, 158, 11, 0.15);
    color: var(--status-warning);
}

.stat-card.error .stat-icon {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-error);
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 1px;
}

/* Dashboard View */
#dashboard-view.active {
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

#dashboard-view .view-header {
    flex-shrink: 0;
}

#dashboard-view .stats-grid {
    flex-shrink: 0;
}

/* Charts */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 250px);
    gap: 12px;
    flex-shrink: 0;
    padding-bottom: 12px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.chart-card h3 {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 12px;
    flex-shrink: 0;
}

.chart-wrapper {
    position: relative;
    height: calc(100% - 36px);
    min-height: 180px;
}

.chart-card canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
}

/* Recurring errors widget */
.recurring-errors-card {
    height: auto;
    flex-shrink: 0;
    overflow: visible;
    margin-bottom: 16px;
}

.recurring-error-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 6px;
}
.recurring-error-item:last-child { margin-bottom: 0; }
.recurring-error-item:hover { background: var(--bg-tertiary); }

.recurring-error-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
}
.recurring-error-count {
    font-weight: 700;
    color: var(--status-error);
    min-width: 28px;
}
.recurring-error-services {
    color: var(--text-secondary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.recurring-error-age {
    color: var(--text-muted);
    white-space: nowrap;
}
.rerr-delivery {
    font-size: 0.85rem;
    font-weight: 700;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}
.rerr-delivery.delivered { color: var(--status-success, #22c55e); }
.rerr-delivery.failed { color: var(--status-error, #ef4444); }
.rerr-delivery.pending { color: var(--text-muted); }
.recurring-error-message {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Recurring error detail modal */
.rerr-meta-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.rerr-meta-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    min-width: 100px;
    padding-top: 2px;
}
.rerr-meta-value {
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.rerr-count-badge {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--status-error);
}
.rerr-services {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.rerr-service-chip {
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    font-family: var(--font-mono);
}
.rerr-full-message {
    margin: 0;
    padding: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 240px;
    overflow-y: auto;
}

/* Containers View */
#containers-view.active {
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

#containers-view > .view-header {
    flex-shrink: 0;
}

#containers-list {
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 24px;
    padding-right: 8px;
    flex: 1 1 0;
    min-height: 0;
}

#containers-list > .host-group {
    margin-bottom: 24px;
}

#containers-list > .host-group:last-child {
    margin-bottom: 0;
}

#stacks-list > .host-group {
    margin-bottom: 16px;
}

#stacks-list > .host-group:last-child {
    margin-bottom: 0;
}

/* Scrollbar styling for containers */
#containers-list::-webkit-scrollbar {
    width: 8px;
}

#containers-list::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

#containers-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

#containers-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.host-group {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.host-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.host-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    padding-left: 16px;
}

.host-header:hover {
    background: var(--bg-elevated);
}

.host-content {
    /* No max-height transition - use display instead */
}

.host-group.collapsed .host-content {
    display: none;
}

.host-group.collapsed .host-header {
    border-bottom: none;
}

.chevron-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
    flex-shrink: 0;
    color: var(--text-muted);
}

.collapsed .chevron-icon {
    transform: rotate(-90deg);
}

.group-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 8px;
    padding: 2px 8px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
}

/* Group stats (memory, CPU) */
.group-stat {
    font-size: 0.7rem;
    font-weight: 500;
    margin-left: 6px;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.group-memory {
    color: var(--accent-tertiary);
}

.group-cpu {
    color: var(--accent-primary);
}

.group-cpu.cpu-warning {
    color: var(--status-warning);
    background: rgba(245, 158, 11, 0.15);
}

.group-cpu.cpu-critical {
    color: var(--status-error);
    background: rgba(239, 68, 68, 0.2);
    font-weight: 600;
}

.group-gpu {
    color: var(--status-success);
}

.group-gpu.gpu-warning {
    color: var(--status-warning);
    background: rgba(245, 158, 11, 0.15);
}

.group-gpu.gpu-critical {
    color: var(--status-error);
    background: rgba(239, 68, 68, 0.2);
    font-weight: 600;
}

.group-disk {
    color: var(--accent-secondary);
}

.group-disk.disk-warning {
    color: var(--status-warning);
    background: rgba(245, 158, 11, 0.15);
}

.group-disk.disk-critical {
    color: var(--status-error);
    background: rgba(239, 68, 68, 0.2);
    font-weight: 600;
}

.host-name {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.host-name svg {
    width: 16px;
    height: 16px;
    color: var(--accent-secondary);
}

.compose-group {
    border-bottom: 1px solid var(--border-color);
    margin-left: 20px;
}

.compose-group:last-child {
    border-bottom: none;
}

.compose-group-empty {
    opacity: 0.6;
}

.compose-group-empty .compose-header svg:first-child {
    color: var(--text-muted);
}

.service-no-replicas {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 1px 6px;
    border-radius: 4px;
}

.container-item-empty {
    cursor: default;
    opacity: 0.7;
}

.compose-header {
    padding: 8px 16px;
    background: var(--bg-elevated);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

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

.compose-header svg {
    width: 16px;
    height: 16px;
    color: var(--accent-tertiary);
}

.compose-header .chevron-icon {
    color: var(--text-muted);
}

.compose-content {
    /* No max-height transition - use display instead */
}

.compose-group.collapsed .compose-content {
    display: none;
}

.compose-group.collapsed .compose-header {
    border-bottom: none;
}

.container-list {
    padding: 4px 8px 4px 16px;
}

.container-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    cursor: pointer;
}

.container-item:hover {
    background: var(--bg-tertiary);
}

.container-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0; /* Allow text truncation */
}

.container-info > div {
    min-width: 0;
}

.container-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.container-image {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.container-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.container-status.running {
    background: var(--status-success);
    box-shadow: 0 0 8px var(--status-success);
}

.container-status.exited {
    background: var(--text-muted);
}

.container-status.paused {
    background: var(--status-warning);
}

.container-name {
    font-weight: 500;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.container-image {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.image-sha {
    display: none;
}

.container-image:hover .image-sha {
    display: inline;
}

.container-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Container Mini Stats */
.container-stats-mini {
    display: flex;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    flex-shrink: 0;
}

.stat-mini {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    min-width: 70px;
    justify-content: flex-end;
    color: var(--status-success);
}

.stat-mini:last-child {
    min-width: 120px;
}

.stat-mini svg {
    opacity: 0.7;
    flex-shrink: 0;
}

.stat-mini-gpu {
    color: var(--accent-purple, #a78bfa);
}

/* Logs Search */
.search-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.search-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.search-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper svg {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
}

.search-input {
    width: 100%;
    padding: 10px 14px 10px 44px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.88rem;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.1);
}

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

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-group select,
.filter-group input {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.small-input {
    width: 80px;
}

/* Search Mode Toggle */
.search-mode-toggle {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: var(--radius-md);
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.mode-btn:hover {
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--bg-card);
    color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}

.mode-btn svg {
    width: 16px;
    height: 16px;
}

.ai-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.ai-indicator.available {
    background: var(--status-success);
    box-shadow: 0 0 6px var(--status-success);
}

.ai-indicator.unavailable {
    background: var(--status-error);
}

.ai-status-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-status-wrapper .ai-badge {
    font-size: 0.85rem;
}

/* AI Search Panel */
.ai-panel {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(14, 165, 233, 0.1));
    border: 1px solid rgba(139, 92, 246, 0.2);
    position: relative;
}

.ai-search-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

/* Recent Queries */
.recent-queries {
    margin-top: 8px;
    padding: 8px 0;
    border-top: 1px solid var(--border-color);
}

.recent-queries-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.recent-queries-header .btn-link {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0;
}

.recent-queries-header .btn-link:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}

.recent-queries-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.recent-query-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-query-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.recent-query-item .delete-query {
    display: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    margin-left: 4px;
}

.recent-query-item:hover .delete-query {
    display: inline;
}

.recent-query-item .delete-query:hover {
    color: var(--error);
}

.ai-badge {
    padding: 4px 10px;
    background: linear-gradient(135deg, var(--accent-tertiary), var(--accent-secondary));
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
}

.ai-hint {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
}

.ai-input {
    border-color: rgba(139, 92, 246, 0.3);
}

.ai-input:focus {
    border-color: var(--accent-tertiary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.ai-interpretation {
    margin-top: 12px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.interpretation-label {
    color: var(--text-muted);
    margin-right: 8px;
}

#ai-interpretation-text {
    color: var(--accent-primary);
    font-family: var(--font-mono);
}

/* Generated Query Panel */
.generated-query-panel {
    margin-top: 12px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.generated-query-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.generated-query-header .interpretation-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.query-json-editor {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-family: var(--font-mono);
    line-height: 1.4;
    resize: vertical;
    min-height: 50px;
}

.query-json-editor:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(106, 153, 85, 0.2);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-loading {
    animation: spin 1s linear infinite;
}

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

/* Logs Results */
.logs-results {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.logs-table-container {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

.logs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.logs-table th,
.logs-table td {
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.logs-table th {
    background: var(--bg-elevated);
    font-weight: 500;
    padding: 8px 10px;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.logs-table tr:hover {
    background: var(--bg-tertiary);
}

.logs-table tr.log-row-error {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--status-error);
}

.logs-table tr.log-row-error:hover {
    background: rgba(239, 68, 68, 0.15);
}

.logs-table tr.log-row-warning {
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid var(--status-warning);
}

.logs-table tr.log-row-warning:hover {
    background: rgba(245, 158, 11, 0.15);
}

/* Column widths - optimized for message content */
.logs-table .col-time {
    width: 70px;
    min-width: 70px;
    white-space: nowrap;
}

.logs-table .col-source {
    width: 140px;
    min-width: 100px;
    max-width: 180px;
}

.logs-table .col-level {
    width: 60px;
    min-width: 60px;
    text-align: center;
}

.logs-table .col-message {
    width: auto;
}

/* Source cell styling */
.source-host {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.2;
}

.source-container {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logs-table td.col-time {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.logs-table td.col-source {
    padding: 4px 10px;
}

.logs-table td.col-level {
    padding: 4px 6px;
}

.logs-table td.col-message {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logs-table td.message {
    font-family: var(--font-mono);
    max-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.log-level {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.log-level.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-error);
}

.log-level.warn {
    background: rgba(245, 158, 11, 0.15);
    color: var(--status-warning);
}

.log-level.info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--status-info);
}

.log-level.debug {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-tertiary);
}

/* Expandable Log Rows */
.log-row {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.log-row.expanded {
    background: var(--bg-tertiary) !important;
}

.message-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.log-expand-row {
    background: var(--bg-elevated) !important;
}

.log-expand-row:hover {
    background: var(--bg-elevated) !important;
}

.log-expand-row td {
    padding: 0 !important;
    border-bottom: 2px solid var(--accent-primary);
}

.log-expand-content {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.log-full-message {
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    overflow-x: auto;
}

.log-full-message pre {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
}

.log-analysis {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.analysis-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--border-color);
}

.analysis-item.similar-count {
    border-left-color: var(--status-info);
}

.analysis-item.ai-assessment {
    border-left-color: var(--accent-tertiary);
    flex: 1;
    min-width: 300px;
}

.analysis-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.analysis-value {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.analysis-value.loading {
    color: var(--text-muted);
    font-style: italic;
}

.analysis-value.loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--text-muted);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.analysis-value.high {
    color: var(--status-error);
}

.analysis-value.medium {
    color: var(--status-warning);
}

.analysis-value.low {
    color: var(--status-success);
}

.analysis-value.error {
    color: var(--status-error);
}

.assessment-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.assessment-badge.normal {
    background: rgba(34, 197, 94, 0.15);
    color: var(--status-success);
}

.assessment-badge.attention {
    background: rgba(245, 158, 11, 0.15);
    color: var(--status-warning);
}

.assessment-badge.critical {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-error);
}

.assessment-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Create Task button */
.analysis-item.create-task-item {
    border-left-color: var(--accent-tertiary);
    padding: 6px 12px;
}

.btn-task-create {
    background: rgba(139, 92, 246, 0.12);
    color: var(--accent-tertiary);
    border: 1px solid rgba(139, 92, 246, 0.25);
    padding: 5px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-task-create:hover {
    background: rgba(139, 92, 246, 0.22);
    border-color: rgba(139, 92, 246, 0.45);
}

/* Task creation modal form */
.task-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.task-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.task-form-group label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.task-input {
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font-mono);
}

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

.task-input[readonly] {
    opacity: 0.7;
    cursor: default;
}

.task-textarea {
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: var(--font-mono);
    resize: vertical;
    min-height: 180px;
    line-height: 1.5;
}

.task-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.btn-toggle-preview {
    float: right;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    padding: 2px 8px;
    cursor: pointer;
}
.btn-toggle-preview:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.task-preview {
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    line-height: 1.6;
    min-height: 180px;
    max-height: 400px;
    overflow-y: auto;
}
.task-preview pre {
    background: var(--bg-tertiary);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 0.8rem;
}
.task-preview code {
    background: var(--bg-tertiary);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.82em;
}
.task-preview pre code {
    background: none;
    padding: 0;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

#page-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.open,
.modal.active {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Fullscreen modal for container details */
.modal-content.modal-fullscreen {
    max-width: 95%;
    width: 95%;
    max-height: 95vh;
    height: 95vh;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.modal-title-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.status-badge {
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.running {
    background: rgba(34, 197, 94, 0.2);
    color: var(--status-success);
}

.status-badge.exited {
    background: rgba(110, 118, 129, 0.2);
    color: var(--text-muted);
}

.status-badge.paused {
    background: rgba(245, 158, 11, 0.2);
    color: var(--status-warning);
}

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

.modal-header-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 28px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    margin-left: 8px;
}

.modal-close:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.modal-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 24px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--bg-card);
    color: var(--accent-primary);
}

.modal-body {
    flex: 1;
    overflow: auto;
    padding: 24px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.logs-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.logs-toolbar-left,
.logs-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logs-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.logs-search-wrapper svg {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    pointer-events: none;
}

.logs-filter-input {
    padding: 8px 12px 8px 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    width: 200px;
    transition: var(--transition);
}

.logs-filter-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    width: 280px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
}

.log-viewer {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.5;
    flex: 1;
    min-height: 300px;
    overflow: auto;
}

.modal-fullscreen .log-viewer {
    max-height: none;
    height: calc(100% - 60px);
}

.modal-fullscreen .modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-fullscreen #tab-logs.active {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Log line styles */
.log-line {
    padding: 4px 16px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    display: flex;
    gap: 8px;
}

.log-line:hover {
    background: var(--bg-tertiary);
}

.log-line.log-error {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--status-error);
}

.log-line.log-error:hover {
    background: rgba(239, 68, 68, 0.15);
}

.log-line.log-warning {
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid var(--status-warning);
}

.log-line.log-warning:hover {
    background: rgba(245, 158, 11, 0.15);
}

.log-line.log-info {
    border-left: 3px solid transparent;
}

.log-line.log-debug {
    color: var(--text-muted);
    border-left: 3px solid transparent;
}

.log-line .log-timestamp {
    color: var(--text-muted);
    margin-right: 8px;
}

.log-line .log-highlight {
    background: rgba(0, 212, 170, 0.3);
    padding: 0 2px;
    border-radius: 2px;
}

.log-line.hidden {
    display: none;
}

.log-line.expanded {
    background: var(--bg-tertiary) !important;
}

.log-message-truncate {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Container Log Expansion */
.container-log-expand {
    background: var(--bg-elevated);
    border-bottom: 2px solid var(--accent-primary);
    padding: 12px 16px;
}

.container-log-expand .log-expand-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.container-log-expand .log-full-message {
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    overflow-x: auto;
}

.container-log-expand .log-full-message pre {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.4;
}

.container-log-expand .log-analysis {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.container-log-expand .analysis-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--border-color);
    font-size: 0.85rem;
}

.container-log-expand .analysis-item.similar-count {
    border-left-color: var(--status-info);
}

.container-log-expand .analysis-item.create-task-item {
    border-left-color: var(--accent-tertiary);
    padding: 4px 10px;
}

.stats-top-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stats-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.stats-controls select {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    font-size: 13px;
    cursor: pointer;
}

.container-charts {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.container-chart-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 12px 16px 8px;
    position: relative;
    height: 140px;
}

.container-chart-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.container-chart-card canvas {
    width: 100% !important;
    height: calc(100% - 22px) !important;
}

.stats-detail {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.stat-row .label {
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-row .value {
    font-family: var(--font-mono);
    font-weight: 600;
}

.info-detail {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-row {
    display: flex;
    gap: 16px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.info-row .label {
    min-width: 140px;
    color: var(--text-secondary);
    font-weight: 500;
}

.info-row .value {
    font-family: var(--font-mono);
    word-break: break-all;
}

.env-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.env-viewer {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.env-row {
    display: flex;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 13px;
}

.env-row .env-key {
    color: var(--color-info);
    font-weight: 600;
    min-width: 200px;
    flex-shrink: 0;
}

.env-row .env-value {
    color: var(--text-primary);
    word-break: break-all;
}

.env-row.hidden {
    display: none;
}

/* ============== Stacks View ============== */

.stacks-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.stacks-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.version-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.version-input {
    width: 80px;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

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

.stacks-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stack-item {
    display: flex;
    flex-direction: column;
    padding: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    overflow: hidden;
}

.stack-item:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.stack-item.deployed {
    border-color: rgba(34, 197, 94, 0.3);
}

.stack-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 8px;
    cursor: default;
}

.stack-item.deployed .stack-header {
    cursor: pointer;
}

.stack-item.deployed .stack-header:hover {
    background: var(--bg-tertiary);
}

.stack-chevron {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.stack-chevron.expanded {
    transform: rotate(180deg);
}

.stack-info {
    flex: 1;
    min-width: 0;
}

.stack-name {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.stack-name a {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition);
}

.stack-name a:hover {
    color: var(--accent-primary);
}

.stack-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.stack-badge.private {
    background: rgba(239, 68, 68, 0.2);
    color: var(--status-error);
}

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

.stack-badge.deployed {
    background: rgba(34, 197, 94, 0.2);
    color: var(--status-success);
    font-family: var(--font-mono);
}

.stack-deployed-ago {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
    margin-left: 2px;
}

.stack-description {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stack-meta {
    display: flex;
    gap: 12px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.stack-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Stack name block with meta badges below */
.stack-name-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stack-name-text {
    font-weight: 600;
}

.stack-meta-badge {
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    margin-right: 4px;
}

.stack-meta-badge.private {
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-error);
}

.stack-meta-badge.lang {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

/* Container age display */
.container-age {
    color: var(--text-muted);
    font-size: 0.85em;
}

.stack-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* Stack Containers (expandable section) */
.stack-containers {
    border-top: 1px solid var(--border-color);
    padding: 12px;
    background: var(--bg-secondary);
}

.stack-service {
    margin-bottom: 12px;
}

.stack-service:last-child {
    margin-bottom: 0;
}

.stack-service-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.stack-service-header svg {
    color: var(--text-muted);
}

.stack-service-containers {
    padding-left: 12px;
}

.stack-service-containers .container-item {
    margin-bottom: 6px;
}

.stack-service-containers .container-item:last-child {
    margin-bottom: 0;
}

.stacks-not-configured {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.stacks-not-configured svg {
    color: var(--text-muted);
    margin-bottom: 16px;
}

.stacks-not-configured h3 {
    color: var(--text-primary);
    margin-bottom: 12px;
}

.stacks-not-configured p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.stacks-not-configured code {
    display: block;
    background: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    color: var(--accent-primary);
    margin: 4px auto;
    max-width: fit-content;
}

.loading-placeholder,
.error-placeholder,
.empty-placeholder {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.error-placeholder {
    color: var(--status-error);
}

/* Action Toast (persistent build/deploy notification) */
#action-toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-toast {
    background: var(--bg-secondary);
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    padding: 12px 16px;
    min-width: 320px;
    max-width: 420px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
}

.action-toast.toast-visible {
    opacity: 1;
    transform: translateY(0);
}

.action-toast.toast-exit {
    opacity: 0;
    transform: translateY(20px);
}

.action-toast-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-toast-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.action-toast-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

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

.action-toast-text {
    flex: 1;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.action-toast-elapsed {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-family: var(--font-mono);
    flex-shrink: 0;
}

.action-toast-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

/* Action Logs Modal */
.action-log-viewer {
    height: 500px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px;
}

.action-log-viewer .log-line {
    padding: 1px 4px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-primary);
}

.action-log-viewer .log-line.log-error {
    color: var(--status-error);
}

.action-log-viewer .log-line.log-success {
    color: var(--status-success);
    font-weight: 600;
}

/* Stack Output Modal */
.stack-output-status {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.status-success {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--status-success);
    font-weight: 600;
}

.status-error {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--status-error);
    font-weight: 600;
}

.status-duration {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.status-host {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.stack-output-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    max-height: 400px;
    overflow: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Service Logs */
.service-logs-btn {
    margin-left: auto;
    font-size: 0.75rem;
    padding: 2px 8px;
}

.service-deploy-btn {
    font-size: 0.75rem;
    padding: 2px 8px;
}

.service-remove-btn {
    font-size: 0.75rem;
    padding: 2px 8px;
}

.service-log-viewer {
    height: 500px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px;
}

.service-log-viewer .log-line {
    padding: 1px 4px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-all;
}

.service-log-viewer .log-line.log-error {
    color: var(--status-error);
}

.service-log-viewer .log-timestamp {
    color: var(--text-muted);
    margin-right: 8px;
    font-size: 0.8rem;
}

.service-log-viewer .log-message {
    color: var(--text-primary);
}

/* Env editor */
.env-help-text {
    margin: 0 0 12px 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.env-editor {
    width: 100%;
    min-height: 300px;
    max-height: 500px;
    resize: vertical;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-primary);
    tab-size: 4;
}

.env-editor:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.env-editor:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.modal-lg {
    max-width: 800px;
}

.modal-md {
    max-width: 550px;
}

/* Form elements for modals */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: var(--transition);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.1);
}

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

.form-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.radio-group {
    display: flex;
    gap: 20px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.radio-label input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-light);
    border-radius: 50%;
    background: var(--bg-primary);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.radio-label input[type="radio"]:checked {
    border-color: var(--accent-primary);
}

.radio-label input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
}

.modal-help-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.current-image-display {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-primary);
    word-break: break-all;
}

.current-image-display strong {
    color: var(--text-primary);
}

/* Tags list for deploy modal */
.tags-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
}

.tags-group {
    border-bottom: 1px solid var(--border-color);
}

.tags-group:last-child {
    border-bottom: none;
}

.tags-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.tags-group-header .branch-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.tags-group-header .branch-name::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2'%3E%3Cpath d='M6 3v12M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM18 9a9 9 0 0 1-9 9'/%3E%3C/svg%3E") no-repeat center/contain;
}

.tags-group-header .tag-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.tags-group-items {
    padding: 8px;
}

.tag-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.tag-item:hover {
    background: var(--bg-tertiary);
}

.tag-item.selected {
    background: rgba(0, 212, 170, 0.15);
    border: 1px solid rgba(0, 212, 170, 0.3);
}

.tag-item .tag-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.tag-item .tag-name::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300d4aa' stroke-width='2'%3E%3Cpath d='M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z'/%3E%3Cline x1='7' y1='7' x2='7.01' y2='7'/%3E%3C/svg%3E") no-repeat center/contain;
}

.tag-item .tag-sha {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.tag-item .tag-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tag-item .tag-age {
    font-size: 0.8rem;
    color: var(--text-muted);
    opacity: 0.8;
}

.selected-tag-display {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(0, 212, 170, 0.1);
    border: 1px solid rgba(0, 212, 170, 0.2);
    border-radius: var(--radius-md);
    margin-top: 16px;
}

.selected-tag-display .label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.selected-tag-display .tag-value {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--accent-primary);
}

.empty-placeholder,
.error-placeholder {
    padding: 32px 24px;
    text-align: center;
    color: var(--text-muted);
}

.empty-placeholder p,
.error-placeholder p {
    margin-bottom: 8px;
}

.empty-placeholder .hint,
.error-placeholder .hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.error-placeholder {
    color: var(--status-error);
}

.btn-loading {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.modal-footer .container-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Mobile Menu Toggle Button (deprecated - logo-icon is used instead) */
.mobile-menu-toggle {
    display: none !important;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.mobile-menu-toggle:hover {
    background: var(--bg-tertiary);
}

.mobile-menu-toggle svg {
    width: 20px;
    height: 20px;
}

/* ============== Update Badge/Button ============== */

.stack-badge.update-available {
    background: rgba(14, 165, 233, 0.15);
    color: var(--accent-secondary);
    border: 1px solid rgba(14, 165, 233, 0.3);
    animation: pulse-subtle 2s infinite;
}

.btn-update {
    background: var(--accent-secondary) !important;
    color: white !important;
    border: none !important;
    font-weight: 600;
}

.btn-update:hover {
    filter: brightness(1.15);
}

@keyframes pulse-subtle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ============== Health-based Background ============== */

.host-header.health-warning {
    background: rgba(245, 158, 11, 0.08);
    border-left: 3px solid #f59e0b;
}
.host-header.health-critical {
    background: rgba(239, 68, 68, 0.08);
    border-left: 3px solid var(--status-error);
}
.host-header.health-warning:hover { background: rgba(245, 158, 11, 0.12); }
.host-header.health-critical:hover { background: rgba(239, 68, 68, 0.12); }

/* ============== Monitoring Tooltip ============== */

.stack-monitoring-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: default;
    margin-left: 4px;
}

.health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.health-dot.dot-ok { background: var(--status-success); }
.health-dot.dot-warning { background: #f59e0b; }
.health-dot.dot-critical { background: var(--status-error); animation: pulse-subtle 2s infinite; }

.stack-monitoring-tooltip .tooltip-content {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    color: var(--text-secondary);
    line-height: 1.6;
}
.stack-monitoring-tooltip .tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--border-color);
}
.stack-monitoring-tooltip:hover .tooltip-content { display: block; }

/* ============== Pipeline Flow ============== */

.pipeline-flow {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 0.75rem;
    margin-left: 4px;
}

.pipeline-step {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-weight: 500;
    user-select: none;
}
.pipeline-step { position: relative; }
.pipeline-step:hover { filter: brightness(1.2); }

.pipeline-log-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.15s, background 0.15s;
    margin-left: 2px;
    flex-shrink: 0;
}
.pipeline-log-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.12);
}

.pipeline-arrow {
    color: var(--text-muted);
    font-size: 0.7rem;
    flex-shrink: 0;
    opacity: 0.5;
    transition: var(--transition);
}

.pipeline-arrow.arrow-approved {
    color: var(--status-success);
    opacity: 1;
    font-weight: bold;
}

.pipeline-arrow.arrow-rejected {
    color: var(--status-error);
    opacity: 1;
    font-weight: bold;
}

.pipeline-arrow.has-gate {
    position: relative;
    font-size: 0.8rem;
}
.pipeline-arrow.has-gate::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent-primary);
}
.pipeline-arrow.has-gate.arrow-approved::after { background: var(--status-success); }
.pipeline-arrow.has-gate.arrow-rejected::after { background: var(--status-error); }

/* Clickable transition button between pipeline steps */
.pipeline-transition-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 3px 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    opacity: 0.6;
    transition: all 0.2s;
    position: relative;
    flex-shrink: 0;
}
.pipeline-transition-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.08);
    color: var(--accent-primary);
}
.pipeline-transition-btn.arrow-approved {
    color: var(--status-success);
    opacity: 0.9;
}
.pipeline-transition-btn.arrow-rejected {
    color: var(--status-error);
    opacity: 0.9;
}
.pipeline-transition-btn.has-gate::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent-primary);
}
.pipeline-transition-btn.has-gate.arrow-approved::after { background: var(--status-success); }
.pipeline-transition-btn.has-gate.arrow-rejected::after { background: var(--status-error); }
.pipeline-transition-btn.transition-mode-manual { color: var(--status-warning); opacity: 0.9; }
.pipeline-transition-btn.transition-mode-agent { color: var(--accent-primary); opacity: 0.9; }

/* Transition mode badge */
.transition-badge {
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 0 3px;
    border-radius: 3px;
    line-height: 14px;
    white-space: nowrap;
}
.transition-badge.badge-manual { background: rgba(251, 191, 36, 0.2); color: var(--status-warning); }
.transition-badge.badge-agent { background: rgba(139, 92, 246, 0.2); color: var(--accent-primary); }
.transition-badge.badge-auto { background: rgba(14, 165, 233, 0.15); color: var(--accent-secondary); }

/* Transition config modal */
.transition-mode-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.transition-mode-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.2s;
}
.transition-mode-option:hover {
    border-color: var(--accent-primary);
    background: rgba(var(--accent-primary-rgb, 139, 92, 246), 0.05);
}
.transition-mode-option.selected {
    border-color: var(--accent-primary);
    background: rgba(var(--accent-primary-rgb, 139, 92, 246), 0.1);
    box-shadow: 0 0 0 1px var(--accent-primary);
}
.transition-mode-option input[type="radio"] {
    margin-top: 2px;
    accent-color: var(--accent-primary);
    flex-shrink: 0;
}
.transition-mode-info {
    flex: 1;
    min-width: 0;
}
.transition-mode-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}
.transition-mode-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Step states */
.pipeline-step.step-idle { background: var(--bg-tertiary); color: var(--text-muted); }
.pipeline-step.step-running { background: rgba(14, 165, 233, 0.15); color: var(--accent-secondary); }
.pipeline-step.step-success { background: rgba(34, 197, 94, 0.15); color: var(--status-success); }
.pipeline-step.step-failed { background: rgba(239, 68, 68, 0.15); color: var(--status-error); }
.pipeline-step.step-warning { background: rgba(251, 146, 60, 0.15); color: #fb923c; }
.pipeline-step.step-gate_rejected { background: rgba(251, 191, 36, 0.15); color: var(--status-warning); }
.pipeline-step.step-pending {
    background: rgba(14, 165, 233, 0.08);
    color: var(--accent-secondary);
    border: 1px dashed rgba(14, 165, 233, 0.3);
}
.pipeline-step.step-skipped {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}

.pipeline-spinner { animation: pipeline-spin 1s linear infinite; }
@keyframes pipeline-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ============== Activity Modal ============== */

.activity-modal-body {
    padding: 0 !important;
    overflow: hidden;
}

.activity-layout {
    display: flex;
    height: 100%;
    overflow: hidden;
}

.activity-graph-panel {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    min-width: 0;
}

.activity-diff-panel {
    width: 55%;
    min-width: 400px;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.activity-diff-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.activity-diff-title {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.activity-diff-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Graph */
.activity-graph {
    position: relative;
}

.activity-svg {
    pointer-events: none;
}

.activity-commit-dot {
    pointer-events: all;
    cursor: pointer;
    transition: r 0.15s;
}

.activity-commit-dot:hover {
    r: 7;
}

.activity-rows {
    position: relative;
}

.activity-row {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    padding: 0 16px 0 0;
    cursor: pointer;
    transition: background 0.15s;
}

.activity-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.activity-row.selected {
    background: rgba(0, 212, 170, 0.08);
}

.activity-row-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.activity-labels {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.activity-label {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    white-space: nowrap;
}

.activity-branch-label {
    background: rgba(0, 212, 170, 0.15);
    color: var(--accent-primary);
    border: 1px solid rgba(0, 212, 170, 0.3);
}

.activity-tag-label {
    background: rgba(245, 158, 11, 0.15);
    color: var(--status-warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.activity-sha {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent-secondary);
    background: rgba(14, 165, 233, 0.1);
    padding: 1px 5px;
    border-radius: 3px;
    flex-shrink: 0;
}

.activity-msg {
    font-size: 0.82rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.activity-row-meta {
    margin-left: auto;
    display: flex;
    gap: 12px;
    flex-shrink: 0;
    padding-left: 12px;
}

.activity-author {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.activity-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 60px;
    text-align: right;
    white-space: nowrap;
}

/* Diff viewer */
.diff-commit-info {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.diff-commit-message {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 8px;
}

.diff-commit-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.diff-stats {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    font-size: 0.78rem;
    font-family: var(--font-mono);
}

.diff-stat-add { color: var(--status-success); }
.diff-stat-del { color: var(--status-error); }
.diff-stat-files { color: var(--text-muted); }

.diff-file {
    margin-bottom: 6px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.diff-file.collapsed .diff-file-body { display: none; }
.diff-file.collapsed .chevron-icon { transform: rotate(-90deg); }

.diff-file-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    cursor: pointer;
    font-size: 0.82rem;
    user-select: none;
}

.diff-file-header:hover { background: var(--bg-elevated); }

.diff-file-header .chevron-icon {
    margin-left: auto;
    width: 14px;
    height: 14px;
    transition: transform 0.2s;
    color: var(--text-muted);
}

.diff-file-status {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.72rem;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
}

.diff-file-status.file-added { background: rgba(34, 197, 94, 0.2); color: var(--status-success); }
.diff-file-status.file-removed { background: rgba(239, 68, 68, 0.2); color: var(--status-error); }
.diff-file-status.file-modified { background: rgba(245, 158, 11, 0.2); color: var(--status-warning); }
.diff-file-status.file-renamed { background: rgba(139, 92, 246, 0.2); color: #8b5cf6; }

.diff-file-name {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.diff-file-stats {
    display: flex;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    flex-shrink: 0;
}

.diff-file-body { overflow-x: auto; }

.diff-patch {
    margin: 0;
    padding: 8px 0;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.6;
    white-space: pre;
    background: var(--bg-secondary);
}

.diff-line {
    display: block;
    padding: 0 12px;
}

.diff-line.diff-add { background: rgba(34, 197, 94, 0.1); color: var(--status-success); }
.diff-line.diff-del { background: rgba(239, 68, 68, 0.1); color: var(--status-error); }
.diff-line.diff-hunk { color: #8b5cf6; background: rgba(139, 92, 246, 0.05); }

.diff-no-patch {
    color: var(--text-muted);
    font-style: italic;
    padding: 12px;
    display: block;
}

/* Responsive */
@media (max-width: 1200px) {
    .charts-grid {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    /* Allow body scroll on mobile */
    body {
        overflow: auto;
    }
    
    /* Hide desktop nav on mobile, logo-icon becomes the menu toggle */
    .nav {
        display: none;
    }

    .logo-icon {
        cursor: pointer;
        transition: transform 0.25s ease, box-shadow 0.25s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .logo-icon:active {
        transform: scale(0.9);
    }

    .logo-icon.menu-open {
        box-shadow: 0 0 0 3px var(--accent-primary), 0 10px 15px -3px rgba(99, 102, 241, 0.3);
        transform: rotate(15deg);
    }

    .connection-status .status-text {
        display: none;
    }

    /* Logo adjustment */
    .logo {
        padding: 0;
    }

    .logo-subtitle {
        display: none;
    }

    /* Main content - full width with scroll */
    .main-content {
        padding: 10px;
        width: 100%;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .view-header h1 {
        font-size: 1.5rem;
    }

    .header-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Stats grid - horizontal scroll */
    .stats-grid {
        display: flex;
        overflow-x: auto;
        gap: 10px;
        margin-bottom: 12px;
        padding-bottom: 6px;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
    }

    .stat-card {
        flex: 0 0 160px;
        scroll-snap-align: start;
        padding: 16px;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
    }

    .stat-icon svg {
        width: 20px;
        height: 20px;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    /* Charts - vertical stack with fixed height */
    .charts-grid {
        display: flex;
        flex-direction: column;
        gap: 4px;
        flex: none;
        overflow-y: auto;
        padding-bottom: 12px;
    }

    .chart-card {
        height: auto;
        min-height: 0;
        flex: none;
        padding: 12px;
    }

    .chart-card h3 {
        font-size: 0.8rem;
        margin-bottom: 8px;
    }

    .chart-wrapper {
        height: 140px;
        min-height: 140px;
    }

    /* Container view */
    #containers-view .view-header {
        padding-bottom: 8px;
    }

    .filter-group {
        flex: 1;
        min-width: 120px;
    }

    .filter-group select {
        width: 100%;
    }

    /* Container items - stack vertically */
    .container-item {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 12px;
    }

    .container-info {
        width: 100%;
    }

    .container-stats-mini {
        width: 100%;
        justify-content: flex-start;
    }

    .stat-mini {
        flex: 1;
        min-width: auto;
        justify-content: center;
    }

    .stat-mini:last-child {
        min-width: auto;
    }

    .container-actions {
        width: 100%;
        justify-content: flex-end;
    }

    /* Host header */
    .host-header {
        flex-wrap: wrap;
        padding: 12px 16px;
    }

    .host-name {
        font-size: 1rem;
    }

    /* Pipeline: wrap to its own row on tablet */
    .host-header-actions {
        flex-wrap: wrap;
    }

    .pipeline-flow {
        order: 99;
        width: 100%;
        margin-left: 0;
        margin-top: 6px;
    }

    .pipeline-step {
        min-height: 32px;
    }

    .compose-header {
        padding: 10px 16px;
        font-size: 0.85rem;
    }

    /* Logs view */
    .search-panel {
        padding: 12px;
    }

    .search-row {
        flex-direction: column;
        gap: 8px;
        margin-bottom: 12px;
    }

    .search-input {
        padding: 14px 14px 14px 44px;
        font-size: 16px; /* Prevents iOS zoom */
    }

    .filters-row {
        display: none; /* Hide advanced filters on mobile */
    }

    /* Logs table - card view on mobile */
    .logs-table {
        display: block;
    }

    .logs-table thead {
        display: none;
    }

    .logs-table tbody {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }

    .logs-table tr {
        display: flex;
        flex-direction: column;
        background: var(--bg-tertiary);
        border-radius: var(--radius-md);
        padding: 12px;
        border: 1px solid var(--border-color);
        border-left-width: 3px;
    }

    .logs-table tr.log-row-error {
        border-left-color: var(--status-error);
    }

    .logs-table tr.log-row-warning {
        border-left-color: var(--status-warning);
    }

    .logs-table td {
        display: block;
        padding: 4px 0;
        border: none;
    }

    .logs-table td.col-time {
        font-size: 0.7rem;
        order: 1;
    }

    .logs-table td.col-source {
        order: 2;
        padding-bottom: 8px;
        border-bottom: 1px solid var(--border-color);
    }

    .logs-table td.col-level {
        position: absolute;
        top: 12px;
        right: 12px;
    }

    .logs-table td.col-message {
        order: 3;
        white-space: normal;
        word-break: break-word;
        max-width: none;
        padding-top: 8px;
        font-size: 0.85rem;
        line-height: 1.5;
    }

    .logs-table tr {
        position: relative;
    }

    /* Pagination */
    .pagination {
        padding: 12px;
        gap: 8px;
    }

    #page-info {
        font-size: 0.8rem;
    }

    /* Modal - full screen on mobile */
    .modal {
        padding: 0;
    }

    .modal-content,
    .modal-content.modal-fullscreen {
        max-width: 100%;
        width: 100%;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
    }

    .modal-header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .modal-title-section {
        flex: 1;
        min-width: 0;
    }

    .modal-header h2 {
        font-size: 1rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .modal-header-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .modal-header-actions .btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .modal-header-actions .btn span:not(.btn-icon) {
        display: none;
    }

    .modal-close {
        position: absolute;
        top: 8px;
        right: 8px;
    }

    .modal-tabs {
        padding: 8px 12px;
        gap: 2px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .modal-body {
        padding: 12px;
        flex: 1;
        overflow: auto;
    }

    /* Logs toolbar in modal */
    .logs-toolbar {
        flex-direction: column;
        gap: 8px;
    }

    .logs-toolbar-left,
    .logs-toolbar-right {
        width: 100%;
        flex-wrap: wrap;
    }

    .logs-filter-input {
        width: 100%;
    }

    .logs-filter-input:focus {
        width: 100%;
    }

    /* Log viewer */
    .log-viewer {
        font-size: 0.75rem;
    }

    .log-line {
        padding: 8px 12px;
        flex-direction: column;
        gap: 4px;
        white-space: normal;
    }

    .log-line .log-timestamp {
        font-size: 0.65rem;
    }

    .log-message-truncate {
        white-space: normal;
        word-break: break-word;
    }

    /* Container log expand */
    .container-log-expand {
        padding: 10px 12px;
    }

    .container-log-expand .log-analysis {
        flex-direction: column;
        gap: 8px;
    }

    .container-log-expand .analysis-item {
        width: 100%;
        min-width: auto;
    }

    /* Env tab */
    .env-toolbar {
        flex-direction: column;
        gap: 8px;
    }

    .env-toolbar input {
        width: 100%;
    }

    .env-row {
        flex-direction: column;
        gap: 4px;
    }

    .env-row .env-key {
        min-width: auto;
        font-size: 0.75rem;
    }

    .env-row .env-value {
        font-size: 0.8rem;
    }

    /* Info tab */
    .info-row {
        flex-direction: column;
        gap: 4px;
    }

    .info-row .label {
        min-width: auto;
        font-size: 0.8rem;
    }

    .info-row .value {
        font-size: 0.85rem;
    }

    /* Stats tab */
    .stat-row {
        padding: 10px 12px;
    }

    /* Modal footer */
    .modal-footer {
        padding: 12px 16px;
    }

    /* Recent queries */
    .recent-query-item {
        max-width: 200px;
        font-size: 0.75rem;
    }

    /* AI panel */
    .ai-search-info {
        flex-wrap: wrap;
        gap: 8px;
    }

    .ai-badge {
        font-size: 0.7rem;
    }

    /* Generated query panel */
    .generated-query-panel {
        padding: 8px 10px;
    }

    .query-json-editor {
        font-size: 0.75rem;
    }

    /* Log expand content */
    .log-expand-content {
        padding: 12px;
    }

    .log-analysis {
        flex-direction: column;
        gap: 8px;
    }

    .analysis-item {
        width: 100%;
        min-width: auto;
    }

    .analysis-item.ai-assessment {
        min-width: auto;
    }
}

/* Small mobile (< 480px) */
@media (max-width: 480px) {
    .stat-card {
        flex: 0 0 140px;
        padding: 12px;
        gap: 10px;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .view-header h1 {
        font-size: 1.25rem;
    }

    .chart-card {
        height: auto;
        min-height: 0;
        padding: 10px;
    }

    .chart-card h3 {
        font-size: 0.75rem;
        margin-bottom: 6px;
    }

    .chart-wrapper {
        height: 120px;
        min-height: 120px;
    }

    .container-stats-mini {
        flex-wrap: wrap;
    }

    .stat-mini {
        flex: 1 1 45%;
        min-width: 70px;
    }

    .host-header-actions .btn span {
        display: none;
    }

    /* Pipeline: full-width row below action buttons on mobile */
    .host-header-actions {
        flex-wrap: wrap;
    }

    .pipeline-flow {
        order: 99;
        width: 100%;
        justify-content: stretch;
        gap: 6px;
        margin-left: 0;
        margin-top: 8px;
    }

    .pipeline-step {
        flex: 1;
        justify-content: center;
        min-height: 44px;
        padding: 8px 6px;
        font-size: 0.75rem;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: var(--radius-md);
        flex-direction: column;
        gap: 2px;
    }

    /* Make idle steps look tappable */
    .pipeline-step.step-idle {
        border: 1px dashed rgba(255, 255, 255, 0.2);
        background: rgba(255, 255, 255, 0.04);
    }

    /* Active press feedback for mobile */
    .pipeline-step:active {
        transform: scale(0.95);
        filter: brightness(0.9);
    }

    /* Keep step labels visible on mobile */
    .pipeline-flow .pipeline-step span {
        display: inline;
    }

    /* Hide version step entirely to save space on mobile */
    .pipeline-flow .pipeline-step:first-child {
        display: none;
    }

    .pipeline-arrow {
        display: none;
    }

    .pipeline-transition-btn {
        display: none;
    }

    .pipeline-log-btn {
        display: none;
    }

    .activity-layout {
        flex-direction: column;
    }

    .activity-diff-panel {
        width: 100%;
        min-width: unset;
        border-left: none;
        border-top: 1px solid var(--border-color);
        max-height: 50%;
    }

    .activity-row-meta {
        display: none;
    }

    .modal-header-actions {
        justify-content: flex-end;
    }
    
    /* Hide group stats on very small screens */
    .group-stat {
        display: none;
    }
}

/* Notifications */
/* Notification toasts (success/error/warning) — inside #action-toast-container */
.action-toast-notification.action-toast-success {
    border-color: var(--status-success);
    background: rgba(34, 197, 94, 0.08);
}

.action-toast-notification.action-toast-error {
    border-color: var(--status-error);
    background: rgba(239, 68, 68, 0.08);
}

.action-toast-notification.action-toast-warning {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.08);
}

.action-toast-icon {
    display: flex;
    flex-shrink: 0;
}

.action-toast-icon-success {
    color: var(--status-success);
}

.action-toast-icon-error {
    color: var(--status-error);
}

.action-toast-icon-warning {
    color: #f59e0b;
}

.action-toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0 4px;
    flex-shrink: 0;
    margin-left: auto;
}

.action-toast-close:hover {
    color: var(--text-primary);
}

/* ============== Login ============== */

.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    margin-bottom: 1rem;
}

.login-logo svg {
    width: 24px;
    height: 24px;
    stroke: var(--bg-primary);
}

.login-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.login-field {
    margin-bottom: 1rem;
}

.login-field input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.login-field input:focus {
    border-color: var(--accent-primary);
}

.login-field input::placeholder {
    color: var(--text-tertiary);
}

.login-btn {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: var(--bg-primary);
    border: none;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.login-btn:hover {
    opacity: 0.9;
}

.login-error {
    margin-top: 1rem;
    padding: 0.6rem 0.8rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    color: var(--status-error);
    font-size: 0.85rem;
    text-align: center;
    display: none;
}

/* ============== Terminal ============== */

#terminal-view.active {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.terminal-wrapper {
    flex: 1;
    padding: 8px;
    background: #0a0e14;
    border-radius: var(--radius-sm);
    overflow: hidden;
    min-height: 0;
}

.terminal-wrapper .xterm {
    height: 100%;
    padding: 4px;
}

.terminal-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.terminal-status {
    font-size: 0.85rem;
    font-family: var(--font-mono);
    padding: 4px 12px;
    border-radius: var(--radius-sm);
}

.terminal-status.connected {
    color: var(--status-success);
    background: rgba(34, 197, 94, 0.1);
}

.terminal-status.disconnected {
    color: var(--status-error);
    background: rgba(239, 68, 68, 0.1);
}

.terminal-status.connecting {
    color: var(--status-warning);
    background: rgba(245, 158, 11, 0.1);
}


/* ============== Agent Topbar Button ============== */

.agent-topbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.82rem;
    font-family: var(--font-mono);
}

.agent-topbar-btn:hover {
    background: var(--bg-elevated);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* ============== Agent Modal ============== */

#agent-modal .modal-content {
    height: 80vh;
    max-height: 80vh;
}

#agent-modal .modal-header {
    display: flex;
    align-items: center;
    gap: 16px;
}

#agent-modal .modal-header h2 {
    margin: 0;
    white-space: nowrap;
}

#agent-modal .modal-close {
    margin-left: auto;
}

.agent-modal-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.agent-tab {
    padding: 5px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
    font-family: var(--font-mono);
}

.agent-tab:hover {
    color: var(--text-primary);
}

.agent-tab.active {
    background: var(--bg-card);
    color: var(--accent-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.agent-modal-body {
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.agent-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 16px;
}

.agent-panel.active {
    display: flex;
}

.agent-instructions-form {
    overflow-y: auto;
    flex: 1;
}

.agent-instructions-form textarea {
    width: 100%;
    font-family: monospace;
    font-size: 12px;
    resize: vertical;
}

/* Agent History */
.agent-history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.agent-history-entry {
    display: flex;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    border-left: 3px solid var(--border-color);
}

.agent-history-entry.type-gate_decision {
    border-left-color: var(--accent-primary);
}

.agent-history-entry.type-gate_decision.rejected {
    border-left-color: var(--status-warning);
}

.agent-history-entry.type-failure_handled {
    border-left-color: var(--status-error);
}

.agent-history-entry.type-recurring_handled {
    border-left-color: var(--status-warning);
}

.agent-history-entry.type-chat {
    border-left-color: var(--accent-secondary);
}

.agent-history-entry.type-gate_error,
.agent-history-entry.type-failure_error,
.agent-history-entry.type-recurring_error {
    border-left-color: var(--status-error);
    opacity: 0.7;
}

.agent-history-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

.agent-history-content {
    flex: 1;
    min-width: 0;
}

.agent-history-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.agent-history-detail {
    color: var(--text-tertiary);
    font-size: 0.78rem;
    word-break: break-word;
    max-height: 80px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    line-height: 1.5;
}
.agent-history-detail pre {
    background: var(--bg-tertiary, #1a1a2e);
    border-radius: 4px;
    padding: 6px 8px;
    margin: 4px 0;
    overflow-x: auto;
    font-size: 0.74rem;
}
.agent-history-detail code {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    background: var(--bg-tertiary, #1a1a2e);
    padding: 1px 4px;
    border-radius: 3px;
}
.agent-history-detail pre code {
    background: none;
    padding: 0;
}
.agent-history-detail strong {
    color: var(--text-secondary, #ccc);
}
.agent-history-detail em {
    color: var(--text-secondary, #ccc);
}
.agent-history-detail.expanded {
    max-height: none;
    overflow: visible;
}
.agent-history-detail:not(.expanded)::after {
    content: '... (click to expand)';
    display: block;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.72rem;
    margin-top: 2px;
}

.agent-history-time {
    flex-shrink: 0;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.agent-history-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-tertiary);
}

.agent-history-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 0 4px;
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
    position: sticky;
    bottom: 0;
    background: var(--bg-secondary);
    z-index: 1;
    padding-bottom: 8px;
}

.pagination-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.15s ease;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.pagination-total {
    color: var(--text-tertiary);
    font-size: 0.75rem;
}


/* ============== User Menu ============== */

.user-menu {
    position: relative;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.82rem;
    font-family: var(--font-mono);
}

.user-menu-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.user-menu-chevron {
    transition: transform 0.2s;
}

.user-menu.open .user-menu-chevron {
    transform: rotate(180deg);
}

.user-menu-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 100;
    overflow: hidden;
}

.user-menu.open .user-menu-dropdown {
    display: block;
}

.user-menu-profile {
    padding: 12px 16px;
}

.user-menu-username {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.user-menu-role {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.user-menu-divider {
    height: 1px;
    background: var(--border-color);
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    font-family: inherit;
}

.user-menu-item:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.user-menu-item.user-menu-logout:hover {
    color: var(--status-error);
}

.user-menu-github {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 0.78rem;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

.user-menu-github-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    margin-left: auto;
}

.user-menu-github-dot.connected {
    background: var(--status-success);
}

.user-menu-github-dot.disconnected {
    background: var(--status-error);
}

/* Icon-only button variant */
.btn-icon {
    padding: 6px;
    min-width: unset;
}


/* ============== Settings Modal ============== */

#settings-modal .modal-content {
    height: 80vh;
    max-height: 80vh;
}

.settings-modal-body {
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.settings-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.settings-tab {
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    font-family: var(--font-mono);
}

.settings-tab:hover {
    color: var(--text-primary);
}

.settings-tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.settings-panel {
    display: none;
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

.settings-panel.active {
    display: flex;
    flex-direction: column;
}

/* LLM Test Chat */
.llm-test-info {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-bottom: 12px;
    flex-shrink: 0;
}

.llm-test-messages {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.llm-test-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.llm-test-msg.user {
    align-self: flex-end;
    background: var(--accent-primary);
    color: var(--bg-primary);
    border-bottom-right-radius: 2px;
}

.llm-test-msg.assistant {
    align-self: flex-start;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom-left-radius: 2px;
}

.llm-test-msg.error {
    align-self: flex-start;
    background: rgba(239, 68, 68, 0.15);
    color: var(--status-error);
    border-left: 3px solid var(--status-error);
}

.llm-test-msg.tool-call {
    align-self: flex-start;
    background: rgba(0, 212, 170, 0.08);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-family: var(--font-mono);
    border-left: 3px solid var(--accent-primary);
}

.llm-test-msg.thinking {
    align-self: flex-start;
    color: var(--text-tertiary);
    font-style: italic;
    background: transparent;
    padding: 4px 12px;
}

.llm-test-msg.thinking::after {
    content: '';
    display: inline-block;
    width: 12px;
    animation: dots 1.4s steps(4) infinite;
}

@keyframes dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

.llm-test-input {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-shrink: 0;
}

.llm-test-input input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.settings-field {
    margin-bottom: 16px;
}

.settings-field label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.settings-field input[type="text"],
.settings-field input[type="password"],
.settings-field textarea,
.settings-field select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: var(--font-mono);
    transition: var(--transition);
}

.settings-field input:focus,
.settings-field textarea:focus,
.settings-field select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.settings-field textarea {
    resize: vertical;
    min-height: 60px;
}

.settings-toggle-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem !important;
}

.settings-toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
}

/* MCP Servers */
.mcp-server-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 12px;
}

.mcp-server-card .settings-field {
    margin-bottom: 10px;
}

.mcp-server-card .settings-field:last-child {
    margin-bottom: 0;
}

.mcp-server-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.mcp-server-header h4 {
    font-size: 0.85rem;
    color: var(--text-primary);
    margin: 0;
}

.mcp-server-remove {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.mcp-server-remove:hover {
    color: var(--status-error);
    background: rgba(239, 68, 68, 0.1);
}

.mcp-test-result {
    margin-left: 10px;
    font-size: 12px;
}

.mcp-test-ok {
    color: var(--status-success);
}

.mcp-test-fail {
    color: var(--status-error);
}

/* Users list */
.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.user-row:last-child {
    border-bottom: none;
}

.user-row-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-row-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.user-row-role {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}

.user-row-actions {
    display: flex;
    gap: 6px;
}

.settings-add-user {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.settings-add-user h4 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0 0 10px 0;
}

.settings-add-user-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.settings-add-user-form input,
.settings-add-user-form select {
    padding: 6px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: var(--font-mono);
}

.settings-add-user-form input { flex: 1; }
.settings-add-user-form select { width: 100px; }

/* Settings footer */
.modal-footer-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.settings-status {
    font-size: 0.82rem;
    color: var(--status-success);
    flex: 1;
}

.settings-status.error {
    color: var(--status-error);
}

.settings-status.success {
    color: var(--status-success);
}

.settings-field-inline {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-field-row {
    display: flex;
    gap: 12px;
}
.settings-field-half {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.settings-field-half input {
    width: 100%;
}

.settings-section-divider {
    height: 1px;
    background: var(--border-color);
    margin: 20px 0 16px;
}

.settings-section-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.settings-section-desc {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    margin: 0 0 16px;
    line-height: 1.4;
}
