html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body.rateb-app {
    font-family: var(--rateb-font);
    background: var(--rateb-bg);
    color: var(--rateb-text);
    min-height: 100vh;
}

.rateb-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
}

.rateb-sidebar {
    width: 268px;
    background: var(--rateb-sidebar);
    color: var(--rateb-sidebar-text);
    flex-shrink: 0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    transition: transform 0.3s ease;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

.rateb-sidebar nav {
    padding: 0.35rem 0 1.25rem;
}

.rateb-sidebar-brand {
    padding: 1.25rem;
    font-size: 1.25rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.rateb-sidebar-brand i {
    color: var(--rateb-accent);
}

.rateb-nav-section {
    padding: 0.9rem 1.15rem 0.3rem;
    font-size: 0.68rem;
    font-weight: 600;
    opacity: 0.55;
    color: var(--rateb-sidebar-text);
}

[dir="ltr"] .rateb-nav-section {
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.rateb-nav-group {
    margin: 0.12rem 0.4rem;
}

.rateb-nav-group-toggle {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--rateb-sidebar-text);
    font-size: 0.82rem;
    font-weight: 600;
    text-align: start;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.rateb-nav-group-toggle:hover,
.rateb-nav-group.is-open > .rateb-nav-group-toggle {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.rateb-nav-group-icon {
    width: 1rem;
    flex-shrink: 0;
    text-align: center;
    opacity: 0.85;
    font-size: 0.9rem;
}

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

.rateb-nav-group-chevron {
    font-size: 0.7rem;
    opacity: 0.65;
    transition: transform 0.2s ease;
}

.rateb-nav-group.is-open > .rateb-nav-group-toggle .rateb-nav-group-chevron {
    transform: rotate(180deg);
}

.rateb-nav-group-body {
    display: none;
    padding: 0.1rem 0 0.35rem;
}

.rateb-nav-group.is-open > .rateb-nav-group-body {
    display: block;
}

/* PWA install: bottom corner of MAIN only — never cover sidebar or bottom toolbars. */
.rateb-erp-pwa-install {
    position: fixed;
    z-index: 900;
    inset-inline-start: auto;
    inset-inline-end: 1rem;
    bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    max-width: 18rem;
    width: auto;
    pointer-events: auto;
}

@media (max-width: 991px) {
    .rateb-erp-pwa-install {
        inset-inline: auto 1rem auto auto;
        max-width: calc(100vw - 2rem);
        bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    }
}

.rateb-nav-group-body .rateb-nav-link {
    margin: 0.08rem 0.35rem;
    padding: 0.45rem 0.85rem 0.45rem 1.85rem;
    font-size: 0.86rem;
}

.rateb-nav-subgroup {
    margin: 0.1rem 0.2rem 0.1rem 0.55rem;
    border-inline-start: 1px solid rgba(255, 255, 255, 0.1);
}

.rateb-nav-subgroup-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.42rem 0.55rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--rateb-sidebar-text);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: start;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.rateb-nav-subgroup-toggle:hover,
.rateb-nav-subgroup.is-open > .rateb-nav-subgroup-toggle {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.rateb-nav-subgroup-toggle i:first-child {
    width: 0.95rem;
    flex-shrink: 0;
    text-align: center;
    opacity: 0.85;
    font-size: 0.82rem;
}

.rateb-nav-subgroup-toggle span {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rateb-nav-subgroup-chevron {
    font-size: 0.65rem;
    opacity: 0.6;
    transition: transform 0.2s ease;
}

.rateb-nav-subgroup.is-open .rateb-nav-subgroup-chevron {
    transform: rotate(180deg);
}

.rateb-nav-subgroup-body {
    display: none;
    padding: 0.05rem 0 0.2rem;
}

.rateb-nav-subgroup.is-open .rateb-nav-subgroup-body {
    display: block;
}

.rateb-nav-subgroup-body .rateb-nav-link {
    margin: 0.06rem 0.2rem 0.06rem 0.35rem;
    padding: 0.38rem 0.65rem 0.38rem 1.15rem;
    font-size: 0.8rem;
}

.rateb-nav-soon {
    font-size: 0.62rem;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: rgba(148, 163, 184, 0.22);
    color: #94a3b8;
    font-weight: 500;
    flex-shrink: 0;
}

.rateb-nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 1.15rem;
    margin: 0.1rem 0.5rem;
    border-radius: 8px;
    color: var(--rateb-sidebar-text);
    text-decoration: none;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    border-left: 3px solid transparent;
    font-size: 0.92rem;
    line-height: 1.35;
}

.rateb-nav-link i {
    width: 1.15rem;
    flex-shrink: 0;
    text-align: center;
    font-size: 0.95rem;
    opacity: 0.9;
}

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

.rateb-nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.rateb-nav-link.active {
    background: var(--rateb-sidebar-active);
    color: #fff;
    border-left-color: var(--rateb-accent);
}

.rateb-nav-link.is-nav-pending {
    outline: 1px solid rgba(56, 189, 248, 0.55);
    outline-offset: -1px;
}

/* Soft-nav in-flight: visual only — NEVER block clicks (was freezing the whole Admin UI). */
.rateb-content.is-nav-busy {
    pointer-events: auto;
    opacity: 0.92;
}

.rateb-nav-link.rateb-nav-logout {
    margin-top: 0.65rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: #fca5a5;
}

.rateb-nav-link.rateb-nav-logout:hover {
    background: rgba(248, 113, 113, 0.12);
    color: #fecaca;
}

.rateb-main {
    flex: 1 1 auto;
    margin-left: 268px;
    margin-right: 0;
    width: calc(100% - 268px);
    max-width: calc(100% - 268px);
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.rateb-topbar {
    background: var(--rateb-surface);
    border-bottom: 1px solid var(--rateb-border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 900;
}

.rateb-topbar-user {
    color: var(--rateb-text, #334155);
    font-weight: 600;
    max-width: 12rem;
    min-width: 0;
}

.rateb-topbar-user__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rateb-topbar-logout {
    white-space: nowrap;
    flex-shrink: 0;
}

.rateb-connection-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.28rem 0.65rem;
    border-radius: 999px;
    border: 1px solid rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.12);
    color: #86efac;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    user-select: none;
    white-space: nowrap;
}

.rateb-connection-indicator__dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 0 rgba(134, 239, 172, 0.55);
    animation: rateb-connection-pulse 2s ease-out infinite;
}

.rateb-connection-indicator.is-offline {
    border-color: rgba(248, 113, 113, 0.4);
    background: rgba(248, 113, 113, 0.12);
    color: #fca5a5;
}

.rateb-connection-indicator.is-offline .rateb-connection-indicator__dot {
    animation: none;
}

@keyframes rateb-connection-pulse {
    0% { box-shadow: 0 0 0 0 rgba(134, 239, 172, 0.45); }
    70% { box-shadow: 0 0 0 0.45rem rgba(134, 239, 172, 0); }
    100% { box-shadow: 0 0 0 0 rgba(134, 239, 172, 0); }
}

@media (max-width: 575.98px) {
    .rateb-connection-indicator__label {
        display: none;
    }
}

.rateb-content {
    padding: 1.5rem;
}

.rateb-card {
    background: var(--rateb-surface);
    border: 1px solid var(--rateb-border);
    border-radius: var(--rateb-radius);
    box-shadow: var(--rateb-shadow);
}

.rateb-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--rateb-border);
    font-weight: 600;
}

.rateb-card-body {
    padding: 1.25rem;
}

.rateb-widget {
    background: var(--rateb-surface);
    border: 1px solid var(--rateb-border);
    border-radius: var(--rateb-radius);
    padding: 1.25rem;
    box-shadow: var(--rateb-shadow);
    height: 100%;
}

.rateb-widget-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}

.rateb-widget-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.rateb-widget-label {
    color: var(--rateb-text-muted);
    font-size: 0.875rem;
}

.rateb-auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
}

