/* Portal premium motions & surfaces */
@keyframes portal-rise {
    from { opacity: 0; transform: translateY(36px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes portal-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes portal-scale {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
@keyframes float-soft {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
@keyframes pulse-line {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
}
@keyframes count-glow {
    from { filter: blur(4px); opacity: 0; }
    to { filter: blur(0); opacity: 1; }
}

.portal-rise { animation: portal-rise 0.85s cubic-bezier(0.22, 1, 0.36, 1) both; }
.portal-rise-1 { animation-delay: 0.08s; }
.portal-rise-2 { animation-delay: 0.16s; }
.portal-rise-3 { animation-delay: 0.24s; }
.portal-rise-4 { animation-delay: 0.32s; }
.portal-rise-5 { animation-delay: 0.4s; }
.portal-scale { animation: portal-scale 0.7s cubic-bezier(0.22, 1, 0.36, 1) both; }
.portal-fade { animation: portal-fade 1s ease both; }

.portal-shell {
    background:
        radial-gradient(ellipse 70% 50% at 100% 0%, rgba(201,162,39,0.06), transparent 50%),
        radial-gradient(ellipse 50% 40% at 0% 100%, rgba(18,42,63,0.08), transparent 45%),
        #F5F2EB;
}

.portal-sidebar {
    background:
        linear-gradient(180deg, rgba(6,16,24,0.55), rgba(6,16,24,0.92)),
        url('https://images.unsplash.com/photo-1518709268805-4e9042af9f23?auto=format&fit=crop&w=800&q=70') center/cover;
}

.portal-nav-link {
    position: relative;
    transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease;
}
.portal-nav-link:hover { transform: translateX(4px); }
.portal-nav-link.active {
    background: linear-gradient(90deg, rgba(201,162,39,0.22), transparent);
    color: #E8C547;
}
.portal-nav-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 3px;
    background: #C9A227;
}

.portal-hero {
    position: relative;
    overflow: hidden;
    background: #0B1D2E;
    min-height: 0;
}
@media (min-width: 1024px) {
    .portal-hero { min-height: 280px; }
}
.portal-hero-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    background-size: cover;
    background-position: center;
    opacity: 0.45;
    transform: scale(1.05);
    animation: portal-fade 1.4s ease both;
    pointer-events: none;
}
.portal-hero-avatar-wrap {
    position: relative;
    z-index: 5;
    flex-shrink: 0;
}
.portal-hero-avatar-wrap .portal-hero-avatar,
.portal-hero-avatar-wrap .portal-hero-avatar-fallback {
    display: block;
    position: relative !important;
    inset: auto !important;
    width: 5rem !important;
    height: 5rem !important;
    max-width: none;
    opacity: 1 !important;
    transform: none !important;
    object-fit: cover;
    border-radius: 0;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
@media (min-width: 640px) {
    .portal-hero-avatar-wrap .portal-hero-avatar,
    .portal-hero-avatar-wrap .portal-hero-avatar-fallback {
        width: 7rem !important;
        height: 7rem !important;
    }
}
.portal-hero-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    font-family: Syne, sans-serif;
    font-weight: 700;
    font-size: 1.75rem;
    color: #E8C547;
}
@media (min-width: 640px) {
    .portal-hero-avatar-fallback { font-size: 2.25rem; }
}
.portal-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(105deg, rgba(6,16,24,0.92) 0%, rgba(11,29,46,0.75) 55%, rgba(11,29,46,0.35) 100%);
    pointer-events: none;
}

.stat-tile {
    position: relative;
    overflow: hidden;
    background: #fff;
    border: 1px solid rgba(226,232,240,0.85);
    transition: transform 0.35s cubic-bezier(0.22,1,0.36,1), box-shadow 0.35s ease, border-color 0.35s ease;
}
.stat-tile-classic {
    padding: 0.7rem 0.85rem;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.stat-tile-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}
.stat-tile-icon-sm { flex-shrink: 0; }
.stat-tile-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(26,58,82,0.5);
    line-height: 1.3;
}
.stat-tile-value {
    font-size: 1.45rem;
    line-height: 1;
    margin-top: auto;
}
.stat-tile:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 40px rgba(6,16,24,0.1);
    border-color: rgba(201,162,39,0.45);
}
@media (hover: none) {
    .stat-tile:hover { transform: none; }
}
.stat-tile::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, #C9A227, transparent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s ease;
}
.stat-tile:hover::after { transform: scaleX(1); }

