/**
 * SESSIONVAULT - LAYOUT CSS
 * --------------------------------------------------------
 * TABLE OF CONTENTS:
 * --------------------------------------------------------
 * 1. App Root & Sidebar
 * 2. Navigation
 * 3. Main Content Area & Topbar
 * 4. Responsive Overrides (Mobile Shell)
 * 5. Grid Layouts, Split Panes & Responsive Metrics
 * ========================================================
 */

/* ======================================================== */
/* 1. APP ROOT & SIDEBAR                                    */
/* ======================================================== */
#app-root {
    display: none;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    flex-shrink: 0;
    overflow-y: auto;
}

.brand-wrapper {
    margin-bottom: 24px;
    padding: 0 8px 24px 8px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
}

.brand {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex-shrink: 0;
}

.brand svg {
    width: 200px;
    height: 60px;
    max-width: 100%;
}

.brand-practice-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #cbd5e1;
    letter-spacing: 0.3px;
    width: 100%;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    line-height: 1.3;
}

[dir="rtl"] .brand-practice-title {
    text-align: right !important;
}


.brand-icon-mobile {
    display: none;
}

/* ======================================================== */
/* 2. NAVIGATION                                            */
/* ======================================================== */
.nav-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.sidebar-section-header {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 10px 12px 4px 12px;
    text-transform: uppercase;
    user-select: none;
}

.sidebar-icon {
    flex-shrink: 0;
    margin-inline-end: 12px;
    stroke: currentColor;
    transition: transform 0.15s ease, stroke 0.15s ease;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.92rem;
    margin-bottom: 3px;
    color: var(--sidebar-text, #94a3b8);
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    position: relative;
    box-sizing: border-box;
}

.nav-link:hover {
    background-color: var(--sidebar-hover, #1e293b);
    color: #ffffff;
}

.nav-link:hover .sidebar-icon {
    transform: scale(1.08);
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.18) 0%, rgba(59, 130, 246, 0.05) 100%);
    color: #60a5fa !important;
    font-weight: 600;
    border-inline-start: 3px solid #3b82f6;
}

[dir="rtl"] .nav-link.active {
    background: linear-gradient(-90deg, rgba(59, 130, 246, 0.18) 0%, rgba(59, 130, 246, 0.05) 100%);
}

.nav-link.active .sidebar-icon {
    color: #60a5fa;
}

/* Pinned Practice Account Card */
.sidebar-footer-account {
    margin-top: auto;
    padding: 12px;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(51, 65, 85, 0.6);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    margin-top: 24px;
    box-sizing: border-box;
}

.sidebar-footer-account:hover {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(100, 116, 139, 0.8);
}

.footer-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.footer-info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.footer-name {
    font-size: 0.84rem;
    font-weight: 600;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.footer-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    color: #94a3b8;
    line-height: 1.2;
}

.footer-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 6px #10b981;
    flex-shrink: 0;
}

.footer-lock-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(51, 65, 85, 0.5);
    border: 1px solid rgba(71, 85, 105, 0.6);
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.footer-lock-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #f87171;
}

#link-admin:not(.active) {
    color: #38bdf8;
}

.admin-nav-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 8px;
    height: 8px;
    background: #ef4444;
    color: #ffffff;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.3);
    animation: admin-pulse 2.5s infinite;
}

.admin-nav-indicator.has-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
}

@keyframes admin-pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
    70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

#admin-btn-refresh.spinning {
    opacity: 0.7;
    pointer-events: none;
}

#admin-btn-refresh.spinning svg {
    animation: spin-anim 0.8s linear infinite !important;
}

.admin-badge-new {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
    font-size: 0.68rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
    line-height: 1.3;
}

.admin-badge-new::before {
    content: '●';
    font-size: 0.55rem;
    color: #059669;
}

.admin-role-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.admin-role-founder {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.admin-role-admin {
    background: #e0e7ff;
    color: #4338ca;
    border: 1px solid #c7d2fe;
}

.admin-role-support {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.admin-role-vip {
    background: #f3e8ff;
    color: #7c3aed;
    border: 1px solid #d8b4fe;
}

.admin-role-customer {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.admin-type-select {
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--surface);
    color: var(--text-main);
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.admin-type-select:hover,
.admin-type-select:focus {
    border-color: var(--accent);
}

.admin-type-select[data-type="support"] {
    background: rgba(2, 132, 199, 0.12);
    color: #0284c7;
    border-color: #38bdf8;
    font-weight: 700;
}

.admin-type-select[data-type="vip"] {
    background: rgba(168, 85, 247, 0.12);
    color: #9333ea;
    border-color: #c084fc;
    font-weight: 700;
}

.admin-type-select[data-type="customer"] {
    background: var(--surface);
    color: var(--text-main);
    border-color: var(--border);
}

.admin-user-row-admin {
    background: rgba(99, 102, 241, 0.06) !important;
    border-left: 4px solid #6366f1 !important;
}

.admin-user-row-support {
    background: rgba(2, 132, 199, 0.06) !important;
    border-left: 4px solid #0284c7 !important;
}

.admin-user-row-vip {
    background: rgba(168, 85, 247, 0.06) !important;
    border-left: 4px solid #a855f7 !important;
}

/* ======================================================== */
/* ADMIN CONSOLE FILTER TOOLBAR & RESPONSIVE LAYOUT         */
/* ======================================================== */
.admin-filter-toolbar {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    background: var(--surface);
}

.admin-search-sort-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 1;
    max-width: 440px;
}

.admin-search-box {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
}

.admin-search-icon {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    pointer-events: none;
    flex-shrink: 0;
}

[dir="rtl"] .admin-search-icon {
    left: auto;
    right: 10px;
}

#admin-search-input,
#admin-ticket-search-input {
    width: 100%;
    height: 38px;
    padding: 0 12px 0 34px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 0.88rem;
    background: var(--bg-main, #f8fafc);
    color: var(--text-main);
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

[dir="rtl"] #admin-search-input,
[dir="rtl"] #admin-ticket-search-input {
    padding: 0 34px 0 12px;
}

#admin-search-input:focus,
#admin-ticket-search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
    outline: none;
}

.admin-sort-box {
    flex: 0 0 auto;
}

#admin-sort-by,
#admin-filter-status,
#admin-filter-plan,
#admin-ticket-filter-status,
#admin-ticket-filter-category {
    height: 38px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 500;
    background: var(--bg-main, #f8fafc);
    color: var(--text-main);
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

#admin-sort-by:focus,
#admin-filter-status:focus,
#admin-filter-plan:focus,
#admin-ticket-filter-status:focus,
#admin-ticket-filter-category:focus {
    border-color: var(--accent);
    outline: none;
}

.ticket-view-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-main, #f8fafc);
    height: 38px;
    box-sizing: border-box;
    flex: 0 0 auto;
}

