/* =========================================================
   CHIFRANDO PRO — BOQ GENERATOR
   Clean responsive stylesheet
   ========================================================= */

:root {
    --brand: #204DA7;
    --brand-dark: #173D87;
    --brand-soft: #EAF0FB;
    --page: #F5F7FB;
    --white: #FFFFFF;
    --text: #182230;
    --muted: #667085;
    --border: #E5E9F0;
    --border-soft: #EDF0F4;
    --input: #D7DCE5;
    --danger: #B42318;
    --danger-soft: #FFF5F5;
    --success: #087443;
    --shadow: 0 2px 10px rgba(16, 24, 40, 0.05);
    --radius: 12px;
}

/* =========================================================
   RESET
   ========================================================= */

* { box-sizing: border-box; }

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--page);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    overflow-x: hidden;
}

body.menu-open,
body.modal-open { overflow: hidden; }

button,
input,
select,
textarea { font: inherit; }

button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }

a { color: inherit; }

#app { min-height: 100vh; }

/* =========================================================
   APP SHELL
   ========================================================= */

.app { min-height: 100vh; }

.main {
    min-height: 100vh;
    margin-left: 248px;
}

.content {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 28px;
}

/* =========================================================
   SIDEBAR
   ========================================================= */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 2000;
    width: 248px;
    padding: 18px 14px;
    background: var(--white);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    transition: transform .25s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 5px 8px 20px;
}

.brandmark {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    place-items: center;
    border-radius: 11px;
    background: var(--brand);
    color: var(--white);
    font-size: 21px;
    font-weight: 850;
}

.brandtext {
    display: flex;
    min-width: 0;
    flex-direction: column;
    line-height: 1.1;
}

.brandtext b { font-weight: 850; }
.brandtext small { margin-top: 3px; color: var(--muted); }

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.navlink {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 11px 13px;
    border-radius: 9px;
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 650;
}

.navlink:hover,
.navlink.active {
    background: var(--brand-soft);
    color: var(--brand);
}

.navlink i {
    width: 20px;
    flex: 0 0 20px;
    text-align: center;
    font-size: 18px;
}

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1900;
    background: rgba(15, 23, 42, .45);
}

/* =========================================================
   TOP HEADER
   ========================================================= */

.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 72px;
    padding: 12px 28px;
    background: var(--white);
    border-bottom: 1px solid var(--border);
}

.head-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1 1 auto;
}

.head-copy { min-width: 0; }

.top-title {
    overflow: hidden;
    font-size: 15px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-sub {
    margin-top: 2px;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-menu {
    display: none;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--white);
    color: var(--brand);
    font-size: 21px;
}

/* =========================================================
   BUTTONS
   ========================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 9px 13px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--white);
    color: var(--text);
    font-size: 13px;
    font-weight: 650;
    line-height: 1.2;
    text-decoration: none;
}

.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--white); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-light { border-color: var(--border); }
.btn-light:hover { background: #F8FAFC; }
.btn-outline { border-color: var(--brand); color: var(--brand); }
.btn-outline:hover { background: var(--brand-soft); }
.btn-danger { border-color: #F0C6C2; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { min-height: 32px; padding: 6px 9px; font-size: 12px; }

.actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* =========================================================
   PAGE HEADINGS / DASHBOARD
   ========================================================= */

.page-head,
.edit-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-head h2,
.edit-top h2 { margin: 0 0 5px; font-size: 22px; font-weight: 800; }
.page-head p,
.edit-top p { margin: 0; color: var(--muted); font-size: 13px; }

.cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 18px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.stat-label { color: var(--muted); font-size: 12px; }
.stat b,
.stat-value { display: block; margin-top: 5px; font-size: 23px; font-weight: 800; }
.stat i { color: var(--brand); font-size: 25px; }

/* =========================================================
   CARDS / FORMS
   ========================================================= */

.card {
    overflow: hidden;
    margin-top: 14px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card:first-child { margin-top: 0; }
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 17px;
    border-bottom: 1px solid var(--border-soft);
    font-weight: 750;
}
.card-body { padding: 17px; }

.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 650;
}

