﻿/* Controo Real Estate ERP - Master Stylesheet */
/* Colors: Primary #20395e (Navy) | Secondary #b89350 (Warm Architecture Gold) */
@import url("https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");

:root {
    --font-ar: "Cairo", sans-serif;
    --font-en: "Plus Jakarta Sans", sans-serif;

    /* Light Mode Tokens */
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-sidebar: #142542;
    --bg-topbar: rgba(255, 255, 255, 0.9);
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    /* Primary & Secondary Brand Tokens */
    --brand-primary: #20395e;
    --brand-primary-hover: #162842;
    --brand-primary-light: rgba(32, 57, 94, 0.08);
    --brand-secondary: #b89350;
    --brand-secondary-hover: #9c7a3d;
    --brand-secondary-light: rgba(184, 147, 80, 0.12);
    --brand-accent: #b89350;

    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #20395e;
    --info-light: rgba(32, 57, 94, 0.12);

    --shadow-sm: 0 1px 3px rgba(32, 57, 94, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(32, 57, 94, 0.08), 0 2px 4px -2px rgba(32, 57, 94, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(32, 57, 94, 0.1), 0 4px 6px -4px rgba(32, 57, 94, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(32, 57, 94, 0.15), 0 8px 10px -6px rgba(32, 57, 94, 0.06);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-body: #0b0f19;
    --bg-card: #151d30;
    --bg-card-hover: #1e2942;
    --bg-sidebar: #142542;
    --bg-topbar: rgba(21, 29, 48, 0.9);
    --border-color: #232f4a;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --brand-primary: #4b6f9e;
    --brand-primary-hover: #20395e;
    --brand-primary-light: rgba(75, 111, 158, 0.2);
    --brand-secondary: #c9a765;
    --brand-secondary-hover: #b89350;
    --brand-secondary-light: rgba(201, 167, 101, 0.2);

    --success-light: rgba(16, 185, 129, 0.15);
    --warning-light: rgba(245, 158, 11, 0.15);
    --danger-light: rgba(239, 68, 68, 0.15);
    --info-light: rgba(75, 111, 158, 0.2);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.6);
}

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

html {
    max-width: 100%;
    overflow-x: clip;
}

body {
    font-family: var(--font-ar);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: clip;
    max-width: 100%;
}

img, svg, canvas, video, iframe {
    max-width: 100%;
}

body.sidebar-open {
    overflow: hidden;
}

html[dir="ltr"] body {
    font-family: var(--font-en);
}

/* Glassmorphism Classes */
.glass-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.glass-panel:hover {
    box-shadow: var(--shadow-lg);
}

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

/* Modern Sidebar */
.app-sidebar {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    background: var(--bg-sidebar);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                opacity 0.2s ease,
                margin 0.3s ease;
    z-index: 1000;
    overflow: hidden;
    position: relative;
}

/* Collapsible / Foldable Sidebar State (Smooth Tuck-in / Slide) */
.app-container.sidebar-collapsed .app-sidebar {
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    flex: 0 0 0% !important;
    flex-basis: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
    overflow: hidden !important;
}

html[dir="rtl"] .app-container.sidebar-collapsed .app-sidebar {
    transform: translateX(100%) !important;
}

html[dir="ltr"] .app-container.sidebar-collapsed .app-sidebar {
    transform: translateX(-100%) !important;
}

.app-container.sidebar-collapsed .app-main {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 1 100% !important;
}

.sidebar-fold-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.sidebar-fold-btn:hover {
    color: #b89350;
    border-color: #b89350;
    background: rgba(184, 147, 80, 0.08);
}

.sidebar-fold-toggle:hover {
    background: rgba(184, 147, 80, 0.2) !important;
    border-color: #b89350 !important;
}

/* Adaptive Brand Logo Switching (Light Mode -> Page 3 Navy/Gold | Night Shift Dark Mode -> Page 1 White/Gold) */
.brand-logo-img-light { display: block; }
.brand-logo-img-dark  { display: none; }
html[data-theme="dark"] .brand-logo-img-light { display: none; }
html[data-theme="dark"] .brand-logo-img-dark  { display: block; }

.sidebar-header {
    height: 72px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid rgba(203, 164, 88, 0.22);
    box-sizing: border-box;
}

.sidebar-logo-link {
    text-decoration: none;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.sidebar-logo-link img {
    max-height: 44px;
    max-width: 190px;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Single Non-Duplicated Brand Logo in Topbar: hidden on desktop when sidebar is open, visible when sidebar is collapsed or on mobile/tablet */
.topbar-brand-slot {
    display: none;
    align-items: center;
    text-decoration: none;
    max-width: 190px;
    overflow: hidden;
}

.topbar-brand-slot img {
    max-height: 36px;
    max-width: 175px;
    width: auto;
    object-fit: contain;
}

.app-container.sidebar-collapsed .topbar-brand-slot {
    display: inline-flex;
}

@media (max-width: 992px) {
    .topbar-brand-slot {
        display: inline-flex;
    }
    .topbar-brand-slot img {
        max-height: 30px;
        max-width: 135px;
    }
}

.brand-logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #20395e, #162842);
    border: 1.5px solid #b89350;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #b89350;
    box-shadow: 0 4px 15px rgba(184, 147, 80, 0.25);
}

.brand-text h2 {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: #fff;
}

.brand-text span {
    font-size: 10px;
    color: #b89350;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.nav-group-accordion {
    margin-bottom: 6px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
    transition: all 0.22s ease;
}

.nav-group-accordion:hover {
    border-color: rgba(184, 147, 80, 0.35);
    background: rgba(255, 255, 255, 0.045);
}

.nav-group-accordion.has-active-child {
    border-color: rgba(184, 147, 80, 0.55);
    background: rgba(184, 147, 80, 0.07);
}

.nav-group-accordion.open {
    border-color: rgba(184, 147, 80, 0.65);
    background: rgba(15, 23, 42, 0.45);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.nav-section-title.nav-group-toggle {
    width: 100%;
    font-family: inherit;
    font-size: 13px;
    font-weight: 800;
    color: #b89350 !important;
    padding: 11px 12px;
    letter-spacing: 0.2px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: start;
    transition: all 0.2s ease;
}

.nav-section-title.nav-group-toggle::before {
    display: none;
}

.nav-section-title.nav-group-toggle:hover {
    color: #f3d493 !important;
}

.nav-group-title-left {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    flex: 1;
}

.nav-group-main-ico {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: rgba(184, 147, 80, 0.15);
    color: #e2be78;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13.5px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.nav-group-accordion.open .nav-group-main-ico,
.nav-group-accordion.has-active-child .nav-group-main-ico {
    background: linear-gradient(135deg, #b89350, #9c7a3d);
    color: #ffffff;
}

.nav-group-title-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-group-title-right {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.nav-group-active-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.22);
}

.nav-group-count {
    font-size: 10.5px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.72);
    background: rgba(255, 255, 255, 0.08);
    padding: 1px 6px;
    border-radius: 99px;
    line-height: 1.4;
}

.nav-group-chevron {
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.65);
    transition: transform 0.22s ease, color 0.22s ease;
}

.nav-group-accordion.open .nav-group-chevron {
    transform: rotate(180deg);
    color: #f3d493;
}

/* Collapsed by default! Only expands when .nav-group-accordion has .open */
.nav-group-items {
    display: none;
    padding: 4px 8px 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-group-accordion.open .nav-group-items {
    display: block;
}

.nav-link-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    color: rgba(255, 255, 255, 0.68);
    text-decoration: none;
    border-radius: var(--radius-md);
    margin-bottom: 3px;
    font-weight: 400;
    font-size: 11.5px;
    transition: var(--transition);
}

.nav-link-item i {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.56);
    transition: var(--transition);
}

.nav-link-item:hover {
    color: #ffffff;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(4px);
}

html[dir="rtl"] body .nav-link-item:hover {
    transform: translateX(-4px);
}

.nav-link-item.active {
    color: #ffffff;
    font-weight: 700;
    background: linear-gradient(135deg, rgba(32, 57, 94, 0.95), rgba(184, 147, 80, 0.85));
    box-shadow: 0 4px 14px rgba(32, 57, 94, 0.4);
    border-inline-start: 4px solid #b89350;
}

.nav-link-item.active i,
.nav-link-item:hover i {
    color: #b89350;
}

.nav-badge {
    margin-inline-start: auto;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 600;
}

/* Main Content Area */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Modern Top Header */
.app-topbar {
    height: 72px;
    background: var(--bg-topbar);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 99;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-toggle-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-primary);
    cursor: pointer;
}

/* Action Icon Buttons */
.btn-icon-control {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 18px;
    transition: var(--transition);
    text-decoration: none;
}

.btn-icon-control:hover {
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    border-color: var(--brand-secondary);
    color: var(--brand-secondary);
}

/* Modern User Profile Dropdown Pill */
.user-profile-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 6px;
    border-radius: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-primary);
}

