/* EngMind AI - AutoCAD-Style Dark Theme Dashboard */

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

:root {
    /* Background layers */
    --bg-dark: #0d1117;
    --bg-panel: #161b22;
    --bg-card: #1c2128;
    --bg-input: #0d1117;
    --bg-hover: #21262d;

    /* Borders */
    --border: #30363d;
    --border-light: #484f58;

    /* Text */
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;

    /* Accent */
    --accent: #2f81f7;
    --accent-hover: #79c0ff;

    /* Severity colors */
    --critical: #E53E3E;
    --high: #DD6B20;
    --medium: #38A169;
    --low: #718096;
    --info: #3182CE;

    /* Score colors */
    --score-good: #38A169;
    --score-warn: #DD6B20;
    --score-bad: #E53E3E;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* Radius */
    --radius: 6px;
    --radius-lg: 8px;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace;
}

html { font-size: 14px; }
body {
    font-family: var(--font-sans);
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.hidden { display: none !important; }

/* === Navbar === */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    height: 48px;
    padding: 0 var(--space-lg);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    gap: var(--space-lg);
}

.nav-brand { display: flex; align-items: center; gap: var(--space-sm); }
.brand-icon {
    width: 28px; height: 28px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px;
}
.brand-text { font-weight: 600; font-size: 15px; }
.brand-env {
    background: var(--medium);
    color: var(--bg-dark);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
}

.nav-links { display: flex; gap: var(--space-md); flex: 1; }
.nav-link {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius);
    transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-link.active { color: var(--text-primary); background: var(--bg-hover); }

.nav-user { display: flex; align-items: center; gap: var(--space-sm); }
.user-name { color: var(--text-secondary); font-size: 12px; }
.auth-state {
    color: var(--text-muted);
    font-size: 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px 6px;
}

/* === Buttons === */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    gap: var(--space-xs);
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-light); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-outline { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; }

/* === Cards === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}
.card-header h3 { font-size: 15px; font-weight: 600; }

/* === Badges === */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-critical { background: var(--critical); color: #fff; }
.badge-high { background: var(--high); color: #fff; }
.badge-medium { background: var(--medium); color: var(--bg-dark); }
.badge-low { background: var(--low); color: #fff; }
.badge-info { background: var(--info); color: #fff; }
.badge-queued { background: var(--text-muted); color: var(--bg-dark); }
.badge-running { background: var(--accent); color: #fff; }
.badge-completed { background: var(--low); color: var(--bg-dark); }
.badge-failed { background: var(--critical); color: #fff; }

/* === Forms === */
.form-group {
    margin-bottom: var(--space-md);
}
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}
input, select, textarea {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-sans);
    transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}
.form-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
    margin-top: var(--space-lg);
}

/* === Pages === */
.page { display: none; padding: var(--space-lg); max-width: 1200px; margin: 0 auto; }
.page.active { display: block; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}
.page-header h2 { font-size: 20px; font-weight: 600; }
.page-header-actions { display: flex; gap: var(--space-sm); }

/* === Login === */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-lg);
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    width: 100%;
    max-width: 400px;
}
.login-header { text-align: center; margin-bottom: var(--space-xl); }
.login-logo {
    width: 64px; height: 64px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-lg);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 32px; font-weight: 700;
    margin-bottom: var(--space-md);
}
.login-header h1 { font-size: 24px; margin-bottom: var(--space-xs); }
.login-subtitle { color: var(--text-secondary); font-size: 13px; margin-bottom: var(--space-sm); }
.login-footer { text-align: center; color: var(--text-muted); font-size: 11px; margin-top: var(--space-md); }

