* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-red: #C8102E;
    --dark-gray: #4A4A4A;
    --light-gray: #F5F5F5;
    --medium-gray: #D0D0D0;
    --text-dark: #2C2C2C;
    --border-color: #CCCCCC;
    --input-border: #DDDDDD;
}

body {
    font-family: 'Arial', 'Helvetica', sans-serif;
    font-size: 10pt;
    line-height: 1.4;
    color: var(--text-dark);
    background-color: #F5F5F5;
    padding: 20px;
}

.page-container {
    max-width: 8.5in;
    margin: 0 auto 20px;
    background: white;
    padding: 0.5in;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    page-break-after: always;
}

/* Header */
.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 15px;
}

.logos {
    display: flex;
    gap: 15px;
    align-items: center;
}

.logo-placeholder {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-placeholder img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.title-box {
    background-color: var(--primary-red);
    color: white;
    padding: 20px 35px;
    text-align: center;
    flex: 1;
    max-width: 550px;
}

.title-box h1 {
    font-size: 13pt;
    font-weight: bold;
    line-height: 1.3;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.subtitle {
    text-align: center;
    color: #666;
    font-size: 11pt;
    margin-bottom: 20px;
    font-style: italic;
}

/* Section Headers */
.section-title {
    color: var(--primary-red);
    font-size: 12pt;
    font-weight: bold;
    text-transform: uppercase;
    margin: 20px 0 5px 0;
}

.section-header {
    background-color: var(--dark-gray);
    color: white;
    padding: 8px 15px;
    font-size: 10pt;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 2px;
}

/* Form Fields */
.form-row {
    display: flex;
    gap: 2px;
    margin-bottom: 2px;
}

.form-field {
    background-color: var(--light-gray);
    padding: 8px 12px;
    flex: 1;
    min-height: 36px;
    border: none;
    position: relative;
}

.form-field.half {
    flex: 0 0 48%;
}

.form-field.third {
    flex: 0 0 32%;
}

.form-field.quarter {
    flex: 0 0 23%;
}

.form-field label {
    font-size: 8pt;
    font-weight: bold;
    text-transform: uppercase;
    display: block;
    margin-bottom: 4px;
    color: var(--text-dark);
}

.form-field input[type="text"],
.form-field input[type="tel"],
.form-field input[type="date"],
.form-field textarea,
.form-field select {
    width: 100%;
    border: 1px solid var(--input-border);
    background: white;
    padding: 6px 8px;
    font-size: 10pt;
    font-family: inherit;
    border-radius: 2px;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 1px var(--primary-red);
}

.form-field textarea {
    min-height: 80px;
    resize: vertical;
}

.form-field.large-text textarea {
    min-height: 150px;
}

/* Date Fields */
.date-input {
    display: flex;
    gap: 5px;
    align-items: center;
}

.date-input input {
    width: 40px;
    text-align: center;
    border: 1px solid var(--input-border);
    padding: 6px 4px;
    background: white;
    border-radius: 2px;
}

.date-input input:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 1px var(--primary-red);
}

.date-input input.year {
    width: 60px;
}

.date-input span {
    font-size: 8pt;
    color: #999;
    text-transform: uppercase;
}

/* Checkbox Groups */
.checkbox-group {
    display: flex;
    gap: 20px;
    align-items: center;
    padding: 8px 0;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
}

.checkbox-item label {
    font-size: 9pt;
    font-weight: bold;
    text-transform: uppercase;
    margin: 0;
}

/* Table Structure (Page 2) */
.treatment-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
}

.treatment-table th {
    background-color: var(--primary-red);
    color: white;
    padding: 8px;
    text-align: center;
    font-size: 9pt;
    font-weight: bold;
    text-transform: uppercase;
    border: 1px solid white;
}

.treatment-table .sub-header {
    background-color: var(--dark-gray);
    color: white;
    padding: 6px;
    text-align: center;
    font-size: 8pt;
}

.treatment-table td {
    background-color: var(--light-gray);
    padding: 8px;
    border: 1px solid #DDDDDD;
    font-size: 9pt;
    vertical-align: middle;
}

.treatment-table .row-label {
    font-weight: bold;
    text-align: center;
    width: 40px;
}

.treatment-table .treatment-desc {
    text-align: left;
    padding-left: 12px;
}

.treatment-table .input-cell {
    background-color: white;
    width: 80px;
    text-align: center;
    padding: 4px;
}

.treatment-table input {
    width: 100%;
    border: 1px solid var(--input-border);
    text-align: center;
    padding: 6px 4px;
    background: white;
    border-radius: 2px;
}

.treatment-table input:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 1px var(--primary-red);
}