.user-avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #20395e, #b89350);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    border: 1px solid rgba(184, 147, 80, 0.4);
}

/* Content Container */
.app-content {
    padding: 28px;
    flex: 1;
}

/* Modern Stats Card Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    padding: 24px;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: "";
    position: absolute;
    top: 0;
    inset-inline-start: 0;
    width: 4px;
    height: 100%;
    background: var(--card-accent, var(--brand-secondary));
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(184, 147, 80, 0.4);
}

a.stat-icon {
    text-decoration: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
}

a.stat-icon:hover {
    transform: scale(1.18);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    filter: brightness(1.08);
}

.clickable-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.clickable-row:hover {
    background-color: var(--bg-hover, rgba(184, 147, 80, 0.06)) !important;
}

.stat-info span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.stat-info h3 {
    font-size: 26px;
    font-weight: 800;
    margin-top: 4px;
    color: var(--text-primary);
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: var(--card-bg-light, var(--brand-secondary-light));
    color: var(--card-accent, var(--brand-secondary));
}

/* Status Badges */
.badge-status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    white-space: nowrap;
    word-break: keep-all;
    line-height: 1.3;
    flex-shrink: 0;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--brand-primary); }
.badge-gold { background: rgba(184, 147, 80, 0.15); color: #b89350; border: 1px solid rgba(184, 147, 80, 0.3); }
.badge-neutral { background: var(--border-color); color: var(--text-secondary); }

/* Universal Flex/Grid Shrink Guarantee so cards & tables NEVER overflow or clip horizontally */
.app-container,
.app-main,
.app-content,
.app-content > *,
.dashboard-widget-container,
.dashboard-draggable-widget,
.glass-panel,
.modal-box {
    min-width: 0;
    max-width: 100%;
}

.app-content div {
    min-width: 0;
}

/* Full-Width Stacked Tables Guarantee (Desktop, Tablet & Mobile):
   Every table / transactions card across the entire system takes 100% width with the next table stacked underneath it */
.app-content [style*="display: grid"]:has(table):not(.modal-box *),
.app-content [style*="display:grid"]:has(table):not(.modal-box *),
.app-content .dashboard-widget-container [style*="grid-template-columns"]:has(table) {
    grid-template-columns: 1fr !important;
}

/* Tables — Smooth Horizontal Scrolling on ALL Screens (RTL & LTR) */
.table-responsive,
.app-content [style*="overflow-x: auto"],
.app-content [style*="overflow-x:auto"] {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    border-radius: var(--radius-md);
    padding-bottom: 6px;
    scrollbar-width: thin;
    scrollbar-color: #b89350 rgba(32, 57, 94, 0.14);
    cursor: grab;
}

.table-responsive.is-dragging {
    cursor: grabbing;
    user-select: none;
}

.table-responsive::-webkit-scrollbar,
.app-content [style*="overflow-x: auto"]::-webkit-scrollbar,
.app-content [style*="overflow-x:auto"]::-webkit-scrollbar {
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track,
.app-content [style*="overflow-x: auto"]::-webkit-scrollbar-track,
.app-content [style*="overflow-x:auto"]::-webkit-scrollbar-track {
    background: rgba(32, 57, 94, 0.08);
    border-radius: 99px;
}

.table-responsive::-webkit-scrollbar-thumb,
.app-content [style*="overflow-x: auto"]::-webkit-scrollbar-thumb,
.app-content [style*="overflow-x:auto"]::-webkit-scrollbar-thumb {
    background: #b89350;
    border-radius: 99px;
}

.table-responsive > table,
.app-content [style*="overflow-x: auto"] > table,
.app-content [style*="overflow-x:auto"] > table {
    width: 100%;
    min-width: 100%;
    table-layout: auto;
    border-collapse: collapse;
}

/* On narrow mobile phones (<= 768px), keep columns spacious & smoothly swipeable left/right */
@media (max-width: 768px) {
    .table-responsive > table,
    .app-content [style*="overflow-x: auto"] > table,
    .app-content [style*="overflow-x:auto"] > table {
        width: max-content;
        min-width: 100%;
    }
    .modern-table td,
    .table-custom td {
        max-width: 220px;
    }
}

/* Universal Table Control Toolbar (Minimize / Open / Float / Horizontal Scroll) */
.table-ctrl-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 7px 12px;
    margin-bottom: 10px;
    border-radius: 11px;
    background: var(--bg-card-hover);
    border: 1px solid var(--border-color);
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
}

.table-ctrl-bar .tcb-left,
.table-ctrl-bar .tcb-right {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.table-ctrl-bar .tcb-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 99px;
    background: rgba(184, 147, 80, 0.14);
    color: #b89350;
    font-size: 11px;
    font-weight: 800;
}

.table-ctrl-bar .tcb-scroll-group {
    display: none;
    align-items: center;
    gap: 5px;
    padding-inline: 6px;
    border-inline-start: 1px solid var(--border-color);
}

.table-ctrl-bar .tcb-scroll-group.visible {
    display: inline-flex;
}

.table-ctrl-bar .tsb-btn {
    height: 29px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    font-size: 11.5px;
    font-weight: 700;
    font-family: inherit;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.table-ctrl-bar .tsb-btn.icon-only {
    width: 29px;
    padding: 0;
}

.table-ctrl-bar .tsb-btn:hover {
    background: #142542;
    color: #ffffff;
    border-color: #b89350;
}

.table-ctrl-bar .tsb-btn.tcb-float-btn:hover,
.table-ctrl-bar .tsb-btn.active {
    background: #b89350;
    color: #ffffff;
    border-color: #b89350;
}

.table-responsive.is-minimized {
    display: none !important;
}

.table-float-placeholder {
    padding: 18px;
    text-align: center;
    border: 2px dashed rgba(184, 147, 80, 0.45);
    border-radius: 12px;
    background: rgba(184, 147, 80, 0.06);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* Floating Draggable Table Window */
.floating-table-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 18, 32, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9990;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.floating-table-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.floating-table-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(92vw, 1180px);
    height: min(84vh, 760px);
    max-width: 98vw;
    max-height: 95vh;
    background: var(--bg-card);
    border: 2px solid #b89350;
    border-radius: 18px;
    box-shadow: 0 28px 80px rgba(10, 18, 32, 0.5);
    z-index: 9995;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    resize: both;
}

.floating-table-window.is-maximized {
    top: 12px !important;
    left: 12px !important;
    transform: none !important;
    width: calc(100vw - 24px) !important;
    height: calc(100vh - 24px) !important;
    height: calc(100dvh - 24px) !important;
    border-radius: 14px;
}

.floating-table-header {
    background: #142542;
    color: #ffffff;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 2px solid #b89350;
    cursor: move;
    user-select: none;
    flex-shrink: 0;
}

.floating-table-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14.5px;
    font-weight: 800;
    min-width: 0;
}

.floating-table-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.floating-table-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.floating-table-actions button {
    height: 30px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}

.floating-table-actions button:hover {
    background: #b89350;
    border-color: #b89350;
}

.floating-table-actions button.ftw-pdf {
    background: rgba(184, 147, 80, 0.22);
    border-color: rgba(184, 147, 80, 0.72);
    color: #f8e4b6;
}

.floating-table-actions button.ftw-pdf:hover {
    background: #b89350;
    border-color: #b89350;
    color: #ffffff;
}

.floating-table-actions button.ftw-close:hover {
    background: #ef4444;
    border-color: #ef4444;
}

.floating-table-body {
    flex: 1;
    overflow: auto;
    padding: 16px;
    background: var(--bg-card);
}

@media (max-width: 640px) {
    .table-ctrl-bar .tcb-btn-label {
        display: none;
    }
    .floating-table-window {
        top: 8px !important;
        left: 8px !important;
        transform: none !important;
        width: calc(100vw - 16px) !important;
        height: calc(100dvh - 16px) !important;
        resize: none;
    }
}

.modern-table,
.table-custom {
    width: 100%;
    border-collapse: collapse;
    text-align: start;
}

.modern-table th,
.table-custom th {
    background: var(--bg-card-hover);
    padding: 10px 10px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    line-height: 1.35;
}

.modern-table td,
.table-custom td {
    padding: 9px 10px;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

.modern-table td:first-child,
.table-custom td:first-child,
.modern-table td code,
.table-custom td code {
    white-space: nowrap;
}

.modern-table td .badge-status,
.table-custom td .badge-status {
    padding: 3px 9px;
    font-size: 11px;
    white-space: nowrap !important;
    word-break: keep-all !important;
}

.modern-table td strong,
.table-custom td strong {
    font-size: 12.5px;
}

.modern-table tr:hover td,
.table-custom tr:hover td {
    background: var(--bg-card-hover);
}

/* Compact Table Typography & Spacing on Laptops & Tablets */
@media (max-width: 1366px) {
    .modern-table th,
    .table-custom th {
        padding: 9px 8px;
        font-size: 11.5px;
    }
    .modern-table td,
    .table-custom td {
        padding: 8px 8px;
        font-size: 12px;
    }
    .modern-table td .badge-status,
    .table-custom td .badge-status {
        padding: 3px 8px;
        font-size: 10.5px;
    }
}

@media (max-width: 1024px) {
    .modern-table th,
    .table-custom th {
        padding: 8px 7px;
        font-size: 11px;
    }
    .modern-table td,
    .table-custom td {
        padding: 8px 7px;
        font-size: 11.5px;
    }
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, #20395e 0%, #162842 100%);
    color: #fff;
    border: 1px solid #20395e;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(32, 57, 94, 0.25);
    transition: var(--transition);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #162842 0%, #0d192a 100%);
    border-color: #162842;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(32, 57, 94, 0.35);
    color: #fff;
}

.btn-gold {
    background: linear-gradient(135deg, #b89350 0%, #9c7a3d 100%);
    color: #ffffff;
    border: 1px solid #b89350;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(184, 147, 80, 0.25);
    transition: var(--transition);
}

.btn-gold:hover {
    background: linear-gradient(135deg, #9c7a3d 0%, #856630 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(184, 147, 80, 0.35);
    color: #fff;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: #b89350;
    color: #b89350;
}

.btn-success {
    background: var(--success);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-control, .form-select {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition);
    outline: none;
}

.form-control:focus, .form-select:focus {
    border-color: #b89350;
    box-shadow: 0 0 0 3px rgba(184, 147, 80, 0.18);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
    box-shadow: var(--shadow-xl);
    transform: scale(0.95);
    transition: var(--transition);
}

.modal-overlay.active .modal-box {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Toast Alerts */
.alert-toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
}

.alert-toast.success { background: var(--success-light); color: var(--success); border: 1px solid var(--success); }
.alert-toast.error { background: var(--danger-light); color: var(--danger); border: 1px solid var(--danger); }

/* Payment Methods Grid */
.payment-methods-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin: 24px 0;
}

.payment-card {
    padding: 24px;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.payment-card:hover, .payment-card.selected {
    border-color: #b89350;
    box-shadow: 0 8px 24px rgba(184, 147, 80, 0.25);
    transform: translateY(-4px);
}

/* Drag and Drop Dashboard Customization Styles */
.dashboard-widget-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.dashboard-draggable-widget {
    cursor: default;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    position: relative;
}

.dashboard-draggable-widget.dragging {
    opacity: 0.4;
    transform: scale(0.98);
    border: 2px dashed #b89350 !important;
}

.widget-drag-handle {
    cursor: grab;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(32, 57, 94, 0.08);
    color: #b89350;
    border: 1px solid rgba(184, 147, 80, 0.3);
    font-size: 16px;
    transition: var(--transition);
}

.widget-drag-handle:active {
    cursor: grabbing;
}

.widget-drag-handle:hover {
    background: #b89350;
    color: #fff;
}

.drag-placeholder-active {
    border: 2px dashed #b89350;
    background: rgba(184, 147, 80, 0.06);
    border-radius: var(--radius-lg);
    min-height: 120px;
    margin-bottom: 24px;
}

/* Sponsored Ad Banner Component */
.sponsored-ad-banner {
    position: relative;
    border-radius: var(--radius-xl);
    overflow: hidden;
    background: linear-gradient(135deg, #101c30 0%, #20395e 100%);
    border: 1.5px solid rgba(184, 147, 80, 0.4);
    box-shadow: 0 10px 30px rgba(32, 57, 94, 0.25);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 32px 36px;
    gap: 28px;
    flex-wrap: wrap;
}

.sponsored-ad-banner::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(184, 147, 80, 0.22), transparent 70%);
    pointer-events: none;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.animated-fade {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Mobile Sidebar Backdrop */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 18, 32, 0.58);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.28s ease, visibility 0.28s ease;
}

.sidebar-backdrop.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Table Responsive Guarantee */
.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ============================================================
   COMPREHENSIVE MULTI-SCREEN RESPONSIVE ENGINE (ALL DEVICES)
   Laptop <=1200px | Tablet <=992px | Mobile <=768px | Small <=540px
   ============================================================ */

/* Global Anti-Overflow & Shrink Guarantees across All Viewports */
html,
body {
    max-width: 100%;
    overflow-x: clip;
}

.app-container,
.app-main,
.app-content {
    max-width: 100%;
    min-width: 0;
}

.app-content {
    overflow-x: clip;
}

.app-content > *,
.glass-panel {
    max-width: 100%;
    min-width: 0;
}

.topbar-lang-btn {
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    flex-shrink: 0;
}

/* 1. Compact Laptops & Small Desktops (<= 1200px) */
@media (max-width: 1200px) {
    .app-sidebar {
        width: 252px;
        min-width: 252px;
        max-width: 252px;
    }

    .app-topbar {
        padding: 0 20px;
    }

    .app-content {
        padding: 22px;
    }

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

/* 2. Tablets & Landscape Phones (<= 992px) */
@media (max-width: 992px) {
    .app-sidebar {
        position: fixed !important;
        top: 0;
        bottom: 0;
        inset-inline-start: -300px;
        width: 280px !important;
        min-width: 280px !important;
        max-width: 84vw !important;
        height: 100vh;
        height: 100dvh;
        z-index: 1050 !important;
        box-shadow: none;
        transition: inset-inline-start 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    }

    .app-sidebar.show {
        inset-inline-start: 0 !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        transform: none !important;
        box-shadow: 0 0 42px rgba(0, 0, 0, 0.5);
    }

    .app-container.sidebar-collapsed .app-sidebar.show {
        width: 280px !important;
        min-width: 280px !important;
        max-width: 84vw !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        transform: none !important;
    }

    .mobile-toggle-btn {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        font-size: 20px;
    }

    .sidebar-fold-btn {
        display: none !important;
    }

    .app-topbar {
        height: 64px;
        padding: 0 14px;
        gap: 8px;
    }

    .topbar-left {
        gap: 10px;
        min-width: 0;
        flex: 1;
    }

    .topbar-brand-slot img {
        max-height: 28px !important;
        max-width: 145px !important;
    }

    .topbar-right {
        gap: 7px;
        flex-shrink: 0;
    }

    .topbar-title {
        min-width: 0;
        overflow: hidden;
    }

    .topbar-brand-name {
        display: inline-block;
        max-width: 200px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        vertical-align: middle;
    }

    .app-content {
        padding: 16px;
    }

    /* Asymmetric multi-column layouts stack cleanly on tablet */
    .app-content [style*="grid-template-columns: 2fr 1fr"],
    .app-content [style*="grid-template-columns:2fr 1fr"],
    .app-content [style*="grid-template-columns: 1fr 2fr"],
    .app-content [style*="grid-template-columns:1fr 2fr"],
    .app-content [style*="grid-template-columns: 1.5fr 1fr"],
    .app-content [style*="grid-template-columns:1.5fr 1fr"],
    .app-content [style*="grid-template-columns: 1.2fr 1fr"],
    .app-content [style*="grid-template-columns:1.2fr 1fr"],
    .app-content [style*="grid-template-columns: 3fr 1fr"],
    .app-content [style*="grid-template-columns:3fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    .dashboard-ads-master-container {
        padding: 18px 16px !important;
        border-radius: 16px !important;
    }

    .sponsored-ad-banner {
        padding: 20px 18px;
        gap: 16px;
    }
}

/* 3. Standard Mobile Phones & Portrait Tablets (<= 768px) */
@media (max-width: 768px) {
    .app-content {
        padding: 14px 12px;
    }

    /* Reduce bulky inline panel paddings cleanly on mobile */
    .app-content .glass-panel {
        padding: 16px 14px !important;
        border-radius: 16px !important;
    }

    /* Preserve full-bleed project detail hero card padding=0 */
    .project-detail-container > .glass-panel:first-of-type {
        padding: 0 !important;
    }

    /* Stack multi-column inline grids inside pages & modals (except tiny 3-cell card micro-metrics) */
    .app-content [style*="grid-template-columns: 1fr 1fr"],
    .app-content [style*="grid-template-columns:1fr 1fr"],
    .app-content [style*="grid-template-columns: 1fr 1fr 1fr"],
    .app-content [style*="grid-template-columns:1fr 1fr 1fr"],
    .app-content [style*="grid-template-columns: 1fr 1fr 1fr 1fr"],
    .app-content [style*="grid-template-columns:1fr 1fr 1fr 1fr"],
    .app-content [style*="grid-template-columns: repeat(2, 1fr)"],
    .app-content [style*="grid-template-columns:repeat(2, 1fr)"],
    .app-content [style*="grid-template-columns: repeat(4, 1fr)"],
    .app-content [style*="grid-template-columns:repeat(4, 1fr)"],
    .app-content [style*="grid-template-columns: 140px 1fr"],
    .app-content [style*="grid-template-columns:140px 1fr"],
    .app-content [style*="grid-template-columns: 180px 1fr"],
    .app-content [style*="grid-template-columns:180px 1fr"],
    .modal-box [style*="grid-template-columns"],
    .hnd-grid-2,
    .hnd-signatures,
    .cc-form-grid {
        grid-template-columns: 1fr !important;
    }

    /* Prevent wide minmax() card grids from overflowing narrow phones */
    .app-content [style*="minmax(280px"],
    .app-content [style*="minmax(290px"],
    .app-content [style*="minmax(300px"],
    .app-content [style*="minmax(320px"],
    .app-content [style*="minmax(340px"],
    .app-content [style*="minmax(350px"],
    .app-content [style*="minmax(360px"],
    .app-content [style*="minmax(380px"],
    .app-content [style*="minmax(400px"] {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        margin-bottom: 18px;
    }

    .stat-card {
        padding: 14px 13px;
        border-radius: 14px;
        gap: 10px;
    }

    .stat-info {
        min-width: 0;
    }

    .stat-info span {
        font-size: 11.5px;
    }

    .stat-info h3 {
        font-size: 19px;
        word-break: break-word;
    }

    .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 18px;
        flex-shrink: 0;
    }

    /* Owner Portal Hero Banner & Integrated Unit Dropdown on Mobile */
    .owner-dashboard-wrapper > div:first-child {
        padding: 20px 16px !important;
        border-radius: 16px !important;
        gap: 14px !important;
    }

    #ownerHeroUnitPicker {
        display: block !important;
        width: 100%;
    }

    #ownerUnitDropdownBtn {
        width: 100%;
        justify-content: space-between;
        font-size: 12.5px !important;
        padding: 8px 12px !important;
    }

    #ownerUnitDropdownMenu {
        min-width: 0 !important;
        width: 100% !important;
        max-width: calc(100vw - 44px) !important;
        inset-inline-start: 0 !important;
        inset-inline-end: 0 !important;
    }

    /* Project Detail Hero Banner Mobile Tuning */
    .project-detail-container > .glass-panel:first-of-type > div:first-child {
        height: 250px !important;
    }

    .project-detail-container h1 {
        font-size: 21px !important;
    }

    /* Handover Sheet Mobile Padding */
    #handoverSheet {
        padding: 18px 14px !important;
        border-radius: 12px !important;
    }

    /* Compact headings & typography */
    .app-content h1 {
        font-size: 20px !important;
        line-height: 1.3;
    }

    .app-content h2 {
        font-size: 16.5px !important;
    }

    .app-content h3 {
        font-size: 15px !important;
    }

    /* Filter Bars wrap cleanly on mobile */
    .glass-panel form > div[style*="min-width"] {
        min-width: 0 !important;
        flex: 1 1 calc(50% - 8px) !important;
    }

    /* Tables & Table Control Bar */
    .table-ctrl-bar {
        padding: 8px 10px;
        gap: 6px;
        flex-wrap: wrap;
    }

    .table-ctrl-bar .tcb-left,
    .table-ctrl-bar .tcb-right {
        gap: 6px;
        flex-wrap: wrap;
    }

    .tsb-btn {
        padding: 5px 9px;
        font-size: 11.5px;
    }

    .modern-table th,
    .modern-table td,
    .table-custom th,
    .table-custom td {
        padding: 9px 10px;
        font-size: 12.5px;
    }

    /* Floating Table Window fits Mobile Viewport Cleanly */
    .floating-table-window {
        top: 4vh !important;
        top: 4dvh !important;
        left: 2vw !important;
        right: 2vw !important;
        width: 96vw !important;
        max-width: 96vw !important;
        height: 92vh !important;
        height: 92dvh !important;
        max-height: 92dvh !important;
        transform: none !important;
        border-radius: 14px !important;
    }

    .floating-table-header {
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .floating-table-title {
        font-size: 13px;
        flex: 1 1 100%;
    }

    .floating-table-actions {
        width: 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 6px;
    }

    /* Modals fit mobile viewports cleanly */
    .modal-overlay {
        padding: 10px;
        align-items: flex-start;
        overflow-y: auto;
    }

    .modal-box {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 92vh;
        max-height: 92dvh;
        margin: auto 0;
        padding: 16px 14px !important;
        border-radius: 16px;
    }

    .modal-box form {
        padding: 12px 0 0 !important;
    }

    /* Compact User Pill on <= 768px */
    .user-profile-meta {
        display: none !important;
    }

    .user-profile-pill {
        padding: 4px 5px;
        gap: 5px;
    }

    .user-avatar-circle {
        width: 30px;
        height: 30px;
        font-size: 12.5px;
    }

    .topbar-brand-name {
        max-width: 140px;
        font-size: 13.5px;
    }

    /* Floatable Screen Ads stay compact on mobile */
    #floatableAdsMasterWrapper {
        bottom: 10px !important;
        inset-inline-end: 10px !important;
        inset-inline-start: 10px !important;
        width: auto !important;
        max-width: calc(100vw - 20px) !important;
    }

    .floatable-screen-ad-card {
        width: 100% !important;
        max-width: 100% !important;
        padding: 12px 14px !important;
        border-radius: 14px !important;
    }

    .alert-toast {
        padding: 11px 13px;
        font-size: 12.5px;
    }
}

