/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: #f5f8fb;
    color: #333;
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    padding: 30px;
    margin-top: 20px;
}

h1 {
    color: #2c3e50;
    text-align: center;
    margin-bottom: 30px;
    font-size: 28px;
    font-weight: 600;
}

/* Form styles */
form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #2c3e50;
}

input[type="number"],
select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s;
    background-color: #f9f9f9;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

button[type="submit"] {
    background: #3498db;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: background 0.3s;
    width: 100%;
    margin-top: 10px;
}

button[type="submit"]:hover {
    background: #2980b9;
}

/* Results section */
#result-area {
    margin-top: 30px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

#result-area h2 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 22px;
}

#result-area p {
    margin-bottom: 10px;
    font-size: 16px;
}

#result-area strong {
    color: #2c3e50;
}

/* Table styles */
.table-container {
    margin-top: 20px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    overflow: hidden;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background-color: #f1f5f9;
    color: #2c3e50;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.5px;
}

tr:last-child td {
    border-bottom: none;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    color: #7f8c8d;
    font-size: 14px;
    padding: 15px 0;
}

footer a {
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        padding: 20px 15px;
    }
    
    form {
        grid-template-columns: 1fr;
    }
    
    th, td {
        padding: 10px 12px;
        font-size: 13px;
    }
}

/* Animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#result-area {
    animation: fadeIn 0.3s ease-out;
}

/* Print styles */
@media print {
    .action-buttons {
        display: none;
    }
    
    body * {
        visibility: hidden;
        margin: 0;
        padding: 0;
    }
    
    #result-area, #result-area * {
        visibility: visible;
    }
    
    #result-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 8mm; /* Reduced padding */
        font-size: 9pt; /* Smaller base font */
        line-height: 1.2; /* Tighter line height */
    }
    
    /* Set page size and margins for A4 */
    @page {
        size: A4;
        margin: 5mm; /* Reduced margins */
    }
    
    /* Table styles */
    table {
        width: 100%;
        margin: 3mm 0; /* Reduced margin */
        font-size: 8pt; /* Smaller font for table */
        page-break-inside: avoid; /* Keep table on one page */
    }
    
    /* Style for print */
    h2 {
        font-size: 14pt; /* Smaller heading */
        margin-bottom: 4mm; /* Reduced margin */
    }
    
    h3 {
        font-size: 11pt; /* Smaller subheading */
        margin: 3mm 0 2mm 0; /* Reduced margins */
    }
    
    p {
        margin: 1mm 0; /* Reduced margin */
    }
    
    /* Table styles for print */
    th, td {
        padding: 1mm; /* Reduced padding */
        border: 0.3pt solid #ddd; /* Thinner border */
        font-size: 8pt; /* Ensure consistent font size */
    }
    
    th {
        background-color: #f5f5f5 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        padding: 1mm 1mm;
    }
    
    /* Ensure the table header is repeated if table breaks */
    thead {
        display: table-header-group;
    }
    
    /* Optimize table container */
    .table-container {
        margin: 0;
        width: 100%;
    }
    
    /* Make sure the table doesn't overflow */
    table {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Reduce spacing in the table */
    td, th {
        padding: 0.5mm 1mm !important;
    }
}