:root {
    --brand-50: 255 245 245;
    --brand-100: 253 225 225;
    --brand-400: 229 80 80;
    --brand-500: 187 18 38;
    --brand-600: 153 14 30;
    --brand-800: 89 6 15;
    --brand-900: 52 3 9;

    --primary-red: #b11226;
    --primary-red-dark: #7a0b16;
    --surface-white: #ffffff;
    --surface-wash: #f6f6f6;
    --surface-gray: #e1e1e1;
    --ink: #050505;
    --charcoal: #1a1a1a;
    --graphite: #2f3033;
    --steel: #4d515a;
    --muted-gray: #8a8d95;

    --nav-sidebar-width: 16rem; /* matches md:w-64 on #sidebar */
    --header-height: 4rem;      /* matches h-16 on header */
    --search-bar-height: 62px;  /* height of .global-search-fixed bar */
}

/* Sidebar logo: fixed red — never inherits tenant theme brand colors */
#sidebar a .naiosh-brand-accent,
#sidebar a:link .naiosh-brand-accent,
#sidebar a:visited .naiosh-brand-accent,
#sidebar a:hover .naiosh-brand-accent,
#sidebar a:active .naiosh-brand-accent {
    color: #e55050 !important;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 4px;
}

/* Branches watermark scrollbar - more visible */
#branches-watermark::-webkit-scrollbar {
    width: 8px;
}

#branches-watermark::-webkit-scrollbar-track {
    background: rgba(241, 245, 249, 0.5);
    border-radius: 4px;
}

#branches-watermark::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.6);
    border-radius: 4px;
}

#branches-watermark::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.8);
}

/* Tenant selector modal scrollbar */
#tenant-selector .overflow-y-auto::-webkit-scrollbar {
    width: 10px;
}

#tenant-selector .overflow-y-auto::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

#tenant-selector .overflow-y-auto::-webkit-scrollbar-thumb {
    background: var(--primary-red);
    border-radius: 4px;
}

#tenant-selector .overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background: var(--primary-red-dark);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleUp {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes pulseSlow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.9; transform: scale(1.02); }
}

.animate-pulse-slow {
    animation: pulseSlow 3s infinite;
}

.fade-in {
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-slide-in {
    animation: slideIn 0.3s ease-out forwards;
}

.animate-scale-up {
    animation: scaleUp 0.3s ease-out forwards;
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

/* ── HQ Dashboard Luxe (المكتب الرئيسي) ── */
@keyframes hqSlideUp {
    from { opacity: 0; transform: translateY(32px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes hqPulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.55; }
}

@keyframes hqShine {
    0% { transform: translateX(-120%) rotate(25deg); }
    100% { transform: translateX(220%) rotate(25deg); }
}

@keyframes hqOrbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(12px, -18px) scale(1.05); }
    66% { transform: translate(-8px, 10px) scale(0.95); }
}

@keyframes hqGoldPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

@keyframes hqBorderGlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.hq-dashboard {
    animation: fadeIn 0.6s ease-out forwards;
    position: relative;
}

.hq-hero-shell {
    position: relative;
    z-index: 1;
}

.hq-dashboard > * {
    position: relative;
    z-index: 1;
}

.credit-balance-widget,
#credit-balance-widget {
    position: relative;
    z-index: 100;
    pointer-events: auto;
    isolation: isolate;
}

#credit-topup-btn,
a.credit-topup-btn,
.credit-topup-btn {
    position: relative;
    z-index: 101;
    pointer-events: auto !important;
    cursor: pointer !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(185, 28, 28, 0.25);
    min-height: 44px;
    min-width: 44px;
    text-decoration: none !important;
    display: inline-flex !important;
    visibility: visible !important;
}

.hq-hero {
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(145deg, #1a0505 0%, #450a0a 22%, #7f1d1d 48%, #991b1b 72%, #2d0a0a 100%);
    border-radius: 1.75rem;
    padding: 2rem 2.25rem;
    color: #fff;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.08),
        0 25px 60px -12px rgba(69, 10, 10, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.15);
}

.hq-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 70% 80% at 100% 0%, rgba(251, 191, 36, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse 50% 60% at 0% 100%, rgba(255, 255, 255, 0.06) 0%, transparent 45%);
    pointer-events: none;
}