/* 4. Small Mobile Phones (<= 540px) */
@media (max-width: 540px) {
    .app-topbar {
        padding: 0 10px;
        height: 58px;
        gap: 6px;
    }

    .topbar-left {
        gap: 7px;
    }

    .topbar-right {
        gap: 5px;
    }

    .topbar-brand-slot img {
        max-height: 24px !important;
        max-width: 112px !important;
    }

    .topbar-brand-name {
        max-width: 100px;
        font-size: 12.5px;
    }

    .topbar-erp-badge {
        display: none !important;
    }

    /* Uniform square icon controls (Theme, Language, WhatsApp, Menu) */
    .btn-icon-control,
    .topbar-lang-btn,
    .topbar-wa-btn,
    .mobile-toggle-btn {
        width: 36px !important;
        height: 36px !important;
        font-size: 14.5px !important;
    }

    .topbar-lang-btn {
        font-size: 11.5px !important;
    }

    /* Owner Portal Hero Action Buttons -> Symmetrical 2x2 Grid on Small Phones */
    .owner-dashboard-wrapper > div:first-child > div:last-child {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px !important;
        width: 100%;
    }

    .owner-dashboard-wrapper > div:first-child > div:last-child > a,
    .owner-dashboard-wrapper > div:first-child > div:last-child > button {
        width: 100%;
        justify-content: center;
        padding: 9px 10px !important;
        font-size: 12px !important;
        text-align: center;
    }

    /* Full-width filter fields on small mobile */
    .glass-panel form > div[style*="min-width"],
    .glass-panel form > button[type="submit"],
    .glass-panel form > a.btn-secondary {
        flex: 1 1 100% !important;
        width: 100% !important;
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .payment-methods-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .btn-primary,
    .btn-gold,
    .btn-secondary {
        padding: 8px 12px;
        font-size: 12.5px;
    }

    .form-control,
    .form-select {
        padding: 10px 12px;
        font-size: 14px;
    }

    .table-ctrl-bar .tcb-btn-label {
        font-size: 11px;
    }
}

/* 5. Ultra-Compact Phones (<= 390px) */
@media (max-width: 390px) {
    .app-topbar {
        padding: 0 8px;
    }

    .btn-icon-control,
    .topbar-lang-btn,
    .topbar-wa-btn,
    .mobile-toggle-btn {
        width: 33px !important;
        height: 33px !important;
        font-size: 13.5px !important;
    }

    .topbar-lang-btn {
        font-size: 11px !important;
    }

    .topbar-brand-slot img {
        max-height: 22px !important;
        max-width: 94px !important;
    }

    .app-content {
        padding: 12px 9px;
    }

    .owner-dashboard-wrapper > div:first-child > div:last-child {
        grid-template-columns: 1fr !important;
    }
}

/* ==========================================================================
   Owner Portal Multi-Unit Switcher, Client Incomplete Filter & Column Sorting
   ========================================================================== */
.owner-unit-switcher-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.owner-unit-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 13px 15px;
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.07);
    border: 1.5px solid rgba(255, 255, 255, 0.16);
    color: #f8fafc;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

