:root {
    --primary: #1565C0;
    --primary-dark: #0D47A1;
    --primary-darker: #1A237E;
    --primary-light: #42A5F5;
    --primary-bg: #E3F2FD;
    --primary-bg-alt: #BBDEFB;
    /* aliases (legacy) */
    --primary-blue: #1565C0;
    --primary-blue-light: #42A5F5;
    --primary-blue-dark: #0D47A1;
    --border-color: #E0E6ED;
    --bg-light: #F0F4F8;
    --body-bg: #F0F4F8;
    --card-bg: #FFFFFF;
    --text-dark: #263238;
    --text-muted: #78909C;
    --text-light: #B0BEC5;
    --border: #E0E6ED;
    --danger: #E53935;
    --success: #43A047;
    --warning: #FB8C00;
    --info: #039BE5;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --sidebar-width: 260px;
    --navbar-height: 64px;
    --transition: all 0.25s ease;
}

body {
    font-family: 'Plus Jakarta Sans', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    background-color: var(--body-bg);
    margin: 0;
    color: var(--text-dark);
}

* { box-sizing: border-box; transition: var(--transition); }
button, a, input, select, textarea { transition: var(--transition); }

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--primary-darker) 0%, var(--primary-dark) 100%);
    color: #fff;
    z-index: 1040;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.sidebar-brand-title { font-size: 1.1rem; font-weight: 800; line-height: 1.2; }
.sidebar-brand-sub { font-size: 0.7rem; opacity: 0.75; letter-spacing: 0.04em; }

.sidebar-menu {
    list-style: none;
    padding: 0.75rem 0;
    margin: 0;
}

.sidebar-menu-label {
    padding: 0.75rem 1.5rem 0.35rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
}

.sidebar-menu-item a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.5rem;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.sidebar-menu-item a:hover,
.sidebar-menu-item a.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.sidebar-menu-item a i {
    width: 20px;
    text-align: center;
}

/* Main content */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top navbar */
.top-navbar {
    height: var(--navbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.top-navbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--primary-blue);
    cursor: pointer;
}

.top-navbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.navbar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-blue-light);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Page content */
.page-content {
    flex: 1;
    padding: 1.5rem;
}

/* Footer */
.admin-footer {
    padding: 1rem 1.5rem;
    background: #fff;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Stat cards */
.stat-card {
    background: #fff;
    border-radius: var(--radius-md);
    padding: 1.25rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    color: #fff;
}

.stat-card-icon.blue { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.stat-card-icon.green { background: var(--success); }
.stat-card-icon.orange { background: var(--warning); }
.stat-card-icon.red { background: var(--danger); }
.stat-card-icon.cyan { background: var(--info); }

.stat-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Page header */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-blue);
    margin: 0;
}

.page-header-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0.25rem 0 0;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.status-badge.active,
.status-badge.paid,
.status-badge.completed,
.status-badge.approved {
    background: #dcfce7;
    color: #166534;
}

.status-badge.inactive,
.status-badge.cancelled,
.status-badge.rejected {
    background: #fee2e2;
    color: #991b1b;
}

.status-badge.pending,
.status-badge.open,
.status-badge.draft {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.partial,
.status-badge.processing {
    background: #dbeafe;
    color: #1e40af;
}

/* Cards */
.content-card {
    background: #fff;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.content-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.content-card-body {
    padding: 1.25rem;
}

/* Breadcrumb */
.breadcrumb {
    margin-bottom: 0;
    font-size: 0.85rem;
}

.breadcrumb-item a {
    color: var(--primary-blue-light);
    text-decoration: none;
}

/* Buttons */
.btn-primary {
    background-color: var(--primary-blue-light);
    border-color: var(--primary-blue-light);
}

.btn-primary:hover {
    background-color: var(--primary-blue-dark);
    border-color: var(--primary-blue-dark);
}

/* POS layout */
.pos-container {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1rem;
    min-height: calc(100vh - var(--navbar-height) - 3rem);
}

.pos-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

.pos-product-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.pos-product-card:hover {
    border-color: var(--primary-blue-light);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

.pos-cart-sidebar {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    height: fit-content;
    position: sticky;
    top: calc(var(--navbar-height) + 1rem);
}

.pos-cart-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

.pos-cart-body {
    padding: 1rem;
    flex: 1;
    max-height: 400px;
    overflow-y: auto;
}

.pos-cart-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Login page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, var(--primary-darker) 0%, var(--primary) 45%, var(--primary-light) 100%);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 480px;
    height: 480px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    top: -120px;
    right: -120px;
}

