/* Sleek Interface Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f8fafc; /* slate-50 */
    color: #0f172a; /* slate-900 */
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* Authentication & Dashboard container cards */
.auth-container, .dashboard-container {
    background: #ffffff;
    padding: 40px;
    border-radius: 16px; /* rounded-2xl */
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05); /* shadow-xl */
    border: 1px solid #e2e8f0; /* border-slate-200 */
    width: 100%;
    max-width: 440px;
    box-sizing: border-box;
}

.dashboard-container {
    max-width: 580px;
}

h2 {
    margin-top: 0;
    margin-bottom: 24px;
    color: #0f172a;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.025em;
    text-align: center;
}

label {
    display: block;
    margin-bottom: 6px;
    color: #475569; /* text-slate-600 */
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input, select, textarea {
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 20px;
    border: 1px solid #cbd5e1; /* border-slate-300 */
    border-radius: 8px; /* rounded-lg */
    background-color: #f8fafc; /* bg-slate-50 */
    color: #0f172a;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease-in-out;
    box-sizing: border-box;
}

input:focus, select:focus, textarea:focus {
    border-color: #4f46e5; /* border-indigo-600 */
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
    background-color: #ffffff;
}

button:focus-visible, a:focus-visible, .filter-tab:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid #4f46e5 !important;
    outline-offset: 2px !important;
}

button {
    width: 100%;
    padding: 12px;
    background-color: #4f46e5; /* bg-indigo-600 */
    color: #ffffff;
    border: none;
    border-radius: 8px; /* rounded-lg */
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.1), 0 2px 4px -2px rgba(79, 70, 229, 0.1);
    transition: all 0.2s ease-in-out;
}

button:hover {
    background-color: #4338ca; /* bg-indigo-700 */
}

button:active {
    transform: scale(0.98);
}

/* Response status messages styled elegantly */
#message {
    margin-bottom: 16px;
}

#message p {
    margin: 0;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
}

.error {
    background-color: #fef2f2; /* red-50 */
    border: 1px solid #fee2e2;
    color: #b91c1c; /* red-700 */
}

.success {
    background-color: #ecfdf5; /* emerald-50 */
    border: 1px solid #d1fae5;
    color: #047857; /* emerald-700 */
}

.info {
    background-color: #eff6ff; /* blue-50 */
    border: 1px solid #dbeafe;
    color: #1d4ed8; /* blue-700 */
}

/* Links & typography accents */
a {
    color: #4f46e5;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.15s ease-in-out;
}

a:hover {
    color: #4338ca;
    text-decoration: underline;
}

p {
    font-size: 14px;
    line-height: 1.6;
    color: #475569; /* text-slate-600 */
    margin: 8px 0;
}

ul {
    padding-left: 20px;
    margin: 16px 0;
}

li {
    font-size: 14px;
    color: #475569;
    margin-bottom: 8px;
}

.dashboard-container p a, .auth-container p a {
    display: inline-block;
}

.auth-container p {
    text-align: center;
    margin-top: 24px;
    margin-bottom: 0;
    font-size: 13px;
}

