/* ================================================================
   StatusKWO — Shared Core Styles
   Used by all portals (admin, broker, borrower) and login pages.
   ================================================================ */

/* ── Reset & Base ─────────────────────────────────────────────── */

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

:root {
    --primary:       #0F2B46;
    --primary-light: #1A3D5C;
    --primary-dark:  #0B1D2E;
    --secondary:     #0D9488;
    --secondary-lt:  #14B8A6;
    --accent:        #5EEAD4;
    --text:          #1E293B;
    --text-light:    #64748B;
    --light:         #F8FAFC;
    --white:         #FFFFFF;
    --border:        #E2E8F0;
    --error:         #EF4444;
    --error-bg:      #FEF2F2;
    --warn:          #9A3412;
    --warn-bg:       #FFF7ED;
    --success:       #065F46;
    --success-bg:    #D1FAE5;
    --blue:          #1D4ED8;
    --blue-bg:       #EFF6FF;
    --radius:        12px;
    --radius-sm:     8px;
    --radius-xs:     6px;
    --shadow-sm:     0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md:     0 4px 20px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
    --shadow-lg:     0 20px 60px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.04);
    --ease:          cubic-bezier(0.16, 1, 0.3, 1);
    --sidebar-w:     260px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--light);
    color: var(--text);
    font-size: 0.925rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--secondary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Login Page ───────────────────────────────────────────────── */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #0B1D2E 0%, #0F2B46 40%, #1A3D5C 100%);
}

.login-card {
    background: var(--white);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.login-header { text-align: center; margin-bottom: 1.5rem; }
.login-logo { height: 30px; width: auto; margin-bottom: 0.75rem; display: block; margin-left: auto; margin-right: auto; }
.login-header p { color: var(--text-light); font-size: 0.85rem; font-weight: 500; }
.login-header h1 { color: var(--text-light); font-size: 0.85rem; font-weight: 500; }

.login-footer {
    text-align: center;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.login-footer a { font-size: 0.85rem; font-weight: 500; }

/* ── Alerts ───────────────────────────────────────────────────── */

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 1rem;
}
.alert-error   { background: var(--error-bg); color: var(--error); border: 1px solid rgba(239,68,68,0.2); }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(6,95,70,0.2); }

/* ── Form Elements ────────────────────────────────────────────── */

.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--primary);
    margin-bottom: 0.4rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.925rem;
    color: var(--text);
    background: var(--white);
    transition: all 0.25s var(--ease);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 4px rgba(13,148,136,0.08), 0 2px 8px rgba(13,148,136,0.1);
}

input::placeholder, textarea::placeholder { color: var(--text-light); opacity: 0.6; }

/* ── Buttons ──────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.7rem 1.4rem;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s var(--ease);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-lt) 100%);
    color: var(--white);
    box-shadow: 0 2px 8px rgba(13,148,136,0.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(13,148,136,0.35); text-decoration: none; }

.btn-outline { background: transparent; color: var(--secondary); border: 1.5px solid var(--secondary); padding: 0.55rem 1.2rem; }
.btn-outline:hover { background: var(--secondary); color: var(--white); text-decoration: none; }

.btn-ghost { background: transparent; color: var(--text-light); padding: 0.5rem 0.8rem; }
.btn-ghost:hover { color: var(--secondary); text-decoration: none; }

.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn-delete { color: var(--text-light); padding: 0.35rem; }
.btn-delete:hover { color: var(--error); }

/* ── Sidebar ──────────────────────────────────────────────────── */

.has-sidebar { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    overflow-y: auto;
}

.sidebar-header { padding: 1.5rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-logo { height: 26px; width: auto; opacity: 0.95; }
.sidebar-nav { flex: 1; padding: 0.75rem 0; }

.nav-item {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.65rem 1.25rem;
    color: rgba(255,255,255,0.6); font-size: 0.85rem; font-weight: 500;
    transition: all 0.2s ease; text-decoration: none; border-left: 3px solid transparent;
}
.nav-item:hover { color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.05); text-decoration: none; }
.nav-item.active { color: var(--accent); background: rgba(255,255,255,0.08); border-left-color: var(--accent); }
.nav-item svg { opacity: 0.7; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; }

