:root {
    --bg-page: #191919;
    --bg-sidebar: #202022;
    --bg-surface: #202022;
    --bg-surface-2: #242426;
    --bg-surface-3: #2a2a2c;
    --bg-selected: #222c2e;
    --bg-card: #202022;
    --bg-hover: rgba(255,255,255,0.04);
    --grid-line: #262626;
    --border: #292a2c;
    --border-strong: #313235;
    --border-hover: #3a3b3e;

    --text-primary: #f1f1f4;
    --text-secondary: #a0a4ac;
    --text-muted: #747780;
    --text-dim: #5f6269;

    --accent-cyan: #29c0c0;
    --accent-blue: #335cff;
    --accent-green: #58d68d;
    --accent-red: #ef4444;
    --accent-amber: #f4a259;
    --badge-green: #58d68d;

    --node-purple: #7b6df6;
    --node-pink: #c94888;
    --node-teal: #00a88f;
    --node-blue: #389bf2;
    --node-amber: #f4a259;

    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, ui-sans-serif, system-ui, sans-serif;
    --sidebar-w: 264px;
    --header-h: 64px;
    --tabs-h: 50px;
    --shadow-card: 0 10px 24px rgba(0,0,0,0.18);
    --shadow-card-hover: 0 14px 32px rgba(0,0,0,0.28);
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
    background: var(--bg-page);
    color: var(--text-primary);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
}
button, a { font: inherit; color: inherit; text-decoration: none; }

/* ========== APP SHELL ========== */
.app {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    background: var(--bg-page);
}
.app.sidebar-collapsed { --sidebar-w: 64px; }
.app.sidebar-collapsed .brand-name,
.app.sidebar-collapsed .nav-item span:not(.nav-icon),
.app.sidebar-collapsed .sidebar-stats,
.app.sidebar-collapsed .demo-button span,
.app.sidebar-collapsed .guides { display: none; }
.app.sidebar-collapsed .demo-button { width: 44px; padding: 0; justify-content: center; }
.app.sidebar-collapsed .nav-item { justify-content: center; padding: 0; }
.app.sidebar-collapsed .nav-icon { margin: 0; }

/* ========== SIDEBAR ========== */
.sidebar {
    flex: 0 0 var(--sidebar-w);
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-strong);
    z-index: 20;
    transition: flex-basis var(--transition-normal);
}

.brand {
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 18px 0 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.brand-mark {
    position: relative;
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
}
.brand-mark::before {
    content: "";
    position: absolute;
    left: 11px;
    top: 0;
    width: 2px;
    height: 26px;
    border-radius: 2px;
    background: #e9e9ed;
    transform: rotate(21deg);
    transform-origin: center;
}
.brand-mark::after {
    content: "";
    position: absolute;
    left: 1px;
    bottom: 3px;
    width: 11px;
    height: 3px;
    border-radius: 2px;
    background: #e9e9ed;
}
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
.collapse-icon {
    width: 18px; height: 18px;
    margin-left: auto;
    border: 1.5px solid #e8e8ec;
    border-radius: 3px;
    opacity: 0.5;
    cursor: pointer;
    position: relative;
    transition: opacity var(--transition-fast);
}
.collapse-icon:hover { opacity: 0.95; }
.collapse-icon::after {
    content: "";
    position: absolute;
    top: 3px; bottom: 3px; left: 7px;
    width: 1px; background: #e8e8ec;
}

.nav { padding: 18px 8px 0; overflow-y: auto; }
.nav-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    list-style: none;
}
.nav-item {
    height: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
    border-radius: 8px;
    color: #d6d6dc;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    white-space: nowrap;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.is-active {
    background: var(--bg-selected);
    color: var(--accent-cyan);
}
.nav-item.is-active::before {
    content: "";
    position: absolute;
    left: 0; top: 10px; bottom: 10px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent-cyan);
}
.nav-icon {
    width: 17px; height: 17px;
    flex: 0 0 auto;
    color: currentColor;
    opacity: 0.9;
}
.nav-icon svg {
    display: block; width: 100%; height: 100%;
    stroke: currentColor; fill: none;
    stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round;
}