code {
    font-family: "JetBrains Mono", SFMono-Regular, Consolas, monospace;
    background-color: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

@media (max-width: 480px) {
    body {
        background-color: #ffffff;
    }
    .auth-container, .dashboard-container {
        padding: 24px 16px;
        box-shadow: none;
        border-radius: 0;
        border: none;
        width: 100%;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
}

/* Wide Dashboard page layouts override */
body.wide-page {
    display: block;
    min-height: 100vh;
    background-color: #f8fafc;
}

.wide-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
    box-sizing: border-box;
}

/* Navigation bar */
.navbar {
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.navbar-brand {
    font-size: 18px;
    font-weight: 700;
    color: #4f46e5;
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-brand span {
    color: #0f172a;
}

.navbar-nav {
    display: flex;
    gap: 20px;
    align-items: center;
}

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

.stat-card {
    background: #ffffff;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1;
}

/* Actions panel above table */
.actions-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-container {
    position: relative;
    flex: 1;
    max-width: 400px;
    min-width: 250px;
}

.search-input {
    margin-bottom: 0 !important;
    padding-left: 36px !important;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
    font-size: 14px;
}

.filter-tabs {
    display: flex;
    background-color: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
    gap: 4px;
}

.filter-tab {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    border-radius: 6px;
    cursor: pointer;
    border: none;
    background: none;
    transition: all 0.15s ease;
    width: auto;
    box-shadow: none;
}

.filter-tab:hover {
    color: #0f172a;
}

.filter-tab.active {
    background-color: #ffffff;
    color: #4f46e5;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Table styles */
.table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
    margin-bottom: 30px;
    width: 100% !important;
    max-width: 100% !important;
}

/* Customized slim, elegant scrollbars for responsive tables */
.table-responsive::-webkit-scrollbar {
    height: 6px !important;
    width: 6px !important;
}
.table-responsive::-webkit-scrollbar-track {
    background: #f8fafc !important;
    border-radius: 9999px !important;
}
.table-responsive::-webkit-scrollbar-thumb {
    background: #cbd5e1 !important;
    border-radius: 9999px !important;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #94a3b8 !important;
}

.tenant-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.tenant-table th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 600;
    padding: 14px 18px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    white-space: nowrap !important; /* Keep table headers clean */
}

.tenant-table td {
    padding: 14px 18px;
    border-bottom: 1px solid #e2e8f0;
    color: #334155;
    vertical-align: middle;
}

.tenant-table tr:hover {
    background-color: #f8fafc;
}

/* Specific Responsive Adjustments for EVERY Table on Mobile/Tablet */
@media (max-width: 768px) {
    .tenant-table th, .tenant-table td,
    .invoice-table th, .invoice-table td {
        white-space: nowrap !important; /* Prevent text wrapping and overlapping */
        padding: 10px 14px !important; /* Touch device optimized padding */
        font-size: 13px !important; /* Clear, responsive readable font sizing */
    }
    
    .tenant-table th, .invoice-table th {
        font-size: 11px !important;
        padding-top: 12px !important;
        padding-bottom: 12px !important;
    }
    
    /* Ensure action buttons are always accessible and have large tap targets */
    .tenant-table td .btn-sm, .invoice-table td .btn-sm {
        min-height: 38px !important; /* Easy tap targets on mobile */
        padding: 8px 12px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        white-space: nowrap !important;
    }
    
    /* Allow cell badges to align perfectly */
    .badge {
        font-size: 10px !important;
        padding: 4px 10px !important;
    }
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-active {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-inactive {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Photo placeholders */
.tenant-photo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background-color: #f1f5f9;
    border: 1px solid #cbd5e1;
}

.tenant-photo-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    font-weight: 700;
    font-size: 12px;
    border: 1px solid #cbd5e1;
}

/* Buttons sizing */
.btn-sm {
    padding: 6px 12px !important;
    font-size: 12px !important;
    border-radius: 6px !important;
    width: auto !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    font-weight: 600 !important;
    box-shadow: none !important;
}

.btn-outline {
    background-color: transparent !important;
    border: 1px solid #cbd5e1 !important;
    color: #475569 !important;
}

.btn-outline:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}

.btn-danger {
    background-color: #ef4444 !important;
    color: #ffffff !important;
}

.btn-danger:hover {
    background-color: #dc2626 !important;
    color: #ffffff !important;
}

.btn-warning {
    background-color: #f59e0b !important;
    color: #ffffff !important;
}

.btn-warning:hover {
    background-color: #d97706 !important;
    color: #ffffff !important;
}

.actions-cell {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Forms layout for adding/editing */
.form-card {
    background: #ffffff;
    padding: 36px;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    box-sizing: border-box;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.form-card h2 {
    text-align: left;
    margin-bottom: 8px;
}

.form-card .subtitle {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 24px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 16px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    border-top: 1px solid #f1f5f9;
    padding-top: 20px;
}

.form-actions button {
    width: auto !important;
    padding: 10px 24px !important;
}

/* Profiles layout */
.profile-card {
    background: #ffffff;
    padding: 36px;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    box-sizing: border-box;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 30px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 24px;
}

.profile-photo-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #4f46e5;
    background-color: #f1f5f9;
}

.profile-photo-placeholder-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4f46e5;
    font-weight: 700;
    font-size: 28px;
    border: 2px solid #cbd5e1;
}

.profile-title-area h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
}

.profile-title-area p {
    margin: 4px 0 0 0;
    font-size: 13px;
    color: #64748b;
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 600px) {
    .profile-grid {
        grid-template-columns: 1fr;
    }
}

.profile-item {
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 12px;
}

.profile-item-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.profile-item-value {
    font-size: 14px;
    color: #0f172a;
    font-weight: 500;
}

.no-tenants {
    text-align: center;
    padding: 40px;
    color: #64748b;
    font-size: 14px;
}

/* ==========================================================
   PHASE 1: COMPLETE RESPONSIVE DESIGN IMPROVEMENTS
   ========================================================== */

/* Prevent overall page horizontal overflow */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Base image auto-resize rule */
img {
    max-width: 100%;
    height: auto;
}

/* Progressive wide container sizing to reduce empty desktop whitespace and keep centered at professional max width */
@media (min-width: 1200px) {
    .wide-container {
        max-width: 1140px;
        margin: 32px auto;
    }
}
@media (min-width: 1366px) {
    .wide-container {
        max-width: 1280px;
        margin: 36px auto;
    }
}
@media (min-width: 1440px) {
    .wide-container {
        max-width: 1380px;
        margin: 40px auto;
    }
}
@media (min-width: 1600px) {
    .wide-container {
        max-width: 1400px; /* Cap around 1400px professional maximum content width */
        margin: 40px auto;
    }
}
@media (min-width: 1920px) {
    .wide-container {
        max-width: 1400px; /* Cap around 1400px professional maximum content width */
        margin: 40px auto;
    }
}

/* Align Navbar contents perfectly with the centered content container on desktop */
@media (min-width: 1400px) {
    .navbar {
        padding: 16px calc((100vw - 1400px) / 2 + 24px) !important;
    }
}

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

/* ==========================================================
   PHASE 3: MOBILE NAVIGATION & SLIDE-IN HAMBURGER MENU
   ========================================================== */

/* Semi-transparent Overlay behind the sidebar */
.mobile-nav-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: rgba(15, 23, 42, 0.45) !important;
    backdrop-filter: blur(2px) !important;
    z-index: 998 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}
