/* ============================================================
   CORE DESIGN TOKENS
   ============================================================ */
:root {
    /* 🌑 Default Dark Mode Variables */
    --bg: #050816;
    --panel: #0b1020;
    --panel-dark: #070a14;
    --panel-soft: #111827;
    --panel-border: #1f2937;
    --line: rgba(255, 255, 255, 0.1);
    --dot-color: rgba(255, 255, 255, 0.1);
    
    /* Branding Colors */
    --accent: #38bdf8; 
    --accent-glow: rgba(56, 189, 248, 0.15);
    --vault-gold: #fbbf24;
    --danger: #f87171;
    --success: #10b981;
    
    /* Text */
    --text-main: #f9fafb;
    --text-dim: #9ca3af;
    --text-muted: #6b7280;
    --text: #f8fafc; /* Bridge for legacy code */

    --font-main: 'Inter', system-ui, -apple-system, sans-serif;

    --tray-item-bg: rgba(255, 255, 255, 0.03);
    --tray-item-hover: rgba(255, 255, 255, 0.08);

    --color-scoping: #2ecc71; /* A vibrant, "green for scoped" color */
    --color-scoping-rgb: 46, 204, 113;
}

/* ☀️ Light Mode Overrides */
body.light-mode {
    --bg: #f1f5f9;
    --panel: #ffffff;
    --panel-dark: #e2e8f0;
    --panel-soft: #f8fafc;
    --panel-border: #cbd5e1;
    --line: rgba(0, 0, 0, 0.1);
    --dot-color: rgba(0, 0, 0, 0.1);
    
    /* Sharpening Branding for Light BG */
    --accent: #0284c7;        /* Deeper blue for readability */
    --accent-glow: rgba(2, 132, 199, 0.1);
    --vault-gold: #b45309;   /* Deeper gold/amber */
    
    /* Text Overrides */
    --text-main: #0f172a;
    --text-dim: #475569;
    --text-muted: #64748b;
    --text: #0f172a;

    --tray-item-bg: rgba(0, 0, 0, 0.03);
    --tray-item-hover: rgba(0, 0, 0, 0.06);
}

.theme-toggle-zone button {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; 
  background: var(--panel-soft); border: 1px solid var(--line); color: var(--text-main); 
  padding: 8px; border-radius: 6px; cursor: pointer;
}

/* Add this to your CSS */
.theme-toggle-zone button:hover {
    background: var(--accent-glow) !important;
    border-color: var(--accent) !important;
}

/* 🎯 Theme Toggle Alignment Fix */
.theme-toggle-zone {
    padding: 10px 0; /* Remove side padding to allow centering */
    margin-top: auto;
    display: flex;
    justify-content: center; /* Centers the button in the zone */
}

.theme-icon {
  min-width: 20px; text-align: center;
}

.client-avatar {
  background: var(--accent); color: white;
}

* { box-sizing: border-box; -webkit-font-smoothing: antialiased; font-size: 11px;}

html {
    background-color: var(--bg); /* Set once at the highest level */
}

body {
    margin: 0;
    padding: 0;
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 11px;
    line-height: 1.5;
    background-color: transparent; /* Let HTML background show through */
    transition: background-color 0.3s ease, color 0.3s ease;
}

.pill {
  cursor: pointer;
}
/* ============================================================
   SYSTEM LAYOUT (Sidebar & Main Container)
   ============================================================ */
#app-root {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}

.sidebar {
    width: 240px;
    position: relative;
    background: var(--panel);
    border-right: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#mainContent {
    padding: 40px;
    height: auto;
    /* 🚀 THE FIX: Use variables for the gradient colors */
    background: radial-gradient(circle at top right, var(--accent-glow), transparent);
    background-color: var(--bg); /* Ensures the 'transparent' part matches the theme */
    background-attachment: fixed;
    background-size: cover;
    transition: background 0.3s ease;
    overflow-y: auto;
}

/* ============================================================
   SIDEBAR CATEGORY LABELS (Sphynx Master / Project Workspace)
   ============================================================ */
.menu-category-label {
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    padding: 24px 10px 12px 14px; /* Integrated top padding for first section */
    text-transform: uppercase;
    user-select: none;
}

/* Specific zones for admin and client nav */
.admin-nav-zone {
    padding-top: 5px;
}

.client-nav-zone {
    padding-top: 5px;
}

.divider {
    height: 1px;
    background: var(--panel-border);
    margin: 10px 14px;
    opacity: 0.5;
}

/* ============================================================
   NAVIGATION MENU & LINKS
   ============================================================ */
.menu {
    padding: 0 12px 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text-dim);
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid transparent; /* Prevents shifting when active */
}

.menu a i { 
    font-style: normal; 
    font-size: 16px; 
    width: 20px; 
    text-align: center; 
}

.menu a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.menu a.active {
    background: var(--panel-soft); /* Darker "inset" blue-grey */
    color: var(--accent); /* Highlight text blue */
    border: 1px solid var(--panel-border); /* Subtle border defined in tokens */
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    font-weight: 600;
}

.menu a.active i {
    color: var(--accent);
    filter: drop-shadow(0 0 5px var(--accent-glow));
}

.menu a:not(.active):hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

/* Collapsed State Styles */
.sidebar.collapsed {
    width: 65px;
}

/* Hide text labels and metadata when collapsed */
.sidebar.collapsed span, 
.sidebar.collapsed .client-info, 
.sidebar.collapsed .menu-category-label,
.sidebar.collapsed .client-meta,
.sidebar.collapsed .theme-label {
    display: none;
}

.sidebar.collapsed .theme-icon {
    display: block;
    padding: 3px 0 6px 0;
}

body:has(.sidebar.collapsed) #mainContent {
    margin-left: 65px;
}

/* Center icons in the rail */
.sidebar.collapsed .menu a {
    justify-content: center;
    padding: 10px 0;
}

.sidebar.collapsed .client-avatar {
    margin: 0 auto;
}

/* The Toggle Button Styling */
.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 10px;
    text-align: right;
    font-size: 18px;
    outline: none;
}
.sidebar-toggle:hover { color: var(--accent); }

/* ============================================================
   CLIENT PROFILE CARD (Inside Project Workspace)
   ============================================================ */
.client-profile-trigger {
    margin: 0 10px 15px 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.client-profile-trigger:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
}

.client-avatar {
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: var(--text-main);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 12px;
}

.client-info {
    flex: 1;
    overflow: hidden;
}

.client-name {
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-main);
}

.client-meta {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
}

.public-container { height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.public-header { 
    padding: 20px 40px; 
    background: var(--panel); 
    border-bottom: 1px solid var(--panel-border);
    display: flex; justify-content: space-between; align-items: center;
}
.public-nav { display: flex; gap: 20px; }
.public-nav a { text-decoration: none; color: var(--muted); font-weight: 600; padding: 8px 16px; border-radius: 6px; }
.public-nav a.active { background: var(--accent); color: white; }
.public-content { padding: 40px; overflow-y: auto; flex: 1; }

.status-pill-dropdown {
    padding: 2px 8px;
    height: 22px;
    appearance: none; /* Removes default arrow */
    -webkit-appearance: none;
    text-align: center;
    transition: all 0.2s ease;
}

.status-pill-dropdown:hover {
    border-color: var(--accent) !important;
    color: var(--accent) !important;
}

/* Optional: Color-coding the border based on status */
.status-pill-dropdown[value="Active"] { border-color: var(--success); }
.status-pill-dropdown[value="On Hold"] { border-color: var(--warn); }

/* ============================================================
   UTILITIES & STATE
   ============================================================ */
.lock-icon {
    font-size: 10px !important;
    opacity: 0.5;
    margin-left: auto;
}

.empty-context-hint {
    padding: 30px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 11px;
    font-style: italic;
}

/* ============================================================
   REGISTRY DASHBOARD & CARDS
   ============================================================ */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 30px;
    gap: 20px;
    z-index: 9999;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* Specific styling for the Sync button to make it feel like a 'System' tool */
.header-actions .btn.primary {
    background: var(--accent-glow);
    border: 1px solid var(--accent);
    color: var(--accent);
    transition: all 0.2s;
}

.header-actions .btn.primary:hover {
    background: var(--accent);
    color:  var(--text-main);
    box-shadow: 0 0 15px var(--accent-glow);
}

.section-header h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.card {
    background: var(--panel-soft);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 24px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    cursor: pointer;
}

.card-section {
  display: flex; flex-direction: column;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
  padding: 15px;
  background: rgba(255,255,255,0.05); 
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

.card.active-client {
    border: 1px solid var(--accent);
    background: linear-gradient(145deg, var(--panel-soft), #0f172a);
}

.card.active-client::after {
    content: "ACTIVE";
    position: absolute;
    top: 12px;
    right: 12px;
    font-size: 9px;
    font-weight: 900;
    color: var(--accent);
    letter-spacing: 0.1em;
}

.card-footer-actions {
    display: flex;
    gap: 8px;
    margin-top: auto; /* Pushes buttons to the bottom of the card */
}

.card-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 101;
    transition: color 0.2s, transform 0.2s;
}

.card-delete-btn:hover {
    color: #ef4444; /* Alert Red */
    transform: scale(1.2);
    cursor: pointer;
}

/* Ensure the header doesn't collapse with the new button */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

/* Badge Style */
.v2-card-part {
    font-size: 9px;
    background: rgba(56, 189, 248, 0.2);
    color: #38bdf8;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(56, 189, 248, 0.4);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}
.v2-card-part:hover {
    background: #38bdf8;
    color: #0f172a;
}

.status-pill {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    background: var(--panel-soft);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--text-muted);
    border: 1px solid var(--panel-border);
}

/* Visual feedback for read-only (View) permissions */
.is-view-only input, 
.is-view-only select, 
.is-view-only textarea {
    cursor: not-allowed;
    background: transparent !important;
    border-color: transparent !important;
    color: var(--text-dim) !important;
    pointer-events: none;
}

.is-view-only .col-actions, 
.is-view-only .header-actions {
    display: none !important;
}

.status-dot {
  width:8px; height:8px; border-radius:50%; 
}

.status-dot.primary {
  background: #a855f7 !important; /* Purple */
}

.status-dot.evaluating {
  background: #eab308 !important; /* Yellow */
}

.status-dot.available {
  border: 1px solid white;
}

/* ============================================================
   BUTTONS & INTERACTION
   ============================================================ */
.btn {
    font-family: inherit;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn.primary {
    background: var(--accent);
    color: var(--text-main);
}

.btn.soft {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border-color: var(--panel-border);
}

.btn.soft:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn.full-width { width: 100%; margin-top: 15px; }

/* Status Indicators */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.badge.discovery { background: var(--accent-glow); color: var(--accent); border: 1px solid var(--accent); }

/*--------------------------------
 APPS GRID
--------------------------------*/

.banner-info {
  margin-bottom:20px; padding:10px; background:rgba(var(--accent-rgb), 0.05); 
  border: 1px solid var(--accent); border-radius:6px; font-size:11px;
}

/* Fixed styling for Deployment and Manager rows */
.dp-manager-row {
    display: flex;
    justify-content: flex-start;
    padding: 10px 14px;
    background: var(--panel-soft);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: border-color 0.2s;
}

.dp-manager-row:hover {
    border-color: var(--accent);
}

.dp-manager-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.card.is-master-template {
    border-left: 4px solid var(--vault-gold) !important;
}

.card.is-local-app {
    border-left: 4px solid var(--accent) !important;
}

.vault-tag {
    font-size: 8px;
    background: var(--vault-gold);
    color:  var(--text-main);
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 900;
    margin-left: 8px;
}

.local-tag {
    font-size: 8px;
    background: var(--line);
    color: var(--text-dim);
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 900;
}

.local-spec {
  display:flex; align-items:center; gap:10px; padding:6px; border-bottom:1px solid var(--line);
}

.flex-1 { flex: 1; }

.card-actions .btn:hover {
    filter: brightness(1.2);
}

/*=============================================================
    RESOURCES GRID
=============================================================== */

/* Container for the button and menu */
.dropdown-plus-container {
    position: relative;
}

/* Hidden by default */
.dropdown-plus-menu {
    display: none;
    position: absolute;
    top: 100%;
    background: var(--bg);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    min-width: 180px;
    padding: 5px 0;
}

/* Show on hover */
.dropdown-plus-container:hover .dropdown-plus-menu {
    display: block;
}

.dropdown-item {
    padding: 10px 15px;
    font-size: 13px;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background: var(--accent);
    color: var(--text-main);
    padding-left: 20px; /* Slight slide effect */
}

/* ============================================================
   FUNCTION CARD STYLING
   ============================================================ */

.card.is-master-template:hover {
    border-color: var(--vault-gold);
    box-shadow: 0 8px 20px rgba(251, 191, 36, 0.15);
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
}

/* ============================================================
   STRICT SCOPING GRID - FORCE ALIGNMENT
   ============================================================ */
/* This rule targets the main container, the header, the round headers, and every row */
.scoping-grid {
    width: 100% !important;
    min-width: 880px; /* This prevents the overlap before the mobile breakpoint hits */
}

.scoping-grid,
.grid-row, 
.round-header-row, 
.grid-header {
    width: 100% !important;
}

.grid-header,
.grid-row,
.round-header-row,
.grand-totals-bar {
    display: grid !important;
    grid-template-columns: 
        minmax(200px, 2fr)   /* 1. Deliverable */
        minmax(150px, 1fr)   /* 2. Status */
        140px                /* 3. Team + Mult*/
        75px                 /* 5. Gross */
        75px                 /* 6. Disc */
        95px                 /* 7. Fee */
        30px !important;     /* 8. X */
    gap: 8px 12px !important;
    align-items: start !important;
    padding: 10px 16px !important;
}

/* Numeric Alignment */
.col-multiplier, .col-gross, .col-discount {
    text-align: center !important;
}

.col-gross, .col-discount, .col-numeric {
    font-variant-numeric: tabular-nums !important;
}

.col-numeric {
    text-align: right !important;
    font-variant-numeric: tabular-nums !important;
    font-weight: 700;
}

.col-actions {
    text-align: right !important;
    display: flex !important;
    justify-content: flex-end !important;
}

/* Ensure Titles don't push columns */
.row-title {
    white-space: normal !important;
    word-wrap: break-word;
    line-height: 1.4;
    font-weight: bold;
    color: var(--accent);
}

.row-note {
    white-space: normal !important;
    font-size: 11px;
    margin-top: 4px;
    display: block;
}

.col-expand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-width: 0; /* Prevents flex children from overflowing */
    overflow: visible !important;
}

/* Ensure the unit badge container can wrap and grow the row height */
.unit-badge-container {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 4px;
    margin-top: 6px;
    height: auto !important;
    min-height: 10px;
}

.unit-tag {
    display: inline-flex;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    background: transparent;
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(56, 189, 248, 0.3);
    margin-top: 4px;
    margin-right: 4px;
    white-space: nowrap;
    /* Ensure it's never hidden if generated */
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ensure the bar uses the master 8-track grid */
.grand-totals-bar {
    display: grid !important;
    /* Use exact match of the row definition */
    grid-template-columns: 
        minmax(200px, 2fr) 1minmax(150px, 1fr) 140px 65px 75px 75px 95px 30px !important;
    gap: 8px 12px !important;
    align-items: center !important;
    padding: 20px 16px !important;
    background: rgba(0, 0, 0, 0.05);
    border-top: 2px solid var(--accent);
    margin-top: 10px;
}

/* Position the totals in their specific tracks */
.total-item-gross { grid-column: 4; text-align: center; }
.total-item-disc  { grid-column: 5; text-align: center; }
.total-item-net   { grid-column: 6; text-align: right; }

/* The Actions (PDF/Adjustments) stay on the left */
.grand-actions { grid-column: 1 / span 2; display: flex; gap: 10px; }

/* ============================================================
   MOBILE: 2-ROW STACKED LAYOUT (< 768px)
   ============================================================ */
@media screen and (max-width: 768px) {
    .scoping-grid {
        min-width: 0 !important;
    }

    .grid-header { display: none !important; } /* Hide headers on mobile */

    .grid-row, .round-header-row {
        grid-template-columns: 2fr 1fr 1fr 30px !important; /* 4 columns on mobile */
        grid-template-areas: 
            "title  status  team    x"
            "prices prices  prices  prices" !important;
    }

    /* Wrap the Financials into a custom sub-row */
    .col-expand { grid-column: 1; }
    .col-status { grid-column: 2; }
    .col-team   { grid-column: 3; }
    .col-actions { grid-column: 4; }

    /* Create a horizontal flexbox for the money metrics on row 2 */
    .col-multiplier, .col-gross, .col-discount, .col-numeric {
        grid-row: 2;
        display: flex !important;
        flex-direction: row;
        justify-content: space-between;
        background: rgba(255,255,255,0.03);
        padding: 8px;
        border-radius: 4px;
        font-size: 12px;
    }

    .col-multiplier::before { content: "Mult: "; font-size: 10px; opacity: 0.5; }
    .col-gross::before      { content: "Gross: "; font-size: 10px; opacity: 0.5; }
    .col-discount::before   { content: "Disc: "; font-size: 10px; opacity: 0.5; }
    .col-numeric::before    { content: "Net: "; font-size: 10px; opacity: 0.5; }
}

/*============================================================
  DISCOUNTS MODAL
  ==============================================================*/

  /* Container for the input and toggle buttons */
.discount-control {
    display: flex;
    align-items: center;
    gap: 0; /* Tighten gap for a single-unit look */
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 2px;
    width: fit-content;
}

/* The numeric entry box */
.discount-control .tiny-input {
    width: 60px !important; /* Force fixed width */
    height: 24px;
    background: transparent !important;
    border: none !important;
    color: white !important;
    font-family: monospace;
    font-size: 12px;
    text-align: center;
    outline: none;
}

/* The toggle buttons group */
.discount-control .toggle-group {
    display: flex;
    border-left: 1px solid var(--line);
    padding-left: 2px;
}

.discount-control .toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    padding: 2px 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.discount-control .toggle-btn.active {
    background: var(--accent);
    color: white;
    border-radius: 2px;
}

/* Remove arrows from number input */
.tiny-input::-webkit-inner-spin-button,
.tiny-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ============================================================
   ANALYSIS MATRIX (GRID SPREADSHEET)
   ============================================================ */

/* 1. Kill the gap: Remove padding from the card shell */
.matrix-card-main {
    padding: 0 !important; 
    overflow: visible !important;
    position: relative;
    background: var(--panel);
}

/* 2. Layer 1: The Dark Title Bar */
.matrix-card-main .section-header {
    position: sticky;
    top: -40px;                              
    background: var(--panel);   /* Uses theme var */
    padding: 20px;
    margin: 0;
    border-bottom: 1px solid var(--panel-border);             /* 🚀 Hard height for docking */
    display: flex;
    align-items: center;
    box-sizing: border-box;
    z-index: 9090;
}
/* 3. Layer 2: The Table Headers */
.matrix-table {
    border-collapse: separate;  /* 🚀 Required for sticky logic */
    border-spacing: 0;
}

.matrix-table thead th {
    position: sticky;
    top: 65px;                  /* 🚀 Exactly the height of the section-header */
    z-index: 9090;
    background-color: var(--panel-soft) !important;
    padding: 12px 15px;
    /* This shadow acts as a 'barrier' for scrolling text */
    box-shadow: 0 2px 0 0 var(--accent);
}

/* 4. Layer 3: Sticky First Column (Features) */
.matrix-table th:first-child, 
.matrix-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 800;               
    background-color: var(--panel-soft) !important;
    border-right: 2px solid var(--panel-border);
}

/* 5. The Corner "Master" Cell */
.matrix-table thead th:first-child {
    z-index: 9999;              
    top: 65px;
    left: 0;
    box-shadow: 0 2px 0 0 var(--accent);
    margin-right: -1px;
    border-right: 2px solid var(--panel-border);
}

.matrix-table thead th::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background-color: var(--accent); /* Uses your gold/accent color */
    z-index: 1001;
}

/* 6. Category Rows (GENERAL, SECURITY, etc) */
.category-header-row td {
    position: sticky;
    left: 0;
    z-index: 750;
    background: var(--panel-soft) !important;
}

/* Ensure inputs don't bloat the column width */
.tiny-input {
    width: 50px !important;
    text-align: left;
    font-size: 11.5px;
}

/* Container for each pricing row */
.tier-entry-row {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    margin-bottom: 4px;
}

/* The Name Input - 🚀 MAKE THIS EXPAND */
.tier-name-input {
    flex: 1; /* This tells it to take all remaining space */
    min-width: 0; /* Prevents input from pushing out of the cell */
    font-size: 10px;
    padding: 2px 4px;
}

/* The Price Wrapper - 📏 MAKE THIS SMALL */
.tier-price-wrapper {
    display: flex;
    align-items: center;
    gap: 2px;
    width: 65px; /* Fixed small width for the currency + amount */
    flex-shrink: 0; /* Prevents the name box from squishing this */
}

.tier-price-input {
    width: 100%;
    font-size: 10px;
    text-align: right;
    padding: 2px;
}

/* Standard UI adjustment to hide scrollbar in web view during preview */
#activeAnalysisMatrix {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none;  /* IE and Edge */
}
#activeAnalysisMatrix::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.col-feature { width: 30%; }
.col-weight { width: 10%; text-align: center; }
.col-app-score { width: 15%; text-align: center; }

