* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #f5f5f5;
    padding: 20px;
    font-size: 13px;
}

.container {
    max-width: 1500px;
    margin: 0 auto;
    background: white;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Header Section */
.header-row {
    display: flex;
    border: 1px solid #000;
}

.header-left {
    flex: 2;
    padding: 10px;
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    border-right: 1px solid #000;
}

.header-right {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
}

/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

th,
td {
    border: 1px solid #000;
    padding: 6px 8px;
    text-align: center;
    vertical-align: middle;
}

/* Light blue header style */
.section-header {
    background: #d6dce4;
    font-weight: bold;
    font-size: 13px;
}

/* Darker blue for main headers */
.main-header {
    background: #c5cbd5;
    font-weight: bold;
}

/* Input fields */
input[type="number"],
input[type="text"] {
    width: 100%;
    min-width: 60px;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 13px;
    padding: 4px;
    font-family: inherit;
}

/* Hide spinner controls on number inputs */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

input[type="number"]:focus,
input[type="text"]:focus {
    outline: 2px solid #4a90d9;
    background: #fffde7;
}

/* Select dropdown styling */
select.nav-input {
    width: 100%;
    padding: 6px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 13px;
    box-sizing: border-box;
    cursor: pointer;
    background-color: white;
}

select.nav-input:focus {
    outline: 2px solid #4a90d9;
    background: #fffde7;
}

/* Calculated fields */
.calculated {
    background: #e8f4e8;
    font-weight: bold;
    color: #2e7d32;
}

/* Editable fields */
.editable {
    background: #fff3e0;
}

/* Section spacing */
.section {
    margin-bottom: 20px;
}

/* Row labels */
.row-label {
    font-weight: bold;
    background: #f0f0f0;
}

/* Sub-header */
.sub-header {
    background: #e0e6ed;
    font-weight: bold;
}

/* Recovery section */
.recovery-table th {
    background: #d6dce4;
    font-size: 12px;
}

/* Print button */
.actions {
    margin-bottom: 20px;
    text-align: right;
}

.btn {
    padding: 10px 20px;
    margin-left: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-primary {
    background: #4a90d9;
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 3px;
    cursor: pointer;
}

.btn:hover {
    opacity: 0.9;
}

/* Summary box */
.summary-box {
    background: #e3f2fd;
    border: 2px solid #1976d2;
    padding: 15px;
    margin-top: 20px;
    border-radius: 4px;
}

.summary-box h3 {
    color: #1565c0;
    margin-bottom: 10px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.summary-item {
    background: white;
    padding: 10px;
    border-radius: 4px;
    text-align: center;
}

.summary-label {
    font-size: 11px;
    color: #666;
    margin-bottom: 5px;
}

.summary-value {
    font-size: 16px;
    font-weight: bold;
    color: #2e7d32;
}

/* Acceptance Criteria Input Styling */
#acceptanceCriteria:hover {
    background: #e8f5e9 !important;
    border-color: #1b5e20 !important;
}

#acceptanceCriteria:focus {
    background: #ffffff !important;
    border: 2px solid #2e7d32 !important;
    outline: none;
    box-shadow: 0 0 5px rgba(46, 125, 50, 0.3);
}

/* Legend */
.legend {
    margin-top: 20px;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 11px;
}

.legend span {
    display: inline-block;
    margin-right: 20px;
}

.legend-editable {
    background: #fff3e0;
    padding: 2px 8px;
    border: 1px solid #ff9800;
}

.legend-calculated {
    background: #e8f4e8;
    padding: 2px 8px;
    border: 1px solid #4caf50;
}

/* Wider cells for potency */
.potency-cell {
    min-width: 80px;
}

/* Navigation hint */
.nav-hint {
    font-size: 11px;
    color: #666;
    margin-top: 5px;
    text-align: center;
}

/* Focused cell highlight */
input:focus {
    background: #fff9c4 !important;
    box-shadow: 0 0 5px rgba(74, 144, 217, 0.5);
}

/* Print styles */
@media print {

    /* Force landscape orientation */
    @page {
        size: A4 landscape;
        margin: 0.5cm;
    }

    /* Hide buttons and navigation hints */
    .btn,
    button,
    .legend,
    .nav-hint {
        display: none !important;
    }

    /* Remove backgrounds for cleaner print */
    body {
        background: white;
    }

    .container {
        max-width: 100%;
        padding: 10px;
    }

    /* Ensure tables don't break across pages */
    table {
        page-break-inside: avoid;
        border-collapse: collapse;
        width: 100%;
    }

    /* Make sure all table borders are visible */
    table,
    th,
    td {
        border: 1px solid #000 !important;
    }

    /* Ensure text is black for printing */
    * {
        color: #000 !important;
    }

    /* Keep calculated fields slightly grey */
    .calculated {
        background: #f0f0f0 !important;
    }

    /* Ensure header styling */
    .section-header {
        background: #e0e0e0 !important;
        font-weight: bold;
    }

    .sub-header {
        background: #f5f5f5 !important;
        font-weight: bold;
    }

    /* Remove input borders for cleaner look */
    input {
        border: none !important;
        background: transparent !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Ensure acceptance criteria displays properly */
    #acceptanceCriteria {
        color: #2e7d32 !important;
        font-weight: bold !important;
        font-size: 14px !important;
        text-align: center !important;
    }

    /* Ensure summary box prints properly */
    .summary-box {
        page-break-inside: avoid;
        border: 2px solid #000 !important;
        background: white !important;
    }

    .summary-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }

    .summary-item {
        border: 1px solid #000 !important;
        background: white !important;
    }

    /* Compact spacing for print */
    .section {
        margin-bottom: 2px !important;
        margin-top: 2px !important;
        padding: 2px !important;
    }

    table {
        margin-bottom: 2px !important;
        margin-top: 2px !important;
        font-size: 10px !important;
    }

    th,
    td {
        padding: 2px !important;
        font-size: 10px !important;
    }

    .header-row {
        margin-bottom: 2px !important;
        padding: 3px !important;
    }

    .summary-box {
        margin-top: 3px !important;
        padding: 5px !important;
    }

    .summary-grid {
        gap: 3px !important;
    }

    .summary-item {
        padding: 3px !important;
    }

    /* Fix select dropdown display in print */
    select {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        border: none !important;
        background: transparent !important;
        padding: 2px !important;
        font-size: 10px !important;
        color: #000 !important;
    }

    /* Show select value properly */
    select option:checked {
        display: inline !important;
    }
}