.ticket-view-toggle .btn {
    padding: 0 10px;
    font-size: 0.82rem;
    font-weight: 500;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    height: 100%;
}

.ticket-view-toggle .btn.active {
    background: var(--accent, #2563eb);
    color: #fff;
}

.admin-filter-pills-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ======================================================== */
/* ADMIN CONSOLE MOBILE RESPONSIVE ACCORDIONS               */
/* ======================================================== */
.admin-mobile-accordion {
    display: none;
    flex-direction: column;
    gap: 8px;
}

@media (max-width: 820px) {
    .admin-desktop-table {
        display: none !important;
    }
    .admin-mobile-accordion {
        display: flex !important;
    }
    .admin-kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        margin-bottom: 16px !important;
    }
    .admin-kpi-grid .panel {
        padding: 12px 14px !important;
    }
    .admin-kpi-grid .panel > div:nth-child(2) {
        font-size: 1.35rem !important;
    }

    .admin-filter-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        padding: 10px 12px !important;
    }

    .admin-search-sort-row {
        max-width: none !important;
        width: 100% !important;
        gap: 8px !important;
    }

    .admin-search-box {
        flex: 1 1 auto !important;
        min-width: 0 !important;
    }

    #admin-search-input,
    #admin-ticket-search-input {
        height: 38px !important;
        font-size: 0.84rem !important;
        padding: 0 10px 0 32px !important;
    }

    [dir="rtl"] #admin-search-input,
    [dir="rtl"] #admin-ticket-search-input {
        padding: 0 32px 0 10px !important;
    }

    .admin-sort-box {
        flex: 0 0 auto !important;
        width: 120px !important;
        max-width: 130px !important;
    }

    .ticket-view-toggle {
        height: 38px !important;
        flex: 0 0 auto !important;
    }

    .ticket-view-toggle .btn {
        padding: 0 8px !important;
        font-size: 0.78rem !important;
    }

    #admin-sort-by {
        height: 38px !important;
        font-size: 0.8rem !important;
        padding: 0 6px !important;
        width: 100% !important;
        text-overflow: ellipsis;
    }

    .admin-filter-pills-row {
        width: 100% !important;
        gap: 8px !important;
    }

    #admin-filter-status,
    #admin-filter-plan,
    #admin-ticket-filter-status,
    #admin-ticket-filter-category {
        flex: 1 1 50% !important;
        width: 50% !important;
        height: 36px !important;
        font-size: 0.8rem !important;
        padding: 0 6px !important;
    }
}

.admin-accordion-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.admin-accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    min-height: 42px;
    box-sizing: border-box;
    cursor: pointer;
    user-select: none;
    gap: 8px;
    background: var(--surface);
    -webkit-tap-highlight-color: transparent;
}

.admin-accordion-header:active {
    background: var(--bg-main);
}

.admin-accordion-item .accordion-arrow {
    font-size: 0.72rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    display: inline-block;
}

.admin-accordion-item.open .accordion-arrow {
    transform: rotate(180deg);
}

.admin-accordion-body {
    display: none;
    padding: 0 12px 12px 12px;
    border-top: 1px dashed var(--border);
    font-size: 0.83rem;
    background: var(--bg-main);
}

.admin-accordion-item.open .admin-accordion-body {
    display: block;
}


/* ======================================================== */
/* 3. MAIN CONTENT AREA & TOPBAR                            */
/* ======================================================== */
.main-frame {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    background-color: var(--bg-app);
    /* NEW: Force GPU rendering to stop flicker during keyboard slide-up */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000;
}

.top-bar {
    min-height: 64px;
    height: 64px;
    background-color: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center !important;
    justify-content: space-between;
    padding: 0 32px;
    flex-shrink: 0;
    flex-wrap: nowrap !important;
    gap: 12px;
    box-sizing: border-box;
}

.topbar-mobile-brand {
    display: none;
}

#view-title {
    color: #0f172a;
    font-weight: 700;
    letter-spacing: -0.025em;
}

#top-bar-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.topbar-sync-badge {
    display: flex;
    align-items: center;
    gap: 7px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 5px 12px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: all 0.15s ease;
}

.topbar-sync-badge:hover {
    border-color: #cbd5e1;
    background: #f8fafc;
}

.sync-pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #10b981;
    display: inline-block;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

#global-sync-status {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1.15;
    text-align: start;
    display: block;
}

.topbar-actions-group {
    display: flex;
    align-items: center;
    gap: 2px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 3px 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.topbar-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    border-radius: 16px;
    cursor: pointer;
    color: #64748b;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
    box-sizing: border-box;
    outline: none;
    -webkit-tap-highlight-color: transparent !important;
}