.score-input {
    width: 50px;
    background: var(--bg);
    border: 1px solid var(--accent);
    color: var(--accent);
    text-align: center;
    border-radius: 4px;
    font-weight: bold;
}

.winner-highlight {
    background: rgba(16, 185, 129, 0.1) !important;
    border: 1px solid var(--success) !important;
    color: var(--success);
    font-weight: 800;
}

/* 1. Center everything in the score and total columns */
.matrix-table td:not(:first-child) {
    text-align: center !important;
}

/* 2. Force inputs to center their text and fill width */
.matrix-score-input, .tiny-input {
    text-align: left !important;
    width: 100% !important;
    box-sizing: border-box !important;
    display: block !important;
    margin: 0 auto !important;
    font-size: 11.5px;
}

/* 3. Total Weighted Score pills centering */
.matrix-table tfoot td span.pill {
    display: inline-flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    max-width: 60px; /* Keeps the pill shape professional */
}

.matrix-notes-auto {
    border: 1px solid var(--panel-border);
    min-height: 40px;
    height: auto;
    overflow: hidden;
    line-height: 1.1; 
    resize: none; 
    padding: 4px; 
    border-radius: 4px;
    font-family: inherit;
}

/* ============================================================
   TASK BLUEPRINTS
   ============================================================ */

/* Styling for the Task Blueprint Title Input */
.modal-title-input {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-bright);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 4px 8px;
    width: 100%;
    margin-left: -8px; /* Aligns text with the label below */
    transition: all 0.2s ease;
}

.modal-title-input:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--line);
}

.modal-title-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}

/* ============================================================
   TASK CHECKLIST UI
   ============================================================ */
.task-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.task-card {
    background: var(--panel-soft);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.task-card horizonta-row {
  border: 1px solid var(--panel-border); 
  padding: 8px 12px; 
  border-radius: 6px; 
  margin-bottom: 6px; 
  display: flex; 
  align-items: center; 
  gap: 16px; 
  transition: all 0.2s ease;
  position: relative;
}

.task-single-column {
  max-width: 800px; margin: 0 auto;
}

.task-card:hover { border-color: var(--accent); }

.task-card.is-done {
    opacity: 0.5;
    background: rgba(16, 185, 129, 0.05);
}

.task-card.is-done .task-name {
    text-decoration: line-through;
}

.task-main { display: flex; align-items: center; gap: 15px; flex: 1; }

.task-name { font-weight: 600; font-size: 13px; }

.task-name is-clickable {
  font-weight: 500; font-size: 13.5px; flex: 1; min-width: 200px; white-space: nowrap;
}

/* The Special SOP Link Button */
.btn-guide-link {
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid var(--accent);
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 700;
}

.btn-guide-link:hover {
    background: var(--accent);
    color: var(--text-main);
}

/* ============================================================
   TASK CHECKLIST STYLING
   ============================================================ */
.task-row {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 16px;
    background: var(--panel-soft);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.task-row:hover {
    border-color: var(--accent);
}

.task-row.is-complete {
    opacity: 0.6;
}

.task-row.is-complete .task-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

.task-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.task-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    outline: none;
}

.task-meta {
    margin-top: 6px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.tiny-select {
    background: var(--panel-soft);
    color: var(--text-dim);
    border: 1px solid var(--panel-border);
    font-size: 11px;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    outline: none;
    max-width: 180px;
}

.tiny-select:hover {
    border-color: var(--accent);
    color: var(--text-main);
}

.modal-input, .form-control, .ghost-input {
    background: var(--panel-soft);
    color:  var(--text-main);
    border: 1px solid var(--panel-border);
    padding: 6px 10px;
    outline: none;
    transition: all 0.2s ease;
}

.modal-input.tiny {
    font-size: 12px;
    padding: 4px 8px;
    text-align: center;
}

/* ============================================================
   CREDENTIAL VAULT & REVEAL LOGIC
   ============================================================ */

.reveal-box {
    cursor: pointer;
    padding: 4px 8px;
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    display: inline-block;
    min-width: 100px;
    transition: background 0.2s;
}

.reveal-box:hover {
    background: rgba(56, 189, 248, 0.1);
}

.reveal-box .visible-val { display: none; }
.reveal-box .hidden-val { display: inline; color: var(--text-muted); }

.reveal-box.revealed .visible-val { display: inline; color: var(--accent); }
.reveal-box.revealed .hidden-val { display: none; }

/* Credential specific status colors */
select.perm-select[value="Verified"] { color: var(--success); }
select.perm-select[value="Invalid"] { color: var(--danger); }

/* ============================================================
   HOW-TO LIBRARY SHARING STYLES
   ============================================================ */

.card.is-shared {
    border: 1px solid var(--success);
    background: linear-gradient(145deg, var(--panel-soft), rgba(16, 185, 129, 0.05));
}

.card.is-private {
    border: 1px solid var(--panel-border);
    opacity: 0.9;
}

.rich-text {
    line-height: 1.7;
    font-size: 14px;
}

.rich-text h3 {
    color: var(--accent);
    margin-top: 20px;
    font-size: 16px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 5px;
}

/* Make sure images in guides don't break the modal */
.rich-text img {
    max-width: 100%;
    border-radius: 8px;
    margin: 15px 0;
    border: 1px solid var(--line);
}

/* ============================================================
   3. SHARED MODAL SYSTEM ENHANCEMENTS
   ============================================================ */

#modal-layer {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-box {
    width: 100%;
    max-width: 640px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: 0 32px 64px rgba(0,0,0,0.5);
    overflow: hidden;
    animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-head {
    padding: 20px 24px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    gap: 15px;
}

.modal-title-text {
    font-size: 18px;
    font-weight: 700;
    outline: none;
    color: var(--text-main);
}

.modal-body {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-column {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.spacer { flex: 1; }

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6); /* Dim the background */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: pointer; /* Hint that clicking here closes it */
}

.modal-box {
    cursor: default; /* Prevent the close-click from inside the box */
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
}

/* Style for the editable icon box in the list */
.icon-edit-box {
    font-size: 18px; 
    cursor: pointer; 
    width: 36px; 
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.3); 
    border-radius: 6px;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.icon-edit-box:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
}

/* Style for the quick-select emoji grid */
.emoji-option {
    background: var(--bg);
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    padding: 8px;
    text-align: center;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.emoji-option:hover {
    background: var(--panel-soft);
    border-color: var(--accent);
    transform: scale(1.1);
}

/* ============================================================
   4. FORM ELEMENTS
   ============================================================ */

.modal-select, .modal-textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    padding: 10px 12px;
    border-radius: 8px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.modal-select:focus, .modal-textarea:focus {
    border-color: var(--accent);
}

.modal-section-label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 0.1em;
    margin-bottom: 8px;
    margin-top: 25px;
}

/* ============================================================
   VAULT MANAGER STYLING
   ============================================================ */

.vault-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.pill.vault-gold {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid var(--vault-gold);
    color: var(--vault-gold);
}

/* Vault Header Indicator */
.active-vault-badge {
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid var(--vault-gold);
    color: var(--vault-gold);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 800;
}

/* ============================================================
   MULTI-SELECT PILL STYLING
   ============================================================ */

.pills-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px; /* Increased gap to account for rounded corners */
    padding: 4px 0;
    margin-top: 8px;
}

