* {
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

.fr-app-body {
    background: #f5fbff !important;
}

/* Desktop header */
.fr-app-header {
    background: rgba(255,255,255,.98);
    border-bottom: 1px solid #e8eef6;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 6px 18px rgba(15,23,42,.05);
}

/* اخفاء عناصر الجوال في الكمبيوتر */
.fr-mobile-header,
.fr-bottom-nav,
.fr-more-backdrop,
.fr-more-sheet {
    display: none;
}

.fr-more-toggle {
    position: fixed;
    opacity: 0;
    pointer-events: none;
}

/* Mobile */
@media (max-width: 1024px) {
    body {
        padding-bottom: calc(82px + env(safe-area-inset-bottom));
        background: #f5fbff !important;
    }

    .fr-app-header {
        background: #f5fbff;
        border-bottom: 0;
        box-shadow: none;
    }

    .fr-mobile-header {
        height: 72px;
        padding: 10px 16px;
        display: grid !important;
        grid-template-columns: 48px 1fr 48px;
        align-items: center;
        gap: 10px;
        background: rgba(255,255,255,.96);
        backdrop-filter: blur(16px);
        border-bottom: 1px solid #edf2f7;
        box-shadow: 0 8px 24px rgba(15,23,42,.05);
    }

    .fr-mobile-brand {
        text-align: center;
        color: #2457e6 !important;
        font-size: 29px;
        line-height: 1;
        font-weight: 950;
        letter-spacing: -.5px;
    }

    .fr-mobile-brand span {
        display: block;
        color: #64748b;
        font-size: 12px;
        font-weight: 800;
        margin-top: 5px;
        letter-spacing: 0;
    }

    .fr-icon-button {
        width: 44px;
        height: 44px;
        border-radius: 16px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: #fff;
        color: #111827 !important;
        border: 1px solid #e8eef6;
        box-shadow: 0 8px 18px rgba(15,23,42,.06);
        font-size: 20px;
        font-weight: 900;
        position: relative;
        cursor: pointer;
        user-select: none;
    }

    .fr-notify-button b {
        position: absolute;
        top: -6px;
        left: -6px;
        min-width: 22px;
        height: 22px;
        border-radius: 999px;
        background: #dc2626;
        color: #fff;
        font-size: 11px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 6px;
        border: 2px solid #fff;
    }

    .fr-page-main {
        padding-top: 18px;
        padding-bottom: 18px;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .container,
    .mx-auto,
    .max-w-7xl,
    .max-w-6xl,
    .max-w-5xl,
    .max-w-4xl,
    .max-w-3xl,
    .max-w-2xl {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    h1 {
        font-size: 30px !important;
        line-height: 1.2 !important;
        font-weight: 950 !important;
        text-align: right !important;
        margin-bottom: 18px !important;
    }

    h2 {
        font-size: 23px !important;
        font-weight: 950 !important;
    }

    .grid {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 16px !important;
    }

    .bg-white,
    .rounded-xl,
    .shadow-sm {
        border-radius: 26px !important;
        border: 1px solid #e8eef6 !important;
        box-shadow: 0 12px 30px rgba(15,23,42,.055) !important;
    }

    .p-8 { padding: 22px !important; }
    .p-6 { padding: 20px !important; }
    .p-5 { padding: 18px !important; }

    a[class*="bg-blue"],
    button[class*="bg-blue"],
    [type="submit"] {
        min-height: 48px !important;
        border-radius: 16px !important;
        font-weight: 950 !important;
        font-size: 15px !important;
        background: linear-gradient(135deg, #2457e6, #1d4ed8) !important;
        box-shadow: 0 10px 22px rgba(36,87,230,.18) !important;
    }

    a[class*="bg-green"],
    button[class*="bg-green"] {
        min-height: 48px !important;
        border-radius: 16px !important;
        font-weight: 950 !important;
    }

    .fr-footer {
        display: none !important;
    }

    /* Bottom nav */
    .fr-bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 80;
        background: rgba(255,255,255,.96);
        backdrop-filter: blur(18px);
        border-top: 1px solid #e8eef6;
        box-shadow: 0 -10px 30px rgba(15,23,42,.08);
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
        display: grid !important;
        grid-template-columns: repeat(5, 1fr);
        gap: 4px;
    }

    .fr-bottom-link {
        min-height: 54px;
        border-radius: 18px;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: #64748b !important;
        font-weight: 900;
        cursor: pointer;
        user-select: none;
    }

    .fr-bottom-link span {
        font-size: 20px;
        line-height: 1;
    }

    .fr-bottom-link small {
        font-size: 11px;
        line-height: 1.1;
    }

    .fr-bottom-link.is-active,
    .fr-bottom-link:hover {
        background: #eef4ff;
        color: #2457e6 !important;
    }

    /* More sheet */
    .fr-more-toggle:checked ~ .fr-more-backdrop {
        display: block !important;
        position: fixed;
        inset: 0;
        z-index: 90;
        background: rgba(15,23,42,.45);
        backdrop-filter: blur(3px);
    }

    .fr-more-toggle:checked ~ .fr-more-sheet {
        display: block !important;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 100;
        background: #fff;
        border-radius: 30px 30px 0 0;
        box-shadow: 0 -24px 60px rgba(15,23,42,.22);
        padding: 12px 18px calc(18px + env(safe-area-inset-bottom));
        max-height: 78vh;
        overflow-y: auto;
        animation: frSheetUp .18s ease-out;
    }

    @keyframes frSheetUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    .fr-sheet-handle {
        width: 54px;
        height: 5px;
        background: #d1d5db;
        border-radius: 999px;
        margin: 4px auto 14px;
    }

    .fr-sheet-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 14px;
    }

    .fr-sheet-head strong {
        display: block;
        font-size: 22px;
        font-weight: 950;
        color: #111827;
    }

    .fr-sheet-head span {
        display: block;
        font-size: 13px;
        color: #64748b;
        margin-top: 3px;
    }

    .fr-close-sheet {
        width: 42px;
        height: 42px;
        border-radius: 16px;
        background: #f1f5f9;
        color: #111827;
        font-size: 28px;
        line-height: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

    .fr-sheet-links {
        display: grid;
        gap: 10px;
    }

    .fr-sheet-link {
        display: flex !important;
        align-items: center;
        gap: 12px;
        width: 100%;
        padding: 14px;
        border-radius: 20px;
        background: #f8fafc;
        color: #111827 !important;
        font-weight: 950;
        text-align: right;
        border: 1px solid #eef2f7;
    }

    .fr-sheet-link:hover {
        background: #eef4ff;
    }

    .fr-sheet-icon {
        width: 38px;
        height: 38px;
        border-radius: 15px;
        background: #fff;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 6px 14px rgba(15,23,42,.05);
    }

    .fr-sheet-text {
        flex: 1;
    }

    .fr-sheet-link b {
        min-width: 26px;
        height: 24px;
        border-radius: 999px;
        background: #dc2626;
        color: #fff;
        font-size: 12px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0 8px;
    }

    .fr-sheet-logout {
        color: #dc2626 !important;
        background: #fff1f2 !important;
        border: 1px solid #ffe4e6 !important;
    }

    /* Tables as cards */
    table.fr-responsive-table,
    table.fr-responsive-table thead,
    table.fr-responsive-table tbody,
    table.fr-responsive-table th,
    table.fr-responsive-table td,
    table.fr-responsive-table tr {
        display: block !important;
        width: 100% !important;
    }

    table.fr-responsive-table {
        min-width: 0 !important;
        border: 0 !important;
        background: transparent !important;
    }

    table.fr-responsive-table thead {
        display: none !important;
    }

    table.fr-responsive-table tbody tr {
        background: #fff !important;
        margin-bottom: 12px !important;
        border: 1px solid #e8eef6 !important;
        border-radius: 22px !important;
        padding: 12px 14px !important;
        box-shadow: 0 10px 24px rgba(15,23,42,.045) !important;
    }

    table.fr-responsive-table td {
        border: 0 !important;
        padding: 9px 0 !important;
        display: flex !important;
        justify-content: space-between !important;
        gap: 12px !important;
        text-align: left !important;
        font-size: 13px !important;
        word-break: break-word !important;
    }

    table.fr-responsive-table td::before {
        content: attr(data-label);
        color: #64748b;
        font-weight: 950;
        text-align: right;
        min-width: 90px;
    }
}

@media (max-width: 430px) {
    .fr-mobile-brand {
        font-size: 26px;
    }

    .fr-mobile-brand span {
        font-size: 11px;
    }

    .fr-icon-button {
        width: 42px;
        height: 42px;
    }

    .fr-bottom-link small {
        font-size: 10px;
    }
}