@media (hover: hover) {
    .topbar-action-btn:hover {
        background: rgba(37, 99, 235, 0.08);
        color: var(--accent);
    }
}

.topbar-action-btn:active {
    background: rgba(37, 99, 235, 0.15);
    color: var(--accent);
    transform: scale(0.95);
}

.topbar-action-btn:focus {
    outline: none;
}

.topbar-action-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.topbar-action-btn.spinning {
    animation: none !important;
    transform: none !important;
    background: transparent !important;
}

.topbar-action-btn.spinning svg,
svg.spinning {
    animation: spin-anim 1s linear infinite !important;
    transform-origin: center;
}

.content-box {
    padding: 32px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    -webkit-overflow-scrolling: touch;
    /* NEW: Force GPU rendering to stop flicker during keyboard slide-up */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000;
}

.panel {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
    min-width: 0;
}

#subscription-status-badge {
    max-width: 100%;
}

#subscription-status-badge>span {
    display: inline-block;
    max-width: 100%;
    word-break: break-word;
}

.split-pane {
    display: grid;
    grid-template-columns: 400px minmax(0, 1fr);
    gap: 24px;
}

.section-view {
    display: none;
}

.section-view.active-view {
    display: block;
}


/* ======================================================== */
/* 4. RESPONSIVE OVERRIDES (MOBILE SHELL)                   */
/* ======================================================== */
@media (min-width: 1001px) {
    .mobile-nav-toggle {
        display: none;
    }

    /* Hide bottom navigation on desktop screens by default */
    .bottom-nav-bar {
        display: none !important;
    }
}