.hq-hero::after {
    content: '';
    position: absolute;
    top: -60%;
    right: -25%;
    width: 70%;
    height: 220%;
    background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.07) 50%, transparent 60%);
    animation: hqShine 7s ease-in-out infinite;
    pointer-events: none;
}

.hq-hero-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(40px);
    pointer-events: none;
    animation: hqOrbFloat 8s ease-in-out infinite;
}

.hq-hero-orb-1 {
    width: 180px;
    height: 180px;
    top: -40px;
    left: 10%;
    background: rgba(251, 191, 36, 0.18);
    animation-delay: 0s;
}

.hq-hero-orb-2 {
    width: 140px;
    height: 140px;
    bottom: -30px;
    right: 25%;
    background: rgba(239, 68, 68, 0.2);
    animation-delay: -3s;
}

.hq-hero-orb-3 {
    width: 100px;
    height: 100px;
    top: 40%;
    right: 5%;
    background: rgba(255, 255, 255, 0.08);
    animation-delay: -5s;
}

.hq-hero-logo {
    width: 72px;
    height: 72px;
    object-fit: contain;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.35));
    animation: hqOrbFloat 6s ease-in-out infinite;
}

.hq-gold-bar {
    height: 3px;
    width: 48px;
    border-radius: 999px;
    background: linear-gradient(90deg, #fbbf24, #f59e0b, #d97706);
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.5);
    animation: hqGoldPulse 3s ease-in-out infinite;
}

.hq-stat-glass {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 1.25rem;
    padding: 1.1rem 1.35rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 8px 32px rgba(0, 0, 0, 0.15);
    transition: transform 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}

.hq-stat-glass:hover {
    transform: translateY(-3px);
    border-color: rgba(251, 191, 36, 0.35);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 16px 40px rgba(0, 0, 0, 0.2);
}

.hq-kpi-card {
    opacity: 0;
    animation: hqSlideUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    background: linear-gradient(165deg, #ffffff 0%, #fafafa 100%);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 1.25rem;
    padding: 1.35rem 1.5rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px -4px rgba(15, 23, 42, 0.08), 0 1px 0 rgba(255, 255, 255, 0.8) inset;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease;
}

.hq-kpi-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.04) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
}

.hq-kpi-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 48px -12px rgba(127, 29, 29, 0.15), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

.hq-kpi-card:hover::after {
    opacity: 1;
}

.hq-kpi-card:nth-child(1) { animation-delay: 0.1s; }
.hq-kpi-card:nth-child(2) { animation-delay: 0.18s; }
.hq-kpi-card:nth-child(3) { animation-delay: 0.26s; }
.hq-kpi-card:nth-child(4) { animation-delay: 0.34s; }

.hq-kpi-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    box-shadow: 0 8px 20px -4px rgba(0, 0, 0, 0.25);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hq-kpi-card:hover .hq-kpi-icon {
    transform: scale(1.12) rotate(-6deg);
}

.hq-panel {
    opacity: 0;
    animation: hqSlideUp 0.75s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.38s;
}

.hq-panel-luxe {
    background: #fff;
    border-radius: 1.5rem;
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 4px 24px -6px rgba(15, 23, 42, 0.07), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
    overflow: hidden;
}

.hq-panel-luxe-header {
    padding: 1.15rem 1.5rem;
    border-bottom: 1px solid rgba(241, 245, 249, 0.9);
    background: linear-gradient(to left, rgba(254, 242, 242, 0.5), #fff 40%);
}

.hq-panel-delay-2 { animation-delay: 0.48s; }
.hq-panel-delay-3 { animation-delay: 0.58s; }

.hq-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 4px rgba(74, 222, 128, 0.3), 0 0 12px rgba(74, 222, 128, 0.5);
    animation: hqPulseDot 2.2s ease-in-out infinite;
}

.hq-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    background: rgba(74, 222, 128, 0.12);
    border: 1px solid rgba(74, 222, 128, 0.25);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #86efac;
}

.hq-module-card {
    position: relative;
    overflow: hidden;
    border-radius: 1.25rem;
    padding: 1.35rem;
    text-align: right;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.3);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease;
}