.pill, .invisible-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    
    /* Rounded Shape */
    border-radius: 20px; 
    
    /* Padding: Top/Bottom 4px, Left/Right 12px */
    padding: 4px 12px; 
    
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    transition: all 0.2s ease;
    border: 1px solid;
    user-select: none;
}

.tiny {
    font-size: 10px;
}

.btn.tiny {
    padding: 2px 6px !important;
    height: 20px;
    line-height: 1; /* Prevents text from pushing the height out */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.invisible-pill {
  border: transparent;
}

.pill.vault-gold:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
    text-decoration: line-through;
}

.pill[class*="status-"] {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    user-select: none; /* Prevents text highlighting while Ctrl+Clicking */
}

/* STATUS COLOR CODING */

.pill.status-primary {
    background: #a855f7 !important; /* Purple */
    color: white;
    border: 1px solid #7e22ce;
}

.pill.status-evaluating {
    background: #eab308 !important; /* Yellow */
    color: var(--text-main);
    border: 1px solid #ca8a04;
}

.pill.status-available {
    background: var(--panel-soft) !important; /* Grey/White */
    color: var(--text-dim);
    border: 1px solid var(--panel-border);
}

/* Interaction Hint */
.pill[title]:hover {
    cursor: pointer;
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* ============================================================
   SEARCH-TO-MAP UI
   ============================================================ */
.search-map-container {
    position: relative;
    width: 100%;
    margin-top: 8px;
    flex: 1;
    max-width: 400px;
}

.search-category-label {
    padding: 8px 12px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.05);
    font-weight: bold;
}

.search-map-container .modal-input {
    background-color: var(--bg) !important; /* Deeper contrast vs the panel */
    border: 1px solid var(--panel-border);
    border-radius: 12px; /* Rounded to match the pills */
    padding: 12px 16px; /* Increased internal padding */
    color: var(--text-main);
    width: 100%;
    font-size: 14px;
    transition: all 0.2s ease;
    outline: none;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); /* Subtle inner shadow */
}

.search-map-container .modal-input:focus {
    border-color: var(--accent);
    background-color: var(--panel-soft) !important;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15), 
                inset 0 2px 4px rgba(0,0,0,0.2);
}

/* Adjusting the placeholder color to be more legible but muted */
.search-map-container .modal-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
    font-size: 13px;
}

/* Adjusting the search overlay to match the new input width and style */
.search-results-overlay {
    margin-top: 10px;
    border-radius: 12px;
    background: var(--bg);
    border: 1px solid var(--accent);
    max-height: 160px; 
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.search-result-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid var(--panel-border);
}

.search-result-item:hover {
    background: var(--panel-soft);
    color: var(--accent);
}

.search-result-item.create-action {
    color: var(--accent);
    font-weight: bold;
    background: rgba(56, 189, 248, 0.05);
}

.tiny-placeholder {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.3);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.tiny-placeholder:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.05);
}

.ghost-input::placeholder {
    color: rgba(255, 255, 255, 0.2);
    font-style: italic;
}

.module-block-container {
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.module-block-container:hover {
    border-color: #fff !important;
    background: rgba(var(--accent-rgb), 0.05) !important;
}

.module-block-container .dp-manager-row {
    justify-content: flex-start !important;
}

.module-nested-steps {
    user-select: none;
}

/* Ensure the edit panel doesn't leave ghost spacing when closed */
.step-group {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.step-group:not(.is-editing) .vis-expanded-editor,
.step-group:not(.is-editing) .edit-panel-wrap {
    display: none !important;
    height: 0;
    overflow: hidden;
}

/* Fullscreen Shell */
#workflow-fs-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: #0b0e14; z-index: 999; display: flex; flex-direction: column;
    animation: fadeIn 0.2s ease-out;
}

body.fs-mode-active {
    overflow: hidden !important;
    height: 100vh;
}

.fs-body { 
    flex: 1; 
    overflow: auto !important; 
    position: relative; 
    display: block; /* Ensure it treats children as a long list */
    background: var(--bg); 
    height: calc(100vh - 60px);
}

.fs-header {
    background: var(--bg); border-bottom: 1px solid #30363d;
    padding: 15px 30px; display: flex; align-items: center; justify-content: space-between;
}

.fs-mode-toggle {
    background: var(--bg); padding: 4px; border-radius: 8px; display: flex; gap: 4px;
}

.fs-mode-btn {
    background: transparent; border: none; color: #8b949e; padding: 8px 20px;
    border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600;
}

.fs-mode-btn.active { background: var(--accent); color:  var(--text-main); }

.fs-body { flex: 1; overflow: auto !important; position: relative; }

/* Visualizer Specifics */
.vis-workspace {
    position: relative;
    overflow: visible !important;
    display: block;
    padding: 50px;
    width: 75%; 
    height: 5000px;
}

.vis-node {
    position: absolute !important; /* Essential for free movement */
    margin: 0 !important;
    cursor: grab;
    z-index: 10;
}

/* 🔷 Logic Node Styling */
.vis-node.is-logic {
    border: 2px solid var(--vault-gold) !important;
    background: rgba(251, 191, 36, 0.05) !important;
    width: 200px !important;
    border-radius: 50% / 10% !important; /* Slight diamond curve */
}

.vis-node.is-logic .vis-node-header {
    background: rgba(251, 191, 36, 0.1) !important;
    border-bottom: 1px solid var(--vault-gold);
    color: var(--vault-gold);
    justify-content: center;
}

/* 🔌 Exit Ports for Logic */
.vis-port.logic-true { color: var(--success); font-weight: 800; }
.vis-port.logic-false { color: var(--danger); font-weight: 800; }

.vis-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

/* Standard sequential path */
.vis-path.standard-path {
    stroke: var(--accent);
    stroke-width: 2;
    opacity: 0.4;
}

/* Conditional logic path */
.vis-path.logic-path {
    stroke: var(--vault-gold); /* Or your preferred logic color */
    stroke-width: 2;
    stroke-dasharray: 6, 4; /* Dashed line */
    opacity: 0.8;
}

.vis-meta-pill {
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.2);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 600;
}

.vis-resources-list {
    border-top: 1px solid var(--panel-border);
    padding: 6px 0;
    margin-bottom: 6px;
}

.vis-resource-item {
    font-size: 9px;
    color: var(--text-muted);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vis-read-only-text {
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-main);
    margin-bottom: 10px;
    white-space: pre-wrap;
}

.vis-outcome-chip {
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    color: var(--vault-gold);
    display: inline-block;
    max-width: 150px;
}

.vis-port {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
}

.vis-node-header { 
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid #444c56;
    position: relative;
    padding: 10px 30px 10px 10px;
    width: 100%;
    display: flex;
    overflow: hidden;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
    padding-right: 50px !important; /* Make room for two buttons */
}

.vis-header-actions {
    position: absolute;
    right: 5px;
    top: 5px;
    display: flex;
    gap: 2px;
    margin-left: 8px;
}

.subheader {
  padding: 8px;
}

.vis-icon-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s ease;
    opacity: 0.4;
}

.vis-node:hover .vis-icon-btn {
    opacity: 1;
}

.vis-icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.vis-icon-btn.edit:hover {
    color: var(--accent);
}

.vis-icon-btn.delete:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.vis-node-delete {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    line-height: 1;
}

.vis-node:hover .vis-node-delete {
    opacity: 0.6;
}

.vis-node-delete:hover {
    opacity: 1 !important;
    color: #ef4444; /* Standard Sphynx Danger Red */
}

.vis-idx { 
    background: var(--accent); color:  var(--text-main); width: 22px; height: 22px; 
    border-radius: 50%; display: flex; align-items: center; justify-content: center; 
    font-weight: 900; font-size: 10px; 
}

.vis-node-body { padding: 12px; }

.vis-port { 
    margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.05); 
}

.vis-arrow { font-size: 10px; color: var(--accent); margin-top: 3px; }

.vis-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%; /* SVG now covers the entire scrollable area */
    pointer-events: none;
    z-index: 1;
}

.vis-path {
    fill: none;
    stroke: var(--accent);
    stroke-width: 1.5;
    opacity: 0.4;
    transition: opacity 0.3s ease;
}

.vis-path:hover {
    opacity: 1;
    stroke-width: 2.5;
}

.vis-trigger-row {
    display: flex;
    gap: 20px;
    margin-bottom: 60px; /* Space between triggers and first step */
    z-index: 2;
}

.vis-vertical-stack {
    display: block !important; /* Kill the flexbox */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.trigger-node {
    border: 2px dashed var(--accent) !important;
    background: rgba(255, 191, 0, 0.05) !important;
    width: 260px !important;
    min-height: 60px;
    display: flex;
    flex-direction: column;
}

.trigger-header {
    background: rgba(255, 191, 0, 0.15) !important;
    border-bottom: 1px solid var(--accent) !important;
    display: flex;
    align-items: flex-start;
    padding: 10px;
}

.trigger-path {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2;
    stroke-dasharray: 5, 5; /* Dotted line for trigger entry */
    opacity: 0.6;
}

/* Ghost Inputs for Nodes */
.vis-input-ghost {
    background: transparent;
    border: none;
    color: inherit;
    font-size: inherit;
    font-weight: inherit;
    font-family: inherit;
    width: 100% !important;
    outline: none;
    text-align: left !important;
    border-bottom: 1px solid transparent;
    resize: none;
    overflow: hidden !important;   /* Hides scrollbars as it grows */
    white-space: pre-wrap !important; /* Forces text to wrap naturally */
    word-break: break-word !important; /* Breaks long words if necessary */
    line-height: 1.4 !important;
    max-width: 100% !important;   /* Prevents textarea from pushing past parent */
    overflow-wrap: anywhere !important; 
    word-wrap: break-word !important;
    display: inline-block !important;
    flex-grow: 1;
}

.vis-input-ghost:focus {
    border-bottom: 1px solid var(--accent);
}

.vis-input-tiny {
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--accent);
    font-size: 9px;
    padding: 2px 4px;
    border-radius: 3px;
    width: 80px;
}

/* Floating Action Button inside Node */
.btn-vis-add {
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color:  var(--text-main);
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
    opacity: 0;
    transition: opacity 0.2s;
}

.vis-node:hover .btn-vis-add {
    opacity: 1;
}

.vis-expanded-editor {
    background: rgba(0, 0, 0, 0.4);
    padding: 12px;
    border-bottom: 1px solid var(--panel-border);
    animation: visExpand 0.2s ease-out;
}

.vis-section-label {
    display: block;
    font-size: 8px;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.vis-description-input {
    width: 100%;
    min-height: 80px;
    background: var(--bg);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    font-size: 11px;
    padding: 8px;
    border-radius: 4px;
    resize: vertical;
    outline: none;
    line-height: 1.4;
}

.vis-description-input:focus {
    border-color: var(--accent);
}

.vis-node-footer {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

.new-link-trigger {
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: var(--accent);
    color:  var(--text-main);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: crosshair;
    font-size: 14px;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.2s;
}

.workflow-block-card:hover .new-link-trigger {
    opacity: 1;
}

.new-link-trigger:hover {
    transform: translateY(-50%) scale(1.2);
    box-shadow: 0 0 10px var(--accent);
}

/* 1. Reset Workspace to a high but manageable level */
#workflow-fs-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: #050816 !important; /* Unified background */
    z-index: 999 !important; /* Reduced from 999,999 */
    display: block;
    flex-direction: column;
}

/* 2. Elevate the Modal Layer to beat the Workspace */
#modal-layer, 
.modal-overlay, 
#active-modal-box {
    z-index: 10000 !important; /* Now double the Workspace index */
}

/* 1. The card being moved (ghost/low opacity) */
.vis-node.is-dragging-source {
    opacity: 0.3 !important;
    border: 1px dashed var(--accent) !important;
}

/* 2. THE BLUE LIGHT: The card where it will land */
.vis-node.drop-target-active {
    border-left: 3px solid #00aaff !important;
    background: rgba(0, 170, 255, 0.08) !important;
    box-shadow: -10px 0 20px rgba(0, 170, 255, 0.2);
    transform: translateX(4px);
    transition: all 0.1s ease;
}

/* 3. Prevent children from stealing focus during the drag */
.vis-vertical-stack:has(.is-dragging-source) .vis-node * {
    pointer-events: none !important;
}

#vis-links-layer {
  position: absolute;
  top:0;
  left:0;
  width: 100%;
  height: 100%;
  pointer-events: none !important;
  z-index: 1000 !important;
} 

/* Ensure the link layer is physically above the cards */
#vis-links-layer, 
#vis-links-layer-l2 {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* 🚀 CRITICAL: Let clicks pass through to cards */
    z-index: 999 !important; /* Sit above every card and container */
    overflow: visible;
}

/* Ensure the arrows themselves are visible */
#vis-links-layer path, 
#vis-links-layer-l2 path {
    pointer-events: none;
}

/* Allow rocket links to remain clickable even though the layer is 'none' */
.external-exit-link, .is-clickable {
    pointer-events: auto !important;
}

/* Ensure card wrappers don't create new stacking contexts that hide the SVG */
.wf-node-container, .wf-resource-wrapper {
    position: relative;
    z-index: 1; /* Lower than SVG */
}

.path-handle {
    fill: #00aaff;
    stroke: #ffffff;
    stroke-width: 2px;
    opacity: 0; 
    transition: opacity 0.2s, r 0.2s;
    pointer-events: auto !important; /* 🚀 CRITICAL: This allows grabbing */
    cursor: move !important;
    
    /* Add a glow so it's visible on dark backgrounds */
    filter: drop-shadow(0 0 5px rgba(0, 170, 255, 0.8));
    -webkit-user-drag: none;
    user-select: none;
    touch-action: none;
}

.vis-workspace:hover .path-handle {
    opacity: 0.5; /* Show faintly on hover */
}

.path-handle:hover {
    opacity: 1 !important;
    r: 8; /* Grow slightly on hover */
    fill: #ffffff;
    stroke: #00aaff;
}

