/* ===============================================
   XRUN STUDIO — INVOICE SYSTEM
   Design Beyond Limits.
   =============================================== */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg: #080808;
    --bg-secondary: #111111;
    --surface: #181818;
    --card: #202020;
    --text: #ffffff;
    --text-muted: #b5b5b5;
    --border: rgba(255, 255, 255, 0.08);

    --grad: linear-gradient(120deg, #ff7a00 0%, #ff2d8e 35%, #7b3dff 68%, #009dff 100%);

    --heading-font: 'Space Grotesk', 'Inter', sans-serif;
    --body-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
    font-family: var(--body-font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    margin: 0;
    padding: 32px 24px;
    line-height: 1.6;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    position: relative;
    overflow-x: hidden;
}

/* faint decorative X in the background, brand-consistent, not overused */
body::before {
    content: "";
    position: fixed;
    top: -10%;
    right: -8%;
    width: 520px;
    height: 520px;
    background:
        linear-gradient(45deg, transparent 46%, rgba(255,255,255,0.035) 47%, rgba(255,255,255,0.035) 53%, transparent 54%),
        linear-gradient(-45deg, transparent 46%, rgba(255,255,255,0.035) 47%, rgba(255,255,255,0.035) 53%, transparent 54%);
    pointer-events: none;
    z-index: 0;
}

/* ========== Landing ========== */
.invoice-home {
    max-width: 440px;
    margin: 100px auto;
    text-align: center;
    background: var(--surface);
    padding: 56px 44px;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.6);
    position: relative;
    z-index: 1;
}

.brand-logo {
    height: 42px;
    margin-bottom: 28px;
}

.invoice-home h1 {
    font-family: var(--heading-font);
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 6px 0;
    letter-spacing: -0.01em;
}

.invoice-home p {
    color: var(--text-muted);
    margin-bottom: 32px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.invoice-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.invoice-links a {
    display: block;
    padding: 15px 24px;
    background: var(--grad);
    color: #ffffff;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    transition: opacity 0.25s ease, transform 0.2s ease;
    background-size: 200% 200%;
    background-position: 0% 50%;
}

.invoice-links a:hover {
    opacity: 0.92;
    transform: translateY(-2px);
    background-position: 100% 50%;
}

.invoice-links a:last-child {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.invoice-links a:last-child:hover {
    background: rgba(255, 255, 255, 0.04);
    transform: none;
}

/* ========== Login Page ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    z-index: 1;
}

.login-box {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    padding: 44px 40px;
    border-radius: 16px;
    box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border);
    text-align: center;
}

.login-box .brand-logo {
    height: 40px;
    margin-bottom: 24px;
}

.login-box h1 {
    font-family: var(--heading-font);
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 4px 0;
}

.login-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 32px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
}

.login-form { text-align: left; }

.login-form .field { margin-bottom: 18px; }

.login-form .field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.login-form input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--card);
    color: var(--text);
}

.login-form input::placeholder { color: #6b6b6b; }

.login-form input:focus {
    outline: none;
    border-color: #7b3dff;
}

.login-error {
    color: #ff4d6d;
    font-size: 12px;
    margin-bottom: 12px;
    min-height: 18px;
}

.btn-login {
    width: 100%;
    padding: 13px;
    background: var(--grad);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    background-size: 200% 200%;
    transition: opacity 0.25s ease, background-position 0.4s ease;
}

.btn-login:hover { opacity: 0.92; background-position: 100% 50%; }

/* ========== Invoice Page ========== */
.invoice-page {
    max-width: 880px;
    margin: 0 auto;
    background: var(--surface);
    padding: 44px 56px;
    box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.6);
    border-radius: 16px;
    border: 1px solid var(--border);
    position: relative;
    z-index: 1;
    color: var(--text);
}

.invoice-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.invoice-actions .btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s, transform 0.15s;
    font-family: inherit;
}

.invoice-actions .btn:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

