/* ================================================================
   Invoice Generator – Stylesheet
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Playfair+Display:wght@700&display=swap');

:root {
    --theme: #6366f1;
    --theme-light: rgba(99, 102, 241, 0.12);
    --theme-glow: rgba(99, 102, 241, 0.3);
    --bg: #0f1117;
    --bg2: #161b27;
    --surface: #1e2535;
    --surface2: #252d3d;
    --border: rgba(255, 255, 255, 0.08);
    --text: #f0f4ff;
    --text-muted: #64748b;
    --text-soft: #94a3b8;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --radius: 14px;
    --radius-sm: 8px;
    --transition: 0.2s ease;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Animated Background ── */
.bg-blobs {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.15;
    animation: blobFloat 12s ease-in-out infinite;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: var(--theme);
    top: -15%;
    left: -10%;
    animation-delay: 0s;
}

.blob-2 {
    width: 400px;
    height: 400px;
    background: #06b6d4;
    bottom: -15%;
    right: -10%;
    animation-delay: 4s;
}

.blob-3 {
    width: 300px;
    height: 300px;
    background: #8b5cf6;
    top: 40%;
    left: 40%;
    animation-delay: 8s;
}

@keyframes blobFloat {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(20px, -20px) scale(1.05);
    }

    66% {
        transform: translate(-15px, 15px) scale(0.97);
    }
}

/* ── App Shell ── */
.app-shell {
    position: relative;
    z-index: 1;
    display: flex;
    min-height: 100vh;
    gap: 0;
}

/* ── Control Panel (Left Sidebar) ── */
.control-panel {
    width: 300px;
    flex-shrink: 0;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    height: 100vh;
    position: sticky;
    top: 0;
    left: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--surface2) transparent;
}

.control-panel::-webkit-scrollbar {
    width: 5px;
}

.control-panel::-webkit-scrollbar-track {
    background: transparent;
}

.control-panel::-webkit-scrollbar-thumb {
    background: var(--surface2);
    border-radius: 9999px;
}

.cp-header {
    padding: 24px 20px 16px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--surface) 0%, rgba(99, 102, 241, 0.08) 100%);
}

.cp-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cp-logo-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 8px var(--theme-glow));
}

.cp-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.cp-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.cp-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.cp-section-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cp-section-icon {
    font-size: 0.9rem;
}

.cp-label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    margin-top: 10px;
}

.cp-label:first-child {
    margin-top: 0;
}

/* Color Palette */
.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
    position: relative;
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.active {
    border-color: #fff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.color-swatch-custom {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
    border: 2px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    position: relative;
    transition: transform var(--transition);
    overflow: hidden;
}

.color-swatch-custom:hover {
    transform: scale(1.15);
}

.color-swatch-custom span {
    color: white;
    font-weight: 700;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    pointer-events: none;
    position: relative;
    z-index: 1;
}

.color-swatch-custom input[type="color"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

/* Select */
.select-group {
    position: relative;
}

.cp-select {
    width: 100%;
    padding: 9px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.88rem;
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M0 0l6 7 6-7z' fill='%2364748b'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    transition: border-color var(--transition);
}

.cp-select:focus {
    border-color: var(--theme);
}

.cp-select option {
    background: var(--bg2);
}

/* Radio Group */
.radio-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.radio-opt {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text-soft);
    transition: all var(--transition);
    user-select: none;
}

.radio-opt:has(input:checked) {
    background: var(--theme-light);
    border-color: var(--theme);
    color: var(--theme);
}

.radio-opt input {
    display: none;
}

/* Input Groups */
.cp-input-group {
    position: relative;
    margin-top: 10px;
}

.cp-input {
    width: 100%;
    padding: 9px 40px 9px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.88rem;
    outline: none;
    transition: border-color var(--transition);
}

.cp-input:focus {
    border-color: var(--theme);
}

.cp-input-suffix {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.82rem;
    pointer-events: none;
}

/* Action Buttons */
.cp-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: none;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.action-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

.action-btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--theme);
    color: #fff;
}

.btn-success {
    background: #10b981;
    color: #fff;
}

.btn-info {
    background: #0ea5e9;
    color: #fff;
}

.btn-warning {
    background: #f59e0b;
    color: #fff;
}