/* === Stats Grid === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    text-align: center;
}
.stat-value {
    font-size: 28px;
    font-weight: 700;
    font-family: var(--font-mono);
}
.stat-label { color: var(--text-secondary); font-size: 12px; margin-top: var(--space-xs); }
.stat-critical .stat-value { color: var(--critical); }
.stat-major .stat-value { color: var(--high); }
.stat-ok .stat-value { color: var(--score-good); }

/* === Data Table === */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th {
    text-align: left;
    padding: var(--space-sm) var(--space-md);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:hover td { background: var(--bg-hover); }
.data-table .empty-row td { color: var(--text-muted); text-align: center; padding: var(--space-xl); }
.data-table .job-id { font-family: var(--font-mono); font-size: 12px; color: var(--accent); cursor: pointer; }
.data-table .score-cell { font-family: var(--font-mono); font-weight: 600; }

/* === Upload === */
.upload-area { max-width: 600px; margin: 0 auto; }
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl) var(--space-lg);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(47, 129, 247, 0.05);
}
.drop-icon { font-size: 48px; margin-bottom: var(--space-md); opacity: 0.6; }
.drop-text { font-size: 16px; font-weight: 500; margin-bottom: var(--space-xs); }
.drop-subtext { color: var(--text-muted); font-size: 12px; margin-bottom: var(--space-md); }

.file-info { display: flex; align-items: center; gap: var(--space-md); margin-bottom: var(--space-lg); }
.file-icon {
    width: 48px; height: 48px;
    background: var(--critical);
    color: #fff;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
}
.file-name { font-weight: 500; display: block; }
.file-size { color: var(--text-secondary); font-size: 12px; }
.metadata-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

/* === Analysis Selection (2-step flow) === */
.classification-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-md); margin-top: var(--space-md);
}
.class-item { display: flex; flex-direction: column; gap: 4px; }
.class-label { color: var(--text-secondary); font-size: 12px; text-transform: uppercase; letter-spacing: 0; }
.class-value { font-weight: 600; font-size: 16px; }

.analysis-select-controls {
    display: flex; gap: var(--space-sm); margin-bottom: var(--space-md);
}
.btn-sm { padding: 4px 12px; font-size: 12px; }

.analysis-checkboxes-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-sm); max-height: 400px; overflow-y: auto;
    padding: var(--space-sm);
}
.analysis-checkbox-item {
    display: flex; align-items: center; gap: var(--space-sm);
    padding: 8px 12px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--bg-dark);
    cursor: pointer; transition: border-color 0.2s, background 0.2s;
}
.analysis-checkbox-item:hover { border-color: var(--border-light); background: var(--bg-hover); }
.analysis-checkbox-item.recommended { border-color: var(--accent); }
.analysis-checkbox-item input[type="checkbox"] {
    accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer;
}
.analysis-checkbox-item label {
    cursor: pointer; font-size: 13px; flex: 1;
}
.analysis-checkbox-item .phase-tag {
    font-size: 10px; color: var(--text-muted); background: var(--bg-panel);
    padding: 2px 6px; border-radius: 3px;
}
.analysis-explanation {
    display: block;
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 2px;
}

.cost-grid {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md); margin-top: var(--space-md); text-align: center;
}
.cost-item { display: flex; flex-direction: column; gap: 4px; }
.cost-label { color: var(--text-secondary); font-size: 12px; }
.cost-value { font-weight: 700; font-size: 20px; color: var(--accent); }
.cost-card {
    border-color: rgba(47, 129, 247, 0.35);
}
.cost-card .text-muted {
    color: var(--text-muted);
    font-size: 12px;
}
.cost-card .cost-value {
    font-family: var(--font-mono);
}
.cost-details {
    margin-top: var(--space-lg);
    border-top: 1px solid var(--border);
    padding-top: var(--space-md);
}
.cost-details h4 {
    color: var(--text-secondary);
    font-size: 12px;
    letter-spacing: 0;
    margin: var(--space-md) 0 var(--space-xs);
    text-transform: uppercase;
}
.cost-table {
    margin-bottom: var(--space-md);
}
.cost-table td,
.cost-table th {
    font-family: var(--font-mono);
}

.analysis-actions {
    display: flex; justify-content: center; margin-top: var(--space-lg);
}
.btn-lg { padding: 12px 48px; font-size: 16px; }

/* === Execution / Pipeline === */
.execution-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: var(--space-lg);
}
.exec-filename { font-weight: 600; }
.exec-jobid { font-family: var(--font-mono); color: var(--text-secondary); font-size: 12px; }

.pipeline-progress { margin-bottom: var(--space-lg); }
.pipeline-stage {
    display: flex; align-items: center; gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border-left: 3px solid var(--border);
    margin-left: var(--space-md);
    transition: border-color 0.3s;
}
.pipeline-stage.active { border-left-color: var(--accent); }
.pipeline-stage.completed { border-left-color: var(--low); }
.pipeline-stage.failed { border-left-color: var(--critical); }