.sidebar-bottom {
    margin-top: auto;
    padding: 16px 12px 16px;
    flex-shrink: 0;
}
.sidebar-stats {
    margin-bottom: 16px;
    padding: 12px;
    border-radius: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
}
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
}
.stat-label { color: var(--text-muted); }
.stat-value { color: var(--text-primary); font-weight: 700; font-size: 14px; }

.demo-button {
    width: 100%; height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 0; border-radius: 999px;
    background: var(--accent-blue);
    color: #fff;
    font-size: 15px; font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.demo-button:hover {
    background: #4a6fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(51,92,255,0.35);
}

/* ========== MAIN ========== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-page);
    overflow: hidden;
}

/* ========== TOPBAR ========== */
.topbar {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 16px;
}
.page-title {
    display: flex;
    align-items: center;
    gap: 13px;
    flex-shrink: 0;
}
.title-icon {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border-radius: 10px;
    background: #292a2d;
    color: #aeb2ba;
    flex-shrink: 0;
}
.title-icon svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.page-title-text { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}
.search-box input {
    width: 280px;
    height: 36px;
    padding: 0 12px 0 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: all var(--transition-fast);
}
.search-box input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(41,192,192,0.1);
}
.search-box input::placeholder { color: var(--text-muted); }
.search-icon {
    position: absolute;
    left: 11px;
    width: 15px; height: 15px;
    stroke: var(--text-muted);
    fill: none;
    stroke-width: 2;
    pointer-events: none;
}

.filters {
    display: flex;
    align-items: center;
    gap: 12px;
}
.filter {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}
.filter-label { color: var(--text-secondary); font-size: 12px; font-weight: 500; }
.select-like {
    height: 36px; min-width: 160px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 13px; font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}
.select-like:hover { border-color: var(--border-hover); background: var(--bg-surface-2); }
.select-like.active { border-color: var(--accent-cyan); }
.chevron {
    width: 7px; height: 7px;
    border-right: 1.5px solid var(--text-muted);
    border-bottom: 1.5px solid var(--text-muted);
    transform: rotate(45deg) translateY(-2px);
    opacity: 0.7;
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}
.select-like.active .chevron { transform: rotate(-135deg) translateY(1px); }

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 160px;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    padding: 6px;
    box-shadow: var(--shadow-card);
    z-index: 30;
    display: none;
    flex-direction: column;
    gap: 2px;
}
.dropdown-menu.open { display: flex; }
.dropdown-item {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-item.active { background: var(--bg-selected); color: var(--accent-cyan); font-weight: 600; }

.icon-btn {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.icon-btn:hover { border-color: var(--border-hover); color: var(--text-primary); background: var(--bg-surface-2); }
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.avatar {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--accent-cyan);
    color: #000;
    font-size: 12px; font-weight: 700;
    cursor: pointer;
    user-select: none;
}

/* ========== TABS ========== */
.tabs {
    height: var(--tabs-h);
    display: flex;
    padding: 0 24px;
    gap: 0;
    border-bottom: 1px solid var(--border-strong);
    flex-shrink: 0;
    background: var(--bg-page);
}
.tab {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    padding: 0 24px;
    color: var(--text-muted);
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    border: none; background: none;
    transition: color var(--transition-fast);
    white-space: nowrap;
}
.tab:hover { color: var(--text-secondary); }
.tab.is-active { color: var(--accent-cyan); }
.tab.is-active::after {
    content: "";
    position: absolute;
    left: 0; right: 0;
    bottom: -1px;
    height: 2.5px;
    background: var(--accent-cyan);
    border-radius: 2px 2px 0 0;
}

/* ========== CONTENT AREA ========== */
.content-area {
    flex: 1;
    min-height: 0;
    overflow: auto;
    position: relative;
}
.content-area::-webkit-scrollbar { width: 6px; height: 6px; }
.content-area::-webkit-scrollbar-track { background: transparent; }
.content-area::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.view-section {
    padding: 24px;
    animation: viewFadeIn 0.3s ease;
}
@keyframes viewFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== GRAPH STAGE ========== */
.graph-stage {
    position: relative;
    width: 100%;
    height: calc(100vh - var(--header-h) - var(--tabs-h));
    overflow: hidden;
    background-color: var(--bg-page);
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 35px 35px;
    background-position: 0 0;
}

.view-toggle {
    position: absolute;
    top: 16px; right: 20px;
    height: 40px;
    display: flex; align-items: center; gap: 3px;
    padding: 3px;
    border-radius: 10px;
    background: rgba(32,32,34,0.7);
    border: 1px solid rgba(49,50,53,0.6);
    backdrop-filter: blur(6px);
    z-index: 15;
}
.toggle-button {
    width: 36px; height: 34px;
    display: grid; place-items: center;
    border: 0; border-radius: 7px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.toggle-button:hover { color: var(--text-secondary); }
.toggle-button.is-active { background: var(--bg-surface-2); color: var(--text-primary); border: 1px solid var(--border-strong); }
.toggle-button svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.legend {
    position: absolute;
    left: 20px; bottom: 16px;
    display: flex; align-items: center; gap: 8px;
    color: var(--text-secondary);
    font-size: 13px; font-weight: 500;
    z-index: 10;
    background: rgba(25,25,25,0.7);
    padding: 6px 12px;
    border-radius: 8px;
    backdrop-filter: blur(4px);
}
.legend-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--badge-green); box-shadow: 0 0 8px rgba(88,214,141,0.4); }

