/* ── DESIGN TOKENS ────────────────────────── */
:root {
    --bg:           #070707;
    --bg-raised:    #0e0e0e;
    --bg-card:      #131313;
    --bg-input:     #191919;
    --border:       rgba(255,255,255,0.065);
    --border-light: rgba(255,255,255,0.11);
    --text:         #fbfbf8;
    --text-dim:     rgba(251,251,248,0.90);
    --text-muted:   rgba(251,251,248,0.76);
    --primary-sidebar-width: 220px;
    --secondary-sidebar-width: 360px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* ── NAVBAR ───────────────────────────────── */
.navbar {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: 60px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background 0.3s, backdrop-filter 0.3s;
}
.navbar.scrolled {
    background: rgba(19,19,19,0.9);
    backdrop-filter: blur(16px);
}
.navbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.navbar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.02em;
}
.navbar-brand:hover { color: var(--text); }

.desktop-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.nav-link-item {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.45rem 0.85rem;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}
.nav-link-item:hover {
    color: var(--text);
    background: rgba(255,255,255,0.06);
}
.nav-user-greeting {
    color: var(--text-dim);
    font-size: 0.875rem;
    padding: 0.45rem 0.85rem;
}

/* hamburger — always visible */
.nav-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}
.nav-toggler {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
}
.nav-toggler span {
    display: block;
    width: 21px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
}

/* mobile menu */
.mobile-menu {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: 210px;
    background: var(--bg-raised);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 0.4rem;
    z-index: 9999;
    box-shadow: 0 8px 32px rgba(0,0,0,0.55);
}
.mobile-menu.open { display: block; }
.mobile-menu a,
.mobile-menu button {
    display: block;
    color: var(--text-dim);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.6rem 0.85rem;
    border: none;
    border-bottom: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    border-radius: 8px;
}
.mobile-menu a:last-child,
.mobile-menu button:last-child { border-bottom: none; }
.mobile-menu a:hover,
.mobile-menu button:hover { color: var(--text); background: rgba(255,255,255,0.055); }

/* ── DASHBOARD LAYOUT ─────────────────────── */
.dashboard-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
}
.dashboard-layout.is-resizing {
    user-select: none;
    cursor: col-resize;
}
.dash-left {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 1.5rem 2rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.dash-left::-webkit-scrollbar { width: 5px; }
.dash-left::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
.dash-sidebar {
    width: var(--primary-sidebar-width);
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    transition: width 0.18s ease, border-color 0.18s ease;
}
.dash-right {
    width: var(--secondary-sidebar-width);
    flex-shrink: 0;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    transition: width 0.18s ease, border-color 0.18s ease;
}
.dash-sidebar > *, .dash-right > * {
    min-width: 0;
    transition: opacity 0.14s ease;
}
.dashboard-layout.primary-collapsed .dash-sidebar {
    width: 0;
    border-right-color: transparent;
}
.dashboard-layout.secondary-collapsed .dash-right {
    width: 0;
    border-left-color: transparent;
}
.dashboard-layout.primary-collapsed .dash-sidebar > *,
.dashboard-layout.secondary-collapsed .dash-right > * {
    opacity: 0;
    pointer-events: none;
}
.sidebar-resizer {
    width: 14px;
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: stretch;
    justify-content: center;
    cursor: col-resize;
    touch-action: none;
}
.sidebar-resizer::before {
    content: '';
    width: 1px;
    background: var(--border);
    opacity: 0.85;
    transition: background 0.18s ease, opacity 0.18s ease;
}
.sidebar-resizer:hover::before,
.sidebar-resizer.active::before {
    background: rgba(255,255,255,0.22);
    opacity: 1;
}
.sidebar-toggle-btn {
    position: absolute;
    top: 0.9rem;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 36px;
    border-radius: 999px;
    border: 1px solid var(--border-light);
    background: var(--bg-raised);
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.68rem;
    padding: 0;
    z-index: 1;
    transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.sidebar-toggle-btn:hover {
    color: var(--text);
    border-color: rgba(255,255,255,0.28);
    background: rgba(255,255,255,0.06);
}
/* ── MACHINE PARAMETERS CARD ───────────────── */
.params-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.params-top { margin-bottom: 1.25rem; }
.params-title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text);
    margin: 0 0 0.25rem;
}
.params-desc {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin: 0;
}
.params-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0.25rem;
}
.params-grid-4 { grid-template-columns: repeat(4, 1fr); }
.params-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-dim);
    margin: 1rem 0 0.4rem;
}
.params-section-label:first-of-type { margin-top: 0; }
.param-item {
    background: var(--bg-raised);
    padding: 1rem;
}
.param-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}
.param-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.param-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}
.param-value-editing,
.params-desc-editing {
    outline: none;
    border-radius: 6px;
    background: rgba(255,255,255,0.06);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
    cursor: text;
}
.param-value-editing {
    padding: 0.05rem 0.35rem;
    min-width: 3ch;
}
.params-desc-editing {
    padding: 0.35rem 0.45rem;
    margin: -0.35rem -0.45rem;
    white-space: pre-wrap;
}
.param-unit { font-size: 0.75rem; color: var(--text-dim); }
.param-edit-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 22px;
    height: 22px;
    border-radius: 5px;
    font-size: 0.65rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, border-color 0.2s;
    flex-shrink: 0;
    margin-left: auto;
}
.param-edit-btn:hover { color: var(--text); border-color: var(--border-light); }
/* ── INLINE CHAT PANEL ─────────────────────── */
.dash-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
}
.dash-chat-header {
    padding: 0.95rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-dim);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}
