/*
 * InvoiceForge (invoice generator): the tool's own components, styled in the site's design language (6 Oct 2026, on
 * the UltraCompress Pro template, after Bill Generator). Base: /libs/site-pages.css (tokens, Inter and Space Grotesk,
 * buttons, theme toggle, focus rings) and /libs/shared-nav.css (the site's header and footer). This file holds only
 * what the tool itself needs: the toolbar, the invoice form and the live preview side by side, the line-item table,
 * the logo drop zone, the windows (history, clients, business profiles, shortcuts) and the toasts. Light is the
 * default; dark applies when <html> has no data-theme. Every class and id the script touches keeps its name, and the
 * variable names the script's markup uses (--text-muted, --spacing-lg, --success-color ...) are aliases of the site's
 * tokens below.
 *
 * The invoice document itself (.invoice-preview with its four templates) keeps fixed paper colours on purpose: it is
 * the page the PDF is made from and must look the same in both page themes.
 */

/* ----- Tokens the tool adds, and the aliases the original rules use ----- */
:root {
    --surface: #ffffff;                 /* cards are true white in the light theme */
    --surface-2: #f3f4f8;               /* a quiet inset inside a card */
    --ring: rgba(139, 92, 246, 0.18);
    --app-max: 1600px;
    --success-color: #059669;
    --danger-color: #dc2626;
    --warning-color: #d97706;
    --primary-color: var(--brand);
    --text-muted: var(--text-3);
    --text-secondary: var(--text-2);
    --border-color: var(--surface-border);
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}
:root:not([data-theme="light"]) {
    --surface: #14141f;
    --surface-2: rgba(255, 255, 255, 0.05);
    --success-color: #4ade80;
    --danger-color: #f87171;
    --warning-color: #fbbf24;
}

/* ----- Page: full width, the page provides the side space ----- */
.container.app-container {
    max-width: calc(var(--app-max) + 2 * var(--content-gutter));
    margin-top: 16px;
}
@media (min-width: 640px) { .container.app-container { margin-top: 24px; } }

/* ----- Tools back link above the header, as on every other tool: the bar scrolls away under the sticky header ----- */
body { padding-top: 0; }
.back-bar { height: 48px; display: flex; align-items: center; padding: 0 var(--zdu-gutter, 24px); }
body > header { position: sticky; top: 0; z-index: 50; }
header .site-nav { position: relative; top: auto; }
.theme-toggle { top: calc(90px + var(--bar-offset, 48px)); }
@media (max-width: 768px) { .theme-toggle { top: calc(75px + var(--bar-offset, 48px)); } }

/* ----- Hero: brand row, headline, tagline ----- */
.app-hero { margin: 0 0 2rem; text-align: center; }
.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.25rem;
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-strong);
}
.app-brand img { width: 44px; height: 44px; border-radius: 12px; display: block; }
.app-hero h1 { margin-bottom: 0.75rem; }
.app-tagline { color: var(--text-2); font-size: 1.125rem; line-height: 1.6; max-width: 46rem; margin: 0 auto; }