@media (max-width: 1024px) {
    .split-pane {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1000px) {

    /* Hide the primary 4 nav links in the sidebar drawer since they live in the bottom bar */
    #link-dashboard,
    #link-clients,
    #link-appointments,
    #link-expenses,
    .sidebar-section-header,
    .sidebar-footer-account {
        display: none !important;
    }

    #app-root {
        flex-direction: column;
        height: 100%;
    }

    .sidebar {
        display: none !important;
    }

    .brand-wrapper {
        margin-bottom: 0;
        padding: 0 !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 8px !important;
        border-bottom: none;
        width: 100%;
    }

    /* Ensure mobile top brand header flows correctly in RTL */
    [dir="rtl"] .brand-wrapper {
        flex-direction: row !important;
        justify-content: flex-start !important;
    }

    .brand-full {
        display: none !important;
    }

    .brand-icon-mobile {
        display: flex !important;
        width: 36px !important;
        height: 36px !important;
        flex-shrink: 0;
    }

    .brand-icon-mobile svg {
        width: 36px;
        height: 36px;
        display: block;
    }

    .brand-practice-title {
        font-size: 0.95rem;
        margin: 0 !important;
        padding: 0 !important;
        border-left: none !important;
        text-align: left !important;
        color: #ffffff;
        font-weight: 600;
        display: block !important;
        width: auto !important;
        flex: 1 1 auto;
        min-width: 0;
    }

    [dir="rtl"] .brand-practice-title {
        text-align: right !important;
    }

    .sidebar-top-row {
        display: none !important;
        /* Hides the entire row that holds the hamburger */
    }

    .mobile-nav-toggle {
        display: none !important;
        /* Completely hides the hamburger button */
    }

    .mobile-nav-toggle svg {
        width: 22px;
        height: 22px;
        stroke: #fff;
    }

    .nav-container {
        display: none;
        flex-direction: column;
        margin-top: 12px;
    }

    .nav-container.nav-open {
        display: flex;
    }

    /* Clean mobile top bar override with Dark Navy seamless theme */
    .top-bar {
        min-height: calc(52px + env(safe-area-inset-top, 0px)) !important;
        max-height: calc(52px + env(safe-area-inset-top, 0px)) !important;
        height: calc(52px + env(safe-area-inset-top, 0px)) !important;
        padding-top: env(safe-area-inset-top, 0px) !important;
        padding-bottom: 0 !important;
        padding-left: max(8px, env(safe-area-inset-left, 0px)) !important;
        padding-right: max(8px, env(safe-area-inset-right, 0px)) !important;
        background-color: #0f172a !important;
        border-bottom: 1px solid #1e293b !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-shrink: 0;
        flex-wrap: nowrap !important;
        gap: 4px !important;
        box-sizing: border-box !important;
    }

    .topbar-mobile-brand {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 22px;
        height: 22px;
        flex-shrink: 0;
        margin-inline-end: 2px;
        border-radius: 5px;
        cursor: pointer;
        transition: transform 0.15s ease;
    }

    .topbar-mobile-brand svg {
        width: 22px;
        height: 22px;
    }

    .topbar-mobile-brand:active {
        transform: scale(0.95);
    }

    #view-title {
        font-size: clamp(0.72rem, 3.2vw, 1.05rem) !important;
        font-weight: 750 !important;
        letter-spacing: -0.02em;
        color: #ffffff !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding-inline-end: 2px !important;
        line-height: 1.25 !important;
    }

    #topbar-subscription-pill {
        margin-inline-end: 4px !important;
        display: flex !important;
        align-items: center !important;
    }

    .topbar-sub-pill {
        display: flex !important;
        align-items: center !important;
        height: 28px !important;
        padding: 0 8px !important;
        font-size: 0.72rem !important;
        border-radius: 14px !important;
        box-sizing: border-box !important;
    }

    .topbar-sub-pill.pro {
        padding: 0 !important;
        width: 28px !important;
        min-width: 28px !important;
        height: 28px !important;
        justify-content: center !important;
        background: rgba(34, 197, 94, 0.16) !important;
        border: 1px solid rgba(74, 222, 128, 0.4) !important;
        color: #4ade80 !important;
    }

    .topbar-sub-pill.pro .topbar-pill-compact {
        display: none !important;
    }

    .topbar-sub-pill.pro .modern-crown-icon {
        width: 14px !important;
        height: 14px !important;
    }

    .topbar-sub-pill.trial {
        background: rgba(99, 102, 241, 0.2) !important;
        border: 1px solid rgba(129, 140, 248, 0.4) !important;
        color: #a5b4fc !important;
    }

    .topbar-sub-pill.read-only {
        background: rgba(239, 68, 68, 0.2) !important;
        border: 1px solid rgba(248, 113, 113, 0.4) !important;
        color: #f87171 !important;
    }

    #top-bar-controls {
        display: flex !important;
        align-items: center !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        gap: 5px !important;
        flex-shrink: 0 !important;
    }

    .topbar-sync-badge {
        background: #1e293b !important;
        border: 1px solid #334155 !important;
        padding: 4px 8px !important;
        border-radius: 14px !important;
        gap: 4px !important;
    }

    .topbar-sync-badge:hover {
        background: #334155 !important;
        border-color: #475569 !important;
    }

    .topbar-actions-group {
        background: #1e293b !important;
        border: 1px solid #334155 !important;
        border-radius: 14px !important;
        padding: 2px !important;
        gap: 2px !important;
    }

    .topbar-action-btn {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        min-height: 28px !important;
        border-radius: 14px !important;
        color: #94a3b8 !important;
    }

    .topbar-action-btn:hover,
    .topbar-action-btn:active {
        background: #334155 !important;
        color: #ffffff !important;
    }

    #global-sync-status-container {
        gap: 4px !important;
    }

    #global-sync-status {
        display: inline-flex !important;
        align-items: center !important;
        font-size: 0.62rem !important;
        line-height: 1 !important;
        max-width: 48px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        max-height: 28px !important;
        color: #94a3b8 !important;
    }

    .sync-text-full {
        display: none !important;
    }

    .sync-text-mobile {
        display: inline !important;
        font-weight: 600 !important;
        font-size: 0.62rem !important;
        line-height: 1 !important;
    }

    .topbar-pill-full {
        display: none !important;
    }

    .topbar-pill-compact {
        display: inline !important;
    }

    .content-box {
        padding: 16px;
        padding-bottom: calc(100px + env(safe-area-inset-bottom));
    }

    .split-pane {
        grid-template-columns: 1fr;
    }

    #whats-new-modal {
        padding-bottom: calc(64px + env(safe-area-inset-bottom) + 16px) !important;
        box-sizing: border-box;
    }

    #whats-new-modal .custom-modal-card {
        max-height: calc(100vh - 64px - env(safe-area-inset-bottom) - 32px) !important;
    }

    /* ======================================================== */
    /* BOTTOM NAVIGATION BAR STYLES (MOBILE FLOATING CAPSULE)   */
    /* ======================================================== */
    .bottom-nav-bar {
        display: flex !important;
        position: fixed !important;
        bottom: max(16px, env(safe-area-inset-bottom)) !important;
        left: 16px !important;
        right: 16px !important;
        width: auto !important;
        max-width: 440px !important;
        margin: 0 auto !important;
        min-height: 64px !important;
        height: 64px !important;
        background: rgba(15, 23, 42, 0.94) !important;
        backdrop-filter: blur(16px) saturate(180%) !important;
        -webkit-backdrop-filter: blur(16px) saturate(180%) !important;
        color: var(--sidebar-text, #94a3b8) !important;
        z-index: 10000 !important;
        flex-direction: row !important;
        justify-content: space-around !important;
        align-items: center !important;
        padding: 0 8px !important;
        border-radius: 32px !important;
        border: 1px solid rgba(255, 255, 255, 0.12) !important;
        box-shadow: 0 12px 36px -4px rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.25) !important;
        box-sizing: border-box !important;
        transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.2s ease !important;
    }

    .bottom-nav-bar.keyboard-open {
        transform: translateY(200%) !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    .bottom-nav-item {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 4px 2px !important;
        gap: 2px !important;
        min-height: 48px !important;
        flex: 1 1 0% !important;
        min-width: 0 !important;
        cursor: pointer !important;
        -webkit-tap-highlight-color: transparent;
        color: #94a3b8;
        transition: color 0.15s ease, transform 0.15s ease;
    }

    .bottom-nav-item .icon-box {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 24px;
        height: 24px;
        margin: 0;
        flex-shrink: 0;
    }

    .bottom-nav-item svg {
        stroke: currentColor;
        transition: stroke 0.15s, transform 0.15s;
    }

    .bottom-nav-item span {
        font-size: 0.65rem !important;
        font-weight: 600 !important;
        letter-spacing: 0.2px;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.15;
        max-width: 100%;
    }

    .bottom-nav-item.active {
        color: #38bdf8 !important;
    }

    .bottom-nav-item.active .icon-box {
        transform: scale(1.1);
    }

    /* Elevated Amber Center Action Button */
    .bottom-nav-hero-slot {
        flex: 1 1 0%;
        display: flex;
        justify-content: center;
        align-items: center;
        position: relative;
        min-width: 52px;
    }

    .bottom-nav-hero-btn {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
        border: 3px solid rgba(15, 23, 42, 0.94);
        color: #ffffff;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 16px rgba(245, 158, 11, 0.45);
        cursor: pointer;
        transform: translateY(-8px);
        transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, background-color 0.2s ease;
        padding: 0;
        margin: 0;
        -webkit-tap-highlight-color: transparent;
        outline: none;
    }

    .bottom-nav-hero-btn:hover,
    .bottom-nav-hero-btn:active {
        transform: translateY(-10px) scale(1.06);
        box-shadow: 0 6px 20px rgba(245, 158, 11, 0.6);
    }

    .bottom-nav-hero-btn.open {
        background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
        box-shadow: 0 4px 16px rgba(239, 68, 68, 0.45);
    }

    .bottom-nav-hero-btn.open .hero-btn-icon {
        transform: rotate(45deg);
    }

    .hero-btn-icon {
        transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .quick-action-tile:hover,
    .quick-action-tile:active {
        transform: translateY(-2px);
    }
}

/* Ensures sync status text aligns to the right next to the cloud icon in RTL mode */
[dir="rtl"] #global-sync-status {
    text-align: right !important;
}

