/* SHF Redesign — EXTRAS
   Separate file for new/updated tokens. Do not edit assets/shf.css. */

/* ========= Responsive breakpoints ========= */
/* Mobile 375 · Tablet 768 · Desktop 1280 · Large 1440 · XL 1920 */

@media (max-width: 1440px) {
    .app {
        max-width: 100%;
    }
}

@media (max-width: 1280px) {
    .content {
        padding: 20px 20px 60px;
    }

    .page-header {
        padding: 16px 20px 0;
    }

    .grid.c-main {
        grid-template-columns: 1fr;
    }

    .grid.c4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid.c5 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .grid.c3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .topbar .top-search {
        max-width: 260px;
    }

    .compare {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .nav-primary {
        overflow-x: auto;
        white-space: nowrap;
    }

    .topbar-right .user-chip span:not(.avatar) {
        display: none;
    }

    .grid.c2 {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .kv-grid {
        grid-template-columns: 1fr;
    }

    .head-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .tabs {
        gap: 0;
        font-size: 12px;
    }

    .tab {
        padding: 8px 10px;
    }

    .stage-grid {
        grid-template-columns: 1fr;
    }

    .stage-rail .stg {
        min-width: 100px;
    }

    .stat-cell {
        border-right: none;
        border-bottom: 1px solid var(--line);
    }
}

@media (max-width: 768px) {
    .page-header h1 {
        font-size: 22px;
    }

    .kpi .v {
        font-size: 22px;
    }

    .grid.c4,
    .grid.c5 {
        grid-template-columns: 1fr 1fr;
    }

    .head-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .head-actions .btn {
        flex: 1;
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-row>* {
        width: 100%;
    }

    .tbl {
        font-size: 11px;
    }

    .tbl th,
    .tbl td {
        padding: 8px 10px;
    }

    .mobile-hide {
        display: none !important;
    }

    .dvr-row {
        grid-template-columns: 60px 16px 1fr;
        gap: 8px;
    }

    .pp-row {
        grid-template-columns: 1fr;
    }

    .pp-s {
        display: none;
    }

    .matrix {
        font-size: 11px;
    }

    .matrix th,
    .matrix td {
        padding: 6px 4px;
    }

    .card-hd,
    .card-ft {
        padding: 12px 14px;
    }

    .card-bd {
        padding: 14px;
    }
}

@media (max-width: 480px) {
    .topbar {
        padding: 8px 10px;
        gap: 8px;
    }

    .logo-text {
        display: none;
    }

    .topbar .top-search {
        display: none;
    }

    .content {
        padding: 14px 12px 60px;
    }

    .page-header {
        padding: 14px 12px 0;
    }

    .page-header h1 {
        font-size: 20px;
    }

    .grid.c4,
    .grid.c5 {
        grid-template-columns: 1fr;
    }

    .kpi {
        padding: 12px 14px;
    }

    .btn {
        padding: 7px 10px;
        font-size: 11px;
    }

    .btn.primary {
        padding: 8px 12px;
    }

    .summary-card .val {
        font-size: 22px;
    }

    .stage-rail .stg {
        min-width: 90px;
        padding: 0 4px;
    }

    .stage-rail .stg .sn {
        width: 36px;
        height: 36px;
        font-size: 12px;
    }

    .stage-rail .stg .st {
        font-size: 10.5px;
    }
}

/* ========= Interactive / hover states ========= */
.btn {
    cursor: pointer;
}

.btn:active {
    transform: translateY(1px);
}

.screen-card {
    cursor: pointer;
}

.tbl tbody tr.clickable {
    cursor: pointer;
    transition: background 0.1s;
}

.tbl tbody tr.clickable:hover {
    background: var(--accent-soft);
}

.doc-row,
.notif,
.dvr-row,
.v-row {
    transition: background 0.1s;
}

.doc-row:hover,
.notif:hover,
.v-row:hover {
    background: var(--paper);
}

/* Toasts */
.toast-host {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
}

.toast-msg {
    background: var(--ink);
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 12.5px;
    font-family: 'Jost', sans-serif;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transform: translateY(8px);
    transition: all 0.2s;
    pointer-events: auto;
    max-width: 340px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast-msg.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-msg .icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 11px;
    flex-shrink: 0;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(28, 26, 27, 0.55);
    display: grid;
    place-items: center;
    z-index: 9000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s;
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: #fff;
    border-radius: 12px;
    width: min(560px, 92vw);
    max-height: 90vh;
    overflow: auto;
    transform: translateY(12px);
    transition: transform 0.18s;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
}

.modal-backdrop.open .modal {
    transform: translateY(0);
}

.modal-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-head .t {
    font-family: 'Jost';
    font-size: 16px;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
}

.modal-foot {
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    background: var(--paper);
}

.modal .close {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--ink-4);
    cursor: pointer;
    line-height: 1;
}

/* Conditional field animation */
.cond-field {
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s ease, margin 0.2s ease;
}

.cond-field[hidden],
.cond-field.hide {
    display: block !important;
    max-height: 0;
    opacity: 0;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    pointer-events: none;
}

.cond-field:not(.hide) {
    max-height: 1200px;
    opacity: 1;
}

/* Emphasise active rows/steps when jumping stage via tweaks */
.stage-card.focused {
    animation: focusPulse 1.4s ease;
}

@keyframes focusPulse {
    0% {
        box-shadow: 0 0 0 0 var(--accent);
    }

    50% {
        box-shadow: 0 0 0 6px var(--accent-soft);
    }

    100% {
        box-shadow: 0 0 0 3px var(--accent-soft);
    }
}

/* Image placeholders */
.ph-img {
    background:
        linear-gradient(135deg, var(--paper-2), var(--paper)),
        repeating-linear-gradient(45deg, transparent 0, transparent 10px, rgba(0, 0, 0, 0.03) 10px, rgba(0, 0, 0, 0.03) 11px);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: var(--ink-4);
    font-family: 'Jost';
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Timeline (loan timeline page) */
.timeline-full {
    padding: 8px 0;
}

.tl-event {
    display: grid;
    grid-template-columns: 140px 28px 1fr;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px dashed var(--line);
    align-items: flex-start;
}

.tl-event:last-child {
    border-bottom: none;
}

.tl-event .when {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--ink-4);
    padding-top: 4px;
}

.tl-event .axis {
    position: relative;
}

.tl-event .axis .d {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    margin: 4px auto 0;
}

.tl-event .axis::before {
    content: '';
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: calc(100% + 14px);
    background: var(--line);
}

.tl-event:last-child .axis::before {
    display: none;
}

.tl-event.minor .axis .d {
    background: var(--ink-4);
    width: 8px;
    height: 8px;
    margin-top: 6px;
}

.tl-event.alert .axis .d {
    background: var(--red);
}

.tl-event .body .t {
    font-weight: 600;
    font-size: 13px;
}

.tl-event .body .m {
    font-size: 11.5px;
    color: var(--ink-4);
    margin-top: 3px;
    line-height: 1.45;
}

.tl-event .body .meta {
    font-size: 10.5px;
    color: var(--ink-4);
    margin-top: 6px;
    font-family: 'JetBrains Mono', monospace;
}

/* Transfers */
.transfer-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 10px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px dashed var(--line);
}

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

.transfer-row .from,
.transfer-row .to {
    background: var(--paper);
    border-radius: 8px;
    padding: 10px 12px;
    border: 1px solid var(--line);
}

.transfer-row .arrow {
    color: var(--accent);
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    padding: 0 10px;
}

/* Compact table variant */
.tbl.compact th,
.tbl.compact td {
    padding: 8px 12px;
    font-size: 11.5px;
}

/* Toggle switch (used in settings) */
.toggle {
    width: 34px;
    height: 18px;
    background: var(--line-strong);
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    display: inline-block;
    vertical-align: middle;
    transition: background 0.15s;
}

.toggle::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    top: 2px;
    left: 2px;
    transition: transform 0.18s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.toggle.on {
    background: var(--accent);
}

.toggle.on::after {
    transform: translateX(16px);
}

/* Segmented control */
.segmented {
    display: inline-flex;
    background: var(--paper-2);
    border-radius: 6px;
    padding: 2px;
    gap: 2px;
}

.segmented button {
    padding: 5px 12px;
    border: none;
    background: transparent;
    font-family: 'Jost';
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ink-3);
    cursor: pointer;
    border-radius: 5px;
}

