/* CraftAxis - Mobile-First Responsive Styles */

/* CSS Custom Properties */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #475569;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --rapid-color: #22c55e;
    --cut-color: #ef4444;
    --leadin-color: #f59e0b;
    --shape-color: #64748b;
    --radius: 8px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    overflow-x: hidden;
}

/* App Container - Three Column Layout */
.app-container {
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    grid-template-columns: 1fr;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* Grid row assignments for app-container children */
.app-header {
    grid-row: 1;
    position: relative;
    z-index: 10;
}

.main-toolbar {
    grid-row: 2;
    position: relative;
    z-index: 9;
}

.main-content {
    grid-row: 3;
    display: grid;
    grid-template-columns: 260px 1fr 300px;
    overflow: hidden;
}

.status-bar {
    grid-row: 4;
    position: relative;
    z-index: 5;
}

/* Panel columns within main-content */
.panel-left {
    grid-column: 1;
    min-height: 0;
    overflow-y: auto;
}

.canvas-container {
    grid-column: 2;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.panel-right {
    grid-column: 3;
    min-height: 0;
    overflow-y: auto;
}

.legacy-sidebar {
    display: none !important;
}

/* Extra Large Screens */
@media (min-width: 1400px) {
    .main-content {
        grid-template-columns: 300px 1fr 360px;
    }
}

@media (min-width: 1920px) {
    .main-content {
        grid-template-columns: 320px 1fr 400px;
    }
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    gap: var(--spacing-md);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.header-project {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.header-project .project-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.header-project .project-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--primary-color);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.header-btn:hover {
    background: var(--surface-light);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.app-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.unit-toggle {
    display: flex;
    background: var(--surface-light);
    border-radius: var(--radius);
    overflow: hidden;
}

.unit-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.unit-btn.active {
    background: var(--primary-color);
    color: white;
}

.unit-btn:not(.active):hover {
    background: var(--border-color);
}

/* Main Toolbar */
.main-toolbar {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.toolbar-separator {
    width: 1px;
    height: 32px;
    background: var(--border-color);
    margin: 0 var(--spacing-xs);
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 var(--spacing-xs);
}

/* Align Dropdown */
.align-dropdown-container {
    position: relative;
}

.align-center-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.align-center-btn:hover:not(:disabled) {
    background: var(--surface-light);
}

.align-center-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.align-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: var(--spacing-sm);
    min-width: 180px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.align-dropdown.hidden {
    display: none;
}

.align-dropdown-header {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xs);
    font-weight: 600;
}

.align-option {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) 0;
    cursor: pointer;
    font-size: 0.875rem;
}

.align-option input[type="radio"] {
    accent-color: var(--primary-color);
}

.align-dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--spacing-sm) 0;
}

.align-action {
    display: block;
    width: 100%;
    padding: var(--spacing-sm);
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    text-align: left;
    margin-bottom: var(--spacing-xs);
}

.align-action:last-child {
    margin-bottom: 0;
}

.align-action:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* Shape Selector (in toolbar) */
.shape-btn {
    width: 40px;
    height: 40px;
    padding: var(--spacing-xs);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface-light);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shape-btn svg {
    width: 24px;
    height: 24px;
}

.shape-btn.active {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.2);
    color: var(--primary-color);
}

.shape-btn:not(.active):hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* Toolbar Import Buttons */
.toolbar-import-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.toolbar-import-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.toolbar-import-btn svg {
    width: 16px;
    height: 16px;
}

.toolbar-trace-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding-left: var(--spacing-sm);
    border-left: 1px solid var(--border-color);
    margin-left: var(--spacing-sm);
}

.toolbar-trace-controls.hidden {
    display: none;
}