.graph-world {
    position: absolute;
    inset: 0;
    z-index: 1;
}
.edge-layer {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}
.edge {
    stroke: #2c2d30;
    stroke-width: 1.2;
    opacity: 0.65;
    transition: opacity 0.4s ease;
}
.fadeable { transition: opacity 0.4s ease, transform 0.4s ease; }

.app[data-mode="timing"] .fadeable:not(.g-timing):not(.g-hub),
.app[data-mode="win"] .fadeable:not(.g-win):not(.g-hub),
.app[data-mode="risk"] .fadeable:not(.g-risk):not(.g-hub),
.app[data-mode="recovery"] .fadeable:not(.g-recovery):not(.g-hub),
.app[data-mode="proactive"] .fadeable:not(.g-proactive):not(.g-hub) {
    opacity: 0.1;
    transform: scale(0.92);
}

.hub {
    position: absolute;
    left: 50%; top: 50%;
    width: 96px; height: 96px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px solid #303136;
    background: rgba(26,26,27,0.75);
    display: grid; place-items: center;
    cursor: pointer;
    z-index: 5;
    transition: all var(--transition-normal);
}
.hub:hover {
    transform: translate(-50%, -50%) scale(1.08);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 24px rgba(41,192,192,0.15);
}
.diamond {
    width: 20px; height: 20px;
    transform: rotate(45deg);
    border-radius: 3px;
    border: 2px solid rgba(216,205,255,0.85);
    background: radial-gradient(circle at 25% 25%, #7d77ff 0 18%, transparent 19%), linear-gradient(135deg, #7e66ff 0%, #9f5bff 32%, #24c2c6 55%, #f2a15c 100%);
    box-shadow: 0 0 14px rgba(126,102,255,0.45), 0 0 10px rgba(242,161,92,0.22);
    animation: diamondPulse 3s ease-in-out infinite;
}
@keyframes diamondPulse {
    0%, 100% { box-shadow: 0 0 14px rgba(126,102,255,0.45), 0 0 10px rgba(242,161,92,0.22); }
    50% { box-shadow: 0 0 20px rgba(126,102,255,0.6), 0 0 16px rgba(242,161,92,0.35); }
}

.cluster {
    position: absolute;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    cursor: pointer;
    z-index: 6;
    transform: translate(-50%, -50%);
}
.cluster:hover .core { transform: scale(1.12); border-color: var(--border-hover); }
.cluster:hover .label { color: var(--text-primary); }
.core {
    width: 64px; height: 64px;
    border-radius: 50%;
    border: 1px solid #303136;
    background: rgba(27,27,29,0.95);
    display: grid; place-items: center;
    transition: all var(--transition-normal);
    position: relative;
}
.core::before {
    content: "";
    position: absolute; inset: -4px;
    border-radius: 50%;
    border: 1.5px solid transparent;
    transition: border-color var(--transition-normal);
}
.cluster:hover .core::before { border-color: var(--border-hover); }
.app[data-mode="timing"] .cluster.g-timing .core,
.app[data-mode="win"] .cluster.g-win .core,
.app[data-mode="risk"] .cluster.g-risk .core,
.app[data-mode="recovery"] .cluster.g-recovery .core,
.app[data-mode="proactive"] .cluster.g-proactive .core {
    transform: scale(1.18);
    border-color: currentColor;
    box-shadow: 0 0 20px rgba(255,255,255,0.08);
}
.count {
    width: 26px; height: 26px;
    display: grid; place-items: center;
    border-radius: 50%;
    color: #fff;
    font-size: 12px; font-weight: 800;
}
.count.pink { background: var(--node-pink); box-shadow: 0 0 10px rgba(201,72,136,0.4); }
.count.purple { background: var(--node-purple); box-shadow: 0 0 10px rgba(123,109,246,0.4); }
.count.teal { background: var(--node-teal); box-shadow: 0 0 10px rgba(0,168,143,0.4); }
.count.blue { background: var(--node-blue); box-shadow: 0 0 10px rgba(56,155,242,0.4); }
.count.amber { background: var(--node-amber); box-shadow: 0 0 10px rgba(244,162,89,0.4); }
.label { color: var(--text-secondary); font-size: 13px; font-weight: 650; white-space: nowrap; letter-spacing: -0.01em; transition: color var(--transition-fast); }

.leaf {
    position: absolute;
    width: 20px; height: 20px;
    border-radius: 50%;
    border: 1px solid #2f3136;
    background: rgba(36,38,44,0.85);
    display: grid; place-items: center;
    cursor: pointer;
    z-index: 4;
    transform: translate(-50%, -50%);
    transition: all var(--transition-fast);
}
.leaf:hover { transform: translate(-50%, -50%) scale(1.3); border-color: var(--border-hover); }
.leaf::after { content: ""; width: 8px; height: 8px; border-radius: 50%; transition: all var(--transition-fast); }
.leaf.purple::after { background: var(--node-purple); box-shadow: 0 0 6px rgba(123,109,246,0.5); }
.leaf.pink::after { background: var(--node-pink); box-shadow: 0 0 6px rgba(201,72,136,0.5); }
.leaf.teal::after { background: var(--node-teal); box-shadow: 0 0 6px rgba(0,168,143,0.5); }
.leaf.blue::after { background: var(--node-blue); box-shadow: 0 0 6px rgba(56,155,242,0.5); }
.leaf.amber::after { background: var(--node-amber); box-shadow: 0 0 6px rgba(244,162,89,0.5); }

.graph-tooltip {
    position: absolute;
    display: none; align-items: center; gap: 10px;
    padding: 8px 14px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    color: var(--text-secondary);
    font-size: 13px; font-weight: 600;
    box-shadow: var(--shadow-card);
    z-index: 20;
    pointer-events: none;
    animation: tooltipIn 0.2s ease;
}
.graph-tooltip.visible { display: flex; }
@keyframes tooltipIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.tooltip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--node-amber); box-shadow: 0 0 0 3px rgba(244,162,89,0.15); flex-shrink: 0; }