.handle-start { fill: #10b981; } /* Green - Exit */
.handle-mid   { fill: #38bdf8; } /* Blue - Bend */
.handle-end   { fill: #f87171; } /* Red - Entry */

.editable-path {
    transition: none !important; /* Disable transitions during manual drag for performance */
}

.vis-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none !important; /* Let clicks pass through to cards */
    z-index: 1000; /* Higher than the nodes */
}

/* Show anchor points on cards when hovering the workspace */
.vis-workspace:hover .vis-node::after,
.vis-workspace:hover .vis-node::before {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    opacity: 0.3;
    z-index: 5;
}

/* Show snap points only while dragging a handle */
.vis-workspace:has(.path-handle:active) .vis-node::after,
.vis-workspace:has(.path-handle:active) .vis-node::before {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent);
    opacity: 0.4;
    z-index: 10;
}

/* Position points at the 4 centers */
.vis-node::after { top: 50%; right: -5px; transform: translateY(-50%); } /* Right */
.vis-node::before { top: 50%; left: -5px; transform: translateY(-50%); } /* Left */

/* The background grid */
.vis-swimlane-layer {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    height: 100%;
    pointer-events: none; /* Let clicks pass to cards */
    z-index: 1;
}

.vis-lane {
    height: 200px;
    display: flex;
    align-items: flex-start;
    border-right: 1px dashed rgba(255, 255, 255, 0.1);
    position: relative;
}

.vis-lane-header {
    position: sticky;
    background: rgba(11, 14, 20, 0.9);
    padding: 15px;
    text-align: center;
    border-bottom: 2px solid var(--accent);
    color: var(--accent);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 11px;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.vis-absolute-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin-top: 0;
}

/* Optional: Alternate lane backgrounds */
.vis-lane:nth-child(even) {
    background: rgba(255, 255, 255, 0.01);
}

/* Optional: Pulse effect for the indicator */
@keyframes left-pulse {
    0% { box-shadow: -5px 0 5px rgba(0, 170, 255, 0.2); }
    50% { box-shadow: -10px 0 15px rgba(0, 170, 255, 0.4); }
    100% { box-shadow: -5px 0 5px rgba(0, 170, 255, 0.2); }
}

@keyframes visExpand {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Optimization for PDF Export */

.print-mode-active textarea,
.print-mode-active .matrix-notes-auto,
.print-mode-active .modal-textarea {
    display: none !important;
}

@media print {
    /* 0. Wipe UI Noise and Artifacts */
    .sidebar, .main-header, .app-header, .btn, .card-close, .top-bar, .card-delete-btn, .header-actions,
    .local-tag, div.cards-grid, .analysis-summary-card, #modal-layer, .fs-mode-toggle, .tiny-select
    .btn-vis-add, .vis-node-delete, .vis-header-actions, .vis-detail-toggle, .drag-handle, .vis-idx,
    .search-map-container, .col-actions, .toolbar, #balance-button, textarea {
        display: none !important;
    }

    @page {
        size: auto;
        margin: 10mm; /* Force a consistent safe margin on all sides */
    }

    /* 1. Global Reset - Eliminates the Blank Page 1 */
    html, body, .main-content, #mainContent, .scoping-container, #activeAnalysisMatrix{
        width: 100% !important;
        height: auto !important;
        background: white !important;
        background-color: white !important;
        border-right: none !important; /* Hides that ghost right border */
        box-shadow: none !important;
        color: black !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
        filter: none !important; 
        backdrop-filter: none !important;
        display: block !important;
        position: relative !important;
    }

    .card {
        background: transparent;
    }

    /* 🛡️ PREVENT CROP */
    * {
        overflow: visible !important;
        -webkit-print-color-adjust: exact;
    }

    /* 🚀 CRITICAL: Hide the background app entirely so it doesn't push content down */
    #mainContent .fs-canvas { 
        display: none !important; 
    }

    .tiny-select {
        appearance: none !important;
        -webkit-appearance: none !important; /* Safari/Chrome */
        -moz-appearance: none !important;    /* Firefox */
        background-image: none !important;    /* Removes custom SVG arrows */
    }

    /* 🎯 Target the internal browser "Arrow" element specifically */
    .tiny-select::-ms-expand {
        display: none !important; /* IE/Edge */
    }

    .grid-header, .grid-row, .round-header-row, .grand-totals-bar {
        grid-template-columns: 1.5fr .8fr 100px 60px 60px 60px 0px !important;
        gap: 5px !important;
        page-break-inside: avoid;
    }

    .card, .matrix-container {
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 auto !important; /* Center horizontally */
        width: 99% !important; /* Slightly less than 100 to ensure border visibility */
        max-width: 99% !important;
        border: none !important;
    }

    div.dp-manager-row {
      border-bottom: 1px solid black !important;
      margin-bottom: 0;
      padding: 4pt auto;
    }
    
    .price-input-tiny, input, textarea {
        border: none !important;
    }

    textarea, .price-input-tiny {
        color:  var(--text-main) !important; /* Ensure high contrast for printing */
    }

    .tiny-select {
        border: none !important;
        color:  var(--text-main) !important; /* Ensure high contrast for printing */
        font-weight: bold;
    }

    #activeAnalysisMatrix {
        border-right: none !important;
    }

    .matrix-table {
        margin: 0 auto !important; /* Center the table */
        width: 99% !important; 
        table-layout: fixed !important;
        border-collapse: collapse !important;
        border: 1px solid #d3d3d3 !important;
        font-size: 11.5px;
        page-break-after: auto;
        
    }

    /* 5. Force Borders on all Cells */
    .matrix-table th, 
    .matrix-table td {
        border: 1px solid #d3d3d3 !important;
        box-sizing: border-box !important; /* Borders grow inward, not outward */
        padding: 4px !important;
    }

    /* 6. Refined Column Widths for Balance */
    .matrix-table th:first-child, 
    .matrix-table td:first-child {
        width: 30% !important; /* Reduced to give more breathing room to right side */
        word-break: break-word !important;
    }

    .matrix-table th:nth-child(2), 
    .matrix-table td:nth-child(2) {
        width: 65px !important; /* Tighten weight column */
    }

    /* 7. Input Alignment */
    .tiny-input, .matrix-score-input {
        width: 100% !important;
        text-align: center !important;
        border: none !important;
        background: transparent !important;
        font-family: inherit !important;
        font-size: 10pt !important;
    }

    /* 8. Categorization Headers - Ensure they span correctly */
    .category-header-row td {
        background-color: var(--bg) !important;
        -webkit-print-color-adjust: exact; /* Ensure background prints */
    }

    /* 1. Prevent the table footer from repeating on every page */
    .matrix-table tfoot {
        display: table-row-group !important;
    }

    /* 2. Force the footer to stay attached to the bottom of the table data */
    .matrix-table tfoot tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    /* 3. Ensure the summary box doesn't get split across pages */
    .executive-summary-wrapper {
        page-break-inside: avoid;
        margin-top: 30px;
    }

    .matrix-final-footer {
        position: relative;
        margin-top: 50px;
        page-break-inside: avoid;
        display: block !important;
    }
    
    /* Hide the placeholder text during print */
    .matrix-notes-auto::placeholder {
        color: transparent;
        opacity: 0 !important;
    }
    
    .matrix-notes-auto, 
    .modal-textarea,
    .executive-summary-wrapper textarea {
        display: block !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        line-height: 1.4 !important;
        white-space: pre-wrap !important; /* This preserves your line breaks */
        background: transparent !important;
        color:  var(--text-main) !important; /* Ensure high contrast for printing */
        -webkit-print-color-adjust: exact;
    }

    /* Force the parent wrapper to expand to the child's height */
    .executive-summary-wrapper,
    .matrix-card-main {
        height: auto !important;
        overflow: visible !important;
        display: block !important;
        page-break-inside: auto !important;
    }

    matrix-card-main {
        zoom: 0.85; /* Adjust this percentage if it still cuts off horizontally */
        transform-origin: top left;
    }

    /* Ensure table cells don't constrain the height */
    .matrix-table td {
        height: auto !important;
        vertical-align: top !important;
    }

    /* 4. Hide scrollbars on the main containers */
    .matrix-interaction-wrapper,
    .matrix-card-main,
    #activeAnalysisMatrix {
        overflow: visible !important;
        height: auto !important;
        display: block !important;
    }

    /* 5. Hide the actual scrollbar track in Webkit browsers */
    ::-webkit-scrollbar {
        display: none !important;
    }

    .print-placeholder {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        border: none !important;
        background: transparent !important;
        color:  var(--text-main) !important;
        font-family: inherit;
        font-size: 11px;
        line-height: 1.4;
        margin: 0;
        padding: 5px 0;
        page-break-inside: avoid; /* Prevents a single note from splitting mid-sentence if possible */
        text-align: left;
    }

    /* Executive summary placeholder should be larger */
    .executive-summary-wrapper .print-placeholder {
        padding: 10px 0;
        page-break-inside: auto; /* Allows summary to span pages */
    }

    /* Hide empty placeholders so they don't take up space */
    .print-placeholder:empty {
        display: none !important;
    }

    /* 2. Force the Workspace to the very top */
    #workflow-fs-overlay {
        position: absolute !important; 
        top: 0 !important;
        left: 0 !important;
        display: block !important;
        width: 100% !important;
        height: auto !important;
        background: white !important;
        box-shadow: none !important;
        z-index: 9999 !important;
    }

    /* 🚀 3. HIDE ALL ARROWS */
    #vis-links-layer, .vis-path, .trigger-path {
        display: none !important;
    }

    .vis-workspace {
        position: relative !important;
        display: block !important;
        background: white !important;
        padding: 5mm 0 !important;
        margin: 0 auto .5cm auto !important;
        width: 100% !important;
    }

    .vis-trigger-row {
        display: flex !important;
        justify-content: center !important;
        gap: 5mm !important;
        margin-bottom: 0 !important; /* This controls space below triggers */
    }

    .vis-vertical-stack {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 0 !important;
        margin-bottom: 0;
    }

    .vis-expanded-editor, 
    .module-nested-steps, 
    .vis-outcomes-area,
    .edit-panel-wrap {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .vis-input-ghost, .modal-textarea, .modal-input {
        border: none !important;
        padding: 0 !important;
        background: transparent !important;
        resize: none !important;
        overflow: visible !important;
        color: var(--text-main) !important;
        font-size: 10pt !important;
    }

    /* 🚀 4. REFINED CARDS - Centered and Slimmed Down */
    .vis-node {
        border: 1px solid #000 !important; 
        border-radius: 10px; 
        background: #fff !important;
        box-shadow: none !important; 
        filter: none !important; 
        break-inside: avoid !important;
        page-break-inside: avoid !important;
        
        /* Centering and Width control */
        margin: 0 auto .5cm auto !important; 
        width: 50% !important; /* Narrower for a manual/book look */
        max-width: 500px !important; 
        position: relative !important;
    }

    .vis-node-header {
        background: #f5f5f5 !important;
        border-radius: 10px 10px 0 0; 
        border-bottom: 1pt solid #000 !important;
        -webkit-print-color-adjust: exact;
    }

    /* 5. TIGHTEN INTERNAL DATA */
    .vis-node-body {
        padding: 10px 15px !important;
        font-size: 10pt;
        font-family: inherit;
    }

    .vis-port {
        padding: 4px 0 !important;
        border-top: 0.5pt solid #eee !important;
    }

    .vis-outcome-chip {
        padding: 2px 6px !important;
        border: 0.5pt solid #ccc !important;
        background: transparent !important;
        -webkit-print-color-adjust: exact;
    }

    .vis-outcome-label-text {
        display: block !important;
        font-size: 10pt !important;
        text-align: right !important;
    }

    .step-group, .vis-node {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        border: 1pt solid #eee !important;
        margin-bottom: 5pt;
    }

}
/*=========== GLOBAL MAP ==============*/
/*==================================================================
  1. CORE LAYOUT (Screen Fitting)
==================================================================*/
/* 🔒 Lock the screen ONLY when the visualizer is active */
body.fs-mode-active {
    overflow: hidden !important;
}

body.is-visualizer #mainContent {
    padding: 10px 10px 40px 0 !important; height: 100%; width: 100%; overflow: hidden;
}

/* Ensure the scoping grid itself doesn't trap the scroll */
.scoping-grid, .rounds-container {
    overflow: visible !important;
}

.three-pane-layout {
    display: grid !important;
    /* [Sidebar] [Central Canvas] [Inspector] */
    grid-template-columns: 240px 1fr 0px; 
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ☀️ When Inspector is Open */
.three-pane-layout:not(.zen-mode-active) {
    grid-template-columns: 240px 1fr 380px;
}

/* 🌙 When Sidebar is Collapsed */
.three-pane-layout:has(.sidebar.collapsed) {
    grid-template-columns: 0px 1fr 0px;
}

.three-pane-layout:has(.sidebar.collapsed):not(.zen-mode-active) {
    grid-template-columns: 65px 1fr 380px;
}

/* 🎨 THE CANVAS AREA (Slot 2) */
#mainContent, .v2-workbench-shell, .pane-canvas-wrap {
    flex: 1;
    grid-column: 2;
    position: relative;
    height: 100%;
}

.v2-workbench-shell, .pane-canvas-wrap, body.view-workbench {
    overflow:hidden;
    width: 100%;
}

/*==================================================================
  2. LEFT SIDEBAR (The Workflow Library Toolbox)
==================================================================*/
.pane-drawer {
    display: flex;
    flex-direction: column;
    position: relative;
    flex: 0 0 auto !important;
    width: 280px;
    max-width: 40%;
    height: 100vh;
    border-right: 1px solid rgba(109, 108, 108, 0.1);
    overflow: hidden;
}

.pane-drawer.light-mode {
    background: rgb(242, 245, 247);
}

.sidebar-resizer {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 10px; /* Wider hit area */
    height: 100%;
    cursor: col-resize;
    z-index: 99999 !important; /* Above everything else */
    background: transparent;
    transition: background 0.2s, box-shadow 0.2s;
}

/* 2. SPECIFIC PLACEMENT */
/* Handle for the LEFT toolbox (on its right edge) */
#pane-drawer .sidebar-resizer {
    right: -5px;
}

/* 2. SPECIFIC PLACEMENT */
/* Handle for the LEFT toolbox (on its right edge) */
#pane-drawer .sidebar-resizer {
    right: -5px;
}

/* 1. Transition for smooth sliding */
.pane-drawer, .pane-inspector {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease;
}

/* 2. Zen Mode State */
.zen-mode-active .pane-drawer {
    transform: translateX(-100%);
    margin-right: -280px; /* Adjust based on your width variable */
}

