*{
    margin:0;
    padding:0;
    box-sizing:border-box;
}

body{

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        'Segoe UI',
        Roboto,
        sans-serif;

    background:
        linear-gradient(
            135deg,
            #f5f5f5 0%,
            #ffffff 100%
        );

    padding:10px;

    min-height:100vh;
}

       /* SPLASH SCREEN STYLING */
        .splash-screen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: white;
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 9999;
            animation: fadeOut 0.8s ease-in-out 1.2s forwards;
        }
        
        .splash-content {
            text-align: center;
            animation: slideUp 0.6s ease-out;
        }
        
        .splash-logo {
            width: 120px;
            height: 120px;
            margin: 0 auto 30px;
            background: linear-gradient(135deg, #007AFF 0%, #0051D5 100%);
            border-radius: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 8px 25px rgba(0, 122, 255, 0.3);
            animation: scaleIn 0.8s ease-out;
        }
        
        .splash-logo-icon {
            font-size: 60px;
        }
        
        .splash-title {
            font-size: 28px;
            font-weight: 700;
            color: #1a1a1a;
            margin-bottom: 10px;
            letter-spacing: -0.5px;
        }
        
        .splash-subtitle {
            font-size: 14px;
            color: #999;
            font-weight: 500;
            letter-spacing: 0.3px;
        }
        
        .splash-loader {
            margin-top: 40px;
            display: flex;
            gap: 6px;
            justify-content: center;
        }
        
        .loader-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: #007AFF;
            animation: pulse 1.4s infinite;
        }
        
        .loader-dot:nth-child(1) { animation-delay: 0s; }
        .loader-dot:nth-child(2) { animation-delay: 0.2s; }
        .loader-dot:nth-child(3) { animation-delay: 0.4s; }
        
        @keyframes fadeOut {
            0% { opacity: 1; }
            100% { opacity: 0; visibility: hidden; }
        }
        
        @keyframes slideUp {
            0% { opacity: 0; transform: translateY(30px); }
            100% { opacity: 1; transform: translateY(0); }
        }
        
        @keyframes scaleIn {
            0% { opacity: 0; transform: scale(0.8); }
            100% { opacity: 1; transform: scale(1); }
        }
        
        @keyframes pulse {
            0%, 60%, 100% { opacity: 0.3; transform: scale(1); }
            30% { opacity: 1; transform: scale(1.2); }
        }

.container{

    max-width:480px;

    margin:0 auto;

    background:
        linear-gradient(
            180deg,
            rgba(255,255,255,0.95),
            rgba(250,250,252,0.95)
        );

    backdrop-filter: blur(20px);

    border:1px solid rgba(255,255,255,0.7);

    box-shadow:
        0 20px 50px rgba(0,0,0,0.12);

    border-radius:16px;

    padding:20px;


}

.header{

    padding:20px;

    border-radius:16px;

    background:
        linear-gradient(
            135deg,
            #0B2E59 0%,
            #1565C0 55%,
            #4DA3FF 100%
        );

    color:white;

    margin-bottom:25px;
}

.header h1{

    color:white;

    text-shadow:
        0 1px 1px rgba(255,255,255,0.2),
        0 2px 4px rgba(0,0,0,0.15);

    font-weight:700;
}

.header p{

    color:rgba(255,255,255,0.85);
}

.diagram{

    height:220px;

    background:
        linear-gradient(
            180deg,
            #f7fbff,
            #eaf4ff
        );

    border:1px solid rgba(0,122,255,0.15);

    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.8);

    border-radius:12px;

    display:flex;

    align-items:center;

    justify-content:center;

    margin-bottom:25px;

    overflow:hidden;
}

.diagram img{

    max-width:100%;

    max-height:100%;

    object-fit:contain;
}

.section{

    margin-bottom:25px;
}

.section-title{

    color:#007AFF;

    font-size:14px;

    margin-bottom:15px;

    text-transform:uppercase;

    font-weight:700;
}

.table-block{

    background:#f9f9f9;

    border-radius:10px;

    padding:14px;

    margin-bottom:15px;
}

.table-block-title{

    color:#0B2E59;

    font-weight:700;

    letter-spacing:0.4px;
}

.input-pair{

    display:flex;

    gap:8px;

    margin-bottom:10px;
}

.input-field{

    flex:1;
}

label{

    display:block;

    margin-bottom:4px;

    font-size:11px;

    font-weight:600;

    color:#333;
}

input[type="number"],
input[type="text"],
select{

    width:100%;

    padding:10px;

    border:2.5px solid #007AFF;

    border-radius:8px;

    font-size:14px;

    background:#f8f9ff;

    color:#333;

    font-weight:500;

    appearance:none;

    -webkit-appearance:none;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus{

    outline:none;

    border-color:#0051D5;

    background:white;

    box-shadow:
        0 0 0 4px rgba(0,122,255,0.1);
}


.expandable {
    margin-bottom: 15px;
}

.expand-btn {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #f5f5f5;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.expand-btn::after {
    content: '▼';
    transition: transform .3s ease;
}

.expand-btn.active::after {
    transform: rotate(180deg);
}

.expandable-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s ease;
}

