/* SAAS LAYOUT OVERRIDES */
html {
    margin: 0;
    padding: 0;
    overflow: hidden !important;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    overscroll-behavior: none;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden !important;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    background: var(--bg-body);
    display: flex;
    flex-direction: column;
    overscroll-behavior: none;
}

#impersonation-banner {
    flex-shrink: 0;
    position: relative;
    z-index: 1040 !important;
}

@media (max-width: 768px) {
    #impersonation-banner {
        padding: 8px 12px !important;
        gap: 8px;
        font-size: 0.78rem;
        line-height: 1.25;
    }

    #impersonation-banner .impersonation-banner-info {
        min-width: 0;
        flex: 1;
        gap: 6px !important;
    }

    #impersonation-banner .impersonation-banner-label {
        display: block;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #impersonation-banner .impersonation-banner-actions {
        gap: 6px !important;
        flex-shrink: 0;
    }

    #impersonation-banner .impersonation-exit-btn {
        padding: 5px 10px !important;
        font-size: 0.76rem;
        white-space: nowrap;
    }
}

@media (max-width: 640px) {
    #impersonation-banner #impersonation-role {
        display: none !important;
    }

    #impersonation-banner .impersonation-feedback-btn {
        padding: 5px 8px !important;
    }

    #impersonation-banner .impersonation-feedback-text {
        display: none;
    }
}

#app-container {
    display: flex;
    flex: 1 1 0%;
    min-height: 0;
    width: 100%;
}

/* APP SHELL */
#app-shell,
#vp-app-shell {
    display: none;
    /* Default Hidden to prevent flicker */
    height: 100%;
    width: 100vw;
    overflow: hidden;
    background: #f1f5f9;
    font-family: 'Inter', sans-serif;
}

/* DEFAULT STATE - PREVENT FLICKER */
#login-screen {
    display: none;
    /* Hide until we know no user */
}

#loader-overlay {
    display: flex;
    /* Show by default */
}

/* SIDEBAR NAV */
#main-nav,
#vp-main-nav {
    width: 256px;
    background: #1a1a1a;
    color: #ecf0f1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #2b2b2b;
    flex-shrink: 0;
    position: relative;
    z-index: 1000;
    transition: width 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s ease;
}

/* Footer Account Row + Sidebar Collapse Toggle (Desktop) */
.nav-footer-account-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #2e2e2e;
}

.sidebar-collapse-btn {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(212, 175, 55, 0.32);
    color: #fef3c7;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.22s ease;
}

.sidebar-collapse-btn:hover {
    background: rgba(212, 175, 55, 0.16);
    border-color: #d4af37;
    color: #ffffff;
}

.sidebar-collapse-btn svg {
    width: 14px;
    height: 14px;
    transition: transform 0.22s ease;
}

/* Sign Out Button (Label left, Icon right) */
.nav-signout-btn {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    margin: 0;
    font-family: inherit;
    text-align: left;
}

.nav-signout-btn svg {
    width: 17px;
    height: 17px;
    margin-right: 0 !important;
    flex-shrink: 0;
}

/* Collapsed Desktop Rail (68px) */
@media (min-width: 1025px) {
    #main-nav.sidebar-collapsed {
        width: 68px;
    }

    #main-nav.sidebar-collapsed .nav-footer-account-row {
        justify-content: center;
        margin-bottom: 8px;
        padding-bottom: 8px;
    }

    #main-nav.sidebar-collapsed .sidebar-collapse-btn svg {
        transform: rotate(180deg);
    }

    #main-nav.sidebar-collapsed .nav-brand {
        padding: 14px 8px !important;
        flex-direction: column;
        gap: 10px;
        justify-content: center !important;
    }

    #main-nav.sidebar-collapsed .nav-brand-text-wrap,
    #main-nav.sidebar-collapsed .nav-section-label,
    #main-nav.sidebar-collapsed .nav-label,
    #main-nav.sidebar-collapsed .nav-tree-chevron,
    #main-nav.sidebar-collapsed .nav-tree-children,
    #main-nav.sidebar-collapsed .beta-pill-badge,
    #main-nav.sidebar-collapsed #sidebar-user-block {
        display: none !important;
    }

    #main-nav.sidebar-collapsed .nav-menu {
        padding: 12px 8px;
    }

    #main-nav.sidebar-collapsed .nav-item {
        justify-content: center;
        padding: 9px;
        gap: 0;
    }

    #main-nav.sidebar-collapsed .nav-item svg {
        margin-right: 0;
    }

    #main-nav.sidebar-collapsed .nav-footer {
        padding: 12px 8px;
    }
}

@media (max-width: 1024px) {
    .sidebar-collapse-btn {
        display: none !important;
    }
}

/* MOBILE RESPONSIVE SIDEBAR */
#mobile-menu-btn,
#vp-mobile-menu-btn {
    display: none;
}

#mobile-overlay,
#vp-mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    backdrop-filter: blur(2px);
}

