/* ═══════════════════════════════════════════════════════════════
   STEP2DXF-V2 — Merged Stylesheet
   Platform layout + design tokens + app component styles.
   ═══════════════════════════════════════════════════════════════ */

/* ── Design Tokens ── */
:root {
    --bg-0: #080c12;
    --bg-1: #0e1520;
    --bg-2: #151c28;
    --bg-3: #1a2436;
    --border: #1c2b3e;
    --border-hover: #263a52;
    --accent: #00d4ff;
    --accent-dim: rgba(0,212,255,0.12);
    --accent-hover: #33ddff;
    --success: #00e676;
    --error: #ff4757;
    --warning: #ffb347;
    --text-1: #dce6f0;
    --text-2: #8fa3b8;
    --text-3: #5a7088;
    --font: 'DM Sans', system-ui, -apple-system, sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
    --radius: 8px;
    --radius-sm: 5px;
    --radius-lg: 12px;
    --sidebar-w: clamp(280px, 30vw, 50vw);  /* Startbreite linke Spalte = 30% des Fensters (min 280px), Drag überschreibt */
    --header-h: 50px;
    --status-h: 28px;
    --shadow: 0 2px 12px rgba(0,0,0,0.4);
    --transition: 0.2s ease;
    /* Legacy variable aliases for old component styles */
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #22253a;
    --text: #e2e8f0;
    --text-dim: #94a3b8;
    --hidden-line: #f87171;
    --visible-line: #e2e8f0;
}

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

body {
    font-family: var(--font);
    background: var(--bg-0);
    color: var(--text-1);
    min-height: 100vh;
    overflow: hidden;
    line-height: 1.5;
}

/* ══════════════════════════════════════════
   LOGIN OVERLAY
   ══════════════════════════════════════════ */
#loginOverlay {
    position: fixed; inset: 0;
    z-index: 99999;
    background: var(--bg-0);
    display: flex; align-items: center; justify-content: center;
}
.login-card {
    width: 380px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    box-shadow: var(--shadow);
}
.login-logo {
    text-align: center; margin-bottom: 28px;
}
.login-logo h1 {
    font-size: 1.5rem; font-weight: 700; color: var(--text-1);
    letter-spacing: -0.02em;
}
.login-logo h1 span { color: var(--accent); }
.login-logo p {
    color: var(--text-3); font-size: 0.8rem; margin-top: 4px;
}
.login-field {
    margin-bottom: 14px;
}
.login-field label {
    display: block; font-size: 0.75rem; color: var(--text-2);
    margin-bottom: 5px; font-weight: 500;
}
.login-field input {
    width: 100%; padding: 10px 14px;
    background: var(--bg-2); color: var(--text-1);
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.9rem; font-family: var(--font);
    outline: none; transition: border-color var(--transition);
}
.login-field input:focus {
    border-color: var(--accent);
}
.login-btn {
    width: 100%; padding: 11px;
    background: var(--accent); color: var(--bg-0);
    border: none; border-radius: var(--radius);
    font-size: 0.9rem; font-weight: 600; cursor: pointer;
    font-family: var(--font); transition: background var(--transition);
    margin-top: 6px;
}
.login-btn:hover { background: var(--accent-hover); }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.login-error {
    color: var(--error); font-size: 0.78rem; margin-top: 12px;
    display: none; text-align: center;
}

/* ══════════════════════════════════════════
   MAIN LAYOUT GRID
   ══════════════════════════════════════════ */
#appShell {
    display: none;
    grid-template-rows: var(--header-h) 1fr var(--status-h);
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-areas:
        "header  header"
        "sidebar main"
        "status  status";
    height: 100vh; width: 100vw;
}
#appShell.visible {
    display: grid;
}

/* ── Header ── */
.platform-header {
    grid-area: header;
    display: flex; align-items: center;
    background: var(--bg-1);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    z-index: 100;
    gap: 4px;
}
.header-brand {
    display: flex; align-items: center; gap: 10px;
    margin-right: 24px; flex-shrink: 0;
}
.header-brand h1 {
    font-size: 1rem; font-weight: 700; white-space: nowrap;
}
.header-brand h1 span { color: var(--accent); }

/* Nav buttons */
.header-nav {
    display: flex; gap: 2px; flex: 1;
}
.nav-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 14px; height: 34px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--text-2);
    font-size: 0.82rem; font-weight: 500;
    font-family: var(--font);
    cursor: pointer; transition: all var(--transition);
    white-space: nowrap;
}
.nav-btn:hover {
    color: var(--text-1);
    background: var(--bg-2);
    border-color: var(--border);
}
.nav-btn.active {
    color: var(--accent);
    background: var(--accent-dim);
    border-color: rgba(0,212,255,0.25);
}
.nav-btn .nav-icon { font-size: 1rem; }

/* User menu area */
.header-user {
    display: flex; align-items: center; gap: 8px;
    margin-left: auto; flex-shrink: 0;
    position: relative;
}
.user-trigger {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 12px; height: 34px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-2);
    font-size: 0.8rem; cursor: pointer;
    font-family: var(--font);
    transition: all var(--transition);
}
.user-trigger:hover { border-color: var(--border-hover); color: var(--text-1); }
.user-avatar {
    width: 24px; height: 24px;
    background: var(--accent-dim);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; color: var(--accent); font-weight: 600;
}
.user-dropdown {
    position: absolute; top: calc(100% + 6px); right: 0;
    width: 220px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: none; z-index: 200;
    overflow: hidden;
}
.user-dropdown.open { display: block; }
.user-dropdown-item {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; width: 100%;
    background: none; border: none;
    color: var(--text-2); font-size: 0.82rem;
    font-family: var(--font); cursor: pointer;
    transition: all var(--transition); text-align: left;
}
.user-dropdown-item:hover {
    background: var(--bg-3); color: var(--text-1);
}
.user-dropdown-item.danger:hover { color: var(--error); }
.user-dropdown-sep {
    height: 1px; background: var(--border); margin: 2px 0;
}

