html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    color: var(--text-dark);
    background-color: #f0f2f5;
}

html:has(#appShell),
html:has(#appShell) body {
    overflow: hidden;
    height: 100%;
}

.app-shell {
    display: flex;
    width: min(1320px, calc(100vw - 32px));
    height: calc(100vh - 32px);
    margin: 16px auto;
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(30, 64, 175, 0.08), 0 1px 4px rgba(0, 0, 0, 0.04);
    background-color: var(--bg-secondary);
}

.app-content {
    flex: 1;
    min-width: 0;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.content-mobile-header {
    display: none;
    align-items: center;
    gap: var(--space-3);
    padding: 0 var(--space-4);
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    height: 52px;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.sidebar-mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-dark);
    font-size: var(--font-size-lg);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.sidebar-mobile-toggle:hover {
    background-color: var(--bg-tertiary);
}

.mobile-header-title {
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
    color: var(--text-dark);
}

.agency-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tab-content {
    display: none;
}

.tab-content.active {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.45);
    z-index: var(--z-fixed);
    cursor: pointer;
}

.sidebar-overlay.active {
    display: block;
}

/* ── Connect Sub-Account full-screen overlay ─────────────────────────────── */

.form-shell-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background-color: #f0f2f5;
    overflow-y: auto;
}

.connect-back-btn {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 201;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius-md);
    color: #fff;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.25);
}

.connect-back-btn:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.35);
}

.connect-back-btn i {
    font-size: 12px;
}

/* Push the form down so it clears the fixed back button */
.form-shell-overlay .ghlm-container {
    padding-top: 80px;
}

/* ── Legacy inline form shell (kept for ghlm-container reuse below) ──────── */

.ghlm-container {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-8) var(--space-4);
    background-color: transparent;
}

.ghlm-content {
    width: 100%;
    max-width: 960px;
    background: var(--bg-primary);
    border: 1px solid transparent;
    border-radius: 16px;
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.09), 0 1px 4px rgba(0, 0, 0, 0.04);
    padding: 48px 48px 40px;
    box-sizing: border-box;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

@media (min-width: 1200px) {
    .app-shell {
        width: min(1280px, calc(100vw - 56px));
        height: calc(100vh - 48px);
        margin: 24px auto;
    }
}

@media (max-width: 860px) {
    .ghlm-content {
        padding: 32px 24px 28px;
        border-radius: 12px;
    }
}

@media (max-width: 768px) {
    .app-shell {
        margin: 12px;
        height: calc(100vh - 24px);
        width: calc(100vw - 24px);
        border-radius: var(--radius-lg);
    }

    .content-mobile-header {
        display: flex;
    }
}
