/* ============================================================
   LEDES BILLING — Legal E-Billing Portal
   Navy/Gold branding. Clean, professional, secretary-friendly.
   ============================================================ */

:root {
    --navy: #1B2A4A;
    --navy-light: #2A3D66;
    --navy-dark: #111D35;
    --gold: #C9A84C;
    --gold-light: #E8D59A;
    --gold-muted: #B89A3E;
    --white: #FFFFFF;
    --gray-50: #F8F9FA;
    --gray-100: #F1F3F5;
    --gray-200: #E9ECEF;
    --gray-300: #DEE2E6;
    --gray-400: #ADB5BD;
    --gray-500: #6C757D;
    --gray-600: #495057;
    --gray-700: #343A40;
    --gray-800: #212529;
    --green: #2E7D4F;
    --green-bg: #E8F5EE;
    --red: #C0392B;
    --red-bg: #FDEDEC;
    --blue: #2E6DA4;
    --blue-bg: #E8F0F8;
    --orange: #D4850B;
    --orange-bg: #FEF5E7;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.12);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-700);
    background: var(--gray-50);
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-body {
    background: var(--navy);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}

.login-header { text-align: center; margin-bottom: 2rem; }

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}
.login-logo img { border-radius: 50%; }

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 0.15rem;
    letter-spacing: 0.5px;
}

.login-subtitle {
    font-size: 0.85rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.login-form { display: flex; flex-direction: column; gap: 1.2rem; }

.login-footer {
    text-align: center;
    margin-top: 2rem;
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 0.3rem; }

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input, .form-group select {
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.95rem;
    color: var(--gray-700);
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--navy-light);
    box-shadow: 0 0 0 3px rgba(27, 42, 74, 0.12);
}

.form-hint {
    font-size: 0.75rem;
    color: var(--gray-400);
}

/* ============================================================
   NAVIGATION
   ============================================================ */
.nav {
    background: var(--navy);
    color: var(--white);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    height: 56px;
    gap: 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand { display: flex; align-items: center; gap: 0.6rem; }
.nav-icon { flex-shrink: 0; border-radius: 4px; }
.nav-firm {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-links { display: flex; gap: 0.25rem; flex: 1; }

.nav-link {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s;
}
.nav-link:hover { color: var(--white); background: rgba(255,255,255,0.1); }
.nav-link.active {
    color: var(--white);
    background: rgba(255,255,255,0.15);
    border-bottom: 2px solid var(--gold);
}

.nav-user { display: flex; align-items: center; gap: 1rem; margin-left: auto; }
.nav-username { font-size: 0.85rem; color: rgba(255,255,255,0.8); }
.nav-logout {
    color: rgba(255,255,255,0.5);
    text-decoration: none;
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius);
    transition: all 0.15s;
}
.nav-logout:hover { color: var(--white); border-color: rgba(255,255,255,0.4); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 2rem 3rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}
.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--navy);
}
.page-subtitle {
    font-size: 0.9rem;
    color: var(--gray-500);
    margin-top: 0.2rem;
}
.page-actions { display: flex; gap: 0.5rem; align-items: center; }

.back-link {
    font-size: 0.85rem;
    color: var(--blue);
    text-decoration: none;
    display: inline-block;
    margin-bottom: 0.3rem;
}
.back-link:hover { text-decoration: underline; }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.section-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--navy);
}
.subsection-header {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray-600);
    margin: 1.5rem 0 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--gray-200);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
    background: var(--white);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}
.btn:hover { background: var(--gray-100); border-color: var(--gray-400); }

.btn-primary {
    background: var(--navy);
    border-color: var(--navy);
    color: var(--white);
}
.btn-primary:hover { background: var(--navy-light); border-color: var(--navy-light); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; padding: 0.7rem; }
.btn-ghost { background: transparent; border-color: var(--gray-300); }
.btn-ghost:hover { background: var(--gray-100); }

/* ============================================================
   STATS CARDS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.2rem;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    margin-bottom: 0.3rem;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--navy);
    line-height: 1.1;
}

.stat-detail {
    font-size: 0.8rem;
    color: var(--gray-400);
    margin-top: 0.2rem;
}

/* ============================================================
   QUICK ACTIONS
   ============================================================ */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.action-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.2rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}