.field input,
.field textarea,
.field select,
.material-input {
    width: 100%;
    min-height: 40px;
    padding: 10px 11px;
    background: var(--white);
    border: 1px solid var(--input);
    border-radius: 8px;
    color: var(--text);
    outline: none;
}

.field textarea { min-height: 100px; resize: vertical; }

.field input:focus,
.field textarea:focus,
.field select:focus,
.material-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(32, 77, 167, .09);
}

.full { grid-column: 1 / -1; }
.req { color: #D92D20; }

/* =========================================================
   BOQ EDITOR / SECTIONS
   ========================================================= */

.edit-page { width: 100%; max-width: 1200px; margin: 0 auto; }
.option-card,
.sections-card { margin-top: 14px; }

.settings-note {
    padding: 12px;
    background: #F8FAFC;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--muted);
    font-size: 12px;
}

.section-card {
    margin-top: 14px;
    overflow: hidden;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.section-card:first-child { margin-top: 0; }

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 15px;
    border-bottom: 1px solid var(--border-soft);
}

.section-head > div:first-child { min-width: 0; flex: 1 1 auto; }
.section-head b,
.section-title { display: block; font-size: 15px; font-weight: 800; }
.section-head small,
.section-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }

.section-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    flex-wrap: wrap;
}

.section-bottom {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 15px;
    border-top: 1px solid var(--border-soft);
}

.add-tab,
.paste-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 10px 14px;
    border: 1px solid var(--brand);
    border-radius: 9px;
    background: var(--white);
    color: var(--brand);
    font-size: 13px;
    font-weight: 700;
}

.add-tab:hover { background: var(--brand); color: var(--white); }
.paste-tab { border-color: var(--input); color: #344054; }
.paste-tab:hover { background: #F8FAFC; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    padding: 0;
    border: 1px solid var(--input);
    border-radius: 8px;
    background: var(--white);
    color: #344054;
}

.subtotal { margin-left: auto; font-size: 13px; }

/* =========================================================
   PRICING TOGGLE
   ========================================================= */

.price-setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.price-setting-copy { min-width: 0; }
.price-setting-title { font-weight: 750; }
.price-setting-state { margin-top: 3px; color: var(--muted); font-size: 12px; }

.switch {
    position: relative;
    display: inline-flex;
    width: 48px;
    height: 28px;
    flex: 0 0 48px;
}

.switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.switch-track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #D0D5DD;
    transition: background .2s ease;
}

.switch-track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--white);
    box-shadow: 0 1px 3px rgba(0,0,0,.18);
    transition: transform .2s ease;
}

.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }

/* =========================================================
   TABLES
   ========================================================= */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    min-width: 650px;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 10px 9px;
    border-bottom: 1px solid var(--border-soft);
    text-align: left;
    vertical-align: middle;
    font-size: 12px;
}

.table th {
    background: #F8FAFC;
    color: #667085;
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .35px;
    text-transform: uppercase;
}

.table th:first-child,
.table td:first-child { width: 50px; text-align: center; }
.table td.actions-cell { width: 1%; text-align: right; white-space: nowrap; }
.table input { width: 100%; padding: 7px; border: 1px solid var(--input); border-radius: 7px; }
.price-input { width: 120px !important; }

/* =========================================================
   PREVIEW / PRINT DOCUMENT
   ========================================================= */

.preview-wrap {
    margin-top: 14px;
    padding: 18px;
    background: #EEF1F6;
    border-radius: var(--radius);
}

.preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.paper {
    width: 100%;
    max-width: 850px;
    margin: 0 auto;
    padding: 42px;
    background: var(--white);
    box-shadow: 0 5px 25px rgba(16, 24, 40, .08);
}

.paper-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 28px;
    padding-bottom: 18px;
    border-bottom: 3px solid var(--brand);
}

.paper-details-block {
    min-width: 0;
    flex: 1 1 0;
}

.paper-details-left {
    text-align: left;
}