@media (max-width: 1024px) {

    #main-nav,
    #vp-main-nav {
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        bottom: 0;
        height: auto !important;
        /* Allow top/bottom anchors to define height */
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
        width: 80%;
        max-width: 300px;
        z-index: 2000 !important;
    }

    #main-nav.mobile-active,
    #vp-main-nav.mobile-active,
    #main-nav.open {
        transform: translateX(0);
    }

    #mobile-overlay.active,
    #vp-mobile-overlay.active,
    #sidebar-overlay.open {
        display: block;
    }

    #mobile-menu-btn,
    #vp-mobile-menu-btn {
        display: none !important;
        align-items: center;
        justify-content: center;
        background: white;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        padding: 7px 9px;
        cursor: pointer;
        color: #1e293b;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Show Top App Bar & Admin Hamburger Button across both Tablet (<=1024px) & Mobile */
    body.authenticated.role-admin #mobile-app-bar {
        display: flex !important;
    }

    body.role-admin #mobile-menu-btn {
        display: flex !important;
        position: static !important;
    }

    /* Show Visitor Button */
    body.role-visitor #vp-mobile-menu-btn {
        display: flex !important;
        position: fixed !important;
        top: 15px !important;
        right: 15px !important;
        left: auto !important;
        z-index: 99999 !important;
    }
}

.nav-brand {
    padding: 20px;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-menu {
    flex: 1;
    padding: 12px 10px 18px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* Custom premium scrollbar for nav menu */
.nav-menu::-webkit-scrollbar {
    width: 5px;
}

.nav-menu::-webkit-scrollbar-track {
    background: transparent;
}

.nav-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    transition: background 0.2s ease;
}

.nav-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Sidebar Section Headers (WORKSPACE / ACCOUNT) */
.nav-section-label {
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.38);
    padding: 12px 12px 5px;
    user-select: none;
}

.nav-section-label:first-child {
    padding-top: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 8px 11px;
    margin-bottom: 3px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    color: #a3a3a3;
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
    font-weight: 500;
    font-size: 0.84rem;
    line-height: 1.3;
    text-decoration: none;
    box-sizing: border-box;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

.nav-item.active {
    background: rgba(212, 175, 55, 0.16);
    color: #fef3c7;
    border-color: rgba(212, 175, 55, 0.34);
    font-weight: 600;
}

.nav-item svg {
    margin-right: 10px;
    width: 17px;
    height: 17px;
    flex-shrink: 0;
}

.nav-item.active svg {
    color: #f5d061;
}

.nav-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Nested Tree Accordion Group & Vertical Guide Line */
.nav-tree-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 2px;
}

.nav-tree-chevron {
    width: 14px !important;
    height: 14px !important;
    margin-right: 0 !important;
    margin-left: auto;
    color: rgba(255, 255, 255, 0.4);
    transition: transform 0.18s ease, color 0.18s ease;
}

.nav-tree-group.expanded>.nav-item.nav-tree-parent .nav-tree-chevron {
    transform: rotate(180deg);
    color: #fef3c7;
}

.nav-tree-group.expanded>.nav-item.nav-tree-parent {
    background: rgba(212, 175, 55, 0.14);
    color: #fef3c7;
    border-color: rgba(212, 175, 55, 0.28);
    font-weight: 600;
}

.nav-tree-children {
    display: none;
    flex-direction: column;
    gap: 2px;
    margin: 2px 0 8px 18px;
    padding-left: 11px;
    border-left: 1.5px solid rgba(212, 175, 55, 0.32);
}

.nav-tree-group.expanded>.nav-tree-children {
    display: flex;
}

/* Keep child drawer hidden if RBAC/MCP hides parent anchor via style="display:none" */
.nav-tree-parent[style*="display: none"]+.nav-tree-children,
.nav-tree-parent[style*="display:none"]+.nav-tree-children {
    display: none !important;
}

.nav-tree-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 7px;
    border: 1px solid transparent;
    font-size: 0.78rem;
    font-weight: 500;
    color: #9ca3af;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    line-height: 1.3;
}

.nav-tree-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #f8fafc;
}

.nav-tree-item.active {
    background: rgba(254, 243, 199, 0.12);
    color: #fef3c7;
    border-color: rgba(212, 175, 55, 0.3);
    font-weight: 600;
}

.nav-tree-badge {
    font-size: 0.56rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(212, 175, 55, 0.18);
    color: #f5d061;
    border: 1px solid rgba(212, 175, 55, 0.36);
}

.nav-footer {
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    border-top: 1px solid #333;
    flex-shrink: 0;
    /* Never squash footer */
}

@media (max-width: 1024px) {
    .nav-footer {
        padding-bottom: calc(40px + env(safe-area-inset-bottom));
        /* Lift higher on mobile */
    }
}

/* MAIN CONTENT AREA */
#main-area,
#vp-main-area {
    flex: 1;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    position: relative;
    background: #f1f5f9;
}