.toolbar-btn {
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.toolbar-btn-danger:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

.toolbar-select {
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.75rem;
    cursor: pointer;
    min-width: 80px;
}

/* Panels (Left & Right) */
.panel {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0; /* Allow shrinking in grid */
    position: relative;
}

.panel-right {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.panel-collapse-btn {
    position: absolute;
    top: var(--spacing-md);
    right: -12px;
    width: 24px;
    height: 24px;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-right .panel-collapse-btn {
    right: auto;
    left: -12px;
}

.panel-section {
    border-bottom: 1px solid var(--border-color);
}

.panel-section:last-child {
    border-bottom: none;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface-light);
    font-weight: 600;
    font-size: 0.8125rem;
    cursor: pointer;
    user-select: none;
}

.section-header:hover {
    background: var(--border-color);
}

.section-action-btn {
    padding: 2px 8px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.6875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.section-action-btn:hover {
    background: var(--surface-light);
    color: var(--text-primary);
}

.section-action-btn.primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.section-action-btn.primary:hover {
    background: var(--primary-hover);
}

.section-content {
    padding: var(--spacing-sm);
    max-height: 200px;
    overflow-y: auto;
}

/* Shape List in Panel */
.shape-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.shape-list-empty,
.layer-list-empty,
.properties-empty,
.settings-empty,
.toolpath-list-empty {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-align: center;
    padding: var(--spacing-md);
    font-style: italic;
}

.shape-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--background);
    border: 2px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.shape-item:hover {
    border-color: var(--border-color);
}

.shape-item.selected {
    border: 2px dashed var(--primary-color);
    background: rgba(37, 99, 235, 0.1);
}

.shape-item-icon {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.shape-item.selected .shape-item-icon {
    color: var(--primary-color);
}

.shape-item-info {
    flex: 1;
    min-width: 0;
}

.shape-item-type {
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: capitalize;
}

.shape-item-dims {
    font-size: 0.625rem;
    color: var(--text-secondary);
}

.shape-item-toolpath {
    font-size: 0.5625rem;
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.1);
    padding: 1px 4px;
    border-radius: 2px;
    margin-top: 2px;
}

/* Toolpath List */
.toolpath-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.toolpath-item {
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.toolpath-item.selected {
    border-color: var(--primary-color);
}

.toolpath-item-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    cursor: pointer;
}

.toolpath-item-header:hover {
    background: var(--surface-light);
}

.toolpath-toggle {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.toolpath-item.expanded .toolpath-toggle {
    transform: rotate(90deg);
}

.toolpath-item-info {
    flex: 1;
    min-width: 0;
}

.toolpath-item-name {
    font-weight: 500;
    font-size: 0.8125rem;
}

.toolpath-item-type {
    font-size: 0.6875rem;
    color: var(--text-secondary);
}

.toolpath-item-shapes {
    display: none;
    padding: var(--spacing-sm);
    padding-top: 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.toolpath-item.expanded .toolpath-item-shapes {
    display: block;
}

.toolpath-enable-toggle {
    width: 32px;
    height: 18px;
    background: var(--surface-light);
    border: none;
    border-radius: 9px;
    cursor: pointer;
    position: relative;
}

.toolpath-enable-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all 0.2s;
}

.toolpath-enable-toggle.enabled {
    background: var(--primary-color);
}

.toolpath-enable-toggle.enabled::after {
    left: 16px;
    background: white;
}

/* Panel Actions */
.panel-actions {
    padding: var(--spacing-md);
    border-top: 1px solid var(--border-color);
    background: var(--surface-light);
    margin-top: auto;
}

.generate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

.generate-btn svg {
    width: 18px;
    height: 18px;
}

/* Canvas Container */
.canvas-container {
    position: relative;
    background: var(--background);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    touch-action: none;
}

.canvas-toolbar {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.canvas-toolbar button {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.canvas-toolbar button:hover:not(:disabled) {
    background: var(--surface-light);
}

.canvas-toolbar button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.canvas-toolbar button.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

#preview-canvas {
    flex: 1;
    width: 100%;
    display: block;
}

.canvas-status {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    font-size: 0.6875rem;
    color: var(--text-secondary);
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--surface-light);
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.status-left,
.status-center,
.status-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.status-divider {
    color: var(--border-color);
}

/* Preview Container (Legacy - keep for mobile) */
.preview-container {
    position: relative;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    aspect-ratio: 4 / 3;
    max-height: 300px;
    touch-action: none;
}

#preview-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.preview-controls {
    position: absolute;
    bottom: var(--spacing-sm);
    left: var(--spacing-sm);
    right: var(--spacing-sm);
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--spacing-xs);
}

.preview-controls button {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.preview-controls button:hover:not(:disabled) {
    opacity: 1;
    background: var(--surface-light);
}

.preview-controls button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.preview-controls button.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* Trim mode button - orange/warning color when active */
#trim-mode.active {
    background: #f97316;
    border-color: #f97316;
}

.preview-controls button svg {
    display: block;
}

.control-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 4px;
}

/* Vertical divider for dropdown menus */
.control-divider-v {
    width: 100%;
    height: 1px;
    background: var(--border-color);
    margin: var(--spacing-xs) 0;
}

/* Collapsible control groups (mobile) */
.control-group.collapsible {
    position: relative;
    display: flex;
    align-items: center;
}

.group-toggle {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.group-toggle:hover {
    opacity: 1;
    background: var(--surface-light);
}

.group-toggle.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.group-buttons {
    position: absolute;
    bottom: 100%;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
    margin-bottom: var(--spacing-xs);
    z-index: 100;
}

.group-buttons.hidden {
    display: none;
}

.group-buttons button {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.group-buttons button:hover:not(:disabled) {
    opacity: 1;
    background: var(--surface-light);
}

.group-buttons button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.group-buttons select {
    height: 36px;
    padding: 0 var(--spacing-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
}

.group-buttons select:hover {
    background: var(--surface-light);
}

/* Desktop: show all buttons inline, hide toggles */
@media (min-width: 768px) {
    .control-group.collapsible {
        display: contents;
    }

    .group-toggle {
        display: none !important;
    }

    .group-buttons,
    .group-buttons.hidden {
        position: static;
        display: flex !important;
        flex-direction: row;
        padding: 0;
        background: none;
        border: none;
        box-shadow: none;
        margin-bottom: 0;
        gap: var(--spacing-xs);
    }

    .group-buttons .control-divider-v {
        width: 1px;
        height: 24px;
        margin: 0 4px;
    }
}

.preview-hint {
    position: absolute;
    top: 56px; /* Below canvas toolbar */
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background: rgba(37, 99, 235, 0.9);
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius);
    pointer-events: none;
    opacity: 0.9;
    transition: opacity 0.3s;
}

.preview-hint.hidden {
    opacity: 0;
}

/* Trace Image Bar */
.trace-image-bar {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.trace-upload-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.trace-upload-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.trace-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex: 1;
}

.trace-controls.hidden {
    display: none;
}

.trace-opacity-label,
.trace-scale-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.trace-opacity-label input[type="range"] {
    width: 80px;
    height: 4px;
    cursor: pointer;
}

.trace-scale-label input {
    width: 60px;
    padding: 4px 8px;
    min-height: auto;
}

#clear-trace-image {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
}

#clear-trace-image:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

.secondary-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover:not(:disabled) {
    background: var(--border-color);
}

.secondary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.text-preview-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: var(--spacing-sm);
    background: var(--surface);
    border-radius: var(--radius);
    text-align: center;
}

.text-preview-label span {
    color: var(--primary-color);
    font-weight: 600;
}

#custom-points[readonly] {
    background: var(--surface);
    cursor: default;
}

/* Sidebar Tabs */
.sidebar-tabs {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    overflow: hidden;
}

.tab-buttons {
    display: flex;
    background: var(--surface-light);
    border-bottom: 2px solid var(--border-color);
    flex-shrink: 0;
}

.tab-btn {
    flex: 1;
    padding: 12px 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--primary-color);
    background: var(--surface);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
}

.tab-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.tab-panel {
    display: none;
    padding: var(--spacing-md);
}

.tab-panel.active {
    display: block;
}

/* Section spacing within tabs */
.tab-panel > * + * {
    margin-top: var(--spacing-md);
}

.tab-panel .param-section {
    margin: 0;
}

.tab-panel .param-section + .param-section {
    margin-top: var(--spacing-md);
}

/* Shape List Panel */
.shape-list-panel {
    background: var(--surface-light);
    border-radius: var(--radius);
    max-height: 180px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.shape-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface-light);
    font-weight: 600;
    font-size: 0.875rem;
}

.shape-list-header button {
    padding: 4px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.shape-list-header button:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

.shape-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-sm);
}

.shape-list-empty {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-align: center;
    padding: var(--spacing-lg);
    font-style: italic;
}

.shape-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: var(--spacing-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.shape-item:hover {
    border-color: var(--text-secondary);
}

.shape-item.selected {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.1);
}