.owner-unit-card:hover {
    background: rgba(184, 147, 80, 0.16);
    border-color: rgba(233, 201, 138, 0.65);
    transform: translateY(-2px);
}

.owner-unit-card.is-active {
    background: linear-gradient(135deg, rgba(184, 147, 80, 0.28), rgba(184, 147, 80, 0.14));
    border-color: #e9c98a;
    box-shadow: 0 6px 18px rgba(184, 147, 80, 0.25);
}

.owner-unit-card .ouc-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.owner-unit-card .ouc-title {
    font-size: 14px;
    font-weight: 800;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.owner-unit-card .ouc-title i {
    color: #e9c98a;
}

.owner-unit-card .ouc-active-dot {
    font-size: 10px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 99px;
    background: #b89350;
    color: #ffffff;
    white-space: nowrap;
}

.owner-unit-card .ouc-meta {
    font-size: 11.5px;
    color: rgba(226, 232, 240, 0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.owner-unit-card .ouc-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 2px;
}

.owner-unit-card .ouc-pill {
    font-size: 10.5px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.owner-unit-card .ouc-pill-warn {
    background: rgba(239, 68, 68, 0.25);
    color: #fecaca;
}

.owner-unit-card .ouc-pill-info {
    background: rgba(245, 158, 11, 0.25);
    color: #fde68a;
}

#ownerUnitDropdownBtn:hover {
    background: rgba(184, 147, 80, 0.22) !important;
    border-color: #e9c98a !important;
}

.ou-dropdown-item:hover {
    background: rgba(184, 147, 80, 0.12) !important;
}

.ou-tab-card:hover {
    border-color: #b89350 !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(184, 147, 80, 0.16);
}

.ou-tab-card.is-active {
    box-shadow: 0 4px 14px rgba(184, 147, 80, 0.18);
}

/* Client Compact Table Filter: hide completed rows until Show All or Floating Window */
tr.client-completed-hidden {
    display: none !important;
}

.tcb-showall-btn {
    border-color: rgba(184, 147, 80, 0.45) !important;
    color: #b89350 !important;
    font-weight: 700 !important;
}

.tcb-showall-btn.active {
    background: linear-gradient(135deg, #b89350, #9c7a3d) !important;
    color: #ffffff !important;
    border-color: #b89350 !important;
}

/* Universal Click-to-Sort Column Headers (A→Z / Z→A) */
th.sortable-col {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.18s ease, color 0.18s ease;
    white-space: nowrap;
}

th.sortable-col:hover {
    background-color: rgba(184, 147, 80, 0.14);
}

th.sortable-col .sort-indicator {
    display: inline-block;
    margin-inline-start: 6px;
    font-size: 10px;
    opacity: 0.45;
    vertical-align: middle;
    transition: opacity 0.18s ease, color 0.18s ease;
}

th.sortable-col .sort-indicator::after {
    content: "⇅";
}

th.sortable-col:hover .sort-indicator {
    opacity: 0.85;
}

th.sortable-col.is-sort-asc .sort-indicator,
th.sortable-col.is-sort-desc .sort-indicator {
    opacity: 1;
    color: #b89350;
}

th.sortable-col.is-sort-asc .sort-indicator::after {
    content: "▲";
}

th.sortable-col.is-sort-desc .sort-indicator::after {
    content: "▼";
}

/* ==========================================================================
   Global Executive Print Rules (Applies Site-Wide to Ctrl+P & Direct Prints)
   ========================================================================== */
@media print {
    @page {
        margin: 0;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    html, body {
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        color: #1e293b !important;
    }

    .app-sidebar,
    .app-topbar,
    .sidebar-backdrop,
    .no-print,
    .table-float-btn,
    .floating-table-header,
    #floatableAdsMasterWrapper,
    .alert-toast {
        display: none !important;
    }

    .app-container {
        display: block !important;
    }

    .app-main {
        margin: 0 !important;
        padding: 12mm 14mm !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .app-content {
        padding: 0 !important;
    }

    .glass-panel {
        box-shadow: none !important;
        border: 1px solid #cbd5e1 !important;
        background: #ffffff !important;
    }

    .modern-table thead th,
    .table-custom thead th {
        background: #142542 !important;
        color: #ffffff !important;
        border-bottom: 2px solid #b89350 !important;
    }
}

/* Global UI Fail-Safe: Hide Excel Export & Import triggers for ALL non-admin users */
body[data-is-admin="0"] [onclick*="exportTableToExcel"],
body[data-is-admin="0"] [onclick*="openImportModal"],
body[data-is-admin="0"] a[href*="/data/export"],
body[data-is-admin="0"] a[href*="/reports/export-csv"] {
    display: none !important;
}

/* Universal Interactive Icons & KPI Cards Across the Entire System */
.stat-card,
.stat-icon,
.ps-kpi,
.ps-kpi .ico,
.proj-stat,
.fs-kpi-box,
.tr-type-card,
.tr-type-card .ico,
.interactive-sys-icon {
    cursor: pointer !important;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, border-color 0.2s ease !important;
}

.stat-card:hover,
.ps-kpi:hover,
.proj-stat:hover,
.fs-kpi-box:hover,
.tr-type-card:hover {
    transform: translateY(-3px);
    border-color: #b89350 !important;
    box-shadow: 0 8px 20px rgba(184, 147, 80, 0.18) !important;
}

.stat-icon:hover,
.ps-kpi:hover .ico,
.tr-type-card:hover .ico,
.interactive-sys-icon:hover {
    transform: scale(1.12);
    box-shadow: 0 4px 12px rgba(184, 147, 80, 0.28);
}

@keyframes sysTargetPulse {
    0%   { box-shadow: 0 0 0 0 rgba(184, 147, 80, 0.7); border-color: #b89350; }
    50%  { box-shadow: 0 0 0 8px rgba(184, 147, 80, 0.18); border-color: #b89350; }
    100% { box-shadow: 0 0 0 0 rgba(184, 147, 80, 0); }
}

.sys-target-highlight {
    animation: sysTargetPulse 1.4s ease-out;
}

/* Fixed Sidebar on Desktop: when sidebar is open, only the main display area (topbar + content) scrolls */
@media screen and (min-width: 993px) {
    .app-container:not(.sidebar-collapsed) {
        height: 100vh;
        min-height: 0;
        overflow: hidden;
    }
    .app-container:not(.sidebar-collapsed) .app-sidebar {
        height: 100vh;
        align-self: stretch;
    }
    .app-container:not(.sidebar-collapsed) .app-main {
        height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
        scroll-behavior: smooth;
    }
}
@media print {
    .app-container:not(.sidebar-collapsed),
    .app-container:not(.sidebar-collapsed) .app-main {
        height: auto !important;
        overflow: visible !important;
    }
    .table-responsive.is-minimized,
    .fs-pillar-card.is-collapsed .fs-pillar-body {
        display: block !important;
    }
}

/* Universal Smart System-First Field Picker (Select from DB first + Manual Entry toggle) */
.smart-picker-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
}
.smart-picker-select {
    width: 100%;
    cursor: pointer;
    border-inline-start: 3px solid #b89350 !important;
}
.smart-picker-manual-row {
    display: flex;
    align-items: stretch;
    gap: 6px;
    width: 100%;
}
.smart-picker-manual-row > input {
    flex: 1 1 auto;
    min-width: 0;
}
.smart-picker-back-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 10px;
    border-radius: 9px;
    border: 1px solid rgba(184, 147, 80, 0.5);
    background: rgba(184, 147, 80, 0.12);
    color: #b89350;
    font-size: 11.5px;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: all 0.16s ease;
}
.smart-picker-back-btn:hover {
    background: #b89350;
    color: #142542;
}
.smart-picker-wrap.is-select-mode .smart-picker-manual-row {
    display: none !important;
}
.smart-picker-wrap.is-manual-mode .smart-picker-select {
    display: none !important;
}
