﻿* {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        :root {
            --bg-main: #1a1a1e;
            --bg-card: #2b2b33;
            --bg-body: #1a1a1e;
            --text-main: #ffffff;
            --text-muted: #999999;
            --border-color: #404050;
            --accent-yellow: #ffc107;
            --accent-green: #2ecc71;
            --accent-blue: #3498db;
        }

        [data-theme="light"] {
            --bg-main: #f5f5f5;
            --bg-card: #ffffff;
            --bg-body: #fafafa;
            --text-main: #333333;
            --text-muted: #666666;
            --border-color: #cccccc;
            --accent-yellow: #d35400;
            --accent-blue: #2980b9;
        }

        body {
            background: var(--bg-main);
            color: var(--text-main);
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            line-height: 1.6;
        }

        .header {
            background: var(--bg-card);
            border-bottom: 2px solid var(--border-color);
            padding: 20px;
            position: sticky;
            top: 0;
            z-index: 100;
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 20px;
        }

        .header h1 {
            font-size: 1.8em;
            color: var(--accent-yellow);
        }

        .theme-toggle {
            background: var(--bg-body);
            border: 1px solid var(--border-color);
            color: var(--text-main);
            padding: 8px 15px;
            border-radius: 5px;
            cursor: pointer;
            font-size: 1.1em;
        }

        .header-main {
            display: flex;
            align-items: center;
            gap: 20px;
            min-width: 0;
        }

        .header-main img {
            height: 80px;
            width: auto;
        }

        .header-stats {
            display: flex;
            gap: 25px;
            align-items: center;
            white-space: nowrap;
        }

        .header-divider {
            width: 1px;
            height: 50px;
            background: var(--border-color);
        }

        .container {
            max-width: 1360px;
            margin: 0 auto;
            padding: 20px;
        }

        .calc-grid {
            display: grid;
            grid-template-columns: 1fr 350px;
            gap: 20px;
        }

        @media (max-width: 768px) {
            .calc-grid {
                grid-template-columns: 1fr;
            }
        }

        .section {
            background: var(--bg-card);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 25px;
            margin-bottom: 20px;
        }

        .section h2 {
            font-size: 1.4em;
            color: var(--accent-yellow);
            margin-bottom: 20px;
            border-bottom: 2px solid var(--accent-yellow);
            padding-bottom: 10px;
        }

        .drop-zone {
            border: 3px dashed var(--border-color);
            border-radius: 8px;
            padding: 40px 20px;
            text-align: center;
            cursor: pointer;
            transition: all 0.2s;
            background: var(--bg-body);
        }

        .drop-zone:hover {
            border-color: var(--accent-yellow);
            background: rgba(255, 193, 7, 0.05);
            color: var(--accent-yellow);
        }

        .drop-zone.over {
            border-color: var(--accent-green);
            background: rgba(46, 204, 113, 0.1);
        }

        .form-group {
            margin-bottom: 10px;
        }

        .form-group-row {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
            margin-bottom: 10px;
        }

        label {
            display: block;
            margin-bottom: 5px;
            color: var(--text-muted);
            font-weight: bold;
            font-size: 0.9em;
        }

        input,
        select,
        textarea {
            width: 100%;
            background: var(--bg-body);
            border: 1px solid var(--border-color);
            color: var(--text-main);
            padding: 10px;
            border-radius: 5px;
            font-size: 1em;
            font-family: inherit;
        }

        input:focus,
        select:focus,
        textarea:focus {
            border-color: var(--accent-yellow);
            outline: none;
            box-shadow: 0 0 5px rgba(255, 193, 7, 0.2);
        }

        .btn {
            background: var(--accent-yellow);
            color: #000;
            border: none;
            padding: 12px 25px;
            border-radius: 6px;
            cursor: pointer;
            font-weight: bold;
            font-size: 1em;
            transition: all 0.2s;
            width: 100%;
            margin-top: 10px;
        }

        .btn:hover {
            background: #ffdd35;
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        }

        .btn:disabled {
            background: var(--text-muted);
            cursor: not-allowed;
            transform: none;
        }

        .btn-small {
            width: auto;
            padding: 8px 12px;
            font-size: 0.9em;
        }

        .btn-danger {
            background: #e74c3c;
            color: #fff;
        }

        .btn-danger:hover {
            background: #c0392b;
        }

        .item-card {
            background: var(--bg-body);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 15px;
            margin-bottom: 15px;
        }

        .item-card.item-card-alt {
            background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(52, 152, 219, 0.05) 100%);
            border-color: rgba(52, 152, 219, 0.22);
        }

        .item-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
            border-bottom: 1px solid var(--border-color);
            padding-bottom: 10px;
        }

        .item-header h4 {
            margin: 0;
            font-size: 1.1em;
            color: var(--accent-yellow);
        }

        .item-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
        }

        .item-grid-full {
            grid-column: 1 / -1;
        }

        .summary-panel {
            position: sticky;
            position: -webkit-sticky;
            top: 120px;
            height: max-content;
            align-self: start;
            z-index: 90;
        }

        .summary-box {
            background: var(--bg-body);
            border-left: 4px solid var(--accent-green);
            padding: 15px;
            border-radius: 5px;
            margin-bottom: 15px;
        }

        .summary-row {
            display: flex;
            justify-content: space-between;
            margin-bottom: 10px;
            color: var(--text-main);
        }

        .total-price {
            font-size: 2em;
            font-weight: bold;
            color: var(--accent-green);
            text-align: center;
            padding: 20px;
            background: rgba(46, 204, 113, 0.1);
            border-radius: 6px;
            margin-top: 10px;
        }

        .modal {
            display: none;
            position: fixed;
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.7);
            z-index: 1000;
            align-items: center;
            justify-content: center;
        }

        .modal.active {
            display: flex;
        }

        .modal-box {
            background: var(--bg-card);
            width: 95%;
            max-width: 500px;
            border-radius: 8px;
            padding: 20px;
            max-height: 85vh;
            overflow-y: auto;
            position: relative;
        }

        .modal-box h3 {
            color: var(--accent-yellow);
            margin-bottom: 15px;
            font-size: 1.3em;
        }

        .modal-close {
            cursor: pointer;
            font-size: 28px;
            color: var(--text-muted);
            position: absolute;
            top: 15px;
            right: 20px;
            transition: color 0.2s;
            z-index: 10;
        }

        .modal-close:hover {
            color: var(--accent-yellow);
        }

        .error-msg {
            background: rgba(231, 76, 60, 0.95);
            border: 1px solid #e74c3c;
            color: #fff;
            padding: 15px 20px;
            border-radius: 8px;
            margin: 0;
            backdrop-filter: blur(5px);
            pointer-events: auto;
            min-width: 280px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.2);
            animation: slideInLeftAlert 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
        }

        .success-msg {
            background: rgba(46, 204, 113, 0.95);
            border: 1px solid #2ecc71;
            color: #fff;
            padding: 15px 20px;
            border-radius: 8px;
            margin: 0;
            backdrop-filter: blur(5px);
            pointer-events: auto;
            min-width: 280px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.2);
            animation: slideInLeftAlert 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
        }

        .info-msg {
            background: rgba(52, 152, 219, 0.95);
            border: 1px solid #3498db;
            color: #fff;
            padding: 15px 20px;
            border-radius: 8px;
            margin: 0;
            backdrop-filter: blur(5px);
            pointer-events: auto;
            min-width: 280px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.2);
            animation: slideInLeftAlert 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
        }

        #messageBox {
            position: fixed;
            top: 130px;
            left: 20px;
            z-index: 10000;
            display: flex;
            flex-direction: column;
            gap: 10px;
            pointer-events: none;
        }

        @keyframes slideInLeftAlert {
            0% { transform: translateX(-150%); opacity: 0; }
            100% { transform: translateX(0); opacity: 1; }
        }

        @keyframes slideOutLeftAlert {
            0% { transform: translateX(0); opacity: 1; }
            100% { transform: translateX(-150%); opacity: 0; }
        }

        .upload-item {
            background: var(--bg-body);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            padding: 12px;
            margin-bottom: 10px;
        }

        .upload-filename {
            font-weight: bold;
            font-size: 0.95em;
            margin-bottom: 8px;
            color: var(--text-main);
        }

        .upload-progress-bar {
            width: 100%;
            height: 24px;
            background: var(--border-color);
            border-radius: 4px;
            overflow: hidden;
            margin-bottom: 6px;
        }

        .upload-progress-fill {
            height: 100%;
            background: linear-gradient(90deg, var(--accent-green), var(--accent-yellow));
            transition: width 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #000;
            font-size: 0.75em;
            font-weight: bold;
        }

        .upload-status {
            font-size: 0.85em;
            color: var(--text-muted);
        }

        .shape-option {
            background: var(--bg-body);
            border: 2px solid var(--border-color);
            border-radius: 8px;
            padding: 20px;
            text-align: center;
            cursor: pointer;
            transition: all 0.2s;
        }

        .shape-option:hover {
            border-color: var(--accent-yellow);
            transform: translateY(-2px);
        }

        .shape-option.active {
            border-color: var(--accent-yellow);
            background: rgba(255, 193, 7, 0.1);
        }

        .dimensions-inputs {
            display: none;
        }

        .dimensions-inputs.active {
            display: block;
        }

        .mode-switch {
            display: flex;
            gap: 20px;
            align-items: center;
        }

        .manual-shapes {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 15px;
            margin-bottom: 20px;
        }

        .manual-form-grid {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 20px;
        }

        @media (max-width: 900px) {
            .header {
                position: static;
                flex-wrap: nowrap;
                padding: 10px 12px;
                gap: 10px;
            }

            .header-main {
                gap: 10px;
                flex: 1;
                min-width: 0;
            }

            .header-main img {
                height: 42px;
            }

            .header h1 {
                font-size: 0.98em;
                line-height: 1.2;
                margin: 0;
            }

            .header-subtitle {
                display: none;
            }

            .header-stats {
                display: none;
            }

            .header-divider {
                display: none;
            }

            .theme-toggle {
                margin-left: 0;
                padding: 6px 10px;
                font-size: 1em;
            }

            .container {
                padding: 12px;
            }

            .section {
                padding: 16px;
                margin-bottom: 12px;
            }

            .section h2 {
                font-size: 1.15em;
                margin-bottom: 14px;
            }

            .drop-zone {
                padding: 24px 12px;
            }

            .mode-switch {
                flex-direction: column;
                align-items: flex-start;
                gap: 10px;
            }

            .manual-shapes {
                grid-template-columns: 1fr;
            }

            .manual-form-grid {
                grid-template-columns: 1fr;
                gap: 12px;
            }

            .item-header {
                flex-direction: column;
                align-items: flex-start;
                gap: 10px;
            }

            .item-header h4 {
                word-break: break-word;
            }

            .item-grid {
                grid-template-columns: 1fr;
            }

            .btn-small {
                width: 100%;
            }

            .summary-panel {
                position: static !important;
                top: auto !important;
            }

            .summary-panel .section {
                position: static !important;
                top: auto !important;
            }

            .total-price {
                font-size: 1.5em;
                padding: 14px;
            }

            .form-group-row {
                grid-template-columns: 1fr;
            }

            .modal {
                align-items: flex-end;
            }

            .modal-box {
                width: 100%;
                max-width: 100%;
                max-height: 92vh;
                border-radius: 12px 12px 0 0;
                padding: 16px;
            }
        }

        .site-footer {
            background: var(--bg-card);
            border-top: 1px solid var(--border-color);
            margin-top: 30px;
            padding: 20px;
        }

        .footer-inner {
            max-width: 1100px;
            margin: 0 auto;
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
            gap: 12px;
        }

        .footer-title {
            color: var(--accent-yellow);
            font-weight: bold;
            margin-bottom: 6px;
        }

        .footer-line {
            color: var(--text-muted);
            font-size: 0.9em;
        }

        .footer-help {
            color: var(--text-main);
            font-size: 0.95em;
        }

        /* DXF Preview Modal */
        #dxfPreviewModal .modal-box {
            max-width: 1100px;
            width: 95%;
            height: 95vh;
            box-sizing: border-box;
            padding: 16px 20px;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        /* Zoom & Pan Controls */
        .zoom-controls {
            position: absolute;
            top: 10px;
            right: 10px;
            display: flex;
            flex-direction: column;
            gap: 5px;
            z-index: 10;
        }

        .zoom-btn {
            background: rgba(43, 43, 51, 0.85);
            border: 1px solid var(--border-color);
            color: white;
            width: 36px;
            height: 36px;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: 0.2s;
            backdrop-filter: blur(4px);
        }

        .zoom-btn:hover {
            background: var(--accent-yellow);
            color: #000;
            border-color: var(--accent-yellow);
        }

        .zoom-btn.active {
            background: var(--accent-blue);
            color: white;
            border-color: var(--accent-blue);
        }

        #dxfPreviewContainer.grabbing {
            cursor: grabbing !important;
        }

        .selection-rect {
            fill: rgba(52, 152, 219, 0.2);
            stroke: var(--accent-blue);
            stroke-width: 1;
        }

        #dxfPreviewContainer {
            background: #000;
            border: 1px solid var(--border-color);
            border-radius: 4px;
            overflow: hidden;
            position: relative;
            cursor: crosshair;
            width: 100%;
            flex: 1;
            min-height: 0;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        #dxfSvgArea {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
            overflow: hidden;
        }

        #dxfSvg {
            width: 100%;
            height: 100%;
            display: block;
        }

        .dxf-ent {
            stroke-width: 1.5;
            vector-effect: non-scaling-stroke;
            cursor: pointer;
            transition: stroke 0.2s, stroke-width 0.2s;
            fill: none;
            pointer-events: visibleStroke;
        }

        .selection-rect {
            fill: rgba(52, 152, 219, 0.2);
            stroke: #3498db;
            stroke-width: 1;
            pointer-events: none;
        }

        .dxf-ent:hover {
            stroke-width: 3px;
            stroke: #fff !important;
        }

        .dxf-ent.excluded {
            stroke: #444 !important;
            stroke-dasharray: 4, 4;
            opacity: 0.5;
        }

        .dxf-ent.active {
            stroke: var(--accent-yellow) !important;
        }

        .preview-controls {
            display: flex;
            gap: 10px;
            margin-bottom: 10px;
            flex-wrap: wrap;
        }

        .preview-info {
            font-size: 0.85em;
            color: var(--text-muted);
            margin-top: 10px;
            display: flex;
            justify-content: space-between;
        }

        .preview-hint {
            font-size: 0.8em;
            color: var(--accent-blue);
            margin-bottom: 8px;
        }

        .seo-footer-content {
            max-width: 1360px;
            margin: 20px auto 50px auto;
            padding: 30px;
            background: #2b2b33;
            border: 1px solid var(--border-color);
            border-radius: 8px;
        }

        .seo-footer-content h2 {
            color: var(--accent-yellow);
            font-size: 1.4rem;
            margin-top: 0;
        }

        .seo-footer-content p,
        .seo-footer-content li {
            color: #bbb;
            font-size: 0.95rem;
            line-height: 1.6;
        }
        /* Mode Selection Cards */
        .mode-cards {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 12px;
            margin-bottom: 20px;
        }

        .mode-card {
            background: var(--bg-card);
            border: 2px solid var(--border-color);
            border-radius: 12px;
            padding: 14px 10px;
            text-align: center;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 7px;
        }

        .mode-card:hover {
            border-color: var(--accent-yellow);
            transform: translateY(-3px);
            box-shadow: 0 10px 20px rgba(0,0,0,0.1);
        }

        .mode-card.active {
            border-color: var(--accent-yellow);
            background: rgba(248, 194, 30, 0.05);
        }

        .mode-card i {
            font-size: 1.8rem;
            color: var(--accent-yellow);
        }

        .mode-card h3 {
            margin: 0;
            font-size: 0.95rem;
            color: var(--text-main);
        }

        .mode-card p {
            margin: 0;
            font-size: 0.78rem;
            color: var(--text-muted);
            line-height: 1.3;
        }

        .mode-card .check-icon {
            position: absolute;
            top: 10px;
            right: 10px;
            color: var(--accent-yellow);
            display: none;
            font-size: 1rem;
        }

        .mode-card.active .check-icon {
            display: block;
        }

        #aiMode {
            display: none;
        }

        .ai-drop-zone {
            border: 2px dashed #444;
            border-radius: 8px;
            padding: 30px;
            text-align: center;
            cursor: pointer;
            transition: all 0.3s;
            background: rgba(255,255,255,0.02);
        }

        .ai-drop-zone:hover, .ai-drop-zone.over {
            border-color: var(--accent-blue);
            background: rgba(30, 136, 229, 0.05);
        }

        .ai-status-box {
            margin-top: 15px;
            padding: 15px;
            border-radius: 8px;
            background: #2b2b33;
            display: none;
        }

        .ai-progress-bar {
            height: 6px;
            background: #444;
            border-radius: 3px;
            overflow: hidden;
            margin-top: 10px;
        }

        .ai-progress-fill {
            height: 100%;
            background: var(--accent-blue);
            width: 0%;
            transition: width 0.3s;
        }

        /* AI Preview & Edit Styles */
        .certainty-badge {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 4px 10px;
            border-radius: 20px;
            font-size: 0.8rem;
            font-weight: bold;
        }
        .certainty-high { background: rgba(46, 204, 113, 0.15); color: #2ecc71; }
        .certainty-medium { background: rgba(241, 196, 15, 0.15); color: #f1c40f; }
        .certainty-low { background: rgba(231, 76, 60, 0.15); color: #e74c3c; }

        #aiEditModal .modal-box {
            max-width: 1100px;
            width: 95%;
            height: auto;
            max-height: 95vh;
            display: flex;
            flex-direction: column;
            padding: 25px;
        }

        #aiPreviewCanvas {
            background: #000;
            border: 1px solid var(--border-color);
            border-radius: 8px;
            width: 100%;
            height: 380px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 25px;
            position: relative;
            overflow: hidden;
            flex-shrink: 0; /* Zapobiega zmniejszaniu się */
        }

        .ai-edit-grid {
            display: grid;
            grid-template-columns: 1fr; /* Uproszczony widok */
            gap: 25px;
        }

        .hole-item {
            background: rgba(255,255,255,0.05);
            padding: 10px;
            border-radius: 6px;
            margin-bottom: 8px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