.stage-indicator {
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
    transition: background 0.3s;
}
.pipeline-stage.active .stage-indicator { background: var(--accent); animation: pulse 1.5s infinite; }
.pipeline-stage.completed .stage-indicator { background: var(--low); }
.pipeline-stage.failed .stage-indicator { background: var(--critical); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.stage-info { display: flex; justify-content: space-between; flex: 1; }
.stage-name { font-size: 13px; font-weight: 500; }
.stage-status { font-size: 12px; color: var(--text-muted); }

.progress-bar-container {
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: var(--space-sm);
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    border-radius: 3px;
    transition: width 0.5s ease;
}
.exec-status { text-align: center; color: var(--text-secondary); font-size: 13px; }

/* === Results === */
.result-score-card {
    display: flex; align-items: center; gap: var(--space-xl);
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}
.score-circle {
    width: 80px; height: 80px;
    border-radius: 50%;
    border: 4px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: 700; font-family: var(--font-mono);
    flex-shrink: 0;
}
.score-circle.good { border-color: var(--score-good); color: var(--score-good); }
.score-circle.warn { border-color: var(--score-warn); color: var(--score-warn); }
.score-circle.bad { border-color: var(--score-bad); color: var(--score-bad); }
.score-info h3 { font-size: 16px; margin-bottom: var(--space-xs); }
.score-info p { color: var(--text-secondary); font-size: 13px; }

.severity-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}
.severity-card {
    text-align: center;
    padding: var(--space-md);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
}
.severity-count { display: block; font-size: 24px; font-weight: 700; font-family: var(--font-mono); }
.severity-label { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; }
.severity-critical .severity-count { color: var(--critical); }
.severity-high .severity-count { color: var(--high); }
.severity-medium .severity-count { color: var(--medium); }
.severity-low .severity-count { color: var(--low); }
.severity-info .severity-count { color: var(--info); }

.filter-bar { display: flex; gap: var(--space-sm); }
.filter-select {
    width: auto; padding: 4px 8px; font-size: 12px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text-primary);
}

/* Findings List */
.findings-list { max-height: 600px; overflow-y: auto; }
.finding-item {
    display: flex; align-items: flex-start; gap: var(--space-md);
    padding: var(--space-md);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}
.finding-item:hover { background: var(--bg-hover); }
.finding-item.selected {
    background: rgba(47, 129, 247, 0.1);
    outline: 1px solid var(--accent);
}
.finding-severity {
    width: 4px; min-height: 40px;
    border-radius: 2px; flex-shrink: 0;
}
.finding-severity.sev-critical { background: var(--critical); }
.finding-severity.sev-high { background: var(--high); }
.finding-severity.sev-medium { background: var(--medium); }
.finding-severity.sev-low { background: var(--low); }
.finding-severity.sev-info { background: var(--info); }

.finding-content { flex: 1; }
.finding-title { font-weight: 500; font-size: 13px; margin-bottom: 2px; }
.finding-message { color: var(--text-secondary); font-size: 12px; }
.finding-meta { display: flex; gap: var(--space-md); margin-top: var(--space-xs); }
.finding-meta span { font-size: 11px; color: var(--text-muted); }

.empty-state { color: var(--text-muted); text-align: center; padding: var(--space-xl); }

/* === Finding Detail === */
.finding-detail-card { max-width: 800px; }
.finding-detail-header {
    display: flex; align-items: center; gap: var(--space-md);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border);
}
.detail-section { margin-bottom: var(--space-lg); }
.detail-section h4 {
    font-size: 12px; text-transform: uppercase; letter-spacing: 0;
    color: var(--text-secondary); margin-bottom: var(--space-xs);
}
.detail-section p { font-size: 14px; line-height: 1.6; }
.detail-meta {
    display: flex; gap: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border);
    font-size: 12px; color: var(--text-secondary);
}
.detail-block {
    border-left: 3px solid var(--border);
    padding-left: var(--space-md);
}
.detail-block.optional.hidden {
    display: none;
}
.location-preview {
    min-height: 96px;
    border: 1px dashed var(--border-light);
    border-radius: var(--radius);
    background:
        linear-gradient(90deg, rgba(139, 148, 158, 0.08) 1px, transparent 1px),
        linear-gradient(0deg, rgba(139, 148, 158, 0.08) 1px, transparent 1px),
        var(--bg-input);
    background-size: 24px 24px;
    padding: var(--space-md);
    color: var(--text-secondary);
    font-size: 12px;
}
.review-control-row {
    display: grid;
    grid-template-columns: minmax(140px, 180px) 1fr auto;
    gap: var(--space-sm);
    align-items: center;
}
.context-note {
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.4;
    margin-top: var(--space-sm);
}