/* Admin gear */
.admin-btn {
    display: none;
    align-items: center; justify-content: center;
    width: 34px; height: 34px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-3); font-size: 1rem;
    cursor: pointer; transition: all var(--transition);
}
.admin-btn:hover { color: var(--accent); border-color: var(--accent); }
.admin-btn.active { color: var(--accent); background: var(--accent-dim); border-color: rgba(0,212,255,0.25); }

/* ── Sidebar ── */
.platform-sidebar {
    grid-area: sidebar;
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    overflow: hidden;
    min-height: 0;
    position: relative;
    z-index: 50;
}
.platform-sidebar.collapsed {
    display: none;
}
.sidebar-resize-handle {
    position: absolute; top: 0; right: 0; width: 4px; height: 100%;
    cursor: col-resize; z-index: 60;
    transition: background var(--transition);
}
.sidebar-resize-handle:hover { background: var(--accent); }

.sidebar-panel {
    display: none;
    flex-direction: column;
    flex: 1; overflow: hidden; min-height: 0;
}
.sidebar-panel.active {
    display: flex;
}

/* ── Main Content ── */
.platform-main {
    grid-area: main;
    background: var(--bg-0);
    overflow: hidden;
    position: relative;
}
.main-panel {
    display: none;
    width: 100%; height: 100%;
    position: absolute; inset: 0;
}
.main-panel.active {
    display: flex;
    flex-direction: column;
}

/* ── Status Bar ── */
.platform-status {
    grid-area: status;
    display: flex; align-items: center;
    background: var(--bg-1);
    border-top: 1px solid var(--border);
    padding: 0 16px;
    font-size: 0.72rem; color: var(--text-3);
    gap: 16px; z-index: 100;
}
.status-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--success);
    display: inline-block;
    margin-right: 4px;
}
.status-dot.offline { background: var(--error); }

/* ══════════════════════════════════════════
   IMPORT MODE — sidebar content
   ══════════════════════════════════════════ */
.import-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    margin: 16px;
}
.import-dropzone:hover, .import-dropzone.dragover {
    border-color: var(--accent);
    background: var(--accent-dim);
}
.import-dropzone-icon { font-size: 2.2rem; margin-bottom: 8px; }
.import-dropzone-text { color: var(--text-2); font-size: 0.85rem; }
.import-dropzone-text strong { color: var(--accent); }
.import-dropzone-formats { color: var(--text-3); font-size: 0.72rem; margin-top: 6px; }

/* ══════════════════════════════════════════
   KONSTRUKTEUR / CHAT
   ══════════════════════════════════════════ */
.chat-iframe {
    width: 100%; height: 100%; border: none;
    background: var(--bg-0);
}

/* ══════════════════════════════════════════
   DATEIEN MODE
   ══════════════════════════════════════════ */
.files-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.files-search input {
    width: 100%; padding: 8px 12px;
    background: var(--bg-2); color: var(--text-1);
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.82rem; font-family: var(--font);
    outline: none;
}
.files-search input:focus { border-color: var(--accent); }

.files-grid {
    flex: 1; overflow-y: auto; padding: 16px;
}
.files-table {
    width: 100%; border-collapse: collapse;
    font-size: 0.82rem;
}
.files-table th {
    text-align: left; padding: 8px 10px;
    color: var(--text-3); font-size: 0.72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--bg-0);
}
.files-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(28,43,62,0.4);
    vertical-align: middle;
}
.files-table tr:hover td { background: var(--bg-2); }

/* ══════════════════════════════════════════
   ADMIN PANEL
   ══════════════════════════════════════════ */
.admin-panel {
    padding: 20px;
    overflow-y: auto; flex: 1;
}
.admin-section {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px; margin-bottom: 16px;
}
.admin-section h3 {
    font-size: 0.9rem; font-weight: 600;
    color: var(--text-1); margin-bottom: 14px;
}

/* ══════════════════════════════════════════
   SHARED UI COMPONENTS
   ══════════════════════════════════════════ */
.badge {
    display: inline-flex; align-items: center;
    padding: 2px 8px; border-radius: 20px;
    font-size: 0.68rem; font-weight: 600;
    letter-spacing: 0.02em;
}
.badge-step { background: rgba(0,212,255,0.12); color: var(--accent); }
.badge-dxf  { background: rgba(0,230,118,0.12); color: var(--success); }
.badge-img  { background: rgba(255,179,71,0.12); color: var(--warning); }
.badge-chat { background: rgba(155,89,255,0.12); color: #9b59ff; }

.btn-primary {
    padding: 8px 18px;
    background: var(--accent); color: var(--bg-0);
    border: none; border-radius: var(--radius);
    font-size: 0.82rem; font-weight: 600; cursor: pointer;
    font-family: var(--font); transition: all var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
    padding: 8px 18px;
    background: var(--bg-3); color: var(--text-2);
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.82rem; font-weight: 500; cursor: pointer;
    font-family: var(--font); transition: all var(--transition);
}
.btn-secondary:hover { background: var(--border); color: var(--text-1); }

.btn-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px;
    background: none; border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-3);
    cursor: pointer; font-size: 0.85rem; transition: all var(--transition);
}
.btn-icon:hover { color: var(--accent); border-color: var(--accent); }
.btn-icon.danger:hover { color: var(--error); border-color: var(--error); }

.form-input {
    width: 100%; padding: 9px 12px;
    background: var(--bg-2); color: var(--text-1);
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.85rem; font-family: var(--font); outline: none;
    transition: border-color var(--transition);
}
.form-input:focus { border-color: var(--accent); }

.form-select {
    width: 100%; padding: 9px 12px;
    background: var(--bg-2); color: var(--text-1);
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 0.85rem; font-family: var(--font); outline: none;
    cursor: pointer;
}

.form-checkbox {
    accent-color: var(--accent); cursor: pointer;
}

.card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-hover); }

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* Password change modal */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 99998;
}
.modal-card {
    width: 360px;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow);
}
.modal-card h3 {
    font-size: 1rem; margin-bottom: 16px; color: var(--text-1);
}

/* ══════════════════════════════════════════
   PLATFORM OVERRIDES for legacy app styles
   ══════════════════════════════════════════ */