.zen-mode-active .pane-inspector {
    transform: translateX(100%);
    margin-left: -450px; /* Adjust based on your width variable */
}

/* Hide the resizer handles while in Zen mode to prevent "ghost" dragging */
.zen-mode-active .sidebar-resizer {
    display: none !important;
}

/* Handle for the RIGHT inspector (on its left edge) */
#inspector-panel .sidebar-resizer {
    position: absolute; left: -4px; /* Hang 4px into the canvas area */ top: 0; width: 8px; height: 100%; cursor: col-resize; z-index: 10001; /* Higher than canvas icons */  background: transparent;
}

/* 3. VISUAL GRABBER (The "Line") */
.sidebar-resizer::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    background: rgba(255, 255, 255, 0.1); /* Subtle default line */
    transform: translateX(-50%);
}

/* 4. HOVER & DRAG STATES */
.sidebar-resizer:hover::after, 
.sidebar-resizer.is-dragging::after {
    background: var(--accent); /* Lights up blue when hovering */
    box-shadow: 0 0 10px var(--accent);
}

.sidebar-resizer:hover {
    background: rgba(56, 189, 248, 0.05); /* Very subtle glow area */
}

.drawer-header {
    padding: 5px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-shrink: 0;
    flex-direction: column;
    max-height: 100vh;
}

.drawer-tools {
    flex: 1;
    overflow-y: auto; /* 🚀 This fixed your "uh oh" overflow */
    padding: 15px 10px 15px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 60%;
}

.draggable-workflow-item {
    display: flex;
    flex-direction: row;
    align-items: flex-start; /* Keeps icons at the top while text grows down */
    gap: 12px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    cursor: grab;
    margin-bottom: 8px;
    
    /* 🚀 THE "I DON'T CARE" GROWTH ENGINE */
    width: 100% !important;
    white-space: normal !important; /* Forces wrapping */
    overflow: visible !important;   /* No clipping allowed */
}

/* Lane 2: The Text */
.draggable-workflow-item span:nth-child(2) {
    flex: 1;
    font-size: 12px;
    line-height: 1.5; /* Breathable spacing between wrapped lines */
    color: var(--text-main);
    word-break: break-word; /* Prevents one long word from breaking the sidebar */
    display: block;
}

/* Lane 3: The Action Buttons */
.item-actions {
    display: none; 
    flex-shrink: 0;
    padding-top: 2px;
}

.draggable-workflow-item:hover .item-actions {
    display: flex;
}

/* 🧱 Factory Block Styling */
.draggable-factory-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 8px;
    cursor: grab;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.8);
}

/* Hover effect to show it's interactive */
.draggable-factory-item:hover {
    background: rgba(56, 189, 248, 0.08);
    border-color: var(--accent);
    color:  var(--text-main);;
    transform: translateX(4px);
}

/* Specific styling for Triggers */
.draggable-factory-item.trigger {
    border-left: 3px solid #ffbf00;
}

/* Specific styling for the Action Builder Drag button */
.draggable-factory-item.action {
    border-left: 3px solid var(--accent);
    justify-content: center;
    background: rgba(56, 189, 248, 0.1);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 800;
}

.draggable-factory-item:active {
    cursor: grabbing;
    opacity: 0.6;
}

.lib-btn {
    background: transparent;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 16px;
    padding: 0;
}

#toolbox-search {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    height: 32px;
    font-size: 11px;
}

#toolbox-search:focus {
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.4);
}

.drawer-header h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
}
/* Ensure lanes are visually distinct */
.vis-lane:nth-child(even) {
    background: rgba(255,255,255,0.01);
}

.filter-bar {
  display: flex; gap: 10px; margin-bottom: 25px; padding-left: 5px;
}

.filter-pill {
    padding: 3px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-dim);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.filter-pill:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.filter-pill.active {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent);
}

/* Hide scrollbar on the pill bar but keep scrolling active */
.filter-pill-bar::-webkit-scrollbar {
    display: none;
}
.filter-pill-bar {
    -ms-overflow-style: none;
    scrollbar-width: none;
    display: flex;
    flex-wrap: wrap;
}

/*==================================================================
  3. VERTICAL TIMELINE CANVAS (Stages & Workflows)
==================================================================*/
.global-canvas-wrapper {
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

/* Allow the plus buttons to "hang" off the edge of the columns */
.macro-stage-col {
    overflow: visible !important;
}

.wf-global-node {
    transition: transform 0.2s, border-color 0.2s;
}

.wf-global-node:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}

/* Ensure the Global View can scroll sideways */
.global-macro-layout .pane-canvas-wrap {
    overflow-x: auto;
}

.global-scroll-canvas {
    flex-grow: 1;
    overflow-x: auto; /* Horizontal scroll happens here */
    overflow-y: auto; /* Vertical scroll happens here */
    padding-bottom: 50px;
}

.canvas-header {
    flex-shrink: 0; /* Ensures header never squishes */
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
}

/* Style for the horizontal columns */
.global-macro-map {
    position: relative;
    display: flex;
    gap: 40px;
    padding: 60px;
    min-width: max-content;
    min-height: 100vh;
}

.asset-mini-card {
    transition: background 0.2s;
    cursor: zoom-in;
    overflow: visible !important;
    width: 100%;
    box-sizing: border-box;
}

.asset-mini-card:hover {
    background: rgba(56, 189, 248, 0.1);
}

.vertical-stage-canvas {
    flex: 1;
    overflow-y: auto;
    padding: 40px 20px 100px 60px; /* Left padding for connectors */
    position: relative;
}

.breadcrumb-trail {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
}

.breadcrumb-item {
    color: var(--text-dim);
    cursor: pointer;
    transition: color 0.2s;
}

.breadcrumb-item:hover {
    color: var(--accent);
    text-decoration: underline;
}

.breadcrumb-current {
    color: var(--accent);
}

.stage-container {
    margin-bottom: 50px;
    position: relative;
}

.stage-header-row {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 0;
}

.stage-number {
    position: absolute;
    left: -45px;
    background: var(--accent);
    color:  var(--text-main);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 12px;
    z-index: 2;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.stage-name {
    font-weight: 800;
    color:  var(--text-main);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 14px;
}

.stage-name[contenteditable="true"] {
    cursor: text;
    padding: 2px 5px;
    border-radius: 4px;
    transition: background 0.2s;
}

.stage-name[contenteditable="true"]:hover {
    background: rgba(255, 255, 255, 0.05);
}

.stage-name[contenteditable="true"]:focus {
    background: rgba(var(--accent-rgb), 0.1);
    outline: 1px solid var(--accent);
}

.stage-delete-x:hover {
    transform: scale(1.2);
}

.stage-header-row:hover .stage-delete-x {
    opacity: 0.6; /* Makes the X visible when hovering over the header */
}

.stage-delete-x {
    cursor: pointer;
    padding: 0 8px;
    opacity: 0.2;
    font-weight: bold;
    font-size: 16px;
    transition: all 0.2s;
}

.stage-delete-x:hover {
    opacity: 1;
    color: #ef4444;
    transform: scale(1.3);
}

.stage-header-row:hover .stage-delete-x {
    opacity: 0.5;
}

.stage-container {
    transition: transform 0.2s, box-shadow 0.2s;
}

.stage-container[draggable="true"]:active {
    cursor: grabbing;
    opacity: 0.7;
}

/* Unified Vertical Container for Level 1, 2, and 3 */
.stage-workflow-stream, 
.lane-workflow-stream {
    display: flex;
    flex-direction: row; 
    flex-wrap: wrap;     
    gap: 12px;
    min-height: 100px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.01);
    border-radius: 8px;
    border: 1px dashed rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
}

/* Hover effect for all vertical sections */
.stage-workflow-stream.drag-over,
.lane-workflow-stream.drag-over {
    background: rgba(56, 189, 248, 0.05) !important;
    border-color: var(--accent) !important;
}

.return-to-library-zone {
    margin-right: 10px;
    margin-bottom: 20px;
    padding: 20px;
    border: 2px dashed rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    text-align: center;
    color: var(--text-dim);
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s ease;
    max-height:10%;
}

.return-to-library-zone.drag-over {
    background: rgba(239, 68, 68, 0.1);
    color: #e7e1e1;
    transform: scale(1.03);
}

.stage-workflow-stream.drag-over {
    background: rgba(56, 189, 248, 0.05) !important;
    border-color: var(--accent) !important;
}

/* 🚀 THE INTERNAL SCROLL WINDOW */
#fs-canvas-wrapper {
    flex: 1 !important;
    width: 100% !important;
    overflow: auto !important; /* This is where the scrollbars should live */
    position: relative !important;
    background: #050816;
}

#fs-canvas-wrapper.drag-over {
    background: rgba(56, 189, 248, 0.02);
}

/* Workflow Mode Specific Grid */
.grid-lane {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
}

.grid-label {
    position: sticky;
    left: 0;
    width: 140px;
    min-width: 140px;
    background: var(--bg);
    z-index: 40;
    display: flex;
    align-items: center;
    padding-left: 15px;
    font-size: 10px;
    font-weight: 800;
    color: var(--accent);
    text-transform: uppercase;
    border-right: 1px solid rgba(255,255,255,0.1);
}

.grid-drop-target {
    height: 100%;
    transition: background 0.2s;
}


/* 🚀 THE BLUE HIGHLIGHT */
.grid-drop-target.hovered {
    background: rgba(56, 189, 248, 0.15);
    box-shadow: inset 0 0 15px rgba(56, 189, 248, 0.2);
}

.drop-placeholder {
    width: 280px;
    height: 60px;
    background: rgba(56, 189, 248, 0.05);
    border: 2px dashed var(--accent);
    border-radius: 8px;
    margin: 5px auto;
    pointer-events: none; /* Crucial: so it doesn't interfere with drag events */
    transition: all 0.2s ease;
}

.grid-content-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let the drop hits the target cells */
}

.grid-snapped {
    pointer-events: auto; /* Re-enable for cards */
}

/* 📏 Fix for Tier 3 Vertical Alignment */
.vertical-lifecycle-mode .stage-container {
    height: auto;
    min-height: 200px; /* Gives plenty of room to drop */
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
}

.vertical-lifecycle-mode .stage-workflow-stream {
    display: flex;
    flex-direction: column;
    align-items: center; /* Centers the stack */
    justify-content: flex-start;
    gap: 15px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.02); /* Subtle visual area */
    border: 1px dashed rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    flex-grow: 1; /* Allows container to expand with content */
}

/* Ensure cards take up the correct space in the center */
.vertical-lifecycle-mode .workflow-block-card {
    display: block;
    width: 320px; /* Fixed width for consistent columns */
    position: relative !important; /* Overrides any accidental absolute positioning */
    margin: 0 auto;
    transform: none;
}

.loose-step {
    background: rgba(15, 23, 42, 0.4) !important;
    border: 1px dashed rgba(56, 189, 248, 0.3) !important;
    margin: 8px 0;
    border-left: 4px solid #64748b !important; /* Muted Slate */
    border-radius: 6px;
    opacity: 0.9;
}

.loose-step:hover {
    border-color: #38bdf8 !important;
    background: rgba(15, 23, 42, 0.8) !important;
}

/* 👁️ Hide logic icons on loose steps by default */
.loose-step-card .logic-trace-icon {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease;
}

/* 🔦 Show icons on hover */
.loose-step-card:hover .logic-trace-icon {
    opacity: 0.6;
    transform: scale(1);
}

.loose-step-card .logic-trace-icon:hover {
    opacity: 1;
    color: var(--accent);
}

.drop-zone {
    height: 4px;
    transition: height 0.2s, background 0.2s;
    margin: 2px 0;
}

.drop-zone.active {
    height: 20px;
    background: rgba(56, 189, 248, 0.1);
    border: 1px dashed #38bdf8;
}

/*==================================================================
  4. WORKFLOW CARDS
==================================================================*/
.workflow-block-card * {
    pointer-events: none; /* 🚀 CRITICAL: Forces the drop to hit the card, not the text */
}

.l1-workflow-node .tiny {
    line-height: 1.2;
    letter-spacing: 0.01em;
}

/* Optional: Make the card slightly taller if logic is present to avoid crowding */
.l1-workflow-node {
    min-height: 65px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.workflow-block-card {
    pointer-events: auto !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 50px;
    width: 280px;
    /* Prevent shrinking */
    flex-shrink: 0; 
    border: 1px solid white;
    border-radius: 8px;
    padding: 8px 12px;
    gap: 4px;
}

.workflow-block-card .bold.accent {
    font-size: 11.5px !important;
    line-height: 1.2;
}

.workflow-block-card .tiny.muted {
    font-size: 9px !important;
}

.workflow-block-card:hover {
    border-color: var(--accent);
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
 }

.workflow-block-card:active {
    cursor: grabbing;
}

.workflow-block-card.dragging {
    opacity: 0.1;
    transform: scale(0.95);
}

.workflow-block-card.active-node {
    border-color: var(--accent) !important;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
    background: rgba(56, 189, 248, 0.05) !important;
}

.workflow-block-card.grid-snapped {
    width: 240px !important; /* Slightly narrower than the 280px column */
    min-height: 80px;
    /* Pinned to top-left of its calculated grid coordinate */
    transform: none;
    margin: 0;
}

.draggable-workflow-item .btn-icon-only {
    display: none;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: white;
}

.draggable-workflow-item:hover .btn-icon-only {
    display: block;
}

.draggable-workflow-item .btn-icon-only:hover {
    background: var(--accent);
    color:  var(--text-main);;
}

/* Placeholder highlight when dragging over a stage */
.stage-workflow-stream.drag-over {
    background: rgba(56, 189, 248, 0.08) !important;
    border: 2px solid var(--accent) !important;
    box-shadow: inset 0 0 20px rgba(56, 189, 248, 0.1);
}

.grid-column-marker {
    transition: background 0.15s ease;
    pointer-events: none; /* Let the drop hit the wrapper */
}

.grid-column-marker.hovered {
    background: rgba(56, 189, 248, 0.15) !important;
    box-shadow: inset 0 0 15px rgba(56, 189, 248, 0.1);
    border: 1px solid var(--accent);
}

/* Add this to ensure the blue preview is always visible */
#grid-snap-preview {
    z-index: 2000 !important;
    pointer-events: none;
}

