:root {
    --bg: #f4f6f9;
    --card: #fff;
    --text: #1a1d26;
    --muted: #5c6578;
    --border: #d8dee8;
    --accent: #16a34a;
    --accent-hover: #15803d;
    --danger: #b91c1c;
    --ok: #15803d;
    --radius: 10px;
    --font: system-ui, "Segoe UI", Roboto, sans-serif;
    --sp-green: #16a34a;
    --sp-green-soft: #dcfce7;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.45;
    padding: 1.25rem 1.5rem 2rem;
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

.top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.top h1 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 650;
}

.top nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.35rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.empty {
    text-align: center;
    padding: 2rem;
    color: var(--muted);
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

label .hint {
    font-weight: 500;
    color: var(--muted);
    font-size: 0.8rem;
}

.readonly-field {
    background: #f1f5f9;
    color: var(--text);
    cursor: default;
}

input[type="text"],
input[type="date"],
input[type="number"],
textarea {
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    background: #fff;
}

textarea {
    resize: vertical;
    min-height: 72px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (max-width: 640px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (max-width: 900px) {
    .grid-3 {
        grid-template-columns: 1fr;
    }
}

.summary-row {
    align-items: end;
}

.totals-preview {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--muted);
}

.totals-preview strong {
    color: var(--text);
}

.items-table--invoice .narrow {
    max-width: 4.5rem;
}

.items-table--invoice .line-amt {
    background: #f8fafc;
}

.section-title {
    font-size: 1rem;
    margin: 1.25rem 0 0.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.35rem;
}

.table-wrap {
    overflow-x: auto;
}

.items-table,
.list-table,
.print-items {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.items-table th,
.items-table td,
.list-table th,
.list-table td {
    border: 1px solid var(--border);
    padding: 0.4rem 0.5rem;
    vertical-align: middle;
}

.items-table thead th {
    background: #eef2f7;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--muted);
}

.items-table .narrow {
    max-width: 5rem;
}

.items-table .num {
    text-align: right;
    max-width: 6rem;
}

.line-num {
    text-align: center;
    width: 2rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.btn-remove {
    border: none;
    background: transparent;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
}
.btn-remove:hover {
    background: #fee2e2;
}

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    text-align: center;
}

.btn.primary {
    background: var(--accent);
    color: #fff;
}
.btn.primary:hover {
    background: var(--accent-hover);
    color: #fff;
    text-decoration: none;
}

.btn.secondary {
    background: #fff;
    color: var(--text);
    border-color: var(--border);
}
.btn.secondary:hover {
    background: #f1f5f9;
    text-decoration: none;
}

.nav-btn {
    padding: 0.4rem 0.85rem;
    font-size: 0.9rem;
}

.actions {
    margin-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
}

.total-line {
    text-align: right;
    margin-top: 0.5rem;
    font-size: 1.05rem;
}

.msg {
    padding: 0.65rem 1rem;
    border-radius: 6px;
    margin: 0 0 1rem;
    font-size: 0.95rem;
}

.msg-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.msg-ok {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.list-table thead th {
    text-align: left;
    background: #eef2f7;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--muted);
}

.list-table .num {
    text-align: right;
}

.actions-cell {
    white-space: nowrap;
}
.actions-cell a {
    margin-right: 0.65rem;
}
.actions-cell a:last-child {
    margin-right: 0;
}

/* —— Printable invoice (Akash-style + selfi petty green) —— */
.print-page--invoice {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.invoice {
    border: 2px solid #111;
    background: #fff;
    color: #111;
    padding: 1rem 1.25rem 1.5rem;
    font-size: 0.88rem;
    line-height: 1.45;
}

/* Issuer (logo + seller) above main header card */
.invoice__issuer {
    text-align: center;
    margin-bottom: 0.85rem;
}

.invoice__issuer-meta {
    margin-top: 0.45rem;
    font-size: 0.82rem;
    color: #444;
    line-height: 1.45;
}

.invoice__issuer-line {
    margin: 0.2rem 0;
}

.invoice__issuer-ids {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem 1.5rem;
    margin: 0.35rem 0 0;
}

.invoice__issuer-ids span {
    white-space: nowrap;
}

/* Bordered header: customer left | challan meta right + green bar */
.invoice__topboard-wrap {
    margin-bottom: 0.85rem;
}

.invoice__topboard {
    display: grid;
    grid-template-columns: 1fr minmax(200px, 38%);
    border: 1px solid #bbb;
    align-items: stretch;
}

.invoice__topboard-left {
    text-align: left;
    padding: 0.65rem 0.85rem;
    border-right: 1px solid #bbb;
}

.invoice__kicker {
    margin: 0 0 0.35rem;
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.invoice__party-name {
    margin: 0 0 0.35rem;
    font-weight: 700;
    font-size: 1rem;
}

.invoice__party-addr,
.invoice__party-line {
    margin: 0.2rem 0;
    font-size: 0.88rem;
}

.invoice__topboard-right {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    min-height: 7rem;
}

.invoice__chcell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.5rem 0.4rem;
    height: 100%;
}

.invoice__chcell--date {
    border-left: 1px solid #bbb;
}

.invoice__chlabel {
    display: block;
    font-size: 0.82rem;
    margin-bottom: 0.35rem;
}

.invoice__chval {
    display: block;
    font-size: 0.95rem;
}

.invoice__topboard-bar {
    height: 5px;
    background: var(--sp-green);
    width: 100%;
}

.invoice__brand {
    margin: 0 0 0.35rem;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--sp-green);
    letter-spacing: 0.02em;
}

.invoice__brand--logo {
    margin: 0 auto 0.5rem;
    font-size: 0;
    line-height: 0;
    font-weight: normal;
    color: transparent;
}

.invoice__logo {
    display: block;
    margin: 0 auto;
    max-width: min(100%, 220px);
    width: auto;
    height: auto;
    vertical-align: top;
}

.invoice__mono {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.invoice__purpose {
    margin: 0 0 0.65rem;
    font-size: 0.88rem;
}

.invoice__table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0 0;
}

.invoice__table th,
.invoice__table td {
    border: 1px solid #111;
    padding: 0.4rem 0.45rem;
    vertical-align: top;
}

.invoice__table thead th {
    background: var(--sp-green-soft);
    color: #14532d;
    font-weight: 700;
    font-size: 0.78rem;
}

.c-sr {
    width: 2rem;
    text-align: center;
}

.c-qty {
    white-space: nowrap;
}

.c-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.invoice__taxpct {
    color: #555;
    font-size: 0.85em;
}

.invoice__empty {
    text-align: center;
    color: #777;
    font-style: italic;
}

.invoice__foot-row td,
.invoice__total-row td,
.invoice__due-row td {
    font-weight: 600;
}

.invoice__total-row {
    background: var(--sp-green-soft);
}

.invoice__total-row .c-num {
    font-weight: 800;
    font-size: 1rem;
}

.invoice__due-row .c-num {
    font-weight: 800;
    color: #b45309;
}

.invoice__foot-label {
    text-align: right;
}

.invoice__transport {
    margin: 0.65rem 0;
    font-size: 0.88rem;
}

.invoice__bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #999;
    align-items: start;
}

.invoice__bottom-title {
    font-weight: 700;
    font-size: 0.82rem;
    margin: 0 0 0.35rem;
    color: #333;
}

.invoice__terms-body {
    font-size: 0.8rem;
    color: #333;
    min-height: 4rem;
}

.invoice__placeholder {
    color: #999;
}

.invoice__sign {
    text-align: right;
}

.invoice__sign-for {
    font-size: 0.85rem;
    margin: 0.5rem 0;
}

.invoice__sign-line {
    border-bottom: 1px solid #111;
    min-height: 2.5rem;
    margin-top: 2rem;
}

@media (max-width: 720px) {
    .invoice__topboard {
        grid-template-columns: 1fr;
    }
    .invoice__topboard-left {
        border-right: none;
        border-bottom: 1px solid #bbb;
    }
    .invoice__bottom {
        grid-template-columns: 1fr;
    }
}

.muted {
    color: var(--muted);
}

.actions-bar {
    margin-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

@media print {
    body.print-page--invoice {
        background: #fff;
        padding: 0;
        max-width: none;
    }
    .invoice {
        border: 1px solid #000;
        padding: 0.5cm;
    }
    .no-print {
        display: none !important;
    }
}
