.kp-overlay { display: none; position: fixed; inset: 0; background: rgba(18,18,18,.45); z-index: 10000; padding: 16px; box-sizing: border-box; }
.kp-overlay.is-open { display: flex; align-items: center; justify-content: center; }
.kp-modal { width: min(1100px, 100%); max-height: 90vh; background: #fff; border: 1px solid #dcdcdc; display: flex; flex-direction: column; box-shadow: 0 16px 40px rgba(0,0,0,.18); min-height: 0; }
.kp-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid #dcdcdc; flex-shrink: 0; }
.kp-modal-head h4 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .8px; }
.kp-modal-tools { padding: 12px 16px; border-bottom: 1px solid #eee; flex-shrink: 0; background: #f8f9fa; }
.kp-search { width: 100%; padding: 10px 12px; border: 1px solid #7eb6d9; box-sizing: border-box; font-size: 13px; margin: 0; }
.kp-modal-body { overflow: auto; flex: 1; min-height: 0; background: #fff; -webkit-overflow-scrolling: touch; }
.kp-overlay .is-hidden { display: none !important; }
body.kp-open { overflow: hidden; }
.btn-sky { background: #e8f4fc !important; border-color: #7eb6d9 !important; color: #1565a8 !important; }
.btn-nk-lieg {
    background: rgba(249, 168, 37, 0.22) !important;
    border-color: #f9a825 !important;
    color: #8a5a00 !important;
    white-space: normal !important;
    line-height: 1.25 !important;
    text-align: center;
    height: auto !important;
    overflow: hidden;
}
.mbros-logged-as {
    font-size: 10px;
    font-weight: 600;
    color: #2e7d32;
    letter-spacing: .2px;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mbros-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.mbros-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
header {
    max-width: 1100px !important;
    width: 100%;
    margin-left: auto !important;
    margin-right: auto !important;
    box-sizing: border-box !important;
}
.main-container {
    max-width: 1100px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    box-sizing: border-box !important;
}
.nav-bar {
    background: #fff !important;
    border: 1px solid #dcdcdc !important;
    border-top: 2px solid #d8d8d8 !important;
    padding: 12px 15px !important;
    margin: 0 0 10px !important;
    display: grid !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 8px !important;
    box-sizing: border-box !important;
    box-shadow: none !important;
}
.nav-link,
.nav-link-locked {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 42px !important;
    height: 42px !important;
    padding: 8px 4px !important;
    background: #f8f9fa !important;
    color: #121212 !important;
    text-decoration: none !important;
    font-weight: 700 !important;
    font-size: 10px !important;
    letter-spacing: 0.5px !important;
    text-transform: uppercase !important;
    text-align: center !important;
    border: 1px solid #dcdcdc !important;
    border-radius: 2px !important;
    box-sizing: border-box !important;
    white-space: nowrap;
}
.nav-link:hover,
.nav-link.active {
    background: #e8e8e8 !important;
    color: #444 !important;
    border-color: #d0d0d0 !important;
}
.nav-link-locked {
    color: #999 !important;
    opacity: 0.55;
    cursor: not-allowed;
}
.sub-nav, .sia-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin: 0 0 16px;
}
.sub-tab-btn, .sia-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 10px 4px;
    background: #f8f9fa;
    border: 1px solid #dcdcdc;
    color: #555;
    text-decoration: none;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    min-height: 58px;
    box-sizing: border-box;
    text-align: center;
    white-space: normal;
}
.sub-tab-btn.active, .sia-tab.active {
    background: #fff;
    color: #121212;
    border-color: #121212;
}
@media (min-width: 768px) {
    .sub-nav, .sia-tabs { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
    .main-container { padding-left: 8px !important; padding-right: 8px !important; max-width: 100% !important; }
    .sub-nav, .sia-tabs {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        overflow: visible !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }
    .sub-tab-btn, .sia-tab {
        display: flex !important;
        flex-direction: column !important;
        min-width: 0 !important;
        min-height: 56px !important;
        width: 100%;
        font-size: 8px;
        padding: 8px 2px;
        white-space: normal;
    }
    header { padding: 12px !important; gap: 10px !important; }
    header h1 { font-size: 14px !important; letter-spacing: .5px !important; width: 100%; }
    header .header-inner {
        flex-direction: column;
        align-items: stretch !important;
    }
    header .header-actions {
        display: flex !important;
        flex-wrap: wrap !important;
        width: 100%;
        gap: 8px;
        align-items: stretch;
    }
    header .header-actions .btn {
        order: 1;
        flex: 1 1 calc(50% - 8px);
        min-width: 0;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }
    header .header-actions .mbros-logged-as {
        order: 2;
        flex: 1 1 100% !important;
        max-width: none !important;
        width: 100%;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: unset !important;
        word-break: break-all;
        line-height: 1.35;
        padding: 4px 0 0;
        text-align: center;
        font-size: 9px !important;
        font-weight: 600;
        color: #2e7d32;
        letter-spacing: 0;
    }
    .action-btn, .btn {
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }
    .nav-bar {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 8px !important;
        gap: 6px !important;
        overflow: visible !important;
    }
    .nav-link,
    .nav-link-locked {
        min-width: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: 44px !important;
        height: auto !important;
        font-size: 10px !important;
        letter-spacing: 0 !important;
        line-height: 1.15 !important;
        padding: 6px 3px !important;
        white-space: normal !important;
        overflow: visible !important;
        overflow-wrap: break-word;
        text-align: center !important;
    }
    .card { padding: 14px !important; }
    input[type="text"], input[type="email"], input[type="tel"], input[type="date"],
    input[type="search"], input[type="number"], input[type="password"], input[type="file"],
    select, textarea, .kp-search {
        font-size: 16px !important;
    }

    .kp-overlay,
    .kp-overlay.is-open {
        padding: 0 !important;
        align-items: stretch !important;
        justify-content: stretch !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        z-index: 10000 !important;
        overscroll-behavior: contain;
        background: #f3f5f7 !important;
    }
    .kp-overlay.is-open .kp-modal {
        width: 100% !important;
        max-width: none !important;
        flex: 1 1 auto !important;
        height: 100% !important;
        max-height: none !important;
        min-height: 0 !important;
        border: none !important;
        box-shadow: none !important;
        display: flex !important;
        flex-direction: column !important;
        background: #f3f5f7;
    }
    .kp-modal-head {
        padding: 12px;
        padding-top: max(12px, env(safe-area-inset-top));
        background: #fff;
    }
    .kp-modal-tools { padding: 10px 12px; background: #fff; }
    .kp-modal-body {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        -webkit-overflow-scrolling: touch;
        background: #f3f5f7 !important;
        padding: 10px 10px calc(16px + env(safe-area-inset-bottom, 0px)) !important;
    }
    .kp-overlay .table-responsive,
    .kp-overlay .desktop-table {
        overflow: visible !important;
        margin: 0 !important;
        width: 100% !important;
    }
    .kp-overlay table {
        min-width: 0 !important;
        width: 100% !important;
        border-collapse: separate;
        border-spacing: 0;
    }
    .kp-overlay thead { display: none !important; }
    .kp-overlay tbody { display: block; padding: 0; }

    .kp-overlay tbody tr {
        display: flex !important;
        flex-wrap: wrap;
        align-items: flex-start;
        background: #fff;
        border: 1px solid #dcdcdc;
        margin: 0 0 12px;
        padding: 14px;
        box-sizing: border-box;
        box-shadow: 0 4px 12px rgba(18, 18, 18, 0.04);
    }
    .kp-overlay tbody td {
        display: block !important;
        width: 100% !important;
        padding: 0 !important;
        border: none !important;
        white-space: normal !important;
        text-align: left !important;
        word-break: break-word;
        font-size: 13px;
        line-height: 1.45;
        color: #121212;
    }
    .kp-overlay tbody td::before { display: none; }

    .kp-overlay td.mbros-card-empty { display: none !important; }

    .kp-overlay td.mbros-card-kicker {
        display: inline-flex !important;
        align-items: center;
        gap: 6px;
        width: auto !important;
        flex: 0 0 auto;
        order: 0;
        margin: 0 8px 8px 0;
        padding: 0 !important;
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .4px;
        color: #1565a8;
    }
    .kp-overlay td.mbros-card-kicker .badge {
        margin: 0;
    }

    .kp-overlay td.mbros-card-title {
        order: 1;
        flex: 1 1 100%;
        font-size: 16px;
        font-weight: 700;
        color: #121212;
        padding: 0 0 10px !important;
        margin-bottom: 4px;
        border-bottom: 1px solid #eee !important;
        line-height: 1.35;
    }
    .kp-overlay td.mbros-card-title .meta-sub {
        display: block;
        margin-top: 3px;
        font-size: 11px;
        font-weight: 600;
        color: #666;
        text-transform: uppercase;
        letter-spacing: .4px;
    }

    .kp-overlay td.mbros-card-field {
        order: 2;
        flex: 1 1 100%;
        display: flex !important;
        flex-direction: column;
        gap: 4px;
        padding: 10px 0 !important;
        border-bottom: 1px solid #f0f0f0 !important;
    }
    .kp-overlay td.mbros-card-field::before {
        display: block;
        content: attr(data-label);
        font-size: 10px;
        font-weight: 700;
        letter-spacing: .5px;
        text-transform: uppercase;
        color: #888;
    }
    .kp-overlay td.mbros-card-field:last-of-type { border-bottom: none !important; }
    .kp-overlay td.mbros-card-field code,
    .kp-overlay td.mbros-card-field .password-box {
        display: inline-block;
        word-break: break-all;
        font-size: 12px;
    }
    .kp-overlay td.mbros-card-field a {
        color: #1565a8;
        word-break: break-all;
    }

    .kp-overlay td.mbros-card-actions {
        order: 3;
        flex: 1 1 100%;
        display: flex !important;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 12px;
        padding-top: 12px !important;
        border-top: 1px solid #e8e8e8 !important;
        border-bottom: none !important;
    }
    .kp-overlay td.mbros-card-actions .btn,
    .kp-overlay td.mbros-card-actions button,
    .kp-overlay td.mbros-card-actions a.btn,
    .kp-overlay td.mbros-card-actions a.btn-edit,
    .kp-overlay td.mbros-card-actions a.btn-del,
    .kp-overlay td.mbros-card-actions a.btn-sky {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        min-height: 42px;
        padding: 8px 12px;
        margin: 0;
        flex: 1 1 calc(50% - 8px);
        box-sizing: border-box;
        white-space: nowrap;
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .4px;
        text-decoration: none;
        border: 1px solid #dcdcdc;
        background: #f8f9fa;
        color: #121212;
    }
    .kp-overlay td.mbros-card-actions a.btn-edit,
    .kp-overlay td.mbros-card-actions a[href*="edit"] {
        background: #e8f4fc;
        border-color: #7eb6d9;
        color: #1565a8;
    }
    .kp-overlay td.mbros-card-actions a.btn-del,
    .kp-overlay td.mbros-card-actions a[href*="delete"],
    .kp-overlay td.mbros-card-actions button[style*="a94442"] {
        background: #fdf2f2 !important;
        border-color: #ebccd1 !important;
        color: #a94442 !important;
    }
    .kp-overlay td.mbros-card-actions form {
        display: flex;
        flex: 1 1 calc(50% - 8px);
        margin: 0;
    }
    .kp-overlay td.mbros-card-actions form button {
        width: 100%;
        flex: 1 1 auto;
    }

    .kp-overlay .property-grid {
        grid-template-columns: 1fr !important;
        margin: 0 !important;
        gap: 12px;
    }
    .kp-overlay .property-tile {
        background: #fff;
        box-shadow: 0 4px 12px rgba(18, 18, 18, 0.04);
    }

    a.btn-del {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 40px;
        padding: 8px 12px;
        background: #fdf2f2;
        border: 1px solid #ebccd1;
        color: #a94442;
        text-decoration: none;
        font-weight: 700;
        text-transform: uppercase;
        font-size: 11px;
        box-sizing: border-box;
    }

    .modal { padding: 0 !important; }
    .modal-content { width: 100% !important; max-width: 100% !important; min-height: 100dvh; margin: 0 !important; border-radius: 0; box-sizing: border-box; }
    .finance-kpi-grid { overflow-x: auto; -webkit-overflow-scrolling: touch; }

    #contactsOverlay {
        padding: 0 !important;
        background: #f3f5f7 !important;
    }
    #contactsOverlay .kp-modal {
        height: 100dvh !important;
        max-height: 100dvh !important;
    }
    #contactsOverlay tbody tr.contact-row,
    #contactsOverlay tbody tr {
        display: block !important;
        flex-wrap: unset;
        padding: 0 !important;
        background: #fff;
        border: 1px solid #dcdcdc;
        margin: 0 0 10px;
    }
    #contactsOverlay tbody tr.contact-row.is-hidden { display: none !important; }
    #contactsOverlay table,
    #contactsOverlay .desktop-table,
    #contactsOverlay tbody tr.contact-row {
        min-width: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    #contactsOverlay tbody td,
    #contactsOverlay td.contact-card {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        border: none !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    #contactsOverlay .contact-more { display: none !important; }
    #contactsOverlay .contact-toggle:checked ~ .contact-more { display: block !important; }
    #contactsOverlay .contact-actions {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 4px !important;
        width: 50% !important;
        max-width: 50% !important;
        box-sizing: border-box !important;
    }
    #contactsOverlay .contact-actions > * {
        min-width: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
        overflow: hidden !important;
    }
    #contactsOverlay .contact-actions > form {
        display: block !important;
        width: auto !important;
    }
    #contactsOverlay .contact-actions > form .btn,
    #contactsOverlay .contact-actions > a.btn,
    #contactsOverlay .contact-actions > button.btn {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        min-height: 36px !important;
        height: 36px !important;
        margin: 0 !important;
        padding: 0 2px !important;
        font-size: 8px !important;
        letter-spacing: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        line-height: 1 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }
}
