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

:root {
    --bg:            #f4f5fb;
    --panel:         #ffffff;
    --border:        rgba(28, 35, 52, 0.08);
    --text:          #1a1f30;
    --muted:         #6b7280;
    --purple:        #6d12c7;
    --purple-dark:   #4b0a90;
    --purple-soft:   #8f3ef4;
    --green:         #10b981;
    --red:           #ef4444;
    --blue:          #2563eb;
    --orange:        #f59e0b;
    --shadow:        0 4px 24px rgba(20, 24, 40, 0.07);
    --shadow-lg:     0 10px 40px rgba(20, 24, 40, 0.11);
    --radius:        20px;
    --radius-sm:     12px;
    --sidebar-w:     260px;
    --topbar-h:      64px;
}

html, body {
    font-family: 'Inter', Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.5;
}

/* ── Shell ────────────────────────────────────────────────────── */
.shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(160deg, #1e0b4b 0%, #3b0d8f 45%, var(--purple-dark) 100%);
    color: #fff;
    padding: 24px 16px 28px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 4px 0 32px rgba(75, 10, 144, 0.22);
    z-index: 100;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 6px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.10);
    text-decoration: none;
    color: #fff;
}

.brand-logo {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: rgba(255,255,255,0.14);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 17px;
    letter-spacing: 1px;
    border: 1px solid rgba(255,255,255,0.18);
    flex-shrink: 0;
}

.brand-text {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.3px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    padding: 13px 14px;
    border-radius: var(--radius-sm);
    transition: background 0.18s, color 0.18s;
    font-weight: 600;
    font-size: 14px;
}

.nav-item:hover { background: rgba(255,255,255,0.09); color: #fff; }

.nav-item.active {
    background: rgba(255,255,255,0.16);
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14);
}

.nav-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 8px 0;
    border-top: 1px solid rgba(255,255,255,0.10);
}

.footer-small { font-size: 11px; opacity: 0.55; text-transform: uppercase; letter-spacing: 0.08em; }
.footer-title { font-size: 14px; font-weight: 700; margin-top: 4px; }
.footer-version { font-size: 11px; opacity: 0.5; margin-top: 3px; }

/* ── Mobile topbar ────────────────────────────────────────────── */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: linear-gradient(90deg, #1e0b4b 0%, #3b0d8f 100%);
    color: #fff;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 200;
    box-shadow: 0 2px 16px rgba(75,10,144,0.25);
}

.mobile-topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
    font-weight: 800;
    font-size: 17px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.hamburger {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.18);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    padding: 0;
}

.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: all 0.22s;
}

.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Overlay ──────────────────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.28s;
}

.sidebar-overlay.visible { opacity: 1; }