.shape-item-icon {
    width: 24px;
    height: 24px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.shape-item.selected .shape-item-icon {
    color: var(--primary-color);
}

.shape-item-info {
    flex: 1;
    min-width: 0;
}

.shape-item-type {
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: capitalize;
}

.shape-item-dims {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shape-item-actions {
    display: flex;
    gap: 4px;
}

.shape-item-actions button {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.shape-item-actions button:hover {
    background: var(--surface-light);
    color: var(--text-primary);
}

.shape-item-actions button.delete-btn:hover {
    background: var(--error);
    color: white;
}

/* Parameters Panel */
.params-panel {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    min-height: 400px;
}

.param-section {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    overflow: visible;
}

.param-section summary {
    padding: var(--spacing-md);
    font-weight: 600;
    cursor: pointer;
    background: var(--surface-light);
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.param-section summary::before {
    content: '▶';
    font-size: 0.75rem;
    transition: transform 0.2s;
}

.param-section[open] summary::before {
    transform: rotate(90deg);
}

.param-content {
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    overflow: visible;
}

.param-content label {
    overflow: visible;
}

.param-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.param-group.hidden {
    display: none;
}

/* Cut Chart Info Panel */
.cut-chart-info {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: var(--spacing-md);
    margin-top: var(--spacing-sm);
}

.cut-chart-info.hidden {
    display: none;
}

.cut-chart-header {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary-color);
    margin-bottom: var(--spacing-sm);
    padding-bottom: var(--spacing-xs);
    border-bottom: 1px solid var(--border-color);
}

.cut-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.cut-chart-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cut-chart-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.cut-chart-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.apply-chart-btn {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.apply-chart-btn:hover {
    background: var(--primary-hover);
}

/* Form Elements */
label {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

label > span {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.input-with-unit {
    display: flex;
    align-items: stretch;
    width: 100%;
    overflow: visible;
}

.input-with-unit input {
    flex: 1;
    border-radius: var(--radius) 0 0 var(--radius);
    border-right: none;
    min-width: 80px;
}

.input-with-unit .unit-label {
    padding: 12px 16px;
    background: var(--surface-light);
    border: 2px solid var(--border-color);
    border-left: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    min-width: 60px;
    justify-content: center;
}

input[type="number"],
input[type="text"],
select,
textarea {
    padding: 12px 16px;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 500;
    width: 100%;
    min-height: 48px;
    transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea {
    resize: vertical;
    min-height: 100px;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.875rem;
}

.checkbox-label {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Material Settings */
.param-row {
    display: flex;
    gap: var(--spacing-sm);
}

.param-row .half-width {
    flex: 1;
    min-width: 0;
}

.bounds-warning {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--error);
    border-radius: var(--radius);
    color: var(--error);
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: var(--spacing-sm);
}

.bounds-warning.hidden {
    display: none;
}

.bounds-warning svg {
    flex-shrink: 0;
}

/* Project Bar */
.project-bar {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--surface-light);
    border-radius: var(--radius);
}

.project-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-right: var(--spacing-xs);
}

.project-bar .secondary-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.875rem;
}

.project-bar .import-btn {
    cursor: pointer;
}

/* Action Bar */
.action-bar {
    padding: var(--spacing-md);
    background: var(--surface-light);
    border-radius: var(--radius);
}

.gcode-units-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    font-size: 0.85rem;
}

.gcode-units-row label {
    color: var(--text-muted);
    white-space: nowrap;
}

.gcode-units-row select {
    flex: 1;
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-color);
    font-size: 0.85rem;
    cursor: pointer;
}

.gcode-units-row select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.primary-btn {
    width: 100%;
    padding: var(--spacing-md);
    background: var(--primary-color);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.primary-btn:hover {
    background: var(--primary-hover);
}

.primary-btn:active {
    transform: scale(0.98);
}

/* Estimation Panel */
#estimation-panel {
    background: var(--surface-light);
    border-radius: var(--radius);
    overflow: hidden;
}

#estimation-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    background: var(--surface-light);
    cursor: pointer;
    user-select: none;
    font-size: 0.875rem;
    font-weight: 500;
}

#estimation-panel .panel-header:hover {
    background: var(--border-color);
}

#estimation-panel .panel-toggle {
    transition: transform 0.2s ease;
    color: var(--text-secondary);
}

#estimation-panel.collapsed .panel-toggle {
    transform: rotate(-90deg);
}

#estimation-panel.collapsed .panel-content {
    display: none;
}

#estimation-panel .panel-content {
    padding: var(--spacing-md);
}

.estimation-stats {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-xs) 0;
}

.stat-row.highlight {
    background: var(--surface-light);
    padding: var(--spacing-sm);
    border-radius: var(--radius);
    margin-top: var(--spacing-xs);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.stat-value {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.stat-row.highlight .stat-value {
    color: var(--success);
    font-size: 1rem;
}

.estimation-cost {
    border-top: 1px solid var(--border-color);
    padding-top: var(--spacing-md);
}

.estimation-cost .section-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.estimation-cost .input-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
}

.estimation-cost .input-row label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.estimation-cost .input-with-unit {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.estimation-cost .currency-symbol {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.estimation-cost input {
    width: 80px;
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    text-align: right;
}

.estimation-cost .unit-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* G-Code Output */
.gcode-output {
    background: var(--surface-light);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.gcode-header {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-md);
    background: var(--surface-light);
    font-size: 0.875rem;
}

.gcode-header span:last-child {
    color: var(--text-secondary);
}

#gcode-display {
    padding: var(--spacing-md);
    background: var(--background);
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.75rem;
    line-height: 1.6;
    overflow-x: auto;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre;
    color: var(--text-secondary);
    min-height: 100px;
}

#gcode-display:empty::before {
    content: 'G-code will appear here after generation...';
    color: var(--text-secondary);
    font-style: italic;
}

.export-buttons {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
}

.export-buttons button {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface-light);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.export-buttons button:hover:not(:disabled) {
    background: var(--border-color);
}

.export-buttons button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Design Export Section */
.design-export {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--surface-dark);
    border-radius: var(--radius);
}

.design-export .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
}

.design-export-buttons {
    padding: 0;
}

.design-export-buttons .export-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
}

.design-export-buttons .export-btn svg {
    flex-shrink: 0;
}

.tier-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
}

.tier-badge.tier-free {
    background: #555;
    color: #fff;
}

.tier-badge.tier-basic {
    background: #2196f3;
    color: #fff;
}

.tier-badge.tier-pro {
    background: #9c27b0;
    color: #fff;
}

.tier-badge.tier-enterprise {
    background: #ff9800;
    color: #000;
}

.upgrade-hint {
    margin-top: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: rgba(255, 152, 0, 0.1);
    border-radius: var(--radius);
    font-size: 0.75rem;
    color: var(--warning);
    text-align: center;
}

.export-usage {
    margin-top: var(--spacing-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
}

.export-usage.low {
    color: var(--warning);
}

.export-usage.depleted {
    color: var(--error);
    font-weight: 500;
}

/* Nesting Features */
.nesting-buttons {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.nesting-buttons .action-btn {
    flex: 1;
}

.secondary-btn {
    background: var(--surface-alt);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.secondary-btn:hover {
    background: var(--border-color);
}

/* Nesting Stats Panel */
.nesting-stats {
    margin-top: var(--spacing-md);
    padding: var(--spacing-sm);
    background: var(--surface-alt);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.stats-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
    font-size: 0.875rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-sm);
}

.stat-item {
    display: flex;
    flex-direction: column;
    padding: var(--spacing-xs);
    background: var(--surface);
    border-radius: var(--radius-sm);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-value.utilization-high {
    color: var(--success);
}

.stat-value.utilization-medium {
    color: var(--warning);
}

.stat-value.utilization-low {
    color: var(--error);
}

/* Cutting Optimization Section */
.subsection-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: var(--spacing-sm) 0;
    padding-bottom: var(--spacing-xs);
    border-bottom: 1px solid var(--border-color);
}

/* Quantities Modal */
.quantities-modal {
    max-width: 400px;
}

.quantities-list {
    max-height: 300px;
    overflow-y: auto;
}

.quantities-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: var(--spacing-lg);
}

.quantity-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm);
    border-bottom: 1px solid var(--border-color);
}

.quantity-item:last-child {
    border-bottom: none;
}

.quantity-item-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex: 1;
    min-width: 0;
}

.quantity-item-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

.quantity-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
}

.qty-input {
    width: 60px;
    padding: var(--spacing-xs);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    text-align: center;
}

.quantities-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-sm);
    border-top: 1px solid var(--border-color);
}

.quantities-actions label {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.875rem;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Legacy layout styles removed - using new three-column CAM layout */

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
    .shape-btn {
        width: 52px;
        height: 52px;
    }

    input[type="number"],
    select {
        font-size: 16px; /* Prevents iOS zoom on focus */
        padding: var(--spacing-md);
    }

    .primary-btn {
        padding: var(--spacing-lg);
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Selection styling */
::selection {
    background: var(--primary-color);
    color: white;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--spacing-md);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--surface-light);
}