/* VIEWS */
.app-view {
    display: none;
    height: 100%;
    overflow-y: auto;
    animation: fadein 0.3s;
    box-sizing: border-box;
}

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

@keyframes fadein {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* VIEW: POINTS (POINT MANAGER) */
/* Reusing Old Layout Logic but nested */
#view-kiosks {
    display: none;
    height: 100%;
}

#view-kiosks.active {
    display: flex;
}

/* VIEW: VISITORS (Sticky Layout) */
#view-visitors {
    display: none;
    height: 100%;
    flex-direction: column;
    overflow: hidden;
    background: #f3f4f6;
}

#view-visitors.active {
    display: flex;
}

.visitors-body-wrap {
    width: 100%;
    padding: 18px 28px;
    box-sizing: border-box;
}

.visitors-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.visitors-table thead tr {
    position: sticky;
    top: 0;
    background: #f9fafb;
    z-index: 1;
    border-bottom: 1px solid #e5e7eb;
}

.visitors-table th {
    text-align: left;
    padding: 11px 16px;
    font-size: 0.71rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.visitors-table tbody tr {
    transition: background 0.14s ease;
}

.visitors-table tbody tr:hover {
    background: #fafafa;
}

.visitors-name-trigger {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
    color: #111827;
    cursor: pointer;
    transition: color 0.14s ease;
}

.visitors-name-trigger:hover {
    color: #b48a18;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.visitors-contact-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    text-decoration: none;
    font-size: 0.76rem;
    font-weight: 600;
    transition: border-color 0.15s ease, background 0.15s ease;
    white-space: nowrap;
}

.visitors-contact-pill:hover {
    background: #ffffff;
    border-color: #d1d5db;
}

/* VIEW: CONFIGURATION, BRANDING, MY CLIENTS, HELP, PROFILE & MCP HUB */
#view-configuration,
#view-sa-branding,
#view-sa-tenants,
#view-sa-packages,
#view-help,
#view-profile,
#view-mcp {
    display: none;
    height: 100%;
}

#view-configuration.active,
#view-sa-branding.active,
#view-sa-tenants.active,
#view-sa-packages.active,
#view-help.active,
#view-profile.active,
#view-mcp.active {
    display: flex;
}

/* Config Sidebar Items */
.config-nav-item {
    padding: 12px 20px;
    cursor: pointer;
    font-weight: 500;
    color: #64748b;
    /* Default Text */
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    margin-bottom: 2px;
}

.config-nav-item:hover {
    color: #1e293b;
    background: #f1f5f9;
}

.config-nav-item.active {
    background: #e2e8f0;
    /* Light Grey Active */
    color: #1a1a1a;
    /* Dark Text */
    font-weight: 600;
}

/* This view is a flex container itself */

.kiosk-sidebar {
    width: 340px;
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.kiosk-main {
    flex: 1;
    /* overflow-y: auto; REMOVING this from parent to let children handle it if needed */
    background: #f3f4f6;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent spillover */
}

/* OLD STYLES RE-MAP */
.list-search-box {
    padding: 14px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: #ffffff;
}

.list-items {
    flex: 1;
    overflow-y: auto;
}

/* UTILS */
.page-header {
    padding: 24px 36px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.page-title {
    font-size: 1.45rem;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    letter-spacing: -0.02em;
    font-weight: 700;
    color: #111827;
    margin: 0;
}

/* Shared Portal Design Tokens & Reusable Header / Card / Action Classes */
.portal-page-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    padding: 16px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    box-sizing: border-box;
    width: 100%;
}

.portal-body {
    padding: 20px 28px 40px;
    max-width: 1240px;
    width: 100%;
    box-sizing: border-box;
}

.portal-input,
.portal-select {
    width: 100%;
    height: 36px;
    padding: 0 11px;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    font-size: 0.84rem;
    color: #111827;
    background: #ffffff;
    box-sizing: border-box;
    font-family: inherit;
    margin: 0;
}

.portal-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.79rem;
    font-weight: 600;
    color: #374151;
    margin: 0 0 5px 0;
    text-transform: none;
    letter-spacing: normal;
}

.portal-header-scope {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.portal-scope-select {
    height: 36px;
    min-width: 210px;
    max-width: 270px;
    padding: 0 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.81rem;
    font-weight: 600;
    color: #111827;
    background: #f9fafb;
    cursor: pointer;
    box-sizing: border-box;
    margin: 0;
}

.portal-scope-pill {
    display: none;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 10px;
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    box-sizing: border-box;
}

.portal-page-title {
    margin: 0;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.portal-page-subtitle {
    margin: 3px 0 0 0;
    font-size: 0.82rem;
    color: #6b7280;
    line-height: 1.4;
}

.portal-page-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.portal-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.portal-card-header {
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    padding: 14px 20px;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.btn-portal-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: #1a1a1a;
    color: #ffffff;
    border: 1px solid #1a1a1a;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.16s ease, transform 0.12s ease, opacity 0.16s ease;
    white-space: nowrap;
}

.btn-portal-primary:hover:not(:disabled) {
    background: #2b2b2b;
}

.btn-portal-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: #ffffff;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
    white-space: nowrap;
}

.btn-portal-secondary:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #111827;
}

