/* ================================================================
   Sales & Purchase Module — Styles
================================================================ */

/* ── Invoice form layout ─────────────────────────────────────── */
.inv-page { display: flex; flex-direction: column; gap: 0; }

.inv-header {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 14px 14px 0 0;
    padding: 20px 24px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
}

.inv-header--purchase { border-top: 4px solid #7c3aed; }
.inv-header--sales    { border-top: 4px solid #2563eb; }

/* ── Items table ─────────────────────────────────────────────── */
.inv-items-wrapper {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-top: none;
    padding: 0 24px 16px;
}

.inv-items-title {
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    padding: 14px 0 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.inv-items-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.inv-items-table th {
    background: #f8fafc;
    padding: 9px 10px;
    text-align: right;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    font-size: 12px;
}

.inv-items-table td {
    padding: 6px 6px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.inv-items-table tr:hover td { background: #fafbff; }

.inv-items-table input,
.inv-items-table select {
    width: 100%;
    padding: 6px 8px;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    background: #fff;
    color: #1e293b;
    box-sizing: border-box;
    transition: border-color .15s;
    font-family: inherit;
}

.inv-items-table input:focus,
.inv-items-table select:focus {
    outline: none;
    border-color: #3b82f6;
}

.inv-items-table input[type="number"] { text-align: left; }

.inv-line-total {
    font-family: monospace;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    text-align: left;
    min-width: 90px;
    padding-left: 12px !important;
}

/* ── Totals footer ───────────────────────────────────────────── */
.inv-totals {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 14px 14px;
    padding: 16px 24px 20px;
    display: flex;
    justify-content: flex-end;
}

.inv-totals-table {
    min-width: 320px;
    font-size: 13px;
    border-collapse: collapse;
}

.inv-totals-table td {
    padding: 5px 12px;
    color: #475569;
}

.inv-totals-table td:last-child {
    text-align: left;
    font-family: monospace;
    font-weight: 600;
    color: #1e293b;
    min-width: 110px;
}

.inv-totals-table tr.inv-total-main td {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    border-top: 2px solid #e2e8f0;
    padding-top: 10px;
}

.inv-totals-table tr.inv-total-main td:last-child {
    color: #2563eb;
}

/* ── Actions bar ─────────────────────────────────────────────── */
.inv-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    align-items: center;
    flex-wrap: wrap;
}

/* ── Invoice list card ───────────────────────────────────────── */
.invoice-card {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 10px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    transition: border-color .2s;
    cursor: pointer;
}

.invoice-card:hover { border-color: #3b82f6; }

.invoice-card--finalized { border-right: 4px solid #059669; }
.invoice-card--draft     { border-right: 4px solid #f59e0b; }
.invoice-card--cancelled { border-right: 4px solid #ef4444; opacity:.7; }

.invoice-card__no {
    font-family: monospace;
    font-size: 12px;
    color: #94a3b8;
}

.invoice-card__party {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    margin: 2px 0;
}

.invoice-card__date { font-size: 12px; color: #64748b; }

.invoice-card__amount {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    font-family: monospace;
    white-space: nowrap;
}

.invoice-card__actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* ── Summary KPI cards ───────────────────────────────────────── */
.sp-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.sp-kpi {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 18px;
    text-align: center;
}

.sp-kpi__value {
    font-size: 20px;
    font-weight: 800;
    color: #1e293b;
    font-family: monospace;
    margin-bottom: 4px;
}

.sp-kpi__label {
    font-size: 11px;
    color: #64748b;
    font-weight: 600;
}

.sp-kpi--blue   .sp-kpi__value { color: #2563eb; }
.sp-kpi--green  .sp-kpi__value { color: #059669; }
.sp-kpi--orange .sp-kpi__value { color: #d97706; }
.sp-kpi--purple .sp-kpi__value { color: #7c3aed; }

/* ── Section tabs inside Sales/Purchase ──────────────────────── */
.sp-section-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
    padding: 10px 0;
}

.sp-nav-card {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s, transform .15s;
    user-select: none;
    text-align: right;
    min-height: 44px;
}

.sp-nav-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 3px 10px rgba(59,130,246,.12);
    transform: translateY(-1px);
}

.sp-nav-card--active {
    border-color: #2563eb;
    background: #eff6ff;
}

.sp-nav-card__icon {
    font-size: 18px;
    margin-bottom: 0;
    display: block;
    flex-shrink: 0;
    line-height: 1;
}

.sp-nav-card__title {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
    margin: 0;
}

/* ── Entity (customer/supplier/product) card list ────────────── */
.entity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 10px;
}

.entity-card {
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 18px;
    position: relative;
    transition: border-color .2s, box-shadow .2s;
}

.entity-card:hover {
    border-color: #3b82f6;
    box-shadow: 0 3px 12px rgba(59,130,246,.12);
}

.entity-card__code { font-size: 10px; color: #94a3b8; font-family: monospace; }

.entity-card__name {
    font-size: 14px;
    font-weight: 700;
    color: #1e293b;
    margin: 4px 0 8px;
}

.entity-card__meta { font-size: 12px; color: #64748b; line-height: 1.6; }

.entity-card__actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    opacity: 0;
    transition: opacity .15s;
}

.entity-card:hover .entity-card__actions { opacity: 1; }

/* ── Accounting link badge ───────────────────────────────────── */
.acc-link-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #d1fae5;
    color: #065f46;
    border-radius: 8px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
}

/* ── Service accounting section ─────────────────────────────── */
.svc-acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.svc-acc-group { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.svc-acc-group h4 { margin: 0 0 10px; font-size: 13px; color: #1e40af; }
.svc-acc-check { flex-direction: row !important; align-items: center; gap: 8px; }
.svc-acc-hint { margin-top: 16px; padding: 12px; background: #eff6ff; border-radius: 8px; font-size: 12px; color: #1e40af; }
.svc-acc-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.svc-acc-kpi { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px; border-top: 3px solid #3b82f6; }
.svc-acc-kpi span { font-size: 11px; color: #64748b; display: block; }
.svc-acc-kpi b { font-size: 16px; font-weight: 800; }
.svc-acc-split-box { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 16px; margin-top: 12px; }
