/* BridgeTech Reporting — minimal, professional CSS. */

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

:root {
    --bg: #f8f9fa;
    --surface: #ffffff;
    --text: #212529;
    --text-muted: #6c757d;
    --border: #dee2e6;
    --primary: #1a5276;
    --primary-hover: #154360;
    --error: #c0392b;
    --success: #27ae60;
    --radius: 6px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* -- nav ------------------------------------------------------------ */
header { background: var(--primary); color: #fff; }

nav {
    max-width: 960px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand { color: #fff; text-decoration: none; font-weight: 600; font-size: 1.1rem; }
.nav-right { display: flex; align-items: center; gap: 1rem; }
.user-name { font-size: 0.9rem; opacity: 0.9; }
.btn-link {
    background: none; border: none; color: #fff; cursor: pointer;
    font-size: 0.9rem; text-decoration: underline; opacity: 0.9;
}
.btn-link:hover { opacity: 1; }
.inline-form { display: inline; }

/* -- main ----------------------------------------------------------- */
main { max-width: 960px; margin: 2rem auto; padding: 0 1rem; }
h1 { margin-bottom: 1rem; }
h2 { margin-bottom: 0.75rem; font-size: 1.15rem; }

/* -- auth forms ----------------------------------------------------- */
.auth-container {
    max-width: 400px;
    margin: 4rem auto;
    background: var(--surface);
    padding: 2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.auth-container h1 { text-align: center; margin-bottom: 1.5rem; }

label { display: block; font-weight: 500; margin-bottom: 0.25rem; margin-top: 1rem; }
label:first-of-type { margin-top: 0; }

input[type="email"],
input[type="password"],
input[type="text"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
}

input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

button[type="submit"] {
    display: block;
    width: 100%;
    margin-top: 1.5rem;
    padding: 0.625rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
}
button[type="submit"]:hover { background: var(--primary-hover); }

.error {
    background: #fdf0ef;
    color: var(--error);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* -- lender cards --------------------------------------------------- */
.current-lender {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.lender-list { margin-top: 1rem; }

.lender-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
}

.lender-card.active { border-color: var(--primary); }

.lender-card button {
    padding: 0.375rem 1rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
}
.lender-card button:hover { background: var(--primary-hover); }
.lender-card.active button { background: var(--success); }

/* -- breadcrumb + context ------------------------------------------- */
.breadcrumb { margin-bottom: 0.5rem; font-size: 0.85rem; color: var(--text-muted); }
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.context-line { color: var(--text-muted); margin-bottom: 1.5rem; }

/* -- sub-heading ---------------------------------------------------- */
.sub-heading { color: var(--text-muted); margin-bottom: 1rem; font-size: 0.95rem; }

/* -- flash messages ------------------------------------------------- */
.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    line-height: 1.4;
}
.flash-success { background: #eafaf1; color: #1e7e34; border: 1px solid #c3e6cb; }
.flash-warning { background: #fff3e0; color: #e65100; border: 1px solid #ffe0b2; }
.flash-error { background: #fdf0ef; color: var(--error); border: 1px solid #f5c6cb; }
.flash-info { background: #e3f2fd; color: #1565c0; border: 1px solid #bbdefb; }

/* -- card ----------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.card h2 { margin-bottom: 0.75rem; }

/* -- upload form ---------------------------------------------------- */
.upload-form .form-row {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.upload-form .form-row label { flex: 1; min-width: 200px; }
.upload-form input[type="file"] {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.9rem;
}
.upload-form input[type="date"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
}

/* -- data tables ---------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.data-table th, .data-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.data-table tbody tr:last-child td { border-bottom: none; }

/* -- summary bar ---------------------------------------------------- */
.summary-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.summary-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}
.summary-stat strong { font-size: 1.25rem; display: block; }

/* -- filter tabs ---------------------------------------------------- */
.filter-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}
.filter-tab {
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 0.9rem;
}
.filter-tab:hover { color: var(--text); }
.filter-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 500;
}

/* -- badges --------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: capitalize;
}
.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-muted { background: #e9ecef; color: var(--text-muted); }
.badge-open { background: #fdf0ef; color: var(--error); }
.badge-explained { background: #fff3e0; color: #e65100; }
.badge-resolved { background: #e8f5e9; color: #2e7d32; }

/* -- buttons / links ------------------------------------------------ */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    margin-top: 0.5rem;
}
.btn:hover { background: var(--primary-hover); }

/* -- anomaly cards -------------------------------------------------- */
.anomaly-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
}
.anomaly-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}
.anomaly-meta { font-size: 0.85rem; color: var(--text-muted); }
.anomaly-detail { margin: 0.5rem 0; font-size: 0.9rem; }
.anomaly-actions {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}
.anomaly-actions textarea {
    flex: 1;
    min-width: 200px;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-family: inherit;
    resize: vertical;
    min-height: 2.5rem;
}
.btn-sm {
    padding: 0.375rem 0.75rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}
.btn-explain { background: #fff3e0; color: #e65100; }
.btn-explain:hover { background: #ffe0b2; }
.btn-resolve { background: #e8f5e9; color: #2e7d32; }
.btn-resolve:hover { background: #c8e6c9; }
.btn-reopen { background: #fdf0ef; color: var(--error); }
.btn-reopen:hover { background: #f8d7d4; }

/* -- empty state ---------------------------------------------------- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

/* -- action links --------------------------------------------------- */
.action-links {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
}
.action-links a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9rem;
}
.action-links a:hover { text-decoration: underline; }

/* -- commentary editor ---------------------------------------------- */
.draft-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.draft-section h2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.draft-source {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}
.draft-original {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin: 0.75rem 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}
.draft-editor textarea {
    width: 100%;
    min-height: 150px;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
}
.draft-editor textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.draft-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}
.draft-actions .btn {
    margin-top: 0;
    width: auto;
}
.edit-indicator { font-size: 0.8rem; color: var(--text-muted); }
.toggle-original {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 0.8rem;
    text-decoration: underline;
    padding: 0;
}

/* -- checklist ------------------------------------------------------ */
.checklist { list-style: none; }
.check-item {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
    font-size: 0.9rem;
}
.check-item::before {
    position: absolute;
    left: 0;
    font-weight: 600;
}
.check-pass::before { content: "\2713"; color: var(--success); }
.check-fail::before { content: "\2717"; color: var(--error); }
.check-item a { color: var(--primary); }

/* -- approval status ------------------------------------------------ */
.approval-status.approved { border-color: var(--success); }
.approval-status.blocked { border-color: var(--border); }
.approval-status.ready { border-color: var(--primary); }
.btn-danger {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--error);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: 0.5rem;
}
.btn-danger:hover { background: #a93226; }

/* -- audit badge ---------------------------------------------------- */
.badge-audit { background: #e9ecef; color: var(--text-muted); }

/* -- publish controls ----------------------------------------------- */
.publish-status {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    font-size: 0.9rem;
}
.publish-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}
.btn-secondary {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--surface);
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}
.btn-secondary:hover { background: var(--bg); }