.modal-body {
    padding: var(--spacing-md);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    border-top: 1px solid var(--border-color);
}

/* Job Setup Modal */
.job-setup-modal {
    max-width: 500px;
}

.job-setup-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: var(--spacing-md);
}

.job-tab {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.job-tab:hover {
    color: var(--text-primary);
}

.job-tab.active {
    color: var(--primary-color);
}

.job-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
}

.job-tab-content {
    display: none;
}

.job-tab-content.active {
    display: block;
}

.job-form .form-section {
    margin-bottom: var(--spacing-lg);
}

.job-form .form-section h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    padding-bottom: var(--spacing-xs);
    border-bottom: 1px solid var(--border-color);
}

.job-form .input-row {
    display: flex;
    gap: var(--spacing-md);
}

.job-form .input-row .input-group {
    flex: 1;
}

.home-position-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-sm);
}

.home-option {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.home-option:hover {
    border-color: var(--text-secondary);
}

.home-option input[type="radio"] {
    width: 16px;
    height: 16px;
}

.home-option input[type="radio"]:checked + .home-label {
    color: var(--primary-color);
}

.z-zero-options {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.z-zero-option {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
}

.job-units-toggle {
    display: flex;
    gap: var(--spacing-md);
}

.job-unit-option {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
}

.job-unit-option:hover {
    border-color: var(--text-secondary);
}

.job-unit-option:has(input:checked) {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
}

.job-unit-option input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
}

.job-unit-label {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.recent-projects-list {
    max-height: 300px;
    overflow-y: auto;
}

/* Settings Modal */
.settings-modal {
    max-width: 600px;
}

.settings-tabs {
    display: flex;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: var(--spacing-sm);
}

.settings-tab {
    padding: var(--spacing-sm) var(--spacing-md);
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.settings-tab:hover {
    color: var(--text-primary);
}

.settings-tab.active {
    background: var(--primary-color);
    color: white;
}

.settings-panel {
    display: none;
}

.settings-panel.active {
    display: block;
}

.settings-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Dropdown Menu */
.dropdown-menu {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 1001;
    min-width: 180px;
    padding: var(--spacing-xs);
}

.dropdown-menu.hidden {
    display: none;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: none;
    border: none;
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}

.dropdown-item:hover {
    background: var(--surface-light);
}

.dropdown-item svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

/* Projects Modal */
.projects-modal {
    max-width: 500px;
}

.projects-modal .modal-header {
    gap: var(--spacing-sm);
}

.project-count {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-left: auto;
    margin-right: var(--spacing-md);
}

.projects-list {
    max-height: 400px;
    overflow-y: auto;
    min-height: 100px;
}

.projects-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: var(--spacing-lg);
    font-style: italic;
}

.project-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.project-item:hover {
    background: var(--surface-light);
}

.project-item:last-child {
    border-bottom: none;
}

.project-item-info {
    flex: 1;
    min-width: 0;
}

.project-item-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-item-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.project-item-actions {
    display: flex;
    gap: var(--spacing-xs);
    flex-shrink: 0;
}

.project-item-actions button {
    padding: var(--spacing-xs) var(--spacing-sm);
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.project-item-actions button:hover {
    background: var(--surface-light);
    color: var(--text-primary);
}

.project-item-actions .delete-btn:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

/* Project name display in header */
.project-name {
    font-size: 0.875rem;
    color: var(--primary-color);
    font-weight: 500;
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.array-inputs {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.array-inputs .input-row {
    display: flex;
    gap: var(--spacing-md);
}

.array-inputs label {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.array-inputs input[type="number"] {
    padding: var(--spacing-sm);
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
    width: 100%;
}

.array-inputs .checkbox-row {
    flex-direction: row;
}

.array-inputs .checkbox-row label {
    flex-direction: row;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
}

.array-inputs input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.array-preview-info {
    display: flex;
    justify-content: space-between;
    margin-top: var(--spacing-md);
    padding: var(--spacing-sm);
    background: var(--background);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.secondary-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.875rem;
}

.secondary-btn:hover {
    background: var(--border-color);
}

/* Section Divider */
.section-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: var(--spacing-md) 0;
}

/* Subsettings (indented child settings) */
.subsettings {
    margin-left: var(--spacing-md);
    padding-left: var(--spacing-md);
    border-left: 2px solid var(--border-color);
    margin-top: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.subsettings label {
    margin-bottom: var(--spacing-xs);
}

/* Settings Profile Section */
.settings-profile-section {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.profile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
}

.profile-label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.profile-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.profile-controls select {
    min-width: 140px;
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.8125rem;
}

.profile-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: var(--bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.profile-btn:hover:not(:disabled) {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.profile-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.profile-btn-danger:hover:not(:disabled) {
    background: var(--error);
    border-color: var(--error);
}

/* Parameter hints */
.param-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: var(--spacing-xs) 0;
    line-height: 1.4;
}

/* Code input styling (monospace for G-code commands) */
.code-input {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8125rem;
}

textarea.code-input {
    resize: vertical;
    min-height: 40px;
}

/* Auto-Nest Button */
.nest-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--info);
    border: none;
    border-radius: var(--radius);
    color: white;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.2s;
}

.nest-btn:hover {
    background: #2563eb;
}

.nest-btn svg {
    flex-shrink: 0;
}

/* Cut Simulation Styles */
.simulation-controls {
    padding: var(--spacing-md);
    background: var(--surface-light);
    border-radius: var(--radius);
}

.simulation-controls hr.section-divider {
    display: none;
}

.simulation-header {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.simulation-row {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.simulate-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--success);
    border: none;
    border-radius: var(--radius);
    color: white;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.2s;
}

.simulate-btn:hover {
    background: #16a34a;
}

.simulate-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

.sim-speed-select {
    width: 70px;
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.875rem;
}

.sim-control-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.sim-control-btn:hover {
    background: var(--background);
}

.sim-stop-btn {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.sim-stop-btn:hover {
    background: #dc2626;
}

.sim-running-controls.hidden,
.simulate-btn.hidden {
    display: none !important;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--surface);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--success);
    transition: width 0.1s linear;
}

.progress-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 35px;
    text-align: right;
}

/* Auto Trace Styles */
.trace-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 var(--spacing-xs);
}

.auto-trace-btn {
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--warning);
    border: none;
    border-radius: var(--radius);
    color: var(--background);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.auto-trace-btn:hover {
    background: #d97706;
}

.auto-trace-modal {
    max-width: 600px;
}

.trace-preview-container {
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: var(--spacing-md);
    overflow: hidden;
    position: relative;
}

#trace-preview-canvas {
    width: 100%;
    height: 250px;
    display: block;
}

.trace-settings {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.trace-settings .input-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.trace-settings label {
    min-width: 80px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.trace-settings input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--surface-light);
    border-radius: 3px;
    cursor: pointer;
}

.trace-settings input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.trace-settings input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.trace-settings span {
    min-width: 40px;
    text-align: right;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.trace-settings .checkbox-group {
    display: flex;
    align-items: center;
}

.trace-settings .checkbox-group label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    min-width: auto;
}

.trace-settings .checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ==========================================
   User Menu & Authentication
   ========================================== */

.header-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.user-menu {
    display: flex;
    align-items: center;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
}

.user-btn:hover {
    background: var(--surface-light);
}

.user-btn svg {
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
}

.user-tier {
    padding: 2px 6px;
    background: var(--primary-color);
    border-radius: 4px;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.user-tier.free { background: var(--secondary-color); }
.user-tier.basic { background: var(--success); }
.user-tier.pro { background: var(--primary-color); }
.user-tier.enterprise { background: var(--warning); color: #000; }

.logout-btn {
    padding: var(--spacing-xs) var(--spacing-sm);
    background: transparent;
    border: 1px solid var(--error);
    border-radius: var(--radius);
    color: var(--error);
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
}

.logout-btn:hover {
    background: var(--error);
    color: white;
}

.profile-btn {
    padding: var(--spacing-xs) var(--spacing-sm);
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.profile-btn:hover {
    background: var(--surface-light);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

/* Profile Modal */
.profile-modal {
    max-width: 450px;
}

.profile-section {
    margin-bottom: var(--spacing-lg);
}

.profile-section:last-child {
    margin-bottom: 0;
}

.profile-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-xs);
    border-bottom: 1px solid var(--border-color);
}

.profile-info {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.profile-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm);
    background: var(--background);
    border-radius: var(--radius);
}

.profile-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.profile-value {
    color: var(--text-primary);
    font-weight: 500;
}

.profile-tier {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.profile-tier.free { background: var(--secondary-color); color: white; }
.profile-tier.basic { background: var(--success); color: white; }
.profile-tier.pro { background: var(--primary-color); color: white; }
.profile-tier.enterprise { background: var(--warning); color: #000; }

.profile-modal .input-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
}

.profile-modal label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.profile-modal input {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
}

.profile-modal input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.profile-error {
    padding: var(--spacing-sm);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: var(--radius);
    color: var(--error);
    font-size: 0.875rem;
    margin-bottom: var(--spacing-md);
}

.profile-error.hidden {
    display: none;
}

.profile-success {
    padding: var(--spacing-sm);
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--success);
    border-radius: var(--radius);
    color: var(--success);
    font-size: 0.875rem;
    margin-bottom: var(--spacing-md);
}

.profile-success.hidden {
    display: none;
}

.change-password-btn {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
}

/* Profile Modal Scrollable Body */
.profile-modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

.profile-modal {
    max-width: 500px;
}

/* Active Sessions */
.sessions-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.session-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.session-item.current {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.05);
}

.session-info {
    flex: 1;
}

.session-device {
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.session-device .current-badge {
    font-size: 0.7rem;
    background: var(--primary-color);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
}

.session-details {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.session-revoke {
    background: transparent;
    border: 1px solid var(--error);
    color: var(--error);
    padding: 4px 8px;
    border-radius: var(--radius);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.session-revoke:hover {
    background: var(--error);
    color: white;
}

.sessions-loading {
    text-align: center;
    color: var(--text-secondary);
    padding: var(--spacing-md);
}

.revoke-all-btn {
    width: 100%;
    margin-top: var(--spacing-sm);
}

/* Security Settings Row */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: var(--spacing-sm);
}

.setting-info {
    flex: 1;
}

.setting-label {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
}

.setting-description {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

/* Danger Zone */
.danger-zone {
    border: 1px solid var(--error);
    border-radius: var(--radius);
    padding: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.danger-title {
    color: var(--error);
    margin-bottom: var(--spacing-md);
}

.danger-zone-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-md);
}

.danger-info {
    flex: 1;
}

.danger-label {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
}

.danger-description {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.danger-btn {
    background: var(--error);
    color: white;
    border: none;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.danger-btn:hover {
    background: #dc2626;
}

/* 2FA Modal */
.twofa-modal {
    max-width: 450px;
}

.twofa-step {
    text-align: center;
}

.qr-code-container {
    display: flex;
    justify-content: center;
    margin: var(--spacing-lg) 0;
    background: white;
    padding: var(--spacing-md);
    border-radius: var(--radius);
}

.qr-code-container svg {
    max-width: 200px;
    max-height: 200px;
}

.manual-entry {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

.manual-entry code {
    background: var(--background);
    padding: 4px 8px;
    border-radius: var(--radius);
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--primary-color);
    user-select: all;
}

.backup-codes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm);
    background: var(--background);
    padding: var(--spacing-md);
    border-radius: var(--radius);
    margin: var(--spacing-md) 0;
}

.backup-code {
    font-family: monospace;
    font-size: 0.95rem;
    padding: var(--spacing-xs);
    background: var(--surface);
    border-radius: var(--radius);
    text-align: center;
}

.warning-text {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid var(--warning);
    color: #92400e;
    padding: var(--spacing-sm);
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: var(--spacing-md);
}

.twofa-step h4 {
    margin-bottom: var(--spacing-sm);
}

#2fa-copy-codes-btn {
    margin-right: var(--spacing-sm);
}

/* 2FA Login Section */
.twofa-section {
    padding: var(--spacing-md) 0;
}

.twofa-prompt {
    text-align: center;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

.twofa-input {
    text-align: center;
    font-size: 1.5rem;
    font-family: monospace;
    letter-spacing: 0.3em;
    padding: var(--spacing-md) !important;
}

.twofa-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--spacing-md);
    font-size: 0.875rem;
}

.twofa-backup-toggle {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    cursor: pointer;
    color: var(--text-secondary);
}

.twofa-backup-toggle input {
    cursor: pointer;
}

.text-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0;
}