.nav-section {
    padding: 1.25rem 1.25rem 0.4rem; font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,0.3);
}

.sidebar-footer { padding: 0.75rem; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-user { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem; margin-bottom: 0.25rem; }

.user-avatar {
    width: 32px; height: 32px; border-radius: 8px;
    background: linear-gradient(135deg, var(--secondary), var(--secondary-lt));
    color: var(--white); display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.82rem; flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { color: rgba(255,255,255,0.9); font-size: 0.8rem; font-weight: 600; }
.user-email { color: rgba(255,255,255,0.4); font-size: 0.7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-logout { color: rgba(255,255,255,0.4); font-size: 0.8rem; }
.nav-logout:hover { color: var(--error); background: rgba(239,68,68,0.1); }

/* ── Main Content ─────────────────────────────────────────────── */

.main-content { flex: 1; margin-left: var(--sidebar-w); padding: 2rem; max-width: calc(100vw - var(--sidebar-w)); }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.75rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 800; color: var(--primary); letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-light); font-size: 0.85rem; margin-top: 0.15rem; }
.page-header-name { font-weight: 600; color: var(--text-light); font-size: 0.85em; }

.header-actions { display: flex; align-items: center; gap: 0.75rem; }
.header-date { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.3; }
.clock-time { font-size: 1.25rem; font-weight: 800; color: var(--primary); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.clock-date { font-size: 0.78rem; font-weight: 500; color: var(--text-light); }

.back-link { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.82rem; font-weight: 600; color: var(--text-light); margin-bottom: 0.5rem; }
.back-link:hover { color: var(--secondary); text-decoration: none; }

/* ── Stats Row ────────────────────────────────────────────────── */

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stats-row-3 { grid-template-columns: repeat(3, 1fr); }

.stat-card {
    background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.1rem 1.25rem; display: flex; align-items: center; gap: 1rem;
    transition: all 0.3s var(--ease);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card-wide { grid-column: span 4; }

.stat-icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon-total   { background: var(--blue-bg); color: var(--blue); }
.stat-icon-pending { background: var(--warn-bg); color: var(--warn); }
.stat-icon-flagged { background: var(--error-bg); color: var(--error); }
.stat-icon-approved { background: var(--success-bg); color: var(--success); }
.stat-icon-value   { background: linear-gradient(135deg, rgba(13,148,136,0.1), rgba(20,184,166,0.1)); color: var(--secondary); }

.stat-content { display: flex; flex-direction: column; }
.stat-value { font-size: 1.5rem; font-weight: 800; color: var(--primary); letter-spacing: -0.03em; line-height: 1.2; }
.stat-label { font-size: 0.75rem; font-weight: 600; color: var(--text-light); margin-top: 0.1rem; }
.stat-card-wide .stat-value { font-size: 1.3rem; }

/* ── Filters Bar ──────────────────────────────────────────────── */

.filters-bar { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem 1rem; margin-bottom: 1rem; }
.filters-form { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }

.filter-search-wrap { position: relative; flex: 1; min-width: 200px; }
.filter-search-icon { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: var(--text-light); opacity: 0.5; pointer-events: none; }
.filter-input { padding: 0.5rem 0.85rem 0.5rem 2.25rem !important; font-size: 0.85rem !important; border-radius: var(--radius-sm) !important; }

.filter-select {
    width: auto !important; min-width: 130px;
    padding: 0.5rem 2rem 0.5rem 0.85rem !important; font-size: 0.85rem !important;
    border-radius: var(--radius-sm) !important; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.7rem center;
}

/* ── Table ─────────────────────────────────────────────────────── */

.table-wrap { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }

.dip-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.dip-table th {
    text-align: left; padding: 0.7rem 1rem; font-weight: 600; font-size: 0.75rem;
    color: var(--text-light); text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--white);
}
.dip-table th a { color: inherit; display: inline-flex; align-items: center; gap: 0.3rem; }
.dip-table th a:hover { color: var(--secondary); text-decoration: none; }

.sort-icon { font-size: 0.9rem; opacity: 0.3; }
.sort-icon.active { opacity: 1; color: var(--secondary); }

.dip-table td { padding: 0.65rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.dip-table tbody tr { transition: background 0.15s ease; }
.dip-table tbody tr:hover { background: rgba(13,148,136,0.02); }
.dip-table tbody tr:last-child td { border-bottom: none; }

.table-footer { padding: 0.6rem 1rem; font-size: 0.8rem; }

/* ── Cards ────────────────────────────────────────────────────── */

.view-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.5rem; }
.view-card-header { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.85rem; padding-bottom: 0.65rem; border-bottom: 1px solid var(--border); color: var(--text-light); }
.view-card-header h2 { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-light); }
.view-card-header svg { opacity: 0.5; }
.view-card-full { grid-column: 1 / -1; }

/* ── View Grid & Detail Lists ─────────────────────────────────── */

.view-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }

.detail-list { display: grid; grid-template-columns: 120px 1fr; gap: 0.5rem 1rem; align-items: baseline; }
.detail-list dt { font-weight: 600; font-size: 0.78rem; color: var(--text-light); }
.detail-list dd { font-size: 0.9rem; }
.detail-list dd a { color: var(--secondary); }
.detail-list-wide { grid-template-columns: 150px 1fr; }

/* ── Badges ────────────────────────────────────────────────────── */

.badge { display: inline-flex; align-items: center; padding: 0.18rem 0.6rem; border-radius: 6px; font-size: 0.72rem; font-weight: 600; white-space: nowrap; }
.badge-lg { padding: 0.3rem 0.85rem; font-size: 0.8rem; }

.badge-declined       { background: var(--error-bg); color: var(--error); }
.badge-flag           { background: var(--error-bg); color: var(--error); }
.badge-type           { background: var(--blue-bg); color: var(--blue); }
.badge-dip_generated  { background: var(--warn-bg); color: var(--warn); }
.badge-under_review   { background: var(--blue-bg); color: var(--blue); }
.badge-info_requested { background: #FFF7ED; color: #9A3412; }
.badge-valuation      { background: #F0F9FF; color: #0369A1; }
.badge-legals         { background: #FAF5FF; color: #7E22CE; }
.badge-completion     { background: var(--success-bg); color: var(--success); }

/* ── Pipeline Tracker ─────────────────────────────────────────── */

.pipeline-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem 1.25rem; margin-bottom: 1rem; overflow-x: auto; }

.pipeline-track { display: flex; align-items: flex-start; justify-content: space-between; position: relative; min-width: 500px; }
.pipeline-track::before { content: ''; position: absolute; top: 22px; left: 22px; right: 22px; height: 3px; background: var(--border); z-index: 0; }

.pipeline-step { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; position: relative; z-index: 1; flex: 1; }

.pipeline-dot {
    width: 44px; height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--white); border: 3px solid var(--border); color: var(--text-light);
    transition: all 0.3s var(--ease); flex-shrink: 0;
}

.pipeline-label { font-size: 0.72rem; font-weight: 600; color: var(--text-light); text-align: center; line-height: 1.2; max-width: 80px; }

.pipeline-step.completed .pipeline-dot { background: var(--secondary); border-color: var(--secondary); color: var(--white); }
.pipeline-step.completed .pipeline-label { color: var(--secondary); }

.pipeline-step.active .pipeline-dot {
    border-color: var(--secondary); color: var(--secondary);
    box-shadow: 0 0 0 6px rgba(13,148,136,0.12), 0 2px 8px rgba(13,148,136,0.2);
    animation: pipeline-pulse 2s ease-in-out infinite;
}
.pipeline-step.active .pipeline-label { color: var(--primary); font-weight: 700; }

@keyframes pipeline-pulse {
    0%, 100% { box-shadow: 0 0 0 6px rgba(13,148,136,0.12), 0 2px 8px rgba(13,148,136,0.2); }
    50% { box-shadow: 0 0 0 10px rgba(13,148,136,0.06), 0 2px 12px rgba(13,148,136,0.15); }
}

.pipeline-step.completed + .pipeline-step::before { content: ''; position: absolute; top: 22px; right: 50%; width: 100%; height: 3px; background: var(--secondary); z-index: -1; }

.pipeline-declined { display: flex; align-items: center; justify-content: center; gap: 0.75rem; padding: 0.5rem 0; color: var(--error); font-size: 1.1rem; font-weight: 700; }

/* ── Audit Log ────────────────────────────────────────────────── */

.audit-log { max-height: 400px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--light); }
.audit-entry { padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--border); font-size: 0.82rem; line-height: 1.5; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.audit-entry:last-child { border-bottom: none; }
.audit-entry-new { background: rgba(13,148,136,0.04); }