/* ── Main ─────────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    padding: 28px 28px 48px;
    min-width: 0;
    margin-left: var(--sidebar-w);
}

/* ── Topbar ───────────────────────────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 26px;
}

.eyebrow {
    color: var(--purple);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    margin-bottom: 4px;
}

.page-title {
    font-size: 30px;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.3px;
}

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

.topbar-chip {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 10px 16px;
    font-weight: 700;
    color: var(--muted);
    font-size: 13px;
    box-shadow: var(--shadow);
    white-space: nowrap;
}

.topbar-status {
    display: flex;
    align-items: center;
    gap: 7px;
    border-radius: 999px;
    padding: 10px 16px;
    font-weight: 700;
    font-size: 13px;
    box-shadow: var(--shadow);
    white-space: nowrap;
}

.topbar-online { background: rgba(16,185,129,0.12); color: #047857; border: 1px solid rgba(16,185,129,0.25); }
.topbar-offline { background: rgba(239,68,68,0.10); color: #b91c1c; border: 1px solid rgba(239,68,68,0.22); }

/* ── Pulse dots ───────────────────────────────────────────────── */
.pulse-dot {
    width: 8px; height: 8px; border-radius: 50%;
    display: inline-block; flex-shrink: 0;
    animation: pulse 2s infinite;
}
.pulse-green { background: var(--green); box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
.pulse-red   { background: var(--red);   box-shadow: 0 0 0 0 rgba(239,68,68,0.4); animation: none; }

@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
    70%  { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
    100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

/* ── Hero panel ───────────────────────────────────────────────── */
.hero-panel {
    background:
        radial-gradient(circle at top right, rgba(143,62,244,0.12), transparent 40%),
        linear-gradient(180deg, #ffffff 0%, #f9f8ff 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    display: flex;
    justify-content: space-between;
    gap: 28px;
    align-items: center;
    margin-bottom: 22px;
    box-shadow: var(--shadow-lg);
}

.hero-copy h2 { margin: 6px 0 10px; font-size: 24px; font-weight: 800; letter-spacing: -0.2px; }
.hero-copy p { color: var(--muted); max-width: 700px; line-height: 1.65; font-size: 14px; }
.hero-kicker { color: var(--purple); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; }

.hero-badge-group { display: flex; flex-direction: column; gap: 8px; min-width: 220px; }

.mini-pill {
    display: flex; align-items: center; gap: 8px;
    background: rgba(109,18,199,0.07);
    color: var(--purple-dark);
    border: 1px solid rgba(109,18,199,0.13);
    border-radius: 999px;
    padding: 11px 14px;
    font-weight: 700; font-size: 13px;
}

.mini-pill.online { background: rgba(16,185,129,0.10); color: #047857; border-color: rgba(16,185,129,0.22); }
.mini-pill.offline { background: rgba(239,68,68,0.09); color: #b91c1c; border-color: rgba(239,68,68,0.20); }

/* ── Cards grid ───────────────────────────────────────────────── */
.cards-grid { display: grid; gap: 18px; margin-bottom: 18px; }
.cards-grid.four { grid-template-columns: repeat(4, minmax(0,1fr)); }
.cards-grid.two  { grid-template-columns: repeat(2, minmax(0,1fr)); }

/* ── Info card ────────────────────────────────────────────────── */
.info-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.info-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--purple) 0%, var(--purple-soft) 100%);
    opacity: 0.5;
    border-radius: var(--radius) var(--radius) 0 0;
}

.card-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.card-icon-blue   { background: rgba(37,99,235,0.10);  color: var(--blue); }
.card-icon-green  { background: rgba(16,185,129,0.10); color: var(--green); }
.card-icon-purple { background: rgba(109,18,199,0.10); color: var(--purple); }
.card-icon-orange { background: rgba(245,158,11,0.10); color: var(--orange); }

.card-label { color: var(--muted); font-size: 13px; margin-bottom: 8px; font-weight: 600; }
.card-value { font-size: 28px; font-weight: 800; line-height: 1.1; }
.card-value.compact { font-size: 18px; }
.card-value.value-green { color: #047857; }
.card-value.value-red   { color: #b91c1c; }
.card-sub { margin-top: 8px; color: var(--muted); font-size: 12px; }
.card-sub.ok  { color: #047857; }
.card-sub.bad { color: #b91c1c; }

/* ── Panel card ───────────────────────────────────────────────── */
.panel-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 0;
}

.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.panel-header h3 { margin: 0; font-size: 18px; font-weight: 800; }

.panel-chip { background: rgba(109,18,199,0.08); color: var(--purple-dark); border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.debug-chip { background: rgba(30,30,60,0.07); color: var(--muted); }

/* ── Progress ─────────────────────────────────────────────────── */
.progress-block { margin-bottom: 20px; }
.progress-track { width: 100%; height: 14px; background: #ecedf5; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--purple) 0%, var(--purple-soft) 100%); border-radius: 999px; transition: width 0.6s ease; }
.progress-caption { margin-top: 8px; color: var(--muted); font-size: 13px; }

/* ── Route steps ──────────────────────────────────────────────── */
.route-steps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.route-step { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border-radius: var(--radius-sm); background: #f4f5fb; border: 1px solid #e8eaf2; }
.route-step.done { background: rgba(16,185,129,0.11); border-color: rgba(16,185,129,0.22); }
.route-step.current { background: rgba(37,99,235,0.10); border-color: rgba(37,99,235,0.20); }
.route-dot { width: 10px; height: 10px; border-radius: 50%; background: #c5ccd9; }
.route-step.done    .route-dot { background: var(--green); }
.route-step.current .route-dot { background: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.18); }
.route-text { font-size: 12px; font-weight: 700; color: var(--text); }

/* ── Status list ──────────────────────────────────────────────── */
.status-list { display: grid; gap: 0; }
.status-row, .summary-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid #eef1f6; font-size: 14px; }
.status-row:last-child, .summary-line:last-child { border-bottom: none; }
.status-row span, .summary-line span { color: var(--muted); }

/* ── Badges ───────────────────────────────────────────────────── */
.badge-ok      { color: #047857; }
.badge-warn    { color: #b45309; }
.badge-danger  { color: #b91c1c; }
.badge-neutral { color: var(--muted); }

/* ── Buttons ──────────────────────────────────────────────────── */
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.button-row.full { grid-column: 1 / -1; }

.btn {
    appearance: none; border: none;
    border-radius: var(--radius-sm);
    padding: 13px 22px;
    font-size: 14px; font-weight: 700;
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.14s ease;
    font-family: inherit;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.13); }
.btn:active { transform: translateY(0); }
.btn.primary { background: linear-gradient(90deg, var(--purple) 0%, var(--purple-soft) 100%); color: white; }
.btn.danger  { background: linear-gradient(90deg, #c0203d 0%, var(--red) 100%); color: white; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.single { grid-template-columns: 1fr; }

label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 13px; color: #2a3045; }
label span { font-weight: 600; }

input, select { border: 1px solid #d6dae8; border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; outline: none; background: white; font-family: inherit; color: var(--text); transition: border-color 0.18s, box-shadow 0.18s; }
input:focus { border-color: var(--purple-soft); box-shadow: 0 0 0 4px rgba(143,62,244,0.11); }

code { background: rgba(109,18,199,0.07); color: var(--purple-dark); border-radius: 6px; padding: 2px 7px; font-size: 13px; }

/* ── Route card / Mission box ─────────────────────────────────── */
.route-card, .mission-summary-box { margin-top: 20px; padding: 18px; border-radius: var(--radius-sm); background: #f7f6ff; border: 1px solid rgba(109,18,199,0.10); }
.route-title { font-size: 14px; font-weight: 800; margin-bottom: 6px; color: var(--purple-dark); }
.route-description { color: var(--muted); font-size: 13px; line-height: 1.65; margin-bottom: 16px; }

/* ── Pre / code blocks ────────────────────────────────────────── */
pre { background: #0e1521; color: #ccd6e8; padding: 16px; border-radius: var(--radius-sm); overflow-x: auto; white-space: pre-wrap; word-break: break-word; font-size: 12px; line-height: 1.6; margin: 0; max-height: 400px; overflow-y: auto; font-family: 'Menlo', 'Monaco', 'Consolas', monospace; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 1280px) {
    .cards-grid.four { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 1024px) {
    .cards-grid.two  { grid-template-columns: 1fr; }
    .hero-panel { flex-direction: column; align-items: flex-start; }
    .hero-badge-group { width: 100%; min-width: unset; flex-direction: row; flex-wrap: wrap; }
}

@media (max-width: 900px) {
    .mobile-topbar { display: flex; }
    .sidebar {
        transform: translateX(-100%);
        padding-top: 80px;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay { display: block; }
    .main-content {
        margin-left: 0;
        padding: 16px;
        padding-top: calc(var(--topbar-h) + 16px);
    }
    .route-steps { grid-template-columns: repeat(3, minmax(0,1fr)); }
    .topbar { margin-bottom: 12px; }
    .topbar .eyebrow { display: none; }
    .topbar .page-title { font-size: 22px; }
}

@media (max-width: 680px) {
    .cards-grid.four { grid-template-columns: 1fr; }
    .cards-grid.two  { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .route-steps { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .topbar { flex-direction: column; align-items: flex-start; }
    .page-title { font-size: 24px; }
    .hero-copy h2 { font-size: 20px; }
    .hero-panel { padding: 20px; }
}