.btn-portal-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease;
    white-space: nowrap;
}

.btn-portal-danger:hover:not(:disabled) {
    background: #fee2e2;
    border-color: #fca5a5;
}

.btn-portal-primary:disabled,
.btn-portal-secondary:disabled,
.btn-portal-danger:disabled {
    opacity: 0.72;
    cursor: not-allowed;
}

@media (max-width: 768px) {
    .portal-page-header {
        padding: 14px 16px;
    }

    .portal-body {
        padding: 14px 14px 96px;
    }

    .portal-scope-select {
        min-width: 0;
        width: 100%;
        max-width: none;
    }
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

th {
    text-align: left;
    padding: 15px;
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    border-bottom: 1px solid #e2e8f0;
}

/* MOBILE UI */
/* Top App Bar (Flex row at top of body on <= 1024px so it never overlaps views or impersonation banner) */
#mobile-app-bar {
    display: none;
    /* Hidden on Desktop */
    position: relative;
    width: 100%;
    height: 56px;
    flex-shrink: 0;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    z-index: 1050;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-sizing: border-box;
}

#mobile-menu-btn {
    background: transparent;
    border: none;
    color: #1e293b;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden !important;
}

/* Mobile Modal Handling */
@media (max-width: 768px) {

    /* Force modals to start lower so they don't cover top buttons */
    #modal-magic-manager,
    #modal-share,
    #modal-overlay {
        padding-top: calc(80px + env(safe-area-inset-top)) !important;
        align-items: flex-start !important;
        /* Align to top (plus padding) instead of center */
    }

    #modal-tenant>div,
    #modal-invite-client>div,
    #modal-import-tour>div,
    #modal-hotspot-discovery>div {
        width: 100% !important;
        max-width: calc(100vw - 24px) !important;
        max-height: calc(100dvh - 24px) !important;
        overflow-y: auto !important;
        box-sizing: border-box !important;
    }

    /* When guided spotlight is active with an open modal on mobile, keep modal actions clear of the bottom spotlight bar */
    body.vistara-spotlight-modal-mobile #modal-tenant,
    body.vistara-spotlight-modal-mobile #modal-invite-client,
    body.vistara-spotlight-modal-mobile #modal-import-tour,
    body.vistara-spotlight-modal-mobile #modal-hotspot-discovery {
        align-items: flex-start !important;
        padding: 12px 12px 136px 12px !important;
        box-sizing: border-box !important;
        overflow-y: auto !important;
    }

    body.vistara-spotlight-modal-mobile #modal-tenant>div,
    body.vistara-spotlight-modal-mobile #modal-invite-client>div,
    body.vistara-spotlight-modal-mobile #modal-import-tour>div,
    body.vistara-spotlight-modal-mobile #modal-hotspot-discovery>div {
        max-height: calc(100dvh - 152px) !important;
    }
}

#sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    backdrop-filter: blur(2px);
}

/* BADGES */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-invest {
    background: #dcfce7;
    color: #166534;
}

/* Green */
.badge-buy {
    background: #dbeafe;
    color: #1e40af;
}

/* Blue */
.badge-partner {
    background: #fef9c3;
    color: #854d0e;
}

/* Yellow */
.badge-other {
    background: #f1f5f9;
    color: #475569;
}

/* Gray */

/* CUSTOM ALERT / CONFIRM MODAL */
#app-dialog-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

#app-dialog-box {
    background: white;
    width: 90%;
    max-width: 400px;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    animation: popIn 0.2s ease-out;
    text-align: center;
}

@keyframes popIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.dialog-btn {
    padding: 8px 20px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    margin: 0 5px;
}

.btn-confirm {
    background: #1a1a1a;
    color: white;
}

.btn-cancel {
    background: #e2e8f0;
    color: #475569;
}