.dash-chat-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}
.dash-chat-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}
.dash-chat-thread-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.dash-chat-toolbar-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, opacity 0.2s;
}
.dash-chat-toolbar-btn:hover:not(:disabled) {
    color: var(--text);
    border-color: var(--border-light);
}
.dash-chat-toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.dash-chat-thread-picker {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.dash-chat-thread-label {
    font-size: 0.67rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.dash-chat-thread-select {
    width: 100%;
    border-radius: 9px;
    border: 1px solid var(--border-light);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.82rem;
    padding: 0.5rem 0.7rem;
    outline: none;
}
.dash-chat-thread-select:disabled {
    opacity: 0.55;
}
.dash-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
}
.dash-chat-messages::-webkit-scrollbar { width: 4px; }
.dash-chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }
.dash-chat-welcome {
    margin: auto;
    text-align: center;
    padding: 1.5rem 1rem;
}
.dash-chat-welcome p {
    font-size: 0.85rem;
    color: var(--text-dim);
    line-height: 1.65;
    margin: 0;
}
.dash-msg { display: flex; flex-direction: column; max-width: 92%; }
.dash-msg.user { align-self: flex-end; }
.dash-msg.ai   { align-self: flex-start; }
.dash-msg-bubble {
    padding: 0.6rem 0.85rem;
    border-radius: 10px;
    font-size: 0.85rem;
    line-height: 1.55;
}
.dash-msg.user .dash-msg-bubble {
    background: var(--text);
    color: var(--bg);
    border-radius: 10px 10px 2px 10px;
}
.dash-msg.ai .dash-msg-bubble {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 2px 10px 10px 10px;
}
.dash-chat-input {
    padding: 0.75rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.dash-chat-inner {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    padding: 0.5rem 0.5rem 0.5rem 0.85rem;
    transition: border-color 0.2s;
}
.dash-chat-inner:focus-within { border-color: rgba(255,255,255,0.2); }
.dash-chat-textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: none;
    max-height: 136px;
    overflow-y: hidden;
    padding: 0.25rem 0;
}
.dash-chat-textarea::placeholder { color: var(--text-muted); }
.dash-send-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: var(--text);
    color: var(--bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
    transition: opacity 0.2s;
}
.dash-send-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.dash-send-btn:not(:disabled):hover { opacity: 0.85; }