.hq-module-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, transparent 45%);
    opacity: 0;
    transition: opacity 0.35s ease;
}

.hq-module-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 100% 0%, rgba(251, 191, 36, 0.25) 0%, transparent 70%);
    pointer-events: none;
}

.hq-module-card:hover {
    transform: translateY(-8px) scale(1.03);
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.35);
}

.hq-module-card:hover::before {
    opacity: 1;
}

.hq-module-arrow {
    opacity: 0;
    transform: translateX(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.hq-module-card:hover .hq-module-arrow {
    opacity: 1;
    transform: translateX(0);
}

.hq-quick-link {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid transparent;
    border-radius: 1rem;
}

.hq-quick-link:hover {
    transform: translateX(-6px);
    background: linear-gradient(to left, rgba(127, 29, 29, 0.04), transparent);
    border-color: rgba(127, 29, 29, 0.08);
    box-shadow: 0 4px 16px -4px rgba(127, 29, 29, 0.1);
}

.hq-summary-luxe {
    background: linear-gradient(155deg, #0f0f0f 0%, #1a1a1a 40%, #2d0a0a 100%);
    border-radius: 1.5rem;
    padding: 1.5rem;
    color: #fff;
    border: 1px solid rgba(251, 191, 36, 0.12);
    box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    position: relative;
    overflow: hidden;
}

.hq-summary-luxe::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 80%;
    height: 100%;
    background: radial-gradient(circle, rgba(185, 28, 28, 0.2) 0%, transparent 60%);
    pointer-events: none;
}

.hq-metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

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

.hq-metric-val {
    font-weight: 800;
    font-size: 1.05rem;
    background: linear-gradient(135deg, #fff, #fca5a5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hq-chart-wrap {
    position: relative;
    min-height: 300px;
    padding: 0.5rem;
}

.hq-chart-wrap::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to top, #fff, transparent);
    pointer-events: none;
}

.hq-ad-card {
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.35s ease, border-color 0.35s ease;
    border-radius: 1rem;
}

.hq-ad-card:hover {
    transform: translateX(-8px);
    box-shadow: 0 16px 32px -8px rgba(127, 29, 29, 0.12);
    border-color: rgba(185, 28, 28, 0.25);
}

.hq-section-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    background: linear-gradient(135deg, rgba(185, 28, 28, 0.08), rgba(251, 191, 36, 0.08));
    color: #b91c1c;
    border: 1px solid rgba(185, 28, 28, 0.12);
}

.hq-modules-wrap {
    background: linear-gradient(165deg, #fff 0%, #fefefe 50%, #fafafa 100%);
    border-radius: 1.75rem;
    border: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 8px 40px -12px rgba(15, 23, 42, 0.1);
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.hq-modules-wrap::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #b91c1c, #f59e0b, #b91c1c);
    background-size: 200% 100%;
    animation: hqBorderGlow 4s ease infinite;
}

.group-item:hover i {
    transform: scale(1.2);
    transition: transform 0.2s;
}

#ad-modal, #ad-wizard-modal, #invoice-modal, #pay-modal {
    transition: opacity 0.3s ease;
}

#app-container {
    background-image: radial-gradient(circle at 10% 20%, rgb(248, 250, 252) 0%, rgb(241, 245, 249) 90%);
}

@media (max-width: 768px) {
    .custom-scrollbar::-webkit-scrollbar {
        width: 0px;
        background: transparent;
    }
}

.backdrop-blur-md {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Tooltip styling */
.tooltip {
    position: relative;
}
.tooltip:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--charcoal);
    color: var(--surface-white);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
    z-index: 50;
    margin-bottom: 5px;
}

.help-guide-container {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 120;
    pointer-events: none;
}

.help-guide-button {
    pointer-events: auto;
    position: fixed;
    top: 64px;
    left: 20px;
    padding: 6px 10px;
    min-width: 92px;
    border-radius: 12px;
    border: 2px solid #dc2626;
    background: #ffffff;
    color: #b91c1c;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 11px;
    letter-spacing: 0.2px;
    text-align: center;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.help-guide-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.18);
    border-color: #b91c1c;
}

