:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d2e;
    --bg-tertiary: #252938;
    --text-primary: #e4e7eb;
    --text-secondary: #9ca3af;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-purple: #8b5cf6;
    --accent-orange: #f59e0b;
    --border-color: #2d3348;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

code, .mono {
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

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

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

.logo-icon {
    font-size: 2rem;
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-stats {
    display: flex;
    gap: 2rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-blue);
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-badge.connected {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.disconnected {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Agents Grid */
.agents-section {
    margin-bottom: 1rem;
}

.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

.agent-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.agent-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--agent-color), transparent);
}

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

.agent-card.main::before { background: linear-gradient(90deg, var(--accent-blue), transparent); }
.agent-card.jobs::before { background: linear-gradient(90deg, var(--accent-purple), transparent); }
.agent-card.money::before { background: linear-gradient(90deg, var(--accent-green), transparent); }

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

.agent-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.agent-emoji {
    font-size: 2rem;
}

.agent-details h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.agent-role {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.agent-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
    animation: pulse 2s infinite;
}

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

.agent-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-top: 1rem;
}

.agent-stat {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.agent-stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.agent-stat-value {
    font-size: 1.125rem;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
}

/* Two Column Layout */
.two-column {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
}

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

/* Activity Feed */
.activity-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

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

.refresh-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px; /* iOS touch target minimum */
}

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

.refresh-btn:active {
    transform: scale(0.98);
}

.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 600px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth momentum scrolling on iOS */
}

.activity-feed::-webkit-scrollbar {
    width: 8px;
}

.activity-feed::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.activity-feed::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.activity-feed::-webkit-scrollbar-thumb:hover {
    background: #3d4256;
}

.activity-item {
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border-left: 3px solid var(--accent-blue);
    transition: all 0.2s;
}

.activity-item:hover {
    background: #2d3142;
}

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

.activity-agent {
    font-weight: 600;
    font-size: 0.875rem;
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}

.activity-message {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Metrics Panel */
.metrics-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.metric-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.metric-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.model-usage {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.model-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.model-name {
    font-size: 0.875rem;
    font-weight: 500;
}

.model-count {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    color: var(--accent-blue);
}

/* Token Stats */
.token-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.token-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.token-info {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.action-btn {
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px; /* iOS touch target minimum */
    display: flex;
    align-items: center;
}

.action-btn:hover {
    background: var(--border-color);
    transform: translateX(4px);
}

.action-btn:active {
    transform: translateX(2px) scale(0.98);
}

/* Footer */
.footer {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer-note {
    margin-top: 0.5rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
}

/* Loading State */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .header {
        padding: 1rem;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .logo-icon {
        font-size: 1.5rem;
    }

    .header-stats {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }

    .stat-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .stat-label {
        font-size: 0.625rem;
        font-weight: 600;
    }

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

    .status-badge {
        font-size: 0.75rem;
        padding: 0.375rem 0.625rem;
    }

    .section-title {
        font-size: 1rem;
        font-weight: 600;
        margin-bottom: 0.875rem;
    }

    .agents-section {
        margin-bottom: 1.5rem;
    }

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

    .agent-card {
        padding: 1rem;
    }

    .agent-emoji {
        font-size: 1.5rem;
    }

    .agent-details h3 {
        font-size: 1rem;
        font-weight: 600;
    }

    .agent-role {
        font-size: 0.8125rem;
        color: var(--text-secondary);
    }

    .agent-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        margin-top: 1rem;
    }

    .agent-stat {
        background: var(--bg-primary);
        padding: 0.5rem;
        border-radius: 6px;
    }

    .agent-stat-label {
        font-size: 0.625rem;
        font-weight: 600;
        text-transform: uppercase;
    }

    .agent-stat-value {
        font-size: 1.125rem;
        margin-top: 0.125rem;
    }

    .two-column {
        grid-template-columns: 1fr;
    }

    .activity-section {
        padding: 1rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .refresh-btn {
        width: 100%;
        padding: 0.75rem;
    }

    .activity-feed {
        max-height: 400px;
    }

    .activity-item {
        padding: 0.75rem;
    }

    .activity-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .activity-message {
        font-size: 0.8125rem;
    }

    .metric-card {
        padding: 1rem;
    }

    .metric-title {
        font-size: 0.9375rem;
    }

    .quick-actions {
        gap: 0.5rem;
    }

    .action-btn {
        padding: 0.875rem 1rem;
        font-size: 0.8125rem;
    }

    .footer {
        margin-top: 2rem;
        padding-top: 1.5rem;
        font-size: 0.8125rem;
    }

    .footer-note {
        font-size: 0.6875rem;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .container {
        padding: 0.5rem;
    }

    .header {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .logo {
        gap: 0.5rem;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .logo-icon {
        font-size: 1.75rem;
    }

    .header-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
        gap: 1rem;
        margin-top: 1rem;
    }

    .stat-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .stat-item:nth-child(3) {
        grid-column: 1 / -1;
    }

    .stat-label {
        font-size: 0.625rem;
        font-weight: 600;
    }

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

    .status-badge {
        width: 100%;
        text-align: center;
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    .agents-grid {
        gap: 1rem;
    }

    .agent-card {
        padding: 1rem;
    }

    .agent-emoji {
        font-size: 2rem;
    }

    .agent-details h3 {
        font-size: 1.125rem;
    }

    .agent-role {
        font-size: 0.875rem;
    }

    .agent-stats {
        gap: 0.75rem;
        margin-top: 1rem;
    }

    .agent-stat {
        background: var(--bg-primary);
        padding: 0.625rem;
        border-radius: 6px;
    }

    .agent-stat-label {
        font-size: 0.625rem;
        font-weight: 600;
    }

    .agent-stat-value {
        font-size: 1.25rem;
    }

    .activity-section,
    .metric-card {
        padding: 1rem;
    }

    .activity-feed {
        max-height: 350px;
    }

    .activity-item {
        padding: 0.75rem;
    }

    .model-item {
        padding: 0.625rem;
        font-size: 0.8125rem;
    }
}
