:root {
    --lo-navy: #0b1f3a;
    --lo-blue: #1261a0;
    --lo-gold: #d4a72c;
    --lo-light: #f4f6f8;
    --lo-border: #dfe3e8;
    --lo-muted: #667085;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: #eef1f5;
    font-family: 'Inter', sans-serif;
}

body {
    min-height: 100vh;
}


/* =====================================================
   TOP BAR
===================================================== */

.topbar {
    height: 64px;
    background: #ffffff;
    border-bottom: 1px solid var(--lo-border);
    display: flex;
    align-items: center;
    padding: 0 22px;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--lo-navy);
}

.brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;

    background:
        linear-gradient(
            135deg,
            var(--lo-navy),
            var(--lo-blue)
        );

    color: #fff;

    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-title {
    margin-left: 25px;
    padding-left: 25px;
    border-left: 1px solid var(--lo-border);
    color: var(--lo-muted);
    font-size: .9rem;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}


/* =====================================================
   BUILDER
===================================================== */

.builder {
    display: flex;
    min-height: calc(100vh - 64px);
}


/* =====================================================
   LEFT FORM PANEL
===================================================== */

.form-panel {
    width: 43%;
    min-width: 430px;
    background: #fff;
    border-right: 1px solid var(--lo-border);
    overflow-y: auto;
    height: calc(100vh - 64px);
}

.form-inner {
    padding: 25px;
    max-width: 700px;
    margin: auto;
}

.form-header {
    margin-bottom: 25px;
}

.form-header h4 {
    font-weight: 800;
    color: var(--lo-navy);
    margin-bottom: 5px;
}

.form-header p {
    color: var(--lo-muted);
    font-size: .88rem;
    margin: 0;
}

.section-card {
    border: 1px solid var(--lo-border);
    border-radius: 13px;
    margin-bottom: 18px;
    overflow: hidden;
    background: #fff;
}

.section-header {
    padding: 13px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--lo-border);
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    color: var(--lo-navy);
    font-size: .9rem;
}

.section-header i {
    color: var(--lo-blue);
}

.section-body {
    padding: 17px;
}

.form-label {
    font-size: .8rem;
    font-weight: 700;
    color: #344054;
    margin-bottom: 6px;
}

.form-control,
.form-select {
    border-color: #d0d5dd;
    border-radius: 8px;
    font-size: .88rem;
    padding: 9px 11px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--lo-blue);

    box-shadow:
        0 0 0 3px
        rgba(18, 97, 160, .10);
}

textarea.form-control {
    min-height: 90px;
    resize: vertical;
}

.small-help {
    font-size: .72rem;
    color: var(--lo-muted);
    margin-top: 5px;
}


/* =====================================================
   LOGO UPLOAD
===================================================== */

.logo-upload {
    border: 2px dashed #cfd6df;
    border-radius: 10px;
    padding: 18px;
    text-align: center;
    cursor: pointer;
    transition: .2s;
}

.logo-upload:hover {
    border-color: var(--lo-blue);
    background: #f8fbff;
}

.logo-upload i {
    font-size: 1.7rem;
    color: var(--lo-blue);
}

.logo-upload p {
    margin: 5px 0 0;
    font-size: .78rem;
    color: var(--lo-muted);
}

#logoPreview {
    max-width: 130px;
    max-height: 80px;
    object-fit: contain;
    display: none;
    margin: 10px auto 0;
}


/* =====================================================
   IMAGE UPLOAD
===================================================== */

.image-upload {
    border: 2px dashed #cfd6df;
    border-radius: 10px;
    padding: 18px;
    text-align: center;
    cursor: pointer;
    transition: .2s;
}

.image-upload:hover {
    border-color: var(--lo-blue);
    background: #f8fbff;
}

.image-upload i {
    font-size: 1.7rem;
    color: var(--lo-blue);
}

.image-upload p {
    margin: 5px 0 0;
    font-size: .78rem;
    color: var(--lo-muted);
}

