/* Re-themed to SnapStatic dark + indigo by aliasing to styles-base --ss-* tokens.
   --blue is kept (the invoice title + PDF use blue; the preview is white paper). */
:root {
    --bg-primary: var(--ss-surface);
    --bg-secondary: var(--ss-bg);
    --bg-tertiary: var(--ss-surface-2);
    --text-primary: var(--ss-text);
    --text-secondary: var(--ss-text-dim);
    --text-muted: var(--ss-text-dim);
    --border-color: var(--ss-border);
    --accent: var(--ss-accent);
    --accent-hover: var(--ss-accent-hover);
    --warning: var(--ss-warn);
    --error: #ef4444;
    --blue: #3b82f6;
    --blue-dark: #1d4ed8;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.5);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* .container, header and footer are owned by the shared frame (styles-base.css). */

.hidden {
    display: none !important;
}

/* Header + badges now rendered by the frame (.ss-nav + .tool-head). */

main {
    padding: 24px 16px;
}

.invoice-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

.section-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}

.form-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.form-section-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
    background: var(--bg-tertiary);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--blue);
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.btn-add {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add:hover {
    background: var(--accent);
    color: white;
}

.line-items-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 40px;
    gap: 8px;
    padding: 8px 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.col-qty,
.col-rate {
    text-align: center;
}

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

.line-items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0;
}

.line-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 40px;
    gap: 8px;
    align-items: center;
}

.line-item input {
    padding: 8px 10px;
    font-size: 13px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    font-family: inherit;
}

.line-item input:focus {
    border-color: var(--blue);
}

.line-item input[type="number"] {
    text-align: center;
}

.item-amount {
    font-weight: 600;
    font-size: 14px;
    text-align: right;
    color: var(--text-primary);
}

.btn-remove {
    padding: 4px 8px;
    background: var(--error);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    transition: opacity 0.2s;
}

.btn-remove:hover {
    opacity: 0.8;
}

.line-items-totals {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.totals-row span:first-child {
    color: var(--text-secondary);
}

.totals-row span:last-child {
    font-weight: 600;
}

.tax-row {
    padding: 8px 0;
}

.tax-input {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tax-input label {
    font-size: 13px;
    color: var(--text-secondary);
}

.tax-input input {
    width: 70px;
    padding: 6px 8px;
    font-size: 13px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    text-align: center;
}

.total-row {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    padding-top: 8px;
    border-top: 2px solid var(--border-color);
}

.total-row span:last-child {
    color: var(--accent);
}

/* Single column: the preview flows below the form at full content width (like mobile). */

.preview-wrapper {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 16px;
    min-height: 400px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.invoice-preview {
    /* White-paper invoice mock: re-declare the light token values locally so the
       printed-invoice preview stays dark-text-on-white inside the dark UI. */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    background: #ffffff;
    color: var(--text-primary);
    width: 100%;
    max-width: 500px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    font-size: 12px;
    line-height: 1.4;
}

.preview-placeholder {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.preview-invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.preview-business-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.preview-business-info {
    color: var(--text-secondary);
    font-size: 11px;
    line-height: 1.5;
}

.preview-invoice-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--blue);
}

.preview-invoice-meta {
    text-align: right;
    font-size: 11px;
    color: var(--text-secondary);
}

.preview-invoice-meta p {
    margin: 2px 0;
}

.preview-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.preview-party h4 {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.preview-party-name {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 2px;
}

.preview-party-info {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.preview-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
}

.preview-items-table th {
    background: var(--bg-tertiary);
    padding: 8px 6px;
    font-size: 10px;
    font-weight: 600;
    text-align: left;
    text-transform: uppercase;
    color: var(--text-muted);
}

.preview-items-table td {
    padding: 8px 6px;
    border-bottom: 1px solid var(--border-color);
    font-size: 11px;
}

.preview-items-table .col-desc {
    width: 40%;
}

.preview-items-table .col-qty,
.preview-items-table .col-rate {
    text-align: center;
}

.preview-items-table .col-amount {
    text-align: right;
}

.preview-totals {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 24px;
}

.preview-totals-table {
    width: 200px;
}

.preview-totals-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 12px;
}

.preview-totals-row.total {
    font-weight: 700;
    font-size: 14px;
    border-top: 2px solid var(--text-primary);
    margin-top: 4px;
    padding-top: 8px;
}

.preview-totals-row.total span:last-child {
    color: var(--accent);
}

.preview-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

.preview-footer h4 {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.preview-footer p {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.preview-actions {
    display: flex;
    gap: 8px;
}

.btn-clear {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-clear:hover {
    background: var(--error);
    color: white;
}

.download-actions {
    margin-top: 16px;
    display: flex;
    justify-content: center;
}

.btn-primary {
    padding: 12px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-large {
    padding: 14px 32px;
    font-size: 16px;
}

.btn-full {
    width: 100%;
}

.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
    font-size: 14px;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: modal-in 0.3s ease;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-header {
    text-align: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.modal-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.modal-body .form-group {
    margin-bottom: 16px;
}

.form-error {
    color: var(--error);
    font-size: 12px;
    margin-top: 4px;
}

.offer-details {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
}

.offer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    margin-bottom: 10px;
}

.offer-item:last-child {
    margin-bottom: 0;
}

.offer-item .check {
    color: var(--accent);
    font-weight: 700;
}

.no-thanks {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
}

.no-thanks a {
    color: var(--text-muted);
    text-decoration: underline;
}

.no-thanks a:hover {
    color: var(--text-secondary);
}

.modal-success {
    text-align: center;
    padding: 20px 0;
}

.success-icon {
    width: 60px;
    height: 60px;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    margin: 0 auto 16px;
}

.modal-success h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal-success p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* .toast is rendered/styled by the shared frame (styles-base.css).
   The email-capture modal styles below are unused (modal removed; standard upsell used). */

@media (max-width: 640px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .header h1 {
        font-size: 20px;
    }

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

    .form-group.full-width {
        grid-column: 1;
    }

    .line-items-header {
        display: none;
    }

    .line-item {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 12px;
        background: var(--bg-tertiary);
        border-radius: var(--radius-md);
        position: relative;
    }

    .line-item input.item-desc {
        width: 100%;
    }

    .line-item input.item-qty,
    .line-item input.item-rate {
        width: 50%;
    }

    .item-amount {
        position: absolute;
        top: 12px;
        right: 40px;
    }

    .btn-remove {
        position: absolute;
        top: 8px;
        right: 8px;
    }

    .preview-section {
        position: static;
    }

    .preview-wrapper {
        padding: 12px;
        min-height: 300px;
    }

    .invoice-preview {
        padding: 16px;
    }

    .preview-parties {
        grid-template-columns: 1fr;
    }

    .modal-content {
        padding: 24px;
    }

    .modal-header h3 {
        font-size: 18px;
    }
}