/* Peryahan Dashboard — Velzon-inspired shell */
:root {
    --py-font: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
    --py-primary: #405189;
    --py-primary-rgb: 64, 81, 137;
    --py-primary-dark: #364574;
    --py-accent: #f7b84b;
    --py-success: #0ab39c;
    --py-success-rgb: 10, 179, 156;
    --py-danger: #f06548;
    --py-warning: #f7b84b;
    --py-info: #299cdb;
    --py-sidebar-bg: #1a1d29;
    --py-sidebar-width: 260px;
    --py-topbar-h: 70px;
    --py-radius: 12px;
    --py-radius-sm: 8px;
    --py-body: #f3f6f9;
    --py-text: #212529;
    --py-muted: #878a99;
    --py-border: #e9ebec;
    --py-shadow: 0 1px 2px rgba(56, 65, 74, .15);
    --py-shadow-hover: 0 8px 24px rgba(56, 65, 74, .12);

    --bs-primary: #405189;
    --bs-primary-rgb: 64, 81, 137;
    --bs-success: #0ab39c;
    --bs-success-rgb: 10, 179, 156;
    --bs-danger: #f06548;
    --bs-danger-rgb: 240, 101, 72;
    --bs-warning: #f7b84b;
    --bs-warning-rgb: 247, 184, 75;
    --bs-info: #299cdb;
    --bs-info-rgb: 41, 156, 219;
    --bs-body-font-family: var(--py-font);
    --bs-border-radius: 8px;
    --bs-border-color: #e9ebec;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    background: var(--py-body);
    margin: 0;
    font-family: var(--py-font);
    color: var(--py-text);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--py-primary); text-decoration: none; }
a:hover { color: var(--py-primary-dark); }

#layout-wrapper { min-height: 100vh; }

/* ---------- Topbar ---------- */
#page-topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--py-sidebar-width);
    height: var(--py-topbar-h);
    background: #fff;
    z-index: 1002;
    border-bottom: 1px solid var(--py-border);
    box-shadow: 0 1px 0 rgba(56, 65, 74, .04);
    transition: left .2s ease;
}
.navbar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: var(--py-topbar-h);
    padding: 0 1.5rem;
    gap: 1rem;
}
.topnav-hamburger {
    width: 40px;
    height: 40px;
    border: 0;
    background: #f3f6f9;
    color: var(--py-primary);
    border-radius: var(--py-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}
.topnav-hamburger:hover { background: #e9ecef; }
.topbar-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--py-text);
    margin: 0;
}
.topbar-meta {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.topbar-clock {
    display: flex;
    align-items: center;
    gap: .4rem;
    color: var(--py-muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    padding: .4rem .7rem;
    background: #f3f6f9;
    border-radius: 999px;
}
.topbar-clock i { color: var(--py-primary); }
.user-chip {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .25rem .25rem .25rem .35rem;
}
.user-chip-text { line-height: 1.2; text-align: right; }
.user-chip-name { display: block; font-size: 13px; font-weight: 600; color: var(--py-text); }
.user-chip-role { display: block; font-size: 11px; color: var(--py-muted); text-transform: capitalize; }
.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--py-primary), #5b73e8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: .02em;
}
.btn-logout {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--py-border);
    background: #fff;
    color: var(--py-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
}
.btn-logout:hover { color: var(--py-danger); border-color: #fde8e4; background: #fff5f3; }

/* ---------- Sidebar ---------- */
.app-menu {
    width: var(--py-sidebar-width);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    background: var(--py-sidebar-bg);
    z-index: 1003;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform .2s ease;
}
.navbar-brand-box {
    height: var(--py-topbar-h);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    flex-shrink: 0;
}
.logo {
    display: flex;
    align-items: center;
    gap: .7rem;
    color: #fff !important;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: .04em;
}
.logo-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--py-accent), #f06548);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a1d29;
    font-size: 1.15rem;
    box-shadow: 0 6px 16px rgba(247, 184, 75, .28);
}
.logo-text { font-size: 15px; line-height: 1.15; }
.logo-text small {
    display: block;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: .12em;
    color: #878a99;
    text-transform: uppercase;
}
#scrollbar {
    flex: 1;
    overflow-y: auto;
    padding: .75rem 0 1.25rem;
}
#scrollbar::-webkit-scrollbar { width: 4px; }
#scrollbar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