/* ======================================================== */
/* 5. GRID LAYOUTS, SPLIT PANES & RESPONSIVE METRICS        */
/* ======================================================== */
.split-pane {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: stretch !important;
    gap: 24px !important;
}

.split-col {
    flex: 1 1 calc(50% - 12px) !important;
    min-width: 250px !important;
    display: flex !important;
    flex-direction: column !important;
}

.panel-stretch {
    flex-grow: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    margin-bottom: 0 !important;
}

.panel-stretch[style*="display: none"] {
    display: none !important;
}

.scroll-area {
    flex: 1 1 0% !important;
    overflow-y: auto !important;
    min-height: 0 !important;
}

.calendar-grid-layout {
    display: grid !important;
    grid-template-columns: 1.25fr 1fr !important;
    gap: 24px !important;
    align-items: start !important;
    height: auto !important;
}

.cg-calendar-panel {
    display: flex;
    flex-direction: column;
}

.cg-side-col {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.cg-agenda-panel {
    display: flex;
    flex-direction: column;
}

.cg-upcoming-panel {
    display: flex;
    flex-direction: column;
}

@media (max-width: 1000px) {
    .calendar-grid-layout {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
        height: auto !important;
    }

    #payment-method-breakdown {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 12px !important;
        width: 100% !important;
    }

    #payment-method-breakdown .metric-card {
        flex: 1 1 calc(50% - 12px) !important;
        min-width: 120px !important;
        margin-bottom: 0 !important;
    }

    .dash-client-wrapper {
        display: flex !important;
        justify-content: flex-end !important;
        align-items: center !important;
        width: 100% !important;
        gap: 12px !important;
    }

    .mobile-only-toggle {
        display: inline-flex !important;
    }

    .mobile-only-date {
        display: block !important;
    }

    .dash-mobile-hidden {
        display: none !important;
    }

    .mobile-expanded .dash-mobile-hidden {
        display: flex !important;
    }

    tr.mobile-expanded {
        background-color: #f8fafc !important;
    }

    #mobile-profile-collapsible.expanded,
    #mobile-config-collapsible.expanded {
        display: flex !important;
        flex-direction: column !important;
    }

    .split-col {
        flex: 1 1 100% !important;
        min-width: 100% !important;
        width: 100% !important;
    }
}

@media (min-width: 1001px) {
    .dash-client-wrapper {
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
    }

    .sticky-desktop {
        position: sticky;
        top: 24px;
    }

    .mobile-only-toggle,
    .mobile-only-date {
        display: none !important;
    }

    #mobile-profile-collapsible,
    #mobile-config-collapsible {
        display: flex !important;
        flex-direction: column !important;
        flex-grow: 1 !important;
    }
}

.dashboard-metrics-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    grid-template-rows: repeat(3, minmax(0, 1fr)) !important;
    gap: 16px !important;
    flex-grow: 1 !important;
}

.dashboard-metrics-grid .metric-card {
    margin-bottom: 0 !important;
    width: auto !important;
    height: 100% !important;
    box-sizing: border-box !important;
}

.dashboard-metrics-grid .metric-card:nth-child(5) {
    grid-column: 1 / -1 !important;
}

@media (max-width: 600px) {
    .dashboard-metrics-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        grid-template-rows: auto auto auto !important;
        gap: 12px !important;
    }

    .dashboard-metrics-grid .metric-card:nth-child(5) {
        grid-column: 1 / -1 !important;
    }
}

@media (max-width: 440px) {
    .dashboard-metrics-grid {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto !important;
        gap: 10px !important;
    }

    .dashboard-metrics-grid .metric-card:nth-child(5) {
        grid-column: auto !important;
    }
}

/* ======================================================== */
/* UNIFIED SINGLE-VIEW DASHBOARD & METRICS STYLES           */
/* ======================================================== */
/* DASHBOARD ACTION BANNERS, CONTROLS & UNIFIED METRICS     */
/* ======================================================== */
.dash-action-banners-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)) !important;
    gap: 16px !important;
    margin-bottom: 24px !important;
}

.dash-past-due-card,
#dash-past-due-apt-container {
    background: #fff1f2 !important;
    border: 1px solid #fecdd3 !important;
    border-left: 5px solid #e11d48 !important;
    border-radius: 14px !important;
    padding: 16px 20px !important;
    box-shadow: 0 2px 8px rgba(225, 29, 72, 0.05) !important;
    margin-bottom: 0 !important;
}

#dash-past-due-apt-container h4 {
    color: #9f1239 !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.06em !important;
    margin-bottom: 6px !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    text-transform: uppercase !important;
}

#dash-past-due-apt-details {
    color: #881337 !important;
    font-size: 1.05rem !important;
    font-weight: 700 !important;
}

#dash-past-due-btn {
    background: #e11d48 !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    padding: 8px 16px !important;
    box-shadow: 0 2px 6px rgba(225, 29, 72, 0.25) !important;
    transition: transform 0.15s ease, background 0.15s ease !important;
}

#dash-past-due-btn:hover {
    background: #be123c !important;
    transform: translateY(-1px) !important;
}

#dash-next-apt-container {
    background: #f0f9ff !important;
    border: 1px solid #bae6fd !important;
    border-left: 5px solid #0284c7 !important;
    border-radius: 14px !important;
    padding: 16px 20px !important;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.05) !important;
    margin-bottom: 0 !important;
}

