/* ==========================================================
   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;
}

/* ══════════════════════════════════════════
   Contact chips (summary filter)
   ══════════════════════════════════════════ */
.chip-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid #e2e8f0;
    font-size: 13px;
    color: #334155;
    text-decoration: none;
    transition: background .12s, border-color .12s, color .12s;
}
.chip:hover { border-color: #cbd5e1; }
.chip.active {
    background: #4f46e5;
    border-color: #4f46e5;
    color: #fff;
}
.chip-count {
    background: #f1f5f9;
    color: #475569;
    border-radius: 999px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}
.chip.active .chip-count {
    background: rgba(255,255,255,.2);
    color: #fff;
}

/* Type badges */
.badge-type-customer { background: #dcfce7; color: #166534; }
.badge-type-prospect { background: #fef3c7; color: #92400e; }
.badge-type-supplier { background: #dbeafe; color: #1e40af; }
.badge-type-both     { background: #ede9fe; color: #4f46e5; }

/* Tag pills */
.tag-pill {
    display: inline-block;
    padding: 2px 8px;
    margin: 2px 3px 2px 0;
    font-size: 11px;
    background: #f1f5f9;
    color: #475569;
    border-radius: 999px;
    font-weight: 500;
}

/* ══════════════════════════════════════════
   Contact detail layout
   ══════════════════════════════════════════ */
.contact-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}
@media (max-width: 900px) {
    .contact-grid { grid-template-columns: 1fr; }
}

.contact-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.contact-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    color: #0f172a;
    text-decoration: none;
    transition: border-color .12s, transform .08s;
}
.contact-action:hover {
    border-color: #4f46e5;
    transform: translateY(-1px);
}
.ca-icon {
    color: #4f46e5;
    font-weight: 700;
    font-size: 15px;
}

/* Detail grid */
.detail-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px 16px;
    font-size: 14px;
}
.detail-row { display: contents; }
.detail-label {
    color: #64748b;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding-top: 3px;
}
.detail-value { color: #0f172a; line-height: 1.5; }
.detail-notes {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}
.detail-notes .detail-label { margin-bottom: 6px; }

/* Timeline */
.timeline {
    list-style: none;
    padding: 0;
    margin: 0;
}
.timeline-item {
    padding: 14px 0;
    border-bottom: 1px solid #e2e8f0;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.timeline-body {
    font-size: 14px;
    color: #334155;
    line-height: 1.55;
}

/* Note type badges */
.badge-note-note    { background: #e2e8f0; color: #334155; }
.badge-note-call    { background: #dbeafe; color: #1e40af; }
.badge-note-email   { background: #fef3c7; color: #92400e; }
.badge-note-meeting { background: #ede9fe; color: #4f46e5; }
.badge-note-task    { background: #ffedd5; color: #c2410c; }
.badge-note-sms     { background: #dcfce7; color: #166534; }

/* Note form spacing */
.note-form { display: grid; gap: 12px; }

/* Invoice mini list */
.invoice-mini-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.invoice-mini-list li {
    padding: 10px 0;
    border-bottom: 1px solid #e2e8f0;
}
.invoice-mini-list li:last-child { border-bottom: none; }

/* Contact picker (invoice form) */
#contact-picker {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    background: #fff;
    color: #0f172a;
}
#contact-picker:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
    outline: none;
}

/* ══════════════════════════════════════════
   Product type badges
   ══════════════════════════════════════════ */
.badge-prod-product { background: #dbeafe; color: #1e40af; }
.badge-prod-service { background: #fce7f3; color: #9d174d; }

/* ══════════════════════════════════════════
   Product type toggle (create form)
   ══════════════════════════════════════════ */
.type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 640px) {
    .type-toggle { grid-template-columns: 1fr; }
}

.type-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    background: #fff;
    transition: border-color .15s, background .15s;
}
.type-option:hover {
    border-color: #cbd5e1;
}
.type-option.selected {
    border-color: #4f46e5;
    background: #eef2ff;
}
.type-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.type-icon {
    font-size: 22px;
    color: #4f46e5;
    width: 32px;
    text-align: center;
}
.type-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.type-label strong {
    font-size: 14px;
    color: #0f172a;
}
.type-label small {
    font-size: 12px;
    color: #64748b;
}

/* ══════════════════════════════════════════
   Row warning (low stock)
   ══════════════════════════════════════════ */
.row-warn {
    background: #fffbeb;
}
.row-warn:hover {
    background: #fef3c7;
}

/* ══════════════════════════════════════════
   Inline checkbox (filter bar)
   ══════════════════════════════════════════ */
.check-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #334155;
    padding: 0 4px;
}

/* ══════════════════════════════════════════
   Items table with product picker
   ══════════════════════════════════════════ */
.items-head,
.item-row {
    display: grid;
    grid-template-columns: 1.4fr 2fr 60px 100px 70px 100px 36px;
    gap: 6px;
    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,
.item-row select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    color: #0f172a;
}
.item-row select.item-product-picker {
    background: #f8fafc;
}
.item-row input:focus,
.item-row select:focus {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
    outline: none;
}

@media (max-width: 900px) {
    .items-head { display: none; }
    .item-row {
        grid-template-columns: 1fr 1fr;
        grid-auto-rows: auto;
    }
    .item-row .col-product,
    .item-row .col-desc { grid-column: span 2; }
    .item-row .col-total { grid-column: span 1; text-align: left; }
}

/* ══════════════════════════════════════════
   Dashboard — KPI tiles
   ══════════════════════════════════════════ */
.dash-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin: 24px 0;
}
.dash-tile {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 18px 20px;
    transition: border-color .15s, transform .08s;
}
.dash-tile:hover {
    border-color: #cbd5e1;
    transform: translateY(-1px);
}
.dash-tile-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 6px;
}
.dash-tile-value {
    font-size: 22px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
    margin-bottom: 6px;
}
.dash-tile-value.kpi-ok   { color: #16a34a; }
.dash-tile-value.kpi-warn { color: #d97706; }
.dash-tile-value.kpi-bad  { color: #dc2626; }
.dash-tile-sub {
    font-size: 12px;
    color: #64748b;
}

/* ══════════════════════════════════════════
   Dashboard — sections
   ══════════════════════════════════════════ */
.dash-section {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 22px 24px;
    margin-bottom: 20px;
}
.dash-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}
.dash-section-head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.dash-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
@media (max-width: 900px) {
    .dash-grid-2 { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════
   Revenue chart
   ══════════════════════════════════════════ */
.chart-wrap {
    width: 100%;
}
.revenue-chart {
    width: 100%;
    height: 160px;
    display: block;
}
.chart-labels {
    display: flex;
    justify-content: space-between;
    padding: 6px 20px 0;
    gap: 4px;
}
.chart-label {
    font-size: 10px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .04em;
    flex: 1;
    text-align: center;
}

/* ══════════════════════════════════════════
   Compact tables (dashboard)
   ══════════════════════════════════════════ */
.data-table.compact th,
.data-table.compact td {
    padding: 8px 10px;
    font-size: 13px;
}

/* ══════════════════════════════════════════
   Overdue list
   ══════════════════════════════════════════ */
.overdue-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.overdue-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
    gap: 12px;
}
.overdue-list li:last-child { border-bottom: none; }
.overdue-list .right { text-align: right; }

/* ══════════════════════════════════════════
   Activity feed
   ══════════════════════════════════════════ */
.activity-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.activity-list li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
}
.activity-list li:last-child { border-bottom: none; }
.act-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 3px 8px;
    border-radius: 6px;
    white-space: nowrap;
    margin-top: 2px;
}
.act-invoice { background: #dbeafe; color: #1e40af; }
.act-payment { background: #dcfce7; color: #166534; }
.act-body { flex: 1; min-width: 0; font-size: 13px; }
.act-time { white-space: nowrap; }

/* ══════════════════════════════════════════
   Quick actions
   ══════════════════════════════════════════ */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}
.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    text-decoration: none;
    color: #0f172a;
    text-align: center;
    transition: background .12s, border-color .12s, transform .08s;
}
.quick-action:hover {
    background: #eef2ff;
    border-color: #4f46e5;
    transform: translateY(-2px);
}
.qa-icon {
    font-size: 24px;
    color: #4f46e5;
    line-height: 1;
}
.qa-label {
    font-size: 13px;
    font-weight: 600;
}

/* ══════════════════════════════════════════
   Alert-tinted sections
   ══════════════════════════════════════════ */
.dash-alert {
    border-color: #fecaca;
    background: #fffafa;
}

/* ══════════════════════════════════════════
   Reports — tabs
   ══════════════════════════════════════════ */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 0;
}
.tab {
    padding: 10px 16px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: color .12s, border-color .12s;
}
.tab:hover {
    color: #334155;
}
.tab.active {
    color: #4f46e5;
    border-bottom-color: #4f46e5;
}

/* Filter bar labels */
.filter-label {
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-right: 4px;
}

/* tfoot rows (report totals) */
.data-table tfoot td {
    padding: 12px 16px;
    background: #f8fafc;
    border-top: 2px solid #cbd5e1;
    font-size: 13px;
}
.data-table tfoot .total-row td {
    background: #f1f5f9;
    font-size: 14px;
}

/* Small button variant for quick ranges */
.btn-xs {
    font-size: 12px;
    padding: 4px 8px;
}

/* ══════════════════════════════════════════
   Plan badges (agency panel)
   ══════════════════════════════════════════ */
.badge-plan-starter { background: #f1f5f9; color: #475569; }
.badge-plan-basic   { background: #dbeafe; color: #1e40af; }
.badge-plan-pro     { background: #ede9fe; color: #4f46e5; }
.badge-plan-agency  { background: #fce7f3; color: #9d174d; }

/* ══════════════════════════════════════════
   Impersonation banner
   ══════════════════════════════════════════ */
.impersonate-bar {
    background: linear-gradient(90deg, #7c2d12 0%, #dc2626 100%);
    color: #fff;
    padding: 10px 20px;
    font-size: 13px;
    z-index: 100;
}
.impersonate-bar-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}
.impersonate-icon {
    font-size: 16px;
    animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.impersonate-bar code {
    background: rgba(255,255,255,.15);
    padding: 1px 6px;
    border-radius: 4px;
}
.impersonate-stop {
    background: #fff;
    color: #dc2626;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: .04em;
    transition: background .12s;
}
.impersonate-stop:hover {
    background: #fee2e2;
}

/* Push layout down when banner is present */
body.has-impersonation-banner .sidebar {
    top: 44px;
    height: calc(100vh - 44px);
}
body.has-impersonation-banner .main-wrap {
    padding-top: 44px;
}

/* ══════════════════════════════════════════
   Inline forms (agency — change plan)
   ══════════════════════════════════════════ */
.inline-form {
    margin: 0;
}
.inline-select {
    padding: 9px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    min-width: 160px;
}

/* ══════════════════════════════════════════
   Danger zone
   ══════════════════════════════════════════ */
.danger-zone {
    border-color: #fecaca;
    background: #fffafa;
}
.danger-zone h2 {
    color: #991b1b;
}
.danger-details {
    margin-top: 14px;
}
.danger-details > summary {
    cursor: pointer;
    color: #dc2626;
    font-weight: 600;
    font-size: 13px;
    padding: 6px 0;
}
.danger-details > summary:hover {
    color: #991b1b;
}
.danger-details .field {
    max-width: 300px;
}
.danger-details .field code {
    background: #fef2f2;
    padding: 1px 5px;
    border-radius: 4px;
    color: #991b1b;
}
.danger-btn {
    background: #dc2626 !important;
}
.danger-btn:hover {
    background: #991b1b !important;
}

/* ══════════════════════════════════════════
   Warning flash style
   ══════════════════════════════════════════ */
.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}

/* ══════════════════════════════════════════
   Employee badges
   ══════════════════════════════════════════ */
.badge-emp-full_time { background: #dcfce7; color: #166534; }
.badge-emp-part_time { background: #fef3c7; color: #92400e; }
.badge-emp-contract  { background: #dbeafe; color: #1e40af; }
.badge-emp-intern    { background: #ede9fe; color: #4f46e5; }
.badge-emp-casual    { background: #f1f5f9; color: #475569; }

.badge-emp-status-active     { background: #dcfce7; color: #166534; }
.badge-emp-status-on_leave   { background: #fef3c7; color: #92400e; }
.badge-emp-status-terminated { background: #fee2e2; color: #991b1b; }
.badge-emp-status-resigned   { background: #f1f5f9; color: #64748b; }

/* ══════════════════════════════════════════
   Attendance badges
   ══════════════════════════════════════════ */
.badge-att-work     { background: #dcfce7; color: #166534; }
.badge-att-leave    { background: #dbeafe; color: #1e40af; }
.badge-att-holiday  { background: #fef3c7; color: #92400e; }
.badge-att-absent   { background: #fee2e2; color: #991b1b; }
.badge-att-half_day { background: #ede9fe; color: #4f46e5; }

/* ══════════════════════════════════════════
   Leave status badges
   ══════════════════════════════════════════ */
.badge-leave-pending   { background: #fef3c7; color: #92400e; }
.badge-leave-approved  { background: #dcfce7; color: #166534; }
.badge-leave-rejected  { background: #fee2e2; color: #991b1b; }
.badge-leave-cancelled { background: #f1f5f9; color: #64748b; }

/* ══════════════════════════════════════════
   Clock-in grid (today's status)
   ══════════════════════════════════════════ */
.clock-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}
.clock-card {
    padding: 14px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    transition: border-color .12s;
}
.clock-card.clock-in {
    border-color: #86efac;
    background: #f0fdf4;
}
.clock-card.clock-out {
    background: #f8fafc;
}
.clock-name {
    font-weight: 600;
    font-size: 14px;
    color: #0f172a;
    margin-bottom: 2px;
}
.clock-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}
.clock-card form { margin: 0; }

/* ══════════════════════════════════════════
   Leave balance cards
   ══════════════════════════════════════════ */
.balance-card {
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-left-width: 4px;
    border-radius: 10px;
    background: #fff;
}
.balance-name {
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 6px;
}
.balance-numbers {
    font-size: 14px;
    color: #334155;
}
.balance-numbers strong {
    font-size: 22px;
    color: #0f172a;
}

/* ══════════════════════════════════════════
   Color input
   ══════════════════════════════════════════ */
.field input[type="color"] {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
}

/* ══════════════════════════════════════════
   Payroll status badges
   ══════════════════════════════════════════ */
.badge-pr-draft     { background: #f1f5f9; color: #475569; }
.badge-pr-approved  { background: #dbeafe; color: #1e40af; }
.badge-pr-paid      { background: #dcfce7; color: #166534; }
.badge-pr-cancelled { background: #fee2e2; color: #991b1b; }

/* ══════════════════════════════════════════
   Payroll table (wider columns)
   ══════════════════════════════════════════ */
.payroll-table th,
.payroll-table td {
    padding: 8px 10px;
    font-size: 13px;
    white-space: nowrap;
}
.payroll-table th.right,
.payroll-table td.right { text-align: right; }

/* ══════════════════════════════════════════
   Profit & Loss table
   ══════════════════════════════════════════ */
.pnl-table td {
    padding: 10px 16px;
    font-size: 14px;
}
.pnl-table .pnl-section td {
    background: #f8fafc;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #64748b;
    padding-top: 14px;
    padding-bottom: 6px;
}
.pnl-table .pnl-total td {
    border-top: 1px solid #cbd5e1;
    padding-top: 10px;
}
.pnl-table .pnl-final td {
    border-top: 2px solid #0f172a;
    padding-top: 14px;
    padding-bottom: 14px;
    font-size: 15px;
}
.pnl-table .pnl-profit td {
    background: #f0fdf4;
    color: #166534;
}
.pnl-table .pnl-loss td {
    background: #fef2f2;
    color: #991b1b;
}

/* ══════════════════════════════════════════
   Expense category badges
   ══════════════════════════════════════════ */
.badge-exp-salaries     { background: #ede9fe; color: #4f46e5; }
.badge-exp-rent         { background: #fce7f3; color: #9d174d; }
.badge-exp-utilities    { background: #fef3c7; color: #92400e; }
.badge-exp-supplies     { background: #dcfce7; color: #166534; }
.badge-exp-marketing    { background: #dbeafe; color: #1e40af; }
.badge-exp-travel       { background: #e0f2fe; color: #075985; }
.badge-exp-taxes        { background: #fee2e2; color: #991b1b; }
.badge-exp-bank_fees    { background: #f1f5f9; color: #475569; }
.badge-exp-professional { background: #f3e8ff; color: #6b21a8; }
.badge-exp-other        { background: #e2e8f0; color: #334155; }

/* ══════════════════════════════════════════
   Project status badges
   ══════════════════════════════════════════ */
.badge-proj-planning  { background: #f1f5f9; color: #475569; }
.badge-proj-active    { background: #dcfce7; color: #166534; }
.badge-proj-on_hold   { background: #fef3c7; color: #92400e; }
.badge-proj-completed { background: #dbeafe; color: #1e40af; }
.badge-proj-cancelled { background: #fee2e2; color: #991b1b; }

/* ══════════════════════════════════════════
   Milestones
   ══════════════════════════════════════════ */
.milestone-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.milestone-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}
.milestone-item:last-child { border-bottom: none; }
.milestone-item.done .milestone-body strong {
    text-decoration: line-through;
    color: #94a3b8;
}
.milestone-check {
    flex-shrink: 0;
    padding-top: 2px;
}
.btn-toggle-done {
    width: 22px;
    height: 22px;
    border: 2px solid #cbd5e1;
    border-radius: 5px;
    background: #fff;
    color: #16a34a;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: grid;
    place-items: center;
    transition: border-color .12s, background .12s;
}
.btn-toggle-done:hover {
    border-color: #4f46e5;
}
.milestone-item.done .btn-toggle-done {
    background: #dcfce7;
    border-color: #16a34a;
}
.milestone-body {
    flex: 1;
    min-width: 0;
    font-size: 13px;
}
.milestone-item form { margin: 0; }

/* ══════════════════════════════════════════
   Task priority badges
   ══════════════════════════════════════════ */
.badge-pri-low    { background: #f1f5f9; color: #475569; }
.badge-pri-normal { background: #dbeafe; color: #1e40af; }
.badge-pri-high   { background: #fef3c7; color: #92400e; }
.badge-pri-urgent { background: #fee2e2; color: #991b1b; }

/* Task status badges */
.badge-task-todo        { background: #f1f5f9; color: #475569; }
.badge-task-in_progress { background: #fef3c7; color: #92400e; }
.badge-task-review      { background: #dbeafe; color: #1e40af; }
.badge-task-done        { background: #dcfce7; color: #166534; }
.badge-task-cancelled   { background: #e2e8f0; color: #64748b; }

/* ══════════════════════════════════════════
   Task checkbox (inline complete)
   ══════════════════════════════════════════ */
.task-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid #cbd5e1;
    border-radius: 5px;
    background: #fff;
    color: #16a34a;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: grid;
    place-items: center;
    transition: border-color .12s, background .12s;
}
.task-checkbox:hover {
    border-color: #4f46e5;
}
.task-checkbox.checked {
    background: #dcfce7;
    border-color: #16a34a;
}
tr.task-done td a strong {
    text-decoration: line-through;
    color: #94a3b8;
}

/* ══════════════════════════════════════════
   Compact task list (on project page)
   ══════════════════════════════════════════ */
.task-compact-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.task-compact {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}
.task-compact:last-child {
    border-bottom: none;
}
.task-compact.done .task-compact-body strong {
    text-decoration: line-through;
    color: #94a3b8;
}
.task-compact-body {
    flex: 1;
    min-width: 0;
    font-size: 13px;
}
.task-compact-badges {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.task-compact form { margin: 0; }

/* ══════════════════════════════════════════
   Progress bars (project sidebar)
   ══════════════════════════════════════════ */
.progress-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.progress-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #334155;
    font-weight: 500;
}
.progress-bar {
    background: #e2e8f0;
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 8px;
}

/* ══════════════════════════════════════════
   Time tracking (specific tweaks)
   ══════════════════════════════════════════ */
/* Nothing major — reuses existing classes */

/* ══════════════════════════════════════════
   Dashboard KPI grid auto-flow (6 tiles now)
   ══════════════════════════════════════════ */
.dash-kpis {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Text warning color for project usage > 80% */
.text-warning { color: #d97706; }