@media (max-width: 768px) {


    #main-nav {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        width: 260px;
        position: fixed;
        /* FIX: Take out of flow */
        height: 100vh;
        /* Full height */
        top: 0;
        left: 0;
    }

    #main-nav.open {
        transform: translateX(0);
    }

    #sidebar-overlay.open {
        display: block;
    }

    #main-area {
        margin-left: 0 !important;
        /* Force reset */
        width: 100%;
        padding: 0;
        padding-top: 0;
    }


    /* MASTER-DETAIL LOGIC (Mobile Only) */
    /* Default: Show Sidebar (List), Hide Main (Editor) */
    /* Default: Show Sidebar (List), Hide Main (Editor) */
    .kiosk-sidebar {
        width: 100% !important;
        display: flex !important;
        flex-direction: column;
        height: 100% !important;
        background: white;
        /* Ensure background matches */
    }

    .kiosk-main {
        display: none;
        /* Mobile default hidden */
        width: 100% !important;
        height: auto;
    }

    /* When Detail Active: Hide Sidebar, Show Main */
    #view-kiosks.mobile-detail-active .kiosk-sidebar {
        display: none !important;
    }

    #view-kiosks.mobile-detail-active .kiosk-main {
        display: block !important;
    }

    #view-kiosks.mobile-detail-active .kiosk-main #editor {
        display: flex !important;
    }

    /* Flattened views keep .config-main visible on mobile (tree items live in main drawer) */
    #view-configuration,
    #view-sa-branding,
    #view-sa-tenants,
    #view-sa-packages,
    #view-help,
    #view-profile,
    #view-mcp,
    #view-media-library {
        padding: 0 !important;
    }

    .config-main {
        display: block !important;
        width: 100% !important;
    }

    /* ZONES VIEW STACKING */
    #view-zones>div {
        grid-template-columns: 1fr !important;
    }

    /* Fix Scrolling Cut-off */
    .list-items {
        padding-bottom: 120px !important;
    }
}

/* Mobile Back Button (Hotspots Master-Detail Only) */
#mobile-back-btn {
    display: none;
}

@media (max-width: 768px) {

    #mobile-back-btn {
        display: flex;
        align-items: center;
        margin-bottom: 15px;
        padding: 8px 12px;
        background: #e2e8f0;
        border-radius: 6px;
        border: none;
        font-weight: 600;
        color: #475569;
        cursor: pointer;
    }

    .editor-container {
        padding: 12px !important;
        box-sizing: border-box !important;
    }

    /* Fix Editor Header Alignment on Mobile */
    .editor-header {
        padding: 12px 14px !important;
        gap: 10px !important;
        border-radius: 10px;
        box-sizing: border-box !important;
        max-width: 100% !important;
    }

    .editor-header .btn-portal-danger,
    .editor-header .btn-portal-primary {
        padding: 7px 12px !important;
        font-size: 0.78rem !important;
    }

    .editor-scroll-area {
        overflow-x: hidden !important;
        width: 100% !important;
        padding: 12px 0 100px 0 !important;
        box-sizing: border-box !important;
    }

    #editor-discovery-banner .editor-discovery-row {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    #editor-discovery-banner .editor-discovery-info {
        min-width: 0 !important;
        width: 100% !important;
    }

    #editor-discovery-banner .editor-discovery-actions {
        width: 100% !important;
    }

    #editor-discovery-banner .editor-discovery-actions button {
        width: 100% !important;
        height: auto !important;
        min-height: 34px;
        padding: 7px 12px !important;
        white-space: normal !important;
        text-align: center;
    }

    .kiosk-list {
        padding-bottom: 120px !important;
    }

    /* Reposition Zoom Controls on Mobile */
    .zoom-controls {
        top: auto !important;
        bottom: 100px !important;
        right: 20px !important;
    }
}

/* Default Desktop Zoom Position */
.zoom-controls {
    top: 20px;
    right: 20px;
}


td {
    padding: 15px;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
}

tr:last-child td {
    border-bottom: none;
}

/* CONFIGURATION GRID RESPONSIVE */
.config-grid-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
}

.config-grid-layout.equal-cols {
    grid-template-columns: 1fr 1fr;
}

@media (max-width: 900px) {

    .config-grid-layout,
    .config-grid-layout.equal-cols {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    /* Optional: Make the form come first on mobile? 
               Usage: <div class="config-grid-layout" style="direction: rtl;"> to swap visual order if needed, 
               but default stacking (List top, Form bottom) is standard. */
}

/* EDITOR FORM GRID */
#standard-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

#standard-fields .full-width {
    grid-column: span 2;
    width: 100%;
}

/* Mobile responsive: stack on small screens */
@media (max-width: 600px) {
    #standard-fields {
        grid-template-columns: 1fr;
    }

    #standard-fields .full-width {
        grid-column: span 1;
    }
}

/* STYLE TOOLBAR */
.style-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    /* Force one line */
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-bottom: none;
    padding: 8px 12px;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    overflow-x: auto;
}

#field-title-container input,
#standard-fields textarea {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.style-font {
    padding: 0 8px;
    /* Adjusted padding for fixed height */
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.9rem;
    width: 200px !important;
    height: 36px !important;
    box-sizing: border-box;
    /* Fixed width for compact look */
    flex: none;
    /* Don't grow */
}

.style-size {
    width: 70px !important;
    height: 36px !important;
    box-sizing: border-box;
    flex: none;
    padding: 0 4px;
    text-align: center;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.9rem;
}

.style-color {
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 4px;
    /* Optional rounded corners */
}