#dash-next-apt-container h4 {
    color: #0369a1 !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.06em !important;
    margin-bottom: 6px !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    text-transform: uppercase !important;
}

#dash-next-apt-details {
    color: #0c4a6e !important;
    font-size: 1.05rem !important;
    font-weight: 700 !important;
}

#dash-next-remind-btn {
    background: #ffffff !important;
    color: #0284c7 !important;
    border: 1px solid #bae6fd !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    padding: 8px 14px !important;
    transition: background 0.15s ease !important;
}

#dash-next-remind-btn:hover {
    background: #e0f2fe !important;
}

#dash-next-apt-container button[data-i18n="btn_go_calendar"] {
    background: #0284c7 !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    padding: 8px 16px !important;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25) !important;
    transition: transform 0.15s ease, background 0.15s ease !important;
}

#dash-next-apt-container button[data-i18n="btn_go_calendar"]:hover {
    background: #0369a1 !important;
    transform: translateY(-1px) !important;
}

/* Controls Header & Segmented Pill Toggle */
.dash-controls-header {
    background: #ffffff !important;
    padding: 14px 18px !important;
    border-radius: 14px !important;
    border: 1px solid var(--border) !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.02) !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.dash-title-period-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex: 1 1 auto;
    flex-wrap: nowrap;
}

#dash-active-view-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
    white-space: nowrap;
}

.dash-period-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: nowrap;
}

#dash-month-val {
    width: 135px;
    height: 38px;
    padding: 4px 8px;
    margin-bottom: 0;
}

#dash-month-year-val {
    width: 95px;
    height: 38px;
    padding: 4px 8px;
    margin-bottom: 0;
}

.dash-tax-year-label {
    display: inline-flex !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    color: var(--text-muted) !important;
    white-space: nowrap !important;
    line-height: 1 !important;
    height: 38px !important;
}

#dash-year-select {
    height: 38px;
    margin-bottom: 0;
}

/* Side-by-Side Dashboard Revenue Graph & Recent Sessions Grid */
.dash-charts-sessions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

@media (min-width: 1024px) {
    .dash-charts-sessions-grid {
        grid-template-columns: 1.05fr 0.95fr;
        align-items: stretch;
    }

    .dash-charts-sessions-grid > .panel {
        margin-bottom: 0 !important;
        display: flex;
        flex-direction: column;
    }

    .dash-charts-sessions-grid .dash-chart-panel {
        justify-content: flex-start;
    }

    .dash-charts-sessions-grid .dash-sessions-panel {
        justify-content: flex-start;
    }

    .dash-charts-sessions-grid .dash-table-wrapper {
        flex: 1;
        max-height: 340px !important;
        overflow-y: auto;
    }
}

.dash-view-toggle-group {
    background: #f1f5f9 !important;
    padding: 3px !important;
    border-radius: 10px !important;
    border: 1px solid #e2e8f0 !important;
}

.dash-view-toggle-btn {
    border-radius: 8px !important;
    padding: 6px 14px !important;
    font-size: 0.88rem !important;
    font-weight: 600 !important;
    border: none !important;
    color: #64748b !important;
    background: transparent !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
}

.dash-view-toggle-btn.active {
    background: #ffffff !important;
    color: #0f172a !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08) !important;
}

/* Unified Metrics Grid & KPI Cards */
.dashboard-metrics-grid-unified {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 16px !important;
}

.dashboard-metrics-grid-unified .metric-card {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 16px !important;
    padding: 22px 20px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03) !important;
    margin-bottom: 0 !important;
    width: auto !important;
    box-sizing: border-box !important;
    position: relative !important;
    overflow: hidden !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

.dashboard-metrics-grid-unified .metric-card:hover {
    transform: translateY(-3px) !important;
    box-shadow: 0 8px 20px -2px rgba(0,0,0,0.06) !important;
}

.dashboard-metrics-grid-unified .metric-card h4 {
    font-size: 0.72rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.06em !important;
    text-transform: uppercase !important;
    color: #64748b !important;
    margin-bottom: 8px !important;
    display: block !important;
    padding-inline-end: 28px !important;
    line-height: 1.35 !important;
}

.dashboard-metrics-grid-unified .metric-card p {
    font-size: 1.85rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.02em !important;
    margin: 0 !important;
}

/* Executive, Purposeful KPI Colors */
#dash-total-gross, #dash-monthly-gross {
    color: #0f172a !important; /* Grounded high-contrast slate */
}
#dash-total-overhead, #dash-monthly-overhead {
    color: #334155 !important; /* Calm charcoal slate */
}
#dash-total-net, #dash-monthly-net {
    color: #059669 !important; /* Elegant Emerald */
}
#dash-total-tax, #dash-monthly-tax {
    color: #d97706 !important; /* Warm Amber reserve */
}
#dash-yearly-sessions, #dash-monthly-sessions {
    color: #0f172a !important; /* Crisp high-contrast */
}
#dash-total-outstanding, #dash-monthly-arrears {
    color: #e11d48 !important; /* Alert rose for unpaid */
}

/* Unpaid Arrears Badge */
.arrears-unpaid-badge {
    background: #ffe4e6 !important;
    color: #be123c !important;
    border: 1px solid #fecdd3 !important;
    font-weight: 700 !important;
    border-radius: 9999px !important;
    padding: 3px 9px !important;
    font-size: 0.72rem !important;
}

.kpi-corner-icon {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 1rem !important;
    opacity: 0.75 !important;
    font-weight: normal !important;
    line-height: 1 !important;
    pointer-events: none;
}

[dir="rtl"] .kpi-corner-icon {
    right: auto;
    left: 20px;
}

