:root {
    --app-bg: #f4f7fb;
    --app-surface: #ffffff;
    --app-text: #111827;
    --app-muted: #6b7280;
    --app-primary: #0d6efd;
    --app-accent: #16a34a;
    --app-border: rgba(15, 23, 42, .08);
    --app-shadow: 0 14px 35px rgba(15, 23, 42, .08);
    --app-radius: 18px;
    --app-bottom-nav-height: 74px;
}

html {
    scroll-behavior: smooth;
}

body {
    -webkit-tap-highlight-color: transparent;
    background: var(--app-bg);
    color: var(--app-text);
}

.app-mobile-header,
.app-bottom-nav,
.app-fab {
    display: none;
}

.app-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.app-card {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    overflow: hidden;
}

.app-shell {
    background:
        radial-gradient(circle at top left, rgba(13, 110, 253, .08), transparent 32rem),
        linear-gradient(180deg, rgba(255, 255, 255, .65), rgba(244, 247, 251, .92));
}

.app-main {
    min-width: 0;
}

.app-container-readable {
    max-width: 960px;
}

.app-text-narrow {
    max-width: 640px;
}

.app-text-readable {
    max-width: 720px;
}

.app-auth-card {
    max-width: 380px;
    width: 100%;
}

.app-auth-card-wide {
    max-width: 420px;
    width: 100%;
}

.app-desktop-sidebar {
    width: 260px;
}

.app-bottom-nav-count-1 { --app-nav-count: 1; }
.app-bottom-nav-count-2 { --app-nav-count: 2; }
.app-bottom-nav-count-3 { --app-nav-count: 3; }
.app-bottom-nav-count-4 { --app-nav-count: 4; }
.app-bottom-nav-count-5 { --app-nav-count: 5; }
.app-bottom-nav-count-6 { --app-nav-count: 6; }

.app-progress-thin {
    height: 8px;
}

.bg-portal-accent {
    background: var(--portal-accent, var(--app-accent));
}

.app-preview-frame {
    height: 520px;
}

.app-preview-hero {
    height: 120px;
}

.app-logo-preview {
    max-height: 72px;
}

.app-logo-preview-large {
    max-height: 64px;
    max-width: 180px;
    object-fit: contain;
}

.app-sticky-top {
    top: 1rem;
}

.app-pre-wrap {
    white-space: pre-wrap;
}

.app-actions-wide {
    min-width: 360px;
}

.app-actions-wider {
    min-width: 420px;
}

.app-actions-widest {
    min-width: 520px;
}

.card,
.app-card,
.package-card {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: 0 12px 30px rgba(15, 23, 42, .06);
}

.card {
    overflow: hidden;
}

.card-header {
    background: rgba(255, 255, 255, .78);
    border-bottom: 1px solid var(--app-border);
}

.btn {
    border-radius: 14px;
    font-weight: 700;
    min-height: 42px;
}

.btn-sm {
    border-radius: 12px;
    min-height: 34px;
}

.form-control,
.form-select {
    border-color: var(--app-border);
    border-radius: 14px;
    min-height: 42px;
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(13, 110, 253, .45);
    box-shadow: 0 0 0 .2rem rgba(13, 110, 253, .12);
}

.alert {
    border-radius: 16px;
}

.table-responsive {
    border-radius: calc(var(--app-radius) - 4px);
}

.table > :not(caption) > * > * {
    padding: .9rem 1rem;
}

.badge {
    border-radius: 999px;
    font-weight: 700;
    padding: .42rem .64rem;
}

.app-search {
    min-height: 48px;
    border-radius: 999px;
    border: 1px solid var(--app-border);
    background: #fff;
    box-shadow: 0 8px 22px rgba(15, 23, 42, .06);
}

.app-skeleton {
    position: relative;
    overflow: hidden;
    background: #e5e7eb;
}

.app-skeleton::after {
    animation: app-shimmer 1.4s infinite;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent);
    content: "";
    inset: 0;
    position: absolute;
    transform: translateX(-100%);
}

.package-card {
    background: #fff;
}

.package-visual {
    align-items: center;
    aspect-ratio: 16 / 8;
    background: linear-gradient(135deg, var(--portal-primary, var(--app-primary)), var(--portal-accent, var(--app-accent)));
    border-radius: 16px;
    color: #fff;
    display: flex;
    justify-content: space-between;
    margin-bottom: 14px;
    overflow: hidden;
    padding: 16px;
    position: relative;
}