[data-theme="light"] .rateb-auth-page {
    background: linear-gradient(135deg, #c5daf0 0%, #1e3a5f 100%);
}

.rateb-auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--rateb-surface);
    border-radius: var(--rateb-radius);
    box-shadow: var(--rateb-shadow);
    padding: 2rem;
}

.rateb-login-qr-wrap {
    width: 200px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 8px;
    padding: 8px;
}

.rateb-login-qr-img {
    max-width: 100%;
    height: auto;
    display: block;
}

.rateb-badge-scan-wrap {
    display: inline-block;
    padding: 14px;
    background: #ffffff;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.rateb-badge-scan-qr {
    display: block;
    width: 280px;
    height: 280px;
    max-width: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.rateb-badge-scan-label {
    font-weight: 600;
    color: var(--rateb-accent, #2563eb);
    text-align: center;
}

.rateb-badge-code {
    font-size: 1.1rem;
    letter-spacing: 0.08em;
}

.rateb-chart-card {
    min-height: 320px;
}

@media (max-width: 991px) {
    .rateb-sidebar {
        transform: translateX(-100%);
    }

    .rateb-sidebar.open {
        transform: translateX(0);
    }

    .rateb-main {
        margin-left: 0;
        margin-right: 0;
        width: 100%;
        max-width: 100%;
    }
}
