:root {
    --ink: #1f2933;
    --muted: #667085;
    --line: #d8dee8;
    --paper: #ffffff;
    --panel: #f5f7fb;
    --accent: #0f8b8d;
    --accent-dark: #0b6264;
    --gold: #f4b740;
    --danger: #c2412d;
    --header-bg: #0f3d63;
    --header-ink: #ffffff;
    --badge-bg: #ffffff;
    --badge-ink: #0f3d63;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: linear-gradient(135deg, #eef4f8 0%, #f8fafc 44%, #fff7e6 100%);
    color: var(--ink);
    font-family: Inter, Arial, sans-serif;
    font-size: 13px;
}

button,
input,
select,
textarea {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
    padding: 18px;
}

.workspace {
    margin: 0 auto;
    max-width: 1540px;
}

.control-panel {
    align-self: start;
    background: #17212b;
    border-radius: 8px;
    color: #fff;
    padding: 18px;
    position: sticky;
    top: 24px;
}

.brand {
    display: flex;
    gap: 14px;
    align-items: center;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--gold);
    color: #14202a;
    font-weight: 800;
}

.brand h1 {
    margin: 0;
    font-size: 17px;
}

.brand p,
.tips span {
    color: #cbd5e1;
    display: block;
    line-height: 1.5;
    margin: 5px 0 0;
}

button {
    border: 0;
    cursor: pointer;
}

.primary-btn,
.ghost-btn {
    align-items: center;
    border-radius: 8px;
    display: flex;
    font-weight: 700;
    gap: 10px;
    justify-content: center;
    min-height: 40px;
    padding: 8px 12px;
}

.primary-btn {
    background: var(--accent);
    color: #fff;
}

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

.ghost-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.floating-actions {
    display: flex;
    gap: 8px;
    position: fixed;
    right: 22px;
    top: 22px;
    z-index: 20;
}

.floating-actions .primary-btn,
.floating-actions .ghost-btn {
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.2);
}

.floating-actions .ghost-btn {
    background: #17212b;
}

.design-picker {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.12);
    display: flex;
    gap: 8px;
    padding: 5px 8px;
}

.design-picker span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.design-picker select {
    border: 0;
    box-shadow: none;
    min-width: 118px;
    padding: 5px 3px;
}

.tips {
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    padding-top: 18px;
}

.invoice-canvas {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.12);
    padding: 22px;
}

.invoice-header {
    align-items: start;
    background: var(--header-bg);
    border-bottom: 0;
    color: var(--header-ink);
    display: grid;
    gap: 24px;
    grid-template-columns: 1fr 230px;
    margin: -22px -22px 20px;
    padding: 22px;
    padding-bottom: 18px;
}

.field-label {
    color: inherit;
    opacity: 0.82;
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin: 0 0 6px;
    text-transform: uppercase;
}

input,
select,
textarea {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    outline: none;
    padding: 7px 8px;
    width: 100%;
}

.print-value {
    display: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 139, 141, 0.14);
}

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

.business-input {
    border: 0;
    font-size: 24px;
    font-weight: 800;
    line-height: 1.25;
    padding: 0;
}

.business-input:focus,
.plain-textarea:focus {
    box-shadow: none;
}

.plain-textarea {
    border: 0;
    line-height: 1.55;
    margin-top: 10px;
    padding: 0;
}

.invoice-header input,
.invoice-header textarea {
    background: transparent;
    color: inherit;
}

.invoice-title-block {
    display: grid;
    gap: 7px;
}

.invoice-badge {
    background: var(--badge-bg);
    border-radius: 8px;
    color: var(--badge-ink);
    font-size: 18px;
    font-weight: 800;
    line-height: 1.25;
    margin-bottom: 8px;
    padding: 11px;
    text-align: center;
}

.party-grid,
.summary-grid {
    display: grid;
    gap: 22px;
    grid-template-columns: 1fr 1fr;
    margin-top: 20px;
}

h2 {
    font-size: 13px;
    margin: 0 0 10px;
}

.party-grid input + input,
.party-grid input + textarea,
.party-grid textarea + input {
    margin-top: 10px;
}

.bank-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr 1fr;
}

.bank-grid input:first-child,
.bank-grid input:nth-child(2),
.bank-grid input:last-child {
    grid-column: 1 / -1;
}

