:root {
    --sidebar-expanded-width: 280px;
    --sidebar-collapsed-width: 84px;
    --shell-bg: #f8fafc;
    --sidebar-bg: #ffffff;
    --sidebar-border: #e5e7eb;
    --text-muted: #64748b;
    --link-hover: #f1f5f9;
    --link-active-bg: #e2e8f0;
    --link-active-text: #0f172a;
}

body {
    background: var(--shell-bg);
    color: #0f172a;
}

a.fb-btn,
a.fb-btn:visited,
a.fb-btn:hover,
a.fb-btn:focus,
button.fb-btn {
    text-decoration: none !important;
}

a.fb-btn-primary,
a.fb-btn-primary:visited,
a.fb-btn-primary:hover,
a.fb-btn-primary:focus,
a.fb-btn-danger,
a.fb-btn-danger:visited,
a.fb-btn-danger:hover,
a.fb-btn-danger:focus {
    color: #fff !important;
}

a.fb-btn-secondary,
a.fb-btn-secondary:visited,
a.fb-btn-ghost,
a.fb-btn-ghost:visited {
    color: #111827 !important;
}

a.fb-btn-secondary:hover,
a.fb-btn-secondary:focus,
a.fb-btn-ghost:hover,
a.fb-btn-ghost:focus {
    color: #1d4ed8 !important;
}

.fb-table .fb-btn {
    height: 2rem !important;
    border-radius: 0.375rem !important;
    border-width: 1px !important;
    padding: 0 0.75rem !important;
    font-size: 0.75rem !important;
    line-height: 1rem !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.fb-table a.fb-btn,
.fb-table a.fb-btn:visited,
.fb-table a.fb-btn:hover,
.fb-table a.fb-btn:focus,
.fb-table button.fb-btn {
    text-decoration: none !important;
}

.app-shell {
    min-height: 100vh;
    display: flex;
}

.app-sidebar {
    width: var(--sidebar-expanded-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    flex-direction: column;
    transition: width 0.2s ease;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand-row {
    padding: 0.875rem 0.75rem;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.sidebar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #0f172a;
    font-weight: 600;
    min-width: 0;
}

.sidebar-brand-logo {
    width: 2rem;
    height: 2rem;
    border-radius: 0.6rem;
    background: #e2e8f0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.sidebar-brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 0.6rem;
    background: #fff;
}

.sidebar-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-collapse-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    border: 0;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
}

.sidebar-collapse-btn:hover {
    color: #0f172a;
}

.sidebar-scroll {
    overflow-y: auto;
    padding: 0.75rem;
}

.sidebar-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 700;
    margin: 1rem 0 0.5rem;
    padding-left: 0.45rem;
}

.sidebar-section-label:first-child {
    margin-top: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: #1e293b;
    border-radius: 0.65rem;
    padding: 0.55rem 0.65rem;
    margin-bottom: 0.2rem;
    line-height: 1.2;
}

.sidebar-link i {
    width: 1.25rem;
    font-size: 1rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-link:hover {
    background: var(--link-hover);
    color: #0f172a;
}

.sidebar-link.active {
    background: var(--link-active-bg);
    color: var(--link-active-text);
    font-weight: 600;
}

.app-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 64px;
    border-bottom: none;
    background: linear-gradient(to bottom, var(--shell-bg) 30%, transparent);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
}

.app-main {
    padding: 1rem;
    flex: 1;
}

/* Logged-out pages (login, password reset, legal, etc.): full-height column so the
   footer sticks to the bottom, with the content anchored in the upper third. */
.auth-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.auth-main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 12vh 1rem 2rem;
}

@media (max-width: 991.98px) {
    .auth-main {
        padding: 8vh 0.85rem 2rem;
    }
}

/* Site footer (shown on every page) */
.site-footer {
    border-top: 1px solid var(--sidebar-border, #e5e7eb);
    background: #fff;
    color: #6b7280;
    font-size: 0.8125rem;
}

.site-footer-inner {
    max-width: 80rem;
    margin: 0 auto;
    padding: 1rem 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
}

.site-footer-brand {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.75rem;
}

.site-footer-company {
    color: #9ca3af;
}

.site-footer-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.25rem;
}

.site-footer a {
    color: #4b5563;
    text-decoration: none;
}

.site-footer a:hover {
    color: #111827;
    text-decoration: underline;
}

.site-footer-builder {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.site-footer-logo {
    height: 20px;
    width: auto;
    display: inline-block;
    vertical-align: middle;
}

body.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .sidebar-section-label,
body.sidebar-collapsed .sidebar-link span {
    display: none;
}

body.sidebar-collapsed .sidebar-brand-row {
    justify-content: space-between;
}

body.sidebar-collapsed .sidebar-link {
    justify-content: center;
}

#mobile-sidebar .sidebar-scroll {
    padding: 0.75rem;
}

@media (max-width: 991.98px) {
    .app-main {
        padding: 0.85rem;
    }
}