.text-btn:hover {
    text-decoration: underline;
}

/* Remember Device Toggle (2FA) */
.twofa-remember-toggle {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.twofa-remember-toggle input {
    cursor: pointer;
}

.twofa-options {
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

/* Trusted Devices */
.trusted-devices-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.trusted-device-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.device-info {
    flex: 1;
}

.device-name {
    font-weight: 500;
    color: var(--text-primary);
}

.device-details {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.device-revoke {
    padding: 4px 8px;
    font-size: 0.75rem;
}

.section-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

.loading-text, .empty-text, .error-text {
    text-align: center;
    color: var(--text-secondary);
    padding: var(--spacing-md);
}

.error-text {
    color: var(--error);
}

.danger-outline {
    background: transparent;
    border: 1px solid var(--error);
    color: var(--error);
}

.danger-outline:hover {
    background: var(--error);
    color: white;
}

/* Delete Account Modal */
.delete-account-modal {
    max-width: 450px;
}

.danger-header {
    background: var(--error);
    color: white;
}

.danger-header h3 {
    color: white;
}

.danger-header .modal-close {
    color: white;
}

.delete-warning {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: var(--radius);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    text-align: center;
}

.delete-warning .warning-icon {
    width: 48px;
    height: 48px;
    color: var(--error);
    margin-bottom: var(--spacing-sm);
}

.delete-warning ul {
    text-align: left;
    margin: var(--spacing-sm) 0 0 var(--spacing-lg);
}

.delete-warning li {
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

/* Auth Modal */
.auth-modal {
    width: 100%;
    max-width: 400px;
}

.auth-tabs {
    display: flex;
    margin-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.auth-tab {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-tab:hover {
    color: var(--text-primary);
}

.auth-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.auth-form .input-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.auth-form label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.auth-form input {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.auth-error {
    padding: var(--spacing-sm);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: var(--radius);
    color: var(--error);
    font-size: 0.875rem;
}

.auth-submit {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    margin-top: var(--spacing-sm);
}

/* Context Menu */
.context-menu {
    position: fixed;
    z-index: 10000;
    min-width: 180px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    padding: var(--spacing-xs) 0;
    font-size: 0.875rem;
}

.context-menu.hidden {
    display: none;
}

.context-menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    gap: var(--spacing-lg);
}

.context-menu-item:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

.context-menu-item:disabled {
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.context-menu-label {
    flex: 1;
}

.context-menu-shortcut {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.context-menu-item:hover:not(:disabled) .context-menu-shortcut {
    color: rgba(255, 255, 255, 0.7);
}

.context-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--spacing-xs) 0;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .user-btn span {
        display: none;
    }

    .header-controls {
        gap: var(--spacing-sm);
    }
}

/* ==========================================
   Login Gate - Full Screen Auth Wall
   ========================================== */

.login-gate {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--background) 0%, #1a1a2e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.login-gate.hidden {
    display: none;
}

.login-gate-content {
    width: 100%;
    max-width: 400px;
    padding: var(--spacing-lg);
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-gate-logo {
    text-align: center;
    margin-bottom: var(--spacing-lg);
    color: var(--primary-color);
}

.login-gate-logo svg {
    margin-bottom: var(--spacing-sm);
}

.login-gate-logo h1 {
    font-size: 1.75rem;
    margin-bottom: var(--spacing-xs);
    color: var(--text-primary);
}

.login-gate-logo p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.login-gate-tabs {
    display: flex;
    margin-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.login-gate-tabs.hidden {
    display: none;
}

.gate-tab {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.gate-tab:hover {
    color: var(--text-primary);
}

.gate-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.gate-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.gate-form.hidden {
    display: none;
}

.gate-form .input-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.gate-form label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.gate-form input {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 1rem;
}

.gate-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.gate-error {
    padding: var(--spacing-sm);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: var(--radius);
    color: var(--error);
    font-size: 0.875rem;
}

.gate-error.hidden {
    display: none;
}

/* Registration success message */
.gate-success-message {
    text-align: center;
    padding: var(--spacing-lg);
}

.gate-success-message.hidden {
    display: none;
}

.gate-success-message .success-icon {
    width: 60px;
    height: 60px;
    background: var(--success);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto var(--spacing-md);
}

.gate-success-message h3 {
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
    font-size: 1.5rem;
}

.gate-success-message p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.gate-success-message .email-highlight {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: var(--spacing-md);
}

.gate-success-message .primary-btn {
    margin-top: var(--spacing-lg);
}

.gate-submit {
    width: 100%;
    padding: var(--spacing-md);
    font-size: 1rem;
    margin-top: var(--spacing-sm);
}

.forgot-password-link {
    display: block;
    text-align: center;
    margin-top: var(--spacing-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-decoration: none;
    transition: color 0.2s;
}

.forgot-password-link:hover {
    color: var(--primary-color);
}

.back-to-login {
    display: block;
    text-align: center;
    margin-top: var(--spacing-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-decoration: none;
    transition: color 0.2s;
}

.back-to-login:hover {
    color: var(--primary-color);
}

.form-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: var(--spacing-md);
}

.gate-success {
    padding: var(--spacing-sm);
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--success);
    border-radius: var(--radius);
    color: var(--success);
    font-size: 0.875rem;
}

.gate-success.hidden {
    display: none;
}

.login-gate-footer {
    margin-top: var(--spacing-lg);
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.login-gate-footer .legal-links {
    margin-top: var(--spacing-sm);
}

.login-gate-footer .legal-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.login-gate-footer .legal-links a:hover {
    color: var(--primary-color);
}

.login-gate-footer .legal-links .separator {
    margin: 0 var(--spacing-sm);
    opacity: 0.5;
}

/* Legal Page Modals */
.legal-modal {
    max-width: 800px;
    max-height: 90vh;
}

.legal-content {
    max-height: 70vh;
    overflow-y: auto;
    padding: var(--spacing-lg);
    line-height: 1.7;
}

.legal-content h3 {
    color: var(--text-primary);
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-sm);
    font-size: 1.1rem;
}

.legal-content h4 {
    color: var(--text-primary);
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-xs);
    font-size: 1rem;
}

.legal-content p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.legal-content ul {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    padding-left: var(--spacing-lg);
}

.legal-content li {
    margin-bottom: var(--spacing-xs);
}

.legal-content a {
    color: var(--primary-color);
}

.legal-content .legal-date {
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: var(--spacing-lg);
}

/* Loading state */
.login-gate-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

.login-gate-loading.hidden {
    display: none;
}

@media (max-width: 480px) {
    .login-gate-content {
        margin: var(--spacing-md);
        padding: var(--spacing-md);
    }
}

/* ========== SNAP TOGGLE ========== */
#snap-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

#snap-toggle:hover {
    background: var(--surface-light);
    color: var(--text-primary);
}

#snap-toggle.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* ========== LINE TOOL ========== */
.line-tool-instructions {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
    line-height: 1.5;
    padding: var(--spacing-sm);
    background: var(--surface);
    border-radius: var(--radius);
}

.line-tool-controls {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.line-tool-controls .secondary-btn {
    flex: 1;
}

.line-point-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: var(--spacing-sm);
    background: var(--surface);
    border-radius: var(--radius);
    text-align: center;
}

.line-point-count span {
    font-weight: 600;
    color: var(--text-primary);
}

/* ========== LINE DIMENSION MODAL ========== */
.line-dimension-modal {
    max-width: 380px;
}

.line-preview-info {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-md);
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: var(--spacing-md);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.line-preview-info strong {
    color: var(--text-primary);
}

.dimension-input-container {
    flex: 1;
}

.dimension-input-container input {
    width: 100%;
    font-size: 1.125rem;
    padding: var(--spacing-sm) var(--spacing-md);
}

.dimension-help {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: var(--spacing-sm);
    line-height: 1.5;
}

.dimension-help code {
    background: var(--surface);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: var(--primary-color);
}

#line-dimension-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

#line-dimension-input.error {
    border-color: var(--error);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

/* ========== VERSION LABEL ========== */
.version-label {
    display: inline-block;
    margin-top: var(--spacing-sm);
    padding: 2px 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--surface);
    border-radius: 4px;
}

/* ========== LAYER PANEL ========== */
.layer-panel {
    background: var(--surface-light);
    border-radius: var(--radius);
    max-height: 200px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: var(--spacing-md);
}

.layer-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface-light);
    font-weight: 600;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
}

.layer-panel-header button {
    padding: 4px 12px;
    border: 1px solid var(--primary-color);
    border-radius: var(--radius);
    background: transparent;
    color: var(--primary-color);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.layer-panel-header button:hover {
    background: var(--primary-color);
    color: white;
}

.layer-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-xs);
}

.layer-list-empty {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-align: center;
    padding: var(--spacing-md);
    font-style: italic;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: var(--spacing-xs);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 36px;
}

.layer-item:hover {
    border-color: var(--text-secondary);
}

.layer-item.active {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.1);
}

.layer-visibility-btn,
.layer-lock-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.layer-visibility-btn:hover,
.layer-lock-btn:hover {
    background: var(--surface-light);
    color: var(--text-primary);
}

.layer-visibility-btn.hidden-layer {
    color: var(--text-secondary);
    opacity: 0.5;
}

.layer-lock-btn.locked {
    color: var(--warning);
}

.layer-color-input {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
    background: none;
}

.layer-color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.layer-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.layer-name {
    flex: 1;
    font-size: 0.8125rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: text;
    padding: 2px 4px;
    border-radius: 4px;
    min-width: 0;
}

.layer-name:hover {
    background: var(--surface-light);
}

.layer-name-input {
    flex: 1;
    font-size: 0.8125rem;
    padding: 2px 4px;
    background: var(--background);
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    color: var(--text-primary);
    min-width: 0;
}

.layer-name-input:focus {
    outline: none;
}

.layer-count {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    padding: 2px 6px;
    background: var(--surface-light);
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.layer-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.layer-actions button {
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.layer-actions button:hover:not(:disabled) {
    background: var(--surface-light);
    color: var(--text-primary);
}

.layer-actions button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.layer-delete-btn:hover:not(:disabled) {
    background: var(--error) !important;
    color: white !important;
}

/* ========== HELP BUTTON ========== */
.help-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* ========== FEEDBACK BUTTON ========== */
.feedback-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    background: var(--surface-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.feedback-btn.hidden {
    display: none;
}

/* ========== SHAPE LIBRARY ========== */
.shape-separator {
    width: 1px;
    height: 32px;
    background: var(--border-color);
    margin: 0 var(--spacing-xs);
}

.library-btn {
    background: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

.library-btn:hover {
    background: var(--primary-hover) !important;
}

.shape-library-modal {
    max-width: 700px;
    width: 95%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.shape-library-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    padding: var(--spacing-md);
    gap: var(--spacing-md);
}

.shape-library-categories {
    display: flex;
    gap: var(--spacing-xs);
    flex-wrap: wrap;
}

.library-cat-btn {
    padding: var(--spacing-xs) var(--spacing-md);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.library-cat-btn:hover {
    background: var(--surface-light);
    color: var(--text-primary);
}

.library-cat-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.shape-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: var(--spacing-sm);
    overflow-y: auto;
    flex: 1;
    min-height: 200px;
    padding: var(--spacing-xs);
}

.library-shape-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-sm);
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.library-shape-item:hover {
    border-color: var(--primary-color);
    background: var(--surface-light);
}

.library-shape-item.selected {
    border-color: var(--primary-color);
    background: rgba(37, 99, 235, 0.1);
}

.library-shape-preview {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--spacing-xs);
}

.library-shape-preview svg {
    width: 100%;
    height: 100%;
    stroke: var(--text-primary);
    fill: none;
    stroke-width: 1.5;
}

.library-shape-name {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.2;
}

.shape-library-params {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: var(--spacing-md);
    display: none;
}

.shape-library-params.active {
    display: block;
}

.shape-library-params h4 {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-sm);
}

.shape-params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--spacing-sm);
}