.align-group {
    height: 36px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    /* gap: 2px; REMOVED gap to look like a segmented control */
    gap: 1px;
    background: #e2e8f0;
    /* Divider color */
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    overflow: hidden;
}

.btn-align {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    border-radius: 0;
}

.btn-align {
    background: white;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 1rem;
    color: #64748b;
}

.btn-align:hover {
    background: #f1f5f9;
}

.btn-align.active {
    background: #1e293b;
    color: white;
}

.editor-divider {
    grid-column: span 2;
    width: 100%;
    border: 0;
    border-top: 1px solid #000000;
    margin: 10px 0;
    /* Reduced margin from 20px */
}

@media (max-width: 600px) {
    .editor-divider {
        grid-column: span 1;
    }
}

/* MAP PIN STYLES */
.map-pin {
    position: absolute;
    width: 30px;
    height: 30px;
    background: #ef4444;
    border: 3px solid white;
    border-radius: 50% 50% 0 50%;
    transform: translate(-50%, -100%) rotate(45deg);
    /* Point tip to bottom center -> rotated 90deg CW */
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
    pointer-events: auto !important;
    z-index: 10;
}

.map-pin:hover {
    transform: translate(-50%, -100%) rotate(-45deg) scale(1.1);
    z-index: 11;
}

.map-pin.active {
    background: #1e293b;
    z-index: 12;
}

.pin-popover {
    position: absolute;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    width: 220px;
    z-index: 20;
    pointer-events: auto !important;
    transform: translate(-50%, 10px);
    /* Center below pin */
}

.pin-popover::before {
    /* Triangle Arrow */
    content: "";
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 6px 6px 6px;
    border-style: solid;
    border-color: transparent transparent white transparent;
}

/* PIN EDITOR */
.pin-editor {
    position: absolute;
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
    width: 260px;
    z-index: 100;
    display: none;
    /* Toggled via JS */
    flex-direction: column;
    gap: 12px;
    border: 1px solid #e2e8f0;
}

.pin-editor h4 {
    margin: 0 0 5px;
    font-size: 0.9rem;
    color: #1e293b;
}

.pin-editor textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px;
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
    font-size: 0.9rem;
}

.color-group {
    display: flex;
    gap: 8px;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 0 0 1px #cbd5e1;
    transition: 0.2s;
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.active {
    box-shadow: 0 0 0 2px #1e293b;
    transform: scale(1.1);
}

.icon-group {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.icon-btn {
    background: #f1f5f9;
    border: 1px solid transparent;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
    font-size: 1.1rem;
}

.icon-btn:hover {
    background: #e2e8f0;
}

.icon-btn.active {
    background: #cbd5e1;
    border-color: #94a3b8;
}

/* VISITOR PORTAL MOBILE FIXES */
@media (max-width: 768px) {

    /* Force Root Container Constraints */
    #visitor-portal-root,
    #vp-app-shell,
    #vp-main-area {
        max-width: 100vw !important;
        overflow-x: hidden !important;
        width: 100% !important;
        box-sizing: border-box !important;
        padding-right: 0 !important;
    }

    /* Fix Table Overflow - This is the Critical Fix */
    #vp-log-table {
        min-width: 800px !important;
        width: 100% !important;
        /* Revert display:block to ensure proper table semantics and sticky header */
        display: table;
    }

    /* Mobile: Page-Level Scroll Strategy (No nested scroll) */
    .table-scroll-wrapper {
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: auto !important;
        /* Keep horizontal scroll for columns */
        display: block !important;

        /* Remove fixed height constraints on mobile - let it grow */
        max-height: none !important;
        overflow-y: visible !important;

        /* Minimal padding since we drive the scroll via the page */
        padding-bottom: 0 !important;
    }

    /* Add massive page buffer to ensure ANY view can be scrolled up */
    .portal-wrapper,
    #vp-view-profile,
    #vp-view-dashboard,
    #vp-main-area>div {
        padding-bottom: 150px !important;
        box-sizing: border-box !important;
    }


    /* Wrap table logic helper */
    /* Note: Since we can't easily add a wrapper div via CSS only, 
       we ensure the EXISTING parent div is scrollable. 
       In visitor-portal.html, the table is inside <div style="max-height:500px; overflow-y:auto; overflow-x:auto;">
       We reinforce that style here. 
    */


    /* Target the parent of the table indirectly if possible, or assume inline style holds. 
       But let's be safe and target the likely structure if we can identify it. 
       The inline style in HTML should handle it: overflow-x:auto. 
       But we add a general rule for scrollable areas. */


    /* Ensure Grid doesn't bleed */
    .visitor-stats-grid {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        box-sizing: border-box !important;
        margin-right: 0 !important;
        gap: 16px !important;
    }

    .visitor-stats-grid .stat-card {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Fix Badges sticking out */
    .badge {
        white-space: normal !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Fix Filter Inputs Overflow */
    .log-filter-input,
    #vp-filter-interest {
        box-sizing: border-box !important;
        max-width: 100% !important;
    }

    /* Stack Profile Inputs on Mobile */
    .profile-details-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
}