.action-card:hover {
    border-color: var(--gold);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.action-icon { font-size: 1.5rem; margin-bottom: 0.5rem; }
.action-label { font-weight: 600; color: var(--navy); font-size: 0.95rem; }
.action-desc { font-size: 0.8rem; color: var(--gray-500); margin-top: 0.2rem; }

/* ============================================================
   DATA TABLES
   ============================================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-table thead th {
    background: var(--gray-100);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--gray-600);
    padding: 0.7rem 0.85rem;
    text-align: left;
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.87rem;
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--gray-50); }

.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--blue-bg) !important; }

.col-check { width: 40px; text-align: center; }
.col-check input { cursor: pointer; }

.mono { font-family: "SF Mono", "Fira Code", "Consolas", monospace; font-size: 0.82rem; }
.mono-sm { font-family: "SF Mono", "Fira Code", "Consolas", monospace; font-size: 0.75rem; color: var(--gray-400); }
.amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.truncate { max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-muted { color: var(--gray-400); font-style: italic; }

.result-count {
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-top: 0.75rem;
}

/* ============================================================
   DETAIL CARDS
   ============================================================ */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.detail-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.2rem;
    box-shadow: var(--shadow);
}

.detail-card h3 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--navy);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0;
    font-size: 0.87rem;
}

.detail-label {
    color: var(--gray-500);
    font-size: 0.82rem;
}

.detail-total {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 2px solid var(--navy);
    font-weight: 700;
}
.detail-total .detail-label { color: var(--navy); font-weight: 700; }
.detail-total .amount { color: var(--navy); font-size: 1.05rem; }

/* ============================================================
   STATUS BADGES
   ============================================================ */
.status-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-draft { background: var(--gray-200); color: var(--gray-600); }
.status-review { background: var(--blue-bg); color: var(--blue); }
.status-submitted { background: var(--orange-bg); color: var(--orange); }
.status-accepted { background: var(--green-bg); color: var(--green); }
.status-paid { background: var(--green-bg); color: var(--green); }
.status-rejected { background: var(--red-bg); color: var(--red); }
.status-active { background: var(--green-bg); color: var(--green); }
.status-closed { background: var(--gray-200); color: var(--gray-500); }
.status-suspended { background: var(--red-bg); color: var(--red); }
.status-generated { background: var(--green-bg); color: var(--green); }
.status-uploaded { background: var(--blue-bg); color: var(--blue); }
.status-confirmed { background: var(--green-bg); color: var(--green); }
.status-error { background: var(--red-bg); color: var(--red); }

/* ============================================================
   STATUS ACTIONS
   ============================================================ */
.status-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}
.status-actions-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--gray-600);
}

/* ============================================================
   FILTERS
   ============================================================ */
.filter-bar {
    margin-bottom: 1.25rem;
    padding: 0.75rem 1rem;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.filter-form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-form select, .filter-search {
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--gray-700);
    background: var(--white);
}
.filter-search { min-width: 200px; }

/* ============================================================
   RATE CHIPS
   ============================================================ */
.rate-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.rate-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.5rem;
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    font-size: 0.78rem;
}
.rate-client { color: var(--gray-500); font-weight: 600; }
.rate-amount { color: var(--green); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ============================================================
   CLIENT GROUPS (Matters page)
   ============================================================ */
.client-group { margin-bottom: 2rem; }
.client-group-header {
    font-size: 1rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.count-badge {
    background: var(--navy);
    color: var(--white);
    font-size: 0.7rem;
    padding: 0.1rem 0.45rem;
    border-radius: 8px;
    font-weight: 600;
}

/* ============================================================
   EXPORT SECTION
   ============================================================ */
.export-section {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}
.export-section h2 {
    font-size: 1.1rem;
    color: var(--navy);
    margin-bottom: 1rem;
}

.export-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--gray-600);
    cursor: pointer;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.87rem;
    margin-bottom: 1rem;
}
.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid #F5C6CB; }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid #C3E6CB; }

/* ============================================================
   ERROR PAGE
   ============================================================ */
.error-page {
    text-align: center;
    padding: 4rem 2rem;
}
.error-page h1 { font-size: 1.5rem; color: var(--navy); margin-bottom: 0.75rem; }
.error-page p { color: var(--gray-500); margin-bottom: 1.5rem; }
.error-detail {
    background: var(--gray-100);
    padding: 1rem;
    border-radius: var(--radius);
    font-family: monospace;
    font-size: 0.82rem;
    color: var(--red);
    text-align: left;
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    font-size: 0.75rem;
    color: var(--gray-400);
    text-align: center;
    border-top: 1px solid var(--gray-200);
}
.footer-powered strong { color: var(--gray-500); }

.empty-state {
    text-align: center;
    color: var(--gray-400);
    padding: 2.5rem;
    font-style: italic;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .nav { flex-wrap: wrap; height: auto; padding: 0.75rem; gap: 0.5rem; }
    .nav-links { order: 3; width: 100%; overflow-x: auto; }
    .main { padding: 1rem; }
    .detail-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .truncate { max-width: 150px; }
}