.btn-print { background: var(--grad); color: #ffffff; background-size: 200% 200%; }
.btn-print:hover { background-position: 100% 50%; }
.btn-back { background: var(--card); color: var(--text); border: 1px solid var(--border); }

/* ========== Invoice Header ========== */
.company-name-top {
    font-family: var(--heading-font);
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
    letter-spacing: 0.1em;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.invoice-type {
    font-family: var(--heading-font);
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
    letter-spacing: -0.01em;
}

.invoice-logo {
    max-height: 52px;
    width: auto;
    object-fit: contain;
}

.header-line {
    height: 2px;
    background: var(--grad);
    margin: 16px 0 24px 0;
    border-radius: 2px;
}

/* ========== Invoice Body ========== */
.invoice-body-purchase {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 20px;
}

.invoice-body-purchase .invoice-block { min-width: 0; }

.company-info {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.7;
}

.invoice-meta-inline {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.invoice-meta-inline span {
    display: flex;
    align-items: center;
    gap: 8px;
}

.meta-input-inline {
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 2px 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    min-width: 140px;
    background: transparent;
    font-family: inherit;
}

.meta-input-inline:focus {
    outline: none;
    border-bottom-color: #7b3dff;
}

/* ========== Invoice Block ========== */
.invoice-block h3 {
    font-family: var(--heading-font);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #ff2d8e;
    margin: 0 0 10px 0;
}

.invoice-block input,
.invoice-block textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    background: var(--card);
    color: var(--text);
}

.invoice-block input::placeholder,
.invoice-block textarea::placeholder { color: #6b6b6b; }

.invoice-block input:focus,
.invoice-block textarea:focus {
    outline: none;
    border-color: #7b3dff;
}

.invoice-block label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.invoice-block .field { margin-bottom: 8px; }
.invoice-block .field:last-child { margin-bottom: 0; }

/* ========== Table ========== */
.invoice-table-wrap {
    overflow-x: auto;
    margin-bottom: 20px;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.invoice-table th,
.invoice-table td {
    padding: 10px 12px;
    border: 1px solid var(--border);
    text-align: left;
}

.invoice-table thead th {
    background: var(--card);
    color: var(--text);
    font-family: var(--heading-font);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.invoice-table tbody tr { background: transparent; }
.invoice-table tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.02); }

.invoice-table input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
    background: var(--card);
    color: var(--text);
}

.invoice-table input::placeholder { color: #6b6b6b; }

.invoice-table input:focus {
    outline: none;
    border-color: #7b3dff;
}

.invoice-table .col-desc { min-width: 180px; }
.invoice-table .col-price { width: 110px; text-align: right; }
.invoice-table .col-qty { width: 70px; text-align: center; }
.invoice-table .col-amount { width: 110px; text-align: right; font-weight: 600; }

/* ========== Totals ========== */
.totals-table {
    width: 100%;
    max-width: 300px;
    margin-left: auto;
    margin-bottom: 24px;
    border-collapse: collapse;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.totals-table td {
    padding: 8px 12px;
    border: 1px solid var(--border);
}

.totals-table td:first-child { font-weight: 600; color: var(--text-muted); }
.totals-table td:last-child { text-align: right; }

.totals-table .total-row td {
    font-family: var(--heading-font);
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    background: var(--card);
}

.totals-table input[type="number"] {
    width: 70px;
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    text-align: right;
    font-family: inherit;
    background: var(--card);
    color: var(--text);
}

/* ========== Footer / Contact / Seal ========== */
.invoice-footer {
    margin-top: 36px;
    padding-top: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.invoice-footer.no-border { border-top: none; }

.footer-contact {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.8;
}

.footer-contact strong { color: var(--text); }

.invoice-seal { text-align: center; }

.invoice-seal img {
    max-width: 150px;
    width: 100%;
    height: auto;
    opacity: 0.95;
}

/* ===============================================
   PRINT — A4 Clean Layout (light, ink-friendly)
   =============================================== */
@media print {
    @page {
        size: A4;
        margin: 14mm;
    }

    html { font-size: 11px; }

    :root {
        --text: #1e1e1e;
        --text-muted: #555555;
        --border: #cccccc;
        --card: #ffffff;
        --surface: #ffffff;
    }

    body {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body::before { display: none !important; }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .invoice-page {
        max-width: none !important;
        width: 100% !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        background: #fff !important;
        color: #1e1e1e !important;
    }

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

    .company-name-top { font-size: 12px; color: #1e1e1e; }

    .invoice-type {
        font-size: 16px;
        color: #000;
    }

    .invoice-logo { max-height: 44px; }

    .header-line {
        background: #000 !important;
        margin: 10px 0 14px 0;
    }

    .company-info {
        font-size: 10px;
        color: #333;
    }

    .invoice-meta-inline {
        font-size: 10px;
        color: #333;
    }

    .meta-input-inline {
        border: none !important;
        border-bottom: none !important;
        padding: 0 !important;
        background: transparent !important;
        color: #1e1e1e !important;
        font-size: 10px;
    }

    .invoice-body-purchase {
        gap: 16px;
        margin-bottom: 14px;
    }

    .invoice-block h3 { font-size: 9px; color: #000 !important; }

    .invoice-block input,
    .invoice-block textarea {
        border: none !important;
        padding: 0 !important;
        background: transparent !important;
        color: #1e1e1e !important;
        font-size: 10px;
    }

    .invoice-block .field { margin-bottom: 4px; }

    .invoice-table {
        font-size: 10px;
        border: 1px solid #000 !important;
        margin-bottom: 10px;
    }

    .invoice-table th,
    .invoice-table td {
        padding: 5px 8px;
        border: 1px solid #666 !important;
        color: #1e1e1e !important;
    }

    .invoice-table thead th {
        font-size: 9px;
        background: #222 !important;
        color: #fff !important;
    }

    .invoice-table tbody tr:nth-child(even) {
        background: #f5f5f5 !important;
    }

    .invoice-table input {
        border: none !important;
        padding: 0 !important;
        background: transparent !important;
        color: #1e1e1e !important;
        font-size: 10px;
    }

    .totals-table {
        margin-bottom: 14px;
        border: 1px solid #000 !important;
    }

    .totals-table td {
        font-size: 10px;
        padding: 4px 8px;
        border: 1px solid #000 !important;
        color: #1e1e1e !important;
    }

    .totals-table .total-row td {
        font-size: 11px;
        background: #eee !important;
        color: #000 !important;
    }

    .totals-table input[type="number"] {
        border: none !important;
        background: transparent !important;
        color: #1e1e1e !important;
    }

    .invoice-footer { margin-top: 18px; padding-top: 0; }

    .footer-contact { color: #333 !important; font-size: 9px; }
    .footer-contact strong { color: #000 !important; }

    .invoice-seal img {
        max-width: 200px !important;
        width: 200px !important;
    }
}