.add-note-form { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.add-note-input { flex: 1; padding: 0.5rem 0.85rem !important; font-size: 0.85rem !important; border-radius: var(--radius-sm) !important; }

/* ── Officer / Company Lists ─────────────────────────────────── */

.officer-list { display: flex; flex-direction: column; }
.officer-row { padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.officer-row:last-child { border-bottom: none; }
.officer-row strong { font-size: 0.85rem; margin-right: 0.4rem; }
.officer-row .badge { vertical-align: middle; }

/* ── Document Rows ────────────────────────────────────────────── */

.docs-list { display: flex; flex-direction: column; gap: 0; }

.doc-row { display: flex; align-items: center; justify-content: space-between; padding: 0.7rem 0; border-bottom: 1px solid var(--border); }
.doc-row:last-child { border-bottom: none; }

.doc-info { display: flex; align-items: center; gap: 0.65rem; min-width: 0; }
.doc-icon { color: var(--error); opacity: 0.7; flex-shrink: 0; }
.doc-icon-upload { color: var(--secondary); opacity: 0.7; flex-shrink: 0; }
.doc-type { display: block; font-weight: 600; font-size: 0.85rem; color: var(--text); }
.doc-meta { display: block; font-size: 0.78rem; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-actions { display: flex; align-items: center; gap: 0.3rem; flex-shrink: 0; }

/* ── Upload Form ──────────────────────────────────────────────── */

.upload-form { margin-bottom: 0.75rem; }
.upload-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.upload-label-input { flex: 1; min-width: 180px; padding: 0.45rem 0.8rem !important; font-size: 0.85rem !important; border-radius: var(--radius-sm) !important; }
.upload-file-btn { cursor: pointer; white-space: nowrap; }
.upload-file-btn span { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; }

/* ── Empty State ──────────────────────────────────────────────── */

.empty-state { padding: 4rem 2rem; text-align: center; color: var(--text-light); display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }

/* ── Helpers ───────────────────────────────────────────────────── */

.mono { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; font-size: 0.82rem; }
.text-light { color: var(--text-light); }
.text-warn  { color: var(--warn); font-weight: 600; }
small { font-size: 0.78rem; }

/* ── Toast Notification ───────────────────────────────────────── */

.toast { position: fixed; bottom: 1.5rem; right: 1.5rem; padding: 0.75rem 1.25rem; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600; color: var(--white); background: var(--primary); box-shadow: var(--shadow-lg); z-index: 100; transform: translateY(0); opacity: 1; transition: all 0.3s var(--ease); }
.toast[hidden] { transform: translateY(1rem); opacity: 0; pointer-events: none; }
.toast.toast-success { background: var(--success); }
.toast.toast-error   { background: var(--error); }

/* ── WebAuthn / Passkeys ─────────────────────────────────────── */

.btn-passkey { background: var(--primary); color: var(--white); gap: 0.6rem; padding: 0.85rem 1.4rem; font-size: 0.95rem; box-shadow: 0 2px 12px rgba(15,43,70,0.25); border-radius: 12px; transition: all 0.3s var(--ease); }
.btn-passkey:hover { background: var(--primary-light); transform: translateY(-1px); box-shadow: 0 6px 24px rgba(15,43,70,0.35); text-decoration: none; }
.btn-passkey svg { opacity: 0.85; }

.login-divider { display: flex; align-items: center; margin: 1.25rem 0; gap: 0.75rem; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.login-divider span { font-size: 0.78rem; font-weight: 500; color: var(--text-light); white-space: nowrap; }

.webauthn-login-error { color: var(--error); font-size: 0.82rem; font-weight: 500; text-align: center; min-height: 1.2em; margin-top: 0.5rem; }

.webauthn-status { font-size: 0.82rem; font-weight: 500; margin-top: 0.5rem; min-height: 1.2em; }
.webauthn-status-success { color: var(--success); }
.webauthn-status-error { color: var(--error); }

/* ── Settings ─────────────────────────────────────────────────── */

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.settings-passkeys { display: flex; flex-direction: column; gap: 1rem; }

.passkey-row { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.passkey-row:last-child { border-bottom: none; }
.passkey-info { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.passkey-icon { color: var(--secondary); opacity: 0.7; flex-shrink: 0; }
.passkey-name { display: block; font-weight: 600; font-size: 0.88rem; color: var(--text); }
.passkey-meta { display: block; font-size: 0.78rem; color: var(--text-light); }

/* ── Mobile Menu ──────────────────────────────────────────────── */

.mobile-menu-btn { display: none; position: fixed; top: 0.75rem; left: 0.75rem; z-index: 60; width: 40px; height: 40px; border: none; border-radius: 10px; background: var(--white); color: var(--primary); box-shadow: var(--shadow-md); cursor: pointer; align-items: center; justify-content: center; transition: all 0.2s ease; }
.mobile-menu-btn:hover { background: var(--light); }

.sidebar-close-btn { display: none; background: none; border: none; color: rgba(255,255,255,0.5); cursor: pointer; padding: 0.25rem; border-radius: 6px; transition: all 0.2s ease; }
.sidebar-close-btn:hover { color: var(--white); background: rgba(255,255,255,0.1); }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 40; opacity: 0; pointer-events: none; transition: opacity 0.3s var(--ease); }
.sidebar-overlay.active { opacity: 1; pointer-events: auto; }

/* ── Responsive ───────────────────────────────────────────────── */

@media (max-width: 1024px) {
    :root { --sidebar-w: 220px; }
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .stat-card-wide { grid-column: span 2; }
}

@media (max-width: 768px) {
    .sidebar { position: fixed; transform: translateX(-100%); transition: transform 0.3s var(--ease); z-index: 50; }
    .sidebar.open { transform: translateX(0); }
    .mobile-menu-btn { display: flex; }
    .sidebar-close-btn { display: block; }
    .sidebar-overlay { display: block; }
    .sidebar-header { display: flex; align-items: center; justify-content: space-between; }

    .main-content { margin-left: 0; max-width: 100vw; padding: 1.25rem; padding-top: 3.5rem; }

    .stats-row, .stats-row-3 { grid-template-columns: 1fr; }
    .stat-card-wide { grid-column: span 1; }
    .settings-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; gap: 0.5rem; }
    .header-date { align-items: flex-start; }
    .view-card { padding: 1rem; }
    .view-grid { grid-template-columns: 1fr; }

    .filters-form { flex-direction: column; }
    .filter-search-wrap, .filter-select { width: 100% !important; min-width: 0 !important; }

    .detail-list { grid-template-columns: 100px 1fr; gap: 0.4rem 0.75rem; }
    .detail-list-wide { grid-template-columns: 110px 1fr; }

    .doc-row { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .doc-actions { align-self: flex-end; }

    .upload-row { flex-direction: column; align-items: stretch; }
    .upload-label-input { min-width: 0 !important; }
    .upload-row .btn, .upload-row .upload-file-btn { width: 100%; justify-content: center; }

    .pipeline-card { padding: 1rem 0.75rem; }
    .pipeline-track { min-width: 0; flex-wrap: wrap; gap: 0.25rem 0; }
    .pipeline-step { flex: 0 0 33.33%; margin-bottom: 0.75rem; }
    .pipeline-track::before { display: none; }
    .pipeline-step.completed + .pipeline-step::before { display: none; }
    .pipeline-dot { width: 38px; height: 38px; }
    .pipeline-label { font-size: 0.68rem; max-width: 70px; }

    .dip-table tbody tr { cursor: pointer; }
    .dip-table tbody tr:active { background: rgba(13,148,136,0.06); }
}

@media (max-width: 480px) {
    .dip-table { font-size: 0.78rem; }
    .dip-table td, .dip-table th { padding: 0.5rem 0.6rem; }
}

/* ── View Tabs ───────────────────────────────────────────────── */

.view-tabs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
    margin-top: 0.75rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-bottom: none;
}

.view-tab {
    padding: 0.65rem 1.4rem;
    font-size: 0.9rem;
    font-weight: 700;
    font-family: inherit;
    color: var(--text-light);
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xs) var(--radius-xs) 0 0;
    border-bottom: 1.5px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    position: relative;
}

.view-tab:hover {
    color: var(--text);
    background: var(--light);
}

.view-tab.active {
    color: var(--secondary);
    background: var(--white);
    border-color: var(--secondary);
    border-bottom-color: var(--white);
    z-index: 1;
}

.view-tab-content {
    display: none;
}

.view-tab-content.active {
    display: block;
}

/* ── Role Badges (shared — used by messaging thread) ────────── */

.badge-role-admin    { background: var(--blue-bg); color: var(--blue); }
.badge-role-broker   { background: var(--warn-bg); color: var(--warn); }
.badge-role-borrower { background: var(--success-bg); color: var(--success); }

.badge-status-active  { background: var(--success-bg); color: var(--success); }
.badge-status-invited { background: var(--warn-bg); color: var(--warn); }

/* ── Messaging Thread ────────────────────────────────────────── */

.message-thread {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--light);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.message-bubble {
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    background: var(--white);
    border: 1px solid var(--border);
    max-width: 85%;
}

.message-role-admin    { border-left: 3px solid var(--blue); }
.message-role-broker   { border-left: 3px solid var(--warn); }
.message-role-borrower { border-left: 3px solid var(--success); }

.message-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.3rem;
    flex-wrap: wrap;
}

.message-sender { font-size: 0.82rem; color: var(--text); }

.message-time {
    font-size: 0.72rem;
    color: var(--text-light);
    margin-left: auto;
}

.message-body {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

.message-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.85rem;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    padding: 0.5rem 0.85rem;
    font-size: 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    resize: vertical;
    min-height: 40px;
    max-height: 120px;
    transition: border-color 0.2s ease;
}

.message-input:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(13,148,136,0.08);
}

.message-bubble-new {
    animation: message-fade-in 0.3s var(--ease);
}

@keyframes message-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Document Checklist ──────────────────────────────────────── */

.checklist-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.checklist-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
    gap: 0.75rem;
}