/* === Chat === */
.chat-container {
    display: flex; flex-direction: column;
    height: calc(100vh - 140px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}
.chat-message { display: flex; }
.chat-message.user { justify-content: flex-end; }
.chat-message.system { justify-content: center; }
.chat-bubble {
    max-width: 70%;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-lg);
    font-size: 13px;
    line-height: 1.5;
}
.chat-message.user .chat-bubble {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: var(--space-xs);
}
.chat-message.assistant .chat-bubble {
    background: var(--bg-hover);
    border-bottom-left-radius: var(--space-xs);
}
.chat-message.system .chat-bubble {
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    text-align: center;
}

.chat-input-area {
    padding: var(--space-md);
    border-top: 1px solid var(--border);
}
.chat-context {
    padding: var(--space-xs) var(--space-sm);
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}
.chat-mode-tabs {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-sm);
}
.chat-mode {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    padding: 5px 10px;
}
.chat-mode.active {
    border-color: var(--accent);
    color: var(--text-primary);
}
.chat-form { display: flex; gap: var(--space-sm); }
.chat-form textarea {
    flex: 1;
    resize: none;
    min-height: 40px;
}
.chat-send { align-self: flex-end; }

/* === Report === */
.report-preview {
    max-height: calc(100vh - 160px);
    overflow-y: auto;
}
.report-content {
    font-size: 14px;
    line-height: 1.7;
}
.report-content h2 {
    font-size: 18px;
    margin: var(--space-lg) 0 var(--space-sm);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border);
}
.report-content h3 {
    font-size: 15px;
    margin: var(--space-md) 0 var(--space-xs);
}
.report-content table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-md) 0;
}
.report-content th, .report-content td {
    padding: var(--space-xs) var(--space-sm);
    border: 1px solid var(--border);
    text-align: left;
    font-size: 12px;
}
.report-content th {
    background: var(--bg-hover);
    font-weight: 600;
}