.navbar-nav { list-style: none; padding: 0; margin: 0; }
.menu-title {
    padding: .85rem 1.35rem .3rem;
    font-size: 11px;
    text-transform: uppercase;
    color: #6c7293;
    letter-spacing: .08em;
    font-weight: 600;
}
.nav-item { margin: 1px .75rem; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: #a3aed0;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 8px;
    transition: background .15s, color .15s;
}
.nav-link i { font-size: 1.15rem; width: 1.25rem; text-align: center; }
.nav-link:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.nav-link.active {
    color: #fff;
    background: #405189;
    box-shadow: inset 3px 0 0 var(--py-accent);
}

.sidebar-foot {
    padding: .9rem 1rem 1.1rem;
    border-top: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}
.sidebar-foot-hint {
    font-size: 11px;
    color: #6c7293;
    margin: 0;
}

.vertical-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 1002;
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s;
}

/* ---------- Main ---------- */
.main-content {
    margin-left: var(--py-sidebar-width);
    padding-top: var(--py-topbar-h);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left .2s ease;
}
.page-content { padding: 1.5rem 1.5rem 2rem; flex: 1; }
.footer {
    padding: .9rem 1.5rem;
    color: var(--py-muted);
    font-size: 12.5px;
    border-top: 1px solid var(--py-border);
    background: #fff;
}

/* ---------- Page header ---------- */
.page-title-box {
    margin-bottom: 1.35rem;
}
.page-title-box h4,
.page-title {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -.02em;
    margin: 0;
    color: #212529;
}
.page-subtitle {
    color: var(--py-muted);
    font-size: 13px;
    margin: .2rem 0 0;
}
.breadcrumb {
    margin: 0 0 .35rem;
    font-size: 12.5px;
    background: none;
    padding: 0;
}
.breadcrumb-item + .breadcrumb-item::before { color: #adb5bd; }
.live-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--py-success);
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(10, 179, 156, .6);
    animation: pulse-live 1.8s infinite;
    margin-right: .45rem;
    vertical-align: middle;
}
@keyframes pulse-live {
    0% { box-shadow: 0 0 0 0 rgba(10, 179, 156, .55); }
    70% { box-shadow: 0 0 0 8px rgba(10, 179, 156, 0); }
    100% { box-shadow: 0 0 0 0 rgba(10, 179, 156, 0); }
}

/* ---------- Cards ---------- */
.card {
    border: 0;
    box-shadow: var(--py-shadow);
    border-radius: var(--py-radius);
    margin-bottom: 1.5rem;
    background: #fff;
}
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--py-border);
    padding: .95rem 1.15rem;
    border-radius: var(--py-radius) var(--py-radius) 0 0;
}
.card-title {
    font-size: 14.5px;
    font-weight: 650;
    margin: 0;
}
.card-header-action { font-size: 12.5px; font-weight: 600; }
.card-body { padding: 1.15rem; }
.card-animate { transition: transform .2s, box-shadow .2s; }
.card-animate:hover { transform: translateY(-3px); box-shadow: var(--py-shadow-hover); }
.row > [class*="col-"] > .kpi-card { height: calc(100% - 1.5rem); }