.paper-details-right {
    text-align: right;
}

.paper-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 18px;
    margin-top: 16px;
}

.paper-details-right .paper-detail-grid {
    grid-template-columns: 1fr;
    justify-items: end;
}

.paper-detail {
    min-width: 0;
}


.paper-brand { color: var(--brand); font-size: 22px; font-weight: 900; }
.paper-title { max-width: 520px; color: var(--brand); font-size: 26px; font-weight: 900; letter-spacing: .6px; line-height: 1.15; }

.paper-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 22px 0;
}

.meta-label { color: #98A2B3; font-size: 10px; font-weight: 850; letter-spacing: 1px; text-transform: uppercase; }
.meta-value { margin-top: 3px; font-size: 14px; font-weight: 650; }

.paper-section { margin-top: 22px; }
.paper-section h4 {
    margin: 0;
    padding: 9px 10px;
    background: var(--brand);
    border-radius: 4px 4px 0 0;
    color: var(--white);
    font-size: 14px;
    letter-spacing: .5px;
    text-transform: uppercase;
}

.paper-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.paper-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}

.paper-table th,
.paper-table td { padding: 9px 8px; border: 1px solid #DCE1E8; }
.paper-table th { background: #EEF3FB; color: #244D8F; font-size: 11px; text-transform: uppercase; }
.paper-table th:nth-child(1),
.paper-table td:nth-child(1) { width: 42px; text-align: center; }
.paper-table th:nth-child(3),
.paper-table td:nth-child(3) { width: 80px; text-align: center; }
.paper-table th:nth-child(4),
.paper-table td:nth-child(4) { width: 75px; text-align: center; }
.paper-table th:nth-child(n+5),
.paper-table td:nth-child(n+5) { text-align: right; white-space: nowrap; }

.paper-total { margin-top: 7px; text-align: right; font-size: 14px; font-weight: 800; }
.paper-summary { margin-top: 24px; padding-top: 10px; border-top: 2px solid var(--brand); }
.summary-row { display: flex; justify-content: space-between; gap: 20px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: 14px; }
.summary-row:last-child { border-bottom: 0; }
.summary-row.total { font-size: 16px; }
.paper-foot { margin-top: 32px; padding-top: 12px; border-top: 1px solid #EEE; color: #98A2B3; font-size: 11px; text-align: center; }

/* =========================================================
   MODALS / MOBILE BOTTOM SHEETS
   ========================================================= */

.modal {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, .52);
}

.modal-card,
.bottom-sheet,
.paste-sheet {
    width: min(820px, 100%);
    max-height: min(760px, 92vh);
    overflow: hidden;
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 18px 60px rgba(15, 23, 42, .2);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 17px;
    border-bottom: 1px solid var(--border);
}

.modal-head b { font-size: 16px; }
.modal-body { max-height: 65vh; overflow-y: auto; padding: 17px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 17px; border-top: 1px solid var(--border); }

.textarea { width: 100%; min-height: 190px; padding: 12px; border: 1px solid var(--input); border-radius: 9px; resize: vertical; }
.parse-actions { margin-top: 10px; }
.full-btn { width: 100%; margin-top: 12px; }
.review-title { margin: 15px 0 8px; font-weight: 800; }
.review { margin-top: 10px; padding: 10px; background: #FFF7ED; border: 1px solid #FED7AA; border-radius: 8px; color: #9A3412; font-size: 12px; }

/* =========================================================
   HELPERS
   ========================================================= */

.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { padding: 24px; color: #98A2B3; font-size: 13px; text-align: center; }
.search { width: 100%; max-width: 380px; padding: 10px 11px; border: 1px solid var(--input); border-radius: 8px; background: var(--white); outline: none; }
.search:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(32, 77, 167, .09); }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 4000; max-width: min(90vw, 420px); padding: 11px 14px; background: #172033; border-radius: 9px; color: var(--white); box-shadow: 0 8px 30px rgba(0,0,0,.18); font-size: 12px; }
.hide { display: none !important; }
.sticky { position: sticky; top: 90px; }

/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 1000px) {
    .sidebar { width: 78px; padding: 18px 9px; }
    .brand { justify-content: center; }
    .brandtext,
    .navlink span { display: none; }
    .navlink { justify-content: center; }
    .main { margin-left: 78px; }
    .content { padding: 20px; }
    .grid { grid-template-columns: 1fr; }
    .sticky { position: static; }
    .paper { padding: 30px; }
}

/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 767px) {
    body { font-size: 14px; }

    .main {
        width: 100%;
        margin-left: 0;
    }

    .content { padding: 12px; }

    /* Off-canvas navigation. */
    .sidebar {
        width: min(290px, 86vw);
        max-width: 86vw;
        padding: 18px 14px;
        transform: translateX(-110%);
        box-shadow: 10px 0 30px rgba(16, 24, 40, .16);
    }

    .sidebar.open { transform: translateX(0); }
    .overlay.show { display: block; }

    .brand { justify-content: flex-start; }
    .brandtext,
    .navlink span { display: block; }
    .navlink { justify-content: flex-start; min-height: 48px; }

    /* Mobile-first header. */
    .topbar {
        min-height: 60px;
        padding: 8px 10px;
    }

    .mobile-menu { display: inline-flex; }
    .head-left { min-width: 0; }
    .head-copy { min-width: 0; overflow: hidden; }
    .top-title { max-width: calc(100vw - 150px); font-size: 14px; }
    .top-sub { max-width: calc(100vw - 150px); font-size: 10px; }

    .topbar > .btn {
        flex: 0 0 auto;
        min-height: 38px;
        padding: 8px 10px;
        font-size: 12px;
        white-space: nowrap;
    }

    /* Page controls. */
    .page-head,
    .edit-top { flex-direction: column; gap: 10px; margin-bottom: 14px; }
    .page-head h2,
    .edit-top h2 { font-size: 19px; }
    .page-head p,
    .edit-top p { font-size: 12px; }
    .page-head > .btn,
    .page-head > .actions,
    .edit-top > .actions { width: 100%; }

    .actions { width: 100%; }
    .actions .btn { flex: 1 1 auto; }

    /* Dashboard. */
    .cards { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat { min-width: 0; padding: 11px; }
    .stat b,
    .stat-value { font-size: 19px; }

    /* Forms. */
    .card-head,
    .card-body { padding: 12px 13px; }
    .grid,
    .grid.two { grid-template-columns: 1fr !important; gap: 10px; }

    .field input,
    .field textarea,
    .field select,
    .material-input { font-size: 16px; }

    /* Pricing switch. */
    .price-setting { align-items: center; }

    /* Section heading: never hide the default section name on mobile. */
    .section-head {
        display: flex;
        align-items: flex-start;
        flex-direction: column;
        padding: 13px;
    }

    .section-head > div:first-child {
        display: block !important;
        width: 100%;
        min-width: 0;
    }

    .section-head b,
    .section-title {
        display: block !important;
        overflow: visible;
        color: var(--text);
        font-size: 16px;
        line-height: 1.35;
        white-space: normal;
        visibility: visible;
        opacity: 1;
    }

    .section-head small,
    .section-meta {
        display: block !important;
        visibility: visible;
    }

    .section-actions {
        width: 100%;
        justify-content: stretch;
    }

    .section-actions .btn,
    .section-actions .icon-btn { flex: 1 1 0; }

    .section-bottom {
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
    }

    .section-bottom .add-tab,
    .section-bottom .paste-tab {
        width: 100%;
        min-height: 44px;
    }

    .subtotal { margin-left: 0; text-align: right; }

    /* Material tables. */
    .table-wrap { max-width: 100%; }
    .table { min-width: 700px; }
    .table th,
    .table td { padding: 9px 7px; font-size: 12px; }

    /* Preview. */
    .preview-wrap { padding: 5px; }
    .paper { width: 100%; padding: 16px !important; box-shadow: none; }
    .paper-head { flex-direction: column; gap: 18px; }
    .paper-details-right { text-align: left; }
    .paper-details-right .paper-detail-grid { justify-items: start; }
    .paper-title { max-width: none; font-size: 21px; }
    .paper-detail-grid { grid-template-columns: 1fr; gap: 9px; margin-top: 13px; }
    .paper-meta { grid-template-columns: 1fr; gap: 9px; margin: 15px 0; }
    .paper-table { min-width: 620px; font-size: 14px; }
    .paper-table th,
    .paper-table td { padding: 8px 6px; }

    /* Centered mobile dialogs, matching the Debit Book modal style. */
    .modal {
        align-items: center;
        justify-content: center;
        padding: 16px;
    }

    .modal-card,
    .bottom-sheet,
    .paste-sheet {
        width: min(620px, calc(100vw - 32px));
        max-width: 100%;
        max-height: 88dvh;
        border-radius: 18px;
        animation: modal-in .18s ease-out;
    }

    .paste-sheet {
        width: min(820px, calc(100vw - 32px));
    }

    .modal-head {
        position: sticky;
        top: 0;
        z-index: 2;
        padding: 15px 17px;
        background: var(--white);
    }

    .modal-head b {
        font-size: 20px;
    }

    .modal-body {
        max-height: calc(88dvh - 126px);
        padding: 17px;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-body .grid,
    .modal-body .grid.two {
        grid-template-columns: 1fr !important;
    }

    .modal-body .field {
        width: 100%;
    }

    .modal-body input,
    .modal-body textarea,
    .modal-body select {
        width: 100%;
        min-height: 46px;
        font-size: 16px;
    }

    .modal-foot {
        position: sticky;
        bottom: 0;
        z-index: 2;
        padding: 11px 17px calc(11px + env(safe-area-inset-bottom));
        background: var(--white);
    }

    .modal-foot .btn {
        flex: 1 1 0;
        min-height: 46px;
    }

    .textarea { min-height: 160px; font-size: 16px; }
    .search { width: 100%; max-width: none; }
}

@keyframes modal-in {
    from { transform: scale(.97); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}


/* =========================================================
   LIVE PREVIEW — MOBILE
   ========================================================= */

@media (max-width: 767px) {
    .preview-wrap {
        width: 100%;
        overflow: hidden;
        padding: 8px;
    }

    #livePreview {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }

    #livePreview .paper {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        margin: 0;
        padding: 18px 14px !important;
        box-shadow: none;
    }

    #livePreview .paper-head {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    #livePreview .paper-right {
        text-align: left;
    }

    #livePreview .paper-meta {
        grid-template-columns: 1fr;
    }

    #livePreview .paper-table-wrap {
        width: 100%;
        overflow-x: auto;
    }

    #livePreview .paper-table {
        min-width: 620px;
    }
}

