:root {
    --bg: #060912;
    --bg-panel: #0d1424;
    --bg-panel-2: #111a2e;
    --border: #1e2a44;
    --text: #dbe4ff;
    --text-dim: #7c8bb0;
    --cyan: #35e8e0;
    --purple: #9d6bff;
    --pink: #ff5fb0;
    --green: #3ddc97;
    --red: #ff5c6c;
    --amber: #ffb347;
    --shadow-glow: 0 0 24px rgba(53, 232, 224, 0.15);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', 'Inter', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
}

.bg-grid, .login-bg-grid {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-image:
        linear-gradient(rgba(53, 232, 224, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(53, 232, 224, 0.06) 1px, transparent 1px);
    background-size: 42px 42px;
    -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 75%);
    mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 75%);
    pointer-events: none;
}

/* ---------- Login ---------- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    position: relative;
    z-index: 1;
    width: 360px;
    background: linear-gradient(180deg, rgba(17, 26, 46, 0.9), rgba(13, 20, 36, 0.9));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: var(--shadow-glow), 0 20px 60px rgba(0,0,0,0.5);
    backdrop-filter: blur(6px);
}

.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.login-logo h1 { font-size: 22px; letter-spacing: 2px; margin: 0; }
.login-logo h1 span { color: var(--cyan); }
.login-sub { color: var(--text-dim); font-size: 13px; margin: 4px 0 24px; }

.logo-pulse {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 12px 2px var(--cyan);
    animation: pulseDot 1.8s ease-in-out infinite;
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.7); }
}

.login-card form { display: flex; flex-direction: column; gap: 16px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-dim); }
.login-card input {
    background: #0a1120;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 11px 12px;
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.login-card input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(53,232,224,0.12); }

.login-card button {
    margin-top: 8px;
    background: linear-gradient(90deg, var(--cyan), var(--purple));
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-weight: 600;
    font-size: 14px;
    color: #051018;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
.login-card button:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(157,107,255,0.35); }

.login-error {
    background: rgba(255, 92, 108, 0.12);
    border: 1px solid rgba(255, 92, 108, 0.4);
    color: var(--red);
    font-size: 13px;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 16px;
}

/* ---------- Topbar ---------- */
.topbar {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px;
    border-bottom: 1px solid var(--border);
    background: rgba(9, 13, 24, 0.7);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 18px; letter-spacing: 2px; margin: 0; }
.brand h1 span { color: var(--cyan); }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.user-chip { font-size: 13px; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.3; }
.user-chip small { color: var(--text-dim); font-size: 11px; }
.logout-btn {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 8px;
    transition: border-color 0.15s, color 0.15s;
}
.logout-btn:hover { color: var(--cyan); border-color: var(--cyan); }

/* ---------- Dashboard layout ---------- */
.dashboard {
    position: relative;
    z-index: 1;
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px 32px 60px;
}

.hero-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: linear-gradient(120deg, rgba(53,232,224,0.08), rgba(157,107,255,0.08));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px 28px;
    margin-bottom: 22px;
}
.hero-eyebrow { text-transform: uppercase; letter-spacing: 2px; font-size: 11px; color: var(--cyan); margin: 0 0 6px; }
.hero-text h2 { margin: 0; font-size: 20px; font-weight: 600; }
.hero-text h2 span { color: var(--cyan); font-weight: 700; }

.hero-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); white-space: nowrap; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--amber); }
.status-dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-dot.pulse { animation: pulseDot 1.4s ease-in-out infinite; }

.controls-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 18px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px 20px;
    margin-bottom: 22px;
}
.refresh-btn {
    display: flex; align-items: center; gap: 8px;
    background: rgba(53,232,224,0.1);
    border: 1px solid rgba(53,232,224,0.4);
    color: var(--cyan);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
    height: fit-content;
}
.refresh-btn:hover:not(:disabled) { background: rgba(53,232,224,0.2); }
.refresh-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.last-updated { margin-left: auto; font-size: 12px; color: var(--text-dim); align-self: center; }
.last-updated span { color: var(--text); }

