/* ==========================================================
   Kazi — Base Styles
   ========================================================== */
:root {
    --bg:        #0f172a;
    --bg-soft:   #1e293b;
    --card:      #ffffff;
    --text:      #0f172a;
    --muted:     #64748b;
    --border:    #e2e8f0;
    --primary:   #4f46e5;
    --primary-h: #4338ca;
    --ok:        #16a34a;
    --fail:      #dc2626;
    --radius:    12px;
    --shadow:    0 10px 25px rgba(15, 23, 42, 0.15);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(1200px 600px at 20% -10%, #1e293b 0%, transparent 60%),
        radial-gradient(900px 500px at 110% 110%, #312e81 0%, transparent 55%),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 28px;
}

.auth-header { text-align: center; margin-bottom: 24px; }

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.brand-mark {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 700;
    font-size: 18px;
}

.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.2px; }

.auth-header h1 {
    margin: 0 0 4px;
    font-size: 22px;
    letter-spacing: -0.3px;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }

.auth-form { display: grid; gap: 14px; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: #334155; }

.field input[type="email"],
.field input[type="password"],
.field input[type="text"] {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}

.row-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}

.check { display: inline-flex; align-items: center; gap: 6px; color: #334155; }

.link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
.link:hover { text-decoration: underline; }

.btn-primary {
    margin-top: 6px;
    padding: 11px 14px;
    border: none;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .05s;
}
.btn-primary:hover { background: var(--primary-h); }
.btn-primary:active { transform: translateY(1px); }

.auth-footer { margin-top: 22px; text-align: center; }

.dev-badge {
    position: fixed;
    bottom: 12px; right: 12px;
    background: #111827;
    color: #e5e7eb;
    font-size: 12px;
    line-height: 1.5;
    padding: 10px 12px;
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(0,0,0,.35);
    max-width: 320px;
    word-break: break-word;
}
.dev-badge .ok   { color: #4ade80; }
.dev-badge .fail { color: #f87171; }

.error-page {
    color: #fff;
    text-align: center;
    padding: 60px 20px;
}
.error-page h1 { font-size: 48px; margin: 0; }
.error-page p  { color: #94a3b8; }
.error-page code {
    background: rgba(255,255,255,.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
}

/* ══════════════════════════════════════════
   Alerts
   ══════════════════════════════════════════ */
.alert {
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}
.alert-success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}
.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}
.alert-info {
    background: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

/* ══════════════════════════════════════════
   App shell (post-login pages)
   ══════════════════════════════════════════ */
.app-body {
    background: #f8fafc;
    color: #0f172a;
    min-height: 100vh;
}
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
}
.app-header .brand { margin-bottom: 0; }
.app-nav { display: flex; align-items: center; gap: 16px; }

.btn-link {
    background: none;
    border: none;
    color: #4f46e5;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 6px;
}
.btn-link:hover { background: #eef2ff; }

.app-main {
    flex: 1 1 auto;
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 28px 120px;
    min-height: calc(100vh - 64px - 60px);
    box-sizing: border-box;
}
.app-main h1 { font-size: 28px; margin: 0 0 6px; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 28px;
}
.card {
    display: block;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, transform .1s;
}
.card:hover {
    border-color: #4f46e5;
    transform: translateY(-2px);
}
.card h3 { margin: 0 0 6px; font-size: 16px; }
.card p { margin: 0; font-size: 13px; }

/* ══════════════════════════════════════════
   Setup wizard
   ══════════════════════════════════════════ */
.setup-card {
    max-width: 560px;
}
.setup-step {
    margin-top: 28px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
}
.setup-step h2 {
    font-size: 15px;
    margin: 0 0 6px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #334155;
}
.setup-step > form {
    margin-top: 14px;
}
.setup-step details summary {
    cursor: pointer;
    color: #991b1b;
    margin-top: 8px;
}

/* ══════════════════════════════════════════
   Layout shell — fixed sidebar / sticky header / fixed footer
   ══════════════════════════════════════════ */
html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* Layout pages (dashboard, invoices, etc.) use a light background */
body.layout-body {
    background: #f8fafc;
}

.layout-body {
    display: block;
    min-height: 100vh;
    background: #f8fafc;      /* ← make sure this is light, not dark */
    color: #0f172a;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow-x: hidden;
}

/* ──────── Sidebar (fixed left, full height) ──────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    background: #0f172a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    z-index: 30;
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid #1e293b;
    flex-shrink: 0;
}
.sidebar-brand .brand-mark {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: #4f46e5;
    display: grid; place-items: center;
    color: #fff;
    font-weight: 700;
    flex-shrink: 0;
}
.sidebar-brand .brand-name {
    color: #fff;
    font-weight: 700;
    font-size: 16px;
}
.sidebar-tenant {
    padding: 16px 20px;
    background: #1e293b;
    flex-shrink: 0;
}
.sidebar-tenant .tenant-name {
    font-weight: 600;
    color: #fff;
    font-size: 14px;
    margin-bottom: 2px;
}
.sidebar-tenant .tenant-plan {
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.sidebar-nav {
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1 1 auto;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    transition: background .12s, color .12s;
}
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: #4f46e5; color: #fff; }
.nav-icon { width: 18px; text-align: center; opacity: .8; }
.nav-divider { height: 1px; background: #1e293b; margin: 8px 0; }

/* Sidebar footer pinned to bottom */
.sidebar-footer {
    flex-shrink: 0;
    padding: 14px 20px;
    border-top: 1px solid #1e293b;
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.5;
}
.sidebar-footer .muted-tiny {
    display: block;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: 10px;
    margin-bottom: 2px;
}
.dev-credit {
    color: #a5b4fc;
    text-decoration: none;
    font-weight: 600;
    transition: color .15s;
}
.dev-credit:hover { color: #c7d2fe; text-decoration: underline; }

/* ──────── Main wrapper (offset for fixed sidebar) ──────── */
.main-wrap {
    margin-left: 240px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* ──────── Sticky header at top of main ──────── */
.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.app-header-title { font-weight: 600; font-size: 15px; color: #0f172a; }
.app-header-user { display: flex; align-items: center; gap: 14px; }

/* ──────── Scrollable main content ──────── */
.app-main {
    flex: 1 1 auto;
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 28px 96px;   /* bottom padding = footer height + breathing room */
}

/* ──────── Fixed footer at bottom of viewport ──────── */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 240px;              /* offset for sidebar */
    right: 0;
    z-index: 20;

    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
    font-size: 12px;
    color: #64748b;
    gap: 12px;
    flex-wrap: wrap;
}
.app-footer strong { color: #334155; }
.app-footer .dev-credit { color: #4f46e5; }

/* ──────── Responsive: stack on mobile ──────── */
@media (max-width: 900px) {
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }
    .sidebar-brand { border-bottom: none; padding: 12px 16px; }
    .sidebar-tenant { display: none; }
    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 8px 12px;
        width: 100%;
    }
    .nav-divider { display: none; }
    .sidebar-footer { display: none; }

    .main-wrap { margin-left: 0; }

    .app-footer {
        position: static;
        margin-top: auto;
    }
    .app-main { padding-bottom: 32px; }
}

/* ══════════════════════════════════════════
   Settings form
   ══════════════════════════════════════════ */
.settings-form {
    margin-top: 24px;
    max-width: 900px;
}
.settings-section {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 22px 24px;
    margin-bottom: 20px;
}
.settings-section h2 {
    margin: 0 0 16px;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #334155;
}
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px 20px;
}
.field select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    font-size: 14px;
    background: #fff;
    color: #0f172a;
}
.field select:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
    outline: none;
}
.field small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
}
.form-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
}

/* ══════════════════════════════════════════
   Sidebar footer (developer credit)
   ══════════════════════════════════════════ */
.sidebar-footer {
    margin-top: auto;
    padding: 14px 20px;
    border-top: 1px solid #1e293b;
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.5;
}
.sidebar-footer .muted-tiny {
    display: block;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: 10px;
    margin-bottom: 2px;
}
.dev-credit {
    color: #a5b4fc;
    text-decoration: none;
    font-weight: 600;
    transition: color .15s;
}
.dev-credit:hover {
    color: #c7d2fe;
    text-decoration: underline;
}

/* ══════════════════════════════════════════
   App footer (page bottom)
   ══════════════════════════════════════════ */
.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    border-top: 1px solid #e2e8f0;
    background: #ffffff;
    font-size: 12px;
    color: #64748b;
    gap: 12px;
    flex-wrap: wrap;
}
.app-footer strong {
    color: #334155;
}
.app-footer .dev-credit {
    color: #4f46e5;
}

/* Fix: make the main content area flexible so footer sticks to bottom */
.main-wrap {
    min-height: 100vh;
}
.app-main {
    flex: 1;
    max-width: 1080px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 28px 40px;
}

/* Small screens: stack footer */
@media (max-width: 640px) {
    .app-footer {
        flex-direction: column;
        text-align: center;
    }
}

/* ══════════════════════════════════════════
   Page header (title + action button)
   ══════════════════════════════════════════ */
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.page-head h1 {
    font-size: 24px;
    margin: 0 0 4px;
}
.page-head p {
    margin: 0;
}
.btn-inline {
    display: inline-block;
    text-decoration: none;
    padding: 10px 16px;
    border-radius: 10px;
}

/* ══════════════════════════════════════════
   Data table
   ══════════════════════════════════════════ */
.table-wrap {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table th,
.data-table td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
}
.data-table th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #64748b;
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table td.right,
.data-table th.right { text-align: right; }

/* ══════════════════════════════════════════
   Badges
   ══════════════════════════════════════════ */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    background: #e2e8f0;
    color: #334155;
}
.badge-soft { background: #ede9fe; color: #4f46e5; }
.badge-ok   { background: #dcfce7; color: #166534; }
.badge-off  { background: #fee2e2; color: #991b1b; }

.badge-role-owner      { background: #ede9fe; color: #4f46e5; }
.badge-role-admin      { background: #dbeafe; color: #1e40af; }
.badge-role-accountant { background: #dcfce7; color: #166534; }
.badge-role-sales      { background: #fef3c7; color: #92400e; }
.badge-role-hr         { background: #fce7f3; color: #9d174d; }
.badge-role-staff      { background: #e2e8f0; color: #334155; }

/* ══════════════════════════════════════════
   Row actions
   ══════════════════════════════════════════ */
.row-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-end;
}
.row-actions .btn-link {
    font-size: 13px;
    padding: 4px 8px;
    text-decoration: none;
}
.row-actions .btn-link.danger { color: #dc2626; }
.row-actions .btn-link.danger:hover { background: #fee2e2; }

/* Form buttons layout */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 4px;
}
.form-actions .btn-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

/* ══════════════════════════════════════════
   KPI cards
   ══════════════════════════════════════════ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 20px;
}
.kpi-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #64748b;
    margin-bottom: 6px;
}
.kpi-value {
    font-size: 22px;
    font-weight: 700;
    color: #0f172a;
}
.kpi-value.kpi-ok   { color: #16a34a; }
.kpi-value.kpi-warn { color: #d97706; }
.kpi-value.kpi-bad  { color: #dc2626; }

/* ══════════════════════════════════════════
   Filter bar
   ══════════════════════════════════════════ */
.filter-bar {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 20px;
}
.filter-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}
.filter-row input[type="text"],
.filter-row input[type="date"],
.filter-row select {
    padding: 9px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    min-width: 140px;
}
.filter-row input[type="text"] { flex: 1; min-width: 200px; }

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}

/* ══════════════════════════════════════════
   Empty state
   ══════════════════════════════════════════ */
.empty-state {
    background: #fff;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    text-align: center;
    padding: 40px 20px;
}
.empty-state p { color: #64748b; margin: 0 0 16px; }

/* ══════════════════════════════════════════
   Pagination
   ══════════════════════════════════════════ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
    padding: 12px;
}

/* ══════════════════════════════════════════
   Status badges
   ══════════════════════════════════════════ */
.badge-inv-draft   { background: #e2e8f0; color: #334155; }
.badge-inv-sent    { background: #dbeafe; color: #1e40af; }
.badge-inv-partial { background: #fef3c7; color: #92400e; }
.badge-inv-paid    { background: #dcfce7; color: #166534; }
.badge-inv-overdue { background: #fee2e2; color: #991b1b; }
.badge-inv-void    { background: #f1f5f9; color: #64748b; }

.text-danger { color: #dc2626; }

/* ══════════════════════════════════════════
   Invoice detail
   ══════════════════════════════════════════ */
.invoice-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    align-items: start;
}
@media (max-width: 900px) {
    .invoice-grid { grid-template-columns: 1fr; }
}

.invoice-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 28px;
}
.invoice-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e2e8f0;
}
.invoice-header .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #64748b;
    margin-bottom: 6px;
}
.invoice-header .value { font-size: 14px; line-height: 1.6; }
.invoice-header .right { text-align: right; }

.invoice-items {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.invoice-items th,
.invoice-items td {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
}
.invoice-items th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #64748b;
    background: #f8fafc;
}
.invoice-items th.right,
.invoice-items td.right { text-align: right; }
.invoice-items tfoot td {
    border-bottom: none;
    padding: 6px 12px;
}
.invoice-items .total-row td {
    padding-top: 12px;
    font-size: 16px;
    border-top: 2px solid #0f172a;
}
.invoice-items .balance-row td {
    font-size: 15px;
    color: #4f46e5;
}

.invoice-notes {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}
.invoice-notes .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #64748b;
    margin-bottom: 6px;
}

/* ══════════════════════════════════════════
   Payments sidebar
   ══════════════════════════════════════════ */
.payments-side {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
}
.payments-side h2 {
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #334155;
    margin: 0 0 12px;
}
.payments-side h3 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #334155;
    margin: 20px 0 10px;
}
.payment-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.payment-list li {
    padding: 10px 0;
    border-bottom: 1px solid #e2e8f0;
}
.payment-list li:last-child { border-bottom: none; }

.payment-form { display: grid; gap: 10px; }
.payment-form .field span { font-size: 12px; }

/* ══════════════════════════════════════════
   Invoice form (dynamic items)
   ══════════════════════════════════════════ */
.invoice-form { max-width: 1100px; }

.items-table {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}
.items-head,
.item-row {
    display: grid;
    grid-template-columns: 3fr 70px 130px 90px 130px 40px;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
}
.items-head {
    background: #f8fafc;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #64748b;
    font-weight: 600;
}
.item-row {
    border-top: 1px solid #e2e8f0;
}
.item-row input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
}
.item-row input:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
    outline: none;
}
.line-total {
    text-align: right;
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
}
.btn-remove {
    background: none;
    border: none;
    color: #dc2626;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 6px;
}
.btn-remove:hover { color: #991b1b; }

/* ══════════════════════════════════════════
   Invoice form totals card (top of form)
   ══════════════════════════════════════════ */
.invoice-totals-card {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin: 0 0 24px;
    padding: 16px 20px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.invoice-totals-card .total-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.invoice-totals-card .total-cell .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #64748b;
    font-weight: 600;
}
.invoice-totals-card .total-cell .value {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}
.invoice-totals-card .total-cell.grand-total .value {
    color: #4f46e5;
    font-size: 22px;
}

/* Responsive: stack on narrow */
@media (max-width: 640px) {
    .invoice-totals-card {
        grid-template-columns: 1fr;
    }
}

/* ══════════════════════════════════════════
   Payment rows (invoice detail sidebar)
   ══════════════════════════════════════════ */
.payment-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}
.btn-xs {
    font-size: 14px;
    line-height: 1;
    padding: 2px 8px;
    border-radius: 6px;
}
.btn-xs.danger {
    color: #dc2626;
}
.btn-xs.danger:hover {
    background: #fee2e2;
}

/* ══════════════════════════════════════════
   Overdue row highlighting
   ══════════════════════════════════════════ */
.row-overdue {
    background: #fff8f8;         /* very subtle red tint */
}
.row-overdue:hover {
    background: #fef2f2;         /* stronger on hover */
}
.row-overdue td:first-child {
    border-left: 3px solid #dc2626;
    padding-left: 13px;          /* compensate for border */
}

/* Small red badge next to invoice number */
.badge-overdue-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 6px;
    border-radius: 50%;
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 0;
    vertical-align: middle;
}

/* "X days overdue" small text under the date */
.overdue-label {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    color: #dc2626;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-top: 2px;
}

/* Balance column emphasis */
.text-bold {
    font-weight: 700;
    color: #0f172a;
}
.text-muted {
    color: #94a3b8;
}