.segmented button.active {
    background: #fff;
    color: var(--ink);
    box-shadow: var(--sh-1);
}

/* Kbd */
kbd {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10.5px;
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    padding: 1px 5px;
    border-radius: 3px;
    color: var(--ink-3);
}

/* Small helpers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.pointer {
    cursor: pointer;
}

.pt-0 {
    padding-top: 0 !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.divider-h {
    height: 1px;
    background: var(--line);
    margin: 14px 0;
}


/* ============ Stage rail (12-stage loan workflow) ============ */
.stage-rail {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 0;
    position: relative;
    padding: 8px 0 4px;
}

.stage-rail::before {
    content: '';
    position: absolute;
    top: 30px;
    left: 4%;
    right: 4%;
    height: 2px;
    background: var(--line);
    z-index: 0;
}

.stage-rail .stg {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 0 4px;
    min-width: 0;
}

/* ============ Selector aliases — match actual HTML in loan-show / loan-stages ============ */
.stage-rail .stg .num {
    /* matches the big rail */
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--line);
    display: grid;
    place-items: center;
    margin: 0 auto;
    font-family: 'Jost', sans-serif;
    font-weight: 600;
    font-size: 14px;
    color: var(--ink-4);
    transition: all 0.15s;
    box-sizing: border-box;
}

