/* ===========================
   CSS Variables
   =========================== */
:root {
    --bg-primary:    #0d1117;
    --bg-secondary:  #161b22;
    --bg-tertiary:   #21262d;
    --border:        #30363d;
    --border-hover:  #484f58;
    --text-primary:  #f0f6fc;
    --text-secondary:#c9d1d9;
    --text-muted:    #8b949e;
    --text-faint:    #6e7681;
    --blue:          #58a6ff;
    --blue-dim:      rgba(88,166,255,0.12);
    --green:         #3fb950;
    --green-dim:     rgba(63,185,80,0.12);
    --orange:        #d29922;
    --orange-dim:    rgba(210,153,34,0.12);
    --purple:        #bc8cff;
    --purple-dim:    rgba(188,140,255,0.12);
    --gray-dim:      rgba(110,118,129,0.15);
    --sidebar-w:     240px;
    --topbar-h:      56px;
    --radius-sm:     6px;
    --radius-md:     10px;
    --radius-lg:     14px;
    --transition:    0.18s ease;
}

/* ===========================
   Reset
   =========================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; }

/* ===========================
   Base
   =========================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

/* ===========================
   Sidebar
   =========================== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 200;
    transition: transform var(--transition);
}

/* Logo */
.sidebar-logo {
    padding: 18px 20px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.logo-wordmark {
    font-size: 18px;
    font-weight: 700;
    font-family: "SFMono-Regular", Consolas, monospace;
    letter-spacing: -0.5px;
}
.logo-wordmark em { color: var(--blue); font-style: normal; }
.logo-tagline {
    display: block;
    font-size: 10px;
    color: var(--text-faint);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.nav-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
    padding: 12px 20px 4px;
    font-weight: 600;
}

/* Nav group */
.nav-group { }

.nav-group-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 8px 16px;
    margin: 1px 6px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition);
    border: none;
    background: none;
    width: calc(100% - 12px);
    text-align: left;
    font-size: 13px;
    font-weight: 500;
}
.nav-group-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.nav-group-btn.active {
    background: var(--blue-dim);
    color: var(--blue);
}

.nav-icon { width: 16px; height: 16px; flex-shrink: 0; }
.nav-icon svg { display: block; width: 100%; height: 100%; }
.nav-text { flex: 1; }
.nav-chevron {
    width: 14px; height: 14px; flex-shrink: 0;
    transition: transform var(--transition);
    opacity: 0.45;
}
.nav-chevron svg { display: block; width: 100%; height: 100%; }
.nav-group.open .nav-chevron { transform: rotate(90deg); opacity: 0.8; }

/* Sub nav */
.nav-sub {
    display: none;
    padding: 2px 0;
}
.nav-group.open .nav-sub { display: block; }

.nav-sub-link {
    display: block;
    padding: 6px 14px 6px 42px;
    margin: 1px 6px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-faint);
    transition: all var(--transition);
}
.nav-sub-link:hover { background: var(--bg-tertiary); color: var(--text-secondary); }
.nav-sub-link.active { color: var(--blue); background: var(--blue-dim); }

/* Sidebar footer */
.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.ver-badge {
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 10px;
    color: var(--text-faint);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 8px;
}

/* ===========================
   Main Wrapper
   =========================== */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===========================
   Topbar
   =========================== */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}
.sidebar-toggle:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.sidebar-toggle svg { display: block; width: 18px; height: 18px; }

.topbar-breadcrumb {
    flex: 1;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}
.topbar-breadcrumb .sep { color: var(--border-hover); }
.topbar-breadcrumb .current { color: var(--text-primary); font-weight: 500; }

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

.platform-tag {
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 11px;
    color: var(--text-faint);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 8px;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}
.status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--green);
    animation: blink 2.4s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.35} }

/* ===========================
   Sidebar Overlay (mobile)
   =========================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 150;
}

/* ===========================
   Page Content
   =========================== */
.page-content {
    flex: 1;
    padding: 28px 28px 40px;
}

.page-header {
    margin-bottom: 28px;
}
.page-header-inner {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}
.page-section-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.page-section-icon svg { display: block; width: 24px; height: 24px; }
.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.25;
}
.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===========================
   Card Grid
   =========================== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

/* Feature Card */
.feature-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 22px 20px 20px;
    display: block;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}
.feature-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    opacity: 0;
    transition: opacity var(--transition);
}
.feature-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.feature-card:hover::before { opacity: 1; }

/* Card icon */
.card-icon {
    width: 40px; height: 40px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.card-icon svg { display: block; width: 20px; height: 20px; }

/* Card content */
.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.card-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.65;
}
.card-footer {
    margin-top: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-tag {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 10px;
}
.card-arrow {
    color: var(--text-faint);
    font-size: 16px;
    line-height: 1;
    transition: transform var(--transition);
}
.feature-card:hover .card-arrow { transform: translateX(3px); color: var(--text-muted); }

/* Color themes */
.c-blue  { background: var(--blue-dim);   color: var(--blue); }
.c-blue .feature-card::before  { background: var(--blue); }
.c-green { background: var(--green-dim);  color: var(--green); }
.c-green .feature-card::before { background: var(--green); }
.c-orange{ background: var(--orange-dim); color: var(--orange); }
.c-orange .feature-card::before{ background: var(--orange); }
.c-purple{ background: var(--purple-dim); color: var(--purple); }
.c-purple .feature-card::before{ background: var(--purple); }
.c-gray  { background: var(--gray-dim);   color: var(--text-muted); }
.c-gray .feature-card::before  { background: var(--text-muted); }

/* ===========================
   Dashboard Home (Overview)
   =========================== */
.overview-sections {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 36px;
}
.overview-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 22px 20px;
    display: block;
    transition: all var(--transition);
}
.overview-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.ov-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}
.ov-icon svg { display: block; width: 22px; height: 22px; }
.ov-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
}
.ov-count {
    font-size: 12px;
    color: var(--text-muted);
}

.section-divider {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* Platform info bar */
.platform-info-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.pib-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}
.pib-dot { width: 6px; height: 6px; border-radius: 50%; }
.pib-sep { color: var(--border-hover); padding: 0 4px; }

/* ===========================
   Placeholder Page
   =========================== */
.placeholder-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 420px;
    text-align: center;
    gap: 0;
}
.ph-icon {
    width: 64px; height: 64px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}
.ph-icon svg { display: block; width: 30px; height: 30px; }
.ph-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.ph-sub {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 380px;
    line-height: 1.65;
    margin-bottom: 24px;
}
.ph-badge {
    display: inline-block;
    font-size: 11px;
    color: var(--blue);
    background: var(--blue-dim);
    border: 1px solid rgba(88,166,255,0.25);
    border-radius: 20px;
    padding: 4px 14px;
    margin-bottom: 20px;
    letter-spacing: 0.04em;
}
.ph-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--blue);
    border-radius: var(--radius-sm);
    padding: 6px 14px;
    border: 1px solid rgba(88,166,255,0.3);
    transition: all var(--transition);
}
.ph-back:hover {
    background: var(--blue-dim);
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.is-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    }
    .sidebar-overlay.is-open { display: block; }
    .main-wrapper { margin-left: 0; }
    .sidebar-toggle { display: flex; }
    .platform-tag { display: none; }
}

@media (max-width: 640px) {
    .page-content { padding: 20px 16px 32px; }
    .card-grid { grid-template-columns: 1fr; }
    .overview-sections { grid-template-columns: 1fr 1fr; }
    .page-header-inner { flex-direction: column; gap: 10px; }
    .page-section-icon { width: 40px; height: 40px; }
    .page-title { font-size: 18px; }
}