.image-previews {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.image-preview-item {
    aspect-ratio: 1 / .75;
    border-radius: 7px;
    overflow: hidden;
    background: #eef1f4;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}


/* =====================================================
   RIGHT PREVIEW PANEL
===================================================== */

.preview-panel {
    width: 57%;
    background: #e9edf2;
    overflow: auto;
    height: calc(100vh - 64px);
}

.preview-header {
    height: 55px;
    background: rgba(255, 255, 255, .92);
    border-bottom: 1px solid #d8dde4;
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(10px);
}

.preview-header-title {
    font-weight: 700;
    color: var(--lo-navy);
    font-size: .9rem;
}

.page-status {
    margin-left: auto;
    padding: 6px 10px;
    border-radius: 20px;
    background: #ecfdf3;
    color: #027a48;
    font-size: .72rem;
    font-weight: 800;
}

.page-status.near {
    background: #fffaeb;
    color: #b54708;
}

.page-status.over {
    background: #fef3f2;
    color: #b42318;
}

.paper-area {
    padding: 35px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}


/* =====================================================
   A4 PAPER
===================================================== */

.a4-paper {
    width: 210mm;
    height: 297mm;
    max-width: 100%;
    background: white;

    box-shadow:
        0 12px 40px
        rgba(16, 24, 40, .18);

    padding: 15mm;
    color: #172033;
    position: relative;
    overflow: hidden;

    font-family:
        Arial,
        Helvetica,
        sans-serif;
}


/* =====================================================
   REPORT HEADER
===================================================== */

.report-header {
    border-bottom: 2px solid var(--lo-navy);
    padding-bottom: 7px;
    margin-bottom: 10px;
}

.report-head-row {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 65px;
}

.report-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
    display: none;
    flex-shrink: 0;
}

.report-title-area {
    flex: 1;
    min-width: 0;
    text-align: center;
}

.report-title {
    font-size: 17px;
    line-height: 1.25;
    font-weight: 800;
    text-transform: uppercase;
    margin: 0;
    word-break: break-word;
}

.report-subtitle {
    margin-top: 3px;
    font-size: 8.5px;
    color: #667085;
}


/* =====================================================
   META
===================================================== */

.report-meta {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin-bottom: 10px;
}

.meta-box {
    border: 1px solid #d0d5dd;
    padding: 5px 6px;
    min-height: 37px;
}

.meta-label {
    font-size: 6.5px;
    text-transform: uppercase;
    font-weight: 700;
    color: #667085;
}

.meta-value {
    font-size: 8px;
    font-weight: 600;
    margin-top: 2px;
    word-break: break-word;
}


/* =====================================================
   REPORT SECTION
===================================================== */

.report-section {
    margin-top: 7px;
}

.report-section-title {
    font-size: 8.5px;
    font-weight: 800;
    color: #fff;
    background: var(--lo-navy);
    padding: 4px 6px;
    text-transform: uppercase;
}

.report-section-content {
    font-size: 7.7px;
    line-height: 1.42;
    padding: 5px 6px;
    border: 1px solid #d0d5dd;
    border-top: none;
    white-space: pre-line;
    min-height: 20px;
    word-break: break-word;
}


/* =====================================================
   REPORT IMAGES
===================================================== */

.report-images {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-top: 7px;
}

.report-image {
    height: 42mm;
    object-fit: cover;
    width: 100%;
    display: none;
    border: 1px solid #d0d5dd;
}


/* =====================================================
   PREPARED
===================================================== */

.prepared-block {
    margin-top: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.prepared-box {
    font-size: 7.5px;
    line-height: 1.5;
}

.prepared-line {
    border-bottom: 1px solid #98a2b3;
    height: 18px;
    margin-bottom: 3px;
}


/* =====================================================
   FOOTER
===================================================== */

.report-footer {
    position: absolute;
    bottom: 10mm;
    left: 15mm;
    right: 15mm;
    border-top: 1px solid #d0d5dd;
    padding-top: 5px;
    display: flex;
    justify-content: space-between;
    font-size: 6.5px;
    color: #667085;
}


/* =====================================================
   MOBILE
===================================================== */

@media (max-width: 1000px) {

    .builder {
        display: block;
    }

    .form-panel,
    .preview-panel {
        width: 100%;
        min-width: 0;
        height: auto;
    }

    .form-panel {
        height: auto;
    }

    .preview-panel {
        min-height: 700px;
    }

    .preview-header {
        position: sticky;
        top: 64px;
    }

    .paper-area {
        padding: 20px 10px;
    }
}


/* =====================================================
   PRINT
===================================================== */

@media print {

    @page {
        size: A4 portrait;
        margin: 0;
    }

    body {
        background: white;
    }

    .topbar,
    .form-panel,
    .preview-header {
        display: none !important;
    }

    .preview-panel {
        width: 100%;
        height: auto;
        overflow: visible;
        background: white;
    }

    .paper-area {
        padding: 0;
    }

    .a4-paper {
        box-shadow: none;
        width: 210mm;
        height: 297mm;
    }
}