/* Add to your stylesheet */
.external-exit-link:hover .exit-label-bg {
    fill: rgba(16, 185, 129, 0.15) !important;
    stroke-width: 1.5px !important;
    filter: drop-shadow(0 0 5px rgba(16, 185, 129, 0.4));
}

.external-exit-link:hover text {
    fill: #fff !important;
    text-shadow: 0 0 5px var(--success);
}

#vis-links-layer {
    pointer-events: none; /* Ignore the empty space */
}

#vis-links-layer .is-clickable {
    pointer-events: auto; /* 🚀 ENABLE clicks for specifically marked groups */
}

.resource-description {
    max-width: 250px;
    text-wrap: wrap;
    font-size: 11px;
}

/* 🏷️ Updated Mini-Map Styles */
.mini-node {
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 10px; /* 🟢 Smaller font */
    background: var(--panel-soft);
    border: 1px solid var(--line);
    line-height: 1.2;
    text-align: center;
    word-wrap: break-word;
    white-space: normal; /* 🟢 Allows wrapping */
    width: 100px; /* 🟢 Fixed width ensures they wrap rather than stretch */
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-map-container {
    position: relative; /* Necessary for the expand button positioning */
    background: rgba(0,0,0,0.2); 
    padding: 20px 15px; 
    border-radius: 8px; 
    border: 1px solid rgba(255,255,255,0.05);
}

.mini-node-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    width: 100%;
}

.mini-icon-circle {
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.mini-node.active .mini-icon-circle {
    background: rgba(56, 189, 248, 0.2);
    border: 1px solid var(--accent);
}

.mini-node.active {
    transform: scale(1.05); /* Make the current step pop slightly */
}

.mini-arrow {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.2);
    font-family: monospace;
}

.mini-logic-label {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel-dark);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-size: 7px;
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    text-transform: uppercase;
    font-weight: bold;
    z-index: 5;
    letter-spacing: 0.05em;
}

.mini-arrow {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.15);
    line-height: 1;
}

.expand-map-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.expand-map-btn:hover {
    opacity: 1;
}

/*=================================================================
ARROWS
===================================================================*/
/* Position the icons on the top/bottom border */
.logic-trace-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    font-size: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.logic-trace-icon:hover {
    background: var(--accent);
    color:  var(--text-main);
    transform: scale(1.3);
}

.logic-trace-icon::after {
    content: attr(data-preview);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color:  var(--text-main);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 900;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.logic-trace-icon:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-5px);
}

/* Styling for the receiver icon on the left */
.logic-trace-icon.in {
    opacity: 0.5;
    filter: grayscale(1);
    transition: all 0.2s ease;
}

.logic-trace-icon.in:hover {
    opacity: 1;
    filter: grayscale(0);
    color: var(--accent);
}

/* Ensure the glow target is centered correctly */
.atomic-step-row.is-inspecting {
    background: rgba(56, 189, 248, 0.1);
    border-radius: 4px;
}

/* Ensure the arrow starts/ends exactly at the icon */
.trace-active-icon {
    box-shadow: 0 0 8px var(--accent);
    background: var(--accent) !important;
    color:  var(--text-main) !important;
}

.logic-trace-trigger {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg);
    border: 1px solid var(--accent);
    border-radius: 4px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    z-index: 20;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.logic-trace-trigger.incoming { top: -12px; }
.logic-trace-trigger.outgoing { bottom: -12px; }

.logic-trace-trigger:hover {
    background: var(--accent);
    color:  var(--text-main);
    transform: translateX(-50%) scale(1.2);
}

/* Pulsing effect for the traced targets */
.trace-highlight-end {
    animation: logic-pulse 1.5s infinite;
}

@keyframes logic-pulse {
    0% { box-shadow: 0 0 0px var(--accent); }
    50% { box-shadow: 0 0 20px var(--accent); }
    100% { box-shadow: 0 0 0px var(--accent); }
}

/* Trace Arrow Animation */
.trace-path {
    stroke-dasharray: 8;
    animation: dash-flow 20s linear infinite;
}

@keyframes dash-flow {
    from { stroke-dashoffset: 1000; }
    to { stroke-dashoffset: 0; }
}

.logic-trace-svg {
    display: block !important;
    overflow: visible !important;
}

/* Make sure the logic icon stands out on hover */
.logic-peek:hover {
    transform: scale(1.3);
    filter: brightness(1.2);
    text-shadow: 0 0 8px var(--vault-gold);
}

/* Give the user a hint that the individual steps are clickable now */
.atomic-step-container .tiny:hover {
    background: rgba(255,255,255,0.05);
    border-radius: 2px;
}

/*==================================================================
  5. STATUS & INDICATORS
==================================================================*/
.node-status-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #050816;
    z-index: 10;
}

.status-legend {
  display:flex; justify-content: space-between; margin-bottom:12px; align-items:center; width: 100%;"
}

.status-live { background: #22c55e; box-shadow: 0 0 8px #22c55e; }
.status-draft { background: #eab308; box-shadow: 0 0 8px #eab308; }
.status-error { background: #ef4444; box-shadow: 0 0 8px #ef4444; }

/* Pulse animation for cross-highlighting */
.pulse-highlight {
    animation: blue-pulse 2s infinite;
    border: 2px solid var(--accent) !important;
}

@keyframes blue-pulse {
    0% { box-shadow: 0 0 0 0px rgba(56, 189, 248, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(56, 189, 248, 0); }
    100% { box-shadow: 0 0 0 0px rgba(56, 189, 248, 0); }
}

/* Highlight for priced items */
.asset-mini-card.is-in-scope {
    position: relative;
    background: rgba(16, 185, 129, 0.05) !important;
}

/* The "Parent" card glows blue when you are inside its steps */
.asset-mini-card.parent-active {
    border: 2px solid var(--accent) !important;
    background: rgba(56, 189, 248, 0.1) !important;
    box-shadow: 0 0 15px var(--accent-glow);
    transition: all 0.3s ease;
}

/* Selected Object Glow */
.is-inspecting, .tiny.step-active {
    outline: 2px solid var(--accent) !important;
    outline-offset: 2px;
    box-shadow: 0 0 20px var(--accent-glow) !important;
    background: rgba(56, 189, 248, 0.1) !important;
    z-index: 100 !important;
    position: relative;
}

/* Parent Highlighting (when inspecting a step inside a resource) */
.parent-active {
    border: 2px solid var(--accent) !important;
}

/* 1. Workflow Node (The Large Container) */
.wf-global-node.is-inspecting {
    outline: 2px solid var(--accent) !important;
    background: rgba(56, 189, 248, 0.08) !important;
    box-shadow: 0 0 15px var(--accent-glow) !important;
}

/* 2. Resource Card (The Middle Tier) */
.asset-mini-card.is-inspecting {
    outline: 2px solid #fff !important; /* Use white or a brighter blue to contrast the workflow */
    outline-offset: 2px;
    background: rgba(56, 189, 248, 0.3) !important;
    z-index: 100 !important;
    transform: scale(1.02);
    margin-bottom: 2%;
}

/* 3. Atomic Step (The Text Level) */
.step-active.is-inspecting {
    background: var(--accent) !important;
    color:  var(--text-main) !important;
    border-radius: 4px;
    padding: 0 4px;
    margin: 2%;
    font-weight: bold;
}

/*==================================================================
  6. BOTTOM INVENTORY & RIGHT INSPECTOR (STABILIZED)
==================================================================*/
.pane-inventory-split {
    height: 300px;
    background: var(--bg);
    border-top: 2px solid var(--accent);
    overflow-y: auto;
}

/* 🕵️ THE INSPECTOR PANEL */
#inspector-panel {
    grid-column: 3; /* Always stay in the 3rd slot */
    height: 100vh;
    background: var(--panel);
    border-left: 1px solid var(--panel-border);
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
}

#inspector-panel.pane-inspector {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: visible !important; /* Allow resizer to hang off the edge */
}

.inspector-scroll-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    height: 100%;
    display: block;
    visibility: visible;
}

/* 2. The Invisible Resize Handle */
.inspector-resizer {
    position: absolute;
    top: 0;
    left: -4px; /* Sits exactly on the border */
    width: 8px;
    height: 100%;
    cursor: col-resize;
    z-index: 100;
    transition: background 0.2s;
}

/* Visual cue when hovering */
.inspector-resizer:hover, 
.inspector-resizer.is-dragging {
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}

.inspector-content {
    padding: 20px;
    color: white !important;
    display:flex;
    flex-direction: column;
    width: 100%;
}

/* Force text wrapping across the app */
.inspector-content, 
.asset-mini-card, 
.wf-global-node,
.atomic-step-row {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important; /* Prevents text from staying on one line */
}

/* Ensure step names in the canvas also wrap if they are too long */
.atomic-step-row span {
    display: block;
    line-height: 1.4;
}

/* Hide the horizontal scrollbar in the inspector */
.inspector-scroll-content {
    overflow-x: hidden !important;
}

.empty-inspector {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.hierarchy-selectors {
    display: flex !important;
    flex-direction: row !important; /* Switch to row */
    flex-wrap: wrap !important;     /* Allow items to wrap */
    gap: 15px !important;
    padding: 15px !important;
}

.hierarchy-selectors .form-group {
    flex: 1 1 180px; /* Each dropdown takes half space if width allows */
    min-width: 150px;
    display: flex;
    flex-direction: column; /* Stack label over select within the wrapper */
}

/* 3. Wrap long text items (titles/descriptions) */
.header-editable-input {
    word-wrap: break-word;
    white-space: normal;
    overflow-wrap: break-word;
    background:transparent; border:none; 
    color:inherit; font-size:18px; font-weight:bold; width:100%; outline:none;
}

/*==================================================================
  7. UTILITIES
==================================================================*/
.vis-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.inventory-row.active-row {
    background: rgba(56, 189, 248, 0.1) !important;
    border-left: 3px solid var(--accent);
}

/* 1. Ensure the Stage Header is the anchor for the Stage + */
.stage-header {
    position: relative; /* Anchor for the horizontal + */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid var(--accent);
    margin-bottom: 20px;
    padding-bottom: 8px;
    min-height: 50px;
}

/* 2. Position the Stage + exactly in the gutter between titles */
.insert-divider.horizontal {
    right: -35px; /* Adjust based on your gap */
    width: 30px;
    height: 30px;
    z-index: 100;
    transition: opacity 0.2s;
    padding-left: 6%;
    margin-top: 2.1%;
}

/* 3. Position the Workflow + between cards */
.wf-global-node-wrapper {
    position: relative;
    padding-bottom: 20px; /* Space for the + */
}

.insert-divider.vertical {
    position: absolute;
    left: 50%;
    width: 24px;
    height: 24px;
    z-index: 100;
    padding-top: 1%;
}

/* 4. Show controls on hover */
.stage-header:hover .insert-divider.horizontal,
.stage-header:hover .card-delete-btn,
.wf-global-node-wrapper:hover .insert-divider.vertical,
.wf-global-node:hover .card-delete-btn {
    opacity: 1 !important;
}

/*============BRAIN DUMP MAP ==============*/

:root {
    /* 🎨 Core Palette */
    --bg-main: #050816;
    --bg-panel: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #263449;
    
    /* ⚡ Accent & UI Colors */
    --accent: #38bdf8;          /* Bright Blue */
    --accent-glow: rgba(56, 189, 248, 0.4);
    --border: #334155;
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --warning: #fbbf24;         /* Gold for Merges */
}

/* 🌞 Light Mode Override */
body.light-mode {
    --bg-main: #f1f5f9;
    --bg-panel: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --border: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --accent: #0284c7; /* Darker blue for contrast on white */
    --accent-glow: rgba(56, 189, 248, 0.4);
    --danger: #ef4444;
    --warning: #fbbf24; 
}

.theme-toggle-btn {
    background: var(--bg-card); color: var(--text-main); border: 1px solid var(--border); padding: 4px 10px; font-size: 10px;
    font-weight: bold; border-radius: 4px; cursor: pointer; text-transform: uppercase; transition: all 0.2s;
}

.theme-toggle-btn:hover {
    background: var(--accent); color: var(--bg-main); border-color: var(--accent);
}

/*==============================================Main Body*/
#v2-viewport { display: flex; flex-direction: column; height: 99vh; overflow: hidden; 
              position: relative}

#v2-main-content {display: flex; flex-direction: row; flex: 1; overflow: hidden; background: var(--bg-main); }

#v2-canvas { position: relative; }

#v2-canvas-scroll-wrap { flex: 1; overflow: auto; position: relative; }

#v2-canvas-svg {overflow: visible; width: 100%; height: 100%;}

#v2-stage-layer { position: absolute; top: 0; left: 0; display: flex; height: 100vh; pointer-events: none; }

#v2-workspace {display: flex; flex-direction: column; flex: 1; position: relative; overflow: hidden;}

#map-focus-controls {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 1000;
    animation: slideDown 0.3s ease-out;
}

.btn-scope-back {
    background: var(--accent); color: white; border: none; padding: 10px 20px; border-radius: 30px;
    font-weight: bold; cursor: pointer; box-shadow: 0 4px 15px rgba(0,0,0,0.3); display: flex;
    align-items: center; gap: 8px;
}

.btn-scope-back:hover {
    background: var(--accent-hover); transform: translateY(-2px);
}

@keyframes slideDown {
    from { top: -50px; opacity: 0; }
    to { top: 20px; opacity: 1; }
}

#exit-focus-btn {
    position: fixed !important; top: 30px !important; left: 50% !important;
    transform: translateX(-50%); display: block !important; z-index: 999999 !important; /* Over everything */
    background: #ff4757; /* Bright Red/Coral */ color: white; padding: 14px 28px;
    border-radius: 50px; border: none; font-weight: 800; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    cursor: pointer;
}

/*====================================Toolbar */

#canvas-filter-input {
  align-items: center; gap: 5px; margin-left: 5px; border-left: 1px solid var(--line); padding-left: 5px;
  z-index: 999; pointer-events: auto; cursor: text;
}

#canvas-match-count {
  font-size: 10px; min-width: 30px; text-align: center;
}

.v2-node-card.search-active {
    outline: 4px solid var(--accent); box-shadow: 0 0 50px rgba(var(--accent-rgb), 0.5); transform: scale(1.05);
    transition: transform 0.3s, box-shadow 0.3s, outline 0.3s;
}