.card-layer {
    position: absolute; inset: 0;
    z-index: 8;
    pointer-events: none;
}
.card-set { display: none; }
.app[data-mode="timing"] .card-set.timing,
.app[data-mode="win"] .card-set.win,
.app[data-mode="risk"] .card-set.risk,
.app[data-mode="recovery"] .card-set.recovery,
.app[data-mode="proactive"] .card-set.proactive { display: block; }

.insight-card {
    position: absolute;
    width: 360px; height: 56px;
    display: flex; align-items: center; gap: 12px;
    padding: 0 16px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px; font-weight: 550;
    box-shadow: var(--shadow-card);
    pointer-events: auto;
    cursor: pointer;
    transition: all var(--transition-fast);
    animation: cardSlideIn 0.35s ease both;
}
.insight-card:hover { background: var(--bg-surface-2); border-color: var(--border-hover); transform: translateX(4px); box-shadow: var(--shadow-card-hover); }
.insight-card.featured { border-color: var(--border-strong); }
.insight-card.featured .card-title { color: var(--text-primary); font-weight: 700; }
.insight-card:nth-child(1) { animation-delay: 0.05s; }
.insight-card:nth-child(2) { animation-delay: 0.1s; }
.insight-card:nth-child(3) { animation-delay: 0.15s; }
.insight-card:nth-child(4) { animation-delay: 0.2s; }
.insight-card:nth-child(5) { animation-delay: 0.25s; }
.insight-card:nth-child(6) { animation-delay: 0.3s; }
@keyframes cardSlideIn { from { opacity: 0; transform: translateX(-12px) scale(0.96); } to { opacity: 1; transform: translateX(0) scale(1); } }

