/* ===== ROOT TOKENS ===== */
:root {
    --bg-deep: hsl(225, 15%, 6%);
    --bg-card: hsl(225, 14%, 10%);
    --bg-card-hover: hsl(225, 14%, 13%);
    --border-card: hsl(225, 14%, 18%);
    --border-glow: hsl(38, 90%, 55%);

    --text-primary: hsl(220, 10%, 92%);
    --text-secondary: hsl(220, 8%, 58%);
    --text-muted: hsl(220, 6%, 40%);

    --accent-gold: hsl(38, 90%, 55%);
    --accent-gold-dim: hsla(38, 90%, 55%, 0.15);
    --accent-green: hsl(145, 65%, 50%);
    --accent-green-dim: hsla(145, 65%, 50%, 0.15);
    --accent-red: hsl(0, 75%, 55%);
    --accent-red-dim: hsla(0, 75%, 55%, 0.15);
    --accent-blue: hsl(210, 80%, 60%);
    --accent-blue-dim: hsla(210, 80%, 60%, 0.15);
    --accent-orange: hsl(30, 85%, 55%);
    --accent-purple: hsl(270, 60%, 60%);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius: 12px;
    --radius-sm: 6px;
    --shadow-card: 0 4px 24px hsla(0, 0%, 0%, 0.4);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
    font-family: var(--font-sans);
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* ===== PARTICLES ===== */
#particles {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.3;
}

/* ===== TOPBAR ===== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: hsla(225, 15%, 8%, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-card);
}
.topbar-left { display: flex; align-items: center; gap: 0.75rem; }
.lamp { font-size: 1.8rem; animation: lamp-glow 3s ease-in-out infinite; }
@keyframes lamp-glow {
    0%, 100% { filter: drop-shadow(0 0 8px var(--accent-gold)); }
    50% { filter: drop-shadow(0 0 20px var(--accent-gold)); }
}
.logo { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.5px; }
.logo-sub { font-weight: 400; color: var(--text-secondary); font-size: 0.85rem; margin-left: 0.5rem; }
.topbar-right { display: flex; align-items: center; gap: 1rem; font-family: var(--font-mono); font-size: 0.8rem; }
.live-pulse {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
    animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}
.status-text { color: var(--accent-gold); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }
.clock { color: var(--text-secondary); }

/* ===== DASHBOARD GRID ===== */
.dashboard {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1rem 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
    transition: border-color var(--transition), transform var(--transition);
}
.card:hover {
    border-color: hsla(38, 90%, 55%, 0.3);
    transform: translateY(-2px);
}
.card-wide { grid-column: 1 / -1; }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid hsla(225, 14%, 18%, 0.5);
}
.card-header h2 { font-size: 1rem; font-weight: 700; }

/* ===== BADGES ===== */
.badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: var(--font-mono);
}
.badge-ok { background: var(--accent-green-dim); color: var(--accent-green); }
.badge-critical { background: var(--accent-red-dim); color: var(--accent-red); animation: badge-blink 2s ease-in-out infinite; }
.badge-info { background: var(--accent-blue-dim); color: var(--accent-blue); }
.badge-warning { background: hsla(30, 85%, 55%, 0.15); color: var(--accent-orange); }
@keyframes badge-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ===== FINANCE CARD ===== */
.finance-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.finance-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem;
    background: hsla(225, 14%, 14%, 0.6);
    border-radius: var(--radius-sm);
    border: 1px solid hsla(225, 14%, 20%, 0.5);
}
.finance-label { font-size: 0.7rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.finance-value { font-family: var(--font-mono); font-size: 1.3rem; font-weight: 700; }
.finance-value.critical { color: var(--accent-red); }
.finance-value.target { color: var(--accent-gold); }

.progress-bar-container { margin-top: 0.5rem; }
.progress-label { font-size: 0.7rem; color: var(--text-secondary); margin-bottom: 0.35rem; }
.progress-bar {
    height: 8px;
    background: hsla(225, 14%, 20%, 0.8);
    border-radius: 100px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-red), var(--accent-orange));
    border-radius: 100px;
    transition: width 1s ease;
    min-width: 4px;
}
.progress-text { font-size: 0.65rem; color: var(--text-muted); font-family: var(--font-mono); margin-top: 0.25rem; display: block; }

/* ===== SERVER GAUGES ===== */
.server-grid {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 1rem;
}
.gauge-container { position: relative; width: 100px; height: 100px; }
.gauge { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge-bg {
    fill: none;
    stroke: hsla(225, 14%, 20%, 0.8);
    stroke-width: 8;
}
.gauge-fill {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 314;
    transition: stroke-dashoffset 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.gauge-cpu { stroke: var(--accent-green); stroke-dashoffset: 289; }
.gauge-ram { stroke: var(--accent-blue); stroke-dashoffset: 166; }
.gauge-disk { stroke: var(--accent-gold); stroke-dashoffset: 239; }

.gauge-label {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
}
.gauge-label strong { display: block; font-size: 1rem; color: var(--text-primary); font-family: var(--font-mono); }

.server-meta {
    display: flex;
    justify-content: space-around;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    padding-top: 0.5rem;
    border-top: 1px solid hsla(225, 14%, 18%, 0.3);
}

/* ===== PIPELINE TABLE ===== */
.pipeline-table-wrap { overflow-x: auto; }
.pipeline-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.pipeline-table th {
    text-align: left;
    color: var(--text-muted);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-card);
}
.pipeline-table td {
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid hsla(225, 14%, 18%, 0.3);
    vertical-align: middle;
}
.pipeline-table tr:hover td { background: hsla(225, 14%, 14%, 0.6); }
.pipeline-table .status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 0.5rem;
}
.status-green { background: var(--accent-green); box-shadow: 0 0 6px var(--accent-green); }
.status-yellow { background: var(--accent-orange); box-shadow: 0 0 6px var(--accent-orange); }
.status-red { background: var(--accent-red); box-shadow: 0 0 6px var(--accent-red); }