.mobile-nav-overlay.active {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Toggle Hamburger Button styles */
.mobile-nav-toggle {
    display: none; /* Hidden on desktop */
    background: none !important;
    border: none !important;
    color: #4f46e5 !important;
    font-size: 24px !important;
    cursor: pointer !important;
    padding: 8px !important;
    z-index: 1001 !important; /* Always visible and above the slide-in sidebar */
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    transition: background-color 0.2s, color 0.2s, transform 0.2s !important;
    width: 44px !important;
    height: 44px !important;
    line-height: 1 !important;
}
.mobile-nav-toggle:hover {
    background-color: #f1f5f9 !important;
}
.mobile-nav-toggle.open {
    color: #ef4444 !important;
    transform: rotate(90deg) !important;
}

/* Better modal fitting on ultra small screens */
#decisionModal > div {
    max-width: 92% !important;
    width: auto !important;
    margin: 20px auto !important;
    box-sizing: border-box !important;
}
#proofModal img {
    max-height: 75vh !important;
    max-width: 100% !important;
    object-fit: contain !important;
}

/* Dark theme support for toggle, overlay and modals */
html.dark-theme .mobile-nav-toggle {
    color: #cbd5e1 !important;
}
html.dark-theme .mobile-nav-toggle:hover {
    background-color: #334155 !important;
}
html.dark-theme .mobile-nav-overlay {
    background-color: rgba(0, 0, 0, 0.6) !important;
}

