:root {
    --bg: #08162f;
    --panel: rgba(14, 34, 66, 0.9);
    --line: rgba(127, 179, 253, 0.25);
    --text: #e8f2ff;
    --muted: #acc6ea;
    --accent: #2fdcaf;
    --blue: #67b0ff;
    --warn: #ffd28c;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Plus Jakarta Sans', Arial, sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 85% 0%, rgba(103, 176, 255, 0.14), transparent 30%), var(--bg);
}

a { color: inherit; }

.container {
    width: min(1140px, calc(100% - 2rem));
    margin: 0 auto;
}

.narrow {
    width: min(780px, calc(100% - 2rem));
    margin: 0 auto;
}

.portal-header {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid var(--line);
    background: rgba(8, 22, 45, 0.9);
    backdrop-filter: blur(10px);
}

.nav-shell {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand-logo {
    width: 168px;
    display: block;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.main-nav a {
    border: 1px solid transparent;
    border-radius: 99px;
    padding: 0.44rem 0.66rem;
    font-size: 0.83rem;
    font-weight: 700;
    color: #d4e5ff;
    text-decoration: none;
}

.main-nav a.active,
.main-nav a:hover {
    border-color: var(--line);
    background: rgba(109, 162, 241, 0.15);
}

.menu-toggle {
    display: none;
    border: 1px solid var(--line);
    background: rgba(17, 40, 76, 0.9);
    color: var(--text);
    border-radius: 10px;
    padding: 0.48rem 0.7rem;
}

.inline-form { margin: 0; }

.section { padding: 1.5rem 0 2rem; }

.section-heading h1 {
    margin: 0;
    font-size: clamp(1.6rem, 3.4vw, 2.2rem);
}

.section-heading p {
    margin: 0.45rem 0 0;
    color: var(--muted);
}

.panel,
.kpi-card,
.card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0.95rem;
    background: var(--panel);
}

.kpi-grid,
.card-grid {
    display: grid;
    gap: 0.8rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.kpi-card h3,
.card h3,
.panel h2 {
    margin: 0;
}

.kpi-card strong {
    margin-top: 0.45rem;
    display: block;
    font-size: 1.3rem;
}

.panel p,
.card p,
.auth-card p {
    color: var(--muted);
    line-height: 1.65;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.auth-card {
    width: min(460px, 100%);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 1rem;
    background: rgba(11, 30, 57, 0.96);
}

.auth-card.wide {
    width: min(760px, 100%);
}

.auth-card h1 {
    margin: 0;
    font-size: 1.5rem;
}

.auth-form {
    margin-top: 0.9rem;
    display: grid;
    gap: 0.6rem;
}

.field {
    display: grid;
    gap: 0.3rem;
}

.field.full { grid-column: 1 / -1; }

.field label {
    font-size: 0.79rem;
    color: #c8dcfa;
    font-weight: 700;
}

.field input,
.field textarea,
.field select {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(8, 24, 47, 0.88);
    color: #edf5ff;
    padding: 0.58rem 0.66rem;
    font-family: inherit;
}

.flash-wrap { margin-top: 0.8rem; }

.flash {
    border-radius: 11px;
    border: 1px solid var(--line);
    padding: 0.62rem 0.72rem;
    font-size: 0.84rem;
    margin-bottom: 0.45rem;
}

.flash.success {
    color: #cdffe8;
    border-color: rgba(47, 220, 175, 0.45);
    background: rgba(47, 220, 175, 0.14);
}

.flash.error {
    color: #ffdfb7;
    border-color: rgba(255, 210, 140, 0.45);
    background: rgba(255, 210, 140, 0.12);
}

.btn {
    border: 1px solid transparent;
    border-radius: 11px;
    padding: 0.56rem 0.8rem;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    text-decoration: none;
}

.btn.btn-primary {
    color: #052140;
    background: linear-gradient(125deg, var(--accent), var(--blue));
}

.btn.btn-soft {
    color: #deebff;
    border-color: var(--line);
    background: rgba(103, 176, 255, 0.14);
}

.btn[disabled] {
    opacity: 0.72;
    cursor: not-allowed;
}

.btn.is-loading::after {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(5, 33, 64, 0.35);
    border-top-color: #052140;
    animation: spin 0.8s linear infinite;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    font-size: 0.74rem;
    font-weight: 700;
}

.badge.ok { color: #ceffe7; }
.badge.warn { color: var(--warn); }

.qris-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.qris-image {
    width: min(170px, 100%);
    border-radius: 12px;
    border: 1px solid var(--line);
    background: white;
    padding: 0.4rem;
}

.table-shell {
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    margin-top: 0.8rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(12, 31, 61, 0.9);
}

th,
td {
    text-align: left;
    padding: 0.72rem 0.84rem;
    border-bottom: 1px solid rgba(130, 182, 255, 0.12);
    font-size: 0.85rem;
}

th {
    background: rgba(23, 49, 90, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.76rem;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
}

.pagination li {
    border: 1px solid var(--line);
    border-radius: 8px;
}

.pagination li > * {
    min-width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #d9e7ff;
}

.helper {
    margin-top: 0.8rem;
    font-size: 0.78rem;
    color: var(--muted);
}

.helper-actions {
    margin-top: 0.85rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.helper-actions .btn {
    min-height: 38px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 980px) {
    .kpi-grid,
    .card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 880px) {
    .menu-toggle { display: inline-flex; }

    .main-nav {
        position: absolute;
        top: calc(100% + 0.4rem);
        left: 1rem;
        right: 1rem;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: rgba(8, 24, 47, 0.98);
        display: none;
        flex-direction: column;
        align-items: stretch;
        padding: 0.6rem;
        gap: 0.45rem;
    }

    .main-nav.open { display: flex; }

    .qris-panel { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 700px) {
    .kpi-grid,
    .card-grid,
    .auth-form {
        grid-template-columns: 1fr;
    }

    .helper-actions {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ============================================================
   PORTAL CHECKOUT PAGE
   ============================================================ */
.checkout-breadcrumb {
    font-size: .8rem;
    color: var(--muted);
    margin-bottom: 1.4rem;
}
.checkout-breadcrumb a { color: var(--accent); text-decoration: none; }
.checkout-breadcrumb a:hover { text-decoration: underline; }

.checkout-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.6rem;
    align-items: start;
}
@media (max-width: 800px) { .checkout-grid { grid-template-columns: 1fr; } }

.checkout-product-card,
.checkout-payment-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 1.6rem;
}

.checkout-product-card h3,
.checkout-payment-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 1rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: .78rem;
}

.checkout-product-img {
    width: 100%;
    max-height: 170px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.checkout-product-name {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 0 .4rem;
}

.checkout-product-desc {
    font-size: .88rem;
    color: var(--muted);
    margin: 0 0 1rem;
    line-height: 1.55;
}

.checkout-price-row {
    display: flex;
    align-items: baseline;
    gap: .5rem;
    margin-bottom: 1rem;
}
.checkout-price-amount {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--accent);
}
.checkout-price-label {
    font-size: .82rem;
    color: var(--muted);
}

.checkout-perks {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: .45rem;
}
.checkout-perks li {
    font-size: .86rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: .5rem;
}
.checkout-perks li::before {
    content: '✓';
    color: var(--accent);
    font-weight: 700;
    flex-shrink: 0;
}

.checkout-qris-box {
    text-align: center;
    margin-bottom: 1.2rem;
}
.checkout-qris-img {
    max-width: 220px;
    border-radius: 10px;
    border: 2px solid var(--line);
}
.checkout-qris-meta {
    font-size: .82rem;
    color: var(--muted);
    margin-top: .5rem;
    line-height: 1.5;
}

.checkout-form { display: flex; flex-direction: column; gap: .9rem; }
.checkout-field { display: flex; flex-direction: column; gap: .3rem; }
.checkout-label { font-size: .84rem; font-weight: 600; }

.checkout-file-input {
    border: 1.5px dashed var(--line);
    border-radius: 8px;
    padding: .65rem .8rem;
    background: transparent;
    color: var(--text);
    font-size: .9rem;
    cursor: pointer;
    transition: border-color .18s;
}
.checkout-file-input:hover { border-color: var(--accent); }

.checkout-submit-btn {
    display: block;
    width: 100%;
    padding: .75rem 1rem;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: opacity .18s;
    text-align: center;
    text-decoration: none;
}
.checkout-submit-btn:hover { opacity: .88; }

.checkout-disclaimer {
    font-size: .76rem;
    color: var(--muted);
    text-align: center;
    margin-top: .5rem;
    line-height: 1.5;
}

.checkout-free-note {
    background: rgba(39,214,164,.1);
    border: 1px solid rgba(39,214,164,.3);
    border-radius: 8px;
    padding: .8rem 1rem;
    font-size: .88rem;
    color: var(--accent);
    margin-bottom: 1rem;
    text-align: center;
}

/* ============================================================
   PORTAL APP SHELL — SIDEBAR LAYOUT (mengganti header-based)
   ============================================================ */

body.portal-app {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: radial-gradient(circle at 80% 0%, rgba(103,176,255,.1), transparent 35%), #060e1f;
}

.portal-shell {
    display: flex;
    min-height: 100vh;
}

/* ── SIDEBAR ── */
.portal-sidebar {
    width: 255px;
    min-height: 100vh;
    background: rgba(6, 18, 40, 0.98);
    border-right: 1px solid rgba(127,179,253,.18);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
    transition: transform .25s;
    scrollbar-width: thin;
    scrollbar-color: rgba(127,179,253,.2) transparent;
}
.portal-sidebar::-webkit-scrollbar { width: 4px; }
.portal-sidebar::-webkit-scrollbar-thumb { background: rgba(127,179,253,.2); border-radius: 99px; }

.portal-sidebar-header {
    padding: 1.1rem 1rem .75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(127,179,253,.12);
}
.portal-sidebar-logo { width: 130px; display: block; }
.portal-sidebar-close {
    display: none;
    background: none; border: none; color: rgba(200,220,255,.5); cursor: pointer; font-size: 1.1rem; padding: .2rem;
}

.portal-sidebar-user {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .9rem 1rem;
    border-bottom: 1px solid rgba(127,179,253,.12);
}
.portal-sidebar-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--blue));
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: .9rem; color: #062140;
    flex-shrink: 0;
}
.portal-sidebar-name {
    font-size: .84rem; font-weight: 700; margin: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.portal-sidebar-school {
    font-size: .73rem; color: rgba(172,198,234,.65); margin: .15rem 0 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.portal-sidebar-nav {
    flex: 1;
    padding: .6rem .6rem 0;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.portal-nav-section {
    padding: .75rem .5rem .25rem;
}
.portal-nav-section span {
    font-size: .67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: rgba(172,198,234,.45);
}

.portal-nav-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .7rem;
    border-radius: 9px;
    font-size: .84rem;
    font-weight: 600;
    color: rgba(200,220,255,.8);
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: background .15s, color .15s;
}
.portal-nav-item:hover {
    background: rgba(103,176,255,.12);
    color: #e8f4ff;
}
.portal-nav-item.active {
    background: rgba(47,220,175,.12);
    color: var(--accent);
}
.portal-nav-item.danger { color: rgba(255,130,130,.75); }
.portal-nav-item.danger:hover { background: rgba(255,100,100,.1); color: #ff9090; }
.portal-nav-icon {
    width: 18px; height: 18px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
}
.portal-nav-icon svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.8; fill: none; }

.portal-sidebar-footer {
    padding: .5rem .6rem .8rem;
    border-top: 1px solid rgba(127,179,253,.12);
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

/* ── MAIN ── */
.portal-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.portal-topbar {
    position: sticky;
    top: 0;
    z-index: 15;
    background: rgba(6,16,38,.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(127,179,253,.18);
    padding: 0 1.4rem;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.portal-menu-toggle {
    display: none;
    background: none; border: 1px solid rgba(127,179,253,.25); border-radius: 8px;
    color: rgba(200,220,255,.8); cursor: pointer; padding: .4rem .5rem; flex-shrink: 0;
}
.portal-topbar-title {
    flex: 1;
    font-size: .9rem;
    font-weight: 700;
    color: rgba(200,220,255,.75);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.portal-topbar-user {
    display: flex; align-items: center; gap: .5rem;
    font-size: .82rem; font-weight: 600; color: rgba(200,220,255,.8); flex-shrink: 0;
}
.portal-topbar-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--blue));
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: .78rem; color: #062140;
}

.portal-content-area {
    flex: 1;
    padding: 1.5rem 1.6rem 2.5rem;
}

.portal-alert {
    border-radius: 10px;
    padding: .65rem .85rem;
    font-size: .85rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}
.portal-alert.ok   { background: rgba(47,220,175,.1); border-color: rgba(47,220,175,.3); color: #a8fce2; }
.portal-alert.warn { background: rgba(255,210,140,.08); border-color: rgba(255,210,140,.3); color: #ffe0a8; }

/* Mobile overlay */
.portal-overlay {
    position: fixed; inset: 0; z-index: 49;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(2px);
}

/* ── CONTENT SECTIONS ── */
.portal-page-head {
    margin-bottom: 1.4rem;
}
.portal-page-head h1 {
    margin: 0 0 .3rem;
    font-size: clamp(1.3rem, 3vw, 1.8rem);
    font-weight: 800;
}
.portal-page-head p { margin: 0; color: var(--muted); font-size: .88rem; }

.portal-kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.4rem;
}
.portal-kpi-card {
    background: rgba(14,34,66,.85);
    border: 1px solid rgba(127,179,253,.2);
    border-radius: 12px;
    padding: 1rem 1.1rem;
}
.portal-kpi-card h3 { margin: 0; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.portal-kpi-card .kpi-val { display: block; font-size: 1.8rem; font-weight: 900; margin-top: .3rem; color: var(--accent); }

.portal-card {
    background: rgba(14,34,66,.85);
    border: 1px solid rgba(127,179,253,.2);
    border-radius: 12px;
    padding: 1.1rem 1.2rem;
}
.portal-card + .portal-card { margin-top: 1rem; }
.portal-card h2 { margin: 0 0 .8rem; font-size: 1rem; font-weight: 700; }
.portal-card p { color: var(--muted); font-size: .88rem; line-height: 1.6; margin: 0 0 .5rem; }

.portal-table-shell {
    border: 1px solid rgba(127,179,253,.18);
    border-radius: 12px;
    overflow: hidden;
}
.portal-table-shell table { width: 100%; border-collapse: collapse; }
.portal-table-shell th {
    background: rgba(18,42,80,.9); padding: .7rem .9rem;
    font-size: .71rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
    color: rgba(172,198,234,.7); border-bottom: 1px solid rgba(127,179,253,.18); text-align: left;
}
.portal-table-shell td {
    padding: .72rem .9rem; font-size: .84rem;
    border-bottom: 1px solid rgba(127,179,253,.09);
    vertical-align: middle;
}
.portal-table-shell tr:last-child td { border-bottom: none; }
.portal-table-shell tr:hover td { background: rgba(103,176,255,.04); }

.portal-badge {
    display: inline-flex; align-items: center;
    padding: .22rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 700;
}
.portal-badge.ok    { background: rgba(47,220,175,.12); color: #5fffce; border: 1px solid rgba(47,220,175,.25); }
.portal-badge.warn  { background: rgba(255,210,140,.1);  color: #ffda8a; border: 1px solid rgba(255,210,140,.25); }
.portal-badge.info  { background: rgba(103,176,255,.1);  color: #8ecfff; border: 1px solid rgba(103,176,255,.25); }

.portal-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.1rem;
}
.portal-product-card {
    background: rgba(14,34,66,.85);
    border: 1px solid rgba(127,179,253,.2);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.portal-product-img {
    width: 100%; height: 140px; object-fit: cover;
    border-bottom: 1px solid rgba(127,179,253,.12);
}
.portal-product-img-placeholder {
    height: 140px; display: flex; align-items: center; justify-content: center;
    background: rgba(18,42,80,.6); font-size: .85rem; color: rgba(172,198,234,.5);
    border-bottom: 1px solid rgba(127,179,253,.12);
}
.portal-product-body { padding: 1rem; flex: 1; display: flex; flex-direction: column; gap: .5rem; }
.portal-product-name { font-size: 1rem; font-weight: 700; margin: 0; }
.portal-product-desc { font-size: .82rem; color: var(--muted); margin: 0; line-height: 1.5; }
.portal-product-price { font-size: 1.1rem; font-weight: 800; color: var(--accent); }
.portal-product-price.free { color: #4ade80; }
.portal-product-actions { padding: 0 1rem 1rem; display: flex; flex-direction: column; gap: .45rem; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
    .portal-menu-toggle { display: inline-flex; }
    .portal-sidebar {
        position: fixed; top: 0; left: 0; z-index: 50; height: 100vh;
        transform: translateX(-100%);
    }
    .portal-sidebar.open { transform: translateX(0); }
    .portal-sidebar-close { display: block; }
    .portal-kpi-grid { grid-template-columns: 1fr 1fr; }
    .portal-content-area { padding: 1rem; }
}
@media (max-width: 560px) {
    .portal-kpi-grid { grid-template-columns: 1fr; }
    .portal-product-grid { grid-template-columns: 1fr; }
}