/* Desktop Defaults (Outside Media Query) */
.profile-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 24px;
}

/* Fix Input Box Model to prevent grid overflow/overlap */
.profile-details-grid input:not([type="checkbox"]) {
    box-sizing: border-box !important;
    width: 100% !important;
}

/* Custom inline spinner for immediate folder processing feedback */
.upload-loader {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #cbd5e1;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: upload-spin 1s linear infinite;
}

@keyframes upload-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Premium Upload Dropzone Hover State */
.premium-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: #f8fafc;
}

.premium-dropzone:hover {
    border-color: #3b82f6;
    background: #eff6ff;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.08);
}

.premium-dropzone svg {
    transition: transform 0.3s ease;
}

.premium-dropzone:hover svg {
    transform: scale(1.1);
}

/* Glassmorphic progress card */
.glass-progress-card {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
    margin-top: 20px;
}

/* Pulsating progress bar container */
.pulse-progress-bar {
    width: 100%;
    height: 10px;
    background: #e2e8f0;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

.pulse-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 5px;
    position: relative;
}

.pulse-progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.3) 50%,
            rgba(255, 255, 255, 0) 100%);
    animation: progress-shimmer 1.5s infinite;
}

@keyframes progress-shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

/* Indeterminate active state while connecting & preparing stream */
.pulse-progress-bar.is-indeterminate .pulse-progress-fill {
    width: 100% !important;
    background: linear-gradient(90deg, #e2e8f0 0%, #3b82f6 50%, #e2e8f0 100%);
    background-size: 200% 100%;
    animation: indeterminate-flow 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes indeterminate-flow {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

@keyframes pulse-scale {
    0% {
        transform: scale(0.8);
        opacity: 0.6;
    }

    100% {
        transform: scale(1.25);
        opacity: 1;
    }
}

/* Upload Detail Row styling */
.upload-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 15px;
    border-top: 1px solid #f1f5f9;
    padding-top: 12px;
}

.upload-meta-item {
    font-size: 0.8rem;
    color: #64748b;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.upload-meta-val {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.9rem;
}

/* Red-themed progress bar for Overwrites */
.pulse-progress-fill-red {
    height: 100%;
    background: linear-gradient(90deg, #ef4444, #f87171);
    transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 5px;
    position: relative;
}

.pulse-progress-fill-red::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.3) 50%,
            rgba(255, 255, 255, 0) 100%);
    animation: progress-shimmer 1.5s infinite;
}

/* Pulsating text animation for loading/cleaning states */
.pulsate-text {
    animation: text-pulse-fade 1.5s ease-in-out infinite;
}

@keyframes text-pulse-fade {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* --- ROLE-BASED NAVIGATION VISIBILITY OVERRIDES --- */
body.role-visitor #main-nav {
    display: none !important;
}

body.role-admin #vp-main-nav {
    display: none !important;
}

/* --- PERSISTENT NOTIFICATION ACTIVITY CENTER (Docked in Sidebar Header) --- */
.notif-bell-btn {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #94a3b8;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}

.notif-bell-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.2);
}

.notif-bell-icon {
    width: 18px;
    height: 18px;
}

.notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.5);
    border: 2px solid #1a1a1a;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    animation: badgePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes badgePop {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes bellWiggle {

    0%,
    100% {
        transform: rotate(0);
    }

    20%,
    60% {
        transform: rotate(14deg);
    }

    40%,
    80% {
        transform: rotate(-14deg);
    }
}

.bell-ring-animation {
    animation: bellWiggle 0.6s ease;
}

/* Slide-out Drawer & Overlay */
.notif-drawer-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.3);
    backdrop-filter: blur(3px);
    z-index: 9998;
    transition: opacity 0.3s ease;
}

.notif-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: white;
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.notif-drawer.active {
    transform: translateX(0);
}

.notif-drawer-header {
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    flex-shrink: 0;
}

.notif-drawer-body {
    flex: 1;
    overflow-y: auto;
    background: #ffffff;
}

.notif-drawer-body::-webkit-scrollbar {
    width: 5px;
}

.notif-drawer-body::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}

/* --- SUPERADMIN 2x3 STATS GRID --- */
.sa-stats-2x3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    margin-bottom: 25px;
}

@media (max-width: 1024px) {
    .sa-stats-2x3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .sa-stats-2x3 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sa-grace-right-col {
        align-items: flex-start !important;
    }
}

/* --- UNIFIED ASYNC BUTTON LOADING & ALERT CARD STATES --- */
@keyframes portalBtnSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.portal-btn-spinner {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    animation: portalBtnSpin 0.75s linear infinite;
}

.portal-btn-loading,
button.portal-btn-loading {
    opacity: 0.78 !important;
    cursor: wait !important;
    pointer-events: none !important;
}