.glass-panel {
    background: rgba(255,255,255,0.92);
    border: 1px solid rgba(226,232,240,0.9);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 30px rgba(6,16,24,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.glass-panel:hover {
    box-shadow: 0 14px 40px rgba(6,16,24,0.08);
}

.access-stage {
    background:
        radial-gradient(ellipse 60% 50% at 75% 30%, rgba(201,162,39,0.2), transparent 55%),
        radial-gradient(ellipse 40% 35% at 15% 80%, rgba(42,80,112,0.35), transparent 50%),
        linear-gradient(155deg, #061018 0%, #0B1D2E 50%, #122A3F 100%);
}

.access-code-input {
    letter-spacing: 0.18em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    text-transform: uppercase;
    font-size: 1.05rem;
    text-align: center;
    border: 1px solid rgba(201,162,39,0.35);
    background: rgba(255,255,255,0.04);
    color: #fff;
    padding: 1rem 1.25rem;
    width: 100%;
    transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
.access-code-input::placeholder { color: rgba(255,255,255,0.28); letter-spacing: 0.12em; }
.access-code-input:focus {
    outline: none;
    border-color: #C9A227;
    background: rgba(255,255,255,0.07);
    box-shadow: 0 0 0 4px rgba(201,162,39,0.15);
}

.gold-shimmer {
    background: linear-gradient(90deg, #A6841C, #E8C547, #C9A227, #E8C547, #A6841C);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: shimmer 4s linear infinite;
}

.float-badge { animation: float-soft 5s ease-in-out infinite; }

.timeline-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #C9A227;
    box-shadow: 0 0 0 4px rgba(201,162,39,0.2);
}

.motion-line {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(201,162,39,0.7), transparent);
    animation: pulse-line 2.8s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
    .portal-rise, .portal-scale, .portal-fade, .float-badge, .gold-shimmer, .motion-line, .portal-hero-bg {
        animation: none !important;
    }
}

/* Rich detail pages */
.detail-card {
    background: rgba(255,255,255,0.95);
    border: 1px solid rgba(226,232,240,0.9);
    padding: 1rem 1.1rem;
    box-shadow: 0 8px 30px rgba(6,16,24,0.05);
}
.detail-card-title {
    font-family: "Syne", sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.85rem;
    color: #0B1D2E;
}
@media (min-width: 640px) {
    .detail-card { padding: 1.5rem; }
    .detail-card-title { font-size: 1.05rem; margin-bottom: 1rem; }
}

.portal-detail-hero h2,
.portal-detail-hero .font-display {
    word-break: break-word;
    overflow-wrap: anywhere;
}
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.5rem;
    font-size: 0.875rem;
}
.detail-grid dt {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(26,58,82,0.45);
    margin-bottom: 0.25rem;
}
.detail-grid dd { font-weight: 600; color: #0B1D2E; }
.detail-stack { font-size: 0.875rem; }
.detail-stack > div { padding: 0.65rem 0; border-bottom: 1px solid #f1f5f9; }
.detail-stack > div:last-child { border-bottom: 0; }
.detail-stack dt {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(26,58,82,0.45);
    margin-bottom: 0.2rem;
}
.detail-stack dd { font-weight: 600; color: #0B1D2E; }

.payment-row {
    background: #fff;
    border: 1px solid rgba(226,232,240,0.9);
    padding: 1.25rem 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
.payment-row:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 36px rgba(6,16,24,0.08);
    border-color: rgba(201,162,39,0.45);
}
.payment-row-icon {
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(201,162,39,0.15), rgba(11,29,46,0.06));
    color: #A6841C;
}

.contract-card {
    display: block;
    background: #fff;
    border: 1px solid rgba(226,232,240,0.9);
    overflow: hidden;
    transition: transform 0.35s ease, box-shadow 0.35s ease;
}
.contract-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 18px 40px rgba(6,16,24,0.1);
}
.contract-card-media {
    position: relative;
    height: 11rem;
    overflow: hidden;
}
.contract-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}
.contract-card:hover .contract-card-media img { transform: scale(1.06); }
.contract-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(6,16,24,0.92), rgba(6,16,24,0.2));
}