.position-field {
    display: inline-block;
    background-color: white;
    padding: 4px 8px;
    margin-left: 10px;
    border: 1px solid var(--input-border);
    min-width: 60px;
    text-align: center;
    border-radius: 2px;
}

/* Signature Section */
.signature-section {
    margin: 30px 0;
    position: relative;
}

.signature-with-date {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.signature-line {
    flex: 1;
    min-height: 120px;
}

.signature-canvas-container {
    border: 2px solid var(--border-color);
    background: white;
    border-radius: 4px;
    margin-bottom: 10px;
    position: relative;
}

.signature-canvas {
    width: 100%;
    height: 120px;
    cursor: crosshair;
    touch-action: none;
    display: block;
}

.signature-controls {
    text-align: right;
    margin-top: 5px;
}

.btn-clear-sig {
    padding: 6px 12px;
    font-size: 9pt;
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-clear-sig:hover {
    background-color: #c82333;
}

.btn-clear-sig:active {
    background-color: #bd2130;
}

.signature-input-hidden {
    display: none;
}

.date-box {
    min-width: 150px;
}

.signature-label {
    text-align: center;
    font-size: 8pt;
    font-weight: bold;
    text-transform: uppercase;
    margin-top: 5px;
    color: var(--text-dark);
}

.signature-label {
    text-align: center;
    font-size: 9pt;
    font-weight: bold;
    text-transform: uppercase;
}

.signature-with-date {
    display: flex;
    gap: 20px;
    align-items: flex-end;
}

.signature-with-date .signature-line {
    flex: 1;
}

.signature-with-date .date-box {
    flex: 0 0 200px;
}

/* Notes and Small Text */
.footnote {
    font-size: 8pt;
    color: #666;
    margin: 10px 0;
    line-height: 1.3;
}

.note-text {
    font-size: 9pt;
    color: var(--text-dark);
    line-height: 1.4;
    padding: 10px;
    background-color: var(--light-gray);
}

/* Page Footer */
.page-footer {
    text-align: right;
    font-size: 8pt;
    color: #666;
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid #ccc;
}

/* View Mode */
.view-mode input,
.view-mode textarea,
.view-mode select {
    border: none;
    background: transparent;
    pointer-events: none;
}

.view-mode .checkbox-item input {
    pointer-events: none;
}

/* Buttons */
.form-actions {
    text-align: center;
    margin: 30px 0;
    padding: 20px;
    background: white;
}

.btn {
    display: inline-block;
    padding: 12px 30px;
    font-size: 11pt;
    font-weight: bold;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    margin: 0 10px;
}

.btn-primary {
    background-color: var(--primary-red);
    color: white;
}

.btn-primary:hover {
    background-color: #A00D25;
}

.btn-secondary {
    background-color: var(--dark-gray);
    color: white;
}

.btn-secondary:hover {
    background-color: #333;
}

.btn-outline {
    background-color: white;
    color: var(--primary-red);
    border: 2px solid var(--primary-red);
}

.btn-outline:hover {
    background-color: var(--primary-red);
    color: white;
}

/* Login Page */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.login-container h2 {
    text-align: center;
    color: var(--primary-red);
    margin-bottom: 30px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-weight: bold;
    margin-bottom: 8px;
    color: var(--text-dark);
}

.login-form input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    font-size: 14px;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-red);
    box-shadow: 0 0 0 2px rgba(200, 16, 46, 0.1);
}

.login-form .btn {
    width: 100%;
    margin-top: 10px;
}

.error-message {
    background-color: #fee;
    border: 1px solid #fcc;
    color: #c33;
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 20px;
    text-align: center;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: #666;
}

/* Responsive Design */
@media (max-width: 1024px) {
    /* Tablet landscape */
    .page-container {
        padding: 0.3in;
    }
    
    .form-header {
        gap: 10px;
    }
    
    .title-box h1 {
        font-size: 11pt;
    }
    
    .treatment-table {
        font-size: 8pt;
    }
    
    .treatment-table th,
    .treatment-table td {
        padding: 6px 4px;
    }
}