.items-section {
    margin-top: 22px;
}

.section-head {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

.icon-btn {
    align-items: center;
    border-radius: 8px;
    display: inline-flex;
    font-size: 20px;
    font-weight: 800;
    height: 30px;
    justify-content: center;
    line-height: 1;
    width: 30px;
}

.add-row {
    background: var(--accent);
    color: #fff;
}

.remove-row {
    background: #fff1ed;
    color: var(--danger);
}

.table-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow-x: auto;
}

.invoice-table {
    border-collapse: collapse;
    min-width: 1280px;
    width: 100%;
    table-layout: fixed;
}

.col-sl {
    width: 42px;
}

.col-product {
    width: 43%;
}

.col-hsn {
    width: 145px;
}

.col-qty {
    width: 70px;
}

.col-rate {
    width: 90px;
}

.col-gst {
    width: 72px;
}

.col-gst-amount,
.col-total {
    width: 115px;
}

.col-action {
    width: 44px;
}

.invoice-table th {
    background: var(--panel);
    color: var(--muted);
    font-size: 11px;
    text-align: left;
    text-transform: uppercase;
}

.invoice-table th,
.invoice-table td {
    border-bottom: 1px solid var(--line);
    padding: 6px;
    vertical-align: middle;
}

.invoice-table tbody tr:last-child td {
    border-bottom: 0;
}

.invoice-table input,
.invoice-table select {
    min-width: 0;
    padding: 7px;
}

.product-input {
    min-width: 100%;
}

.lookup-field {
    display: grid;
    gap: 5px;
    grid-template-columns: minmax(0, 1fr) 28px;
    min-width: 0;
}

.lookup-field .hsn-input {
    min-width: 0;
}

.mini-lookup {
    background: var(--gold);
    border-radius: 6px;
    color: #17212b;
    font-weight: 800;
    height: 28px;
    width: 28px;
}

.mini-lookup svg {
    fill: currentColor;
    height: 16px;
    width: 16px;
}

.sl-col {
    width: 42px;
}

.action-col {
    width: 46px;
}

.row-number {
    color: var(--muted);
    font-weight: 700;
    text-align: center;
}

.notes-box textarea {
    min-height: 112px;
}

