:root {
    --primary-color: #003366;
    --text-color: #333333;
    --light-text: #666666;
    --bg-color: #ffffff;
    --card-border: #eeeeee;

    /* Branding Colors */
    --eng-color: #003366;
    --sensors-color: #0056b3;
    --calib-color: #bfa15c;

    /* Certification Colors */
    --ex-yellow: #FFC107;
    --ul-red: #D32F2F;
    --fm-black: #000000;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100dvh;
    overflow: hidden;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-color);
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 2px 2px, rgba(0, 51, 102, 0.05) 1px, transparent 0);
    background-size: 30px 30px;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* Header - Ultra Compact */
.header {
    padding: 12px 0;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    z-index: 100;
}

.header.container {
    display: flex;
    flex-direction: column; /* Stack vertically */
    align-items: flex-start; /* Align left */
    gap: 8px; /* Balanced gap */
}

.main-logo {
    max-width: 180px; /* Even larger as requested */
    height: auto;
}

.tagline {
    font-size: 1.05rem; /* Slightly larger */
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
    max-width: 500px; /* Ensure it stays readable */
}

/* Main Content Area */
main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1vh 0;
}

.services-section {
    width: 100%;
}

.section-title {
    color: var(--primary-color);
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 2px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
    text-transform: uppercase;
}

.section-title::before {
    content: "";
    width: 4px;
    height: 16px;
    background: #0077B6;
    border-radius: 2px;
}

.section-title::after {
    content: "";
    height: 1px;
    background: linear-gradient(to right, #eeeeee, transparent);
    flex-grow: 1;
}

/* 3D Flip Card Layout - Forced 3 Columns */
.services-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    perspective: 1500px;
}

.service-card {
    height: 55vh;
    min-height: 320px;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: left;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 20px;
    border: 1px solid var(--card-border);
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
    transition: all 0.4s ease;
    border-top: 5px solid transparent;
}

/* Category Tints & Borders */
.engineering .card-face {
    border-top-color: var(--eng-color);
    background-color: rgba(0, 51, 102, 0.03);
}
.sensors .card-face {
    border-top-color: var(--sensors-color);
    background-color: rgba(0, 86, 179, 0.03);
}
.calib .card-face {
    border-top-color: var(--calib-color);
    background-color: rgba(191, 161, 92, 0.03);
}

/* Hover Effects */
.engineering:hover .card-face { box-shadow: 0 15px 40px -5px rgba(0, 51, 102, 0.15); border-color: var(--eng-color); }
.sensors:hover .card-face { box-shadow: 0 15px 40px -5px rgba(0, 86, 179, 0.15); border-color: var(--sensors-color); }
.calib:hover .card-face { box-shadow: 0 15px 40px -5px rgba(191, 161, 92, 0.15); border-color: var(--calib-color); }

.card-visual {
    width: 100%;
    height: 25vh;
    min-height: 150px;
    margin: 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    perspective: 1000px;
}

.piece-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 15px 25px rgba(0,0,0,0.1));
    transition: transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

.service-card:hover .piece-img {
    transform: translateY(-10px) rotate(-3deg) scale(1.1);
}

.card-front {
    z-index: 2;
}

.card-back {
    transform: rotateY(180deg);
    z-index: 1;
}

/* Card Content */
.card-logo {
    max-height: 25px;
    margin-bottom: 5px;
    object-fit: contain;
}

.card-description {
    color: var(--light-text);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.3;
}

/* Certification Styles - RESTORED COLORS */
.certifications {
    display: flex;
    gap: 15px;
    margin-top: auto;
    padding-bottom: 10px;
}

.cert-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--light-text);
}

.cert-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    border: 2px solid transparent;
}

.cert-badge.ex {
    background-color: var(--ex-yellow);
    color: black;
}

.cert-badge.ul {
    background-color: white;
    border-color: var(--ul-red);
    color: var(--ul-red);
}

.cert-badge.fm {
    border: 2px solid var(--fm-black);
    border-radius: 4px;
    color: var(--fm-black);
    background-color: white;
}

/* Arrow Interaction Icon - IMPROVED VISIBILITY */
.arrow-wrapper {
    margin-top: auto;
    width: 100%;
    display: flex;
    justify-content: flex-end;
}

.arrow-icon {
    width: 35px;
    height: 35px;
    border: 2px solid currentColor;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.engineering .arrow-icon { color: var(--eng-color); }
.sensors .arrow-icon { color: var(--sensors-color); }
.calib .arrow-icon { color: var(--calib-color); }

.arrow-icon svg {
    width: 18px;
    height: 18px;
}

.feature-list {
    list-style: none;
    margin: 10px 0;
}

.feature-list li {
    position: relative;
    padding-left: 15px;
    margin-bottom: 6px;
    font-size: 0.8rem;
    color: var(--text-color);
    line-height: 1.2;
}

.feature-list li::before {
    content: "•";
    position: absolute;
    left: 0;
    color: inherit;
}

/* Button Theming */
.contact-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 20px;
    border: 2px solid currentColor;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    margin-top: auto;
    width: 100%;
}

.engineering .contact-btn { color: var(--eng-color); }
.sensors .contact-btn { color: var(--sensors-color); }
.calib .contact-btn { color: var(--calib-color); }

.engineering .contact-btn:hover { background: var(--eng-color); color: white; }
.sensors .contact-btn:hover { background: var(--sensors-color); color: white; }
.calib .contact-btn:hover { background: var(--calib-color); color: white; }

.contact-btn:active {
    transform: scale(0.98);
}

/* Contact Pane - Compact */
.contact-pane {
    padding: 10px 0;
    border-top: 1px solid var(--card-border);
    margin-top: 5px;
}