.checklist-row:last-child { border-bottom: none; }

.checklist-info {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
}

.checklist-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

.checklist-icon-outstanding { background: var(--border); color: var(--text-light); }
.checklist-icon-received    { background: var(--blue-bg); color: var(--blue); }
.checklist-icon-approved    { background: var(--success-bg); color: var(--success); }
.checklist-icon-rejected    { background: var(--error-bg); color: var(--error); }

.checklist-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-right: 0.4rem;
}

.checklist-meta {
    display: block;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.15rem;
}

.checklist-meta-rejected {
    color: var(--error);
    font-style: italic;
}

.checklist-actions {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 0;
}

.badge-outstanding { background: var(--border); color: var(--text-light); }
.badge-received    { background: var(--blue-bg); color: var(--blue); }
.badge-approved    { background: var(--success-bg); color: var(--success); }
.badge-rejected    { background: var(--error-bg); color: var(--error); }

.btn-success-outline {
    background: none;
    border: 1.5px solid var(--success);
    color: var(--success);
    cursor: pointer;
    border-radius: var(--radius-xs);
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: background 0.2s ease, color 0.2s ease;
}
.btn-success-outline:hover { background: var(--success-bg); }

.btn-danger-outline {
    background: none;
    border: 1.5px solid var(--error);
    color: var(--error);
    cursor: pointer;
    border-radius: var(--radius-xs);
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: background 0.2s ease, color 0.2s ease;
}
.btn-danger-outline:hover { background: var(--error-bg); }

.reject-reason-form {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-top: 0.4rem;
}

.reject-reason-form input {
    flex: 1;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xs);
    font-family: inherit;
}

.reject-reason-form input:focus {
    outline: none;
    border-color: var(--error);
}

.upload-checklist-select {
    padding: 0.4rem 0.6rem;
    font-size: 0.82rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xs);
    font-family: inherit;
    background: var(--white);
    color: var(--text);
    min-width: 160px;
    max-width: 240px;
}

.upload-checklist-select:focus {
    outline: none;
    border-color: var(--secondary);
}