.totals-box {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.totals-box div {
    align-items: center;
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
}

.totals-box div + div {
    border-top: 1px solid var(--line);
}

.grand-total {
    color: var(--accent-dark);
    font-size: 18px;
}

.invoice-footer {
    align-items: end;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 24px;
    grid-template-columns: 1fr 230px;
    margin-top: 20px;
    padding-top: 18px;
}

.invoice-footer span {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.signature-box {
    align-items: center;
    border: 1px dashed var(--line);
    border-radius: 8px;
    display: grid;
    justify-items: center;
    min-height: 118px;
    padding: 10px;
    text-align: center;
}

.signature-box img {
    display: none;
    max-height: 72px;
    max-width: 190px;
    object-fit: contain;
}

.signature-box.has-image img {
    display: block;
}

.upload-sign {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    margin: 6px 0;
    padding: 7px 10px;
}

.signature-box span {
    color: var(--ink);
    font-weight: 700;
}

.sr-only {
    height: 1px;
    left: -999px;
    overflow: hidden;
    position: absolute;
    width: 1px;
}

.modal-backdrop {
    align-items: center;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    inset: 0;
    justify-content: center;
    padding: 18px;
    position: fixed;
    z-index: 50;
}

.modal-backdrop.is-open {
    display: flex;
}

.lookup-modal {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.3);
    max-height: 88vh;
    max-width: 780px;
    overflow: auto;
    padding: 18px;
    width: 100%;
}

.modal-head,
.search-line,
.pagination-row {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.modal-head p {
    color: var(--muted);
    margin: 4px 0 0;
}

.close-modal {
    background: #f3f4f6;
}

.search-line {
    margin-top: 16px;
}

.search-line input {
    min-height: 40px;
}

.lookup-results {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 14px;
    overflow: hidden;
}

.lookup-empty {
    color: var(--muted);
    padding: 16px;
    text-align: center;
}

.lookup-result {
    align-items: center;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 12px;
    grid-template-columns: 92px 1fr 78px 88px;
    padding: 10px;
    text-align: left;
    width: 100%;
}

.lookup-result:last-child {
    border-bottom: 0;
}

.lookup-result:hover {
    background: #f7fbfb;
}

.lookup-result strong {
    font-size: 14px;
}

.lookup-result span {
    color: var(--muted);
}

.lookup-result .gst-pill {
    background: #e8f7f7;
    border-radius: 999px;
    color: var(--accent-dark);
    font-weight: 800;
    padding: 6px 8px;
    text-align: center;
}

.ghost-light {
    background: #f3f4f6;
    border-radius: 6px;
    color: var(--ink);
    font-weight: 700;
    min-height: 34px;
    padding: 7px 11px;
}

.ghost-light:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.pagination-row {
    margin-top: 12px;
}

.pdf-exporting {
    border: 0;
    box-shadow: none;
    max-width: none;
    padding: 18px;
    width: 980px;
}

.pdf-exporting .invoice-header {
    gap: 18px;
    grid-template-columns: 1fr 190px;
    margin: -18px -18px 16px;
    padding: 18px;
    padding-bottom: 14px;
}

.pdf-exporting .party-grid,
.pdf-exporting .summary-grid {
    gap: 14px;
    grid-template-columns: 1fr 1fr;
    margin-top: 16px;
}

.pdf-exporting .party-grid {
    align-items: start;
}

.pdf-exporting .bank-grid {
    gap: 6px 12px;
    grid-template-columns: 1fr 1fr;
}

.pdf-exporting .items-section {
    margin-top: 16px;
}

.pdf-exporting .invoice-table {
    font-size: 11px;
    min-width: 0;
}

.pdf-exporting .col-sl {
    width: 34px;
}

.pdf-exporting .col-product {
    width: 38%;
}

.pdf-exporting .col-hsn {
    width: 82px;
}

.pdf-exporting .col-qty {
    width: 48px;
}

.pdf-exporting .col-rate {
    width: 70px;
}

.pdf-exporting .col-gst {
    width: 50px;
}

.pdf-exporting .col-gst-amount,
.pdf-exporting .col-total {
    width: 86px;
}

.pdf-exporting .invoice-table th,
.pdf-exporting .invoice-table td {
    padding: 5px;
}

.pdf-exporting .totals-box {
    padding: 10px 12px;
}

.pdf-exporting .totals-box div {
    padding: 6px 0;
}

.pdf-exporting .invoice-footer {
    margin-top: 16px;
    padding-top: 14px;
}

.pdf-exporting .signature-box {
    min-height: 92px;
}

.pdf-exporting .no-print {
    display: none !important;
}

.pdf-exporting .pdf-field-hidden {
    display: none !important;
}

.pdf-exporting .print-value {
    color: inherit;
    display: block;
    line-height: 1.45;
    min-height: 24px;
    overflow-wrap: anywhere;
    padding: 7px 8px;
    white-space: pre-wrap;
}

.pdf-exporting .bank-print-value {
    border-bottom: 1px solid #e5e7eb;
    display: grid;
    gap: 2px;
    min-height: 0;
    padding: 3px 0 5px;
}

.pdf-exporting .bank-print-value::before {
    color: var(--muted);
    content: attr(data-label);
    display: block;
    font-size: 9px;
    font-weight: 800;
    line-height: 1.2;
    text-transform: uppercase;
}

.pdf-exporting .business-print-value {
    font-size: 24px;
    font-weight: 800;
    line-height: 1.25;
    padding: 0;
}

.pdf-exporting .plain-print-value {
    line-height: 1.55;
    margin-top: 10px;
    padding: 0;
}

.pdf-exporting .invoice-table .print-value {
    min-height: 0;
    padding: 4px 2px;
}

.pdf-exporting .invoice-title-block .print-value {
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 6px;
}

.invoice-canvas {
    --accent: #0f3d63;
    --accent-dark: #082b47;
    --panel: #edf4fb;
    --header-bg: #0f3d63;
    --header-ink: #ffffff;
    --badge-bg: #ffffff;
    --badge-ink: #0f3d63;
}

.design-classic {
    --accent: #0f8b8d;
    --accent-dark: #0b6264;
    --panel: #f5f7fb;
    --header-bg: #1f2933;
    --header-ink: #ffffff;
    --badge-bg: #ffffff;
    --badge-ink: #1f2933;
}

.design-corporate {
    --accent: #234f8f;
    --accent-dark: #173760;
    --panel: #eef4ff;
    --header-bg: #103b63;
    --header-ink: #ffffff;
    --badge-bg: #ffffff;
    --badge-ink: #103b63;
}

.design-modern {
    --accent: #c05621;
    --accent-dark: #8a3b13;
    --panel: #fff5ec;
    --header-bg: #8a3b13;
    --header-ink: #ffffff;
    --badge-bg: #fff5ec;
    --badge-ink: #8a3b13;
}

.design-modern {
    border-top: 8px solid var(--accent);
}

.design-modern .invoice-table th {
    background: #1f2933;
    color: #fff;
}

.design-minimal {
    --accent: #111827;
    --accent-dark: #111827;
    --panel: #fff;
    border-color: #111827;
    box-shadow: none;
    --header-bg: #ffffff;
    --header-ink: #111827;
    --badge-bg: #111827;
    --badge-ink: #ffffff;
}

.design-minimal input,
.design-minimal select,
.design-minimal textarea {
    border-radius: 0;
}

.design-minimal .invoice-badge,
.design-minimal .add-row {
    border-radius: 0;
}

.design-premium {
    --accent: #7c3aed;
    --accent-dark: #5b21b6;
    --gold: #f3c969;
    --panel: #faf7ff;
    border: 2px solid #7c3aed;
    --header-bg: #4c1d95;
    --header-ink: #ffffff;
    --badge-bg: #f3c969;
    --badge-ink: #2e1065;
}

.design-premium .invoice-badge {
    background: linear-gradient(135deg, #5b21b6, #a855f7);
}

.design-premium .invoice-header {
    border-bottom-color: #f3c969;
}

.design-executive {
    --accent: #334155;
    --accent-dark: #0f172a;
    --panel: #f1f5f9;
    --header-bg: #0f172a;
    --header-ink: #ffffff;
    --badge-bg: #e2e8f0;
    --badge-ink: #0f172a;
}

.design-ledger {
    --accent: #3f6212;
    --accent-dark: #365314;
    --panel: #f7fee7;
    --header-bg: #365314;
    --header-ink: #ffffff;
    --badge-bg: #ecfccb;
    --badge-ink: #365314;
}

.design-steel {
    --accent: #475569;
    --accent-dark: #334155;
    --panel: #f8fafc;
    --header-bg: #334155;
    --header-ink: #ffffff;
    --badge-bg: #ffffff;
    --badge-ink: #334155;
}

.design-emerald {
    --accent: #047857;
    --accent-dark: #065f46;
    --panel: #ecfdf5;
    --header-bg: #065f46;
    --header-ink: #ffffff;
    --badge-bg: #d1fae5;
    --badge-ink: #064e3b;
}

.design-maroon {
    --accent: #9f1239;
    --accent-dark: #881337;
    --panel: #fff1f2;
    --header-bg: #881337;
    --header-ink: #ffffff;
    --badge-bg: #ffe4e6;
    --badge-ink: #881337;
}

.design-indigo {
    --accent: #4338ca;
    --accent-dark: #3730a3;
    --panel: #eef2ff;
    --header-bg: #3730a3;
    --header-ink: #ffffff;
    --badge-bg: #e0e7ff;
    --badge-ink: #312e81;
}

.design-slate {
    --accent: #1e293b;
    --accent-dark: #0f172a;
    --panel: #f1f5f9;
    --header-bg: #1e293b;
    --header-ink: #ffffff;
    --badge-bg: #ffffff;
    --badge-ink: #1e293b;
}

.design-teal {
    --accent: #0f766e;
    --accent-dark: #115e59;
    --panel: #f0fdfa;
    --header-bg: #115e59;
    --header-ink: #ffffff;
    --badge-bg: #ccfbf1;
    --badge-ink: #134e4a;
}

.design-amber {
    --accent: #b45309;
    --accent-dark: #92400e;
    --panel: #fffbeb;
    --header-bg: #92400e;
    --header-ink: #ffffff;
    --badge-bg: #fef3c7;
    --badge-ink: #78350f;
}

.design-rose {
    --accent: #be123c;
    --accent-dark: #9f1239;
    --panel: #fff1f2;
    --header-bg: #9f1239;
    --header-ink: #ffffff;
    --badge-bg: #ffe4e6;
    --badge-ink: #881337;
}

.design-mono {
    --accent: #262626;
    --accent-dark: #171717;
    --panel: #f5f5f5;
    --header-bg: #ffffff;
    --header-ink: #171717;
    --badge-bg: #171717;
    --badge-ink: #ffffff;
    box-shadow: none;
}

.design-navyline {
    --accent: #1d4ed8;
    --accent-dark: #1e40af;
    --panel: #eff6ff;
    --header-bg: #ffffff;
    --header-ink: #172554;
    --badge-bg: #1d4ed8;
    --badge-ink: #ffffff;
    border-top: 8px solid #1d4ed8;
}

.design-greenline {
    --accent: #15803d;
    --accent-dark: #166534;
    --panel: #f0fdf4;
    --header-bg: #ffffff;
    --header-ink: #14532d;
    --badge-bg: #15803d;
    --badge-ink: #ffffff;
    border-top: 8px solid #15803d;
}

.design-blackgold {
    --accent: #b45309;
    --accent-dark: #78350f;
    --panel: #fffbeb;
    --header-bg: #111827;
    --header-ink: #ffffff;
    --badge-bg: #f3c969;
    --badge-ink: #111827;
}

.design-cleanblue {
    --accent: #0284c7;
    --accent-dark: #0369a1;
    --panel: #f0f9ff;
    --header-bg: #e0f2fe;
    --header-ink: #0c4a6e;
    --badge-bg: #0284c7;
    --badge-ink: #ffffff;
}

.design-mono .invoice-header,
.design-navyline .invoice-header,
.design-greenline .invoice-header,
.design-cleanblue .invoice-header {
    border-bottom: 2px solid var(--accent);
}

@media (max-width: 980px) {
    .app-shell {
        padding: 14px;
    }

    .workspace,
    .invoice-header,
    .party-grid,
    .summary-grid,
    .invoice-footer {
        grid-template-columns: 1fr;
    }

    .control-panel {
        position: static;
    }

    .floating-actions {
        bottom: 14px;
        left: 14px;
        right: 14px;
        top: auto;
    }

    .floating-actions button {
        flex: 1;
    }

    .design-picker {
        flex: 1 1 100%;
    }

    .floating-actions {
        flex-wrap: wrap;
    }

    .invoice-canvas {
        padding: 20px;
    }

    .lookup-result {
        grid-template-columns: 1fr;
    }

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

    .bank-grid input {
        grid-column: auto;
    }
}

@media (max-width: 720px) {
    body {
        font-size: 12px;
    }

    .app-shell {
        padding: 8px 8px 86px;
    }

    .invoice-canvas {
        border-radius: 6px;
        padding: 12px;
    }

    .business-input {
        font-size: 20px;
    }

    .invoice-badge {
        font-size: 16px;
    }

    .party-grid,
    .summary-grid {
        gap: 14px;
        margin-top: 16px;
    }

    .invoice-table {
        min-width: 860px;
    }

    .product-input {
        min-width: 260px;
    }

    .floating-actions {
        background: rgba(255, 255, 255, 0.94);
        border-top: 1px solid var(--line);
        box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.14);
        gap: 7px;
        padding: 8px;
    }

    .design-picker {
        min-width: 100%;
    }

    .design-picker select {
        flex: 1;
    }
}

@media print {
    body {
        background: #fff;
        font-size: 11px;
    }

    .app-shell,
    .invoice-canvas {
        box-shadow: none;
        padding: 0;
    }

    .workspace {
        display: block;
        max-width: none;
    }

    .invoice-canvas {
        border: 0;
        border-radius: 0;
        max-width: none;
        width: 100%;
    }

    .no-print {
        display: none !important;
    }

    input,
    select,
    textarea {
        border-color: transparent;
        box-shadow: none !important;
    }

    .table-wrap {
        overflow: visible;
    }

    .invoice-table {
        font-size: 10px;
        min-width: 0;
        table-layout: fixed;
    }

    .invoice-table th,
    .invoice-table td {
        padding: 4px;
    }

    .col-product {
        width: 38%;
    }

    .col-hsn {
        width: 82px;
    }

    .col-qty {
        width: 48px;
    }

    .col-rate {
        width: 70px;
    }

    .col-gst {
        width: 50px;
    }

    .col-gst-amount,
    .col-total {
        width: 86px;
    }
}
