:root {
    --primary-color: #1a1a1a;
    --secondary-color: #6b7280;
    --bg-color: #f3f4f6;
    --card-bg: rgba(255, 255, 255, 0.9);
    --border-color: #e5e7eb;
    --accent-color: #2563eb;
    --font-family: 'Inter', -apple-system, sans-serif;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--primary-color);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Layout */
.sidebar {
    width: 420px;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--border-color);
    padding: 2.5rem;
    overflow-y: auto;
    z-index: 10;
}

.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    background: radial-gradient(circle at top left, #e5e7eb, #d1d5db);
}

/* Form Styles */
h2 {
    margin-bottom: 2rem;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.form-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.form-section h3 {
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: #4b5563;
    margin-bottom: 0.4rem;
}

input,
textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: #fff;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1.2fr auto;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    align-items: center;
}

.btn {
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    width: 100%;
    margin-top: 1rem;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    background-color: #000;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #fff;
    border: 1px solid var(--border-color);
    color: var(--primary-color);
    width: 100%;
}

.btn-secondary:hover {
    background-color: #f9fafb;
}

.btn-danger {
    padding: 0.5rem;
    color: #ef4444;
    background: transparent;
}

.btn-danger:hover {
    color: #b91c1c;
    background: #fee2e2;
}

/* Preview Styles (A4 Paper) */
.preview-container {
    width: 210mm;
    min-height: 297mm;
    background: white;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 25mm;
    position: relative;
    color: #111;
    transform: scale(0.9);
    transform-origin: top center;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 5rem;
    padding-bottom: 2rem;
    border-bottom: 2px solid #000;
}

.company-info {
    position: relative;
    padding-left: 1.5rem;
}

.company-info::before {
    content: '';
    position: absolute;
    left: 0;
    top: 5px;
    bottom: 5px;
    width: 4px;
    background: #000;
}

.company-info h1 {
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: -0.05em;
    line-height: 1.1;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
}

.company-info p {
    color: var(--secondary-color);
    font-size: 1rem;
    margin-bottom: 0.2rem;
    font-weight: 500;
}

.invoice-meta {
    text-align: right;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.invoice-meta h2 {
    font-size: 6rem;
    font-weight: 900;
    color: #000;
    margin: 0;
    line-height: 0.75;
    text-transform: uppercase;
    letter-spacing: -0.05em;
    position: absolute;
    right: 5mm;
    top: 5mm;
    z-index: 0;
    opacity: 0.05;
    /* Much lighter, purely decorative */
    pointer-events: none;
    white-space: nowrap;
}

.meta-details {
    position: relative;
    z-index: 2;
    padding-left: 1rem;
}

.meta-details p {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #1a1a1a;
}

.meta-details p span {
    font-weight: 400;
    color: var(--secondary-color);
    margin-left: 0.5rem;
}

.client-section {
    margin-bottom: 4rem;
}

.client-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--secondary-color);
    margin-bottom: 0.75rem;
    letter-spacing: 0.1em;
    font-weight: 700;
}

.client-info b {
    font-size: 1.25rem;
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 800;
}

.client-info p {
    font-size: 1rem;
    color: #374151;
    line-height: 1.5;
}

/* Table Styles */
.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 3rem;
}

.items-table th {
    background-color: #000;
    color: #fff;
    text-align: left;
    padding: 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.items-table td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid #f3f4f6;
    font-size: 1rem;
    transition: background 0.2s;
}

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

.total-section {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 5rem;
}

.total-box {
    width: 380px;
    border-top: 3px solid #000;
    padding-top: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.total-box strong {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
    margin-right: 1rem;
}

.total-box span {
    font-weight: 900;
    font-size: 1.85rem;
    letter-spacing: -0.025em;
    white-space: nowrap;
}

.footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding-top: 2rem;
    border-top: 1px solid #f3f4f6;
}

.payment-info h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--secondary-color);
}

.payment-info p {
    font-size: 0.9rem;
    margin-bottom: 0.35rem;
    color: #374151;
}

.qr-container {
    text-align: right;
}

.qr-code {
    width: 100px;
    height: 100px;
    background: #fff;
    padding: 5px;
    border: 1px solid #eee;
    margin-bottom: 0.5rem;
}

.qr-label {
    font-size: 0.65rem;
    color: var(--secondary-color);
    text-transform: uppercase;
    font-weight: 700;
}

/* Print Overrides */
@media print {
    @page {
        size: A4;
        margin: 15mm;
    }

    body {
        background: #fff;
        display: block;
        height: auto;
        overflow: visible;
    }

    .sidebar,
    .btn-primary {
        display: none !important;
    }

    .main-content {
        padding: 0;
        margin: 0;
        background: none;
        display: block;
        overflow: visible;
    }

    .preview-container {
        box-shadow: none;
        width: 100%;
        min-height: auto;
        padding: 0;
        margin: 0;
        transform: none;
        position: relative;
    }

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

    .invoice-meta h2 {
        opacity: 0.08 !important;
        /* Slightly visible in print */
        top: 0;
        right: 0;
    }
}