body > .app {
    display: contents !important;
    height: auto !important;
}

.sidebar-panel > .app {
    flex: 1; display: flex; flex-direction: column;
    overflow: hidden; min-height: 0;
}

.sidebar {
    width: 100% !important; min-width: unset !important; max-width: unset !important;
    border-right: none !important;
    background: transparent !important;
    height: 100% !important;
}

.viewer {
    width: 100% !important; height: 100% !important;
    flex: 1 !important;
    position: relative !important;
}

.sidebar-header { border-bottom-color: var(--border) !important; }

/* Tab bar hidden — platform header nav replaces it */
.tab-bar { display: none !important; }

/* Tab contents — switched by platform nav */
.tab-content { display: none; }
.tab-content.platform-active { display: flex; flex-direction: column; flex: 1; overflow: hidden; min-height: 0; }
/* Bild/Skizze, Dateien, Admin: Inhalt kann höher als das Panel werden (z.B. mit
   geladener Bild-Vorschau) — vertikal scrollbar machen, sonst ist der untere Button
   ("In Teileliste übernehmen") abgeschnitten und nicht erreichbar. */
#tabImage.platform-active, #tabFiles.platform-active, #tabAdmin.platform-active { overflow-y: auto; }

.sidebar-body { flex: 1; overflow: hidden; min-height: 0; }

#chatOverlay { display: none !important; }


/* ══════════════════════════════════════════════════════════════
   LEGACY APP COMPONENT STYLES
   (from original app.css, without conflicting layout/tab rules)
   ══════════════════════════════════════════════════════════════ */

/* Sidebar layout (used inside platform sidebar panels) */
.sidebar {
    display: flex; flex-direction: column;
    overflow: hidden; min-height: 0; position: relative;
}
.sidebar-resize {
    position: absolute; top: 0; right: -5px; width: 14px; height: 100%;
    cursor: col-resize; z-index: 10; background: transparent;
    transition: background 0.15s;
}
/* Sichtbare dünne Linie mittig im breiten Greifbereich */
.sidebar-resize::before {
    content: ''; position: absolute; top: 0; bottom: 0; left: 5px; width: 2px;
    background: var(--border); transition: background 0.15s;
}
.sidebar-resize:hover::before, .sidebar-resize.active::before {
    background: var(--accent);
}
.sidebar-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.sidebar-header h1 { font-size: 1.4rem; font-weight: 600; }
.sidebar-header h1 span { color: var(--accent); }
.sidebar-header p { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.25rem; }
.sidebar-body {
    flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0;
}
.sidebar-top {
    padding: 1.25rem 1.5rem; overflow-y: auto; flex-shrink: 0;
    min-height: 80px;
}
.sidebar-hsplit {
    height: 14px; margin: -4px 0; background: transparent; cursor: row-resize;
    flex-shrink: 0; position: relative; z-index: 11;
}
/* Sichtbarer Greif-Indikator: kurze Linie mittig (Doppellinie als Hinweis) */
.sidebar-hsplit::before {
    content: ''; position: absolute; left: 50%; top: 50%;
    width: 40px; height: 4px; transform: translate(-50%, -50%);
    border-top: 2px solid var(--border); border-bottom: 2px solid var(--border);
    border-radius: 2px; transition: border-color 0.15s;
}
.sidebar-hsplit:hover::before, .sidebar-hsplit.active::before {
    border-color: var(--accent);
}
.sidebar-bottom {
    flex: 1; padding: 0 1.5rem 1.25rem; display: flex; flex-direction: column;
    overflow: hidden; min-height: 0;
}

/* Dropzone */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 2rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--accent);
    background: rgba(79, 143, 247, 0.05);
}
.dropzone-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.dropzone-text { color: var(--text-dim); font-size: 0.9rem; }
.dropzone-text strong { color: var(--accent); }

/* Kompakte Dropzone: weniger Höhe, Icon inline, Klick-Links */
.dropzone-compact {
    padding: 0.7rem 0.9rem;
    border-radius: 8px;
}
.dropzone-compact .dropzone-text {
    font-size: 0.82rem; margin: 0;
}
.dropzone-compact .dropzone-icon {
    font-size: 1rem; margin: 0;
}
.dropzone-links {
    margin: 0.3rem 0 0; font-size: 0.78rem;
}
.dropzone-links a {
    color: var(--accent); text-decoration: none; cursor: pointer;
}
.dropzone-links a:hover { text-decoration: underline; }
.dropzone-links .sep { color: var(--text-dim); margin: 0 0.35rem; }

/* File info */
.file-info {
    margin-top: 0.75rem; padding: 0.6rem 0.8rem;
    background: rgba(79, 143, 247, 0.1); border-radius: 8px;
    display: none; align-items: center; gap: 0.5rem; font-size: 0.85rem;
}
.file-info.show { display: flex; }
.file-info .name { flex: 1; }
.file-info .size { color: var(--text-dim); }

/* Options / Toggle */
.options { margin-top: 1rem; display: flex; align-items: center; gap: 0.6rem; }
.toggle { position: relative; width: 38px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
    position: absolute; inset: 0; background: var(--border);
    border-radius: 11px; cursor: pointer; transition: 0.2s;
}
.toggle .slider::before {
    content: ""; position: absolute; height: 16px; width: 16px;
    left: 3px; bottom: 3px; background: white;
    border-radius: 50%; transition: 0.2s;
}
.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::before { transform: translateX(16px); }