/* ----- Buttons: the site's pills in the tool's sizes (.btn is the class the script writes) ----- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.2;
    padding: 12px 24px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-primary { background: var(--gradient-brand); color: #fff; box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text-strong); border: 1px solid var(--surface-border); padding: 11px 23px; }
.btn-secondary:hover:not(:disabled) { border-color: var(--brand); color: var(--link); transform: translateY(-2px); }
.btn-success { background: linear-gradient(135deg, #059669, #10b981); color: #fff; box-shadow: 0 4px 15px rgba(5, 150, 105, 0.3); }
.btn-success:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(5, 150, 105, 0.4); }
.btn-danger { background: var(--danger-strong); color: #fff; box-shadow: 0 4px 15px rgba(185, 28, 28, 0.25); }
.btn-danger:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(185, 28, 28, 0.35); }
.btn-sm { font-size: 0.85rem; padding: 9px 16px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-secondary.btn-sm { padding: 8px 15px; }

/* ----- The app: the toolbar above the two panels ----- */
.app-shell { margin: 0 0 3rem; scroll-margin-top: 90px; }
.app-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin: 0 0 1.25rem; }
.template-pick { display: inline-flex; align-items: center; gap: 10px; font-size: 0.9rem; font-weight: 600; color: var(--text-2); }
.template-pick .form-select { width: auto; min-width: 190px; }
.app-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ----- The two panels: the form and the live preview ----- */
.main-content { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.panel {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--surface-shadow);
    overflow: hidden;
}
.panel-header { padding: 14px 20px; border-bottom: 1px solid var(--surface-border); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-title { margin: 0; font-size: 1.05rem; font-weight: 700; }
.panel-body { padding: 20px; }
.preview-panel { position: sticky; top: 100px; max-height: calc(100vh - 120px); display: flex; flex-direction: column; }
.preview-panel .panel-body { flex: 1; overflow-y: auto; background: var(--surface-2); display: flex; justify-content: center; align-items: flex-start; }
.preview-note { font-size: 0.8125rem; color: var(--text-3); }
.flex { display: flex; }
.gap-sm { gap: 8px; }
.mb-md { margin-bottom: 1rem; }

/* Form sections */
.form-section { margin-bottom: 1.75rem; padding-bottom: 1.75rem; border-bottom: 1px solid var(--surface-border); }
.form-section:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.section-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 1rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
}
.section-title > svg { width: 18px; height: 18px; color: var(--link); flex-shrink: 0; }
.section-title .section-actions { margin-left: auto; display: flex; gap: 6px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.form-row:last-child { margin-bottom: 0; }
.form-row.single { grid-template-columns: 1fr; }
.form-row.triple { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-label { font-size: 0.85rem; font-weight: 600; color: var(--text-strong); }
.form-hint { font-size: 0.78rem; color: var(--text-3); }
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--field);
    border: 1px solid var(--field-border);
    border-radius: 12px;
    font-size: 0.925rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--placeholder); }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.form-input:disabled { opacity: 0.55; cursor: not-allowed; }