.stage-rail .stg .lbl {
    margin-top: 8px;
    font-size: 11.5px;
    color: var(--ink-3);
    font-weight: 500;
    line-height: 1.3;
    text-transform: none;
    letter-spacing: 0;
}

.stage-rail .stg .meta {
    font-size: 10px;
    color: var(--ink-4);
    font-family: 'JetBrains Mono', monospace;
    margin-top: 2px;
}

.stage-rail .stg.done .num {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.stage-rail .stg.current .num {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.stage-rail .stg.current .lbl {
    color: var(--accent-deep);
    font-weight: 600;
}

.stage-rail .stg.current .meta {
    color: var(--accent);
}

.stage-rail .stg.amber .num {
    background: var(--amber-soft);
    border-color: var(--amber);
    color: var(--amber);
}

/* stage-card uses .num as inner big type — make sure it keeps its display:flex look in stage-card context */
.stage-card .h .num {
    width: auto;
    height: auto;
    border: 0;
    background: transparent;
    display: inline;
    margin: 0;
    font-size: 22px;
    color: var(--ink-4);
    box-shadow: none;
}

.stage-card .h .num strong {
    color: var(--ink);
}

/* cibil block alt class names */
.cibil .v {
    font-family: 'Jost';
    font-size: 40px;
    font-weight: 600;
    line-height: 1;
    color: var(--green);
    font-variant-numeric: tabular-nums;
}

.cibil .l {
    font-size: 10.5px;
    color: var(--ink-4);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

/* Ensure clickable is cursor pointer without needing tbody tr */
.clickable {
    cursor: pointer;
}

/* current-row highlight */
.tbl tbody tr.current-row td {
    background: var(--accent-soft);
}

.tbl tbody tr.current-row td:first-child {
    box-shadow: inset 3px 0 0 var(--accent);
}


/* ============ Parallel processing rows (loan-show) ============ */
.parallel {
    display: grid;
}

.pp-row {
    display: grid;
    grid-template-columns: 1.6fr 1.4fr 0.8fr;
    gap: 12px;
    padding: 12px 18px;
    border-top: 1px solid var(--line);
    align-items: center;
    font-size: 13px;
}

.pp-row:first-child {
    border-top: 0;
}

.pp-l {
    color: var(--ink);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pp-r {
    color: var(--ink-2);
    font-size: 12.5px;
}

.pp-s {
    text-align: right;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 8px;
    background: var(--ink-4);
}

.dot.green {
    background: var(--green);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--green) 18%, transparent);
}

.dot.amber {
    background: var(--amber);
    box-shadow: 0 0 0 3px var(--amber-soft);
}

.dot.red {
    background: var(--red);
    box-shadow: 0 0 0 3px var(--red-soft);
}

.dot.blue {
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ============ Stage cards (loan-stages.html) ============ */
.stage-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (min-width: 1280px) {
    .stage-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.stage-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    margin-bottom: 12px;
    overflow: hidden;
}

.stage-card .sh {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    border-bottom: 1px solid transparent;
}

.stage-card .sn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--line);
    display: grid;
    place-items: center;
    font-family: 'Jost', sans-serif;
    font-weight: 600;
    font-size: 13px;
    color: var(--ink-4);
    flex: 0 0 38px;
}

.stage-card .st {
    font-family: 'Jost', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.2;
}

.stage-card .sm {
    font-size: 12px;
    color: var(--ink-3);
    margin-top: 3px;
}

.stage-card .sh>div:not(:first-child):not(:last-child) {
    flex: 1;
}

.stage-card .sh>.badge {
    margin-left: auto;
}

.stage-card.done .sn {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.stage-card.current {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.stage-card.current .sn {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.stage-card.current .sh {
    background: color-mix(in oklab, var(--accent-soft) 50%, #fff);
}

/* Mobile: stack pp-row single column */
@media (max-width: 768px) {
    .pp-row {
        grid-template-columns: 1fr;
        gap: 4px;
        padding: 10px 14px;
    }

    .pp-r,
    .pp-s {
        text-align: left;
        font-size: 12px;
    }

    .stage-card .sh {
        padding: 12px 14px;
        gap: 12px;
    }

    .stage-card .sn {
        width: 34px;
        height: 34px;
        flex: 0 0 34px;
        font-size: 12px;
    }
}


/* ============ Dropdown menus (filter buttons with ▾) ============ */
.shf-dropdown {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.06);
    padding: 6px;
    min-width: 180px;
    max-height: 360px;
    overflow-y: auto;
    animation: ddIn 0.12s ease-out;
}

@keyframes ddIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.shf-dropdown-item {
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    user-select: none;
}

.shf-dropdown-item:hover {
    background: var(--accent-soft);
    color: var(--accent-deep);
}

.shf-dropdown-clear {
    border-top: 1px solid var(--line);
    margin-top: 4px;
    padding-top: 10px;
    color: var(--red);
    font-size: 12px;
}

.shf-dropdown-clear:hover {
    background: var(--red-soft);
    color: var(--red);
}

.btn.dd-open {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-deep);
}

.btn.dd-selected {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-deep);
    font-weight: 500;
}

/* ============ Native <select> styling ============ */
select.input,
select.select,
.field select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}

select.input:focus,
select.select:focus,
.field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}