@media (max-width: 768px) {
    /* Tablet portrait & large phones landscape */
    body {
        padding: 10px;
    }
    
    .page-container {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    /* Signature pads on mobile */
    .signature-with-date {
        flex-direction: column;
        gap: 10px;
    }
    
    .signature-line {
        width: 100%;
    }
    
    .signature-canvas {
        height: 150px; /* Taller on mobile for better signing */
    }
    
    .date-box {
        width: 100%;
    }
    
    .form-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .logos {
        order: 2;
        margin-top: 10px;
        gap: 10px;
    }
    
    .logo-placeholder {
        width: 70px;
        height: 70px;
    }
    
    .title-box {
        order: 1;
        max-width: 100%;
        width: 100%;
        padding: 15px 20px;
    }
    
    .title-box h1 {
        font-size: 10pt;
        line-height: 1.4;
    }
    
    .subtitle {
        font-size: 10pt;
        margin-bottom: 15px;
    }
    
    .section-title {
        font-size: 11pt;
    }
    
    .section-header {
        font-size: 9pt;
        padding: 6px 10px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .form-field {
        margin-bottom: 2px;
    }
    
    .form-field.half,
    .form-field.third,
    .form-field.quarter {
        flex: 1 1 100%;
        width: 100%;
    }
    
    .form-field label {
        font-size: 7.5pt;
    }
    
    .form-field input,
    .form-field textarea {
        font-size: 9pt;
        padding: 8px;
    }
    
    .form-field textarea {
        min-height: 60px;
    }
    
    .form-field.large-text textarea {
        min-height: 100px;
    }
    
    .note-text,
    .footnote {
        font-size: 8pt;
        line-height: 1.3;
        padding: 8px;
    }
    
    /* Treatment Table - Mobile Optimized */
    .treatment-table {
        font-size: 7pt;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .treatment-table thead,
    .treatment-table tbody,
    .treatment-table tr {
        display: table;
        width: 100%;
        table-layout: fixed;
    }
    
    .treatment-table th,
    .treatment-table td {
        padding: 4px 2px;
        font-size: 7pt;
    }
    
    .treatment-table .treatment-desc {
        font-size: 7pt;
        padding-left: 4px;
        line-height: 1.2;
    }
    
    .treatment-table .input-cell {
        width: 60px;
        padding: 2px;
    }
    
    .treatment-table input {
        padding: 4px 2px;
        font-size: 8pt;
    }
    
    .position-field {
        display: block;
        margin: 5px 0;
        padding: 4px 6px;
        font-size: 7pt;
    }
    
    /* Signature sections */
    .signature-section {
        margin: 20px 0;
    }
    
    .signature-with-date {
        flex-direction: column;
        gap: 10px;
    }
    
    .signature-with-date .date-box {
        flex: 1 1 100%;
        width: 100%;
    }
    
    .signature-line {
        height: 30px;
    }
    
    .signature-label {
        font-size: 8pt;
    }
    
    .date-input {
        justify-content: center;
    }
    
    .date-input input {
        width: 35px;
        padding: 6px 2px;
        font-size: 9pt;
    }
    
    .date-input input.year {
        width: 50px;
    }
    
    /* Checkbox groups */
    .checkbox-group {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .checkbox-item label {
        font-size: 8pt;
    }
    
    /* Buttons */
    .form-actions {
        flex-direction: column;
        padding: 15px;
    }
    
    .btn {
        width: 100%;
        margin: 5px 0;
        padding: 12px 20px;
    }
    
    .page-footer {
        font-size: 7pt;
    }
    
    /* Login page mobile */
    .login-container {
        margin: 50px auto;
        padding: 30px 20px;
    }
}

@media (max-width: 480px) {
    /* Small phones portrait */
    body {
        padding: 5px;
    }
    
    .page-container {
        padding: 10px;
    }
    
    .title-box h1 {
        font-size: 9pt;
    }
    
    .logo-placeholder {
        width: 50px;
        height: 50px;
    }
    
    .treatment-table {
        font-size: 6pt;
    }
    
    .treatment-table th,
    .treatment-table td {
        padding: 3px 1px;
        font-size: 6pt;
    }
    
    .treatment-table .input-cell {
        width: 45px;
    }
    
    .treatment-table input {
        font-size: 7pt;
        padding: 3px 1px;
    }
}

/* Landscape mode specific */
@media (max-width: 926px) and (orientation: landscape) {
    /* Phone landscape & small tablet landscape */
    .page-container {
        padding: 10px 15px;
    }
    
    .form-header {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .logos {
        order: 1;
        flex-direction: column;
        gap: 5px;
    }
    
    .logo-placeholder {
        width: 60px;
        height: 60px;
    }
    
    .title-box {
        order: 2;
        padding: 10px 20px;
        max-width: 70%;
    }
    
    .title-box h1 {
        font-size: 10pt;
        line-height: 1.3;
    }
    
    .form-row {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .form-field.half {
        flex: 0 0 48%;
    }
    
    .form-field.third {
        flex: 0 0 32%;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
        padding: 0;
    }
    
    .page-container {
        box-shadow: none;
        margin: 0;
        padding: 0.5in;
        page-break-after: always;
    }
    
    .page-container:last-child {
        page-break-after: auto;
    }
    
    .form-actions {
        display: none;
    }
}