.shape-params-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.shape-params-grid label span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.shape-params-grid input {
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.875rem;
}

/* ========== FEEDBACK MODAL ========== */
.feedback-modal {
    max-width: 500px;
    width: 95%;
}

.feedback-form {
    padding: var(--spacing-lg);
}

.feedback-form .form-group {
    margin-bottom: var(--spacing-md);
}

.feedback-form label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.feedback-form input[type="text"],
.feedback-form textarea {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.feedback-form input[type="text"]:focus,
.feedback-form textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.feedback-form textarea {
    resize: vertical;
    min-height: 120px;
}

.char-count {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: var(--spacing-xs);
}

/* Feedback Type Selector */
.feedback-type-selector {
    display: flex;
    gap: var(--spacing-sm);
}

.feedback-type-option {
    flex: 1;
    cursor: pointer;
}

.feedback-type-option input[type="radio"] {
    display: none;
}

.feedback-type-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.feedback-type-option input[type="radio"]:checked + .feedback-type-label.feature {
    background: rgba(34, 197, 94, 0.1);
    border-color: #22c55e;
    color: #22c55e;
}

.feedback-type-option input[type="radio"]:checked + .feedback-type-label.bug {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

.feedback-type-label:hover {
    border-color: var(--text-secondary);
}

/* Feedback Note */
.feedback-note {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface);
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

.feedback-note svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--primary-color);
}

