* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header & Navigation */
header {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar {
    padding: 1rem 0;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h2 {
    color: #667eea;
    font-size: 1.8rem;
    font-weight: 700;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    color: #333;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: #667eea;
}

/* Main Content */
main {
    padding: 2rem 0;
}

.main-title {
    text-align: center;
    color: white;
    margin-bottom: 2rem;
}

.main-title h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 2rem;
}

/* Form Section */
.form-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #667eea;
}

.section-header h2 {
    color: #667eea;
    font-size: 1.8rem;
}

.controls {
    display: flex;
    gap: 0.5rem;
}

.btn-secondary {
    padding: 0.5rem 1rem;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Form Group Section */
.form-group-section {
    margin-bottom: 1.5rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.section-title {
    background: #f8f9fa;
    padding: 1rem 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: #333;
    user-select: none;
    transition: background 0.3s;
}

.section-title:hover {
    background: #e9ecef;
}

.toggle-icon {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
}

.section-content {
    padding: 1.5rem;
    display: none;
}

.form-group-section.active .section-content {
    display: block;
}

.form-group-section.active .toggle-icon::before {
    content: '−';
}

.form-group-section:not(.active) .toggle-icon::before {
    content: '+';
}

/* Form Elements */
.form-row {
    margin-bottom: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #555;
}

.form-group input,
.form-group select {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.section-note {
    font-weight: 600;
    color: #666;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.column-headers {
    margin-bottom: 1.5rem;
}

.header-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn-add {
    padding: 0.5rem 1rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
}

.btn-add:hover {
    background: #5568d3;
}

/* Asset Items */
.asset-item {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #e0e0e0;
}

.asset-item:last-child {
    border-bottom: none;
}

.asset-number {
    font-weight: 700;
    color: #667eea;
    font-size: 1.1rem;
    min-width: 30px;
}

.asset-content {
    flex: 1;
}

.asset-content h4 {
    margin-bottom: 1rem;
    color: #333;
    font-size: 1rem;
}

.asset-inputs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #666;
    font-size: 0.9rem;
}

.input-group input {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.note-text {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
    margin-top: 1rem;
    line-height: 1.5;
}

/* Liability Items */
.liability-item {
    margin-bottom: 1.5rem;
}

.liability-item h4,
.liability-item h5 {
    margin-bottom: 0.75rem;
    color: #333;
}

.liability-item h5 {
    font-size: 0.95rem;
    font-weight: 500;
}

.sub-item {
    margin-left: 2rem;
    margin-top: 1rem;
}

/* Declaration Section */
.declaration-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.declaration-text {
    font-weight: 500;
    margin-bottom: 1.5rem;
    color: #333;
}

.signature-section {
    margin-top: 1rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    justify-content: center;
}

.btn-reset,
.btn-download {
    padding: 1rem 2.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-reset {
    background: #6c757d;
    color: white;
}

.btn-reset:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.btn-download {
    background: #28a745;
    color: white;
}

.btn-download:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.tip-box {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
}

.tip-box p {
    color: #856404;
    font-size: 0.9rem;
}

/* Preview Section */
.preview-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    position: sticky;
    top: 120px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

.preview-section h3 {
    color: #667eea;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    text-align: center;
}

.preview-container {
    background: #f5f5f5;
    padding: 1rem;
    border-radius: 8px;
}

.preview-page {
    background: white;
    padding: 1.5rem 2rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.preview-header {
    text-align: center;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #333;
    padding-bottom: 1rem;
}

.preview-header h2 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}

.preview-content p {
    margin-bottom: 0.8rem;
    font-size: 0.85rem;
    line-height: 1.5;
}

.preview-content h3 {
    font-size: 1.1rem;
    margin: 1.5rem 0 1rem 0;
    color: #333;
}

.preview-content h4 {
    font-size: 1rem;
    margin: 1rem 0 0.75rem 0;
    color: #333;
}

.small-text {
    font-size: 0.75rem;
    color: #666;
}

.highlight {
    font-weight: 600;
    text-decoration: underline;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.8rem;
}

.preview-table th,
.preview-table td {
    border: 1px solid #333;
    padding: 0.5rem;
    text-align: left;
}

.preview-table th {
    background: #f0f0f0;
    font-weight: 600;
}
.preview-table th small {
    display: block;
    font-weight: 500;
    color: #667eea;
    margin-top: 0.25rem;
    font-size: 0.75rem;
}
.preview-table td:first-child {
    width: 40px;
    text-align: center;
    font-weight: 600;
}

.liability-table td:first-child {
    width: 50px;
}

.page-footer {
    text-align: right;
    margin-top: 2rem;
    font-style: italic;
}

/* Page 2 specific - standard readable layout */
.preview-page:nth-child(2) {
    font-size: 0.85rem;
}

.preview-page:nth-child(2) h3 {
    font-size: 1.05rem;
    margin: 0.6rem 0 0.4rem 0;
    font-weight: bold;
}

.preview-page:nth-child(2) .small-text {
    font-size: 0.75rem;
    margin: 0.3rem 0;
    font-style: italic;
}

.preview-page:nth-child(2) .preview-table {
    font-size: 0.8rem;
    margin: 0.4rem 0;
}

.preview-page:nth-child(2) .preview-table th,
.preview-page:nth-child(2) .preview-table td {
    padding: 0.4rem 0.3rem;
    line-height: 1.3;
}

/* Page 3 specific - fit both sections with readable fonts */
.preview-page:nth-child(3) {
    font-size: 0.75rem;
}

.preview-page:nth-child(3) > p:first-of-type {
    margin: 0 0 0.3rem 0;
    font-size: 0.75rem;
    line-height: 1.3;
}

.preview-page:nth-child(3) .preview-table {
    font-size: 0.7rem;
    margin: 0.25rem 0;
}

.preview-page:nth-child(3) .preview-table th,
.preview-page:nth-child(3) .preview-table td {
    padding: 0.15rem 0.2rem;
    line-height: 1.2;
}

.preview-page:nth-child(3) .liability-subheading {
    margin-top: 0.4rem;
    margin-bottom: 0.2rem;
    font-size: 0.8rem;
    font-weight: bold;
}

.preview-page:nth-child(3) .personal-details-table {
    font-size: 0.7rem;
    margin-top: 0.2rem;
}

.preview-page:nth-child(3) .personal-details-table td {
    padding: 0.08rem 0 !important;
    line-height: 1.2;
}

.preview-page:nth-child(3) .declaration-preview {
    margin-top: 0.4rem;
}

.preview-page:nth-child(3) .declaration-preview p {
    margin: 0.25rem 0;
    font-size: 0.72rem;
    line-height: 1.3;
}

.preview-page:nth-child(3) .signature-block {
    margin-top: 0.4rem;
    font-size: 0.7rem;
    gap: 0.4rem;
}

.preview-page:nth-child(3) .signature-block p {
    margin-bottom: 0.15rem;
    line-height: 1.25;
}

.preview-page:nth-child(3) .signature-block div p {
    margin-bottom: 0.18rem;
}

.liability-subheading {
    margin-top: 1.5rem;
    font-size: 1rem;
    color: #333;
}

.personal-details-preview {
    margin: 1rem 0;
    font-size: 0.85rem;
}

.personal-details-preview p {
    margin-bottom: 0.5rem;
}

.declaration-preview {
    margin-top: 1.5rem;
    font-size: 0.85rem;
}

.signature-block {
    margin-top: 2rem;
}

.signature-block p {
    margin-bottom: 0.5rem;
}

/* Footer */
footer {
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 2rem;
}

/* Scrollbar Styling */
.form-section::-webkit-scrollbar,
.preview-section::-webkit-scrollbar {
    width: 8px;
}

.form-section::-webkit-scrollbar-track,
.preview-section::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.form-section::-webkit-scrollbar-thumb,
.preview-section::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.form-section::-webkit-scrollbar-thumb:hover,
.preview-section::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }

    .preview-section {
        position: static;
        max-height: none;
    }
}

@media (max-width: 768px) {
    .main-title h1 {
        font-size: 1.8rem;
    }

    .asset-inputs {
        grid-template-columns: 1fr;
    }

    .nav-links {
        gap: 1rem;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn-reset,
    .btn-download {
        width: 100%;
    }
}

@media print {
    @page {
        size: A4;
        margin: 0;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body {
        background: white;
        margin: 0;
        padding: 0;
    }

    .form-section,
    .navbar,
    footer,
    .action-buttons,
    .tip-box,
    .preview-header-controls,
    .main-title {
        display: none !important;
    }

    .content-wrapper {
        display: block;
        margin: 0;
        padding: 0;
    }

    .preview-section {
        box-shadow: none;
        padding: 0;
        max-height: none;
        overflow: visible;
        margin: 0;
        position: static;
    }

    .preview-container {
        margin: 0;
        padding: 0;
        background: white;
        border-radius: 0;
    }

    .preview-page {
        page-break-after: auto;
        page-break-inside: auto;
        break-inside: auto;
        width: 100%;
        max-width: 100%;
        padding: 15mm 18mm;
        margin: 0;
        box-shadow: none;
        border: none;
        background: white;
        min-height: 0;
        font-size: 10pt;
    }

    .preview-page:nth-child(1) {
        page-break-after: always;
    }

    .preview-page:nth-child(2) {
        page-break-after: always;
    }

    .preview-page:nth-child(3) {
        page-break-after: auto;
    }

    .preview-page:last-child {
        page-break-after: auto;
    }

    /* Standard readable fonts for all pages */
    .preview-page h3 {
        font-size: 11pt;
        margin: 0.6rem 0 0.4rem 0;
        font-weight: bold;
    }

    .preview-page h4 {
        font-size: 10pt;
        margin: 0.4rem 0 0.3rem 0;
        font-weight: bold;
    }

    .preview-page p {
        font-size: 9pt;
        margin-bottom: 0.3rem;
        line-height: 1.4;
    }

    .preview-page .small-text {
        font-size: 8pt;
        margin: 0.25rem 0;
        font-style: italic;
    }

    .preview-header {
        margin-bottom: 0.6rem;
        padding-bottom: 0.4rem;
    }

    .preview-header h2 {
        font-size: 13pt;
        margin-bottom: 0.3rem;
        font-weight: bold;
    }

    .preview-page:nth-child(3) {
        font-size: 7pt;
    }

    .preview-page:nth-child(3) .preview-table {
        font-size: 6pt;
        margin: 0.15rem 0;
    }

    .preview-page:nth-child(3) .preview-table th,
    .preview-page:nth-child(3) .preview-table td {
        padding: 0.1rem 0.15rem;
        line-height: 1.1;
    }

    .preview-page:nth-child(3) p {
        margin-bottom: 0.15rem;
        font-size: 6pt;
    }

    .preview-page:nth-child(3) .liability-subheading {
        margin-top: 0.3rem;
        margin-bottom: 0.15rem;
        font-size: 7pt;
    }

    .preview-page:nth-child(3) .personal-details-table {
        font-size: 6pt;
        margin-top: 0.15rem;
    }

    .preview-page:nth-child(3) .personal-details-table td {
        padding: 0.08rem 0 !important;
    }

    .preview-page:nth-child(3) .declaration-preview {
        margin-top: 0.4rem;
    }

    .preview-page:nth-child(3) .declaration-preview p {
        margin: 0.25rem 0;
        font-size: 6.5pt;
    }

    .preview-page:nth-child(3) .signature-block {
        margin-top: 0.5rem;
        font-size: 6pt;
        gap: 0.5rem;
    }

    .preview-page:nth-child(3) .signature-block p {
        margin-bottom: 0.15rem;
    }

    .preview-table {
        page-break-inside: auto;
        font-size: 9pt;
        margin: 0.3rem 0;
        border-collapse: collapse;
    }

    .preview-table th,
    .preview-table td {
        padding: 0.3rem 0.3rem;
        line-height: 1.3;
        border: 1px solid #333;
    }

    .preview-table th {
        font-weight: bold;
        background-color: #f5f5f5;
    }

    .preview-table thead {
        display: table-header-group;
    }

    .preview-table tbody {
        display: table-row-group;
    }

    .personal-details-table td {
        border: none !important;
    }

    .page-footer {
        margin-top: 0.6rem;
        font-size: 8pt;
    }

    h3, h4 {
        page-break-after: avoid;
    }
}