#app-alert {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#app-alert pre,
#app-alert code {
    white-space: pre-wrap !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

#app-alert .app-alert-action-btn {
    background: transparent;
    border: none;
    color: #b45309;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    padding: 2px 0;
}

#app-alert .app-alert-action-btn:hover {
    color: #92400e;
}

#app-alert .app-alert-close:hover {
    background: #f3f4f6 !important;
    color: #111827 !important;
}

/* --- GET STARTED STUDIO & SPOTLIGHTS (Client & Agency) --- */
.gs-view-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    background: #f3f4f6;
    overflow-y: auto;
    box-sizing: border-box;
}

.gs-studio-body {
    width: 100%;
    max-width: none;
    padding: 24px 28px 48px;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

.gs-header-tips-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 6px 11px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    user-select: none;
    margin: 0;
    text-transform: none;
    letter-spacing: 0;
    white-space: nowrap;
    height: 36px;
    box-sizing: border-box;
}

.gs-hero-card {
    background: #141414;
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 14px;
    padding: 22px 26px;
    color: #ffffff;
    margin-bottom: 20px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.14);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.gs-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: rgba(212, 175, 55, 0.14);
    border: 1px solid rgba(212, 175, 55, 0.35);
    color: #d4af37;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 4px 10px;
    border-radius: 999px;
    margin-bottom: 9px;
}

.gs-hero-title {
    font-family: 'Plus Jakarta Sans', sans-serif;
    margin: 0 0 6px 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.02em;
}

.gs-hero-desc {
    margin: 0 0 16px 0;
    font-size: 0.84rem;
    color: #a3a3a3;
    line-height: 1.5;
    max-width: 620px;
}

.gs-hero-cta {
    background: linear-gradient(135deg, #ecc963 0%, #d4af37 100%);
    color: #141414;
    border: 1px solid #b48a18;
    padding: 9px 18px;
    border-radius: 9px;
    font-weight: 700;
    font-size: 0.84rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(212, 175, 55, 0.25);
    transition: transform 0.15s ease, filter 0.15s ease;
    width: auto;
    margin: 0;
}

.gs-hero-cta:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

.gs-hero-status-box {
    background: #1c1c1c;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px 18px;
    min-width: 240px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.gs-hero-secondary-btn {
    background: #242424;
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #ffffff;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 5px 11px;
    border-radius: 7px;
    cursor: pointer;
    margin: 0;
    width: auto;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.gs-hero-secondary-btn:hover {
    border-color: #d4af37;
    color: #d4af37;
}

.gs-section-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
    padding: 0 2px;
}

.gs-spotlight-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}

.gs-feature-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
    box-sizing: border-box;
    min-width: 0;
}

.gs-feature-card:hover {
    border-color: rgba(212, 175, 55, 0.45);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.gs-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.gs-card-icon-box {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #f3f4f6;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.gs-card-category-pill {
    font-size: 0.66rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #f9fafb;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    padding: 3px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

.gs-card-title-row {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.gs-card-title-row h4 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    margin: 0;
    font-size: 0.96rem;
    color: #111827;
    font-weight: 700;
    line-height: 1.3;
}

.gs-card-desc {
    margin: 0 0 14px 0;
    font-size: 0.8rem;
    color: #6b7280;
    line-height: 1.48;
}

.gs-guide-btn {
    width: 100%;
    height: 34px;
    background: #f9fafb;
    color: #1a1a1a;
    border: 1px solid #e5e7eb;
    padding: 0 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0;
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
    box-sizing: border-box;
}

.gs-guide-btn:hover {
    background: #1a1a1a;
    color: #d4af37;
    border-color: #1a1a1a;
}

.gs-counter-pill {
    font-size: 0.71rem;
    font-weight: 700;
    color: #4b5563;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

/* ============================================================
   CLEAN ASSET-CHIP MASKING (INTERNAL STORAGE URLS)
   ============================================================ */

.vistara-asset-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 36px;
    padding: 4px 6px 4px 8px;
    box-sizing: border-box;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.vistara-asset-chip:hover {
    border-color: rgba(212, 175, 55, 0.55);
    background: #ffffff;
}

.vistara-asset-chip-thumb {
    width: 26px;
    height: 26px;
    border-radius: 5px;
    object-fit: cover;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    flex-shrink: 0;
}

.vistara-asset-chip-icon {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: #141414;
    color: #d4af37;
    border: 1px solid rgba(212, 175, 55, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.vistara-asset-chip-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.vistara-asset-chip-name {
    font-size: 0.79rem;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
}

.vistara-asset-chip-sub {
    font-size: 0.67rem;
    font-weight: 500;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.vistara-asset-chip-actions {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}

.vistara-asset-chip-btn {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: all 0.15s ease;
}

.vistara-asset-chip-btn:hover {
    background: #f3f4f6;
    color: #111827;
    border-color: #e5e7eb;
}

.vistara-asset-chip-btn--clear:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fecaca;
}