/* Feedback Submit Button States */
.feedback-form .primary-btn {
    min-width: 140px;
}

.feedback-form .btn-loading {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.feedback-form .btn-loading::before {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.feedback-form .btn-text.hidden,
.feedback-form .btn-loading.hidden {
    display: none;
}

/* ========== HELP MODAL ========== */
.help-modal {
    max-width: 900px;
    width: 95%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.help-modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* Help Navigation Sidebar */
.help-nav {
    width: 200px;
    flex-shrink: 0;
    background: var(--surface-light);
    border-right: 1px solid var(--border-color);
    padding: var(--spacing-sm);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    overflow-y: auto;
}

.help-nav-item {
    padding: var(--spacing-sm) var(--spacing-md);
    background: transparent;
    border: none;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.help-nav-item:hover {
    background: var(--surface);
    color: var(--text-primary);
}

.help-nav-item.active {
    background: var(--primary-color);
    color: white;
}

/* Help Content Area */
.help-content {
    flex: 1;
    padding: var(--spacing-lg);
    overflow-y: auto;
    min-width: 0;
}

.help-section {
    display: none;
}

.help-section.active {
    display: block;
}

.help-section h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 2px solid var(--primary-color);
}

.help-section h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-top: var(--spacing-lg);
    margin-bottom: var(--spacing-sm);
}

.help-section p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--spacing-md);
}

.help-section ul,
.help-section ol {
    color: var(--text-secondary);
    margin-left: var(--spacing-lg);
    margin-bottom: var(--spacing-md);
    line-height: 1.8;
}

.help-section li {
    margin-bottom: var(--spacing-xs);
}

.help-section strong {
    color: var(--text-primary);
}

/* Keyboard keys */
.help-section kbd {
    display: inline-block;
    padding: 3px 8px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--text-primary);
    box-shadow: 0 2px 0 var(--border-color);
}

/* Help Tables */
.help-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--spacing-lg);
    font-size: 0.875rem;
}

.help-table th,
.help-table td {
    padding: var(--spacing-sm) var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.help-table th {
    background: var(--surface-light);
    color: var(--text-primary);
    font-weight: 600;
}

.help-table td {
    color: var(--text-secondary);
}

.shortcuts-table td:first-child {
    width: 180px;
}

/* Tool Grid */
.help-tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.help-tool-item {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.help-tool-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-light);
    border-radius: var(--radius);
    color: var(--primary-color);
}

.help-tool-icon svg {
    width: 24px;
    height: 24px;
}

.help-tool-info strong {
    display: block;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.help-tool-info p {
    font-size: 0.8rem;
    margin: 0;
    color: var(--text-secondary);
}

/* Shortcut Grid */
.help-shortcut-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.help-shortcut-item {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface);
    border-radius: var(--radius);
}