.contact-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.contact-icon {
    width: 32px;
    height: 32px;
    background: #f1f5f9;
    color: var(--primary-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.contact-icon svg {
    width: 16px;
    height: 16px;
}

.contact-text h3 {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0;
}

.contact-text p {
    font-size: 0.75rem;
    color: var(--light-text);
}

.contact-actions {
    margin-top: 10px;
    text-align: center;
}

.info-btn {
    padding: 6px 25px;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.8rem;
}

.services-actions {
    margin-top: 10px;
    text-align: center;
}

.secondary-btn {
    padding: 6px 20px;
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* Footer - Ultra Minimal */
.footer {
    padding: 5px 0;
    text-align: center;
    border-top: 1px solid rgba(0,0,0,0.02);
}

.contact-email {
    font-size: 0.7rem;
    font-weight: 600;
}

.copyright {
    font-size: 0.6rem;
    opacity: 0.5;
}

/* Modal Styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-container {
    background: white;
    width: 95%;
    max-width: 600px; /* Slightly wider */
    max-height: 85dvh;
    border-radius: 28px; /* Modern curves */
    overflow: hidden;
    position: relative;
    box-shadow: 0 40px 100px -15px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    padding: 0;
}

.modal-close {
    position: absolute;
    top: 25px;
    right: 25px;
    width: 44px; /* Larger and easier to hit */
    height: 44px;
    border-radius: 50%;
    background: white;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500; /* Ensure it's on top */
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: var(--text-color);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.modal-close svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
}

.modal-close:hover {
    background: var(--ul-red);
    color: white;
    transform: rotate(90deg) scale(1.1);
    border-color: var(--ul-red);
}

.modal-body {
    padding: 50px 40px; /* More breathing room */
    overflow-y: auto;
}

/* Form Styles */
.modern-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-color);
    margin-left: 4px;
}

.input-wrapper {
    position: relative;
}

.modern-form input,
.modern-form textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #f8fafc;
    transition: all 0.3s ease;
}

.modern-form input:focus,
.modern-form textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 4px rgba(0, 51, 102, 0.05);
}

.modern-form textarea {
    min-height: 100px;
    resize: vertical;
}

.submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 30px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 14px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 10px;
}

.submit-btn svg {
    width: 18px;
    height: 18px;
    transition: transform 0.3s ease;
}

.submit-btn:hover {
    background: #004080;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 51, 102, 0.2);
}

.submit-btn:hover svg {
    transform: translateX(5px);
}

.submit-btn:active {
    transform: translateY(0);
}

.submit-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    transform: none;
}

.form-response {
    margin-top: 15px;
    padding: 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    display: none;
}

.form-response.success {
    display: block;
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.form-response.error {
    display: block;
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* About Modal Design Refinement */
.about-header {
    text-align: left;
    margin-bottom: 35px;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 20px;
}

.about-logo {
    max-height: 45px; /* Larger logo in about */
    margin-bottom: 15px;
}

.about-title {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

.about-lead {
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 20px;
    font-size: 1.15rem;
    border-left: 4px solid var(--sensors-color);
    padding-left: 15px;
}

.about-content p {
    font-size: 1rem;
    color: #4b5563;
    line-height: 1.7;
    margin-bottom: 25px;
}

.legal-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    background: linear-gradient(145deg, #f8fafc, #f1f5f9);
    padding: 25px;
    border-radius: 16px;
    margin-top: 30px;
    border: 1px solid #e2e8f0;
}

.legal-item {
    display: flex;
    flex-direction: column;
}

.legal-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    color: #94a3b8;
}

.legal-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
}

/* RESPONSIVE */
@media (max-width: 576px) {
    html, body {
        height: auto;
        overflow: auto;
    }

    body {
        justify-content: flex-start;
    }

    .header.container {
        padding: 20px 15px;
    }

    .main-logo {
        max-width: 120px; /* Larger mobile logo */
    }

    .services-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .service-card {
        height: 180px; /* Base height for fast navigation */
        transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
        margin-bottom: 12px;
    }

    .service-card.is-flipped {
        height: 460px; /* Sufficient to avoid overlapping */
    }

    .card-face {
        position: absolute; /* ESSENTIAL FOR 3D FLIP */
        width: 100%;
        height: 100%;
        padding: 20px;
        justify-content: center; /* Center front content when closed */
    }

    .card-back {
        justify-content: flex-start; /* List starts from top */
        padding: 25px 20px;
    }

    .card-visual {
        height: 70px; /* Very compact visuals */
        margin: 5px 0;
    }

    .card-description {
        font-size: 0.75rem;
        line-height: 1.2;
        max-width: 90%;
        text-align: center;
        align-self: center;
    }

    .arrow-wrapper {
        position: absolute;
        bottom: 15px;
        right: 15px;
        display: flex;
        margin: 0;
    }

    .arrow-icon {
        width: 32px;
        height: 32px;
        background: white; /* Make it pop */
        box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    }

    /* Fix Engineering Icon Overflow */
    .certifications {
        flex-wrap: nowrap; /* Keep on one line if possible or wrap tightly */
        justify-content: center;
        gap: 10px;
        padding-bottom: 0;
        margin-top: 10px;
    }

    .cert-badge {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }

    .cert-badge.ex { background-color: #FFC107; color: #000; }
    .cert-badge.ul { border: 2px solid #D32F2F; color: #D32F2F; background: white; }
    .cert-badge.fm { border: 2px solid #000; color: #000; background: white; }

    .contact-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .modal-body {
        padding: 25px;
    }
}
