* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: Arial, Helvetica, sans-serif;
    background: #f3f4f6;
    color: #111827;
}
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #0f0f10, #1e1e24);
}
.login-card, .sidebar-card, .invoice-sheet {
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.12);
}
.login-card {
    width: 100%;
    max-width: 460px;
    padding: 32px;
}
.logo-box {
    width: 130px;
    background: #000;
    color: #d4af37;
    text-align: center;
    padding: 14px 8px;
    border-radius: 8px;
    font-weight: bold;
    line-height: 1.25;
    margin-bottom: 18px;
    font-size: 12px;
}
.logo-box.large {
    width: 122px;
    min-height: 88px;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.subtitle, .small-note { color: #6b7280; }
.login-form, .form-grid { display: grid; gap: 12px; }
label { font-size: 14px; font-weight: 700; }
input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    font-size: 14px;
}
input:focus {
    outline: none;
    border-color: #d4af37;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}
.btn {
    display: inline-block;
    text-align: center;
    text-decoration: none;
    padding: 12px 18px;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
    border: none;
}
.btn-gold { background: #d4af37; color: #111; }
.btn-outline { border: 1px solid #d1d5db; color: #111827; background: #fff; }
.error-message {
    background: #fef2f2;
    color: #b91c1c;
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 12px;
}
.demo-box {
    margin-top: 18px;
    padding: 14px;
    border-radius: 14px;
    background: #f9fafb;
    color: #374151;
    font-size: 14px;
}
.app-shell {
    display: grid;
    grid-template-columns: 390px 1fr;
    gap: 24px;
    padding: 24px;
}
.sidebar { display: flex; flex-direction: column; gap: 20px; }
.sidebar-card { padding: 22px; }
.action-row { display: flex; gap: 12px; margin: 14px 0; flex-wrap: wrap; }
.form-grid h3 {
    margin: 10px 0 0;
    font-size: 18px;
    color: #111827;
    border-top: 1px solid #e5e7eb;
    padding-top: 16px;
}
.form-grid h3:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.preview-area { overflow: auto; }
.invoice-sheet {
    width: 210mm;
    min-height: 297mm;
    max-width: 210mm;
    margin: 0 auto;
    padding: 11mm 12mm 10mm;
    border-radius: 10px;
}
.invoice-sheet p, .invoice-sheet td, .invoice-sheet th, .invoice-sheet div, .invoice-sheet span {
    line-height: 1.18;
}
.invoice-header {
    display: grid;
    grid-template-columns: 136px 1fr;
    gap: 14px;
    align-items: start;
    padding-bottom: 10px;
    border-bottom: 1px solid #aeb9c6;
}
.company-meta h1 {
    margin: 0;
    font-size: 17px;
    letter-spacing: 0.2px;
}
.company-meta p { margin: 4px 0; font-size: 11.5px; }
.invoice-title {
    text-align: center;
    font-size: 20px;
    letter-spacing: 0.8px;
    color: #334155;
    margin: 10px 0 10px;
}
.top-grid, .bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.top-grid p, .consignee-block p, .bottom-grid p { margin: 2px 0; font-size: 11.4px; }
.top-grid h3, .consignee-block h3 { margin: 0 0 4px; font-size: 12px; }
.right-meta { text-align: right; }
.consignee-block { margin-top: 12px; }
.section-title {
    font-weight: 700;
    margin: 12px 0 6px;
    font-size: 12px;
}
.cargo-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11.1px;
    table-layout: fixed;
}
.cargo-table td {
    border: 1px solid #8f98a3;
    padding: 3px 7px;
    vertical-align: top;
    word-wrap: break-word;
}
.cargo-table td:first-child {
    width: 34%;
    background: #f3f4f6;
    font-weight: 700;
}
.bottom-grid {
    margin-top: 12px;
    grid-template-columns: 1fr 250px;
    align-items: end;
}
.signature-line {
    margin-top: 20px;
    padding-top: 4px;
    border-top: 1px dashed #6b7280;
    width: 120px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
}
.reg-box {
    align-self: end;
    border: 1px solid #6b7280;
    padding: 10px 12px;
    font-size: 11px;
    min-height: 64px;
}
.pdf-note {
    margin-top: 10px;
    font-size: 12px;
    color: #6b7280;
}
@media (max-width: 1100px) {
    .app-shell { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .invoice-sheet {
        width: 100%;
        max-width: 100%;
        min-height: auto;
        padding: 18px;
    }
}
@media (max-width: 700px) {
    .invoice-header, .top-grid, .bottom-grid {
        grid-template-columns: 1fr;
    }
    .right-meta { text-align: left; }
    .action-row { flex-direction: column; }
    .invoice-sheet { padding: 16px; }
}
@page {
    size: A4 portrait;
    margin: 0;
}
@media print {
    html, body {
        width: 210mm;
        height: 297mm;
        background: #fff;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .no-print { display: none !important; }
    .app-shell { display: block; padding: 0; }
    .preview-area { overflow: visible; }
    .invoice-sheet {
        box-shadow: none;
        border-radius: 0;
        width: 210mm;
        min-height: 297mm;
        max-width: 210mm;
        margin: 0;
        padding: 11mm 12mm 10mm;
        page-break-after: avoid;
        page-break-inside: avoid;
        overflow: hidden;
    }
    .invoice-sheet * {
        page-break-inside: avoid;
    }
}


body.pdf-exporting .no-print {
    display: none !important;
}

body.pdf-exporting {
    background: #ffffff;
}

body.pdf-exporting .app-shell {
    display: block;
    padding: 0;
}

body.pdf-exporting .preview-area {
    overflow: visible;
}

body.pdf-exporting .invoice-sheet {
    box-shadow: none;
    border-radius: 0;
    margin: 0 auto;
}

.btn:disabled {
    opacity: 0.7;
    cursor: wait;
}