.btn-secondary {
    background: var(--surface2);
    color: var(--text-soft);
    border: 1px solid var(--border);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ── Invoice Workspace ── */
.invoice-workspace {
    flex: 1;
    padding: 32px 24px;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* ── Invoice Paper ── */
.invoice-paper {
    background: #fff;
    color: #1e293b;
    width: 100%;
    max-width: 820px;
    border-radius: 4px;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.5);
    padding: 48px 48px 36px;
    font-family: 'Inter', sans-serif;
    position: relative;
    transition: box-shadow var(--transition);
}

.invoice-paper:hover {
    box-shadow: 0 24px 100px rgba(0, 0, 0, 0.6);
}

/* ── Invoice Header ── */
.inv-header {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 32px;
}

.inv-company {
    flex: 1;
}

.inv-doc-title {
    font-family: 'Playfair Display', serif;
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--theme);
    letter-spacing: -0.02em;
    line-height: 1;
    margin-bottom: 10px;
    outline: none;
    cursor: text;
    transition: color var(--transition);
}

.inv-company-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: #0f172a;
    outline: none;
    cursor: text;
    margin-bottom: 6px;
}

.inv-company-details {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.inv-field {
    font-size: 0.85rem;
    color: #64748b;
    outline: none;
    cursor: text;
    min-height: 20px;
    padding: 1px 2px;
    border-radius: 3px;
    transition: background 0.15s;
}

.inv-field:focus {
    background: rgba(99, 102, 241, 0.06);
    outline: 1px dashed rgba(99, 102, 241, 0.4);
}

/* Invoice Meta (Right side of header) */
.inv-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 16px;
    min-width: 220px;
}

/* Logo Upload */
.logo-upload-zone {
    width: 160px;
    height: 90px;
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: border-color var(--transition), background var(--transition);
    overflow: hidden;
    background: #f8fafc;
}

.logo-upload-zone:hover {
    border-color: var(--theme);
    background: rgba(99, 102, 241, 0.04);
}

.logo-upload-zone.drag-over {
    border-color: var(--theme);
    background: rgba(99, 102, 241, 0.08);
}

.logo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    pointer-events: none;
}

.logo-upload-icon {
    font-size: 1.5rem;
}

.logo-upload-text {
    font-size: 0.72rem;
    color: #94a3b8;
    font-weight: 500;
}

.logo-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
}

.logo-remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: rgba(239, 68, 68, 0.85);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: background var(--transition);
}

.logo-remove-btn:hover {
    background: #ef4444;
}

/* Invoice Meta Fields */
.inv-meta-fields {
    width: 100%;
}

.inv-meta-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 6px;
}

.inv-meta-label {
    font-size: 0.78rem;
    color: #94a3b8;
    white-space: nowrap;
    font-weight: 500;
}

.inv-meta-input {
    padding: 5px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.82rem;
    color: #0f172a;
    outline: none;
    text-align: right;
    width: 130px;
    background: #f8fafc;
    transition: border-color var(--transition);
}

.inv-meta-input:focus {
    border-color: var(--theme);
    background: #fff;
}

/* ── Divider ── */
.inv-divider {
    height: 3px;
    border-radius: 2px;
    background: var(--theme);
    margin-bottom: 28px;
    transition: background var(--transition);
}

/* ── Billing ── */
.inv-billing {
    display: flex;
    gap: 32px;
    margin-bottom: 32px;
}

.inv-party {
    flex: 1;
}

.inv-party-right {
    padding-left: 32px;
    border-left: 1px solid #e2e8f0;
}

.inv-party-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--theme);
    margin-bottom: 8px;
    text-transform: uppercase;
    transition: color var(--transition);
}

.inv-party-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
    outline: none;
    cursor: text;
    margin-bottom: 4px;
    min-height: 26px;
    padding: 1px 2px;
}

.inv-party-name:focus {
    outline: 1px dashed rgba(99, 102, 241, 0.4);
    border-radius: 3px;
}

.inv-party-field {
    font-size: 0.83rem;
    color: #475569;
    outline: none;
    cursor: text;
    min-height: 20px;
    padding: 1px 2px;
    border-radius: 3px;
    margin-bottom: 2px;
    transition: background 0.15s;
}

