/* =============================================================================
   Condoit design system
   Sidebar application shell, Prancer purple brand, Inter UI type, Montserrat brand type.
   Built on Bootstrap 5.3 (grid, modals, dropdowns); everything visual is themed here.
   ============================================================================= */

@font-face { font-family: Inter; font-weight: 400; font-display: swap; src: url('/assets/lib/fonts/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: Inter; font-weight: 500; font-display: swap; src: url('/assets/lib/fonts/inter-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: Inter; font-weight: 600; font-display: swap; src: url('/assets/lib/fonts/inter-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: Inter; font-weight: 700; font-display: swap; src: url('/assets/lib/fonts/inter-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: Montserrat; font-weight: 500; font-display: swap; src: url('/assets/lib/fonts/montserrat-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: Montserrat; font-weight: 700; font-display: swap; src: url('/assets/lib/fonts/montserrat-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Roboto Mono'; font-weight: 400; font-display: swap; src: url('/assets/lib/fonts/roboto-mono-latin-400-normal.woff2') format('woff2'); }

:root {
    /* Brand */
    --brand: #7c3991;
    --brand-600: #6c2f80;
    --brand-700: #5a2569;
    --brand-50: #f6eff9;
    --brand-100: #ecdcf2;
    --brand-200: #d9bce5;
    --gold: #c79a2c;

    /* Shell */
    --sidebar-bg: #24112e;
    --sidebar-bg-2: #351a43;
    --sidebar-text: #cdbcd6;
    --sidebar-text-strong: #ffffff;
    --sidebar-hover: rgba(255, 255, 255, .07);
    --sidebar-width: 256px;

    /* Neutrals */
    --canvas: #f5f3f8;
    --surface: #ffffff;
    --surface-2: #faf9fc;
    --border: #e7e2ee;
    --border-strong: #d6cfe0;
    --text: #1f1a26;
    --text-2: #4d4558;
    --muted: #7a7187;

    /* Semantic */
    --green: #1f8a4c;  --green-bg: #e6f5ec;
    --red: #c23b3b;    --red-bg: #fbe9e9;
    --amber: #a8620a;  --amber-bg: #fdf1df;
    --blue: #2563b8;   --blue-bg: #e7effb;
    --teal: #0f766e;   --teal-bg: #e0f3f1;
    --indigo: #4b45b5; --indigo-bg: #ebeafb;
    --rose: #b4415d;   --rose-bg: #fbe8ee;
    --slate: #4f5a6b;  --slate-bg: #eceff3;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(31, 16, 41, .05);
    --shadow: 0 1px 2px rgba(31, 16, 41, .04), 0 6px 20px rgba(31, 16, 41, .06);
    --shadow-lg: 0 10px 40px rgba(31, 16, 41, .18);

    --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --font-brand: Montserrat, Inter, system-ui, sans-serif;
    --font-mono: 'Roboto Mono', Consolas, monospace;

    /* Bootstrap theming */
    --bs-primary: var(--brand);
    --bs-primary-rgb: 124, 57, 145;
    --bs-link-color: var(--brand-600);
    --bs-link-color-rgb: 108, 47, 128;
    --bs-link-hover-color: var(--brand-700);
    --bs-body-font-family: var(--font);
    --bs-body-color: var(--text);
    --bs-body-bg: var(--canvas);
    --bs-border-color: var(--border);
    --bs-border-radius: var(--radius-sm);
    --bs-focus-ring-color: rgba(124, 57, 145, .25);
}

* { -webkit-font-smoothing: antialiased; }
html, body { height: 100%; }
body { font-family: var(--font); font-size: 14.5px; color: var(--text); background: var(--canvas); font-feature-settings: "cv11", "ss01"; }
h1, h2, h3, h4, h5 { color: var(--text); letter-spacing: -.01em; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); text-decoration: underline; }
.tabular, td, .kpi-value { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted) !important; }
.small-caps { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; color: var(--muted); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); z-index: 1040;
    background: linear-gradient(180deg, var(--sidebar-bg-2) 0%, var(--sidebar-bg) 55%);
    color: var(--sidebar-text); display: flex; flex-direction: column;
    transition: transform .25s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 14px; }
.sidebar-brand img { height: 38px; width: auto; }
.sidebar-brand .app-name { font-family: var(--font-brand); font-weight: 700; color: #fff; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; opacity: .75; border-left: 1px solid rgba(255,255,255,.2); padding-left: 10px; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 6px 12px 12px; }
.nav-section { margin: 16px 10px 6px; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; font-weight: 600; color: rgba(205, 188, 214, .55); }
.side-link {
    display: flex; align-items: center; gap: 12px; padding: 9px 12px; margin: 2px 0;
    color: var(--sidebar-text); border-radius: 9px; font-weight: 500; font-size: 14px; text-decoration: none;
    border: 0; background: none; width: 100%; text-align: left;
}
.side-link i { font-size: 17px; width: 20px; text-align: center; opacity: .85; }
.side-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); text-decoration: none; }
.side-link.active { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(124, 57, 145, .45); }
.side-link.active i { opacity: 1; }
.side-link .count { margin-left: auto; background: #e04f6a; color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.sidebar-user { border-top: 1px solid rgba(255,255,255,.08); padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-200); color: var(--brand-700); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.sidebar-user .who { flex: 1; min-width: 0; line-height: 1.2; }
.sidebar-user .who strong { color: #fff; font-weight: 600; font-size: 13.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .who span { font-size: 12px; color: var(--sidebar-text); }
.icon-btn { border: 0; background: transparent; color: inherit; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; font-size: 17px; }
.sidebar .icon-btn:hover { background: var(--sidebar-hover); color: #fff; }

.main { flex: 1; margin-left: var(--sidebar-width); min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 1020; background: rgba(245, 243, 248, .85); backdrop-filter: saturate(160%) blur(10px);
    display: flex; align-items: center; gap: 12px; padding: 18px 28px 14px; border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar h1 { font-size: 22px; font-weight: 700; margin: 0; }
.topbar .subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }
.topbar .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.menu-toggle { display: none; }
.content { padding: 8px 28px 40px; }
.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(20, 8, 26, .45); z-index: 1035; }
    .main { margin-left: 0; }
    .menu-toggle { display: grid; background: var(--surface); border: 1px solid var(--border); color: var(--text); }
    .topbar { padding: 12px 16px; }
    .topbar h1 { font-size: 18px; }
    .content { padding: 6px 14px 32px; }
}

/* ---------- Surfaces ---------- */
.card-c { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-c + .card-c { margin-top: 18px; }
.card-c .card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-c .card-h h2, .card-c .card-h h3 { font-size: 15px; font-weight: 650; margin: 0; }
.card-c .card-h .tools { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-c .card-b { padding: 16px 18px; }
.card-c.pad { padding: 16px 18px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.kpi .kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .kpi-value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.kpi .kpi-sub { font-size: 12px; color: var(--muted); }
.kpi .kpi-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); font-size: 15px; }

/* ---------- Buttons & form ---------- */
.btn { font-weight: 500; border-radius: 9px; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover, .btn-brand:focus { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }
.btn-soft { background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-2); }
.btn-soft:hover { background: var(--brand-50); border-color: var(--brand-200); color: var(--brand-700); }
.btn-ghost { background: transparent; border: 0; color: var(--text-2); }
.btn-ghost:hover { background: var(--brand-50); color: var(--brand-700); }
.btn-danger-soft { background: var(--red-bg); color: var(--red); border: 1px solid transparent; }
.btn-danger-soft:hover { background: var(--red); color: #fff; }
.form-control, .form-select { border-radius: 9px; border-color: var(--border-strong); font-size: 14px; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(124, 57, 145, .15); }
.form-label { font-weight: 500; font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
.search-box { position: relative; }
.search-box i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 34px; min-width: 260px; background: var(--surface); }
@media (max-width: 575.98px) { .search-box input { min-width: 0; width: 100%; } .topbar .actions { width: 100%; } .search-box { flex: 1; } }

/* ---------- Status pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--slate-bg); color: var(--slate); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill.s-new { background: var(--brand-50); color: var(--brand-600); }
.pill.s-analyst { background: var(--blue-bg); color: var(--blue); }
.pill.s-paycall { background: var(--amber-bg); color: var(--amber); }
.pill.s-pending { background: var(--green-bg); color: var(--green); }
.pill.s-declined { background: var(--red-bg); color: var(--red); }
.pill.s-updated { background: var(--rose-bg); color: var(--rose); }
.pill.s-funding { background: var(--indigo-bg); color: var(--indigo); }
.pill.s-funded { background: var(--teal-bg); color: var(--teal); }
.pill.s-returned { background: var(--amber-bg); color: #8a4b12; }
.pill.s-recontract { background: var(--slate-bg); color: var(--slate); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: var(--slate-bg); color: var(--slate); }

/* ---------- Status tabs (quick filters) ---------- */
.seg { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.seg a { padding: 6px 12px; border-radius: 99px; font-size: 13px; font-weight: 500; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); text-decoration: none; }
.seg a:hover { border-color: var(--brand-200); color: var(--brand-700); }
.seg a.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.filter-chips .chip { background: var(--brand-50); color: var(--brand-700); border-radius: 99px; padding: 3px 10px; font-size: 12.5px; font-weight: 500; }

/* ---------- Data tables ---------- */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.table-wrap { overflow: auto; max-height: calc(100vh - 250px); }
.table-c { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table-c thead th {
    position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--muted);
    font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; font-weight: 600;
    padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none;
}
.table-c thead th[data-sort] { cursor: pointer; }
.table-c thead th[data-sort]:hover { color: var(--brand-700); }
.table-c thead th .arrow { display: inline-block; width: 10px; margin-left: 4px; color: var(--brand); }
.table-c tbody td { padding: 10px 14px; border-bottom: 1px solid #f0edf4; white-space: nowrap; vertical-align: middle; }
.table-c tbody tr:last-child td { border-bottom: 0; }
.table-c tbody tr.clickable { cursor: pointer; }
.table-c tbody tr.clickable:hover td { background: #faf6fc; }
.table-c tbody tr.clickable:focus-visible td { background: var(--brand-50); outline: none; }
.table-c .num { text-align: right; }
.table-c .id { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-2); }
.table-c .strong { font-weight: 600; color: var(--text); }
.table-foot { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; background: var(--surface-2); }
.fico { display: inline-block; min-width: 36px; text-align: right; font-weight: 600; }
.fico.lo { color: var(--red); } .fico.mid { color: var(--amber); } .fico.hi { color: var(--green); }
.score { display: inline-block; min-width: 36px; text-align: right; font-weight: 600; color: var(--text); }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty i { font-size: 34px; display: block; margin-bottom: 8px; color: var(--brand-200); }

/* Mobile: tables become cards */
@media (max-width: 767.98px) {
    .table-c.stack thead { display: none; }
    .table-c.stack, .table-c.stack tbody, .table-c.stack tr, .table-c.stack td { display: block; width: 100%; }
    .table-c.stack tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
    .table-c.stack td { border: 0; padding: 2px 0; white-space: normal; }
    .table-c.stack td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 92px; color: var(--muted); font-size: 12px; }
    .table-c.stack td.hide-sm { display: none; }
    .table-wrap { max-height: none; }
}

/* ---------- Detail views ---------- */
.detail-hero { display: flex; flex-wrap: wrap; gap: 18px 28px; align-items: flex-start; padding: 18px 20px; background: linear-gradient(135deg, var(--brand-50), #fff 70%); border-bottom: 1px solid var(--border); }
.detail-hero .title { font-size: 20px; font-weight: 700; margin: 0; }
.detail-hero .meta { color: var(--text-2); font-size: 13px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.detail-hero .facts { display: flex; flex-wrap: wrap; gap: 10px; margin-left: auto; }
.fact { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; min-width: 96px; }
.fact .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.fact .v { font-size: 16px; font-weight: 700; }
.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 24px; }
.dl-grid .dt { font-size: 12px; color: var(--muted); font-weight: 500; }
.dl-grid .dd { font-weight: 500; color: var(--text); word-break: break-word; }
.section-title { font-size: 13px; font-weight: 700; color: var(--brand-700); text-transform: uppercase; letter-spacing: .08em; margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.nav-tabs-c { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 16px; overflow-x: auto; background: #fff; }
.nav-tabs-c button { border: 0; background: none; padding: 12px 12px 10px; font-weight: 600; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.nav-tabs-c button:hover { color: var(--text); }
.nav-tabs-c button.active { color: var(--brand-700); border-bottom-color: var(--brand); }
.bureau-text { white-space: pre; font-family: var(--font-mono); font-size: 12px; line-height: 1.45; background: #fff; color: #000;
    border: 1px solid var(--border); border-radius: 10px; padding: 16px; overflow: auto; max-height: 70vh; margin: 0; cursor: zoom-in; }
.bureau-text:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.bureau-text:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Pop-out expanded view (any element with data-expand) */
.expand-dialog { width: min(1100px, 96vw); height: 92vh; max-width: none; max-height: none; padding: 0; border: 0; border-radius: 14px;
    box-shadow: 0 24px 60px rgba(20, 10, 30, .35); display: none; flex-direction: column; overflow: hidden; background: #fff; color: #000; }
.expand-dialog[open] { display: flex; }
.expand-dialog::backdrop { background: rgba(20, 12, 28, .55); }
.expand-dialog .expand-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.expand-dialog .expand-head h2 { font-size: 15px; font-weight: 600; margin: 0 auto 0 0; }
.expand-dialog .expand-head h2 { min-width: 0; }
.expand-dialog .expand-head .btn { flex: none; white-space: nowrap; }
.expand-dialog .expand-body { flex: 1; overflow: auto; margin: 0; padding: 20px 24px; white-space: pre; font-family: var(--font-mono);
    font-size: 14px; line-height: 1.5; background: #fff; color: #000; }
@media (max-width: 767.98px), (max-height: 500px) and (pointer: coarse) {
    /* Full screen on phones (also sideways) (condoit.js pins it to the visible area). Safe-area padding keeps the
       buttons clear of the notch and rounded corners (the app uses viewport-fit=cover). */
    .expand-dialog { width: 100%; height: 100%; height: 100dvh; inset: 0; margin: 0; border-radius: 0; }
    .expand-dialog .expand-head { gap: 4px; padding: calc(8px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 8px calc(12px + env(safe-area-inset-left)); }
    .expand-dialog .expand-head h2 { flex: 1 1 auto; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .expand-dialog .expand-head .close-text { display: none; }
    .expand-dialog .expand-body { font-size: 12px; padding: 10px calc(10px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left)); }
    .bureau-text { padding: 8px; } }
.stat-table { width: 100%; font-size: 13px; }
.stat-table th { font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px; text-align: right; }
.stat-table th:first-child, .stat-table td:first-child { text-align: left; }
.stat-table td { padding: 7px 8px; text-align: right; border-top: 1px solid #f0edf4; font-variant-numeric: tabular-nums; }
.stip-list { margin: 0; padding-left: 18px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: -6px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 1px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--brand-200); }
.timeline .when { font-size: 12px; color: var(--muted); }
.timeline .subj { font-weight: 600; font-size: 13px; }
.timeline .body { white-space: pre-line; font-size: 13.5px; color: var(--text-2); }
.check-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid #f0edf4; font-size: 13px; }
.check-row .desc { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check-row .desc.expanded { white-space: normal; }

/* ---------- Modal ---------- */
.modal-content { border: 0; border-radius: 16px; box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-xl-c .modal-dialog { max-width: min(1240px, 96vw); }
.modal-xl-c .modal-body { padding: 0; background: var(--canvas); }
@media (max-width: 767.98px) {
    .modal-xl-c .modal-dialog { margin: 0; max-width: 100vw; min-height: 100vh; min-height: 100dvh; height: 100dvh; }
    .modal-xl-c .modal-content { border-radius: 0; min-height: 100vh; min-height: 100dvh; }
}
/* Phones with a notch / Dynamic Island / rounded corners (the app draws edge to edge: viewport-fit=cover).
   Keep window headers and their close buttons below the camera area and inside the rounded corners. */
@media (max-width: 767.98px), (max-height: 500px) and (pointer: coarse) {
    .modal-xl-c .modal-header { position: sticky; top: 0; z-index: 3; background: var(--surface);
        padding-top: calc(.75rem + env(safe-area-inset-top)); padding-left: calc(1rem + env(safe-area-inset-left)); padding-right: calc(1rem + env(safe-area-inset-right)); }
    .modal-xl-c .modal-body { padding-bottom: env(safe-area-inset-bottom); padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
    .modal:not(.modal-xl-c) .modal-dialog { margin-top: calc(.5rem + env(safe-area-inset-top)); margin-bottom: calc(.5rem + env(safe-area-inset-bottom)); }
    .offcanvas-header { padding-top: calc(1rem + env(safe-area-inset-top)); padding-right: calc(1rem + env(safe-area-inset-right)); }
    .offcanvas-body { padding-bottom: calc(1rem + env(safe-area-inset-bottom)); }
    .modal-header .btn-close, .offcanvas-header .btn-close { min-width: 44px; min-height: 44px; }
}

/* ---------- Login ---------- */
body.bare { background: var(--canvas); }
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 1fr); }
.login-art {
    position: relative; overflow: hidden; color: #fff; padding: 48px;
    background: radial-gradient(1200px 600px at 10% 0%, #8f45a8 0%, transparent 60%), linear-gradient(160deg, #4a1f5c 0%, #24112e 100%);
    display: flex; flex-direction: column; justify-content: space-between;
}
.login-art .horse { position: absolute; right: -60px; bottom: -40px; width: 520px; opacity: .14; }
.login-art img.logo { height: 56px; width: auto; }
.login-art h2 { color: #fff; font-family: var(--font-brand); font-weight: 700; font-size: 36px; max-width: 460px; line-height: 1.15; }
.login-art p { color: rgba(255,255,255,.75); max-width: 420px; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { font-family: var(--font-brand); font-weight: 700; font-size: 28px; }
.login-card .form-control { padding: 11px 14px; font-size: 15px; }
.login-card .btn { padding: 11px; font-size: 15px; }
.login-error { background: var(--red-bg); color: var(--red); border-radius: 9px; padding: 10px 12px; font-size: 13.5px; }
@media (max-width: 860px) { .login { grid-template-columns: 1fr; } .login-art { padding: 28px; min-height: 180px; } .login-art h2 { font-size: 24px; } .login-art p { display: none; } }

.error-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.error-card { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 32px; max-width: 520px; box-shadow: var(--shadow); }

/* ---------- Misc ---------- */
.alert-c { border-radius: 10px; padding: 10px 14px; font-size: 13.5px; display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.alert-c.ok { background: var(--green-bg); color: var(--green); }
.alert-c.err { background: var(--red-bg); color: var(--red); }
.alert-c.info { background: var(--blue-bg); color: var(--blue); }
.loader-bar { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--gold); z-index: 2000; transition: width .4s ease; }
.loader-bar.go { width: 70%; }
.spinner-c { width: 28px; height: 28px; border: 3px solid var(--brand-100); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.secret { filter: blur(5px); transition: filter .2s; }
.toast-c { position: fixed; right: 20px; bottom: 20px; z-index: 3000; background: #24112e; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 14px; opacity: 0; transform: translateY(10px); transition: all .25s; }
.toast-c.show { opacity: 1; transform: none; }
@media print { .sidebar, .topbar .actions, .no-print { display: none !important; } .main { margin: 0; } body { background: #fff; } }

/* ---------- Refinements ---------- */
.btn-brand:disabled, .btn-brand.disabled { background: var(--brand-200); border-color: var(--brand-200); color: #fff; opacity: 1; }
.text-uppercase::placeholder { text-transform: none; }
@media (max-width: 991.98px) {
    .topbar { flex-wrap: wrap; row-gap: 10px; }
    .topbar .actions { flex: 1 1 100%; margin-left: 0; }
    .topbar .actions .search-box { flex: 1; }
    .topbar .actions .search-box input { min-width: 0; width: 100%; }
    .seg { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
    .seg::-webkit-scrollbar { display: none; }
    .seg a { flex: none; }
}
@media (max-width: 767.98px) {
    .table-c.stack td.num { text-align: left; }
    .table-c.stack td[data-label]::before { font-weight: 400; }
    .table-c.stack td.strong { font-size: 15px; }
}
.login-art img.logo, .sidebar-brand img { align-self: flex-start; object-fit: contain; max-width: 240px; }
@media (max-width: 767.98px) { .table-c.stack .fico { min-width: 0; text-align: left; } }

/* ---------- Employee Portal integration ---------- */
.side-link .ext { margin-left: auto; font-size: 11px; width: auto; opacity: .55; }
.staff-notice { display: flex; gap: 12px; align-items: flex-start; background: var(--brand-50); border: 1px solid rgba(124, 57, 145, .18);
    border-left: 4px solid var(--brand); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.staff-notice > .bi { color: var(--brand); font-size: 18px; margin-top: 1px; }
.staff-notice .body { flex: 1; min-width: 0; }
.staff-notice .t { font-weight: 600; }
.staff-notice .icon-btn { flex: none; }

/* ======================================================================
   Phones & tablets - most sales reps only ever use Condoit on a phone.
   ====================================================================== */
.m-card, .tabbar { display: none; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.quick-actions .btn { display: inline-flex; align-items: center; gap: 6px; }

@media (max-width: 991.98px) {
    /* Bottom tab bar (layout.asp WriteTabBar) */
    body.has-tabbar .tabbar {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
        background: rgba(255, 255, 255, .97); backdrop-filter: blur(12px) saturate(160%); -webkit-backdrop-filter: blur(12px) saturate(160%);
        border-top: 1px solid var(--border); padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
        box-shadow: 0 -4px 18px rgba(31, 16, 41, .06);
    }
    .tabbar .tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 54px; padding: 4px 2px;
        border: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 600; text-decoration: none; position: relative; border-radius: 12px;
        -webkit-tap-highlight-color: transparent; }
    .tabbar .tab i { font-size: 21px; line-height: 1; }
    .tabbar .tab:active { background: var(--brand-50); }
    .tabbar .tab.active { color: var(--brand); }
    .tabbar .tab.active i { background: var(--brand-50); border-radius: 99px; padding: 3px 16px; margin: -3px 0; }
    .tabbar .badge-dot { position: absolute; top: 3px; left: calc(50% + 7px); background: #e04f6a; color: #fff; font-size: 10.5px; font-weight: 700;
        min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: grid; place-items: center; border: 2px solid #fff; box-sizing: content-box; }
    body.has-tabbar .content { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
    body.has-tabbar .menu-toggle { display: none; }
    body.has-tabbar .toast-c { left: 14px; right: 14px; bottom: calc(74px + env(safe-area-inset-bottom)); text-align: center; }
    .topbar { padding-top: calc(12px + env(safe-area-inset-top)); }
    .sidebar { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }

    /* Page actions that aren't a search box stay on the title row */
    .topbar .actions:not(:has(.search-box)) { flex: 0 0 auto; width: auto; margin-left: auto; }

    /* Comfortable touch targets */
    .icon-btn { width: 40px; height: 40px; }
    .seg a { padding: 8px 14px; }
    .btn-sm { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
    .btn-close { padding: .8rem; }

    /* 16px inputs: iPhones don't zoom the page when you tap a field */
    .form-control, .form-select, .form-control-sm, .form-select-sm { font-size: 16px; }
    .form-control:not(textarea), .form-select { min-height: 44px; }
}

@media (max-width: 767.98px) {
    /* Lists become compact cards (td.m-card) instead of label/value stacks */
    .table-c.stack tr:has(> td.m-card) > td:not(.m-card) { display: none; }
    .table-c.stack tr > td.m-card { display: block; padding: 0; }
    .table-c.stack tr:has(> td.m-card) { padding: 12px 16px; }
    .table-c.stack tr.clickable:has(> td.m-card) { position: relative; padding-right: 34px; }
    .table-c.stack tr.clickable:has(> td.m-card)::after { content: "\F285"; font-family: bootstrap-icons; position: absolute; right: 12px; top: 50%;
        transform: translateY(-50%); color: var(--border-strong); font-size: 14px; }
    .table-c.stack tr.clickable:active td { background: var(--brand-50); }
    .m-card .mc-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
    .m-card .mc-title { font-weight: 650; font-size: 15.5px; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .m-card .mc-sub { display: flex; justify-content: space-between; gap: 10px; color: var(--text-2); font-size: 14px; margin-top: 3px; }
    .m-card .mc-sub > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .m-card .mc-fico { flex: none; font-size: 12px; color: var(--muted); }
    .m-card .mc-fico .fico { min-width: 0; font-size: 14px; }
    .m-card .mc-fico .score { min-width: 0; font-size: 14px; }
    .m-card .mc-meta { display: flex; flex-wrap: nowrap; overflow: hidden; white-space: nowrap; color: var(--muted); font-size: 12.5px; margin-top: 5px; }
    .m-card .mc-meta > span + span::before { content: "·"; margin: 0 7px; }
    .m-card .mc-meta .id { font-family: var(--font-mono); font-size: 12px; }
    .m-card .mc-body { color: var(--text-2); font-size: 14px; white-space: pre-line; margin-top: 2px; word-break: break-word; }
    .m-card > .mc-meta:first-child { margin-top: 0; margin-bottom: 2px; }
    .m-card > .mc-title:not(:first-child) { white-space: normal; }

    /* KPI tiles: three across, compact */
    .kpis { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin-bottom: 12px; }
    .kpi { padding: 10px 12px; }
    .kpi .kpi-icon, .kpi .kpi-sub { display: none; }
    .kpi .kpi-label { font-size: 11.5px; }
    .kpi .kpi-value { font-size: 21px; margin-top: 2px; }

    /* Application / dealer detail */
    .detail-hero { padding: 14px 16px; gap: 12px; }
    .detail-hero > div:first-child { width: 100%; }
    .detail-hero .facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-left: 0; width: 100%; }
    .fact { min-width: 0; padding: 7px 10px; }
    .fact .l { font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .fact .v { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .modal .detail-hero > div:first-child > .small-caps:first-child { display: none; }   /* the modal title already says it */
    .modal .nav-tabs-c { position: sticky; top: 0; z-index: 6; box-shadow: 0 1px 0 var(--border); }
    .nav-tabs-c { padding: 0 6px; scrollbar-width: none; }
    .nav-tabs-c::-webkit-scrollbar { display: none; }
    .nav-tabs-c button { padding: 13px 11px 11px; font-size: 14px; }
    .dl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
    .dl-grid .dd { font-size: 14.5px; }
    .card-c .card-h { padding: 12px 14px; }
    .card-c .card-b, .card-c.pad { padding: 14px; }
    .detail-root .p-3 { padding: 12px !important; }
    .stat-table { font-size: 12.5px; }
    .stat-table th { font-size: 10.5px; letter-spacing: .02em; padding: 6px 4px; }
    .stat-table td { padding: 7px 4px; }
    .cmt-actions .btn { flex: 1; }
    .check-row { flex-wrap: wrap; row-gap: 4px; padding: 9px 0; }
    .check-row .desc { flex: 1 1 100%; white-space: normal; font-weight: 500; }
    .check-row > span[style] { min-width: 0 !important; }
    .quick-actions { width: 100%; }
    .quick-actions .btn { flex: 1; justify-content: center; min-height: 44px; }

    /* Sign-in: a compact brand header, form right away */
    .login-art { min-height: 0; padding: calc(18px + env(safe-area-inset-top)) 22px 18px; gap: 8px; }
    .login-art img.logo { height: 38px; }
    .login-art h2 { font-size: 19px; margin: 8px 0 0; }
    .login-art > .small { display: none; }
    .login-art .horse { width: 280px; right: -80px; bottom: -70px; }
    .login-form { padding: 26px 20px 40px; align-items: flex-start; }
    .login-card h1 { font-size: 24px; }
    .login-card .form-control { font-size: 16px; min-height: 48px; }
    .login-card .btn { min-height: 48px; font-size: 16px; }
}
@media (max-width: 991.98px) {
    .modal-header .btn-close, .offcanvas-header .btn-close { padding: .85rem; margin: -.5rem -.5rem -.5rem auto; }
    .msg-list-card .seg a { padding: 8px 14px; }
    .expand-dialog .expand-head .btn { min-width: 40px; }
}
@media (max-width: 767.98px) { .check-row a.desc { padding: 8px 0; } }
@media (max-width: 767.98px) {
    .fact { padding: 7px 8px; }
    .fact .l { white-space: normal; line-height: 1.2; }
    .fact .v { font-size: clamp(13px, 3.8vw, 15px); letter-spacing: -.01em; }
    .content > .detail-root { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
    .content > .detail-root .nav-tabs-c { border-radius: 0; }
}

/* Deal Manager: column picker and the extra (old CONDOIT) columns */
#dealTable .col-off { display: none !important; }
#dealTable thead th, #dealTable tbody td { padding-left: 10px; padding-right: 10px; }
#dealTable thead th:first-child, #dealTable tbody td:first-child { padding-left: 14px; }
.col-group { margin-bottom: 14px; }
.col-opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.col-opt:hover { background: var(--surface-2); }
.col-opt .form-check-input { margin-top: 3px; flex: none; }
.col-opt span { display: flex; flex-direction: column; line-height: 1.3; }
.col-opt small { color: var(--muted); font-size: 12px; }
.col-opt.locked { opacity: .65; cursor: default; }
.ind-tag { background: var(--amber-bg, #fff4dc); color: var(--amber, #a86a00); font-weight: 600; }
.tag.src-dt, .tag.src-rt1 { font-weight: 600; }
.m-card .mc-extra { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 12.5px; color: var(--text-2); }
.m-card .mc-extra small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; }
.m-card .mc-extra .fico { min-width: 0; }

/* Application view: tab change by swipe (condoit.js) */
@keyframes swipeInLeft { from { transform: translateX(28px); opacity: .35; } to { transform: none; opacity: 1; } }
@keyframes swipeInRight { from { transform: translateX(-28px); opacity: .35; } to { transform: none; opacity: 1; } }
.swipe-in-left { animation: swipeInLeft .18s ease-out; }
.swipe-in-right { animation: swipeInRight .18s ease-out; }
@media (prefers-reduced-motion: reduce) { .swipe-in-left, .swipe-in-right { animation: none; } }
