/* ============================================================
   BILLING NEW — Clean billing UI styles
   ============================================================ */

/* ── Layout ─────────────────────────────────────────────── */
#view-billing-new {
    padding: 0;
}

.bv2-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 20px 28px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
}

.bv2-header h1 {
    font-size: 1.3rem;
    font-weight: 800;
    color: #1e293b;
    margin: 0;
}

.bv2-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Summary bar ─────────────────────────────────────────── */
#bv2-summary-bar {
    display: flex;
    gap: 12px;
    padding: 14px 28px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
}

.bv2-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 20px;
    min-width: 140px;
    flex: 1;
}

.bv2-stat-num {
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1;
    color: #1e293b;
}

.bv2-stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #64748b;
    letter-spacing: 0.05em;
    margin-top: 4px;
    text-transform: uppercase;
}

.bv2-stat-paid  .bv2-stat-num { color: #059669; }
.bv2-stat-unpaid .bv2-stat-num { color: #dc2626; }
.bv2-stat-money .bv2-stat-num { color: #2563eb; }

/* ── Table container ─────────────────────────────────────── */
.bv2-table-wrap {
    padding: 0 28px 32px;
    overflow-x: auto;
}

/* ── Table ───────────────────────────────────────────────── */
.bv2-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
    margin-top: 0;
}

.bv2-table thead th {
    background: #f8fafc;
    color: #475569;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 10px 14px;
    text-align: left;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.bv2-row {
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.1s;
}

.bv2-row:hover {
    background: #f0f9ff;
}

.bv2-row td {
    padding: 12px 14px;
    vertical-align: middle;
    color: #334155;
}

.bv2-row-outstanding {
    background: #fff7ed;
}

.bv2-row-outstanding:hover {
    background: #fef3c7;
}

.bv2-row-archived {
    background: #f8fafc;
    opacity: 0.72;
}

.bv2-row-archived:hover {
    background: #f1f5f9;
    opacity: 1;
}

.bv2-cust-name {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.88rem;
}

.bv2-cust-addr {
    font-size: 0.73rem;
    color: #94a3b8;
    margin-top: 2px;
}

.bv2-col-amount {
    font-weight: 700;
    font-size: 0.9rem;
    color: #1e293b;
}

.bv2-col-bill {
    color: #6366f1;
    font-weight: 600;
}

.bv2-period-overdue {
    color: #b45309;
    font-weight: 600;
    font-size: 0.78rem;
}

.bv2-period-ok {
    color: #059669;
    font-weight: 500;
    font-size: 0.78rem;
}

.bv2-muted {
    color: #94a3b8;
}

/* ── Badges ──────────────────────────────────────────────── */
.bv2-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.bv2-badge-bacs   { background: #dbeafe; color: #1d4ed8; }
.bv2-badge-square { background: #fef9c3; color: #92400e; }
.bv2-badge-stripe { background: #f3e8ff; color: #6d28d9; }
.bv2-badge-ok     { background: #dcfce7; color: #166534; }

/* ── Shared button styles ────────────────────────────────── */
.bv2-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.83rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    white-space: nowrap;
}

.bv2-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.bv2-btn-primary {
    background: #4f46e5;
    color: #fff;
    box-shadow: 0 2px 6px rgba(79,70,229,0.25);
}

.bv2-btn-primary:hover:not(:disabled) {
    background: #4338ca;
    box-shadow: 0 4px 10px rgba(79,70,229,0.35);
}

.bv2-btn-ghost {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.bv2-btn-ghost:hover:not(:disabled) {
    background: #e2e8f0;
}

.bv2-btn-sm {
    padding: 5px 11px;
    font-size: 0.78rem;
}

.bv2-btn-lg {
    padding: 10px 24px;
    font-size: 0.88rem;
}

/* ── Search / header input ───────────────────────────────── */
.bv2-search {
    height: 34px;
    padding: 0 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.82rem;
    outline: none;
    width: 200px;
    transition: border-color 0.15s;
}

.bv2-search:focus { border-color: #6366f1; }

/* ── Overlay / popup ─────────────────────────────────────── */
.bv2-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    padding: 20px;
}

.bv2-popup {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.bv2-popup-sm {
    max-width: 420px;
}

.bv2-popup-invoice {
    max-width: 620px;
}

/* ── Popup header ────────────────────────────────────────── */
.bv2-popup-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px 20px 16px;
    border-bottom: 1px solid #f1f5f9;
    gap: 12px;
}

.bv2-popup-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
}

.bv2-popup-sub {
    font-size: 0.78rem;
    color: #64748b;
    margin-top: 3px;
}

.bv2-close-btn {
    background: none;
    border: none;
    font-size: 1rem;
    color: #94a3b8;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    line-height: 1;
    flex-shrink: 0;
    transition: background 0.1s;
}

.bv2-close-btn:hover { background: #f1f5f9; color: #334155; }

/* ── Popup body sections ─────────────────────────────────── */
.bv2-section-label {
    padding: 14px 20px 6px;
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #94a3b8;
    text-transform: uppercase;
}

/* ── Breakdown box ───────────────────────────────────────── */
.bv2-breakdown-box {
    margin: 0 20px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

.bv2-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 14px;
    font-size: 0.83rem;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
}

.bv2-line:last-child { border-bottom: none; }

.bv2-line-discount {
    color: #059669;
    font-style: italic;
}

.bv2-breakdown-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    font-weight: 700;
    font-size: 0.9rem;
    color: #1e293b;
    background: #f8fafc;
    border-top: 2px solid #e2e8f0;
}

/* ── Last 3 payments ─────────────────────────────────────── */
.bv2-last3-box {
    margin: 0 20px;
}

.bv2-last3-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.82rem;
    color: #334155;
}

.bv2-last3-row:last-child { border-bottom: none; }

.bv2-last3-amt {
    font-weight: 600;
    margin-left: auto;
}

/* ── Bills list (all bills popup) ────────────────────────── */
.bv2-bills-list {
    padding: 8px 20px 16px;
}

.bv2-bill-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #f1f5f9;
    border-radius: 7px;
    margin-bottom: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    color: #334155;
    transition: background 0.1s;
}

.bv2-bill-item:hover { background: #f0f9ff; border-color: #bae6fd; }

.bv2-bill-date { font-weight: 500; min-width: 80px; }
.bv2-bill-amt  { font-weight: 700; }
.bv2-bill-src  { color: #94a3b8; font-size: 0.75rem; margin-left: auto; }

/* ── Bill meta info (detail popup) ──────────────────────── */
.bv2-bill-meta {
    margin: 10px 20px 16px;
    font-size: 0.76rem;
    color: #64748b;
    line-height: 1.8;
}

.bv2-mono { font-family: monospace; font-size: 0.73rem; }
.bv2-link { color: #6366f1; text-decoration: none; }
.bv2-link:hover { text-decoration: underline; }

/* ── Invoice popup form ──────────────────────────────────── */
.bv2-field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 14px 20px 0;
}

.bv2-date-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    padding: 0 20px;
}

.bv2-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bv2-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.bv2-label-hint {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: #94a3b8;
}

.bv2-input {
    height: 36px;
    padding: 0 10px;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    font-size: 0.82rem;
    outline: none;
    color: #1e293b;
    background: #fff;
    transition: border-color 0.15s;
    width: 100%;
    box-sizing: border-box;
}

.bv2-input:focus { border-color: #6366f1; }

.bv2-textarea {
    height: auto;
    min-height: 60px;
    padding: 8px 10px;
    resize: vertical;
    line-height: 1.4;
}

/* ── Payment method info strip ───────────────────────────── */
.bv2-pay-info {
    margin: 14px 20px 0;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.bv2-pay-bacs   { background: #eff6ff; border: 1px solid #bfdbfe; }
.bv2-pay-square { background: #fefce8; border: 1px solid #fde68a; }

.bv2-pay-warn {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.bv2-pay-warn-title {
    font-weight: 600;
    color: #92400e;
    font-size: 0.82rem;
}

.bv2-pay-warn-actions {
    display: flex;
    gap: 8px;
}

/* ── Status message ──────────────────────────────────────── */
.bv2-status {
    margin: 12px 20px 0;
    padding: 9px 14px;
    border-radius: 7px;
    font-size: 0.82rem;
    font-weight: 600;
}

.bv2-status-ok  { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.bv2-status-err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* ── Popup footer ────────────────────────────────────────── */
.bv2-popup-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 20px;
    gap: 10px;
    border-top: 1px solid #f1f5f9;
    margin-top: 16px;
}

.bv2-footer-left {
    display: flex;
    gap: 8px;
}

.bv2-empty-msg {
    padding: 12px 0;
    color: #94a3b8;
    font-size: 0.82rem;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 680px) {
    .bv2-field-grid,
    .bv2-date-grid {
        grid-template-columns: 1fr;
    }
    .bv2-table-wrap { padding: 0 12px 32px; }
    .bv2-header { padding: 14px 12px; }
    #bv2-summary-bar { padding: 12px; }
}
