:root {
    --invoice-ink: #172033;
    --invoice-muted: #64748b;
    --invoice-line: #cbd5e1;
    --invoice-line-strong: #94a3b8;
    --invoice-blue: #1d4ed8;
    --invoice-cyan: #0891b2;
    --invoice-green: #047857;
    --invoice-soft-blue: #eff6ff;
    --invoice-soft-cyan: #ecfeff;
    --invoice-soft-green: #ecfdf5;
}

body {
    font-family: Inter, Arial, sans-serif;
    background:
        radial-gradient(circle at 12% 4%, rgba(29, 78, 216, 0.16), transparent 26%),
        radial-gradient(circle at 88% 0%, rgba(4, 120, 87, 0.13), transparent 28%),
        linear-gradient(180deg, #eef6ff 0%, #f8fafc 42%, #eefdf8 100%);
    color: var(--invoice-ink);
}

* {
    box-sizing: border-box;
}

.invoice-shell {
    max-width: 1320px;
    margin: 0 auto;
}

.invoice-paper {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,255,255,1)),
        #fff;
    color: var(--invoice-ink);
    box-shadow: 0 34px 100px -46px rgba(15, 23, 42, 0.72);
    padding: 9mm;
    font-family: Inter, Arial, sans-serif;
    font-size: 11px;
    line-height: 1.32;
    border-radius: 18px;
    overflow: visible;
    border: 1px solid rgba(148, 163, 184, 0.55);
}

.invoice-paper.preview-mode input,
.invoice-paper.preview-mode textarea,
.invoice-paper.preview-mode select {
    border-color: transparent;
    background: transparent;
}

.invoice-input,
.invoice-textarea,
.invoice-select {
    width: 100%;
    min-width: 0;
    min-height: 28px;
    border: 1px solid var(--invoice-line);
    border-radius: 7px;
    padding: 6px 8px;
    font: inherit;
    line-height: 1.3;
    color: var(--invoice-ink);
    background: rgba(255, 255, 255, 0.96);
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.9);
}

.invoice-textarea {
    min-height: 44px;
    resize: vertical;
}

.invoice-input:focus,
.invoice-textarea:focus,
.invoice-select:focus {
    border-color: var(--invoice-blue);
    box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.12), inset 0 1px 0 rgba(255,255,255,0.9);
}

.invoice-box {
    border: 1px solid var(--invoice-line-strong);
    border-radius: 12px;
    overflow: visible;
    background: rgba(255,255,255,0.98);
}

.invoice-grid {
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    width: 100%;
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid var(--invoice-line-strong);
    background: #fff;
}

.invoice-grid th,
.invoice-grid td {
    border: 0;
    border-right: 1px solid var(--invoice-line);
    border-bottom: 1px solid var(--invoice-line);
    padding: 6px 7px;
    vertical-align: top;
    overflow-wrap: anywhere;
    word-break: normal;
}