/* Prevent root-level horizontal overflow on ALL viewports */
html,
body {
    max-width: 100vw;
    overflow-x: hidden;
}

.app {
    max-width: 100%;
    overflow-x: hidden;
}

/* ============ REAL MOBILE RESPONSIVENESS (<=768) ============ */
@media (max-width: 768px) {

    /* Universal: any fixed-column inline grid collapses gracefully */
    [style*="grid-template-columns:repeat(6"],
    [style*="grid-template-columns: repeat(6"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    [style*="grid-template-columns:repeat(5"],
    [style*="grid-template-columns: repeat(5"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    [style*="grid-template-columns:repeat(4"],
    [style*="grid-template-columns: repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    [style*="grid-template-columns:repeat(3"],
    [style*="grid-template-columns: repeat(3"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Photos/thumbnails stay in 3-col */
    .photos[style*="grid-template-columns"],
    [data-photos][style*="grid-template-columns"] {
        grid-template-columns: repeat(3, 1fr) !important;
    }

    /* Cards & content never overflow */


    .card,
    .panel,
    main.content,
    .content {
        max-width: 100%;
        min-width: 0;
    }

    .card>*,
    .card-bd>*,
    .card-hd>*,
    .card-ft>* {
        min-width: 0;
    }

    /* Images, SVGs, pre never push width */
    img,
    svg,
    canvas,
    video,
    pre {
        max-width: 100%;
    }

    /* Topbar: hide nav items, show hamburger */
    .topbar {
        position: sticky;
        top: 0;
        z-index: 50;
        padding: 10px 12px;
        gap: 8px;
    }

    .topbar .logo-text {
        display: none;
    }

    .topbar .nav-primary {
        position: fixed;
        top: 0;
        left: -320px;
        bottom: 0;
        width: 280px;
        max-width: 82vw;
        background: #1a1a1a !important;
        color: #fff !important;
        border-right: 1px solid rgba(255, 255, 255, 0.08);
        flex-direction: column;
        align-items: stretch;
        padding: 60px 10px 16px;
        gap: 2px;
        overflow-y: auto;
        transition: left 0.25s ease;
        z-index: 100;
        box-shadow: 4px 0 30px rgba(0, 0, 0, 0.4);
        white-space: normal;
    }

    body.nav-open .topbar .nav-primary {
        left: 0;
    }

    body.nav-open::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 90;
    }

    .topbar .nav-primary .nav-item {
        padding: 13px 14px !important;
        border-radius: 8px;
        font-size: 15px !important;
        font-weight: 500;
        width: 100%;
        justify-content: flex-start !important;
        gap: 12px !important;
        color: rgba(255, 255, 255, 0.9) !important;
        background: transparent !important;
        opacity: 1 !important;
        visibility: visible !important;
        display: flex !important;
    }

    .topbar .nav-primary .nav-item:hover,
    .topbar .nav-primary .nav-item:focus {
        background: rgba(241, 90, 41, 0.14) !important;
        color: #ff8a5b !important;
    }

    .topbar .nav-primary .nav-item.active {
        background: rgba(241, 90, 41, 0.18) !important;
        color: #ff8a5b !important;
    }

    .topbar .nav-primary .nav-item svg {
        opacity: 0.85;
    }

    /* Settings dropdown inside drawer: inline all items */
    .topbar .nav-primary .nav-dd-wrap {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .topbar .nav-primary .nav-dd-wrap::after {
        display: none;
    }

    .topbar .nav-primary .nav-dd {
        position: static;
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
        transform: none;
        box-shadow: none;
        border: none;
        background: transparent;
        padding: 4px 0 8px 40px;
        margin: 0;
    }

    .topbar .nav-primary .nav-dd-item {
        color: rgba(255, 255, 255, 0.7) !important;
        font-size: 13px;
        padding: 8px 10px;
    }

    .topbar .nav-primary .nav-dd-item:hover {
        color: #ff8a5b !important;
        background: rgba(255, 255, 255, 0.04);
    }

    /* Hamburger button (injected) */
    .m-hamburger {
        display: flex !important;
        width: 36px;
        height: 36px;
        border: 1px solid var(--line);
        background: #fff;
        border-radius: 8px;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex: 0 0 36px;
    }

    .m-hamburger svg {
        width: 18px;
        height: 18px;
    }

    /* Top search collapses */
    .topbar .search-wrap,
    .topbar .top-search {
        display: none !important;
    }

    .topbar-right {
        gap: 6px;
        margin-left: auto;
    }

    .topbar-right .user-chip {
        padding: 4px 6px;
    }

    .topbar-right .user-chip span:not(.avatar) {
        display: none;
    }

    .topbar-right .icon-btn {
        width: 36px;
        height: 36px;
    }

    /* Page header cleanup */
    .page-header {
        padding: 14px 14px 0;
    }

    .page-header .head-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .page-header h1 {
        font-size: 22px;
        line-height: 1.2;
    }

    .head-actions {
        flex-wrap: wrap;
        gap: 6px;
    }

    .head-actions .btn {
        flex: 1 1 auto;
    }

    /* KPI / stat grids: force responsive */
    .grid.c2,
    .grid.c3,
    .grid.c4,
    .grid.c5 {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .grid.c-main {
        grid-template-columns: 1fr;
    }

    .kpi-grid,
    .stat-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    .kpi {
        padding: 12px 14px;
    }

    .kpi .v,
    .kpi .val {
        font-size: 22px !important;
    }

    .kpi .sub {
        font-size: 10.5px;
    }

    /* Content padding */
    .content {
        padding: 14px 14px 80px;
    }

    .card-hd {
        padding: 12px 14px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .card-bd {
        padding: 14px;
    }

    .card-ft {
        padding: 12px 14px;
        flex-wrap: wrap;
        gap: 8px;
    }

    /* =============== Tables: convert to card list on mobile =============== */
    .card-bd {
        overflow-x: visible;
    }

    /* Wrap is for tables we truly can't convert */
    .tbl-wrap,
    .tbl-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table.tbl {
        display: block;
        width: 100%;
        min-width: 0 !important;
        font-size: 13px;
        border: none;
    }

    table.tbl thead {
        display: none;
    }

    table.tbl tbody {
        display: block;
        width: 100%;
    }

    table.tbl tr {
        display: block;
        padding: 12px 14px;
        border: 1px solid var(--line);
        border-radius: 8px;
        margin-bottom: 10px;
        background: #fff;
    }

    table.tbl tr:last-child {
        margin-bottom: 0;
    }

    table.tbl td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        padding: 6px 0;
        border: none;
        white-space: normal;
        text-align: left;
        min-height: 26px;
    }

    table.tbl td::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 600;
        color: var(--ink-3, #666);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        flex: 0 0 38%;
        text-align: left;
    }

    table.tbl td:first-child {
        font-weight: 600;
        font-size: 14px;
        border-bottom: 1px dashed var(--line);
        padding-bottom: 8px;
        margin-bottom: 4px;
    }

    table.tbl td:first-child::before {
        display: none;
    }

    table.tbl td.num,
    table.tbl td.tnum {
        text-align: right;
        justify-content: space-between;
    }

    table.tbl td .badge,
    table.tbl td .btn {
        flex: 0 0 auto;
    }

    /* Matrix tables (roles) — scroll instead; too many columns to stack */
    table.tbl.matrix {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        min-width: 100% !important;
    }

    table.tbl.matrix thead {
        display: table-header-group;
    }

    table.tbl.matrix tbody {
        display: table-row-group;
    }

    table.tbl.matrix tr {
        display: table-row;
        padding: 0;
        border: none;
        border-radius: 0;
        margin: 0;
        background: transparent;
    }

    table.tbl.matrix td {
        display: table-cell;
        padding: 8px 10px;
        border-bottom: 1px solid var(--line);
        white-space: nowrap;
    }

    table.tbl.matrix td::before {
        display: none;
    }

    table.tbl.matrix td:first-child {
        border-bottom: 1px solid var(--line);
        font-weight: inherit;
        font-size: inherit;
        padding-bottom: 8px;
        margin-bottom: 0;
    }

    /* Filter row: wrap nicely */
    .filter-row {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .filter-row>* {
        width: 100%;
    }

    .filter-row .search-wrap {
        width: 100%;
    }

    .filter-row .search-wrap input {
        width: 100%;
    }

    .filter-row .btn {
        justify-content: space-between;
    }

    .filter-row>div[style*="margin-left:auto"] {
        width: 100%;
        justify-content: stretch;
    }

    /* Tabs: horizontal scroll */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        gap: 0;
        padding: 0 2px;
        scrollbar-width: none;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab {
        padding: 10px 12px;
        font-size: 12.5px;
        flex: 0 0 auto;
    }

    .tab .count {
        font-size: 10px;
        padding: 1px 5px;
    }

    /* Stage rail: horizontal scroll instead of grid */
    .stage-rail {
        display: flex !important;
        overflow-x: auto;
        gap: 12px;
        padding: 8px 2px;
        scrollbar-width: none;
    }

    .stage-rail::-webkit-scrollbar {
        display: none;
    }

    .stage-rail::before {
        display: none;
    }

    .stage-rail .stg {
        flex: 0 0 80px;
        min-width: 80px;
    }

    .stage-rail .stg .num {
        width: 36px;
        height: 36px;
        font-size: 12px;
    }

    .stage-rail .stg .lbl {
        font-size: 10px;
    }

    .stage-rail .stg .meta {
        font-size: 9px;
    }

    /* Charts: shrink bars */
    .bars,
    .chart {
        overflow-x: auto;
    }

    .bar-grp {
        min-width: 48px;
    }

    /* Forms */
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .kv-grid {
        grid-template-columns: 1fr !important;
    }

    .field input,
    .field select,
    .field textarea {
        font-size: 16px;
    }

    /* prevent iOS zoom */
    .segmented {
        flex-wrap: wrap;
    }

    .segmented .seg-opt {
        flex: 1 1 40%;
    }

    /* Cards and stage-card */
    .stage-card .sh {
        flex-wrap: wrap;
    }

    .stage-card .sh>.badge {
        flex: 0 0 auto;
        margin-left: 0;
    }

    /* Page header: hide "Showing N of M" helper text */
    .tbl-footbar {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }

    .tbl-footbar .pager {
        justify-content: center;
    }

    /* Modals: full-screen on mobile */
    .modal-box {
        width: 95vw !important;
        max-width: 95vw !important;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Tweak panel placement */
    .tweaks-panel {
        right: 12px !important;
        left: 12px !important;
        bottom: 12px !important;
        width: auto !important;
    }

    /* Sidebar (loan-show right rail): stack below main */
    aside.sidebar,
    .sidebar {
        grid-column: 1 / -1;
    }

    /* Dropdown full width */
    .shf-dropdown {
        max-width: 90vw;
    }

    /* Hide decorative columns marked mobile-hide */
    .mobile-hide,
    th.mobile-hide,
    td.mobile-hide {
        display: none !important;
    }
}

/* Very small (<=480) */
@media (max-width: 480px) {

    .grid.c2,
    .grid.c3,
    .grid.c4,
    .grid.c5 {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .kpi-grid,
    .stat-grid {
        grid-template-columns: 1fr !important;
    }

    .page-header h1 {
        font-size: 20px;
    }

    .content {
        padding: 12px 10px 80px;
    }

    .card-hd,
    .card-bd,
    .card-ft {
        padding: 12px;
    }

    .topbar {
        padding: 8px 10px;
    }

    .topbar .logo-mark {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .head-actions .btn {
        flex: 1 1 100%;
        justify-content: center;
    }

    .segmented .seg-opt {
        flex: 1 1 100%;
    }
}

/* ============ Hamburger button ============ */
.m-hamburger {
    display: none;
}


/* ============ Topbar nav dropdown (Settings menu) ============ */
.nav-dd-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.nav-dd-wrap>.nav-item {
    cursor: pointer;
}

.nav-dd {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    background: #1a1a1a;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
    padding: 6px;
    margin-top: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s;
    z-index: 1000;
    pointer-events: none;
}

/* Invisible bridge so hover doesn't drop when moving from trigger to menu */
.nav-dd-wrap::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 10px;
    background: transparent;
}

.nav-dd-wrap:hover>.nav-dd,
.nav-dd-wrap:focus-within>.nav-dd,
.nav-dd-wrap.open>.nav-dd {
    opacity: 1;
    visibility: visible;
    transform: translateY(6px);
    pointer-events: auto;
}

.nav-dd-item {
    display: block;
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.88) !important;
    text-decoration: none !important;
    white-space: nowrap;
    background: transparent;
}

.nav-dd-item:hover {
    background: rgba(241, 90, 41, 0.15);
    color: #ff8a5b !important;
}

/* ============ Date input — visible affordance ============ */
.input[type="date"],
.input[type="time"],
.input[type="datetime-local"],
.shf-date {
    font-family: inherit;
    cursor: pointer;
    position: relative;
}

.input[type="date"]::-webkit-calendar-picker-indicator,
.input[type="time"]::-webkit-calendar-picker-indicator,
.input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    filter: saturate(0);
}

.input[type="date"]:hover::-webkit-calendar-picker-indicator,
.input[type="time"]:hover::-webkit-calendar-picker-indicator {
    opacity: 1;
}

/* ============ Map placeholder ============ */
.map-placeholder {
    width: 100%;
    height: 240px;
    background:
        linear-gradient(135deg, #e8f1f5 0%, #d6e7f0 100%);
    background-image:
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.4) 0%, transparent 30%),
        radial-gradient(circle at 70% 60%, rgba(255, 255, 255, 0.3) 0%, transparent 30%),
        repeating-linear-gradient(0deg, rgba(120, 150, 180, 0.1) 0 1px, transparent 1px 80px),
        repeating-linear-gradient(90deg, rgba(120, 150, 180, 0.1) 0 1px, transparent 1px 80px),
        linear-gradient(135deg, #e8f1f5 0%, #d6e7f0 100%);
    border-radius: 10px;
    border: 1px solid var(--line);
    position: relative;
    overflow: hidden;
}

.map-placeholder::before {
    content: '📍';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.map-placeholder::after {
    content: 'Map preview · click to set location';
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    color: var(--ink-2);
    font-weight: 500;
}

.map-placeholder.lg {
    height: 360px;
}

.map-placeholder.sm {
    height: 160px;
}

/* ============ Upload drop zone ============ */
.upload-zone {
    border: 2px dashed var(--line);
    border-radius: 10px;
    padding: 24px;
    text-align: center;
    background: var(--paper);
    transition: all 0.15s;
    cursor: pointer;
}

.upload-zone:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.upload-zone .link {
    color: var(--accent);
    text-decoration: underline;
}

/* ============ Checkbox label ============ */
.check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--ink-2);
    cursor: pointer;
}

.check input[type="checkbox"] {
    accent-color: var(--accent);
}

/* ============ Row action menu (...) ============ */
.row-actions {
    position: relative;
    display: inline-block;
}

.row-actions-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 4px;
    min-width: 160px;
    box-shadow: 0 8px 20px -4px rgba(0, 0, 0, 0.15);
    z-index: 100;
    display: none;
}

.row-actions.open .row-actions-menu {
    display: block;
}

.row-actions-menu a,
.row-actions-menu button {
    display: block;
    width: 100%;
    padding: 8px 12px;
    text-align: left;
    background: none;
    border: 0;
    font-size: 13px;
    color: var(--ink);
    cursor: pointer;
    border-radius: 5px;
    text-decoration: none;
}

.row-actions-menu a:hover,
.row-actions-menu button:hover {
    background: var(--paper);
}

.row-actions-menu .danger {
    color: var(--red);
}

.row-actions-menu .danger:hover {
    background: var(--red-soft);
}

.row-actions-menu hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 4px 0;
}

/* ============ Stage card collapsed body ============ */
.stage-card .sb {
    padding: 12px 18px 14px;
    transition: max-height 0.2s, padding 0.2s, opacity 0.2s;
    max-height: 600px;
    opacity: 1;
    overflow: hidden;
}

.stage-card .sb.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

.stage-card .sh {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.stage-card .sh>.badge {
    margin-right: 22px;
}

.stage-card .sh::after {
    content: '▾';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-4);
    font-size: 11px;
    transition: transform 0.2s;
}

.stage-card:has(.sb.collapsed) .sh::after {
    transform: translateY(-50%) rotate(-90deg);
}

.stage-jump-btn {
    min-width: 32px;
    padding: 5px 10px;
    font-family: 'Jost', sans-serif;
    font-weight: 600;
}

.stage-jump-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ============ Field requirement marker ============ */
.req {
    color: var(--red);
    margin-left: 2px;
    font-weight: 600;
}

/* link */
.link {
    color: var(--accent);
    text-decoration: underline;
    cursor: pointer;
}

.w-full {
    width: 100%;
}

.mt-1 {
    margin-top: 4px;
}

.mt-2 {
    margin-top: 8px;
}

.mt-4 {
    margin-top: 16px;
}

/* kv-stack */
.kv-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kv-stack .kv {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    border-bottom: 1px dashed var(--line);
}

.kv-stack .kv:last-child {
    border: 0;
}

.kv-stack .kv span {
    font-size: 12px;
    color: var(--ink-3);
}

.kv-stack .kv strong {
    font-size: 13px;
    color: var(--ink);
    font-weight: 500;
}

/* ========= DVR/Reports utility additions ========= */
.legend-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    font-size: 13px;
    color: var(--ink-2);
}

.legend-row .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.bar {
    --p: 0%;
    height: 6px;
    background: var(--paper-2);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.bar::after {
    content: '';
    position: absolute;
    inset: 0;
    width: var(--p);
    background: var(--accent);
}

.bar.green::after {
    background: var(--green);
}

.bar.amber::after {
    background: var(--amber);
}

.bar.blue::after {
    background: var(--blue);
}

.bar.red::after {
    background: var(--red);
}

/* ========= Loan-show: timeline + notes ========= */
.tl {
    padding: 0 20px 16px;
}

.tl-day {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-4);
    margin: 18px 0 8px;
    font-family: 'JetBrains Mono', monospace;
}

.tl-item {
    display: grid;
    grid-template-columns: 16px 1fr;
    gap: 14px;
    padding: 8px 0;
    align-items: flex-start;
    position: relative;
}

.tl-item::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 20px;
    bottom: -10px;
    width: 2px;
    background: var(--paper-2);
}

.tl-item:last-child::before {
    display: none;
}

.tl-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--paper-2);
    border: 3px solid var(--paper);
    margin-top: 4px;
    position: relative;
    z-index: 1;
    box-shadow: 0 0 0 1px var(--line);
}

.tl-dot.blue {
    background: var(--blue);
}

.tl-dot.green {
    background: var(--green);
}

.tl-dot.amber {
    background: var(--amber);
}

.tl-dot.red {
    background: var(--red);
}

.note {
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 10px;
    padding: 10px 0;
}

.note+.note {
    border-top: 1px dashed var(--line);
}

.note-b {
    font-size: 13px;
    line-height: 1.5;
    color: var(--ink-2);
}

.note-h {
    margin-bottom: 4px;
    font-size: 12px;
}