/* ═══════════════════════════════════════════════
   LexBill PNG — Site Stylesheet
   ═══════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --navy:      #1a3a6b;
    --navy-dark: #122a52;
    --blue:      #2563eb;
    --green:     #16a34a;
    --red:       #dc2626;
    --orange:    #ea580c;
    --yellow:    #d97706;
    --gray-50:   #f8fafc;
    --gray-100:  #f1f5f9;
    --gray-200:  #e2e8f0;
    --gray-400:  #94a3b8;
    --gray-600:  #475569;
    --gray-800:  #1e293b;
    --sidebar-w: 240px;
    --radius:    8px;
    --shadow:    0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

body {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--gray-800);
    background: var(--gray-50);
    min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--navy);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.brand-icon { font-size: 22px; }

.brand-name {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.3px;
}
.brand-name em { color: #93c5fd; font-style: normal; }

.nav-menu { list-style: none; padding: 12px 0; flex: 1; }

.nav-section {
    padding: 12px 20px 4px;
    font-size: 10px;
    font-weight: 600;
    color: rgba(255,255,255,.4);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-size: 13.5px;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: rgba(255,255,255,.15); color: #fff; font-weight: 600; }
.nav-icon { width: 18px; text-align: center; font-size: 14px; }

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,.1);
    font-size: 12px;
    color: rgba(255,255,255,.6);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.btn-logout {
    background: none;
    border: 1px solid rgba(255,255,255,.3);
    color: rgba(255,255,255,.7);
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
}
.btn-logout:hover { background: rgba(255,255,255,.1); }

/* ── MAIN CONTENT ───────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 28px;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    font-size: 13px;
    color: var(--gray-600);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-firm { font-weight: 600; color: var(--navy); }

/* ── ALERTS ─────────────────────────────────────── */
.alert {
    padding: 10px 28px;
    font-size: 13.5px;
    font-weight: 500;
}
.alert-success { background: #dcfce7; color: #166534; border-bottom: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border-bottom: 1px solid #fecaca; }
.alert-warning { background: #fef9c3; color: #854d0e; border-bottom: 1px solid #fef08a; }

/* ── PAGE STRUCTURE ─────────────────────────────── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 24px 28px 16px;
}
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--navy); }
.page-subtitle { color: var(--gray-600); font-size: 13px; margin-top: 2px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── CARDS ──────────────────────────────────────── */
.card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: 0 28px 20px;
    overflow: hidden;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid var(--gray-100);
    background: var(--gray-50);
}
.card-header h2, .card-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
}

/* ── KPI CARDS ──────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 16px;
    padding: 0 28px 20px;
}
.kpi-grid-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-grid-2 { grid-template-columns: repeat(2, 1fr); }

.kpi-card {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.kpi-label { font-size: 11.5px; color: var(--gray-600); font-weight: 500; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 6px; }
.kpi-value { font-size: 20px; font-weight: 700; color: var(--gray-800); }
.kpi-sub   { font-size: 11.5px; color: var(--gray-400); margin-top: 4px; }

.kpi-outstanding .kpi-value { color: var(--navy); }
.kpi-overdue     .kpi-value { color: var(--red); }
.kpi-paid        .kpi-value { color: var(--green); }
.kpi-wip         .kpi-value { color: var(--blue); }

/* ── DASHBOARD GRID ─────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
    padding: 0 28px;
}
.dashboard-grid .card { margin: 0 0 20px; }

/* ── TABLES ─────────────────────────────────────── */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table th {
    text-align: left;
    padding: 10px 14px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    font-weight: 600;
    font-size: 12px;
    color: var(--gray-600);
    white-space: nowrap;
}
.table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
.table-hover tr:hover td { background: var(--gray-50); }
.table tfoot .totals-footer td {
    padding: 12px 14px;
    font-weight: 700;
    border-top: 2px solid var(--gray-200);
    background: var(--gray-50);
}