.offline-banner {
    background: rgba(255, 92, 108, 0.1);
    border: 1px solid rgba(255, 92, 108, 0.4);
    color: var(--red);
    font-size: 13px;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 22px;
}
.offline-banner strong { color: var(--text); }

.totals-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 14px;
    margin-bottom: 26px;
}
.total-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.total-card[data-stage="queue"] { border-top: 2px solid var(--purple); }
.total-card[data-stage="processing"] { border-top: 2px solid var(--cyan); }
.total-card[data-stage="sent"] { border-top: 2px solid var(--green); }
.total-card[data-stage="capacity"] { border-top: 2px solid var(--amber); }
.total-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); }
.total-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.total-sub { font-size: 12px; color: var(--text-dim); }
.total-sub span { color: var(--text); font-weight: 600; }

.activity-row {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 20px;
}

/* ---------- Pipeline panel ---------- */
.pipeline-panel {
    background: linear-gradient(180deg, var(--bg-panel), var(--bg-panel-2));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px 28px;
    position: relative;
    overflow: hidden;
    flex: 0 1 380px;
}
.pipeline-panel::before {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(600px circle at 0% 0%, rgba(53,232,224,0.06), transparent 40%);
    pointer-events: none;
}

.pipeline { display: flex; align-items: center; }
.pipeline-node { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 78px; flex-shrink: 0; }
.node-icon {
    width: 44px; height: 44px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: #0a1120;
    border: 1px solid var(--border);
    color: var(--text-dim);
    transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.pipeline-node.active .node-icon { color: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 14px rgba(53,232,224,0.35); }
.node-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); }
.node-count { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }

.pipeline-track { position: relative; flex: 1; height: 4px; margin: 0 -6px; }
.track-line { position: absolute; inset: 0; border-radius: 2px; background: var(--border); }
.pipeline-track.flowing .track-line { background: linear-gradient(90deg, rgba(53,232,224,0.15), rgba(53,232,224,0.4)); }

.particle {
    position: absolute;
    top: 50%;
    width: 7px; height: 7px;
    margin-top: -3.5px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 8px var(--cyan);
    opacity: 0;
    left: -8px;
}
.pipeline-track.flowing .particle { opacity: 1; animation: flowRight 1.8s linear infinite; }
.pipeline-track.flowing .particle.p2 { animation-delay: 0.6s; }
.pipeline-track.flowing .particle.p3 { animation-delay: 1.2s; }
.pipeline-track[data-track="b"].flowing .particle { background: var(--green); box-shadow: 0 0 8px var(--green); }

@keyframes flowRight {
    0% { left: -8px; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { left: 100%; opacity: 0; }
}

.eta-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px 28px;
    flex: 1 1 320px;
}
.eta-heading { margin: 0 0 14px; font-size: 14px; font-weight: 600; }
.eta-loading { margin: 0; font-size: 13px; color: var(--text-dim); }
.eta-partial-note {
    margin: -6px 0 16px;
    font-size: 12px;
    color: var(--amber);
    background: rgba(255,179,71,0.1);
    border: 1px solid rgba(255,179,71,0.35);
    border-radius: 8px;
    padding: 8px 12px;
}

.eta-timeline {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.eta-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: #0a1120;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 18px;
    min-width: 100px;
}
.eta-count { font-size: 20px; font-weight: 700; color: var(--amber); font-variant-numeric: tabular-nums; }
.eta-remaining { font-size: 12px; font-weight: 600; color: var(--cyan); }

@media (max-width: 720px) {
    .topbar { padding: 14px 18px; }
    .dashboard { padding: 20px 16px 40px; }
    .hero-banner { flex-direction: column; align-items: flex-start; }
    .totals-row { grid-template-columns: 1fr; }
    .last-updated { margin-left: 0; }
    .pipeline-node { width: 60px; }
    .pipeline-panel { padding: 22px 16px; flex-basis: 100%; }
    .eta-panel { padding: 18px 16px; flex-basis: 100%; }
}