.doc-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid #f1f5f9;
    background: #faf9f6;
    transition: border-color 0.25s ease;
}
.doc-row:hover { border-color: rgba(201,162,39,0.35); }
.doc-row-icon {
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0B1D2E;
    color: #E8C547;
}

.portal-page-hero { padding-bottom: 0.25rem; }

/* Continuous upward-scrolling updates feed */
.updates-roll {
    position: relative;
    overflow: hidden;
}
.updates-roll-mask {
    height: 11.5rem;
    overflow: hidden;
    position: relative;
    mask-image: linear-gradient(to bottom, transparent 0%, #000 10%, #000 90%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 10%, #000 90%, transparent 100%);
}
.updates-roll-track {
    display: flex;
    flex-direction: column;
    animation: updates-roll-up var(--roll-duration, 24s) linear infinite;
    will-change: transform;
}
.updates-roll:hover .updates-roll-track {
    animation-play-state: paused;
}
.updates-roll-group {
    display: flex;
    flex-direction: column;
}
.updates-roll-item {
    padding: 0.85rem 0.9rem 0.95rem;
    border-left: 3px solid #C9A227;
    margin: 0.4rem 0.75rem;
    background: linear-gradient(90deg, rgba(201,162,39,0.06), transparent 55%);
}
.updates-roll-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.65rem;
    margin-bottom: 0.35rem;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(26,58,82,0.45);
}
.updates-roll-title {
    font-family: "Syne", sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    color: #0B1D2E;
    margin-bottom: 0.35rem;
    line-height: 1.25;
}
.updates-roll-body {
    color: #1A3A52;
    line-height: 1.45;
    font-size: 0.8125rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.updates-roll-body p { margin: 0 0 0.5rem; }
.updates-roll-body p:last-child { margin-bottom: 0; }

/* Full page: show complete update text */
.updates-roll--full .updates-roll-mask { height: 18rem; }
.updates-roll--full .updates-roll-body {
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
}

@keyframes updates-roll-up {
    from { transform: translateY(0); }
    to { transform: translateY(-50%); }
}

@media (min-width: 640px) {
    .stat-tile-classic {
        padding: 1.1rem 1.25rem;
        min-height: 7.25rem;
    }
    .stat-tile-head { margin-bottom: 1rem; }
    .stat-tile-label { font-size: 10px; letter-spacing: 0.16em; }
    .stat-tile-value { font-size: 2rem; }

    .updates-roll-mask { height: 16rem; }
    .updates-roll-item { padding: 1rem 1.1rem; margin: 0.5rem 1rem; }
    .updates-roll-title { font-size: 1.05rem; }
    .updates-roll-body {
        font-size: 0.875rem;
        -webkit-line-clamp: 4;
    }
}

@media (max-width: 640px) {
    .detail-grid { grid-template-columns: 1fr; }

    .payment-row { padding: 1rem; }
    .payment-row-icon { width: 2.5rem; height: 2.5rem; }

    .portal-page-hero h2 { font-size: 1.75rem; }

    .updates-roll-mask { height: 12.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    .updates-roll-track { animation: none !important; }
    .updates-roll-mask { overflow-y: auto; height: auto; max-height: 16rem; mask-image: none; -webkit-mask-image: none; }
    .updates-roll-group[aria-hidden="true"] { display: none; }
}

/* ── Operational portal surface ── */
.portal-ops {
    background: #F4F2EC;
}
.ops-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    padding: 0.85rem 1rem;
    background: #fff;
    border: 1px solid #e2e8f0;
}
.ops-kpi {
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 0.7rem 0.85rem;
}
.ops-kpi-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(26,58,82,0.5);
    margin-bottom: 0.25rem;
}
.ops-kpi-value {
    font-family: "Syne", sans-serif;
    font-weight: 800;
    font-size: 1.35rem;
    color: #0B1D2E;
    line-height: 1.15;
}
.ops-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.ops-section-title {
    font-family: "Syne", sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    color: #0B1D2E;
}
.ops-link {
    font-size: 11px;
    font-weight: 700;
    color: #A6841C;
}
.ops-link:hover { color: #C9A227; }
.ops-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
}
.ops-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    transition: background 0.15s;
}
.ops-row:hover { background: #F8F6F1; }
.ops-attention {
    display: grid;
    grid-template-columns: 7.5rem 1fr auto;
    gap: 0.5rem 0.75rem;
    align-items: center;
    padding: 0.7rem 1rem;
    font-size: 0.8125rem;
    transition: background 0.15s;
}
.ops-attention:hover { background: #F8F6F1; }
.ops-attention-label {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.ops-attention-danger .ops-attention-label { color: #be123c; }
.ops-attention-warn .ops-attention-label { color: #b45309; }
.ops-attention-info .ops-attention-label { color: #0369a1; }
.ops-attention-neutral .ops-attention-label { color: #A6841C; }
.ops-attention-text {
    font-weight: 600;
    color: #0B1D2E;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ops-attention-go { color: #94a3b8; font-size: 12px; }
.ops-page-head {
    margin-bottom: 1rem;
}
.ops-page-head h2 {
    font-family: "Syne", sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    color: #0B1D2E;
}
.ops-page-head p {
    font-size: 0.8125rem;
    color: rgba(26,58,82,0.65);
    margin-top: 0.25rem;
}
.ops-back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #A6841C;
    margin-bottom: 0.75rem;
}
.ops-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1rem;
    font-size: 0.8125rem;
}
.ops-meta-grid dt {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(26,58,82,0.45);
    margin-bottom: 0.15rem;
}
.ops-meta-grid dd { font-weight: 600; color: #0B1D2E; }
@media (min-width: 640px) {
    .ops-meta-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .ops-kpi-value { font-size: 1.5rem; }
}
@media (max-width: 640px) {
    .ops-attention {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
    }
    .ops-attention-label { grid-column: 1; }
    .ops-attention-text { grid-column: 1; white-space: normal; }
    .ops-attention-go { grid-row: 1 / span 2; grid-column: 2; align-self: center; }
    .updates-roll-mask { height: 11rem; }
}

/* Document viewer modal (teleported to body via Alpine) */
.doc-viewer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(6, 16, 24, 0.88);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(0.75rem, env(safe-area-inset-top, 0px))
             max(0.75rem, env(safe-area-inset-right, 0px))
             max(0.75rem, env(safe-area-inset-bottom, 0px))
             max(0.75rem, env(safe-area-inset-left, 0px));
}
.doc-viewer-panel {
    width: 100%;
    max-width: 56rem;
    max-height: min(90vh, calc(100dvh - 2rem));
    height: min(90vh, calc(100dvh - 2rem));
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.doc-viewer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    background: #F8F6F1;
    flex-shrink: 0;
}
.doc-viewer-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
}
.doc-viewer-frame {
    width: 100%;
    height: 100%;
    min-height: 16rem;
    border: 0;
    background: #fff;
    display: block;
}
.doc-viewer-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.doc-viewer-fallback {
    text-align: center;
    padding: 2rem 1.5rem;
    max-width: 20rem;
}
.doc-viewer-foot {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 0.875rem 1rem;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    flex-shrink: 0;
}
@media (max-width: 640px) {
    .doc-viewer-backdrop {
        padding: 0;
        align-items: stretch;
    }
    .doc-viewer-panel {
        max-width: none;
        max-height: none;
        height: 100dvh;
        border: 0;
        border-radius: 0;
    }
    .doc-viewer-head {
        padding-top: max(0.875rem, env(safe-area-inset-top, 0px));
    }
    .doc-viewer-foot {
        padding-bottom: max(0.875rem, env(safe-area-inset-bottom, 0px));
        justify-content: stretch;
    }
    .doc-viewer-foot .btn-primary,
    .doc-viewer-foot .btn-secondary {
        flex: 1 1 calc(50% - 0.375rem);
        justify-content: center;
        text-align: center;
    }
}
