:root {
    --portal-navy: #16312c;
    --portal-navy-dark: #0f221f;
    --portal-teal: #0e6f7f;
    --portal-teal-dark: #0b5a67;
    --portal-gold: #c98c17;
    --portal-nav-active: #2e7d7d;
    --portal-nav-active-bg: #e8f4f4;
    --portal-bg: #fcf8ef;
    --portal-card: #ffffff;
    --portal-text: #040404;
    --portal-muted: #737477;
    --portal-border: #f1f1f4;
    --portal-field: #e4e8f3;
    --portal-sidebar-w: 260px;
    --portal-bottom-h: 76px;
}

* { box-sizing: border-box; }

body.portal-body {
    font-family: 'Cairo', system-ui, sans-serif;
    background: var(--portal-bg);
    color: var(--portal-text);
    min-height: 100vh;
}

.portal-sidebar {
    width: var(--portal-sidebar-w);
    background: linear-gradient(180deg, var(--portal-navy) 0%, var(--portal-navy-dark) 100%);
    color: #fff;
    min-height: 100vh;
    position: fixed;
    top: 0;
    bottom: 0;
    z-index: 1040;
    overflow-y: auto;
}

[dir="ltr"] .portal-sidebar { left: 0; }
[dir="rtl"] .portal-sidebar { right: 0; }

.portal-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
}

.portal-brand img { width: 36px; height: 36px; object-fit: contain; }
.portal-brand:hover { color: #fff; }

.portal-nav a {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .7rem 1.25rem;
    color: rgba(255,255,255,.78);
    text-decoration: none;
    font-size: .92rem;
    border-inline-start: 3px solid transparent;
    border-radius: 0;
}

.portal-nav a:hover,
.portal-nav a.active {
    color: #fff;
    background: rgba(255,255,255,.08);
    border-inline-start-color: var(--portal-gold);
}

.portal-nav .nav-section {
    padding: .9rem 1.25rem .3rem;
    font-size: .72rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: rgba(255,255,255,.45);
}

.btn-portal-ghost {
    background: transparent;
    border: 1px solid rgba(255,255,255,.35);
    color: #fff;
    border-radius: 20px;
}

.btn-portal-ghost:hover {
    background: rgba(255,255,255,.1);
    color: #fff;
    border-color: #fff;
}

.portal-main { min-height: 100vh; }

[dir="ltr"] .portal-main { margin-left: var(--portal-sidebar-w); }
[dir="rtl"] .portal-main { margin-right: var(--portal-sidebar-w); }

.portal-topbar {
    background: var(--portal-card);
    border-bottom: 1px solid var(--portal-border);
    padding: .85rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.portal-content { padding: 1.5rem; }

.portal-card {
    background: var(--portal-card);
    border: 1px solid var(--portal-border);
    border-radius: 12px;
    box-shadow: none;
}

.portal-card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--portal-border);
    font-weight: 700;
    padding: 1rem 1.25rem;
}

.portal-body .form-control,
.portal-body .form-select {
    border-radius: 12px;
    min-height: 48px;
    border-color: #e4e0d4;
    background: #fff;
}

.portal-body .form-control:focus,
.portal-body .form-select:focus {
    border-color: var(--portal-teal);
    box-shadow: 0 0 0 .2rem rgba(14, 111, 127, .15);
}

.portal-body .btn {
    border-radius: 20px;
    min-height: 42px;
    padding-inline: 1.15rem;
    font-weight: 600;
}

.portal-body .btn-sm {
    min-height: 34px;
    border-radius: 16px;
    padding-inline: .85rem;
    font-weight: 600;
}

.portal-body .btn-link {
    min-height: auto;
    border-radius: 0;
    font-weight: 600;
}

.btn-portal {
    background: var(--portal-navy);
    border-color: var(--portal-navy);
    color: #fff;
}

.btn-portal:hover,
.btn-portal:focus {
    background: var(--portal-teal);
    border-color: var(--portal-teal);
    color: #fff;
}

.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: linear-gradient(160deg, #16312c 0%, #0e6f7f 100%);
}

.auth-card {
    width: 100%;
    max-width: 480px;
    background: #fff;
    border-radius: 18px;
    padding: 2rem;
    box-shadow: 0 20px 50px rgba(0,0,0,.18);
}

.auth-card.wide { max-width: 640px; }

.stat-tile {
    border-radius: 12px;
    padding: 1.1rem 1.2rem;
    background: #fff;
    border: 1px solid var(--portal-border);
    height: 100%;
}

.stat-tile .label { color: var(--portal-muted); font-size: .85rem; }
.stat-tile .value { font-size: 1.45rem; font-weight: 800; color: var(--portal-navy); }