.row-billed td { opacity: 0.55; }
.row-critical td { background: #fff5f5; }
.row-warning td  { background: #fffbeb; }
.text-right  { text-align: right; }
.text-center { text-align: center; }

/* ── BUTTONS ─────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-800);
    text-decoration: none;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
}
.btn:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }

.btn-success { background: var(--green); color: #fff; border-color: var(--green); }
.btn-success:hover { background: #15803d; }

.btn-warning { background: var(--yellow); color: #fff; border-color: var(--yellow); }
.btn-danger  { background: var(--red);    color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #b91c1c; }

.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-xs  { padding: 3px 8px;  font-size: 11.5px; }
.btn-full { width: 100%; justify-content: center; }

/* ── BADGES ──────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-open, .badge-sent   { background: #dbeafe; color: #1e40af; }
.badge-paid                { background: #dcfce7; color: #166534; }
.badge-draft               { background: var(--gray-100); color: var(--gray-600); }
.badge-overdue, .badge-closed { background: #fee2e2; color: #991b1b; }
.badge-partiallypaid       { background: #fef9c3; color: #854d0e; }
.badge-void, .badge-onhold { background: #f3f4f6; color: #6b7280; }

/* ── TAGS ────────────────────────────────────────── */
.tag {
    display: inline-block;
    padding: 2px 7px;
    background: var(--gray-100);
    color: var(--gray-600);
    border-radius: 4px;
    font-size: 11.5px;
    font-weight: 500;
}

/* ── FORMS ───────────────────────────────────────── */
.form-control, .form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--gray-800);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.filter-bar { padding: 0 28px 16px; }
.filter-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.filter-form .form-control, .filter-form .form-select { width: auto; flex: 1; min-width: 150px; }

/* ── DETAIL PAGES ────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
    padding: 0 28px;
}
.detail-grid .card { margin: 0 0 20px; }

.detail-card { padding: 20px; }
.detail-card h3 { font-size: 13px; font-weight: 600; color: var(--navy); margin-bottom: 12px; }

.dl-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.dl-grid dt { color: var(--gray-600); font-weight: 500; white-space: nowrap; }
.dl-grid dd { color: var(--gray-800); }

/* ── INVOICE LAYOUT ──────────────────────────────── */
.invoice-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 0 20px;
    padding: 0 28px;
    align-items: start;
}
.invoice-layout .card { margin: 0 0 20px; }

.invoice-card { padding: 28px; }

.invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--navy);
}
.invoice-firm-name { font-size: 18px; font-weight: 700; color: var(--navy); }
.invoice-meta      { font-size: 11px; color: var(--gray-400); margin-top: 2px; }
.invoice-number-block { text-align: right; font-size: 13px; }
.inv-number { font-size: 16px; font-weight: 700; color: var(--navy); }

.bill-to-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
    font-size: 13px;
    line-height: 1.6;
}
.section-label { font-size: 10px; font-weight: 700; color: var(--gray-400); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px; }

.invoice-table { margin-bottom: 0; }
.invoice-table th { background: var(--navy); color: #fff; }

.totals-block {
    margin-top: 16px;
    margin-left: auto;
    width: 260px;
    border-top: 1px solid var(--gray-200);
    padding-top: 10px;
}
.totals-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 13px;
}
.totals-total {
    font-weight: 700;
    font-size: 15px;
    border-top: 2px solid var(--navy);
    padding-top: 8px;
    margin-top: 4px;
    color: var(--navy);
}
.totals-balance { font-weight: 700; font-size: 14px; }

.invoice-terms {
    margin-top: 24px;
    padding: 12px 16px;
    background: var(--gray-50);
    border-radius: 6px;
    font-size: 12px;
    color: var(--gray-600);
    line-height: 1.6;
}
.invoice-footer-note {
    margin-top: 16px;
    font-size: 11px;
    color: var(--gray-400);
    text-align: center;
    border-top: 1px solid var(--gray-100);
    padding-top: 12px;
}

/* ── COLOURS ──────────────────────────────────────── */
.text-primary { color: var(--navy) !important; }
.text-success { color: var(--green) !important; }
.text-danger  { color: var(--red) !important; }
.text-warning { color: var(--yellow) !important; }
.text-orange  { color: var(--orange) !important; }
.text-muted   { color: var(--gray-400) !important; }
.p-3 { padding: 12px 16px; }
.mb-4 { margin-bottom: 16px; }
.mt-1 { margin-top: 4px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.actions { white-space: nowrap; }

/* ── LOGIN PAGE ──────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 60%, #1e4d9b 100%);
}
.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px 36px;
    width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo span { font-size: 32px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: var(--navy); margin-top: 6px; }
.login-logo h1 em { color: var(--blue); font-style: normal; }
.login-logo p { color: var(--gray-600); font-size: 13px; margin-top: 4px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-600); margin-bottom: 5px; }
.form-group .form-control { width: 100%; }

.validation-summary-errors { background: #fee2e2; border: 1px solid #fecaca; border-radius: 6px; padding: 10px 14px; margin-bottom: 16px; color: var(--red); font-size: 13px; }

/* ── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 1200px) {
    .dashboard-grid, .detail-grid { grid-template-columns: 1fr; }
    .invoice-layout { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }
    .sidebar { display: none; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
}