/* The outer wrapper */
.canvas-search-wrap {
    display: flex; align-items: center; background: rgba(0, 0, 0, 0.2); border: 1px solid var(--line); border-radius: 4px;
    padding: 2px 8px; min-width: 200px; flex: 1; width: 320px; pointer-events: none;
}

.search-icon {
    margin-right: 8px; font-size: 12px; opacity: 0.6;
}

.canvas-search-wrap:focus-within {
    border-color: var(--accent); background: rgba(255, 255, 255, 0.08);
}

/* The actual text input */
.v2-search-input {
    background: transparent; border: none; color: white; font-size: 12px; outline: none; width: 100%; padding: 4px 0; flex: 1; 
}

.v2-search-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

/* Ensure the master toolbar doesn't squish everything */
.v2-toolbar {
    display: flex; align-items: center; gap: 12px;
}
/*===========================================Global Shelf*/

#global-shelf { 
    min-height: 150px; max-height: 25%; background: var(--bg-panel); border-bottom: 2px solid var(--accent); transition: background 0.2s, border-color 0.2s;
    padding: 10px; display: flex; flex-wrap: wrap; gap: 10px; overflow-y: auto; z-index: 100; box-sizing: border-box;
}

#global-shelf.drag-over {
    background: var(--bg-card-hover); border-bottom-color: var(--warning); /* Change to gold when active */
}

#shelf-contents {
    display: flex; flex-direction: row;  flex-wrap: wrap;  gap: 12px; align-items: flex-start;
}

/* Make the shelf cards more compact since they are just in storage */
#shelf-contents .v2-node-card {
    position: relative !important; left: auto !important;   top: auto !important; width: 180px; flex-shrink: 0;
    margin: 0;
}

.v2-node-card.on-shelf { position: relative; left: auto !important; top: auto !important; height: fit-content; }

/* Optional: a class to show where the card will be inserted */
.shelf-drop-indicator {
    border-left: 4px solid var(--warning) !important;
}

/*==========================================Card Lanes*/

.v2-lane-section { 
    border-right: 1px dashed var(--accent-glow); position: relative; height: 100%;
    display: flex; flex-direction: column; align-items: center; padding-top: 20px; overflow: visible;
}

/* The vertical trigger zone between lanes */
.lane-insert-trigger {
    position: absolute;  right: -15px;  top: 0;   bottom: 0;   width: 30px;  display: flex;   align-items: center;  
     justify-content: center;   z-index: 60;  cursor: pointer;   pointer-events: all !important;
}

/* The actual plus button icon */
.insert-btn {
    width: 24px;   height: 24px;   border: 1px solid var(--text-main);   color: var(--text-main);   border-radius: 50%;   display: flex;
    align-items: center;   justify-content: center;   font-weight: bold;   font-size: 16px;   opacity: 0; /* Hidden by default */
    transition: opacity 0.2s, transform 0.2s;   box-shadow: 0 0 10px var(--accent-glow); position: fixed; top: 25px; padding-bottom: 5px;
}

.lane-insert-trigger:hover .insert-btn {
    opacity: 1;  transform: scale(1.2);
}

.delete-lane-btn {
    width: 18px;  height: 18px;  display: flex; align-items: center; justify-content: center; 
    background: color-mix(in srgb, var(--danger), transparent 80%); color: var(--danger); border-radius: 50%; border: none; 
    font-size: 14px; cursor: pointer; opacity: 0; transition: opacity 0.2s, background 0.2s; line-height: 1;
}

.lane-label:hover .delete-lane-btn {
    opacity: 1;
}

.delete-lane-btn:hover {
    background: var(--danger);
    color: white;
}

.lane-label { 
    color: var(--accent); font-weight: bold; background: color-mix(in srgb, var(--bg-panel), transparent 10%);
     padding: 5px 15px; border-radius: 20px; position: sticky; top: 20px; cursor: text; transition: border-color 0.2s, box-shadow 0.2s; 
     min-width: 120px; text-align: center; pointer-events: all; user-select: text; z-index: 1000; display: flex; 
     flex-direction: row; gap: 8px;
}

.lane-label:hover {
    border-color: var(--accent);  background: var(--bg-card);
}

.lane-label:focus {
    outline: none;  border-color: var(--warning);  box-shadow: color-mix(in srgb, var(--warning), transparent 70%);
}

/*====================== Node Cards */

.header-row-content { width:100%; align-items:center;}

.step-row-content { width:100%; align-items:center; display: flex; flex-direction: row; min-height: 24px;}

.v2-node-card {
    position: absolute; width: 220px; background: var(--bg-card); color: var(--text-main); overflow: visible;
    border: 1px solid var(--border); border-radius: 8px; padding: 15px; cursor: grab;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3); user-select: none; /* Prevents text selection during drag */
    transition: left 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), 
                top 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), 
                width 0.3s ease;
}

.v2-node-card:hover {
    border-color: var(--accent); background: var(--bg-card-hover); transform: translateY(-2px);
}

.v2-node-card.focused-node {
    z-index: 9999 !important; box-shadow: 0 0 30px var(--accent); border: 2px solid var(--accent);
    transform: scale(1.05); transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.v2-node-card.node-dimmed, #mainContent.canvas-dimmed .card:not(.family-focus) {
    opacity: 0.15 !important; filter: grayscale(1); pointer-events: none;
}

.v2-node-card.node-matched, #mainContent.canvas-dimmed .card.family-focus {
    opacity: 1 !important; border: 2px solid var(--accent) !important; box-shadow: 0 0 15px var(--accent-glow) !important;
}

.v2-node-card.filter-hidden {
    display: none !important; /* Completely hide non-matches */
    /* OR use opacity if you want a "ghost" look: */
    /* opacity: 0.1; pointer-events: none; */
}

/* Ensure the search-match highlight is visible */
.v2-node-card.search-match {
    border: 2px solid var(--accent) !important; box-shadow: 0 0 15px rgba(var(--accent-rgb), 0.3);
}

/* The Selection Glow */
.card.is-active {
    border-color: var(--accent) !important; box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.3), var(--shadow-lg);
    background: rgba(var(--accent-rgb), 0.05); transform: translateY(-2px);
}

/* Family Badge Polish */
.family-badge {
    display: flex; align-items: center; justify-content: center; min-width: 16px; height: 14px;
}

@keyframes pulse-gold {
    0% { box-shadow: 0 0 0 0px rgba(56, 189, 248, 0.7); }
    100% { box-shadow: 0 0 0 20px rgba(56, 189, 248, 0); }
}

.search-focus {
    border: 2px solid var(--accent) !important;  animation: pulse-gold 1.5s ease-out;  z-index: 5001; /* Ensure it's above other cards */
}

.res-name-text:hover {
    color: var(--accent); /* Turn text blue on hover to signal link */cursor: pointer;
}

/* The Milestone Glow */
.v2-node-card.is-milestone {
    border: 2px solid #fbbf24 !important; /* Vault Gold */ box-shadow: 0 0 15px rgba(251, 191, 36, 0.3) !important;
}

/* Optional: Add a little trophy or star icon to the header of milestones */
.v2-node-card.is-milestone .v2-node-header::before {
    content: "🏆"; margin-right: 8px; font-size: 14px;
}

/*==================Node Card Badges */

.header-badges-wrap {
    display: flex; gap: 8px; margin-left: auto; padding-left: 10px; flex-direction: row; margin-top: 10px;
}

.v2-scope-badge, .v2-duplicate-badge, .v2-logic-badge {
   width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
    border-radius: 4px; font-size: 10px; cursor: pointer; transition: all 0.2s;
    background: rgba(255,255,255,0.05);  border: 1px solid rgba(255,255,255,0.1);
}

.v2-scope-badge {
    color: #10b981; pointer-events: auto; text-decoration: none;
}

/* 2. 🟢 State: IS OFF (Hollow, Green Text/Border) */
.v2-scope-badge.is-off {
    background: transparent;  border: 1px solid rgba(var(--color-scoping-rgb));  color: var(--color-scoping) !important; 
    opacity: 0.6; /* Slight fade when unscoped */
}

.v2-scope-badge.is-off:hover {
    opacity: 1; border-style: solid; border-color: var(--color-scoping); background: rgba(var(--color-scoping-rgb), 0.1);
    transform: translateY(-1px);
}

/* 3. 💸 State: IS ON (Solid Green, White Text) */
.v2-scope-badge.is-on {
    background: var(--color-scoping) !important; /* Solid Green */ color: #fff !important; /* White text, overriding inherit */
    border: 1px solid var(--color-scoping); box-shadow: 0 3px 6px rgba(var(--color-scoping-rgb), 0.2); /* A gentle money shadow */
}

.v2-scope-badge.is-on:hover {
    transform: scale(1.1); filter: brightness(1.15); /* Get slightly brighter */ box-shadow: 0 5px 15px rgba(var(--color-scoping-rgb), 0.4);
}

.v2-logic-badge {
  background: var(--bg-main); color: var(--text-main); border: 1px solid var (--text-main);
}

.v2-logic-badge:hover {
    transform: scale(1.1); filter: brightness(1.15); /* Get slightly brighter */ box-shadow: 0 5px 15px var(--vault-gold);
}

.v2-logic-badge.has-logic {
    background: var(--accent) !important; color: #000 !important;  border: 1px solid var(--accent);
    box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.3); opacity: 1 !important;
}

/* Optional: Pulse effect for high-priority logic */
.v2-logic-badge.has-logic:hover {
    filter: brightness(1.2);   transform: scale(1.1);
}

.v2-duplicate-badge {
    color: var(--accent); border: 1px solid var(--accent); opacity: 0.6;
}

.v2-duplicate-badge:hover {
    background: var(--accent);  color: var(--bg-main);
}

.type-badge {border: 1px solid var(--vault-gold); opacity: 0.5; border-radius: 4px; padding-left: 3%; padding-right: 3%;}

/* ================ Logic Menu */

/* Ensure the wrapper allows absolute positioning */
.v2-logic-trigger-wrap {
    position: relative;
    display: inline-block;
}

/* The actual dropdown content */
.v2-logic-menu {
    display: none; /* Hidden by default */
    position: absolute; top: 50%; right: 0; width: 160px; background: var(--bg-card); border: 1px solid var(--accent, #38bdf8);
    border-radius: 6px; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5); z-index: 99999 !important; /* Must be higher than the node cards */
    padding: 5px 0; color: var(--text-main); pointer-events: auto !important;
}

.v2-node-card:has(.v2-logic-menu[style*="display: block"]) {
    z-index: 99998; /* Make the parent card slightly higher than others */
}

.v2-logic-menu .dropdown-item {
    padding: 8px 12px;  font-size: 11px; cursor: pointer;  white-space: nowrap;
}

.v2-logic-menu .dropdown-item:hover {
    background: rgba(56, 189, 248, 0.2);
}

.v2-logic-menu .divider {
    height: 1px; background: rgba(255,255,255,0.1); margin: 4px 0;
}

.step-logic-icon {
    font-size: 10px; font-weight: bold; background: rgba(var(--accent-rgb), 0.1);
    border: 1px solid rgba(var(--accent-rgb), 0.2); border-radius: 3px; padding: 0px 4px; line-height: 1.2;
    display: inline-block; vertical-align: middle; flex-shrink: 0; max-width: 80px; overflow: hidden; text-overflow: ellipsis;
}

.step-logic-icon.active {
  color: var(--accent);
}
/* Specific Loop Icon Style */
.step-logic-icon.loop {
    color: var(--warning);  background: rgba(255, 191, 0, 0.1); border-color: rgba(255, 191, 0, 0.3); font-size: 11px;
}

.step-logic-icon.next-step-arrow {
    opacity: 0.6; transition: opacity 0.2s; color:var(--text-muted);
}

.step-logic-icon.next-step-arrow:hover {
    opacity: 1;  color: var(--accent) !important;
}
/*=================Card Drag */

.is-dragging-node { cursor: grabbing !important; }

.is-dragging-node .v2-node-card {
    transition: none; /* Disable transitions WHILE moving for 1:1 tracking */
}

/* The ghost that shows where the card WILL land */
#drag-indicator {
    position: fixed;  width: 8px;  height: 8px;   background: var(--accent);  border-radius: 50%;  pointer-events: none;
    z-index: 999;   box-shadow: 0 0 10px var(--accent-glow);   transition: transform 0.1s ease-out;   display: none;
}

/* Hide the actual card being dragged */
.is-dragging-ghost {
    opacity: 0 !important;  pointer-events: none;
}

/* The vertical dashed line showing the insertion column */
.drop-preview-line {
    position: absolute;   width: 2px;  background:var(--accent-glow);  border-left: 2px dashed var(--accent);
    pointer-events: none;  z-index: 5;
}

/* ============================ Card Steps */

.v2-add-step-btn {
    width: 100%; margin-top: 10px; background: transparent; border: 1px dashed var(--border); color: var(--text-muted);
    font-size: 10px; font-weight: bold; text-transform: uppercase; padding: 6px; border-radius: 4px; cursor: pointer;
    transition: all 0.2s;
}

.v2-add-step-btn:hover {
    border-color: var(--accent); color: var(--accent); background: var(--accent-glow);
}

.delete-step-btn {
    opacity: 0; color: var(--danger); padding: 0 5px; font-size: 10px; transition: opacity 0.2s;
}

.v2-step-item:hover .delete-step-btn {
    opacity: 1;
}

.v2-step-badge {
    position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%) scale(1); background: var(--bg-panel); 
    color: var(--accent); font-size: 9px; font-weight: bold; padding: 2px 8px; border-radius: 10px; cursor: pointer; 
    border: 1px solid var(--accent); z-index: 100 !important; pointer-events: auto;
}

.v2-step-badge:hover {
    background: var(--accent); color: var(--bg-main); z-index: 100 !important; transform: translateX(-50%) scale(1);
}

.v2-steps-preview {
    margin-top: 25px;  border-top: 1px solid var(--border); display: none; /* Hidden by default */
    min-height: 10px; padding-top: 25px;
}

.is-expanded .v2-steps-preview {
    display: flex; flex-direction: column; width: 100%;
}

.v2-step-item {
    font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; transition: background 0.2s; 
    position: relative; background: transparent; box-sizing: border-box; pointer-events: all; cursor: pointer; min-height: 32px; 
    width: 100%;
}

.v2-step-item span {white-space: normal; word-break: break-word;}