.help-guide-button:active {
    transform: translateY(0);
}

.help-guide-button::after {
    content: none;
}

.help-guide-backdrop {
    pointer-events: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.32);
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 110;
    border: none;
}

.help-guide-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

.help-guide-panel {
    pointer-events: none;
    visibility: hidden;
    position: fixed;
    top: 128px;
    left: 16px;
    width: min(320px, calc(100vw - 32px));
    max-height: calc(100vh - 160px);
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 24px 48px rgba(15, 23, 42, 0.2);
    border: 1px solid rgba(226, 232, 240, 0.8);
    overflow: hidden;
    transform: translateX(-12px) scale(0.98);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 130;
}

.help-guide-panel.is-open {
    pointer-events: auto;
    visibility: visible;
    opacity: 1;
    transform: translateX(0) scale(1);
}

.help-guide-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(120deg, #fee2e2, #fff7ed);
    color: #7f1d1d;
}

.help-guide-header h3 {
    font-size: 14px;
    font-weight: 800;
    margin: 0;
}

.help-guide-close {
    background: transparent;
    border: none;
    color: #7f1d1d;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.help-guide-close:hover {
    background: rgba(248, 113, 113, 0.2);
    transform: rotate(8deg);
}

.help-guide-body {
    padding: 16px;
    overflow-y: auto;
}

.help-guide-description {
    margin: 0 0 12px;
    font-size: 13px;
    color: #475569;
    line-height: 1.6;
}

.help-guide-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 10px;
}

.help-guide-list li {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 12px;
    color: #0f172a;
    font-weight: 600;
}

@media (max-width: 640px) {
    .help-guide-button {
        top: 60px;
        left: 12px;
        min-width: 86px;
        padding: 5px 9px;
        font-size: 10px;
    }

    .help-guide-panel {
        top: 112px;
        left: 12px;
        width: min(300px, calc(100vw - 24px));
    }
}

/* Sidebar: position fixed, starts from the very top, full viewport height */
@media (min-width: 768px) {
    #sidebar {
        position: fixed;
        top: 0;        /* no gap — sidebar touches the top of the screen */
        right: 0;
        height: 100vh; /* full viewport height */
    }

    /* Reserve space on the right so content does not slide under the sidebar */
    #app-container {
        padding-right: var(--nav-sidebar-width);
    }

    /* ID+element specificity (1,0,1) beats Tailwind class selectors (0,1,0).
       Keeps the header visually above the sidebar (z-50) at all times. */
    #app-container header {
        position: relative;
        z-index: 60;
    }
}

/* ── Mobile: dashboard & HQ ── */
@media (max-width: 767px) {
    html, body {
        overflow-x: hidden;
    }

    #app-container {
        height: 100dvh;
        min-height: 100dvh;
        max-height: 100dvh;
    }

    #app-container > .flex-1 {
        min-width: 0;
        width: 100%;
    }

    #main-view {
        padding: 12px !important;
        -webkit-overflow-scrolling: touch;
    }

    #app-container header {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    #sidebar {
        width: min(85vw, 18rem);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    .hq-dashboard {
        padding-bottom: env(safe-area-inset-bottom, 12px);
    }

    .hq-hero {
        padding: 1.25rem 1rem;
        border-radius: 1.25rem;
    }

    .hq-hero .relative.z-10.flex {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .hq-hero h2 {
        font-size: 1.65rem !important;
        line-height: 1.25;
    }

    .hq-hero-logo {
        width: 52px;
        height: 52px;
    }

    .hq-stat-glass {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 0;
    }

    .hq-hero .flex.flex-wrap.gap-3 {
        width: 100%;
    }

    .hq-kpi-card {
        padding: 1rem;
    }

    .hq-kpi-card h3 {
        font-size: 1.35rem !important;
    }

    .hq-panel-luxe-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }

    .hq-modules-wrap {
        padding: 1.25rem;
    }

    .hq-module-card {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .hq-hero .flex.flex-wrap.gap-3 {
        flex-direction: column;
    }

    .hq-stat-glass {
        width: 100%;
    }

    .hq-kpi-icon {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 0.95rem;
    }
}