.card-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; flex-shrink: 0; }
.card-dot.purple { background: var(--node-purple); box-shadow: 0 0 0 3px rgba(123,109,246,0.18); }
.card-dot.blue { background: var(--node-blue); box-shadow: 0 0 0 3px rgba(56,155,242,0.18); }
.card-dot.amber { background: var(--node-amber); box-shadow: 0 0 0 3px rgba(244,162,89,0.18); }

.card-title { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1 1 auto; letter-spacing: -0.01em; }
.badge { height: 20px; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; padding: 0 8px; border: 1px solid var(--badge-green); border-radius: 999px; color: var(--badge-green); font-size: 10px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.metric { flex: 0 0 auto; margin-left: 4px; color: var(--text-secondary); font-size: 13px; font-weight: 700; min-width: 36px; text-align: right; }
.arrow { flex: 0 0 auto; color: var(--text-muted); font-size: 15px; line-height: 1; transition: transform var(--transition-fast), color var(--transition-fast); }
.insight-card:hover .arrow { transform: translateX(3px); color: var(--text-primary); }

.card-set.timing .insight-card:nth-child(1) { left: 18%; top: 16%; }
.card-set.timing .insight-card:nth-child(2) { left: 38%; top: 24%; }
.card-set.timing .insight-card:nth-child(3) { left: 14%; top: 36%; }
.card-set.timing .insight-card:nth-child(4) { left: 12%; top: 52%; }
.card-set.timing .insight-card:nth-child(5) { left: 30%; top: 62%; }
.card-set.win .insight-card:nth-child(1) { left: 30%; top: 32%; }
.card-set.win .insight-card:nth-child(2) { left: 16%; top: 44%; }
.card-set.win .insight-card:nth-child(3) { left: 44%; top: 52%; }
.card-set.win .insight-card:nth-child(4) { left: 14%; top: 60%; }
.card-set.win .insight-card:nth-child(5) { left: 46%; top: 68%; }
.card-set.win .insight-card:nth-child(6) { left: 22%; top: 76%; }
.card-set.risk .insight-card:nth-child(1) { left: 42%; top: 36%; }
.card-set.risk .insight-card:nth-child(2) { left: 52%; top: 44%; }
.card-set.risk .insight-card:nth-child(3) { left: 28%; top: 52%; }
.card-set.risk .insight-card:nth-child(4) { left: 54%; top: 64%; }
.card-set.risk .insight-card:nth-child(5) { left: 30%; top: 70%; }
.card-set.risk .insight-card:nth-child(6) { left: 44%; top: 80%; }

/* ========== TABLE VIEW ========== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th {
    text-align: left;
    padding: 10px 14px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
}
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}
.data-table tr {
    transition: background var(--transition-fast);
    cursor: pointer;
}
.data-table tr:hover { background: var(--bg-hover); }
.data-table .cell-name { font-weight: 600; }
.data-table .cell-secondary { color: var(--text-secondary); font-size: 12px; }
.data-table .tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}
.tag-green { background: rgba(88,214,141,0.12); color: var(--badge-green); }
.tag-blue { background: rgba(56,155,242,0.12); color: var(--node-blue); }
.tag-purple { background: rgba(123,109,246,0.12); color: var(--node-purple); }
.tag-amber { background: rgba(244,162,89,0.12); color: var(--node-amber); }
.tag-red { background: rgba(239,68,68,0.12); color: var(--accent-red); }
.tag-gray { background: rgba(255,255,255,0.06); color: var(--text-muted); }

/* ========== CARDS GRID ========== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.info-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    transition: all var(--transition-fast);
}
.info-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-card); }
.info-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.info-card-title { font-size: 14px; font-weight: 700; }
.info-card-value { font-size: 28px; font-weight: 800; margin: 8px 0; }
.info-card-sub { font-size: 12px; color: var(--text-muted); }

/* ========== PIPELINE ========== */
.pipeline-container {
    display: flex;
    gap: 12px;
    padding: 8px 0;
    overflow-x: auto;
}
.pipeline-stage {
    flex: 0 0 220px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}
.pipeline-stage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.pipeline-stage-name { font-size: 13px; font-weight: 700; }
.pipeline-stage-count {
    width: 24px; height: 24px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--bg-surface-2);
    font-size: 11px; font-weight: 700;
    color: var(--text-secondary);
}
.pipeline-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.pipeline-card:hover { border-color: var(--border-hover); transform: translateY(-1px); }
.pipeline-card-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.pipeline-card-meta { font-size: 11px; color: var(--text-muted); }
.pipeline-card-score {
    margin-top: 8px;
    height: 4px;
    border-radius: 2px;
    background: var(--bg-surface-2);
    overflow: hidden;
}
.pipeline-card-score-bar {
    height: 100%;
    border-radius: 2px;
    background: var(--accent-cyan);
}