[dir="rtl"] .dash-past-due-card,
[dir="rtl"] #dash-past-due-apt-container {
    border-left: 1px solid #fecdd3 !important;
    border-right: 5px solid #e11d48 !important;
}

[dir="rtl"] #dash-next-apt-container {
    border-left: 1px solid #bae6fd !important;
    border-right: 5px solid #0284c7 !important;
}

@media (max-width: 900px) {
    .dashboard-metrics-grid-unified {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 14px !important;
    }
}

@media (max-width: 768px) {
    .dash-action-banners-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    #dash-next-apt-container,
    .dash-past-due-card {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 14px 16px !important;
        gap: 12px !important;
    }

    #dash-past-due-btn,
    #dash-next-remind-btn,
    #dash-next-apt-container button[data-i18n="btn_go_calendar"] {
        width: 100% !important;
        min-height: 40px !important;
        justify-content: center !important;
        font-size: 0.9rem !important;
    }
}

@media (max-width: 600px) {
    .dash-controls-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding: 12px 14px !important;
    }

    .dash-view-toggle-group {
        display: flex !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .dash-view-toggle-btn {
        flex: 1 1 50% !important;
        justify-content: center !important;
        min-height: 40px !important;
        font-size: 0.9rem !important;
        padding: 6px 12px !important;
    }

    .dash-title-period-bar {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        gap: 8px !important;
        flex-wrap: nowrap !important;
    }

    #dash-active-view-title {
        font-size: clamp(0.78rem, 3.2vw, 0.95rem) !important;
        font-weight: 700 !important;
        white-space: nowrap !important;
        margin: 0 !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        letter-spacing: -0.01em !important;
    }

    .dash-period-row {
        flex: 0 0 auto !important;
        width: auto !important;
        gap: 5px !important;
        flex-wrap: nowrap !important;
        justify-content: flex-end !important;
    }

    #dash-month-val {
        width: clamp(88px, 24vw, 110px) !important;
        height: 34px !important;
        padding: 2px 4px !important;
        font-size: 0.8rem !important;
    }

    #dash-month-year-val {
        width: clamp(62px, 17vw, 76px) !important;
        height: 34px !important;
        padding: 2px 4px !important;
        font-size: 0.8rem !important;
    }

    #dash-year-select {
        width: auto !important;
        height: 34px !important;
        padding: 2px 8px !important;
        font-size: 0.82rem !important;
        margin-bottom: 0 !important;
    }

    .dash-tax-year-label {
        height: 34px !important;
        font-size: 0.8rem !important;
        margin: 0 !important;
        padding: 0 !important;
        line-height: 1 !important;
        display: inline-flex !important;
        align-items: center !important;
    }

    .dashboard-metrics-grid-unified {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .dashboard-metrics-grid-unified .metric-card {
        padding: 14px 12px !important;
    }

    .dashboard-metrics-grid-unified .metric-card h4 {
        font-size: 0.72rem !important;
        padding-inline-end: 22px !important;
    }

    .kpi-corner-icon {
        top: 14px !important;
        right: 12px !important;
        font-size: 0.95rem !important;
    }

    [dir="rtl"] .kpi-corner-icon {
        right: auto !important;
        left: 12px !important;
    }

    .dashboard-metrics-grid-unified .metric-card p {
        font-size: 1.25rem !important;
    }

    .dash-past-due-details,
    #dash-next-apt-details {
        word-break: break-word !important;
    }

    .dash-arrears-filter-banner {
        width: 100% !important;
        justify-content: space-between !important;
        box-sizing: border-box !important;
        margin-top: 8px !important;
        padding: 6px 12px !important;
        border-radius: 8px !important;
    }
}

.dash-arrears-filter-banner[style*="display: none"] {
    display: none !important;
}

.dash-view-toggle-group {
    display: inline-flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 10px;
    border: 1px solid var(--border);
    gap: 4px;
}

.dash-view-toggle-btn {
    border: none;
    background: transparent;
    padding: 7px 18px;
    border-radius: 7px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.dash-view-toggle-btn:hover {
    color: var(--text-main);
}

.dash-view-toggle-btn.active {
    background: #ffffff;
    color: var(--accent);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    font-weight: 700;
}

.metric-card-interactive {
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.metric-card-interactive:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.12);
    border-color: #fca5a5 !important;
}

.metric-card-interactive.filter-active {
    border-color: #dc2626 !important;
    background: #fff5f5 !important;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2) !important;
}

.dash-past-due-card {
    margin-bottom: 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.dash-arrears-filter-banner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fee2e2;
    border: 1px solid #fecaca;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #991b1b;
    font-weight: 600;
    text-align: start;
    box-sizing: border-box;
}

.arrears-unpaid-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 9999px;
    background: #fee2e2;
    color: #dc2626;
    font-weight: 700;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    line-height: 1.2;
}

html[dir="rtl"] .dash-arrears-filter-banner {
    text-align: start;
}

/* ======================================================== */
/* CLIENT DIRECTORY EXECUTIVE POLISH                        */
/* ======================================================== */
#view-clients .panel {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 18px !important;
    padding: 0 28px 24px 28px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03) !important;
    position: relative;
}

/* Sticky Header Bar for Client Directory */
.clients-sticky-header {
    position: sticky;
    top: -32px;
    z-index: 25;
    background: #ffffff;
    margin: 0 -28px 18px -28px;
    padding: 24px 28px 16px 28px;
    border-bottom: 1px solid #e2e8f0;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
}

/* Apple-style segmented tabs */
#directory-tab-container {
    display: inline-flex !important;
    background: #f1f5f9 !important;
    padding: 4px !important;
    border-radius: 12px !important;
    border: 1px solid #e2e8f0 !important;
    gap: 4px !important;
    margin-bottom: 0 !important;
}