/* Tablet & Mobile Overrides */
@media (max-width: 1024px) {
    /* Show mobile hamburger toggle button */
    .mobile-nav-toggle {
        display: inline-flex !important;
    }

    /* Navbar top bar layout */
    .navbar {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 12px 16px !important;
        position: sticky !important;
        top: 0 !important;
        width: 100% !important;
        box-sizing: border-box !important;
        z-index: 1000 !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
    }
    
    .navbar-brand {
        margin-bottom: 0 !important;
    }
    
    /* Convert navigation links into a left slide-in drawer sidebar */
    .navbar-nav {
        position: fixed !important;
        top: 0 !important;
        left: -280px !important; /* Start completely offscreen */
        width: 280px !important;
        height: 100vh !important;
        background-color: #ffffff !important;
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.12) !important;
        z-index: 999 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        padding: 80px 20px 24px 20px !important;
        gap: 8px !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        overflow-y: auto !important;
        box-sizing: border-box !important;
    }
    
    /* Slide-in sidebar active state */
    .navbar-nav.active {
        transform: translateX(280px) !important;
    }
    
    /* Style menu elements in mobile drawer with enhanced touch target sizes (min-height: 44px) */
    .navbar-nav a {
        display: flex !important;
        align-items: center !important;
        width: 100% !important;
        padding: 12px 16px !important;
        border-radius: 8px !important;
        color: #334155 !important;
        font-weight: 500 !important;
        font-size: 15px !important;
        text-decoration: none !important;
        transition: background-color 0.2s ease, color 0.2s ease !important;
        box-sizing: border-box !important;
        min-height: 44px !important; /* Increase touch target size */
    }
    
    .navbar-nav a:hover {
        background-color: #f1f5f9 !important;
        color: #4f46e5 !important;
    }
    
    /* Header/Welcome text inside slide-in sidebar */
    .navbar-nav span {
        display: block !important;
        padding: 12px 16px !important;
        font-size: 14px !important;
        color: #64748b !important;
        border-bottom: 1px solid #f1f5f9 !important;
        margin-bottom: 12px !important;
        box-sizing: border-box !important;
    }

    /* Dark theme mobile sidebar support */
    html.dark-theme .navbar-nav {
        background-color: #1e293b !important;
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.3) !important;
    }
    html.dark-theme .navbar-nav a {
        color: #cbd5e1 !important;
    }
    html.dark-theme .navbar-nav a:hover {
        background-color: #334155 !important;
        color: #ffffff !important;
    }
    html.dark-theme .navbar-nav span {
        color: #94a3b8 !important;
        border-bottom-color: #334155 !important;
    }
    
    /* Stats Grid alignment on iPad/tablets */
    .stats-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 16px !important;
    }
    
    /* Prevent table text squeezing */
    .tenant-table {
        min-width: 750px;
    }
}

@media (max-width: 768px) {
    /* Base wide container spacing optimization */
    .wide-container {
        margin: 16px auto !important;
        padding: 0 12px !important;
    }
    
    /* Center wide containers dynamically */
    .dashboard-container, .form-card, .profile-card {
        padding: 24px !important;
        width: 100% !important;
        box-sizing: border-box;
    }
    
    /* Stats grid alignment on smaller tablets */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
    }
    
    /* Profile Grid responsiveness */
    .profile-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    /* Force form grid to be single column */
    .form-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Override inline 2-column layouts to single column */
    div[style*="grid-template-columns: 1.2fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns: 1fr  1fr"],
    div[style*="grid-template-columns:1fr 1fr"],
    div[style*="grid-template-columns:1.2fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    
    /* Actions panel adjustments */
    .actions-panel {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }
    .search-container {
        max-width: 100% !important;
        width: 100% !important;
    }
    .actions-panel > div {
        width: 100% !important;
        justify-content: space-between !important;
    }
    .actions-panel > div a, .actions-panel > div button {
        flex: 1;
        text-align: center;
        justify-content: center;
    }
    
    /* Responsive typography scaling */
    body {
        font-size: 14px;
    }
    h2 {
        font-size: 20px !important;
    }
    h3 {
        font-size: 16px !important;
    }
    .stat-value {
        font-size: 24px !important;
    }
}

@media (max-width: 480px) {
    /* Spacing & Padding optimization on mobile screens */
    .dashboard-container, .form-card, .profile-card {
        padding: 16px !important;
        border-radius: 12px !important;
    }
    
    /* Balanced stats grid layout for mobile */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    /* Symmetrical look by expanding odd card to double width */
    .stats-grid .stat-card:last-child {
        grid-column: span 2 !important;
    }
    
    /* Button wrapping on mobile */
    .form-actions {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding-top: 16px !important;
    }
    .form-actions button, .form-actions a {
        width: 100% !important;
        text-align: center !important;
        justify-content: center !important;
    }
    
    /* Typography scaling for mobile */
    body {
        font-size: 13px;
    }
    h2 {
        font-size: 18px !important;
    }
    h3 {
        font-size: 14px !important;
    }
    .stat-value {
        font-size: 20px !important;
    }
}