.shortcut-label {
    display: block;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.875rem;
}

.shortcut-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Screenshot Placeholder */
.help-screenshot {
    margin: var(--spacing-lg) 0;
}

.screenshot-placeholder {
    padding: var(--spacing-xl, 32px);
    background: var(--surface);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    text-align: center;
}

.screenshot-placeholder span {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.screenshot-placeholder p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
    font-style: italic;
}

/* Responsive Help Modal */
@media (max-width: 768px) {
    .help-modal {
        max-height: 90vh;
    }

    .help-modal-body {
        flex-direction: column;
    }

    .help-nav {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: var(--spacing-xs);
        max-height: 120px;
        overflow-y: auto;
    }

    .help-nav-item {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 0.75rem;
        white-space: nowrap;
    }

    .help-content {
        padding: var(--spacing-md);
    }

    .help-section h2 {
        font-size: 1.25rem;
    }

    .help-tool-grid {
        grid-template-columns: 1fr;
    }

    .shortcuts-table td:first-child {
        width: auto;
    }
}

/* ============================================
   Toast Notification System
   ============================================ */

/* Toast Container - fixed position top-right */
.toast-container {
    position: fixed;
    top: var(--spacing-md);
    right: var(--spacing-md);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    pointer-events: none;
}

/* Toast Base */
.toast {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: var(--spacing-sm) var(--spacing-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    pointer-events: auto;
    animation: toast-in 0.3s ease;
    max-width: 350px;
}

/* Toast variants */
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--primary-color); }

/* Toast animations */
@keyframes toast-in {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

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

/* ============================================
   Loading States / Skeletons
   ============================================ */

/* Skeleton loader base */
.skeleton {
    background: linear-gradient(90deg,
        var(--surface-light) 25%,
        var(--surface) 50%,
        var(--surface-light) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: var(--radius);
}

@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Skeleton variants */
.skeleton-text { height: 1rem; margin-bottom: var(--spacing-xs); }
.skeleton-text.short { width: 60%; }
.skeleton-button { height: 40px; width: 120px; }
.skeleton-card { height: 100px; }

/* Inline spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Button loading state */
.btn-with-spinner {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.btn-with-spinner .spinner { display: none; }
.btn-with-spinner.loading .spinner { display: block; }
.btn-with-spinner.loading .btn-text { opacity: 0.7; }

/* ============================================
   Onboarding Tour
   ============================================ */

/* Onboarding overlay */
.onboarding-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1500;
    pointer-events: auto;
}

/* Spotlight cutout */
.onboarding-spotlight {
    position: absolute;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7);
    border-radius: var(--radius);
    pointer-events: none;
    transition: all 0.3s ease;
}

/* Tooltip */
.onboarding-tooltip {
    position: absolute;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: var(--spacing-md);
    max-width: 300px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 1501;
}

.onboarding-tooltip h4 {
    margin: 0 0 var(--spacing-sm);
    color: var(--text-primary);
}

.onboarding-tooltip p {
    margin: 0 0 var(--spacing-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.onboarding-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.onboarding-progress {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.onboarding-actions {
    display: flex;
    gap: var(--spacing-sm);
}

/* ============================================
   Export Data Modal
   ============================================ */

.export-data-list {
    margin: var(--spacing-md) 0;
    padding-left: var(--spacing-lg);
    color: var(--text-secondary);
}

.export-data-list li {
    margin-bottom: var(--spacing-xs);
}

.profile-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: var(--spacing-md);
}

/* Projects loading state */
.projects-loading {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

/* Help tour section */
.help-tour-section {
    background: var(--surface-light);
    border-radius: var(--radius);
    padding: var(--spacing-md);
    margin: var(--spacing-md) 0;
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.help-tour-description {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ============================================
   Auto Feed Rate Badge
   ============================================ */

.stat-value-with-badge {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.auto-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    background: var(--success);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 3px;
}

.auto-badge.hidden {
    display: none;
}

.auto-feed-toggle {
    padding: var(--spacing-sm) 0;
    border-top: 1px solid var(--border-color);
    margin-top: var(--spacing-sm);
}

.auto-feed-toggle .checkbox-label {
    font-size: 0.8rem;
}

/* ============================================
   Quote Button & Modal
   ============================================ */

.quote-btn {
    width: 100%;
    margin-top: var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    background: var(--primary-color);
    color: white;
}

.quote-btn:hover {
    background: var(--primary-hover);
}

.quote-modal {
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
}

.quote-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

@media (max-width: 600px) {
    .quote-form-grid {
        grid-template-columns: 1fr;
    }
}

.quote-section {
    background: var(--background);
    border-radius: var(--radius);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.quote-section-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.quote-section .input-group {
    margin-bottom: var(--spacing-sm);
}

.quote-section label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 2px;
}

.quote-section input,
.quote-section textarea,
.quote-section select {
    width: 100%;
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.quote-section input:focus,
.quote-section textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.quote-summary {
    background: var(--surface-light);
    border-radius: var(--radius);
    padding: var(--spacing-md);
}

.quote-summary-title {
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--border-color);
}

.quote-line {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-xs) 0;
    font-size: 0.875rem;
}

.quote-line.subtotal {
    border-top: 1px solid var(--border-color);
    margin-top: var(--spacing-xs);
    padding-top: var(--spacing-sm);
}

.quote-line.adjustment {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.quote-line.total {
    border-top: 2px solid var(--border-color);
    margin-top: var(--spacing-sm);
    padding-top: var(--spacing-sm);
    font-weight: 600;
    font-size: 1rem;
    color: var(--success);
}

.quote-terms {
    margin-top: var(--spacing-md);
}

.quote-terms textarea {
    min-height: 60px;
    resize: vertical;
}

/* Shape Toolpath Options Section */
.shape-toolpath-section {
    border-color: var(--primary);
}

.shape-toolpath-section summary {
    background: rgba(var(--primary-rgb), 0.1);
}

.shape-toolpath-info {
    padding: var(--spacing-sm);
    background: var(--surface-light);
    border-radius: var(--radius);
    font-size: 0.85rem;
}

.shape-toolpath-info .shape-count {
    font-weight: 500;
}

.kerf-auto-info {
    padding: var(--spacing-xs) var(--spacing-sm);
    background: rgba(var(--primary-rgb), 0.05);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.8rem;
}

#shape-kerf-mode option[value="auto"] {
    font-weight: 500;
}

/* Lead Settings Groups */
.lead-settings-group {
    background: var(--surface-light);
    border-radius: var(--radius);
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.lead-header {
    font-weight: 500;
    margin-bottom: var(--spacing-xs);
}

.lead-settings {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    padding-left: var(--spacing-md);
    border-left: 2px solid var(--primary);
    margin-top: var(--spacing-xs);
}

.lead-settings label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-sm);
}

.lead-settings label span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.lead-settings .input-with-unit {
    min-width: 100px;
}

.lead-settings .input-with-unit input {
    width: 60px;
}

.setting-hint {
    display: block;
    margin-top: var(--spacing-xs);
    color: var(--text-secondary);
    font-size: 0.75rem;
}