/* ── Entity hierarchy display (branch / incubator / platform / customer) ── */
.entity-hierarchy-table {
    border-collapse: separate;
    border-spacing: 0;
}

.entity-hierarchy-table th,
.entity-hierarchy-table td {
    vertical-align: middle;
}

.entity-hierarchy-table--customer-service {
    min-width: 1680px;
}

.entity-hierarchy-table--customer-service th,
.entity-hierarchy-table--customer-service td {
    white-space: nowrap;
    padding-left: 12px;
    padding-right: 12px;
    font-size: 13px;
}

.entity-hierarchy-table--customer-service thead th {
    font-size: 11px;
    letter-spacing: 0.02em;
}

.entity-hierarchy-grid {
    display: grid;
    gap: 4px;
    min-width: 280px;
}

.entity-hierarchy-grid-labels,
.entity-hierarchy-grid-values {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    text-align: center;
}

.entity-hierarchy-grid-label {
    font-size: 11px;
    font-weight: 800;
    color: #94a3b8;
    white-space: nowrap;
}

.entity-hierarchy-grid-value {
    font-size: 13px;
    font-weight: 700;
    color: #334155;
    padding: 6px 4px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entity-hierarchy-grid-value--primary {
    color: #0f172a;
    background: #fff1f2;
    border-color: #fecaca;
    font-weight: 800;
}

.entity-hierarchy-form-grid {
    display: grid;
    gap: 12px;
}

.entity-hierarchy-form-grid--top {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.entity-hierarchy-form-grid--bottom {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.entity-hierarchy-form-section {
    margin-bottom: 4px;
}

.entity-hierarchy-form-field {
    display: block;
    min-width: 0;
}


@media (max-width: 767px) {
    .entity-hierarchy-form-grid--top,
    .entity-hierarchy-form-grid--bottom {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .entity-hierarchy-grid-labels,
    .entity-hierarchy-grid-values {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .entity-hierarchy-table {
        min-width: 720px;
    }
}

.tenant-workspace-dashboard {
    animation: fadeIn 0.55s ease-out forwards;
}

.tenant-workspace-hero {
    position: relative;
    overflow: hidden;
    border-radius: 1.75rem;
    padding: 1.75rem;
    color: #fff;
    background: linear-gradient(
        135deg,
        var(--tenant-secondary, #1a1a1a) 0%,
        var(--tenant-primary, #0e139a) 52%,
        color-mix(in srgb, var(--tenant-primary, #0e139a) 82%, #000) 100%
    );
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.tenant-workspace-hero::before,
.tenant-workspace-hero::after {
    content: '';
    position: absolute;
    border-radius: 999px;
    pointer-events: none;
}

.tenant-workspace-hero::before {
    width: 280px;
    height: 280px;
    top: -120px;
    left: -80px;
    background: rgba(255, 255, 255, 0.08);
}

.tenant-workspace-hero::after {
    width: 220px;
    height: 220px;
    bottom: -100px;
    right: -40px;
    background: rgba(255, 255, 255, 0.06);
}

.tenant-workspace-logo {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.14);
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.tenant-workspace-stat {
    min-width: 140px;
    padding: 1rem 1.15rem;
    border-radius: 1.15rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(10px);
}

.tenant-workspace-kpi {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 1.25rem;
    padding: 1.15rem 1.25rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.tenant-workspace-kpi-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, var(--tenant-primary, #0e139a), var(--tenant-secondary, #1a1a1a));
}

.tenant-workspace-module {
    border: 1px solid #e2e8f0;
    border-radius: 1.35rem;
    padding: 1.2rem;
    background: #fff;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
    text-align: right;
}

.tenant-workspace-module:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.1);
    border-color: color-mix(in srgb, var(--tenant-primary, #0e139a) 35%, #e2e8f0);
}

.tenant-workspace-module-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    margin-bottom: 0.85rem;
    background: linear-gradient(135deg, var(--tenant-primary, #0e139a), var(--tenant-secondary, #1a1a1a));
}

.tenant-workspace-checklist {
    border: 1px dashed #cbd5e1;
    border-radius: 1.25rem;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.tenant-workspace-check-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 1rem;
    background: #fff;
    border: 1px solid #e2e8f0;
}