.inv-party-field:focus {
    background: rgba(99, 102, 241, 0.06);
    outline: 1px dashed rgba(99, 102, 241, 0.4);
}

/* ── Items Table ── */
.inv-items-section {
    margin-bottom: 24px;
}

.inv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.inv-table thead tr {
    background: var(--theme);
    color: #fff;
    transition: background var(--transition);
}

.inv-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.inv-table th.col-rate,
.inv-table th.col-qty,
.inv-table th.col-amount {
    text-align: right;
}

.inv-table th.col-action {
    width: 40px;
}

.inv-table tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
}

.inv-table tbody tr:hover {
    background: #f8fafc;
}

.inv-table tbody tr:last-child {
    border-bottom: none;
}

.inv-table td {
    padding: 8px 12px;
    vertical-align: middle;
}

.item-desc-input,
.item-rate-input,
.item-qty-input {
    width: 100%;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.88rem;
    color: #1e293b;
    outline: none;
    min-width: 0;
}

.item-desc-input:focus,
.item-rate-input:focus,
.item-qty-input:focus {
    background: rgba(99, 102, 241, 0.06);
    border-radius: 4px;
    outline: 1px dashed rgba(99, 102, 241, 0.4);
}

.item-rate-input,
.item-qty-input {
    text-align: right;
}

.item-amount {
    text-align: right;
    font-weight: 600;
    color: #0f172a;
}

.item-remove-btn {
    background: none;
    border: none;
    color: #cbd5e1;
    font-size: 1rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color var(--transition), background var(--transition);
    line-height: 1;
}

.item-remove-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

/* Add Item Btn */
.add-item-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 8px 14px;
    background: none;
    border: 1.5px dashed #cbd5e1;
    border-radius: var(--radius-sm);
    color: #94a3b8;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.add-item-btn:hover {
    border-color: var(--theme);
    color: var(--theme);
    background: rgba(99, 102, 241, 0.06);
}

/* ── Totals ── */
.inv-totals-section {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 28px;
}

.inv-totals-spacer {
    flex: 1;
}

.inv-totals {
    width: 280px;
    border-top: 2px solid #e2e8f0;
    padding-top: 12px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    font-size: 0.88rem;
    color: #475569;
}

.total-label {
    font-weight: 500;
}

.total-value {
    font-weight: 600;
    color: #0f172a;
}

.discount-val {
    color: #10b981;
}

.grand-total-row {
    border-top: 2px solid #e2e8f0;
    margin-top: 6px;
    padding-top: 10px;
}

.grand-label {
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
}

.grand-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--theme);
    transition: color var(--transition);
}

.balance-row {
    margin-top: 4px;
    color: #64748b;
}

.balance-due-row {
    background: var(--theme);
    color: #fff !important;
    border-radius: 8px;
    padding: 8px 12px;
    margin-top: 8px;
    transition: background var(--transition);
}

.balance-due-row .total-label,
.balance-due-row .balance-value {
    color: #fff !important;
    font-size: 1rem;
    font-weight: 700;
}

.inline-input {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    color: #0f172a;
    text-align: right;
    width: 100px;
    outline: none;
    border-bottom: 1px dashed #e2e8f0;
    padding: 0 2px 2px;
}

.inline-input:focus {
    border-color: var(--theme);
}

/* ── Notes ── */
.inv-notes {
    margin-bottom: 24px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 8px;
    border-left: 4px solid var(--theme);
    transition: border-color var(--transition);
}

.inv-notes-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--theme);
    margin-bottom: 6px;
    transition: color var(--transition);
}

.inv-notes-body {
    font-size: 0.84rem;
    color: #475569;
    line-height: 1.6;
    outline: none;
    cursor: text;
    min-height: 40px;
}

.inv-notes-body:focus {
    outline: 1px dashed rgba(99, 102, 241, 0.4);
    border-radius: 4px;
}