/* KPI */
.kpi-card .card-body { padding: 1.15rem 1.2rem; }
.kpi-label {
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--py-muted);
    margin: 0 0 .35rem;
}
.kpi-value, .counter-value {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -.03em;
    margin: 0;
    font-variant-numeric: tabular-nums;
}
.kpi-meta { font-size: 12px; color: var(--py-muted); margin-top: .35rem; }
.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.avatar-sm {
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: .5rem;
    font-size: 1.25rem;
}
.bg-primary-subtle { background-color: rgba(64, 81, 137, .12) !important; }
.bg-success-subtle { background-color: #d1f5ee !important; }
.bg-danger-subtle { background-color: #fde8e4 !important; }
.bg-warning-subtle { background-color: #fef4e4 !important; }
.bg-info-subtle { background-color: #d9f0fb !important; }
.text-primary { color: var(--py-primary) !important; }
.text-success { color: var(--py-success) !important; }
.text-danger { color: var(--py-danger) !important; }
.text-warning { color: #d99a20 !important; }
.text-info { color: var(--py-info) !important; }

.stat-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .75rem;
    margin-bottom: 1.5rem;
}
.stat-chip {
    background: #fff;
    border-radius: var(--py-radius);
    box-shadow: var(--py-shadow);
    padding: .85rem 1rem;
    display: flex;
    align-items: center;
    gap: .75rem;
}
.stat-chip i {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}
.stat-chip strong { display: block; font-size: 1.05rem; line-height: 1.2; }
.stat-chip span { font-size: 12px; color: var(--py-muted); }

/* ---------- Tables ---------- */
.table { --bs-table-hover-bg: #f8f9fb; font-size: 13.5px; }
.table > :not(caption) > * > * { padding: .8rem 1rem; vertical-align: middle; }
.table thead th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--py-muted);
    font-weight: 650;
    background: #f8f9fb !important;
    border-bottom: 1px solid var(--py-border) !important;
    white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover tbody tr { transition: background .12s; }
code {
    font-size: 12px;
    background: #f3f6f9;
    padding: .15rem .4rem;
    border-radius: 4px;
    color: #405189;
}

/* ---------- Badges / status ---------- */
.badge { font-weight: 600; letter-spacing: .02em; padding: .35em .65em; border-radius: 6px; }
.badge-open, .badge-ready { background: #299cdb; color: #fff; }
.badge-in_game, .badge-playing, .badge-betting_open, .badge-betting { background: #0ab39c; color: #fff; }
.badge-offline, .badge-closed, .badge-paused { background: #878a99; color: #fff; }
.badge-created, .badge-betting_closed, .badge-result_pending { background: #f7b84b; color: #1a1d29; }
.badge-calculated, .badge-payout_confirmed { background: #405189; color: #fff; }
.badge-voided, .badge-void_pending_approval { background: #f06548; color: #fff; }

.status-dot {
    width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: .4rem; vertical-align: middle;
}
.status-dot.in_game, .status-dot.open { background: var(--py-success); }
.status-dot.ready { background: var(--py-info); }
.status-dot.offline, .status-dot.closed { background: #adb5bd; }
.status-dot.paused { background: var(--py-warning); }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; font-size: 13px; color: #495057; margin-bottom: .35rem; }
.form-control, .form-select {
    border-color: #ced4da;
    border-radius: var(--py-radius-sm);
    padding: .5rem .75rem;
    font-size: 14px;
}
.form-control:focus, .form-select:focus {
    border-color: #8fa0d4;
    box-shadow: 0 0 0 .2rem rgba(64, 81, 137, .15);
}
.btn {
    font-weight: 600;
    border-radius: var(--py-radius-sm);
    padding: .45rem .9rem;
    font-size: 13.5px;
}
.btn-primary {
    background: var(--py-primary);
    border-color: var(--py-primary);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--py-primary-dark);
    border-color: var(--py-primary-dark);
}
.btn-outline-primary {
    color: var(--py-primary);
    border-color: #c5cbe3;
}
.btn-outline-primary:hover {
    background: var(--py-primary);
    border-color: var(--py-primary);
    color: #fff;
}
.btn-outline-secondary {
    color: #495057;
    border-color: #c5ccd6;
}
.btn-outline-secondary:hover {
    background: #495057;
    border-color: #495057;
    color: #fff;
}
.btn-outline-danger {
    color: var(--py-danger);
    border-color: #f0c2b8;
}
.btn-outline-danger:hover {
    background: var(--py-danger);
    border-color: var(--py-danger);
    color: #fff;
}
.alert {
    border: 0;
    border-radius: var(--py-radius-sm);
    box-shadow: var(--py-shadow);
}

.address-preview {
    background: #f3f6f9;
    border: 1px dashed #c5ccd6;
    border-radius: var(--py-radius-sm);
    padding: .75rem 1rem;
    color: #495057;
    min-height: 2.75rem;
}

/* ---------- Activity / lists ---------- */
.activity-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .8rem 1.15rem;
    border-bottom: 1px solid var(--py-border);
    text-decoration: none;
    color: inherit;
    transition: background .12s;
}
.activity-item:last-child { border-bottom: 0; }
.activity-item:hover { background: #f8f9fb; color: inherit; }
.activity-round {
    width: 38px; height: 38px; border-radius: 10px;
    background: #f3f6f9; color: var(--py-primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.activity-meta { flex: 1; min-width: 0; }
.activity-meta strong { display: block; font-size: 13.5px; }
.activity-meta span { font-size: 12px; color: var(--py-muted); }
.activity-amt { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }

.alert-panel {
    display: flex;
    gap: .85rem;
    align-items: flex-start;
    padding: 1rem;
    background: #fff8e8;
    border: 1px solid #f5e2b8;
    border-radius: 10px;
}
.alert-panel.ok {
    background: #edfaf7;
    border-color: #c6ebe4;
}
.alert-panel i { font-size: 1.35rem; }
.card-footer {
    border-top: 1px solid var(--py-border);
    padding: .85rem 1.15rem;
}

.perm-matrix-wrap {
    overflow: auto;
    max-height: min(70vh, 720px);
}
.perm-matrix thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}
.perm-matrix th.perm-sticky,
.perm-matrix td.perm-sticky {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #fff;
    min-width: 240px;
    text-align: left;
}
.perm-matrix thead th.perm-sticky { z-index: 3; background: #f8f9fb; }
.perm-matrix .perm-group td {
    background: #f3f6f9;
    font-weight: 650;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--py-muted);
    padding: .55rem 1rem;
}
.perm-matrix .perm-group td.perm-sticky { background: #f3f6f9; }
.perm-matrix .form-check-input {
    width: 1.15em;
    height: 1.15em;
    cursor: pointer;
    margin: 0;
}
.perm-matrix .form-check-input:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.empty-state {
    text-align: center;
    padding: 2.25rem 1rem;
    color: var(--py-muted);
}
.empty-state i { font-size: 1.8rem; display: block; margin-bottom: .5rem; opacity: .7; }

.filter-bar {
    background: #fff;
    border-radius: var(--py-radius);
    box-shadow: var(--py-shadow);
    padding: .9rem 1rem;
    margin-bottom: 1.25rem;
}

/* ---------- Auth ---------- */
.auth-page {
    min-height: 100vh;
    background: #0f1220;
    display: flex;
}
.auth-split {
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    min-height: 100vh;
    width: 100%;
}
.auth-hero {
    background:
        radial-gradient(1200px 500px at -10% -20%, rgba(247, 184, 75, .22), transparent 50%),
        radial-gradient(800px 400px at 110% 110%, rgba(64, 81, 137, .55), transparent 45%),
        linear-gradient(160deg, #1a1d29 0%, #2c3250 100%);
    color: #fff;
    padding: 3.5rem 4rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.auth-hero h1 { font-size: 2rem; font-weight: 750; letter-spacing: -.03em; margin: .75rem 0 .5rem; }
.auth-hero p.lead { color: #c5cbe3; font-size: 15px; max-width: 28rem; }
.auth-features { list-style: none; padding: 0; margin: 2rem 0 0; }
.auth-features li {
    display: flex; gap: .7rem; align-items: flex-start;
    margin-bottom: .9rem; color: #d8dcec; font-size: 13.5px;
}
.auth-features i {
    color: var(--py-accent); font-size: 1.15rem; margin-top: 1px;
}
.auth-panel {
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.5rem;
}
.auth-card-inner { width: 100%; max-width: 400px; }
.auth-card-inner h4 { font-weight: 700; }
.auth-brand-mobile { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1199.98px) {
    .stat-strip { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 991.98px) {
    .app-menu { transform: translateX(-100%); }
    #page-topbar, .main-content { left: 0; margin-left: 0; }
    #page-topbar { left: 0; }
    body.sidebar-enable .app-menu { transform: translateX(0); }
    body.sidebar-enable .vertical-overlay {
        opacity: 1;
        visibility: visible;
    }
    .auth-split { grid-template-columns: 1fr; }
    .auth-hero { display: none; }
    .auth-brand-mobile { display: flex; align-items: center; gap: .65rem; margin-bottom: 1.5rem; }
    .auth-page { background: #f3f6f9; }
    .auth-panel { background: transparent; }
    .auth-card-inner {
        background: #fff;
        padding: 1.75rem;
        border-radius: 16px;
        box-shadow: 0 12px 40px rgba(15, 23, 42, .08);
    }
}
@media (max-width: 575.98px) {
    .page-content { padding: 1rem; }
    .stat-strip { grid-template-columns: 1fr 1fr; }
    .kpi-value, .counter-value { font-size: 1.3rem; }
    .navbar-header { padding: 0 1rem; }
    .user-chip-text { display: none; }
    .topbar-clock span { display: none; }
}