.v2-step-item:hover {
    background: var(--accent-glow);
}

/* ================ Steps Movement */

.v2-step-item.is-dragging {
    opacity: 0.2; background: var(--accent) !important;
}

.v2-step-item.drag-over {
    border-top: 2px solid var(--accent) !important; background: rgba(var(--accent-rgb), 0.05);
}

.drag-handle:active {
    cursor: grabbing;
}

/*=================Steps Split Scissor */
/* 🧪 THE DIVIDER SCISSOR SYSTEM */
.v2-step-divider {
    height: 4px;  margin: 2px 0; position: relative; cursor: pointer; transition: all 0.2s; display: flex; align-items: center;
    justify-content: center; z-index: 10;
}

/* The Blue Line that appears on hover */
.v2-step-divider::after {
    content: ''; position: absolute; left: 10px; right: 10px; height: 2px; background: var(--accent); opacity: 0; transition: opacity 0.2s;
    box-shadow: 0 0 8px var(--accent-glow);
}

/* Hover States */
.v2-step-divider:hover::after {
    opacity: 0.6;
}

/* The Step Scissor Button */
.step-scissor {
    position: absolute; right: 15px; top: 50%; transform: translateY(-50%); cursor: pointer; opacity: 0; transition: opacity 0.2s;
    font-size: 12px; width: 20px; height: 20px; background: var(--bg-panel); border: 1px solid var(--accent); border-radius: 50%; 
    display: flex; align-items: center; justify-content: center; z-index: 1000;
}

/* The Scissor Icon */
.split-icon {
    position: absolute; font-size: 10px; background: var(--bg-panel); border: 1px solid var(--accent); border-radius: 50%; width: 18px; 
    height: 18px; display: flex; align-items: center; justify-content: center; opacity: 0; transform: scale(0.5); 
    transition: all 0.2s; z-index: 11;
}

.v2-step-item:hover .step-scissor {
    opacity: 1; z-index: 1000;
}

.v2-step-divider:hover .split-icon {
    opacity: 1;
    transform: scale(1);
}

.v2-step-item:last-child .step-scissor {
    display: none !important;
}

/* ====================  Card Parts */

.res-name-text {
  width: 100%;
}

.v2-card-part {
    font-size: 10px; background: color-mix(in srgb, var(--accent), transparent 85%); color: var(--accent); padding: 2px 6px;
    border-radius: 4px; font-weight: bold; border: 1px solid color-mix(in srgb, var(--accent), transparent 70%); 
    cursor: help; transition: all 0.2s;
}

.v2-card-part:hover {
    background: var(--accent);   color: var(--bg-main);
}

/* When a family is highlighted */
.v2-node-card.family-focus {
    box-shadow: 0 0 25px var(--accent-glow); border-color: var(--accent); z-index: 100 !important;
}

/* Dimming effect for everything else */
.canvas-dimmed .v2-node-card:not(.family-focus) {
    opacity: 0.3; filter: grayscale(0.5);  pointer-events: none;
}

/* ===================== Card Merge */

.v2-node-card.merge-ready {
    border: 2px dashed var(--warning) !important; /* Gold dashed border */  transform: scale(1.05); background: var(--accent-glow);
}

/*======================= Inspector Panel */
#v2-inspector-panel {
    width: 0; transition: width 0.3s ease; overflow: hidden; background: var(--bg-panel); border-left: var(--panel-border); 
    overflow-x: hidden; overflow-y: auto; display: flex; flex-direction: column; 
}

#v2-inspector-panel.open {
    width: 350px; right: 0;
}

/* 5. Prevent content from squishing during the slide */
#inspector-content {
    min-width: 350px;  padding: 20px; box-sizing: border-box; height: 100%; overflow-y: auto;
}

.inspector-section {
   margin-top:20px; border-top: 1px solid var(--border); padding-top: 15px;
}

.section-label {
    font-size: 10px; color: var(--accent); font-weight: bold; margin-bottom: 10px;
}

.inspector-name-input {
    background: transparent; border: none; border-bottom: 1px solid transparent; color: var(--text-main); font-size: 1.2rem;
    font-weight: bold; width: 100%; margin: 5px 0 15px 0; padding: 5px 0; transition: border-color 0.2s;
}

.inspector-name-input:focus {
    outline: none; border-bottom-color: var(--accent);
}

/*=========================== Inspector Logic */

.logic-item {
    background: var(--bg-main); border: 1px solid var(--border); border-radius: 6px; padding: 10px; margin-bottom: 8px;
    display: flex; flex-direction: column; gap: 5px; cursor: pointer;
}

.logic-item input {
    background: transparent; border: none; border-bottom: 1px solid var(--border); color: var(--text-main); font-size: 12px;
}

.add-logic-btn {
    width: 100%; background: transparent; border: 1px dashed var(--accent); color: var(--accent); border-radius: 4px;
    padding: 5px; font-size: 11px; cursor: pointer;
}

.breadcrumb {
    font-size: 10px; text-transform: uppercase; color: var(--text-muted); cursor: pointer; margin-bottom: 10px;
}

.breadcrumb:hover { color: var(--accent); }

.inspector-search-wrap input {
    width: 100%; padding: 10px; background: var(--bg-main); border: 1px solid var(--border); border-radius: 4px;
    color: var(--text-main); margin-bottom: 15px;
}

/* ================= Lines, Arrows and Icons */

#v2-connections {
    width: 100% !important; height: 100% !important; pointer-events: none;
    overflow: visible; z-index: 5; position: relative;
}

#line-group, marker {
    overflow: visible !important;
}

path {
    transition: stroke 0.2s ease, stroke-width 0.2s ease;
}

.v2-node-card:hover + #v2-canvas-svg path {
    opacity: 0.3; /* Dim others */
}

/* 🕵️ Hide labels by default */
.logic-rule-label {
    opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease; transform: translateY(5px);
}

/* 👁️ Show on hover of the container */
.logic-gate-container:hover .logic-rule-label {
    opacity: 1; transform: translateY(0);
}

/* 🎨 Optional: Make the icon pulse slightly on hover to signal it's interactive */
.logic-gate-container:hover circle {
    stroke-width: 2px; filter: drop-shadow(0 0 5px var(--accent));
}

/* Update your path styles to handle loop colors */
path[marker-end*="arrowhead"] {
    stroke-dasharray: none;
}

/* We can add a class to paths dynamically in JS or use a stroke color */
.path-is-loop {
    stroke: var(--warning) !important; stroke-dasharray: 4 2;
}
/* Loop-specific icon styling */
.is-loop-gate circle {
    stroke-dasharray: 25; /* Makes the border look slightly segmented */
}

.is-loop-gate:hover circle {
    fill: var(--warning); stroke: var(--warning);
}

.is-loop-gate:hover text {
    fill: var(--bg-main) !important;
}

/* Make the path itself gold if it's a loop */
path.is-loop-path {
    stroke: var(--warning) !important; stroke-dasharray: 4 2;
}

/* 🛠️ 1. THE FLOATING UI OVERLAY */
.v2-ui-overlay {
    position: absolute; top: 0; left: 0; width: 100%; padding: 15px 20px; z-index: 5000; pointer-events: none;
}

/* 🛠️ 2. THE MASTER TOOLBAR BAR */
.v2-master-toolbar {
    align-items: center; justify-content: flex-start; pointer-events: auto;
}

.v2-toolbar {
    align-items: center; gap: 8px; padding: 6px 12px; background: var(--panel); border: 1px solid var(--panel-border);
    border-radius: 10px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4); backdrop-filter: blur(10px);
}

.v2-master-toolbar, .v2-toolbar, .context-menu {
    pointer-events: auto !important; /* 🔥 RESTORES CLICKABILITY to buttons/selects */
    display: flex;
    gap: 10px;
}
/* 🔍 THE SEARCH INPUT INSIDE TOOLBAR */
.canvas-search-wrap {
    display: flex; align-items: center; gap: 10px; padding-right: 12px; margin-right: 4px;  border-right: 1px solid var(--line);
}

.canvas-select, .tiny-select {
    cursor: pointer;
}

.divider-v {
  width: 1px;
  border-right: 1px solid var(--line);
}

#canvas-filter-input {
    width: 160px; background: transparent; border: none; color: var(--text-main); font-size: 11px; outline: none;
}

#canvas-filter-input::placeholder {
    color: var(--text-muted); font-style: italic;
}

/* 📦 3. THE GLOBAL SHELF FIX (Prevents Overlap) */
.global-shelf-container {
    flex-shrink: 0;  z-index: 101; margin: 70px 20px 10px 20px !important;  background: var(--bg); 
    border: 2px dashed var(--accent-glow);
}

/*======================== Left Workbench Unmapped Resources */
#v2-workbench-sidebar {
    width: 0; transition: width 0.3s ease; overflow: hidden; background: var(--bg-panel); border-left: var(--panel-border); 
    overflow-x: hidden; overflow-y: auto; display: flex; flex-direction: column; z-index: 7000;
}

.workbench-header {
  padding: 20px; border-bottom: 1px solid var(--line);
}

.workbench-contents {
  flex: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; gap: 12px;
}

#unmap-zone {
  padding: 20px; text-align: center; border-top: 1px solid var(--line); font-size: 10px; opacity: 0.5;
  margin-top: auto; height: 120px; display: flex; align-items: center; justify-content: center;
}

/* 🚀 State when Workbench is OPEN */
#v2-viewport:not(.tray-closed) #v2-workbench-sidebar {
   width: 350px;
}

/* B. If Menu is COLLAPSED (Body has .collapsed class) */
body:has(.sidebar.collapsed) #v2-viewport {
    width: calc(100vw - 65px);
}

/* C. If Menu is COLLAPSED and Workbench is OPEN */
body:has(.sidebar.collapsed) #v2-viewport:not(.tray-closed) #v2-workbench-sidebar {
    left: 65px;
}

/* 🛡️ SECURITY: Ensure the Main Sidebar is ALWAYS on top of the Workbench */
.sidebar {
    z-index: 6000 !important;
}

.logic-control-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;  width: 100%;
}

.logic-delete-btn {
    background: rgba(239, 68, 68, 0.1); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.2); border-radius: 4px;
    width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; cursor: pointer;
    font-size: 16px; flex-shrink: 0;
}

.logic-delete-btn:hover {
    background: #ef4444; color: white;
}

.logic-item.is-readonly {
    background: rgba(255,255,255,0.02); opacity: 0.8;
}

#line-group path {
    stroke-dasharray: 8, 5; animation: flowLine 30s linear infinite;
}

@keyframes flowLine {
    from { stroke-dashoffset: 500; }
    to { stroke-dashoffset: 0; }
}

/* Make the arrowheads match the line color */
#arrowhead path {
    fill: var(--accent);
}

/*=================Mini Map */

/* 🏆 Milestone Styling */
.v2-node-card.is-milestone {
    border: 2px solid #fbbf24 !important; box-shadow: 0 0 20px rgba(251, 191, 36, 0.2) !important;
}

/* 🕸️ Mini-Map Grid Polish */
.mini-node {
    transition: all 0.2s ease; min-height: 50px; display: flex; align-items: center; justify-content: center;
}

.mini-node:hover {
    filter: brightness(1.2); transform: translateY(-1px);
}

.mini-node-text {
    font-size: 10px; font-weight: 600; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2;  -webkit-box-orient: vertical; 
    overflow: hidden; text-align: center;
}

.mini-arrow {
    font-size: 18px; color: var(--accent); font-weight: bold; display: flex; justify-content: center;
}

/* 🏷️ Theme-Aware Node Titles */
.v2-node-title, .mini-node-text {
    /* Uses your app's dynamic text variable */
    color: var(--text-main) !important;  font-weight: 700; white-space: normal; word-wrap: break-word;  
    display: block; width: 100%; text-align: center;
}

/* 🏆 Milestone Specific Text (Adaptive Gold) */
.is-milestone .v2-node-title, .is-milestone .mini-node-text {
    /* A gold that works in both modes - slightly brighter for dark mode */
    color: #fbbf24 !important;
}

.v2-node-header {
    min-height: 40px; height: auto !important; padding: 8px 10px; display: flex;
    flex-direction: column; align-items: center; justify-content: center;
}

/* 🚀 Adaptive Hover Tooltip */
.v2-node-header:hover .v2-node-title, 
.mini-node:hover .mini-node-text {
    overflow: visible; white-space: normal; position: absolute;z-index: 999; background: var(--card-bg, var(--bg-main));
    color: var(--text-main); padding: 8px 12px; border-radius: 6px; box-shadow: 0 10px 25px rgba(0,0,0,0.4);
     border: 1px solid var(--accent); width: max-content; max-width: 300px;  left: 50%; transform: translateX(-50%);
    top: 100%;
}

/*==================== Resource Type */
.type-editor-row {
    margin-bottom: 8px;   background: var(--panel-soft);   padding: 10px;  border-radius: 6px;   display: flex; 
    gap: 12px;   align-items: center;
}

.type-name-edit {
    font-weight: 600;   flex: 1;   cursor: text;  font-size: 12px;
}

.func-match-select {   background: var(--input-bg);  border-color: var(--line-alt);
}

.manager-footer-add {
    margin-top: 20px;   padding-top: 20px;   border-top: 1px solid var(--panel-border);
}

.add-type-form {
    display: flex;   gap: 8px;   margin-bottom: 12px;
}

.emoji-quick-grid {
    display: grid;  grid-template-columns: repeat(12, 1fr);   gap: 5px;
}

/*=============================== App Card */
.subscription-grid {
    display: flex; align-items: flex-end;  gap: 20px; margin-top: 10px;
}

.input-group {
    display: flex; flex-direction: column; gap: 6px; flex: 1;}

.fee-input-wrapper { display: flex; align-items: center;
    gap: 5px; background: var(--input-bg);  border: 1px solid var(--line); border-radius: 4px;
    padding: 0 8px; height: 27px; font-size: 12px;
}

.fee-input-wrapper input {
    border: none !important; padding: 0 !important; background: transparent !important;
    height: 100%; width: 100%;
}

/*======= Resource Comments */
/* Ensure the modal box is wide enough for a sidebar */
.modal-box {
    max-width: 900px !important; width: 90vw !important;
}

.comment-bubble {
    transition: transform 0.2s ease;
}

.comment-bubble:hover {
    background: rgba(255, 255, 255, 0.06) !important;
}