/* =========================================================
   PRINT / A4 PDF
   ========================================================= */

@media print {
    body {
        background: var(--white);
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .sidebar,
    .topbar,
    .no-print,
    .preview-bar { display: none !important; }
    .main { margin: 0; }
    .content { max-width: none; padding: 0; }
    .preview-wrap { margin: 0; padding: 0; background: var(--white); }
    .paper { max-width: none; padding: 7mm; box-shadow: none; font-size: 16px !important; }
    .paper-brand { font-size: 24px !important; }
    .paper-title { font-size: 27px !important; }
    .paper-section h4 { break-after: avoid; font-size: 16px !important; background: var(--brand) !important; color: var(--white) !important; }
    .paper-table { width: 100%; min-width: 0; font-size: 16px !important; }
    .paper-table th { font-size: 13px !important; }
    .paper-table th,
    .paper-table td { padding: 9px !important; }
    .paper-table thead { display: table-header-group; }
    .paper-table tr { break-inside: avoid; }
    .meta-value,
    .paper-detail .meta-value,
    .summary-row { font-size: 16px !important; }
    .meta-label { font-size: 11px !important; }
    .paper-total { font-size: 16px !important; }
    .paper-foot { font-size: 12px !important; }
    @page { size: A4; margin: 7mm; }
}