/* ===== ACCOUNTS ===== */
.account-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
    max-height: 260px;
    overflow-y: auto;
}
.account-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: hsla(225, 14%, 14%, 0.6);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    border: 1px solid transparent;
    transition: border-color var(--transition);
}
.account-item:hover { border-color: var(--accent-gold-dim); }
.account-item .acct-icon { font-size: 1.1rem; }
.account-item .acct-name { font-weight: 600; flex: 1; }
.account-item .acct-project { color: var(--text-secondary); font-size: 0.7rem; }
.account-item .acct-status {
    width: 8px; height: 8px; border-radius: 50%;
}

.account-summary {
    display: flex;
    gap: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid hsla(225, 14%, 18%, 0.3);
}
.account-stat { text-align: center; flex: 1; }
.stat-val { display: block; font-family: var(--font-mono); font-size: 1.5rem; font-weight: 800; color: var(--accent-gold); }
.stat-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; }

/* ===== TOOLS ===== */
.tool-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.tool-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: hsla(225, 14%, 14%, 0.6);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    border-left: 3px solid transparent;
    transition: all var(--transition);
}
.tool-item:hover { background: var(--bg-card-hover); }
.tool-item.tool-ready { border-left-color: var(--accent-green); }
.tool-item.tool-pending { border-left-color: var(--accent-orange); }
.tool-item.tool-down { border-left-color: var(--accent-red); }
.tool-name { font-weight: 600; flex: 1; }
.tool-version { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted); }
.tool-status { font-size: 0.7rem; font-family: var(--font-mono); }
.tool-status.green { color: var(--accent-green); }
.tool-status.yellow { color: var(--accent-orange); }
.tool-status.red { color: var(--accent-red); }

/* ===== AGENTS ===== */
.agent-hierarchy {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 300px;
    overflow-y: auto;
}
.agent-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    transition: background var(--transition);
}
.agent-item:hover { background: hsla(225, 14%, 14%, 0.6); }
.agent-item.agent-master { background: var(--accent-gold-dim); border: 1px solid hsla(38, 90%, 55%, 0.3); }
.agent-item.agent-core { background: hsla(210, 80%, 60%, 0.08); }
.agent-icon { font-size: 1.1rem; }
.agent-name { font-weight: 600; }
.agent-role { color: var(--text-secondary); font-size: 0.7rem; margin-left: auto; }

/* ===== DOCKER ===== */
.docker-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.4rem;
    max-height: 300px;
    overflow-y: auto;
}
.docker-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: hsla(225, 14%, 14%, 0.6);
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-family: var(--font-mono);
    border-left: 2px solid var(--accent-green);
}
.docker-item .docker-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.docker-item .docker-time { color: var(--text-muted); font-size: 0.6rem; }

/* ===== ACTIVITY FEED ===== */
.activity-feed {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.activity-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.78rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.activity-item:hover { background: hsla(225, 14%, 14%, 0.6); }
.activity-time { color: var(--text-muted); font-family: var(--font-mono); font-size: 0.7rem; white-space: nowrap; min-width: 70px; }
.activity-type { font-weight: 600; min-width: 70px; }
.activity-type.type-decision { color: var(--accent-gold); }
.activity-type.type-update { color: var(--accent-blue); }
.activity-type.type-issue { color: var(--accent-red); }
.activity-type.type-created { color: var(--accent-green); }
.activity-msg { color: var(--text-secondary); flex: 1; }

/* ===== DEPARTMENTS ===== */
.dept-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.6rem;
}
.dept-item {
    padding: 0.75rem;
    background: hsla(225, 14%, 14%, 0.6);
    border-radius: var(--radius-sm);
    border: 1px solid hsla(225, 14%, 20%, 0.5);
    text-align: center;
    transition: all var(--transition);
}
.dept-item:hover { border-color: var(--accent-gold-dim); transform: translateY(-2px); }
.dept-icon { font-size: 1.5rem; display: block; margin-bottom: 0.35rem; }
.dept-name { font-weight: 600; font-size: 0.8rem; }
.dept-status { font-size: 0.65rem; color: var(--text-muted); font-family: var(--font-mono); margin-top: 0.2rem; }

/* ===== FOOTER ===== */
.footer {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    font-size: 0.65rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-card);
    font-family: var(--font-mono);
    position: relative;
    z-index: 1;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: hsla(225, 14%, 30%, 0.5); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: hsla(225, 14%, 40%, 0.7); }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .dashboard { grid-template-columns: 1fr; }
    .finance-grid { grid-template-columns: repeat(2, 1fr); }
    .server-grid { flex-wrap: wrap; gap: 1rem; }
}
@media (max-width: 500px) {
    .topbar { flex-direction: column; gap: 0.5rem; }
    .finance-grid { grid-template-columns: 1fr; }
}