/* Button */
.btn {
    margin-top: 1rem; width: 100%; padding: 0.75rem;
    border: none; border-radius: 8px; background: var(--accent);
    color: white; font-size: 0.95rem; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { background: var(--border); color: var(--text-dim); cursor: not-allowed; }

/* Progress */
.progress { margin-top: 1rem; display: none; }
.progress.show { display: block; }
.progress-bar { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-bar .fill {
    height: 100%; background: var(--accent); border-radius: 2px;
    animation: loading 1.5s ease-in-out infinite; width: 40%;
}
@keyframes loading { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }
.progress-text { margin-top: 0.4rem; font-size: 0.8rem; color: var(--text-dim); }

/* Error box */
.error-box {
    margin-top: 0.75rem; padding: 0.75rem; font-size: 0.85rem;
    background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3);
    border-radius: 8px; color: var(--error); display: none;
}
.error-box.show { display: block; }

/* Results */
.results { margin-top: 0; display: none; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.results.show { display: flex; }
.result-header { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.75rem; font-size: 0.9rem; }

/* Part list */
.part-list { background: var(--surface2); border-radius: 8px; overflow: hidden; flex: 1; overflow-y: auto; min-height: 0; }
.part-item {
    display: flex; align-items: center; padding: 0.5rem 0.8rem;
    border-bottom: 1px solid var(--border); font-size: 0.8rem;
    gap: 0.5rem; cursor: pointer; transition: background 0.15s;
    flex-wrap: wrap;
}
.part-item .part-dim-list {
    flex-basis: 100%; width: 100%; margin: 2px 0 0 16px;
    font-size: 0.66rem; color: var(--text-dim); line-height: 1.3;
    white-space: normal; overflow-wrap: anywhere;
}
.part-item:last-child { border-bottom: none; }
.part-item:hover { background: rgba(79, 143, 247, 0.08); }
.part-item.active { background: rgba(79, 143, 247, 0.15); }
.part-item.multi-selected { background: rgba(0, 212, 255, 0.16); box-shadow: inset 3px 0 0 var(--accent); }
.part-item.multi-selected.active { background: rgba(0, 212, 255, 0.24); }
.dup-count { background: var(--surface2); color: var(--accent); border-radius: 8px; padding: 0 6px; font-size: 11px; font-weight: 600; flex: 0 0 auto; }
.part-item .status { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.part-item .status.ok { background: var(--success); }
.part-item .status.fail { background: var(--error); }
.part-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part-item .edges { color: var(--text-dim); flex-shrink: 0; }

/* Download button */
.download-btn {
    margin-top: 0.75rem; display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.6rem 1.2rem; background: var(--success); color: #0f1117;
    border: none; border-radius: 8px; font-weight: 600; font-size: 0.9rem;
    cursor: pointer; text-decoration: none; transition: opacity 0.2s;
}
.download-btn:hover { opacity: 0.85; }

/* Viewer */
.viewer {
    flex: 1; display: flex; flex-direction: column;
    background: var(--bg); position: relative;
}
.viewer-toolbar {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 1rem; background: var(--surface);
    border-bottom: 1px solid var(--border); font-size: 0.85rem;
}
.viewer-toolbar .part-title { flex: 1; font-weight: 500; }
.viewer-toolbar button {
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--text); padding: 0.3rem 0.6rem; border-radius: 5px;
    cursor: pointer; font-size: 0.8rem; transition: background 0.15s;
}
.viewer-toolbar button:hover { background: var(--border); }
.viewer-canvas-wrap {
    flex: 1; position: relative; overflow: hidden;
}
.viewer-canvas-wrap canvas {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
}
.viewer-empty {
    flex: 1; display: flex; align-items: center; justify-content: center;
    color: var(--text-dim); font-size: 0.95rem;
}
.viewer-legend {
    position: absolute; bottom: 1rem; right: 1rem;
    background: rgba(26,29,39,0.9); border: 1px solid var(--border);
    border-radius: 8px; padding: 0.5rem 0.75rem; font-size: 0.75rem;
}
.legend-item { display: flex; align-items: center; gap: 0.4rem; margin: 0.2rem 0; }
.legend-line { width: 20px; height: 2px; }
.legend-line.vis { background: var(--visible-line); }
.legend-line.hid { background: var(--hidden-line); stroke-dasharray: 4 3; }
.legend-line.bend { background: #22d3ee; height: 2px; background-image: repeating-linear-gradient(90deg, #22d3ee 0, #22d3ee 6px, transparent 6px, transparent 8px, #22d3ee 8px, #22d3ee 10px, transparent 10px, transparent 14px); background-size: 14px 2px; }

/* Search */
.search-box {
    margin-bottom: 0.5rem;
}
.search-box input {
    width: 100%; padding: 0.45rem 0.7rem;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text); font-size: 0.8rem;
    outline: none;
}
.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--text-dim); }