/* ── Signature ── */
.inv-signature-section {
    margin-bottom: 20px;
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.inv-sig-line {
    width: 200px;
    height: 1px;
    background: #cbd5e1;
}

.inv-sig-label {
    font-size: 0.78rem;
    color: #94a3b8;
    letter-spacing: 0.04em;
}

.inv-sig-img {
    max-width: 200px;
    max-height: 60px;
    object-fit: contain;
}

/* ── Attachments ── */
.inv-attachments {
    margin-bottom: 20px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 8px;
}

.inv-attach-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #94a3b8;
    margin-bottom: 8px;
}

.inv-attach-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attach-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

/* ── Invoice Footer ── */
.inv-footer {
    text-align: center;
    font-size: 0.72rem;
    color: #cbd5e1;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
}

/* ── Modals ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
    width: 100%;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from {
        transform: translateY(20px) scale(0.97);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-sm {
    max-width: 520px;
}

.modal-xs {
    max-width: 380px;
}

.modal-preview {
    max-width: 900px;
    max-height: 90vh;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--surface2);
    color: var(--text);
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Preview Body */
.preview-body {
    background: #e5e7eb;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    overflow-y: auto;
    max-height: calc(90vh - 130px);
}

.preview-body .invoice-paper {
    width: 680px;
    min-width: 680px;
    transform-origin: top center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-soft);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 10px 13px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.88rem;
    outline: none;
    transition: border-color var(--transition);
    resize: vertical;
}

.form-input:focus,
.form-textarea:focus {
    border-color: var(--theme);
}

/* Signature */
.sig-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.sig-tab {
    padding: 7px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-soft);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
}

.sig-tab.active {
    background: var(--theme-light);
    border-color: var(--theme);
    color: var(--theme);
    font-weight: 600;
}

.sig-canvas {
    width: 100%;
    height: 160px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: crosshair;
    display: block;
}

.sig-canvas-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.sig-upload-area {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 30px 16px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.88rem;
    transition: all var(--transition);
    text-align: center;
    margin-bottom: 10px;
}

.sig-upload-area:hover {
    border-color: var(--theme);
    color: var(--theme);
}

.sig-upload-preview {
    max-width: 100%;
    max-height: 120px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.attach-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.attach-preview-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1e2535;
    color: #f0f4ff;
    padding: 12px 24px;
    border-radius: 9999px;
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    border: 1px solid var(--border);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Sidebar ── */
.has-sidebar .invoice-workspace {
    /* push right of the sidebar handled by sidebar.css */
}

/* ── Print Styles ── */
@media print {
    .app-shell {
        display: block;
    }

    .control-panel,
    .add-item-btn,
    .item-remove-btn,
    .logo-upload-zone .logo-placeholder {
        display: none !important;
    }

    .invoice-workspace {
        padding: 0;
        background: #fff;
    }

    .invoice-paper {
        box-shadow: none;
        border-radius: 0;
        max-width: 100%;
        padding: 32px;
    }

    .bg-blobs {
        display: none;
    }
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .app-shell {
        flex-direction: column;
    }

    .control-panel {
        width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex-direction: row;
        flex-wrap: wrap;
        overflow-x: auto;
    }

    .cp-section {
        flex: 0 0 auto;
        min-width: 220px;
    }

    .invoice-workspace {
        padding: 16px;
    }

    .invoice-paper {
        padding: 24px;
    }

    .inv-header {
        flex-direction: column-reverse;
    }

    .inv-meta {
        align-items: flex-start;
    }

    .inv-billing {
        flex-direction: column;
    }

    .inv-party-right {
        border-left: none;
        border-top: 1px solid #e2e8f0;
        padding-left: 0;
        padding-top: 16px;
    }
}

@media (max-width: 600px) {
    .invoice-paper {
        padding: 16px;
    }

    .inv-table {
        font-size: 0.78rem;
    }

    .inv-doc-title {
        font-size: 1.8rem;
    }

    .inv-totals {
        width: 100%;
    }

    .inv-totals-section {
        flex-direction: column;
    }
}

/* ─── Contenteditable focus placeholder ──── */
[contenteditable]:empty:before {
    content: attr(data-placeholder);
    color: #cbd5e1;
    pointer-events: none;
}

/* col widths */
.col-desc {
    width: 45%;
}

.col-rate {
    width: 18%;
}

.col-qty {
    width: 12%;
}

.col-amount {
    width: 18%;
}

.col-action {
    width: 7%;
    text-align: center;
}