.expandable-content.show {
    max-height: 1000px;
}

/* Inaktive Felder */

.input-disabled,
.select-disabled{

    background:#f0f0f0 !important;
    border:2.5px solid #bdbdbd !important;
    color:#666 !important;
}

.unit{

    display:flex;

    align-items:flex-end;

    padding-bottom:10px;

    font-size:11px;

    color:#555;
}

.button-group{

    display:flex;

    gap:10px;

    margin-top:25px;
}

button{

    flex:1;

    padding:14px;

    border:none;

    border-radius:10px;

    font-weight:700;

    font-size:14px;

    cursor:pointer;

    transition:0.2s ease;
}

button:active{

    transform:scale(0.92);
}

.calc-btn{

    background:
        linear-gradient(
            180deg,
            #4DA3FF,
            #007AFF
        );

    color:white;

    box-shadow:
        0 8px 20px rgba(0,122,255,0.25);
}

.reset-btn{

    background:
        linear-gradient(
            180deg,
            #f3f3f5,
            #e5e5ea
        );

    color:#1d1d1f;
}

.export-btn{

    background:
        linear-gradient(
            180deg,
            #4CD964,
            #34C759
        );

    color:white;
}

.result-section{

    margin-top:30px;

    background:
        linear-gradient(
            180deg,
            #ffffff,
            #f6f9ff
        );

    border:1px solid rgba(0,122,255,0.12);

    box-shadow:
        0 10px 30px rgba(0,0,0,0.06);

    padding:18px;

    border-radius:12px;

    display:none;
}

.result-section.show{

    display:block;
}

.result-card{

    background:white;

    border-radius:12px;

    padding:16px;

    margin-top:20px;

    border:1px solid #dce8f8;
}

.result-card h3{

    margin-bottom:15px;

    color:#007AFF;

    font-size:16px;

    font-weight:700;
}


#toleranceDiagram{

    width:100%;

    height:320px;

    display:block;

    background:#fafcff;

    border:1px solid #dce8f8;

    border-radius:10px;
}

#toleranceStatus{

    display:block;

    margin-top:12px;

    text-align:center;

    font-weight:600;

    color:#333;

    font-size:14px;
}

.result-title{

    font-size:18px;

    font-weight:700;

    margin-bottom:20px;

    color:#007AFF;
}

.result-item{

    margin-bottom:20px;
}

.result-label{

    margin-bottom:8px;

    font-weight:700;

    color:#333;
}

.range-display{

    background:white;

    border-radius:8px;

    padding:10px;
}

.range-item{

    display:flex;

    justify-content:space-between;

    margin-bottom:6px;

    font-size:14px;
}

.range-item:last-child{

    margin-bottom:0;
}

#shaftToleranceFields,
#holeToleranceFields{

    overflow:hidden;

    transition:
        all 0.25s ease;
}

.tolerance-hidden{

    display:none;
}

input:read-only,
select:disabled{


    background:white;

    border:1px solid #D2D2D7;

    border-radius:10px;

    transition:.2s ease;
}

input:focus,
select:focus{

    border-color:#0A84FF;

    box-shadow:
        0 0 0 4px rgba(10,132,255,0.20);
}

.footer{

    margin-top:40px;

    padding:24px;

    text-align:center;

    color:#000;

    font-size:14px;

    opacity:0.75;
}

.footer-link{

    color:inherit;

    text-decoration:none;
}

.footer-link:hover{

    text-decoration:underline;
}

/* PDF */

.pdf-section{

    page-break-inside:avoid;

    break-inside:avoid;
}

table{

    page-break-inside:avoid;

    width:100%;
}

tr{

    page-break-inside:avoid;
}

h2{

    page-break-after:avoid;
}

.active-field{

    background:#f8f9ff !important;
    border:2.5px solid #007AFF !important;
}

.inactive-field{

    background:#f0f0f0 !important;
    border:2.5px solid #bdbdbd !important;
}

/* PDF MODE */

.pdf-mode{

    width:190mm !important;
    max-width:190mm !important;

    margin:0 auto !important;
    padding:0 !important;

    box-sizing:border-box;
}

.pdf-mode .button-group{

    display:none !important;
}

.pdf-mode .diagram{

    height:120px !important;

    margin-bottom:20px !important;

    background:#ffffff !important;

    border:1px solid #dcdcdc !important;

    page-break-inside:avoid;
}

.pdf-mode .diagram img{

    object-fit:contain;
}

.pdf-mode .table-block{

    background:#ffffff !important;

    border:1px solid #dcdcdc !important;

    margin-bottom:16px !important;

    page-break-inside:auto !important;

    break-inside:auto !important;
}

.pdf-mode .result-section{

    display:block !important;

    background:#ffffff !important;

    border:2px solid #007AFF !important;

    margin-top:20px !important;

    page-break-inside:avoid;
}


.pdf-mode #toleranceDiagram{

    background:white !important;

    border:1px solid #cccccc !important;

    page-break-inside:avoid;
}

.pdf-mode .result-card{

    border:1px solid #cccccc !important;

    page-break-inside:avoid;
}