.package-visual::after {
    background: rgba(255, 255, 255, .22);
    border-radius: 999px;
    content: "";
    height: 120px;
    position: absolute;
    right: -38px;
    top: -28px;
    width: 120px;
}

.package-price {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: 0;
}

.package-meta {
    color: var(--app-muted);
    font-size: .88rem;
}

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

@media (max-width: 767.98px) {
    body {
        background: var(--app-bg) !important;
        color: var(--app-text);
        font-size: 15px;
        overflow-x: hidden;
        padding-bottom: calc(var(--app-bottom-nav-height) + env(safe-area-inset-bottom) + 18px);
    }

    .app-desktop-sidebar,
    .portal-nav {
        display: none !important;
    }

    .app-shell {
        display: block !important;
        min-height: 100vh;
    }

    .app-main {
        padding: 82px 14px 22px !important;
        width: 100%;
    }

    .portal-shell.app-main {
        max-width: none;
        padding-inline: 14px !important;
    }

    .app-mobile-header {
        align-items: center;
        backdrop-filter: blur(18px);
        background: rgba(244, 247, 251, .92);
        border-bottom: 1px solid rgba(15, 23, 42, .06);
        display: flex;
        gap: 12px;
        justify-content: space-between;
        left: 0;
        min-height: 64px;
        padding: 10px 14px;
        padding-top: max(10px, env(safe-area-inset-top));
        position: fixed;
        right: 0;
        top: 0;
        z-index: 1040;
    }

    .app-mobile-brand {
        min-width: 0;
    }

    .app-mobile-brand strong {
        display: block;
        font-size: 1rem;
        line-height: 1.1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-mobile-brand span {
        color: var(--app-muted);
        display: block;
        font-size: .76rem;
    }

    .app-header-action {
        align-items: center;
        background: var(--app-surface);
        border: 1px solid var(--app-border);
        border-radius: 999px;
        box-shadow: 0 8px 22px rgba(15, 23, 42, .07);
        color: var(--app-text);
        display: inline-flex;
        height: 44px;
        justify-content: center;
        text-decoration: none;
        width: 44px;
    }

    .app-bottom-nav {
        align-items: center;
        backdrop-filter: blur(20px);
        background: rgba(255, 255, 255, .94);
        border-top: 1px solid rgba(15, 23, 42, .08);
        bottom: 0;
        box-shadow: 0 -10px 30px rgba(15, 23, 42, .08);
        display: grid;
        gap: 2px;
        grid-template-columns: repeat(var(--app-nav-count, 5), 1fr);
        left: 0;
        min-height: var(--app-bottom-nav-height);
        padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
        position: fixed;
        right: 0;
        z-index: 1040;
    }

    .app-bottom-nav a {
        align-items: center;
        border-radius: 16px;
        color: var(--app-muted);
        display: flex;
        flex-direction: column;
        font-size: .68rem;
        font-weight: 600;
        gap: 3px;
        min-height: 56px;
        justify-content: center;
        text-decoration: none;
        transition: background .18s ease, color .18s ease, transform .18s ease;
    }

    .app-bottom-nav a:active {
        transform: scale(.96);
    }

    .app-bottom-nav a.active {
        background: rgba(13, 110, 253, .11);
        color: var(--app-primary);
    }

    .app-fab {
        align-items: center;
        background: var(--app-primary);
        border-radius: 999px;
        bottom: calc(var(--app-bottom-nav-height) + env(safe-area-inset-bottom) + 18px);
        box-shadow: 0 14px 28px rgba(13, 110, 253, .32);
        color: #fff;
        display: inline-flex;
        font-weight: 700;
        gap: 8px;
        min-height: 52px;
        padding: 0 18px;
        position: fixed;
        right: 16px;
        text-decoration: none;
        z-index: 1035;
    }

    .card,
    .app-card,
    .package-card {
        border: 1px solid var(--app-border) !important;
        border-radius: var(--app-radius) !important;
        box-shadow: var(--app-shadow) !important;
    }

    .card-header {
        border-radius: var(--app-radius) var(--app-radius) 0 0 !important;
    }

    .row {
        --bs-gutter-x: .85rem;
        --bs-gutter-y: .85rem;
    }

    .display-6 {
        font-size: 1.65rem;
    }

    h2, .h2 {
        font-size: 1.55rem;
    }

    h3, .h3 {
        font-size: 1.35rem;
    }

    h5, .h5 {
        font-size: 1rem;
    }

    .btn,
    .form-control,
    .form-select {
        min-height: 44px;
    }

    .btn {
        align-items: center;
        border-radius: 14px;
        display: inline-flex;
        font-weight: 700;
        justify-content: center;
        transition: filter .18s ease, transform .18s ease;
    }

    .btn:active {
        transform: scale(.98);
    }

    .form-control,
    .form-select {
        border-radius: 14px;
        font-size: 16px;
    }

    .table-responsive {
        border-radius: var(--app-radius);
    }

    .table {
        min-width: 640px;
    }

    .alert {
        border-radius: 16px;
    }

    .portal-logo {
        max-height: 62px;
    }

    .portal-hero {
        background: linear-gradient(135deg, rgba(13, 110, 253, .12), rgba(25, 135, 84, .10));
        border: 1px solid var(--app-border);
        border-radius: 24px;
        box-shadow: var(--app-shadow);
        padding: 18px;
        text-align: left !important;
    }

    .portal-package-grid {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .portal-package-column {
        width: 100%;
    }

    .package-card {
        border-top: 0 !important;
        transition: transform .18s ease, box-shadow .18s ease;
    }

    .package-card:active {
        transform: translateY(1px) scale(.99);
    }

}

@media (min-width: 768px) {
    body {
        background: var(--app-bg) !important;
    }

    .app-shell {
        gap: 22px;
        padding: 18px;
    }

    .app-desktop-sidebar {
        align-self: flex-start;
        background: rgba(255, 255, 255, .86) !important;
        border: 1px solid var(--app-border);
        border-radius: 24px;
        box-shadow: var(--app-shadow);
        color: var(--app-text) !important;
        max-height: calc(100vh - 36px);
        overflow-y: auto;
        position: sticky;
        top: 18px;
    }

    .app-desktop-sidebar h5 {
        color: var(--app-text);
        font-weight: 800;
        letter-spacing: 0;
    }

    .app-desktop-sidebar a.d-block {
        border-radius: 14px;
        color: var(--app-muted) !important;
        font-weight: 700;
        margin-bottom: 4px;
        padding: 10px 12px !important;
        transition: background .18s ease, color .18s ease, transform .18s ease;
    }

    .app-desktop-sidebar a.d-block:hover {
        background: rgba(13, 110, 253, .07);
        color: var(--app-primary) !important;
        transform: translateX(2px);
    }

    .app-desktop-sidebar a.text-white {
        background: rgba(13, 110, 253, .12);
        color: var(--app-primary) !important;
    }

    .app-desktop-sidebar hr {
        border-color: rgba(15, 23, 42, .12);
    }

    .app-desktop-sidebar .btn-outline-light {
        border-color: rgba(13, 110, 253, .24);
        color: var(--app-primary);
    }

    .app-desktop-sidebar .btn-outline-light:hover {
        background: var(--app-primary);
        color: #fff;
    }

    .app-main {
        background: rgba(255, 255, 255, .58);
        border: 1px solid rgba(255, 255, 255, .72);
        border-radius: 28px;
        box-shadow: 0 18px 45px rgba(15, 23, 42, .06);
        min-height: calc(100vh - 36px);
    }

    .app-main > h2:first-child,
    .app-main > h3:first-child,
    .app-main > .d-flex:first-child h2,
    .app-main > .d-flex:first-child h3 {
        letter-spacing: 0;
    }

    .row {
        --bs-gutter-x: 1rem;
        --bs-gutter-y: 1rem;
    }

    .card:hover {
        box-shadow: 0 18px 42px rgba(15, 23, 42, .08);
    }

    .portal-shell {
        background: rgba(255, 255, 255, .68);
        border: 1px solid var(--app-border);
        border-radius: 28px;
        box-shadow: var(--app-shadow);
        margin-top: 24px;
        padding: 28px !important;
    }

    .portal-nav {
        background: rgba(255, 255, 255, .82);
        border: 1px solid var(--app-border);
        border-radius: 999px;
        box-shadow: 0 10px 24px rgba(15, 23, 42, .05);
        margin-inline: auto;
        max-width: max-content;
        padding: 8px;
    }

    .portal-nav a {
        border-radius: 999px;
        font-weight: 700;
        padding: 8px 14px;
        text-decoration: none;
    }

    .portal-nav a:hover {
        background: rgba(13, 110, 253, .09);
    }

    .portal-hero {
        border: 1px solid var(--app-border);
        border-radius: 24px;
        box-shadow: var(--app-shadow);
        padding: 26px;
    }

    .package-card {
        border-top: 0 !important;
        transition: transform .18s ease, box-shadow .18s ease;
    }

    .package-card:hover {
        transform: translateY(-2px);
    }
}