/* Tree / Group styles */
.group-header {
    display: flex; align-items: center; padding: 0.45rem 0.8rem;
    border-bottom: 1px solid var(--border); font-size: 0.8rem;
    gap: 0.4rem; cursor: pointer; transition: background 0.15s;
    user-select: none;
}
.group-header:hover { background: rgba(79, 143, 247, 0.06); }
.group-arrow {
    font-size: 0.65rem; width: 0.9rem; text-align: center;
    flex-shrink: 0; transition: transform 0.15s; display: inline-block;
}
.group-arrow.collapsed { transform: rotate(-90deg); }
.group-name { flex: 1; font-weight: 600; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-count { color: var(--text-dim); font-size: 0.7rem; flex-shrink: 0; }
.group-children.collapsed { display: none; }

.part-item .dims {
    color: var(--text-dim); font-size: 0.65rem; flex-shrink: 0;
    font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
    opacity: 0.8;
}
.part-item .dl-btn {
    background: none; border: none; color: var(--text-dim);
    cursor: pointer; font-size: 0.75rem; padding: 0.15rem 0.3rem;
    border-radius: 4px; flex-shrink: 0; transition: all 0.15s;
    opacity: 0; line-height: 1;
}
.part-item:hover .dl-btn { opacity: 1; }
.part-item .dl-btn:hover { color: var(--success); background: rgba(52,211,153,0.15); }
.group-header .dl-btn {
    background: none; border: none; color: var(--text-dim);
    cursor: pointer; font-size: 0.7rem; padding: 0.15rem 0.3rem;
    border-radius: 4px; flex-shrink: 0; transition: all 0.15s;
    opacity: 0; line-height: 1;
}
.group-header:hover .dl-btn { opacity: 1; }
.group-header .dl-btn:hover { color: var(--success); background: rgba(52,211,153,0.15); }
.viewer-dims {
    font-size: 0.8rem; color: var(--accent);
    font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
}

/* 3D Controls Overlay */
.viewer-3d-controls {
    position: absolute; top: 0.6rem; right: 0.6rem;
    display: flex; flex-direction: column; gap: 0.4rem;
    z-index: 20; pointer-events: none;
    max-height: calc(100% - 1.2rem); overflow-y: auto;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.viewer-3d-controls > * { pointer-events: auto; }
.ctrl-group {
    background: rgba(26,29,39,0.92); border: 1px solid var(--border);
    border-radius: 8px; padding: 0.45rem 0.65rem;
    font-size: 0.75rem; display: flex; flex-direction: column; gap: 0.35rem;
}
.ctrl-group-row {
    display: flex; align-items: center; gap: 0.5rem;
}
.ctrl-btn {
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--text); padding: 0.25rem 0.55rem; border-radius: 5px;
    cursor: pointer; font-size: 0.75rem; transition: all 0.15s;
    white-space: nowrap;
}
.ctrl-btn:hover { background: var(--border); }
.ctrl-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ctrl-label { color: var(--text-dim); font-size: 0.7rem; min-width: 2rem; }
.ctrl-slider {
    -webkit-appearance: none; appearance: none;
    width: 100px; height: 4px; border-radius: 2px;
    background: var(--border); outline: none;
}
.ctrl-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--accent); cursor: pointer;
}
.ctrl-slider::-moz-range-thumb {
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--accent); cursor: pointer; border: none;
}
.ctrl-axis-btns { display: flex; gap: 0.2rem; }
.ctrl-axis-btn {
    background: var(--surface2); border: 1px solid var(--border);
    color: var(--text-dim); padding: 0.15rem 0.4rem; border-radius: 4px;
    cursor: pointer; font-size: 0.7rem; font-weight: 600; transition: all 0.15s;
}
.ctrl-axis-btn:hover { background: var(--border); }
.ctrl-axis-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ctrl-value { color: var(--text-dim); font-size: 0.65rem; font-family: monospace; min-width: 3.5rem; text-align: right; }
.pick-plane-cursor { cursor: crosshair !important; }
.ctrl-btn.picking { background: var(--accent); border-color: var(--accent); color: #fff; animation: pulse-pick 1.5s infinite; }
@keyframes pulse-pick {
    0%, 100% { box-shadow: 0 0 0 0 rgba(79,143,247,0.4); }
    50% { box-shadow: 0 0 0 6px rgba(79,143,247,0); }
}

/* 3D mode indicator */
.mode-badge {
    font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 4px;
    font-weight: 600; flex-shrink: 0;
}
.mode-badge.mode-2d { background: rgba(79,143,247,0.2); color: var(--accent); }
.mode-badge.mode-3d { background: rgba(52,211,153,0.2); color: var(--success); }

/* Part badges */
.part-item .dxf-badge {
    font-size: 0.65rem; color: var(--success); background: rgba(52,211,153,0.12);
    padding: 0.1rem 0.35rem; border-radius: 3px; flex-shrink: 0;
    font-family: 'SF Mono', 'Consolas', 'Menlo', monospace;
    display: none;
}
.part-item.active .dxf-badge { display: inline; }
.part-item .sheet-badge {
    font-size: 0.6rem; color: #22d3ee; background: rgba(34,211,238,0.12);
    padding: 0.1rem 0.35rem; border-radius: 3px; flex-shrink: 0;
    font-weight: 600; letter-spacing: 0.02em;
}
/* "Noch nicht abgewickelt" — orange/dashed, klar abgesetzt vom abgewickelten Zustand */
.part-item .sheet-badge.pending {
    color: #fb923c; background: rgba(251,146,60,0.14);
    border: 1px dashed rgba(251,146,60,0.45);
    padding: 0 0.3rem;
}
/* "Abgewickelt" — gruener Haken hinter dem BLECH-Badge */
.part-item .sheet-badge.done::after {
    content: ' \2713'; color: #4ade80; font-weight: 700; margin-left: 0.15rem;
}
/* Einzelnes Teil abwickeln: dedizierter Button neben jedem ausstehenden Teil */
.part-item .unfold-btn {
    background: rgba(251,146,60,0.10); border: 1px solid rgba(251,146,60,0.4);
    color: #fb923c; font-size: 0.7rem; padding: 0.02rem 0.3rem;
    border-radius: 3px; cursor: pointer; flex-shrink: 0; font-weight: 600;
    opacity: 0.78; transition: opacity 0.15s, background 0.15s;
}
.part-item:hover .unfold-btn { opacity: 1; }
.part-item .unfold-btn:hover { background: rgba(251,146,60,0.25); color: #fed7aa; }
.part-item .unfold-btn:disabled { opacity: 0.3; cursor: wait; }
.part-item .flat-badge {
    font-size: 0.6rem; color: #4ade80; background: rgba(74,222,128,0.12);
    padding: 0.1rem 0.35rem; border-radius: 3px; flex-shrink: 0;
    font-weight: 600; letter-spacing: 0.02em;
}
.part-item .noflat-badge {
    font-size: 0.6rem; color: #f97316; background: rgba(249,115,22,0.12);
    padding: 0.1rem 0.35rem; border-radius: 3px; flex-shrink: 0;
    font-weight: 600; letter-spacing: 0.02em;
}
.part-item .gravur-badge {
    font-size: 0.6rem; color: #e879f9; background: rgba(232,121,249,0.12);
    padding: 0.1rem 0.35rem; border-radius: 3px; flex-shrink: 0;
    font-weight: 600; letter-spacing: 0.02em;
}
.part-item .gravur-btn {
    background: none; border: 1px solid rgba(232,121,249,0.25);
    color: #a855f7; font-size: 0.55rem; padding: 0.05rem 0.25rem;
    border-radius: 3px; cursor: pointer; flex-shrink: 0; font-weight: 700;
}
.part-item .gravur-btn:hover { background: rgba(232,121,249,0.15); }
.part-item .gravur-btn.active {
    background: rgba(232,121,249,0.2); border-color: #e879f9; color: #e879f9;
}
.part-item .text-engrave-btn {
    background: none; border: 1px solid rgba(232,121,249,0.25);
    color: #c084fc; font-size: 0.55rem; padding: 0.05rem 0.25rem;
    border-radius: 3px; cursor: pointer; flex-shrink: 0; font-weight: 700;
}
.part-item .text-engrave-btn:hover { background: rgba(232,121,249,0.15); }
.part-item .bend-engrave-btn {
    background: none; border: 1px solid rgba(34,197,94,0.30);
    color: #22c55e; font-size: 0.55rem; padding: 0.05rem 0.25rem;
    border-radius: 3px; cursor: pointer; flex-shrink: 0; font-weight: 700;
}
.part-item .bend-engrave-btn:hover { background: rgba(34,197,94,0.15); }
.part-item .bend-engrave-btn.active {
    background: rgba(34,197,94,0.22); border-color: #22c55e; color: #4ade80;
}

/* === Kalkulation Panel === */
.kalk-panel {
    padding: 0.75rem 1rem; overflow-y: auto; flex: 1;
    display: flex; flex-direction: column; gap: 0.75rem;
}
.kalk-section {
    background: var(--surface2); border-radius: 8px; padding: 0.7rem;
}
.kalk-section h3 {
    font-size: 0.8rem; color: var(--accent); margin-bottom: 0.5rem;
    font-weight: 600;
}
.kalk-row {
    display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.4rem;
    font-size: 0.8rem;
}
.kalk-label { color: var(--text-dim); min-width: 5rem; flex-shrink: 0; }
.kalk-value { color: var(--text); font-weight: 500; font-family: 'SF Mono', monospace; }
.kalk-select {
    background: var(--bg); border: 1px solid var(--border); color: var(--text);
    padding: 0.3rem 0.5rem; border-radius: 5px; font-size: 0.78rem;
    outline: none; flex: 1; min-width: 0;
}
.kalk-select:focus { border-color: var(--accent); }
.kalk-input {
    background: var(--bg); border: 1px solid var(--border); color: var(--text);
    padding: 0.3rem 0.5rem; border-radius: 5px; font-size: 0.78rem;
    outline: none; width: 4rem; text-align: right;
}
.kalk-input:focus { border-color: var(--accent); }

/* Order table — table-layout:fixed, damit alle Spalten in die Sidebar passen
   und sich proportional an die Breite anpassen (keine horizontale Scrollleiste). */
.order-table {
    width: 100%; border-collapse: collapse; font-size: 0.72rem;
    table-layout: auto;
}
/* Nur die Namensspalte (erste Spalte) wächst beim Verbreitern der Sidebar; die
   Datenspalten behalten ihre per <th> gesetzte (inhaltsgerechte) Breite. width:100%
   lässt die Namensspalte den Rest nehmen, max-width:0 verhindert, dass lange Namen die
   Spalte aufblähen — sie werden stattdessen mit Ellipsis gekürzt. */
.order-table th:first-child { width: 100%; }
.order-table .part-name-cell,
.order-table .asm-name-cell { max-width: 0; }
/* Material-/Dicke-Selects bleiben in ihrer Spalte (kein Aufblähen durch lange Namen). */
.order-table .mat-select,
.order-table .dicke-select { max-width: 100%; box-sizing: border-box; }
.order-table th {
    text-align: left; color: var(--text-dim); font-weight: 500;
    padding: 0.3rem 0.3rem; border-bottom: 1px solid var(--border);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.order-table td {
    padding: 0.3rem 0.3rem; border-bottom: 1px solid rgba(42,45,58,0.5);
    vertical-align: middle;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Inputs in der Tabelle dürfen ihre Zelle nicht sprengen */
.order-table input { max-width: 100%; box-sizing: border-box; }
/* Spinner-Pfeile der Zahlenfelder ausblenden — die schmalen Tabellenspalten haben
   dafür keinen Platz, sonst bleibt für die Ziffer selbst kaum Breite übrig. */
.order-table input[type=number]::-webkit-inner-spin-button,
.order-table input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.order-table input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.order-table .qty-input,
.order-table .asm-qty-input {
    width: 100%; text-align: center; background: var(--bg);
    border: 1px solid var(--border); color: var(--text);
    border-radius: 4px; padding: 0.25rem 0.15rem; font-size: 0.85rem;
    font-weight: 600;
}
.order-table .remove-btn {
    background: none; border: none; color: var(--error); cursor: pointer;
    font-size: 0.8rem; padding: 0.1rem 0.3rem; border-radius: 3px;
}
.order-table .remove-btn:hover { background: rgba(248,113,113,0.15); }
.add-to-order-btn {
    background: rgba(79,143,247,0.15); border: 1px solid rgba(79,143,247,0.4);
    color: var(--accent); cursor: pointer; font-size: 0.85rem;
    padding: 0.15rem 0.45rem; border-radius: 4px; flex-shrink: 0;
    transition: all 0.15s; font-weight: 700; line-height: 1;
}
.add-to-order-btn:hover { background: rgba(79,143,247,0.3); border-color: var(--accent); }

.del-part-btn {
    background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.4);
    color: #ef4444; cursor: pointer; font-size: 0.75rem;
    padding: 0.1rem 0.35rem; border-radius: 4px; flex-shrink: 0;
    transition: all 0.15s; font-weight: 700; line-height: 1;
    opacity: 0;
}
.part-item:hover .del-part-btn { opacity: 1; }
.del-part-btn:hover { background: rgba(239,68,68,0.35); border-color: #ef4444; }

.split-dxf-btn {
    background: rgba(168,85,247,0.15); border: 1px solid rgba(168,85,247,0.4);
    color: #a855f7; cursor: pointer; font-size: 0.65rem;
    padding: 0.15rem 0.4rem; border-radius: 4px; flex-shrink: 0;
    transition: all 0.15s; font-weight: 600; margin-left: auto;
}
.split-dxf-btn:hover { background: rgba(168,85,247,0.3); border-color: #a855f7; }

/* Baugruppen */
.assembly-item { border-bottom: 1px solid var(--border); }
.assembly-header {
    display: flex; align-items: center; gap: 0.35rem;
    padding: 0.5rem; cursor: pointer; background: rgba(249,115,22,0.08);
    border-left: 3px solid #f97316;
}
.assembly-header:hover { background: rgba(249,115,22,0.15); }
.assembly-name { font-weight: 600; font-size: 0.82rem; color: #f97316; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.assembly-arrow { font-size: 0.7rem; color: var(--text-dim); transition: transform 0.15s; }
.assembly-arrow.collapsed { transform: rotate(-90deg); }
.assembly-children.collapsed { display: none; }
.assembly-children .part-item { padding-left: 1.2rem !important; }

.asm-header-row { background: rgba(249,115,22,0.1); border-left: 3px solid #f97316; }
.asm-header-row td { padding-top: 0.5rem; padding-bottom: 0.3rem; }

/* Aktuell in der Vorschau angezeigtes Teil hervorheben */
.order-table tr.order-active { background: var(--accent-dim); }
.order-table tr.order-active td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.order-table tr.order-oversize { background: rgba(248,113,113,0.14); }
.order-table tr.order-oversize td:first-child { box-shadow: inset 3px 0 0 #f87171; }
.order-table tr.order-oversize td:first-child::after { content: " ⚠ passt nicht aufs Format"; color: #f87171; font-size: 0.7rem; }

/* Drag&Drop-Sortierung (Teile-Liste + Auftragstabelle) */
[draggable="true"].sortable-item { cursor: grab; }
.sortable-item.dragging { opacity: 0.4; }
.sortable-item.drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.sortable-item.drop-after { box-shadow: inset 0 -3px 0 var(--accent); }
.order-table tr.sortable-item.drop-before td { box-shadow: inset 0 3px 0 var(--accent); }
.order-table tr.sortable-item.drop-after td { box-shadow: inset 0 -3px 0 var(--accent); }

/* Nesting preview */
.nesting-preview {
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 6px; padding: 0.5rem; position: relative;
    min-height: 120px;
}
.nesting-canvas { width: 100%; cursor: pointer; }
.nesting-canvas:hover { opacity: 0.85; }
.nesting-info {
    display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 0.4rem;
    font-size: 0.75rem;
}
.nesting-info span { color: var(--text-dim); }
.nesting-info strong { color: var(--text); }

/* Canvas Lightbox Modal */
.canvas-modal-overlay {
    display: none; position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.85); backdrop-filter: blur(4px);
    justify-content: center; align-items: center; padding: 2rem;
}
.canvas-modal-overlay.show { display: flex; }
.canvas-modal {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; width: 90vw; max-height: 90vh;
    display: flex; flex-direction: column; overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
/* Vollbild (Fullscreen-API): Modal füllt den ganzen Bildschirm */
.canvas-modal:fullscreen,
.canvas-modal:-webkit-full-screen {
    width: 100vw !important; max-width: none !important;
    height: 100vh !important; max-height: none !important;
    border-radius: 0; border: none;
}
.canvas-modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border);
}
.canvas-modal-header h3 { font-size: 1rem; font-weight: 600; }
.canvas-modal-close {
    background: none; border: none; color: var(--text-dim); font-size: 1.5rem;
    cursor: pointer; padding: 0.25rem 0.5rem; border-radius: 4px;
    transition: all 0.15s;
}
.canvas-modal-close:hover { color: var(--text); background: var(--surface2); }
.canvas-modal-body {
    flex: 1; overflow: auto; padding: 0.5rem;
    display: block;
}
.canvas-modal-body canvas { image-rendering: auto; cursor: grab; }

/* Cost summary */
.cost-table {
    width: 100%; border-collapse: collapse; font-size: 0.78rem;
}
.cost-table td {
    padding: 0.3rem 0.4rem;
    border-bottom: 1px solid rgba(42,45,58,0.5);
}
.cost-table td:nth-child(2), .cost-table td:nth-child(3) { text-align: right; font-family: 'SF Mono', monospace; white-space: nowrap; }
.cost-table th { padding: 0.3rem 0.4rem; font-size: 0.7rem; color: var(--text-dim); font-weight: 600; text-align: right; }
.cost-table th:first-child { text-align: left; }
.cost-table tr.total td {
    border-top: 2px solid var(--accent); font-weight: 700;
    color: var(--accent); font-size: 0.85rem;
}
.cost-table tr.subtotal td { color: var(--text-dim); font-weight: 600; }
.cost-table tr.section-header td {
    color: var(--text-dim); font-size: 0.7rem; border-bottom: none;
    padding-top: 0.5rem; padding-bottom: 0.1rem;
}
.cost-table tr.section-header td:nth-child(2), .cost-table tr.section-header td:nth-child(3) { visibility: hidden; }
/* Anklickbare Teil-Kopfzeile in der Kosten-Übersicht → Vorschau */
.cost-table tr.cost-clickable { cursor: pointer; }
.cost-table tr.cost-clickable:hover td { color: var(--accent); }
.cost-table tr.cost-active td:first-child { box-shadow: inset 3px 0 0 var(--accent); color: var(--accent); }
.cost-table tr.detail td {
    color: var(--text-dim); font-size: 0.72rem; padding-top: 0.15rem; padding-bottom: 0.15rem;
    border-bottom: 1px solid rgba(42,45,58,0.3);
}

/* In-order badge */
.part-item .in-order-badge {
    font-size: 0.6rem; color: var(--success); background: rgba(52,211,153,0.12);
    padding: 0.1rem 0.35rem; border-radius: 3px; flex-shrink: 0;
    font-weight: 600; letter-spacing: 0.02em;
}

/* Save/Load buttons */
.kalk-actions {
    display: flex; gap: 0.4rem; margin-bottom: 0.5rem;
}
.kalk-action-btn {
    flex: 1; padding: 0.4rem 0.5rem; font-size: 0.75rem; font-weight: 600;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface2); color: var(--text-dim);
    cursor: pointer; transition: all 0.15s; text-align: center;
}
.kalk-action-btn:hover { background: var(--border); color: var(--text); }

/* DXF badge in dropzone */
.dropzone-formats { font-size: 0.68rem; color: var(--text-dim); margin: 0.25rem 0 0; }

/* DWG Inspect cluster tiles */
.dwg-cluster-tile {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.15s, transform 0.1s;
    display: flex; flex-direction: column;
    position: relative;
    cursor: pointer;
}
.dwg-cluster-tile:hover { border-color: var(--text-dim); transform: translateY(-1px); }
.dwg-cluster-tile.selected { border-color: #1a6bbf; box-shadow: 0 0 0 1px #1a6bbf inset; }
.dwg-cluster-tile.frame { opacity: 0.45; }
.dwg-cluster-tile-preview {
    background: #1a1a1a;
    aspect-ratio: 4/3;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.dwg-cluster-tile-preview svg { width: 100%; height: 100%; }
.dwg-cluster-tile-info {
    padding: 6px 10px;
    font-size: 0.78rem;
    color: var(--text);
    display: flex; flex-direction: column; gap: 3px;
}
.dwg-cluster-tile-name-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    padding: 3px 6px;
    font-size: 0.8rem;
    font-family: inherit;
}
.dwg-cluster-tile-name-input:focus { outline: 1px solid #1a6bbf; border-color: #1a6bbf; }
.dwg-cluster-tile-meta {
    display: flex; gap: 8px;
    color: var(--text-dim);
    font-size: 0.7rem;
    font-family: monospace;
}
.dwg-cluster-tile-badge {
    position: absolute; top: 6px; right: 6px;
    padding: 2px 6px; border-radius: 3px;
    font-size: 0.65rem; font-weight: 600;
    background: rgba(26, 107, 191, 0.85); color: white;
}
.dwg-cluster-tile-badge.frame { background: rgba(180, 80, 80, 0.8); }
.dwg-cluster-tile-badge.auto { background: rgba(80, 140, 60, 0.8); }
.dwg-cluster-tile-badge.iso { background: rgba(180, 130, 60, 0.8); }
.dwg-cluster-tile-badge.marker { background: rgba(110, 110, 130, 0.8); }
.dwg-cluster-tile-badge.assembly { background: rgba(200, 100, 60, 0.85); }
.dwg-cluster-tile-classification {
    display: flex; flex-wrap: wrap; gap: 6px;
    font-size: 0.68rem; font-family: monospace;
    margin-top: 3px;
}
.dwg-cluster-tile-classification .cls-cut    { color: #ffffff; }
.dwg-cluster-tile-classification .cls-bend   { color: #ff8844; }
.dwg-cluster-tile-classification .cls-engrave{ color: #55ff55; }
.dwg-cluster-tile-classification .cls-unknown{ color: #888888; }

/* Lasso/Rect Selection Modal */
.dwg-lasso-rect {
    position: absolute;
    border: 2px solid #1a6bbf;
    background: rgba(26, 107, 191, 0.15);
    pointer-events: none;
}
.dwg-lasso-rect.committed {
    border-color: #4caf50;
    background: rgba(76, 175, 80, 0.10);
    pointer-events: auto;
    cursor: move;
}
.dwg-lasso-rect.committed:hover { background: rgba(76, 175, 80, 0.20); }
.dwg-lasso-rect-label {
    position: absolute;
    top: -22px; left: 0;
    background: #1a6bbf; color: white;
    padding: 1px 6px; border-radius: 3px;
    font-size: 11px; font-weight: 600;
    font-family: monospace; white-space: nowrap;
    pointer-events: none;
}
.dwg-lasso-rect.committed .dwg-lasso-rect-label { background: #4caf50; }
.dwg-lasso-list-item {
    background: var(--surface2);
    border-radius: 4px; padding: 6px 8px;
    display: flex; flex-direction: column; gap: 3px;
}
.dwg-lasso-list-item .name-row {
    display: flex; gap: 4px; align-items: center;
}
.dwg-lasso-list-item input {
    flex: 1; background: rgba(0,0,0,0.3);
    border: 1px solid var(--border); border-radius: 3px;
    color: white; padding: 3px 6px; font-size: 12px;
}
.dwg-lasso-list-item .meta {
    color: #999; font-size: 11px; font-family: monospace;
}
.dwg-lasso-list-item .remove-btn {
    background: none; border: none; color: #ff6666;
    cursor: pointer; padding: 0 4px; font-size: 14px;
}
.dwg-cluster-tile-check {
    position: absolute; top: 6px; left: 6px;
    width: 22px; height: 22px;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: rgba(20, 20, 20, 0.8);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; color: white; line-height: 1;
}
.dwg-cluster-tile.selected .dwg-cluster-tile-check {
    background: #1a6bbf;
    border-color: #1a6bbf;
}
.dwg-cluster-tile.selected .dwg-cluster-tile-check::before { content: "✓"; }

/* DWG Layer-Mapping rows */
.dwg-layer-row {
    display: grid;
    grid-template-columns: 200px 1fr 160px 32px 180px;
    gap: 14px;
    align-items: center;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: border-color 0.15s;
}
.dwg-layer-row:hover { border-color: var(--text-dim); }
.dwg-layer-row.role-contour { border-left: 3px solid #1a6bbf; }
.dwg-layer-row.role-bend    { border-left: 3px solid #ff8844; }
.dwg-layer-row.role-engrave { border-left: 3px solid #55ff55; }
.dwg-layer-row.role-ignore  { border-left: 3px solid #555; opacity: 0.55; }
.dwg-layer-name {
    font-family: monospace; font-weight: 600;
    color: var(--text); font-size: 0.9rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dwg-layer-preview {
    background: #1a1a1a;
    border-radius: 4px;
    height: 320px;
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}
.dwg-layer-preview svg { width: 100%; height: 100%; }
.dwg-layer-info {
    font-size: 0.75rem;
    color: var(--text-dim);
    line-height: 1.4;
    font-family: monospace;
}
.dwg-layer-color {
    width: 24px; height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border);
    justify-self: center;
}
.dwg-layer-role-select {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    width: 100%;
}
.dwg-layer-role-select:focus { outline: 1px solid #7a5cbf; border-color: #7a5cbf; }