/* === Canvas Review === */
.canvas-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr) 320px;
    gap: var(--space-md);
    min-height: calc(100vh - 96px);
}
.canvas-sidebar,
.canvas-detail {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}
.canvas-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
}
.canvas-panel h3 {
    font-size: 14px;
    margin-bottom: var(--space-sm);
}
.canvas-filter-stack {
    display: grid;
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
}
.canvas-filter-stack label {
    color: var(--text-secondary);
    font-size: 12px;
}
.canvas-finding-list {
    display: grid;
    gap: var(--space-xs);
    max-height: 320px;
    overflow-y: auto;
}
.canvas-finding-row {
    display: grid;
    grid-template-columns: 8px 1fr;
    gap: var(--space-sm);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    padding: var(--space-sm);
}
.canvas-finding-row.selected {
    border-color: var(--accent);
    background: rgba(47, 129, 247, 0.12);
}
.canvas-finding-stripe {
    border-radius: 4px;
}
.canvas-finding-title {
    font-size: 12px;
    font-weight: 600;
}
.canvas-finding-meta {
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 2px;
}
.canvas-main {
    display: grid;
    grid-template-rows: auto minmax(420px, 1fr) auto;
    gap: var(--space-md);
    min-width: 0;
}
.canvas-toolbar {
    display: flex;
    justify-content: space-between;
    gap: var(--space-md);
    align-items: center;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
}
.canvas-title {
    font-size: 16px;
    font-weight: 700;
}
.canvas-subtitle {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 2px;
}
.canvas-tools {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    justify-content: flex-end;
}
.canvas-workspace {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: #070b10;
    min-height: 520px;
}
.drawing-surface {
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(940px, 92%);
    height: min(640px, 88%);
    transform: translate(-50%, -50%) scale(var(--canvas-scale, 1));
    transform-origin: center;
    border: 1px solid var(--border-light);
    background:
        linear-gradient(90deg, rgba(49, 130, 206, 0.12) 1px, transparent 1px),
        linear-gradient(0deg, rgba(49, 130, 206, 0.12) 1px, transparent 1px),
        #0b1218;
    background-size: 40px 40px;
    box-shadow: inset 0 0 0 2px rgba(230, 237, 243, 0.04);
}
.drawing-surface.light {
    background:
        linear-gradient(90deg, rgba(49, 130, 206, 0.18) 1px, transparent 1px),
        linear-gradient(0deg, rgba(49, 130, 206, 0.18) 1px, transparent 1px),
        #f5f7fa;
    color: #111827;
}
.drawing-title-block {
    position: absolute;
    right: 24px;
    bottom: 24px;
    width: 220px;
    border: 1px solid currentColor;
    padding: var(--space-sm);
    display: grid;
    gap: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
}
.drawing-grid-label {
    position: absolute;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 20px;
    opacity: 0.55;
}
.label-a { left: 12%; top: 16%; }
.label-b { left: 48%; top: 42%; }
.label-c { left: 72%; top: 22%; }
.marker-layer,
.heat-map-layer {
    position: absolute;
    inset: 0;
}
.marker-layer.hidden,
.heat-map-layer.hidden {
    display: none;
}
.finding-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    min-width: 34px;
    min-height: 34px;
    border: 3px solid currentColor;
    border-radius: 50%;
    background: rgba(13, 17, 23, 0.86);
    color: var(--info);
    cursor: pointer;
    display: grid;
    place-items: center;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    box-shadow: 0 0 0 4px rgba(13, 17, 23, 0.6);
}
.finding-marker.high-shape {
    border-radius: var(--radius);
}
.finding-marker.medium-shape {
    border-radius: 0;
    transform: translate(-50%, -50%) rotate(45deg);
}
.finding-marker.medium-shape span {
    transform: rotate(-45deg);
}
.finding-marker.selected {
    outline: 3px solid #fff;
    z-index: 10;
}
.heat-spot {
    position: absolute;
    transform: translate(-50%, -50%);
    width: 96px;
    height: 96px;
    border-radius: 50%;
    opacity: 0.22;
    filter: blur(4px);
}
.canvas-minimap {
    position: absolute;
    right: 14px;
    top: 14px;
    width: 136px;
    height: 96px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    background: rgba(13, 17, 23, 0.84);
    color: var(--text-muted);
    font-size: 11px;
    padding: var(--space-xs);
}
.minimap-window {
    position: absolute;
    left: 34px;
    top: 28px;
    width: 56px;
    height: 38px;
    border: 2px solid var(--accent);
}
.canvas-status-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
}
.canvas-status-grid > div {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-md);
    background: var(--bg-card);
}
.canvas-status-grid p {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.4;
    margin-top: var(--space-xs);
}
.canvas-detail-block {
    border-bottom: 1px solid var(--border);
    padding: var(--space-sm) 0;
}
.canvas-detail-block:last-child {
    border-bottom: 0;
}
.canvas-detail-block h4 {
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.canvas-chat-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

/* === Toast === */
.toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}
.toast {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}
.toast.success { border-left: 3px solid var(--low); }
.toast.error { border-left: 3px solid var(--critical); }
.toast.warning { border-left: 3px solid var(--medium); }
.toast.info { border-left: 3px solid var(--info); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* === Loading Overlay === */
.loading-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(13, 17, 23, 0.8);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    z-index: 999;
}
.loading-spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: var(--space-md);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Scrollbar === */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* === Responsive === */
@media (max-width: 768px) {
    .severity-grid { grid-template-columns: repeat(3, 1fr); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .nav-links { display: none; }
    .page { padding: var(--space-md); }
    .metadata-grid,
    .canvas-shell,
    .canvas-status-grid,
    .review-control-row {
        grid-template-columns: 1fr;
    }
    .canvas-main {
        grid-template-rows: auto 460px auto;
    }
    .canvas-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }
    .canvas-detail {
        order: 3;
    }
}