.form-textarea { resize: vertical; min-height: 76px; }
.form-select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b93a1' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
.form-select option { color: #0a0a14; background: #fff; }
.form-input[type="date"] { color-scheme: light; }
:root:not([data-theme="light"]) .form-input[type="date"] { color-scheme: dark; }
.custom-terms-input { margin-top: 6px; }

/* Logo drop zone: the site's drop zone in miniature (tint, lift, the icon grows) */
.file-upload {
    border: 2px dashed rgba(139, 92, 246, 0.45);
    border-radius: 14px;
    padding: 18px 16px;
    text-align: center;
    cursor: pointer;
    background: var(--surface-2);
    transition: border-color 0.25s ease, background 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}
.file-upload:hover, .file-upload.dragover { border-color: var(--brand); background: var(--tint-brand); transform: translateY(-2px); box-shadow: var(--surface-hover-shadow); }
.file-upload-icon {
    width: 48px;
    height: 48px;
    padding: 12px;
    margin: 0 auto 8px;
    border-radius: 50%;
    background: var(--gradient-brand);
    color: #fff;
    display: block;
    transition: transform 0.25s ease;
}
.file-upload:hover .file-upload-icon, .file-upload.dragover .file-upload-icon { transform: scale(1.1); }
.file-upload-text { font-size: 0.9rem; color: var(--text-2); margin: 0; }
.file-upload-text span { color: var(--link); font-weight: 600; }
.file-upload input { display: none; }
.logo-preview-container { display: flex; align-items: center; gap: 12px; }
.logo-preview-img { max-width: 120px; max-height: 56px; object-fit: contain; border-radius: 8px; background: #fff; padding: 4px; border: 1px solid var(--surface-border); }

/* Line items (a table in the form) */
.line-items-container { border: 1px solid var(--surface-border); border-radius: 12px; overflow: hidden; }
.line-items-table { width: 100%; border-collapse: collapse; margin: 0; background: none; border-radius: 0; }
.line-items-table th {
    text-align: left;
    padding: 10px 10px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
    background: var(--surface-2);
    border: 0;
    border-bottom: 1px solid var(--surface-border);
}
.line-items-table td { padding: 6px 6px; border: 0; border-bottom: 1px solid var(--surface-border); vertical-align: middle; }
.line-items-table tr:last-child td { border-bottom: none; }
.line-items-table .col-desc { width: 40%; }
.line-items-table .col-qty { width: 14%; }
.line-items-table .col-rate { width: 20%; }
.line-items-table .col-amount { width: 18%; text-align: right; }
.line-items-table .col-actions { width: 8%; text-align: center; }
.line-item-input {
    width: 100%;
    padding: 8px 10px;
    background: var(--field);
    border: 1px solid var(--field-border);
    border-radius: 10px;
    font-size: 0.875rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.line-item-input::placeholder { color: var(--placeholder); }
.line-item-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.line-item-amount { font-weight: 700; color: var(--text-strong); text-align: right; font-size: 0.9rem; overflow-wrap: anywhere; padding-right: 10px; }
.delete-line-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(185, 28, 28, 0.3);
    background: rgba(185, 28, 28, 0.08);
    color: var(--danger);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease;
}
.delete-line-btn svg { width: 16px; height: 16px; }
.delete-line-btn:hover { background: var(--danger-strong); color: #fff; }
.add-line-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px;
    margin-top: 10px;
    border: 2px dashed rgba(139, 92, 246, 0.45);
    border-radius: 12px;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}
.add-line-btn:hover { border-color: var(--brand); color: var(--link); background: var(--tint-brand); }

/* ===== The invoice document: fixed colours, the same in both page themes (this is the PDF) ===== */
.invoice-preview {
    --invoice-accent: #2563eb;
    --paper-text: #1e293b;
    --paper-muted: #64748b;
    --paper-faint: #64748b;
    --paper-line: #e2e8f0;
    --paper-inset: #f8fafc;
    width: 100%;
    max-width: 640px;
    min-height: 760px;
    background: #ffffff;
    color: var(--paper-text);
    border-radius: 10px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.12), 0 10px 10px -5px rgba(0, 0, 0, 0.05);
    padding: 2.5rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
}
.invoice-preview h1, .invoice-preview h4, .invoice-preview div.invoice-title { font-family: inherit; color: inherit; }
.invoice-header { display: flex; justify-content: space-between; gap: 1.5rem; margin-bottom: 2.25rem; padding-bottom: 1.5rem; border-bottom: 3px solid var(--invoice-accent); }
.invoice-brand { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }
.invoice-logo { max-width: 150px; max-height: 60px; object-fit: contain; }
.invoice-logo-placeholder { width: 60px; height: 60px; background: var(--invoice-accent); border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 1.5rem; }
.invoice-company-name { font-size: 1.5rem; font-weight: 700; color: var(--invoice-accent); overflow-wrap: anywhere; }
.invoice-company-details { font-size: 0.875rem; color: var(--paper-muted); line-height: 1.6; overflow-wrap: anywhere; }
.invoice-title-section { text-align: right; flex-shrink: 0; }
.invoice-title { font-size: 2.5rem; font-weight: 800; color: var(--invoice-accent); text-transform: uppercase; letter-spacing: 2px; line-height: 1.1; margin: 0; }
.invoice-number { font-size: 1rem; color: var(--paper-muted); margin-top: 0.5rem; }
.invoice-info-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 1.25rem; margin-bottom: 2.25rem; }
.invoice-info-block h4 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; color: var(--paper-faint); margin: 0 0 0.5rem; font-weight: 600; }
.invoice-info-block p { font-size: 0.9375rem; color: var(--paper-text); line-height: 1.6; margin: 0; overflow-wrap: anywhere; }
.invoice-info-block strong { font-weight: 600; color: var(--paper-text); }
.amount-due { font-size: 1.3rem !important; font-weight: 700; line-height: 1.3 !important; color: var(--invoice-accent) !important; white-space: nowrap; }
.currency-conversion { font-size: 0.8125rem !important; color: var(--paper-faint) !important; margin-top: 0.25rem !important; }
.invoice-items-table { width: 100%; border-collapse: collapse; margin: 0 0 2rem; background: none; border-radius: 0; }
.invoice-items-table th { text-align: left; padding: 0.75rem 1rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; color: #fff; background: var(--invoice-accent); border: 0; font-weight: 600; }
.invoice-items-table th:last-child { text-align: right; }
.invoice-items-table td { padding: 0.85rem 1rem; border: 0; border-bottom: 1px solid var(--paper-line); font-size: 0.9375rem; color: var(--paper-text); overflow-wrap: anywhere; }
.invoice-items-table td:last-child { text-align: right; font-weight: 500; }
.invoice-items-table tbody tr:nth-child(even) td { background: var(--paper-inset); }
.invoice-totals { display: flex; justify-content: flex-end; margin-bottom: 2rem; }
.totals-table { width: 300px; max-width: 100%; }
.totals-row { display: flex; justify-content: space-between; gap: 12px; padding: 0.5rem 0; border-bottom: 1px solid var(--paper-line); font-size: 0.9375rem; color: var(--paper-muted); }
.totals-row.discount { color: #059669; }
.totals-row.total { font-size: 1.25rem; font-weight: 700; color: var(--invoice-accent); border-bottom: none; border-top: 2px solid var(--invoice-accent); padding-top: 0.75rem; margin-top: 0.5rem; }
.totals-label { font-weight: 500; }
.totals-value { font-weight: 600; }
.invoice-notes { padding: 1.25rem; background: var(--paper-inset); border-radius: 8px; margin-bottom: 1.5rem; }
.invoice-notes h4 { font-size: 0.875rem; font-weight: 600; color: var(--paper-text); margin: 0 0 0.5rem; }
.invoice-notes p { font-size: 0.875rem; color: var(--paper-muted); white-space: pre-wrap; margin: 0; overflow-wrap: anywhere; }
.invoice-footer { text-align: center; padding-top: 1.5rem; border-top: 1px solid var(--paper-line); }
.invoice-footer p { font-size: 0.875rem; color: var(--paper-faint); margin: 0; }
/* The four templates: an accent each, and a header treatment of its own */
.invoice-preview.template-modern { --invoice-accent: #2563eb; }
.invoice-preview.template-classic { --invoice-accent: #1e293b; }
.invoice-preview.template-classic .invoice-header { border-bottom: 1px solid #1e293b; box-shadow: 0 4px 0 -2px #1e293b; }
.invoice-preview.template-classic .invoice-title, .invoice-preview.template-classic .invoice-company-name { font-family: Georgia, 'Times New Roman', serif; letter-spacing: 1px; }
.invoice-preview.template-classic .invoice-items-table th { background: #f1f5f9; color: #1e293b; border-bottom: 2px solid #1e293b; }
.invoice-preview.template-minimal { --invoice-accent: #64748b; }
.invoice-preview.template-minimal .invoice-header { border-bottom: 1px solid var(--paper-line); }
.invoice-preview.template-minimal .invoice-title { font-weight: 300; letter-spacing: 6px; }
.invoice-preview.template-minimal .invoice-items-table th { background: none; color: var(--paper-faint); border-bottom: 1px solid var(--paper-line); }
.invoice-preview.template-minimal .invoice-items-table tbody tr:nth-child(even) td { background: none; }
.invoice-preview.template-minimal .invoice-logo-placeholder { border-radius: 50%; }
.invoice-preview.template-bold { --invoice-accent: #7c3aed; }
.invoice-preview.template-bold .invoice-header { background: var(--invoice-accent); color: #fff; margin: -2.5rem -2.5rem 2.25rem; padding: 2.5rem; border-bottom: 0; }
.invoice-preview.template-bold .invoice-company-name, .invoice-preview.template-bold .invoice-title { color: #fff; }
.invoice-preview.template-bold .invoice-company-details, .invoice-preview.template-bold .invoice-number { color: rgba(255, 255, 255, 0.85); }
.invoice-preview.template-bold .invoice-logo-placeholder { background: #fff; color: var(--invoice-accent); }

/* ----- Windows (history, clients, business profiles, shortcuts) ----- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 20, 0.6);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(12px);
    transition: transform 0.25s ease;
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header { padding: 18px 20px; border-bottom: 1px solid var(--surface-border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-title { margin: 0; font-size: 1.15rem; }
.modal-close {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1px solid var(--chip-border);
    background: var(--chip);
    color: var(--text-strong);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease, color 0.2s ease;
}
.modal-close svg { width: 18px; height: 18px; }
.modal-close:hover { border-color: var(--brand); color: var(--link); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--surface-border); display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }

/* Saved lists inside the windows */
.saved-list { list-style: none; margin: 0; padding: 0; }
.saved-list > li { color: var(--text-3); }
.saved-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--surface-border);
    border-radius: 12px;
    margin-bottom: 8px;
    background: var(--surface-2);
    transition: border-color 0.2s ease, transform 0.2s ease;
}
.saved-item:hover { border-color: var(--brand); transform: translateY(-2px); }
.saved-item-info { flex: 1; min-width: 0; }
.saved-item-name { font-weight: 600; color: var(--text-strong); overflow-wrap: anywhere; }
.saved-item-details { font-size: 0.8125rem; color: var(--text-3); overflow-wrap: anywhere; }
.saved-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.saved-item-actions .btn-sm { padding: 7px 14px; }
.saved-item-actions .btn-danger.btn-sm { padding: 7px 10px; }

/* Shortcuts window */
.shortcuts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.shortcut-item { display: flex; align-items: center; gap: 12px; }
.shortcut-keys { display: flex; gap: 4px; }
.shortcut-key {
    background: var(--surface-2);
    border: 1px solid var(--surface-border);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 600;
    color: var(--text-2);
}
.shortcut-desc { font-size: 0.875rem; color: var(--text-2); }
.modal-hint { display: block; margin: 14px 0 0; }

/* ----- Toasts ----- */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; max-width: calc(100vw - 32px); }
.toast {
    background: #0a0a14;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-left: 4px solid var(--brand);
    border-radius: 14px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
    min-width: 260px;
    max-width: 400px;
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast.success { border-left-color: #4ade80; }
.toast.error { border-left-color: #f87171; }
.toast.warning { border-left-color: #fbbf24; }
.toast-icon { width: 24px; height: 24px; flex-shrink: 0; }
.toast-message { flex: 1; font-size: 0.875rem; font-weight: 500; overflow-wrap: anywhere; }
.toast-close { background: none; border: none; cursor: pointer; color: rgba(255, 255, 255, 0.7); font-size: 1.2rem; line-height: 1; padding: 2px 4px; }
.toast-close:hover { color: #fff; }

.hidden { display: none !important; }

/* ----- Information sections below the tool ----- */
.info-section { margin: 0 0 2.5rem; }
.info-section h2 { font-size: 1.75rem; margin: 0 0 1.25rem; }
.info-section > p { max-width: 70ch; }
/* Three columns on desktops, two on tablets, one on phones: six cards fill two rows without a gap. */
.info-section .info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.info-three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 1rem 0 1.5rem; }
.info-stack { display: grid; gap: 12px; }
.info-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    box-shadow: var(--surface-shadow);
    padding: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.info-card:hover { transform: translateY(-4px); box-shadow: var(--surface-hover-shadow); }
.info-card--small { padding: 16px; box-shadow: none; }
.info-card h3 { margin: 0 0 0.75rem; font-size: 1.15rem; }
.info-card p { color: var(--text-2); margin-bottom: 0.75rem; }
.info-card p:last-child { margin-bottom: 0; }
.info-section article:not(.info-card) p { color: var(--text-2); max-width: 70ch; }
.step-card { position: relative; padding-top: 24px; }
.step-num {
    position: absolute;
    top: -16px;
    left: 20px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--gradient-brand);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}
.step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 0.75rem; }
.step-head h3 { margin: 0; }
.step-emoji { font-size: 1.6rem; line-height: 1; }
.info-section .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 1.5rem; }
.tax-table { width: 100%; border-collapse: collapse; margin: 0; background: var(--surface); border: 1px solid var(--surface-border); border-radius: 12px; overflow: hidden; }
.tax-table th { padding: 10px 14px; text-align: left; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); background: var(--surface-2); border: 0; border-bottom: 1px solid var(--surface-border); }
.tax-table td { padding: 9px 14px; border: 0; border-bottom: 1px solid var(--surface-border); font-size: 0.9rem; color: var(--text); }
.tax-table tr:last-child td { border-bottom: none; }
.info-section details.info-card { padding: 0; }
.info-section details.info-card summary {
    cursor: pointer;
    padding: 16px 20px;
    font-weight: 600;
    color: var(--text-strong);
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.info-section details.info-card summary::-webkit-details-marker { display: none; }
.info-section details.info-card summary::after { content: '+'; color: var(--link); font-weight: 700; font-size: 1.2rem; line-height: 1; flex-shrink: 0; }
.info-section details.info-card[open] summary::after { content: '\2212'; }
.info-section details.info-card p { padding: 0 20px 16px; margin: 0; color: var(--text-2); }

/* ----- Tablets ----- */
@media (max-width: 1023px) {
    .main-content { grid-template-columns: 1fr; }
    .preview-panel { position: static; max-height: none; order: -1; }
    .preview-panel .panel-body { max-height: 560px; }
    .invoice-info-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .info-section .info-grid, .info-three { grid-template-columns: repeat(2, 1fr); }
}

/* ----- Phones ----- */
@media (max-width: 639px) {
    .app-hero { margin-bottom: 1.5rem; }
    .app-tagline { font-size: 1rem; }
    .app-toolbar { gap: 10px; }
    .template-pick { width: 100%; }
    .template-pick .form-select { flex: 1; }
    .app-actions { width: 100%; }
    .app-actions .btn { flex: 1 1 auto; padding-left: 12px; padding-right: 12px; }
    .panel-header, .panel-body { padding-left: 16px; padding-right: 16px; }
    .preview-panel .panel-body { padding: 12px; }
    .form-row, .form-row.triple { grid-template-columns: 1fr; }
    .section-title .section-actions { margin-left: 0; width: 100%; }
    .section-title .section-actions .btn { flex: 1; }
    .line-items-table th { display: none; }
    .line-items-table, .line-items-table tbody { display: block; }
    .line-items-table tr { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) 32px; grid-template-areas: "desc desc desc desc" "qty rate amount remove"; gap: 8px; padding: 10px; border-bottom: 1px solid var(--surface-border); }
    .line-items-table tr:last-child { border-bottom: none; }
    .line-items-table td { display: block; padding: 0; border: 0; }
    .line-items-table td:nth-child(1) { grid-area: desc; }
    .line-items-table td:nth-child(2) { grid-area: qty; }
    .line-items-table td:nth-child(3) { grid-area: rate; }
    .line-items-table td:nth-child(4) { grid-area: amount; align-self: center; }
    .line-items-table td:nth-child(5) { grid-area: remove; align-self: center; }
    .line-items-table td[colspan] { grid-column: 1 / -1; grid-area: auto; text-align: center; }
    .invoice-preview { padding: 1.25rem; min-height: 0; }
    .invoice-preview.template-bold .invoice-header { margin: -1.25rem -1.25rem 1.5rem; padding: 1.25rem; }
    .invoice-header { flex-direction: column; gap: 1rem; }
    .invoice-title-section { text-align: left; }
    .invoice-title { font-size: 1.75rem; }
    .invoice-info-grid { grid-template-columns: 1fr; gap: 1rem; }
    .invoice-items-table th, .invoice-items-table td { padding: 0.6rem 0.5rem; font-size: 0.85rem; }
    .totals-table { width: 100%; }
    .shortcuts-grid { grid-template-columns: 1fr; }
    .modal-overlay { padding: 8px; }
    .modal-body, .modal-header, .modal-footer { padding-left: 16px; padding-right: 16px; }
    .saved-item { flex-wrap: wrap; }
    .toast-container { bottom: 16px; right: 16px; left: 16px; align-items: flex-end; }
    .toast { min-width: 0; }
    .info-section h2 { font-size: 1.4rem; }
    .info-section .info-grid, .info-three { grid-template-columns: 1fr; }
    .info-card { padding: 16px; }
    .step-num { left: 16px; }
}

/* ----- Print: only the invoice ----- */
@media print {
    .back-bar, body > header, body > footer, .theme-toggle, .app-hero, .app-toolbar, .info-section, .form-panel, .panel-header, .toast-container, .modal-overlay, #zdu-cookie-banner, noscript { display: none !important; }
    body { padding: 0; background: #fff; }
    body::before { display: none; }
    .container.app-container { max-width: none; margin: 0; padding: 0; }
    .main-content { display: block; }
    .preview-panel { position: static; max-height: none; border: 0; box-shadow: none; }
    .preview-panel .panel-body { padding: 0; background: #fff; max-height: none; overflow: visible; }
    .invoice-preview { box-shadow: none; max-width: 100%; border-radius: 0; padding: 0; min-height: 0; }
    .invoice-preview.template-bold .invoice-header { margin: 0 0 2rem; }
}

@media (prefers-reduced-motion: reduce) {
    .btn, .file-upload, .file-upload-icon, .saved-item, .info-card, .modal, .toast { transition: none; animation: none; }
}

/* Phones: 16 px text, 44 px tap targets (AdSense audit H-04, 8 Oct 2026) */
@media (max-width: 639.98px) {
    main button, main select, main summary, main [role="button"],
    main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]) { min-height: 44px; }
    div#logoUpload.file-upload > p.file-upload-text,
    main .tax-table td { font-size: 1rem; }
    main button.delete-line-btn { min-width: 44px; }
}