.badge-pending { background: #fff4d6; color: #8a6d12; }
.badge-accepted, .badge-approved, .badge-resolved { background: #e4f7ec; color: #1b7a43; }
.badge-rejected, .badge-cancelled { background: #fde8e8; color: #b42318; }
.badge-canceled { background: #eee; color: #555; }
.badge-under_review { background: #e8f1fb; color: #185fa5; }

.table-portal thead th {
    font-size: .8rem;
    color: var(--portal-muted);
    font-weight: 700;
    border-bottom-width: 1px;
}

.progress-portal { height: 10px; border-radius: 99px; background: #eee8d8; }
.progress-portal .progress-bar { background: var(--portal-teal); }

.lang-switch a { text-decoration: none; }

.app-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.app-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1px solid var(--portal-border);
    border-radius: 12px;
    padding: 12px 14px;
    text-decoration: none;
    color: inherit;
}

a.app-list-item:hover { background: #fffdf8; color: inherit; }

.app-list-avatar {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--portal-field);
    color: var(--portal-navy);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    flex-shrink: 0;
}

.app-list-body { flex: 1; min-width: 0; }
.app-list-body strong { display: block; font-weight: 600; }
.app-list-meta { color: var(--portal-muted); font-size: .82rem; }
.app-list-actions { display: flex; flex-wrap: wrap; gap: 6px; flex-shrink: 0; }
.app-empty { text-align: center; color: var(--portal-muted); padding: 2rem 1rem; }

.shortcut-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--portal-bg);
    border: 1px solid var(--portal-border);
    border-radius: 12px;
    padding: 16px;
    text-decoration: none;
    color: inherit;
}

.shortcut-card:hover { color: inherit; background: #fff; }

.portal-carousel {
    border-radius: 12px;
    overflow: hidden;
    height: 180px;
}

.portal-carousel .carousel-item,
.portal-carousel img {
    height: 180px;
    object-fit: cover;
    width: 100%;
}

.portal-carousel .carousel-indicators {
    margin-bottom: .4rem;
}

.portal-carousel .carousel-indicators [data-bs-target] {
    width: 6px;
    height: 6px;
    border-radius: 10px;
    border: 0;
    background: #fff;
    opacity: .55;
}

.portal-carousel .carousel-indicators .active {
    width: 18px;
    opacity: 1;
    background: var(--portal-navy);
}

.file-preview {
    border: 1px solid var(--portal-border);
    border-radius: 12px;
    padding: 10px 12px;
    background: #fff;
    margin-top: 8px;
}

.file-preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.file-preview-name {
    font-size: .88rem;
    font-weight: 600;
    word-break: break-all;
}

.file-preview-img {
    display: block;
    max-width: 100%;
    max-height: 320px;
    margin-top: 10px;
    border-radius: 8px;
    object-fit: contain;
    background: var(--portal-bg);
}

.file-preview.is-compact .file-preview-img { max-height: 180px; }

.file-preview-frame {
    width: 100%;
    height: 360px;
    border: 0;
    margin-top: 10px;
    border-radius: 8px;
    background: #f4f4f4;
}

.file-preview.is-compact .file-preview-frame { height: 240px; }

.file-preview-video { margin-top: 10px; border-radius: 8px; max-height: 280px; }

.app-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    border-bottom: 1px solid var(--portal-border);
}

.app-tabs .nav-item { white-space: nowrap; }

.app-tabs .nav-link {
    border: 0;
    color: var(--portal-muted);
    font-weight: 600;
    border-radius: 0;
    padding: .7rem 1rem;
}

.app-tabs .nav-link.active {
    color: var(--portal-navy);
    background: transparent;
    border-bottom: 2px solid var(--portal-navy);
}

.info-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .45rem 0;
    border-bottom: 1px solid var(--portal-border);
    font-size: .92rem;
}

.info-row:last-child { border-bottom: 0; }
.info-row .lbl { color: var(--portal-muted); }
.info-row .val { font-weight: 600; text-align: end; }

.portal-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    background: #fff;
    border-top: 1px solid var(--portal-border);
    display: flex;
    justify-content: space-around;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}

.portal-bottom-nav a,
.portal-bottom-nav button {
    flex: 1;
    background: none;
    border: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: #6c757d;
    text-decoration: none;
    font-size: .72rem;
    font-weight: 600;
    font-family: inherit;
}

.portal-bottom-nav .nav-ico {
    display: inline-flex;
    padding: 8px;
    border-radius: 12px;
    font-size: 1.05rem;
    line-height: 1;
}

.portal-bottom-nav a.active,
.portal-bottom-nav button.active {
    color: var(--portal-nav-active);
}

.portal-bottom-nav a.active .nav-ico,
.portal-bottom-nav button.active .nav-ico {
    background: var(--portal-nav-active-bg);
}

.bottom-badge {
    position: absolute;
    top: 2px;
    inset-inline-end: 0;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 99px;
    background: #ea4124;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 991.98px) {
    .portal-sidebar { display: none; }
    [dir] .portal-main { margin: 0; }
    .portal-content { padding-bottom: calc(var(--portal-bottom-h) + 1.25rem); }
    .portal-sidebar.offcanvas.show,
    .portal-sidebar.offcanvas.showing {
        display: flex;
        flex-direction: column;
        width: min(86vw, 320px);
    }

    .portal-more-drawer {
        background: var(--portal-bg);
        color: var(--portal-text);
    }

    .portal-more-drawer .portal-brand {
        color: var(--portal-navy);
        border-bottom-color: var(--portal-border);
    }

    .portal-more-drawer .portal-brand:hover { color: var(--portal-navy); }

    .portal-more-drawer .portal-nav a {
        color: var(--portal-text);
        background: #fff;
        border: 1px solid var(--portal-border);
        border-radius: 12px;
        margin: 6px 12px;
        border-inline-start: 0;
    }

    .portal-more-drawer .portal-nav a:hover,
    .portal-more-drawer .portal-nav a.active {
        background: var(--portal-nav-active-bg);
        color: var(--portal-nav-active);
    }

    .portal-more-drawer .nav-section {
        color: var(--portal-muted);
    }

    .portal-more-drawer .btn-portal-ghost {
        border-color: var(--portal-navy);
        color: var(--portal-navy);
    }

    .portal-more-drawer .btn-portal-ghost:hover {
        background: var(--portal-navy);
        color: #fff;
    }
}

@media (max-width: 767.98px) {
    .portal-carousel,
    .portal-carousel .carousel-item,
    .portal-carousel img {
        height: 160px;
    }
}