/* ── FILE TREE SIDEBAR ───────────────────── */
.sidebar-header {
    padding: 0.75rem 0.9rem 0.6rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.sidebar-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-dim);
}
.sidebar-new-btn {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, border-color 0.2s;
    flex-shrink: 0;
}
.sidebar-new-btn:hover { color: var(--text); border-color: var(--border-light); }
.mode-switch {
    display: flex;
    gap: 0.35rem;
    padding: 0.55rem 0.8rem 0.65rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.mode-switch-btn {
    flex: 1;
    border: 1px solid var(--border-light);
    background: transparent;
    color: var(--text-dim);
    border-radius: 8px;
    padding: 0.35rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    cursor: pointer;
}
.mode-switch-btn.active {
    background: rgba(255,255,255,0.10);
    color: var(--text);
}
.sidebar-tree {
    flex: 1;
    overflow-y: auto;
    padding: 0.35rem 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.07) transparent;
}
.sidebar-tree::-webkit-scrollbar { width: 4px; }
.sidebar-tree::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.07); border-radius: 2px; }
.sidebar-empty {
    padding: 1.25rem 1rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    text-align: center;
    line-height: 1.6;
}
/* tree rows */
.tree-project-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.38rem 0.9rem;
    cursor: pointer;
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--text-dim);
    transition: background 0.13s, color 0.13s;
    user-select: none;
}
.tree-project-row:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.tree-project-row.active { background: rgba(255,255,255,0.07); color: var(--text); }
.tree-chevron {
    font-size: 0.55rem;
    color: var(--text-dim);
    width: 9px;
    flex-shrink: 0;
    transition: transform 0.18s;
}
.tree-project-row.open .tree-chevron { transform: rotate(90deg); }
.tree-project-children { display: none; }
.tree-project-children.open { display: block; }
.tree-folder-group { display: block; }
.tree-folder-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.9rem 0.28rem 1.7rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-dim);
    cursor: pointer;
    transition: background 0.13s, color 0.13s;
}
.tree-folder-row:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.tree-folder-row.open { color: var(--text); }
.tree-folder-row.active,
.tree-project-row.active-node,
.tree-file-row.active-node,
.tree-special-row.active-node {
    background: rgba(255,255,255,0.16);
    box-shadow: inset 3px 0 0 rgba(255,255,255,0.7), inset 0 0 0 1px rgba(255,255,255,0.12);
    color: var(--text);
}
.tree-folder-chevron {
    font-size: 0.55rem;
    color: var(--text-dim);
    width: 9px;
    flex-shrink: 0;
    transition: transform 0.18s;
}
.tree-folder-row.open .tree-folder-chevron { transform: rotate(90deg); }
.tree-folder-children { display: none; }
.tree-folder-children.open { display: block; }
.tree-inline-create {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.9rem 0.45rem 2.6rem;
}
.tree-inline-btn {
    border: 1px solid var(--border-light);
    background: rgba(255,255,255,0.04);
    color: var(--text-dim);
    border-radius: 999px;
    font-size: 0.68rem;
    padding: 0.2rem 0.65rem;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.tree-inline-btn:hover {
    color: var(--text);
    background: rgba(255,255,255,0.08);
}
.tree-special-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.24rem 0.9rem 0.24rem 2.5rem;
    font-size: 0.74rem;
    color: var(--text-dim);
    cursor: pointer;
}
.tree-special-row:hover {
    background: rgba(255,255,255,0.04);
    color: var(--text);
}
.tree-folder-count {
    font-size: 0.68rem;
    color: var(--text-muted);
    opacity: 0.9;
}
.tree-row-actions {
    display: flex;
    align-items: center;
    gap: 0.22rem;
    margin-left: auto;
    flex-shrink: 0;
}
.tree-action-btn {
    margin-left: 0;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: none;
    color: var(--text-muted);
    font-size: 0.58rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    flex-shrink: 0;
    transition: opacity 0.15s, color 0.15s;
}
.tree-project-row:hover .tree-action-btn,
.tree-folder-row:hover .tree-action-btn,
.tree-file-row:hover .tree-action-btn { opacity: 1; }
.tree-project-row:hover .tree-action-btn:hover,
.tree-folder-row:hover .tree-action-btn:hover,
.tree-file-row:hover .tree-action-btn:hover { color: var(--text); border-color: var(--border-light); }
/* drag-over highlight */
.tree-folder-row.drag-over {
    background: rgba(255,255,255,0.08);
    outline: 1px dashed rgba(255,255,255,0.3);
    outline-offset: -2px;
    border-radius: 5px;
}
.tree-project-row.drag-over {
    background: rgba(255,255,255,0.08);
    outline: 1px dashed rgba(255,255,255,0.3);
    outline-offset: -2px;
    border-radius: 7px;
}
.tree-file-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.18rem 0.9rem 0.18rem 2.5rem;
    font-size: 0.76rem;
    color: var(--text-dim);
    cursor: default;
    transition: background 0.13s, color 0.13s;
}
.tree-file-row:hover { background: rgba(255,255,255,0.035); color: var(--text); }
.tree-file-row.selected {
    background: rgba(255,255,255,0.06);
    color: var(--text);
}
.tree-file-check {
    flex-shrink: 0;
    width: 13px;
    height: 13px;
    accent-color: var(--text);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.13s;
}
.tree-file-row:hover .tree-file-check,
.tree-file-row.selected .tree-file-check { opacity: 1; }
.tree-file-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tree-file-del {
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    border-radius: 3px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 0.58rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.13s, color 0.13s;
}
.tree-file-row:hover .tree-file-del { opacity: 1; }
.tree-file-row:hover .tree-file-del:hover { color: #ff6b6b; }
/* bulk-delete bar */
.tree-bulk-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.75rem;
    background: rgba(239,68,68,0.1);
    border-top: 1px solid rgba(239,68,68,0.25);
    font-size: 0.75rem;
    color: #fca5a5;
    flex-shrink: 0;
}
.tree-bulk-bar.visible { display: flex; }
.tree-bulk-del-btn {
    background: rgba(239,68,68,0.2);
    border: 1px solid rgba(239,68,68,0.35);
    color: #fca5a5;
    border-radius: 5px;
    font-size: 0.72rem;
    padding: 0.2rem 0.6rem;
    cursor: pointer;
    font-family: inherit;
}
.tree-bulk-del-btn:hover { background: rgba(239,68,68,0.35); }
.tree-upload-bar {
    display: none;
    flex-direction: column;
    gap: 0.32rem;
    padding: 0.45rem 0.75rem;
    border-top: 1px solid rgba(79,110,247,0.35);
    background: rgba(79,110,247,0.1);
    flex-shrink: 0;
}
.tree-upload-bar.visible { display: flex; }
.tree-upload-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.74rem;
    color: #bfdbfe;
}
.tree-upload-track {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(255,255,255,0.12);
}
.tree-upload-fill {
    height: 100%;
    width: 0%;
    transition: width 0.2s ease;
    background: linear-gradient(90deg, #60a5fa, #93c5fd);
}
.tree-upload-detail {
    font-size: 0.7rem;
    color: #bfdbfe;
    opacity: 0.95;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* new-project modal overrides */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    color: var(--text);
}
.modal-header { border-bottom-color: var(--border); }
.modal-footer { border-top-color: var(--border); }

/* ── PROJECT HEADER ───────────────────────── */
.project-header {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
    margin: 1.5rem 0;
}
.workspace-shell {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-height: 100%;
}
.workspace-card {
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.35rem;
}
.workspace-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.5rem;
    border-radius: 18px;
    background:
        radial-gradient(circle at top right, rgba(96,165,250,0.18), transparent 38%),
        linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.015));
    border: 1px solid rgba(255,255,255,0.08);
}
.workspace-eyebrow {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 0.55rem;
    font-weight: 700;
}
.workspace-title {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.035em;
    margin: 0 0 0.4rem;
}
.workspace-subtitle {
    margin: 0;
    color: var(--text-dim);
    line-height: 1.65;
    max-width: 70ch;
}
.workspace-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}
.workspace-button {
    border: 1px solid var(--border-light);
    background: rgba(255,255,255,0.05);
    color: var(--text);
    border-radius: 10px;
    padding: 0.62rem 0.95rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.workspace-button:hover { background: rgba(255,255,255,0.08); }
.workspace-button.primary {
    background: var(--text);
    color: var(--bg);
    border-color: transparent;
}
/* ---- Mode-switcher pills (Analysis / Trend) ---- */
.mode-switcher {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    align-items: center;
}
.mode-pill {
    padding: 0.28rem 0.85rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-light);
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.mode-pill:hover { background: rgba(255,255,255,0.07); color: var(--text); }
.mode-pill.active {
    background: rgba(255,255,255,0.12);
    color: var(--text);
    border-color: rgba(255,255,255,0.25);
}

/* Ingest-in-progress banner (measurement view + machine view) */
.ingest-running-banner {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.8rem;
    border-radius: 8px;
    background: rgba(99,102,241,0.10);
    border: 1px solid rgba(99,102,241,0.28);
    font-size: 0.82rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}
.ingest-running-spinner {
    display: inline-block;
    animation: spin-cw 1s linear infinite;
}
@keyframes spin-cw { to { transform: rotate(360deg); } }
.workspace-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.95rem;
}
.workspace-stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem;
}
.workspace-stat-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    font-weight: 700;
}
.workspace-stat-value {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}
.workspace-columns {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 1rem;
}
.workspace-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.workspace-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.85rem 0.95rem;
}
.workspace-list-item h4 {
    margin: 0 0 0.18rem;
    font-size: 0.92rem;
}
.workspace-list-item p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.78rem;
}
.workspace-empty {
    padding: 1.3rem;
    border: 1px dashed var(--border-light);
    border-radius: 14px;
    color: var(--text-dim);
    line-height: 1.65;
    text-align: center;
}
.workspace-warning {
    border: 1px solid rgba(245, 158, 11, 0.45);
    background: rgba(245, 158, 11, 0.12);
    color: #fcd34d;
    border-radius: 12px;
    padding: 0.8rem 0.95rem;
    margin-bottom: 0.85rem;
    font-size: 0.82rem;
}
.workspace-badge {
    display: inline-block;
    border-radius: 999px;
    padding: 0.22rem 0.65rem;
    border: 1px solid var(--border-light);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.workspace-badge.good { color: #86efac; border-color: rgba(34,197,94,0.45); }
.workspace-badge.warn { color: #fcd34d; border-color: rgba(245,158,11,0.45); }
.workspace-badge.bad { color: #fca5a5; border-color: rgba(239,68,68,0.45); }
.workspace-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
}
.workspace-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    min-width: 720px;
}
.workspace-table th,
.workspace-table td {
    border-bottom: 1px solid var(--border);
    padding: 0.58rem 0.62rem;
    text-align: left;
    vertical-align: top;
}
.workspace-table th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    background: rgba(255,255,255,0.03);
}
.workspace-table tr:last-child td { border-bottom: none; }
.params-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem 1rem;
}
.params-form-grid .full {
    grid-column: 1 / -1;
}
.params-form-section {
    margin-top: 1.3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.params-form-section:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}
