:root {
    --bg-app: #0b1220;
    --bg-panel: #111827;
    --bg-panel-soft: #1f2937;
    --bg-input: #0f172a;
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --text-dark: #111827;
    --border-color: #334155;
    --border-light: #e5e7eb;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: rgba(37, 99, 235, 0.12);
    --success: #10b981;
    --danger: #ef4444;

    --paper-bg: #ffffff;
    --paper-text: #374151;
    --paper-accent: #111827;
    --paper-muted: #6b7280;
    --paper-border: #e5e7eb;
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.18);
    --radius: 16px;
    --radius-sm: 10px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.15), transparent 25%),
        radial-gradient(circle at top right, rgba(16, 185, 129, 0.08), transparent 20%),
        linear-gradient(180deg, #0b1220 0%, #111827 100%);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Main layout */
.app-container {
    display: flex;
    align-items: flex-start;
    gap: 0;
    min-height: 100vh;
}

/* ---------------- Editor Panel ---------------- */
.editor-panel {
    /* width: 410px; */
    width: 35%;
    max-width: 100%;
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(14px);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.3);
    z-index: 20;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.editor-panel h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    padding: 1.5rem 1.5rem 1rem;
    color: #ffffff;
}

#invoiceForm {
    padding: 0 1.5rem 1.5rem;
    flex: 1;
}

.form-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
}

.form-section h2 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-weight: 700;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
}

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

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 0.88rem;
    margin-bottom: 0.45rem;
    color: #d1d5db;
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.8rem 0.9rem;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.92rem;
    transition: all 0.2s ease;
}

textarea {
    resize: vertical;
    min-height: 90px;
}

input::placeholder,
textarea::placeholder {
    color: #94a3b8;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #111c30;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 0.4rem;
    display: inline-block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.item-row {
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 1rem;
    border-radius: 14px;
    margin-bottom: 1rem;
    position: relative;
    animation: slideIn 0.22s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.item-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.btn-remove {
    background: transparent;
    border: none;
    color: #fca5a5;
    cursor: pointer;
    font-size: 0.88rem;
    padding: 0.25rem;
    transition: all 0.2s ease;
}

.btn-remove:hover {
    color: #ef4444;
    text-decoration: underline;
}

.btn-secondary,
.btn-primary {
    border-radius: 12px;
    padding: 0.8rem 1rem;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #dbeafe;
}

.btn-secondary:hover {
    background: rgba(37, 99, 235, 0.12);
    border-color: rgba(37, 99, 235, 0.35);
}

.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    border: none;
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.28);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 30px rgba(37, 99, 235, 0.35);
}

.btn-primary:active,
.btn-secondary:active {
    transform: scale(0.99);
}

.editor-footer {
    padding: 1.2rem 1.5rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    background: rgba(17, 24, 39, 0.98);
    position: sticky;
    bottom: 0;
    backdrop-filter: blur(10px);
}

.footer-buttons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
    margin-bottom: 0.65rem;
}

/* ---------------- Preview Panel ---------------- */
.preview-panel {
    flex: 1;
    min-width: 0;
    padding: 2rem;
    overflow-y: auto;
    display: block;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0)),
        #1f2937;
}

.preview-wrapper {
    width: 210mm;
    min-height: 297mm;
    max-width: 100%;
    background: white;
    box-shadow: var(--shadow-lg);
    border-radius: 18px;
    margin: 0 auto 2rem auto;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.15);
}

.invoice-paper {
    padding: 15mm;
    color: var(--paper-text);
    font-size: 10pt;
    line-height: 1.5;
    position: relative;
    min-height: 100%;
    height: auto;
    display: flex;
    flex-direction: column;
    font-family: 'Inter', sans-serif;
    background: var(--paper-bg);
}

.header-bar {
    width: 100%;
    height: 10px;
    background: linear-gradient(90deg, #2563eb, #60a5fa);
    margin-bottom: 18px;
    border-radius: 999px;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 38px;
    margin-top: 8px;
}

.logo {
    max-width: 200px;
    max-height: 80px;
    object-fit: contain;
}

.text-logo {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.6rem;
    color: var(--paper-accent);
    text-align: left;
    line-height: 1.2;
    margin-bottom: 10px;
}

.header-right {
    text-align: right;
    width: 60%;
}

.header-date {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--paper-accent);
    margin-bottom: 0.35rem;
}

.header-note {
    color: var(--paper-muted);
    font-size: 0.92rem;
}

/* Generic invoice blocks */
.invoice-paper table {
    width: 100%;
    border-collapse: collapse;
}

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

.invoice-paper th {
    font-weight: 700;
    color: var(--paper-accent);
    background: #f8fafc;
}

.invoice-paper h2,
.invoice-paper h3,
.invoice-paper h4 {
    color: var(--paper-accent);
}

.invoice-paper p,
.invoice-paper li,
.invoice-paper div,
.invoice-paper span {
    word-break: break-word;
}

/* ---------------- SEO / Content Section ---------------- */
.wordContent {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto 4rem;
    padding: 3rem 1.5rem;
    clear: both;
    color: #e5e7eb;
}

.wordContent .content-box {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 22px;
    padding: 2rem;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
}

.wordContent h1,
.wordContent h2,
.wordContent h3 {
    font-family: 'Outfit', sans-serif;
    color: #ffffff;
    margin-bottom: 0.9rem;
    line-height: 1.2;
}

.wordContent h2 {
    font-size: 1.9rem;
    margin-top: 1rem;
}

.wordContent h3 {
    font-size: 1.2rem;
    margin-top: 1.5rem;
}

.wordContent p {
    color: #d1d5db;
    line-height: 1.8;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.wordContent ul,
.wordContent ol {
    margin: 1rem 0 1.25rem 1.5rem;
    color: #d1d5db;
}

.wordContent li {
    margin-bottom: 0.65rem;
    line-height: 1.7;
}

.wordContent a {
    color: #93c5fd;
    text-decoration: none;
}

.wordContent a:hover {
    text-decoration: underline;
}

/* ---------------- Utility ---------------- */
img {
    max-width: 100%;
    display: block;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 1200px) {
    .preview-wrapper {
        width: 100%;
    }
}

@media (max-width: 992px) {
    .app-container {
        flex-direction: column;
    }

    .editor-panel {
        position: relative;
        width: 100%;
        height: auto;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.08);
    }

    .preview-panel {
        width: 100%;
        padding: 1rem;
    }

    .preview-wrapper {
        width: 100%;
        border-radius: 14px;
    }

    .wordContent {
        padding: 2rem 1rem 3rem;
    }
}

@media (max-width: 640px) {
    .editor-panel h1 {
        font-size: 1.35rem;
    }

    #invoiceForm {
        padding: 0 1rem 1rem;
    }

    .editor-footer {
        padding: 1rem;
    }

    .form-grid,
    .footer-buttons-grid {
        grid-template-columns: 1fr;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
    }

    .preview-panel {
        padding: 0.75rem;
    }

    .invoice-paper {
        padding: 8mm;
        font-size: 9pt;
    }

    .header-date {
        font-size: 1.15rem;
    }

    .wordContent .content-box {
        padding: 1.25rem;
        border-radius: 16px;
    }

    .wordContent h2 {
        font-size: 1.45rem;
    }
}