:root {
    --bg-main: #0a0e17;
    --bg-surface: #111827;
    --bg-surface-elevated: #162032;
    --bg-card: #111827;
    --border-color: #1f293d;
    --border-highlight: #374151;
    
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --nordic-gold: #eab308;
    --nordic-cyan: #06b6d4;
    --nordic-blue: #3b82f6;
    
    --status-running: #10b981;
    --status-stopped: #ef4444;
    --status-starting: #f59e0b;
    --status-stopping: #f97316;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Container */
.app-container {
    max-width: 1300px;
    width: 100%;
    margin: 0 auto;
    padding: 1.75rem 1.5rem;
}

/* Header */
header.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1.25rem;
    margin-bottom: 1.75rem;
    border-bottom: 1px solid var(--border-color);
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-icon {
    font-size: 1.85rem;
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.15), rgba(6, 182, 212, 0.15));
    border: 1px solid rgba(234, 179, 8, 0.3);
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.brand-titles h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

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

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-surface);
    padding: 0.3rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--text-primary);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-highlight);
    box-shadow: var(--shadow-sm);
}

/* Tab Panels */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

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

/* Grid Layouts */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.grid-3col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
    .grid-2col, .grid-3col {
        grid-template-columns: 1fr;
    }
}

/* Cards */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    position: relative;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Status Badges */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(31, 41, 61, 0.8);
    border: 1px solid var(--border-color);
}

.dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--text-muted);
}

.dot.Running {
    background: var(--status-running);
    box-shadow: 0 0 10px var(--status-running);
}

.dot.Stopped {
    background: var(--status-stopped);
}

.dot.Starting, .dot.Stopping {
    background: var(--status-starting);
    animation: pulse 1.2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

/* Metric Display */
.metric-box {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

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

.metric-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

/* Action Buttons */
.btn-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none;
}

.btn:disabled, .btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: var(--nordic-blue);
    color: #fff;
}
.btn-primary:hover {
    background: #2563eb;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
}

.btn-success {
    background: #059669;
    color: #fff;
}
.btn-success:hover {
    background: #10b981;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}
.btn-danger:hover {
    background: #ef4444;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
}

.btn-warning {
    background: #d97706;
    color: #fff;
}
.btn-warning:hover {
    background: #f59e0b;
}

.btn-secondary {
    background: var(--bg-surface-elevated);
    border-color: var(--border-color);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: #1e293b;
    border-color: var(--border-highlight);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

/* HTMX Request Indicator */
.htmx-indicator {
    display: none;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--nordic-gold);
    font-weight: 500;
}

.htmx-indicator.htmx-request,
form.htmx-request .htmx-indicator {
    display: inline-flex !important;
}

.card-footer-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 44px;
    flex-wrap: wrap;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.metric-value, .status-pill, table.data-table td {
    font-variant-numeric: tabular-nums;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(234, 179, 8, 0.3);
    border-top-color: var(--nordic-gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

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

.form-control {
    width: 100%;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.65rem 0.9rem;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--nordic-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
}

.form-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--nordic-blue);
    cursor: pointer;
}

/* Terminal & Console */
.terminal-wrapper {
    background: #050811;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.terminal-header {
    background: #0c1220;
    padding: 0.6rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.terminal-title {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.terminal-body {
    padding: 1rem;
    height: 480px;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: #cbd5e1;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Custom Scrollbars */
.terminal-body::-webkit-scrollbar {
    width: 8px;
}
.terminal-body::-webkit-scrollbar-track {
    background: #050811;
}
.terminal-body::-webkit-scrollbar-thumb {
    background: #1f293d;
    border-radius: 4px;
}
.terminal-body::-webkit-scrollbar-thumb:hover {
    background: #374151;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}

table.data-table th {
    background: var(--bg-surface-elevated);
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

table.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

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

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

/* Player list tag pills */
.player-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(6, 182, 212, 0.12);
    border: 1px solid rgba(6, 182, 212, 0.3);
    color: #67e8f9;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 500;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-highlight);
    color: var(--text-primary);
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    animation: slideIn 0.25s ease forwards;
}

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