.pdf-mode .footer{

    margin-top:40px !important;

    padding-top:16px !important;

    border-top:1px solid #dcdcdc !important;

    text-align:center;
}

.pdf-mode h1{

    font-size:28px !important;
}

.pdf-mode h2{

    font-size:18px !important;

    margin-bottom:12px !important;
}

.pdf-mode .section-title{

    margin-bottom:18px !important;
}

.pdf-mode input,
.pdf-mode select{

    border:1px solid #cccccc !important;

    background:#ffffff !important;
}

/* PAGE BREAKS */

.pdf-mode table{

    width:100%;

    border-collapse:collapse;
}

.pdf-mode tr{

    page-break-inside:avoid;
}

.pdf-mode .table-block-title,
.pdf-mode .result-title,
.pdf-mode h1,
.pdf-mode h2{

    page-break-after:avoid;
}


.drawing-btn{

    width:100%;

    padding:12px;

    background:#6c757d;

    color:white;

    border:none;

    border-radius:10px;

    font-weight:700;

    margin-bottom:15px;
}

.modal{

    position:fixed;

    inset:0;

    background:rgba(0,0,0,0.5);

    display:none;

    justify-content:center;

    align-items:center;

    z-index:9999;
}

.modal.show{

    display:flex;
}

.modal-content{

    width:90%;

    max-width:500px;

    max-height:80vh;

    overflow:auto;

    background:white;

    border-radius:12px;

    padding:20px;
}

.modal-header{

    display:flex;

    justify-content:space-between;

    align-items:center;

    margin-bottom:20px;
}

.close-btn{

    background:none;

    font-size:20px;
}

.fitting-select{

    background:#f8f9ff;

    border:2px solid #007AFF;

    border-radius:10px;

    padding:12px;

    margin-bottom:10px;

    cursor:pointer;
}

.upload-area{

    min-height:120px;

    border:3px dashed #007AFF;

    border-radius:12px;

    display:flex;

    align-items:center;

    justify-content:center;

    text-align:center;

    padding:20px;

    cursor:pointer;

    background:#f8f9ff;

    color:#666;

    font-weight:600;

    transition:all 0.2s ease;
}

.upload-area:hover{

    background:#eef5ff;
}

.upload-area.dragover{

    background:#dfeeff;

    border-color:#0051D5;
}


.result-summary{
    margin: 10px 0 15px 0;
    padding: 10px 12px;
    background: #f5f5f5;
    border-left: 4px solid #ff9800;
    font-size: 14px;
}

.fit-row{
    display:flex;
    gap:20px;
}

.fit-row .card{
    flex:1;
}

.material-row{
    display:flex;
    gap:20px;
}

.material-row .card{
    flex:1;
}

.shaft-block{
    background:#e8f5e9;
}

.hole-block{
    background:#e3f2fd;
}


/* --------------------------------------------------
   PDF IMPORT
-------------------------------------------------- */

.upload-area{

    border:2px dashed #007AFF;

    border-radius:10px;

    padding:30px;

    text-align:center;

    cursor:pointer;

    transition:all .25s ease;

    background:#f8f9ff;

    color:#666;

    font-weight:600;

    min-height:120px;

    display:flex;

    align-items:center;

    justify-content:center;
}

.upload-area:hover{

    background:#eef5ff;
}

.upload-area.dragover{

    background:#dfeeff;

    border-color:#0051D5;

    transform:scale(1.02);
}

.file-info{

    margin-top:15px;

    padding:12px;

    border-left:4px solid #34C759;

    background:#e8f5e9;

    color:#2e7d32;

    border-radius:4px;

    display:none;
}

.file-info.show{

    display:block;
}

.error{

    margin-top:15px;

    padding:12px;

    border-left:4px solid #ff3b30;

    background:#ffebee;

    color:#c62828;

    border-radius:4px;

    display:none;
}

.error.show{

    display:block;
}

.debug{

    margin-top:20px;

    background:#f0f0f0;

    border:1px solid #ddd;

    border-radius:6px;

    padding:12px;

    font-size:11px;

    font-family:monospace;

    white-space:pre-wrap;

    max-height:250px;

    overflow:auto;

    display:none;
}

.debug.show{

    display:block;
}

.fitting-select{

    background:#f8f9ff;

    border:2px solid #007AFF;

    border-radius:10px;

    padding:12px;

    margin-top:10px;

    cursor:pointer;

    transition:.2s;
}

.fitting-select:hover{

    background:#eef5ff;
}

.diagram-container {
    page-break-inside: avoid;
    break-inside: avoid;
}

.pdf-page-break {
    page-break-before: always;
    break-before: page;
}

.table-block,
.result-item,
.result-summary,
.diagram,
.material-row,
.fit-row,
.expandable,
#toleranceDiagram{

    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

.pdf-mode .material-page{
    page-break-before: always;
    break-before: page;
}

@media (max-width:480px){

    #toleranceDiagram{

        height:280px;
    }
    
       .material-row{
        flex-direction:column;
    }
}

@media print {

    .card,
    .result-card,
    .diagram-container,
    .material-card,
    .comparison-table,
    .section {
        page-break-inside: avoid;
        break-inside: avoid;
    }

}