.login-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
    position: relative;
    z-index: 1;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo i {
    font-size: 3rem;
    color: var(--primary-blue-light);
}

.login-logo h1 {
    font-size: 1.5rem;
    color: var(--primary-blue);
    margin: 0.5rem 0 0;
}

/* Chart placeholder */
.chart-placeholder {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    border-radius: 0.5rem;
    color: var(--text-muted);
}

/* Responsive */
.sidebar-menu-item.has-submenu > a { justify-content: flex-start; }
.submenu-arrow { font-size: 0.7rem; opacity: 0.7; transition: transform 0.2s; }
.sidebar-menu-item.has-submenu > a:not(.collapsed) .submenu-arrow { transform: rotate(180deg); }
.sidebar-submenu { list-style: none; padding: 0; margin: 0; background: rgba(0,0,0,0.15); }
.sidebar-submenu li a { display: block; padding: 0.5rem 1.5rem 0.5rem 3rem; color: rgba(255,255,255,0.75); text-decoration: none; font-size: 0.85rem; }
.sidebar-submenu li a:hover, .sidebar-submenu li a.active { background: rgba(255,255,255,0.1); color: #fff; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1035; }
body.sidebar-open .sidebar-overlay { display: block; }
.navbar-user-name { font-weight: 600; font-size: 0.9rem; line-height: 1.2; }
.report-icon { width: 64px; height: 64px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.bg-primary-soft { background: #E3F2FD; }
.bg-success-soft { background: #E8F5E9; }
.bg-info-soft { background: #E0F7FA; }
.bg-warning-soft { background: #FFF3E0; }
.bg-danger-soft { background: #FFEBEE; }
.page-header-title { font-size: 1.5rem; font-weight: 700; color: var(--primary-dark); margin: 0; }
.page-header-subtitle { color: var(--text-muted); margin: 0.25rem 0 0; }

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .pos-container {
        grid-template-columns: 1fr;
    }
}

/* Portal & Coach channels */
.portal-nav, .coach-nav { background: linear-gradient(135deg, var(--primary-darker), var(--primary)); padding: 12px 0; }
.portal-body, .coach-body { background: var(--body-bg); min-height: 100vh; padding-bottom: 70px; }
.portal-bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card-bg); border-top: 1px solid var(--border); display: flex; justify-content: space-around; padding: 8px 0; z-index: 1000; box-shadow: var(--shadow-md); }
.portal-bottom-nav a { text-align: center; color: var(--text-muted); text-decoration: none; font-size: 11px; padding: 4px 8px; }
.portal-bottom-nav a.active { color: var(--primary); }
.portal-bottom-nav i { display: block; font-size: 18px; margin-bottom: 2px; }
.coach-tabs { display: flex; overflow-x: auto; background: var(--card-bg); border-bottom: 1px solid var(--border); }
.coach-tabs a { flex: 1; text-align: center; padding: 12px 8px; color: var(--text-muted); text-decoration: none; font-size: 12px; white-space: nowrap; }
.coach-tabs a.active { color: var(--primary); border-bottom: 3px solid var(--primary); }
.coach-touch-card { min-height: 120px; }
.coach-check-card { display: block; background: var(--card-bg); border: 2px solid var(--border); border-radius: var(--radius-md); padding: 16px; text-align: center; cursor: pointer; min-height: 60px; }
.coach-check-card:has(input:checked) { border-color: var(--primary); background: var(--primary-bg); }
.coach-check-card input { display: none; }

.card-custom { background: var(--card-bg); border: none; border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.card-custom:hover { box-shadow: var(--shadow-md); }
.card-header-custom { padding: 16px 20px; border-bottom: 1px solid var(--border); font-size: 15px; font-weight: 700; background: var(--card-bg); border-radius: var(--radius-md) var(--radius-md) 0 0; }

.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); border: none; font-weight: 600; border-radius: var(--radius-sm); box-shadow: 0 4px 12px rgba(21,101,192,0.3); }
.btn-primary:hover { transform: translateY(-1px); background: linear-gradient(135deg, var(--primary-dark), var(--primary-darker)); }
.btn-success { background: linear-gradient(135deg, #43A047, #2E7D32); border: none; font-weight: 600; box-shadow: 0 4px 12px rgba(67,160,71,0.3); }
.btn-danger { background: linear-gradient(135deg, #E53935, #C62828); border: none; font-weight: 600; }

.badge-soft-success, .status-badge.lunas, .status-badge.aktif, .status-badge.hadir, .status-badge.passed, .status-badge.paid { background: #E8F5E9; color: #2E7D32; }
.badge-soft-warning, .status-badge.belum, .status-badge.pending { background: #FFF3E0; color: #E65100; }
.badge-soft-info, .status-badge.sebagian { background: #E3F2FD; color: #1565C0; }
.badge-soft-danger, .status-badge.batal, .status-badge.alpha { background: #FFEBEE; color: #C62828; }

.stat-card-gradient { border-radius: var(--radius-md); padding: 20px; color: #fff; position: relative; overflow: hidden; }
.stat-card-gradient.primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.stat-card-gradient.success { background: linear-gradient(135deg, #43A047, #2E7D32); }
.stat-card-gradient.warning { background: linear-gradient(135deg, #FB8C00, #EF6C00); }
.stat-card-gradient.danger { background: linear-gradient(135deg, #E53935, #C62828); }
.stat-card-gradient .stat-value { font-size: 28px; font-weight: 800; }
.stat-card-gradient:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.datatable thead th { background: var(--primary-bg) !important; color: var(--primary-dark) !important; text-transform: uppercase; font-size: 13px; letter-spacing: 0.5px; border-bottom: 2px solid var(--primary-bg-alt) !important; }
.table-striped > tbody > tr:nth-of-type(odd) > * { background-color: #FAFCFF; }
.table-hover > tbody > tr:hover > * { background-color: #F5F9FF !important; }

.form-control, .form-select { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; }
.form-control:focus, .form-select:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(21,101,192,0.12); }

.fade-in { animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.module-tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.module-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 16px 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: #fff;
    text-decoration: none;
    color: var(--text-dark);
    box-shadow: var(--shadow-sm);
}

.module-tile:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
    color: var(--primary-dark);
}

.module-tile-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
}

.module-tile-primary .module-tile-icon { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.module-tile-success .module-tile-icon { background: linear-gradient(135deg, #43A047, #2E7D32); }
.module-tile-warning .module-tile-icon { background: linear-gradient(135deg, #FB8C00, #EF6C00); }
.module-tile-danger .module-tile-icon { background: linear-gradient(135deg, #E53935, #C62828); }
.module-tile-info .module-tile-icon { background: linear-gradient(135deg, #039BE5, #0277BD); }

.module-tile-title { font-size: 0.78rem; font-weight: 700; line-height: 1.3; }

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.module-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: #fff;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-sm);
}

.module-card:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.module-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary-bg);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.module-card-title { font-weight: 700; font-size: 0.95rem; }
.module-card-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.module-card-arrow { margin-left: auto; color: var(--text-muted); font-size: 0.85rem; }
.module-group-title { font-weight: 800; color: var(--primary-dark); margin-bottom: 12px; }

.list-panel-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.list-panel-item:last-child { border-bottom: none; }

.empty-state-sm {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.content-card, .card-custom { border: none !important; }

@media print {
    .sidebar, .top-navbar, .admin-footer, .no-print { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    .card-custom { box-shadow: none !important; border: 1px solid #DDD !important; }
}