.params-form-note {
    margin: -0.2rem 0 0.9rem;
    color: var(--text-dim);
    font-size: 0.83rem;
    line-height: 1.45;
}
.params-form-field.is-disabled {
    opacity: 0.58;
}
.params-form-field.is-disabled .form-label {
    color: var(--text-dim);
}
.params-form-heading {
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 0 0 0.8rem;
}
.upload-zone.compact {
    padding: 2rem 1.4rem;
    margin-top: 0.8rem;
}
.project-header h2 {
    color: var(--text);
    margin-bottom: 0.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}
.text-muted { color: var(--text-muted) !important; }

/* ── TABS ─────────────────────────────────── */
.nav-tabs {
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
    display: flex;
    gap: 0;
    flex-wrap: wrap;
}
.nav-tabs .nav-link {
    color: var(--text-dim) !important;
    border: none !important;
    border-bottom: 2px solid transparent !important;
    padding: 0.85rem 1.25rem;
    font-weight: 500;
    font-size: 0.875rem;
    background: none !important;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    border-radius: 0 !important;
    font-family: inherit;
}
.nav-tabs .nav-link:hover {
    color: var(--text) !important;
}
.nav-tabs .nav-link.active {
    color: var(--text) !important;
    background: none !important;
    border-bottom: 2px solid var(--text) !important;
}
.tab-content {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 12px 12px;
    padding: 2rem;
    margin-bottom: 2rem;
}

