@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #0b0d19;
    --panel: #141729;
    --panel-light: #1b2036;
    --border: #2b3150;
    --text: #f2f3ff;
    --muted: #9299b8;
    --accent: #9275ff;
    --accent-light: #b6a4ff;
    --green: #70e1bd;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: 'DM Sans', sans-serif;
    color: var(--text);
    background:
        radial-gradient(ellipse at 10% 0%, #25204e 0%, transparent 38%),
        radial-gradient(ellipse at 95% 35%, #172d46 0%, transparent 32%),
        var(--bg);
}

.invoice-container {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 30px 34px 50px;
}

/* HEADER */

.invoice-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 42px;
    padding: 0 13px;
    border: 1px solid var(--border);
    border-radius: 13px;
    color: var(--accent-light);
    text-decoration: none;
    background: #191b31;
    transition: 0.2s ease;
}

.back-link:hover {
    background: #292447;
    border-color: var(--accent);
}

.invoice-header h1 {
    margin: 0;
    font-size: clamp(23px, 3vw, 32px);
    font-weight: 800;
    letter-spacing: -1px;
}

/* MAIN LAYOUT */

.invoice-workspace {
    display: grid;
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
    gap: 25px;
    align-items: start;
}

.invoice-form-section,
.invoice-preview-section {
    min-width: 0;
    padding: 26px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: linear-gradient(145deg, #171a2e, #111425);
    box-shadow: 0 20px 60px #00000024;
}

.invoice-form-section h2,
.invoice-preview-section h2 {
    margin: 0 0 24px;
    font-size: 19px;
    font-weight: 700;
}

/* FORM BLOCKS */

.form-block {
    margin-bottom: 27px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.form-block:last-child {
    border-bottom: none;
}

.form-block h3 {
    margin: 0 0 18px;
    color: var(--accent-light);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 17px;
}

.form-group label {
    color: #c5cae1;
    font-size: 13px;
    font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea,
.inline-fields input,
.item-row input,
.format-dropdown {
    width: 100%;
    min-width: 0;
    padding: 13px 14px;
    border: 1px solid #343956;
    border-radius: 11px;
    outline: none;
    color: var(--text);
    background: #0e1120;
    font: inherit;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.inline-fields input:focus,
.item-row input:focus,
.format-dropdown:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px #9275ff20;
}

.form-group input::placeholder,
.item-row input::placeholder {
    color: #6f7696;
}

.inline-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 13px;
}

.inline-fields .form-group {
    min-width: 0;
}

/* ITEMS */

#itemsContainer {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.item-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 75px 105px;
    gap: 9px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #101323;
}

.item-row input {
    padding: 11px 9px;
    font-size: 13px;
}

.btn-add-item {
    width: 100%;
    margin-top: 13px;
    padding: 13px;
    border: 1px dashed #7964ce;
    border-radius: 12px;
    color: var(--accent-light);
    background: #211d3a;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s ease;
}

.btn-add-item:hover {
    background: #302751;
    border-color: var(--accent);
}

/* EXPORT */

.download-box {
    padding: 19px;
    border: 1px solid #39305e;
    border-radius: 16px;
    background: linear-gradient(135deg, #211d3b, #171c31);
}

.download-box h3 {
    margin-top: 0;
}

.format-dropdown {
    margin-bottom: 12px;
}

.btn-download {
    width: 100%;
    padding: 14px 18px;
    border: none;
    border-radius: 12px;
    color: #fff;
    background: linear-gradient(110deg, #8062f4, #a16bfa);
    box-shadow: 0 7px 22px #9275ff30;
    font: inherit;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
}

.btn-download:hover {
    transform: translateY(-2px);
    filter: brightness(1.12);
}

/* INVOICE PREVIEW */

.invoice-preview-section {
    background:
        radial-gradient(ellipse at 50% 0%, #29254a 0%, transparent 55%),
        #111425;
}

.invoice-preview-section h2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.invoice-paper {
    width: 100%;
    max-width: 680px;
    min-height: 700px;
    margin: 0 auto;
    padding: clamp(22px, 4vw, 43px);
    overflow-wrap: anywhere;
    border: 1px solid #e0e2ee;
    border-radius: 5px;
    color: #20243a;
    background: #f9f9fd;
    box-shadow: 0 18px 50px #00000050;
}

.paper-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 15px;
    padding-bottom: 24px;
}

.paper-header h2,
.paper-header h3 {
    margin: 0;
    color: #24213f;
}

.paper-header h2 {
    font-size: clamp(24px, 3vw, 34px);
    font-weight: 800;
    letter-spacing: -1px;
}

.paper-badge {
    display: inline-block;
    padding: 7px 12px;
    border-radius: 7px;
    color: #6347d8;
    background: #e9e4ff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
}

.divider {
    height: 3px;
    margin: 0 0 26px;
    border: none;
    background: linear-gradient(90deg, #8667f5 0%, #c6b9ff 70%, #eeeaff 100%);
}

.paper-bill-to {
    margin-bottom: 25px;
}

.paper-bill-to h3 {
    margin: 0 0 12px;
    color: #756f94;
    font-size: 11px;
    letter-spacing: 1.3px;
    text-transform: uppercase;
}

.paper-bill-to p {
    margin: 6px 0;
    color: #30334a;
    font-size: 13px;
    line-height: 1.6;
}

.paper-table {
    width: 100%;
    margin: 0 0 24px;
    border-collapse: collapse;
    font-size: 12px;
}

.paper-table th {
    padding: 13px 10px;
    color: #fff;
    background: #292344;
    font-size: 10px;
    letter-spacing: 0.6px;
    text-align: left;
    text-transform: uppercase;
}

.paper-table td {
    padding: 13px 10px;
    border-bottom: 1px solid #e6e5f0;
    color: #38394e;
    line-height: 1.5;
}

.paper-table th:last-child,
.paper-table td:last-child {
    text-align: right;
}

.paper-summary {
    width: min(100%, 290px);
    margin-left: auto;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 9px 0;
    color: #66677f;
    font-size: 13px;
}

.total-line {
    margin-top: 8px;
    padding: 15px;
    border-radius: 10px;
    color: #fff;
    background: #292344;
    font-size: 15px;
    font-weight: 800;
}

.paper-footer {
    margin-top: 45px;
    padding-top: 17px;
    border-top: 1px solid #e4e2ef;
    color: #8a89a0;
    font-size: 11px;
    line-height: 1.7;
    text-align: center;
}

/* TABLET */

@media (max-width: 1050px) {
    .invoice-container {
        padding: 24px 20px 40px;
    }

    .invoice-workspace {
        grid-template-columns: 1fr;
    }

    .invoice-form-section,
    .invoice-preview-section {
        padding: 24px;
    }

    .invoice-paper {
        max-width: 720px;
    }
}

/* MOBILE */

@media (max-width: 600px) {
    .invoice-container {
        padding: 16px 12px 28px;
    }

    .invoice-header {
        margin-bottom: 18px;
        padding-bottom: 17px;
    }

    .header-left {
        gap: 12px;
    }

    .back-link {
        min-width: 38px;
        height: 38px;
        padding: 0 10px;
    }

    .invoice-header h1 {
        font-size: 22px;
        letter-spacing: -0.7px;
    }

    .invoice-workspace {
        gap: 17px;
    }

    .invoice-form-section,
    .invoice-preview-section {
        padding: 17px 13px;
        border-radius: 17px;
    }

    .invoice-form-section h2,
    .invoice-preview-section h2 {
        margin-bottom: 19px;
        font-size: 17px;
    }

    .inline-fields {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .item-row {
        grid-template-columns: minmax(0, 1fr) 58px 80px;
        gap: 6px;
        padding: 8px;
    }

    .item-row input {
        padding: 10px 6px;
        font-size: 12px;
    }

    .download-box {
        padding: 14px;
    }

    .invoice-paper {
        min-height: 0;
        padding: 19px 13px;
    }

    .paper-header {
        gap: 8px;
        padding-bottom: 18px;
    }

    .paper-header h2 {
        font-size: 25px;
    }

    .paper-badge {
        padding: 6px 8px;
        font-size: 9px;
    }

    .paper-table {
        font-size: 10px;
    }

    .paper-table th {
        padding: 10px 5px;
        font-size: 9px;
    }

    .paper-table td {
        padding: 10px 5px;
        font-size: 10px;
    }

    .paper-summary {
        width: 100%;
    }

    .paper-footer {
        margin-top: 30px;
    }
}

/* SMALL PHONES */

@media (max-width: 360px) {
    .invoice-container {
        padding-right: 8px;
        padding-left: 8px;
    }

    .invoice-form-section,
    .invoice-preview-section {
        padding: 13px 9px;
    }

    .item-row {
        grid-template-columns: minmax(0, 1fr) 48px 68px;
        gap: 4px;
    }

    .item-row input {
        padding: 9px 4px;
        font-size: 11px;
    }

    .invoice-paper {
        padding: 15px 9px;
    }
}