#directory-tab-container .tab {
    border: none !important;
    background: transparent !important;
    padding: 7px 18px !important;
    border-radius: 8px !important;
    font-size: 0.88rem !important;
    font-weight: 600 !important;
    color: #64748b !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    transition: all 0.2s ease !important;
    box-shadow: none !important;
}

#directory-tab-container .tab:hover {
    color: #0f172a !important;
}

#directory-tab-container .tab.active {
    background: #ffffff !important;
    color: #0f172a !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08) !important;
    font-weight: 700 !important;
}

.tab-count-badge {
    background: #e2e8f0;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 9999px;
    margin-inline-start: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

#directory-tab-container .tab.active .tab-count-badge {
    background: #eff6ff;
    color: #2563eb;
}

/* Polished Table (Desktop & Tablet) */
.dir-table-wrapper {
    overflow: visible;
}

#dir-data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: visible;
}

#dir-data-table thead {
    background: #f8fafc !important;
}

#dir-data-table th {
    color: #64748b !important;
    font-size: 0.75rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.06em !important;
    font-weight: 700 !important;
    padding: 14px 18px !important;
    border-bottom: 1px solid #e2e8f0 !important;
    background: #f8fafc !important;
}

@media (min-width: 769px) {
    .dir-table-wrapper {
        overflow: visible !important;
    }
    #dir-data-table {
        overflow: visible !important;
    }
    #dir-data-table thead th {
        position: sticky !important;
        top: var(--clients-sticky-th-top, 112px) !important;
        z-index: 20 !important;
        background: #f8fafc !important;
        border-top: 1px solid #e2e8f0 !important;
        border-bottom: 2px solid #e2e8f0 !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04) !important;
    }
    #dir-data-table thead th:first-child {
        border-start-start-radius: 13px !important;
    }
    #dir-data-table thead th:last-child {
        border-start-end-radius: 13px !important;
    }
    #dir-data-table tr:last-child td:first-child {
        border-end-start-radius: 13px !important;
    }
    #dir-data-table tr:last-child td:last-child {
        border-end-end-radius: 13px !important;
    }
}

@media (max-width: 768px) {
    .dir-table-wrapper {
        overflow-x: auto !important;
    }
}

#dir-data-table td {
    padding: 16px 18px !important;
    border-bottom: 1px solid #f1f5f9 !important;
    vertical-align: middle !important;
    font-size: 0.92rem !important;
    color: #334155 !important;
}

#dir-data-table tr:last-child td {
    border-bottom: none !important;
}

#dir-data-table tr.clickable:hover {
    background: #f8fafc !important;
}

/* Avatar Badge */
.client-avatar-chip {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.82rem;
    letter-spacing: -0.02em;
    flex-shrink: 0;
    user-select: none;
}

/* Modern Status Pills */
.status-pill-active {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ecfdf5 !important;
    color: #047857 !important;
    border: 1px solid #a7f3d0 !important;
    padding: 4px 10px !important;
    border-radius: 9999px !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.04em !important;
    text-transform: uppercase !important;
}
.status-pill-active::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
}

.status-pill-closed {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f1f5f9 !important;
    color: #64748b !important;
    border: 1px solid #cbd5e1 !important;
    padding: 4px 10px !important;
    border-radius: 9999px !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    letter-spacing: 0.04em !important;
    text-transform: uppercase !important;
}
.status-pill-closed::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
}

/* Arrears Badge Pill */
.arrears-badge-pill {
    background: #ffe4e6 !important;
    color: #be123c !important;
    border: 1px solid #fecdd3 !important;
    font-weight: 700 !important;
    border-radius: 9999px !important;
    padding: 3px 10px !important;
    font-size: 0.78rem !important;
    display: inline-block !important;
    white-space: nowrap !important;
    line-height: 1.2 !important;
}

.mobile-only-arrears {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

/* Modern accordion chevron */
.mobile-modern-arrow {
    width: 28px !important;
    height: 28px !important;
    min-height: 28px !important;
    border-radius: 50% !important;
    background: #f1f5f9 !important;
    border: 1px solid #e2e8f0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #64748b !important;
    font-size: 0.72rem !important;
    padding: 0 !important;
    transition: all 0.2s ease !important;
}

tr.dir-row.mobile-expanded .mobile-modern-arrow {
    background: #eff6ff !important;
    color: #2563eb !important;
    border-color: #bfdbfe !important;
}

@media (min-width: 769px) {
    .mobile-only-toggle,
    .mobile-only-arrears,
    .mobile-modern-arrow {
        display: none !important;
    }
}

@media (max-width: 768px) {
    #view-clients .panel {
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        box-shadow: none !important;
    }

    .clients-sticky-header {
        top: -16px !important;
        margin: -16px -16px 14px -16px !important;
        padding: 12px 14px 8px 14px !important;
        border-radius: 0 !important;
        border-bottom: 1px solid #e2e8f0 !important;
        box-shadow: 0 4px 14px -2px rgba(0, 0, 0, 0.06) !important;
    }

    #directory-tab-container {
        display: flex !important;
        width: 100% !important;
        box-sizing: border-box !important;
        margin-bottom: 2px !important;
        padding: 3px !important;
        gap: 2px !important;
    }

    #directory-tab-container .tab {
        flex: 1 1 33.33% !important;
        justify-content: center !important;
        padding: 6px 2px !important;
        font-size: 0.78rem !important;
    }

    /* Mobile Client Card Surfaces */
    tr.dir-row {
        margin-bottom: 12px !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 14px !important;
        background: #ffffff !important;
        padding: 0 !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03) !important;
        overflow: hidden !important;
        transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
    }

    tr.dir-row:hover {
        border-color: #cbd5e1 !important;
    }

    tr.dir-row td.dir-name-cell {
        padding: 14px 16px !important;
        background: #ffffff !important;
    }
}