/* ── UPLOAD ZONE ──────────────────────────── */
.upload-zone {
    border: 2px dashed var(--border-light);
    border-radius: 10px;
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.03);
}
.upload-zone i {
    font-size: 2.5rem;
    color: var(--text-dim);
    margin-bottom: 1rem;
}

/* ── FILE LIST ────────────────────────────── */
.file-list { margin-top: 1.5rem; }
.file-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s;
}
.file-item:hover { border-color: var(--border-light); }
.file-item .badge {
    font-size: 0.75rem;
    padding: 0.35rem 0.75rem;
    border-radius: 100px;
    font-weight: 600;
}

/* ── CARDS ────────────────────────────────── */
.card {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px;
    color: var(--text);
}
.card-header {
    background: var(--bg-raised) !important;
    border-bottom: 1px solid var(--border) !important;
    color: var(--text);
    border-radius: 10px 10px 0 0 !important;
}
.card-body {
    background: var(--bg-card) !important;
    color: var(--text);
}
.card-title {
    color: var(--text-dim) !important;
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── BUTTONS ──────────────────────────────── */
.btn-primary-custom {
    background: var(--text);
    color: var(--bg);
    border: none;
    padding: 0.6rem 1.35rem;
    border-radius: 7px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.2s;
}
.btn-primary-custom:hover { opacity: 0.85; }

.btn-outline-primary {
    background: transparent !important;
    color: var(--text-dim) !important;
    border: 1px solid var(--border-light) !important;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.btn-outline-primary:hover {
    color: var(--text) !important;
    border-color: rgba(255,255,255,0.3) !important;
    background: rgba(255,255,255,0.05) !important;
}

/* ── CHART CONTAINER ──────────────────────── */
.chart-container {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
}

/* ── BOOTSTRAP FORM OVERRIDES ─────────────── */
.form-control, .form-select {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-light) !important;
    color: var(--text) !important;
    border-radius: 7px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
}
.form-control:focus, .form-select:focus {
    outline: none !important;
    border-color: rgba(255,255,255,0.3) !important;
    box-shadow: none !important;
    background: var(--bg-card) !important;
    color: var(--text) !important;
}
.form-control::placeholder { color: var(--text-muted); }
.form-label {
    font-size: 0.815rem;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 0.35rem;
}
.form-check-input {
    background-color: var(--bg-card);
    border-color: var(--border-light);
}
.form-check-input:checked {
    background-color: var(--text);
    border-color: var(--text);
}
.form-check-label { color: var(--text-dim); }
.form-text { color: var(--text-muted) !important; }
.form-select option { background: var(--bg-raised); color: var(--text); }

/* Radio btn-check group */
.btn-check + .btn-outline-primary {
    background: transparent !important;
    color: var(--text-dim) !important;
    border-color: var(--border-light) !important;
    font-size: 0.875rem;
    font-weight: 500;
}
.btn-check:checked + .btn-outline-primary {
    background: var(--text) !important;
    color: var(--bg) !important;
    border-color: var(--text) !important;
}
.btn-check + .btn-outline-primary:hover {
    background: rgba(255,255,255,0.05) !important;
    color: var(--text) !important;
    border-color: rgba(255,255,255,0.25) !important;
}

/* Progress bar */
.progress {
    background: var(--bg-card);
    border-radius: 100px;
    height: 0.65rem;
    border: 1px solid var(--border);
}
.progress-bar {
    background: var(--text) !important;
    color: var(--bg) !important;
    font-size: 0.7rem;
    font-weight: 600;
}
.progress-bar.bg-success { background: #22c55e !important; }

/* Alerts */
.alert { border-radius: 8px; font-size: 0.875rem; }
.alert-success { background: rgba(34,197,94,0.12); color: #86efac; border: 1px solid rgba(34,197,94,0.2); }
.alert-danger  { background: rgba(239,68,68,0.12);  color: #fca5a5; border: 1px solid rgba(239,68,68,0.2); }
.alert-info    { background: rgba(99,179,237,0.12);  color: #93c5fd; border: 1px solid rgba(99,179,237,0.2); }

/* Tables */
.table { color: var(--text); }
.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(255,255,255,0.03);
    color: var(--text);
}
.table > :not(caption) > * > * {
    background-color: transparent;
    color: var(--text);
    border-color: var(--border);
}
.table thead th {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-color: var(--border);
}

/* Badges */
.bg-success { background-color: rgba(34,197,94,0.2) !important; color: #86efac !important; }
.bg-danger  { background-color: rgba(239,68,68,0.2) !important;  color: #fca5a5 !important; }
.bg-secondary { background-color: var(--bg-card) !important; color: var(--text-dim) !important; border: 1px solid var(--border); }
.text-primary { color: #93c5fd !important; }
.text-success { color: #86efac !important; }
.text-danger  { color: #fca5a5 !important; }
.text-info    { color: #93c5fd !important; }

/* Modal */
.modal-content {
    background: var(--bg-raised) !important;
    border: 1px solid var(--border-light) !important;
    border-radius: 12px;
    color: var(--text);
}
.modal-header { border-bottom: 1px solid var(--border) !important; color: var(--text); }
.modal-footer { border-top: 1px solid var(--border) !important; }
.modal-title { color: var(--text); }
.btn-close { filter: invert(1); opacity: 0.5; }
.btn-close:hover { opacity: 1; }
.btn-secondary {
    background: var(--bg-card) !important;
    color: var(--text-dim) !important;
    border: 1px solid var(--border-light) !important;
    border-radius: 6px;
    font-weight: 500;
    transition: border-color 0.2s;
}
.btn-secondary:hover {
    border-color: rgba(255,255,255,0.25) !important;
    color: var(--text) !important;
}
.btn.btn-primary {
    background: var(--text) !important;
    color: var(--bg) !important;
    border: none !important;
    border-radius: 6px;
    font-weight: 600;
}
.btn.btn-primary:hover { opacity: 0.85; }
.btn.btn-danger {
    background: rgba(239,68,68,0.18) !important;
    color: #fca5a5 !important;
    border: 1px solid rgba(239,68,68,0.32) !important;
    border-radius: 6px;
    font-weight: 600;
}
.btn.btn-danger:hover {
    background: rgba(239,68,68,0.3) !important;
    color: #fecaca !important;
    border-color: rgba(239,68,68,0.45) !important;
}
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.upload-param-summary {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
    color: var(--text-dim);
}
.upload-param-summary strong { color: var(--text); }
.upload-param-table-wrap {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255,255,255,0.015);
}
.upload-param-table td:first-child,
.upload-param-table th:first-child {
    width: 44px;
}
.upload-param-check {
    width: 16px;
    height: 16px;
    accent-color: var(--text);
}
.upload-param-field {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.upload-param-field small,
.upload-param-sources,
.upload-param-ambiguous {
    color: var(--text-muted);
    font-size: 0.73rem;
    line-height: 1.5;
}
.upload-param-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.16rem 0.55rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border: 1px solid var(--border-light);
}
.upload-param-badge.fill {
    color: #bfdbfe;
    border-color: rgba(96,165,250,0.35);
    background: rgba(96,165,250,0.08);
}
.upload-param-badge.conflict {
    color: #fcd34d;
    border-color: rgba(245,158,11,0.35);
    background: rgba(245,158,11,0.1);
}
.upload-param-modal-error {
    margin-top: 0.85rem;
    color: #fca5a5;
    font-size: 0.8rem;
    display: none;
}

/* Spinner */
.spinner-border { color: var(--text-dim) !important; }

/* Border utilities */
.border { border-color: var(--border) !important; }
.rounded { border-radius: 8px !important; }
.border.rounded { border-color: var(--border-light) !important; }
.fw-bold { color: var(--text); }

/* ── FOOTER ───────────────────────────────── */
.site-footer {
    background: var(--bg-raised);
    border-top: 1px solid var(--border);
    padding: 2.5rem 2rem;
    margin-top: 4rem;
}
.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.25rem;
}
.footer-brand-block .footer-brand {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}
.footer-brand-block .footer-copy {
    font-size: 0.775rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}
.footer-links {
    display: flex;
    gap: 1.75rem;
    list-style: none;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
}
.footer-links a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.825rem;
    font-weight: 500;
    transition: color 0.2s;
}
.footer-links a:hover { color: var(--text); }

/* ── RESPONSIVE ───────────────────────────── */
@media (max-width: 768px) {
    .dash-left { padding: 1rem; }
    .dashboard-layout { flex-direction: column; height: auto; overflow: visible; }
    .dash-right { width: 100%; border-left: none; border-top: 1px solid var(--border); height: 60vh; }
    .dash-sidebar { display: none; }
    .sidebar-resizer { display: none; }
    .dashboard-layout.primary-collapsed .dash-sidebar { display: none; }
    .dashboard-layout.secondary-collapsed .dash-right {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
    }
    .dashboard-layout.secondary-collapsed .dash-right > * { opacity: 1; pointer-events: auto; }
    .params-grid, .params-grid.params-grid-4 { grid-template-columns: 1fr; }
    .workspace-grid,
    .workspace-columns,
    .params-form-grid { grid-template-columns: 1fr; }
    .desktop-nav { display: none !important; }
}

/* ── LOG TERMINAL PANEL ────────────────────── */
.log-terminal-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 260px;
    display: none;
    flex-direction: column;
    background: #0d1117;
    border-top: 2px solid #30363d;
    z-index: 2000;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.6);
}
.log-terminal-panel.open {
    display: flex;
}
.log-terminal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.75rem;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
}
.log-terminal-title {
    color: #8b949e;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-family: 'Courier New', Courier, monospace;
}
.log-terminal-controls {
    display: flex;
    align-items: center;
    gap: 0.15rem;
}
.log-terminal-btn {
    background: none;
    border: none;
    color: #8b949e;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    font-size: 0.72rem;
    border-radius: 3px;
    transition: background 0.12s, color 0.12s;
    font-family: inherit;
}
.log-terminal-btn:hover {
    background: #21262d;
    color: #cdd9e5;
}
.log-terminal-close-btn {
    margin-left: 0.35rem;
    font-size: 0.8rem;
}
.log-terminal-output {
    flex: 1;
    overflow-y: auto;
    padding: 0.3rem 0.7rem 0.5rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.7rem;
    line-height: 1.55;
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
}
.log-line {
    margin: 0;
    padding: 0;
    white-space: pre-wrap;
    word-break: break-all;
}
.log-line-ts    { color: #4a5568; }
.log-line-info  { color: #8b949e; }
.log-line-warn  { color: #e3a730; }
.log-line-error { color: #ff6b6b; font-weight: 600; }
.log-line-debug { color: #3b4654; }
.log-line-msg   { }

.log-terminal-toggle-btn {
    position: fixed;
    bottom: 1rem;
    left: 1.1rem;
    width: 2.1rem;
    height: 2.1rem;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 50%;
    color: #8b949e;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1999;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.log-terminal-toggle-btn:hover {
    background: #21262d;
    color: #cdd9e5;
    box-shadow: 0 2px 12px rgba(0,0,0,0.6);
}
