:root {
    --app-sidebar-bg: #1f2430;
    --app-sidebar-hover: #2a3040;
    --app-sidebar-active: #0d6efd;
    --app-topbar-bg: #ffffff;
    --app-body-bg: #f4f6fa;
    --app-border: #e2e6ef;
    --app-text: #2b3445;
    --app-text-muted: #6b7688;
    --app-primary: #0d6efd;
    --app-radius: 0.75rem;
    --app-shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    background-color: var(--app-body-bg);
    color: var(--app-text);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 0.925rem;
    line-height: 1.5;
}

a {
    color: var(--app-primary);
}

/* ---------------------------------------------------------------
   Layout: fixed sidebar + content
--------------------------------------------------------------- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: 240px;
    min-width: 240px;
    background: linear-gradient(180deg, #20253a 0%, #1c2030 100%);
    color: #cbd2e0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.app-sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 1.1rem 1.25rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-sidebar .brand img {
    height: 34px;
}

.app-sidebar .brand .brand-sub {
    display: block;
    font-size: 0.68rem;
    font-weight: 400;
    color: #8f98ad;
    letter-spacing: 0.4px;
}

.sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0.75rem 0.75rem;
    flex: 1 1 auto;
}

.sidebar-nav .nav-section {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #7c85a0;
    padding: 0.9rem 0.75rem 0.35rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.58rem 0.75rem;
    margin: 0.15rem 0;
    border-radius: 0.5rem;
    color: #cbd2e0;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-nav .nav-link i {
    width: 1.1rem;
    text-align: center;
    color: #8f98ad;
    transition: color 0.15s ease;
}

.sidebar-nav .nav-link:hover {
    background: var(--app-sidebar-hover);
    color: #fff;
}

.sidebar-nav .nav-link:hover i {
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--app-sidebar-active);
    color: #fff;
}

.sidebar-nav .nav-link.active i {
    color: #fff;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.75rem;
    color: #8f98ad;
}

/* Sidebar toggle (mobile) */
.sidebar-toggler {
    display: none;
    background: transparent;
    border: 0;
    color: var(--app-text);
    font-size: 1.25rem;
    padding: 0.25rem 0.5rem;
}

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ---------------------------------------------------------------
   Topbar
--------------------------------------------------------------- */
.app-topbar {
    background: var(--app-topbar-bg);
    border-bottom: 1px solid var(--app-border);
    padding: 0.65rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.app-topbar .page-title h1 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
}

.app-topbar .page-title small {
    color: var(--app-text-muted);
    font-size: 0.78rem;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0.9rem;
    border: 1px solid var(--app-border);
    border-radius: 2rem;
    background: #fff;
    color: var(--app-text);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
}

.user-chip .avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--app-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

/* ---------------------------------------------------------------
   Content
--------------------------------------------------------------- */
.app-content {
    padding: 1.5rem;
    flex: 1 1 auto;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggler {
        display: inline-block;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        z-index: 1049;
        display: none;
    }

    .sidebar-backdrop.show {
        display: block;
    }
}

/* ---------------------------------------------------------------
   Components
--------------------------------------------------------------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.page-header h3 {
    font-weight: 700;
    margin: 0;
    font-size: 1.25rem;
}

.card {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    margin-bottom: 1.25rem;
}

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

.card .card-header:first-child {
    border-radius: calc(var(--app-radius) - 1px) calc(var(--app-radius) - 1px) 0 0;
}

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

.stat-card {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.1;
}

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

.btn-primary {
    --bs-btn-bg: #0d6efd;
    --bs-btn-border-color: #0d6efd;
}

.btn-soft {
    background: #eef2ff;
    color: #3b5bdb;
    border: 1px solid #d9e2ff;
    font-weight: 600;
}

.btn-soft:hover {
    background: #dfe7ff;
    color: #364fc7;
}

/* Dashboard tiles */
.tile {
    display: block;
    text-decoration: none;
    color: var(--app-text);
    padding: 1.5rem 1rem;
    text-align: center;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    background: #fff;
    box-shadow: var(--app-shadow);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    height: 100%;
}

.tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(16, 24, 40, 0.12);
    color: var(--app-text);
}

.tile .tile-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    margin: 0 auto 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
}

.tile .tile-title {
    font-weight: 700;
    font-size: 0.95rem;
}

.tile .tile-sub {
    color: var(--app-text-muted);
    font-size: 0.75rem;
}

/* ---------------------------------------------------------------
   Tables
--------------------------------------------------------------- */
.table-card .table {
    margin: 0;
}

.table thead th {
    background: #f8fafc;
    border-bottom: 2px solid var(--app-border);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--app-text-muted);
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background: #f8faff;
}

/* ---------------------------------------------------------------
   Forms
--------------------------------------------------------------- */
.form-label {
    font-weight: 600;
    font-size: 0.85rem;
}

.form-control,
.form-select {
    border-radius: 0.55rem;
}

.form-control:focus,
.form-select:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.12);
}

.form-section-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--app-text);
    border-bottom: 1px solid var(--app-border);
    padding-bottom: 0.5rem;
    margin: 1.5rem 0 1rem;
}

.login-card {
    border: 0;
    border-radius: 1rem;
    box-shadow: 0 25px 50px rgba(16, 24, 40, 0.18);
    overflow: hidden;
}

.login-logo {
    height: 72px;
}

/* ---------------------------------------------------------------
   Badges
--------------------------------------------------------------- */
.badge {
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* DataTables polish */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 0.75rem;
}

.dataTables_wrapper .dataTables_filter input {
    border: 1px solid var(--app-border);
    border-radius: 0.45rem;
    padding: 0.3rem 0.6rem;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    padding-top: 0.75rem;
}

/* Audio player */
.audio-player audio {
    max-width: 220px;
    height: 34px;
}

/* Charts */
.chart-box {
    position: relative;
    height: 300px;
    width: 100%;
}
.report-filter-form {
    background: var(--app-card-bg, #fff);
    border: 1px solid var(--app-border, rgba(0, 0, 0, 0.08));
    border-radius: 0.75rem;
}
.hub-tile {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--app-border, rgba(0, 0, 0, 0.08));
    border-radius: 0.75rem;
    background: var(--app-card-bg, #fff);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
    text-decoration: none;
    color: inherit;
    height: 100%;
}
.hub-tile:hover {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
    text-decoration: none;
}
.hub-tile .hub-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}
.hub-tile .hub-title {
    font-weight: 600;
    margin-bottom: 0.15rem;
}
.hub-tile .hub-desc {
    font-size: 0.82rem;
    color: var(--app-text-muted, #6c757d);
}
/* ---------------------------------------------------------------------------
   Admin area
   --------------------------------------------------------------------------- */
.admin-sidebar .brand {
    border-bottom-color: rgba(255, 255, 255, 0.15);
}
.admin-sidebar .nav-link.active {
    background: rgba(255, 193, 7, 0.16);
    color: #ffd54f;
}
.admin-badge {
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    vertical-align: middle;
}
.stat-tile {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.1rem;
    border-radius: 14px;
    background: #fff;
    border: 1px solid var(--app-border, #e6e8ee);
    height: 100%;
}
.stat-tile .stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}
.stat-tile .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
}
.stat-tile .stat-label {
    font-size: 0.78rem;
    color: var(--app-text-muted, #6c757d);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