/* ========== PROGRESS BAR ========== */
.progress-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--bg-surface-2);
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
    transition: width 0.6s ease;
}

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal {
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn 0.25s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border: 0; border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

/* XAPI panel inside modal */
.xapi-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.xapi-tab {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition-fast);
}
.xapi-tab:hover { border-color: var(--border-hover); color: var(--text-primary); }
.xapi-tab.active { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }
.xapi-data {
    font-size: 13px;
    max-height: 320px;
    overflow: auto;
    background: #0f0f11;
    color: #c8cdd0;
    padding: 16px;
    border-radius: 8px;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'SF Mono', Monaco, monospace;
    line-height: 1.6;
}
.xapi-formatted { font-size: 14px; line-height: 1.6; }
.xapi-row { padding: 5px 0; border-bottom: 1px solid var(--border); }
.xapi-row:last-child { border-bottom: none; }
.xapi-warning { background: rgba(244,162,89,0.1); color: var(--node-amber); padding: 12px 16px; border-radius: 8px; font-size: 13px; }
.xapi-error { background: rgba(239,68,68,0.1); color: var(--accent-red); padding: 12px 16px; border-radius: 8px; font-size: 13px; }

/* ========== TOAST ========== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-card-hover);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    max-width: 360px;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(20px); } }

/* ========== LIST VIEW ========== */
.list-view {
    padding: 24px;
}
.list-view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.list-view-title { font-size: 18px; font-weight: 700; }
.list-view-actions { display: flex; gap: 10px; }

.btn {
    height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn:hover { border-color: var(--border-hover); background: var(--bg-surface-2); }
.btn-primary { background: var(--accent-blue); border-color: var(--accent-blue); color: #fff; }
.btn-primary:hover { background: #4a6fff; }

/* ========== RESPONSIVE ========== */
@media (max-width: 1200px) {
    .insight-card { width: 300px; }
    .search-box input { width: 200px; }
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