@media (max-width: 360px) {
    /* Stack stats grid fully on ultra-small viewports */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    .stats-grid .stat-card:last-child {
        grid-column: span 1 !important;
    }
}

/* ==========================================================
   PHASE 2: DESKTOP DASHBOARD LAYOUT IMPROVEMENTS (>= 1200px)
   ========================================================== */
@media (min-width: 1200px) {
    /* Professional and even stats card alignment */
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
        gap: 24px !important;
        margin-bottom: 32px !important;
    }

    .stat-card {
        padding: 24px 28px !important;
        border-radius: 14px !important;
        box-shadow: 0 4px 12px -2px rgba(0,0,0,0.03), 0 2px 4px -1px rgba(0,0,0,0.01) !important;
        transition: transform 0.2s ease, box-shadow 0.2s ease !important;
    }

    .stat-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 20px -5px rgba(0,0,0,0.04), 0 4px 6px -2px rgba(0,0,0,0.02) !important;
    }

    /* Professional search section alignment and sizing */
    .search-container {
        max-width: 460px !important;
        transition: max-width 0.25s ease !important;
    }

    .search-container:focus-within {
        max-width: 520px !important;
    }

    /* Action buttons and page headers positioning */
    .actions-panel {
        margin-bottom: 24px !important;
        gap: 24px !important;
    }

    /* High quality Table desktop spacing & card padding alignment */
    .table-responsive {
        border-radius: 14px !important;
        box-shadow: 0 4px 12px -2px rgba(0,0,0,0.03) !important;
        border-color: #e2e8f0 !important;
        margin-bottom: 40px !important;
    }

    .tenant-table th {
        padding: 16px 24px !important;
        background-color: #f8fafc !important;
        font-weight: 700 !important;
        letter-spacing: 0.05em !important;
    }

    .tenant-table td {
        padding: 18px 24px !important;
    }

    /* Page Header and container spacing */
    .wide-container {
        padding: 0 32px !important;
    }
}

/* ==========================================================
   DEVICE-SPECIFIC PROFILES (1024px, 768px, 480px, 390px, 375px, 360px, 320px)
   ========================================================== */

/* 1024px Profile (iPad Pro / Small Laptop) */
@media (max-width: 1024px) {
    .wide-container {
        padding: 0 16px !important;
        margin-top: 24px !important;
    }
}

/* 768px Profile (iPad Mini / Portrait Tablet) */
@media (max-width: 768px) {
    .dashboard-container, .form-card, .profile-card {
        padding: 20px !important;
    }
    /* Touch target padding for actionable buttons and elements */
    .btn, .btn-sm, .btn-outline, .btn-danger, input[type="submit"], input[type="button"], a.btn-sm, a.btn {
        min-height: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding-top: 8px !important;
        padding-bottom: 8px !important;
    }
}

/* 480px Profile (Large Smartphones) */
@media (max-width: 480px) {
    .wide-container {
        padding: 0 10px !important;
        margin-top: 16px !important;
    }
    .stats-grid {
        gap: 12px !important;
    }
}

/* 390px & 375px Profiles (iPhone 12/13/14/15/16 and iPhone SE/X/XS) */
@media (max-width: 390px) {
    .dashboard-container, .form-card, .profile-card {
        padding: 14px !important;
        border-radius: 10px !important;
    }
    .stats-grid {
        grid-template-columns: 1fr !important; /* Stack grid items to keep typography readable */
        gap: 10px !important;
    }
    .stats-grid .stat-card:last-child {
        grid-column: span 1 !important;
    }
}

/* 360px & 320px Profiles (Galaxy S8/S9/S10 and iPhone 5/SE 1st Gen) */
@media (max-width: 360px) {
    .navbar-brand {
        font-size: 16px !important;
    }
    .mobile-nav-toggle {
        width: 38px !important;
        height: 38px !important;
        font-size: 20px !important;
    }
    h2 {
        font-size: 16px !important;
    }
    .dashboard-container, .form-card, .profile-card {
        padding: 12px !important;
    }
}