.invoice-grid th {
    font-weight: 800;
    text-transform: uppercase;
    text-align: center;
    background: linear-gradient(180deg, #e0f2fe, #eef6ff);
    color: #0f3f7a;
    font-size: 9.5px;
    letter-spacing: 0.03em;
    line-height: 1.18;
}

.invoice-grid th:last-child,
.invoice-grid td:last-child {
    border-right: 0;
}

.invoice-grid tbody tr:last-child td {
    border-bottom: 0;
}

.freight-grid th:nth-child(1),
.freight-grid td:nth-child(1) {
    width: 44px;
}

.freight-grid th:nth-child(2),
.freight-grid td:nth-child(2) {
    width: 18%;
}

.freight-grid th:nth-child(3),
.freight-grid td:nth-child(3) {
    width: 13%;
}

.freight-grid th:nth-child(4),
.freight-grid td:nth-child(4),
.freight-grid th:nth-child(5),
.freight-grid td:nth-child(5),
.freight-grid th:nth-child(6),
.freight-grid td:nth-child(6),
.freight-grid th:nth-child(7),
.freight-grid td:nth-child(7) {
    width: 13%;
}

.totals-grid td:first-child {
    width: 48%;
}

.invoice-label {
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #475569;
    font-size: 9.5px;
    line-height: 1.2;
}

.invoice-section-title {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 4px 10px;
    margin: -2px 0 8px;
    border-radius: 999px;
    background: var(--invoice-soft-green);
    color: var(--invoice-green);
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.invoice-actions {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(241, 245, 249, 0.94);
    backdrop-filter: blur(10px);
}

.invoice-modern-header {
    border-color: #7dd3fc;
    overflow: hidden;
    background:
        linear-gradient(135deg, rgba(29, 78, 216, 0.1), transparent 35%),
        linear-gradient(180deg, #ffffff 0%, #f0f9ff 100%);
}

.invoice-header-main {
    border-right: 1px solid #bae6fd;
}

.invoice-meta-panel {
    background: linear-gradient(180deg, #e0f2fe 0%, #f8fafc 100%);
}

.invoice-customer-box {
    margin-top: 8px;
    border-color: #bbf7d0;
    background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 72%);
}

.invoice-tax-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--invoice-blue);
    border-radius: 999px;
    background: linear-gradient(135deg, var(--invoice-blue), var(--invoice-cyan));
    color: #fff;
    min-height: 24px;
    padding: 5px 16px;
    font-size: 11px;
    letter-spacing: 0.14em;
    box-shadow: 0 14px 30px -20px rgba(29, 78, 216, 0.85);
}

.invoice-tax-pill {
    text-transform: uppercase;
    font-weight: 900;
}

.invoice-title-input {
    border-color: transparent;
    background: transparent;
    letter-spacing: 0.08em;
    color: #0f2f67;
}

.invoice-title-input:focus {
    border-color: var(--invoice-blue);
}

.invoice-mini-button {
    border: 1px solid var(--invoice-line-strong);
    border-radius: 999px;
    background: #ffffff;
    color: var(--invoice-blue);
    font-size: 11px;
    font-weight: 900;
    padding: 8px 12px;
    box-shadow: 0 10px 24px -18px rgba(15, 23, 42, 0.45);
}

.mini-slip {
    border: 1px dashed var(--invoice-green);
    border-radius: 12px;
    margin-top: 8mm;
    padding: 4mm;
    page-break-inside: avoid;
    background: linear-gradient(180deg, #ecfdf5 0%, #ffffff 68%);
}

.mini-slip-head {
    border-bottom: 1px solid #86efac;
    color: #065f46;
}

.print-only {
    display: none;
}

@page {
    size: A4;
    margin: 7mm;
}

@media (max-width: 980px) {
    .invoice-paper {
        width: 100%;
        min-height: auto;
        padding: 14px;
        font-size: 10px;
        border-radius: 14px;
    }

    .invoice-header-main {
        border-right: 0;
        border-bottom: 1px solid #bae6fd;
    }

    .freight-grid {
        display: block;
        overflow-x: auto;
        table-layout: auto;
    }

    .freight-grid th,
    .freight-grid td {
        min-width: 96px;
    }

    .freight-grid th:first-child,
    .freight-grid td:first-child {
        min-width: 44px;
    }
}

@media print {
    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body {
        background: #fff !important;
    }

    .no-print,
    .page-nav,
    .invoice-actions {
        display: none !important;
    }

    .print-only {
        display: block;
    }

    .invoice-shell {
        max-width: none;
        margin: 0;
        padding: 0 !important;
    }

    .invoice-paper {
        width: 196mm;
        max-width: 196mm;
        min-height: auto;
        margin: 0;
        padding: 0;
        box-shadow: none;
        font-size: 10px;
        border-radius: 0;
        border: 0;
        overflow: visible;
        color: #000;
    }

    .invoice-input,
    .invoice-textarea,
    .invoice-select {
        border-color: transparent !important;
        background: transparent !important;
        padding: 0;
        box-shadow: none !important;
        appearance: none;
        -webkit-appearance: none;
        resize: none !important;
    }

    input[type="date"]::-webkit-calendar-picker-indicator,
    input[type="number"]::-webkit-inner-spin-button,
    input[type="number"]::-webkit-outer-spin-button,
    textarea::-webkit-resizer {
        display: none !important;
        opacity: 0 !important;
    }

    select::-ms-expand {
        display: none;
    }

    .invoice-box,
    .invoice-grid,
    .mini-slip {
        border-radius: 0;
        border-color: #555 !important;
    }

    .invoice-grid th,
    .invoice-grid td {
        border-color: #555 !important;
    }

    .invoice-modern-header,
    .invoice-meta-panel,
    .invoice-customer-box,
    .mini-slip,
    .invoice-grid th {
        background: #f8fafc !important;
    }

    .invoice-tax-pill {
        border-color: #1d4ed8 !important;
        color: #fff !important;
        background: #1d4ed8 !important;
        box-shadow: none !important;
    }

    .invoice-section-title {
        border-radius: 0;
        background: transparent !important;
        color: #000 !important;
        padding-left: 0;
    }

    button {
        display: none !important;
    }
}
