:root {
    --primary-blue: #1B396A;
    --secondary-blue: #2D5A96;
    --light-bg: #ffffff;
    --surface-bg: #ffffff;
    --soft-bg: #f8f9fa;
    --border-color: #e0e0e0;
    --text-dark: #333645;
    --text-muted: #7a7f88;
    --table-head-bg: #17345f;
    --table-head-border: #102744;
    --dashboard-header-bg: linear-gradient(135deg, #17345f 0%, #275087 100%);
    --dashboard-accent: #1B396A;
    --dashboard-accent-soft: #2D5A96;
    --success-accent: #218838;
    --warning-accent: #b38600;
}

:root[data-theme="dark"] {
    --primary-blue: #79a9ef;
    --secondary-blue: #9cc2ff;
    --light-bg: #111827;
    --surface-bg: #172033;
    --soft-bg: #202a3d;
    --border-color: #344158;
    --text-dark: #edf2f7;
    --text-muted: #b7c0cf;
    --table-head-bg: #0f2f59;
    --table-head-border: #78a7e8;
    --dashboard-header-bg: linear-gradient(135deg, #20324d 0%, #2f4668 100%);
    --dashboard-accent: #9fc7ff;
    --dashboard-accent-soft: #76b6ff;
    --success-accent: #6ee7a0;
    --warning-accent: #f8d46b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background-color: var(--light-bg);
    color: var(--text-dark);
    line-height: 1.5;
}

html, body {
    height: 100%;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--primary-blue);
    font-family: 'Raleway', sans-serif;
    font-weight: 600;
}

/* Navbar styling */
.navbar {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar .container-xl {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar-toggler {
    border: none;
    padding: 0.25rem 0.75rem;
    font-size: 1.25rem;
}

.navbar-toggler:focus {
    box-shadow: none;
    border: none;
}

.navbar-collapse {
    transition: all 0.3s ease;
    overflow: visible;
}

@media (max-width: 991.98px) {
    .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: inherit;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        border-radius: 0 0 8px 8px;
        max-height: calc(100vh - 64px);
        overflow-y: auto;
    }

    .navbar-collapse.show {
        display: block !important;
    }

    .nav-link {
        padding: 0.75rem 1rem !important;
        border-left: 3px solid transparent;
    }

    .nav-link:hover {
        border-left-color: rgba(255,255,255,0.5);
        background: rgba(255,255,255,0.1);
    }

    .dropdown-menu {
        position: static !important;
        float: none;
        width: 100% !important;
        margin: 0;
        padding: 0.5rem 0;
        border: none;
        box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
    }
}

.navbar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    color: white !important;
    display: flex !important;
    align-items: center;
    gap: 12px;
}

.navbar-brand img {
    height: 45px;
    width: auto;
}

.navbar-brand-text {
    line-height: 1.1;
    display: flex;
    flex-direction: column;
}

.navbar-brand-text span:first-child {
    font-size: 0.85rem;
}

.navbar-brand-text span:last-child {
    font-size: 1.05rem;
}

.nav-link {
    color: rgba(255,255,255,0.8) !important;
    transition: all 0.3s;
    margin: 0 5px;
}

.nav-link:hover {
    color: white !important;
}

/* Buttons */
.btn {
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.3s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.btn-primary:hover {
    background-color: var(--secondary-blue);
    border-color: var(--secondary-blue);
    transform: translateY(-1px);
}

.btn-outline-primary {
    color: var(--primary-blue);
    border-color: var(--primary-blue);
}

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

.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
}

@media (max-width: 575.98px) {
    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }

    .btn-lg {
        padding: 0.5rem 1rem;
        font-size: 1rem;
        width: 100%;
    }

    .btn-block {
        display: block;
        width: 100%;
    }
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-radius: 8px;
    transition: transform 0.3s, box-shadow 0.3s;
    height: 100%;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.card-body {
    padding: 1.5rem;
}

.card-header {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    color: white;
    border: none;
    font-weight: 600;
    padding: 1.25rem 1.5rem;
}

.card-title {
    margin-bottom: 1rem;
}

/* Stats cards */
.stat-card {
    background: white;
    border-radius: 8px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.stat-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-blue);
    margin-bottom: 10px;
    line-height: 1;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@media (max-width: 768px) {
    .card {
        margin-bottom: 1rem;
    }

    .card-body {
        padding: 1.25rem;
    }

    .card-header {
        padding: 1rem 1.25rem;
    }

    .stat-card {
        padding: 15px;
        min-height: 150px;
    }

    .stat-icon {
        font-size: 2.5rem;
        margin-bottom: 10px;
    }

    .stat-number {
        font-size: 1.8rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }
}

@media (max-width: 575.98px) {
    .card {
        margin-bottom: 0.75rem;
    }

    .card-body {
        padding: 1rem;
    }

    .card-header {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    .stat-card {
        padding: 12px;
        min-height: 130px;
    }

    .stat-icon {
        font-size: 2rem;
        margin-bottom: 8px;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }
}

/* Section styling */
.section {
    padding: 60px 0;
}

.section-title {
    font-size: 2.5rem;
    margin-bottom: 15px;
    color: var(--primary-blue);
}

.section-subtitle {
    color: var(--text-muted);
    margin-bottom: 40px;
    font-size: 1.1rem;
}

/* Breadcrumbs */
.breadcrumb {
    background: transparent;
    padding: 0;
}

.breadcrumb-item {
    color: var(--text-muted);
}

.breadcrumb-item.active {
    color: var(--primary-blue);
    font-weight: 600;
}

/* Footer */
.footer {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    color: white;
    padding: 40px 0 20px;
    margin-top: 60px;
}

.footer a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: color 0.3s;
}

.footer a:hover {
    color: white;
}

.footer .row {
    display: grid;
    gap: 30px;
}

@media (max-width: 768px) {
    .footer {
        padding: 30px 0 15px;
        margin-top: 40px;
    }

    .footer .row {
        gap: 20px;
    }
}

@media (max-width: 575.98px) {
    .footer {
        padding: 20px 0 10px;
    }

    .footer h5 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }
}

/* Alert styling */
.alert-primary {
    background-color: rgba(27, 57, 106, 0.1);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

/* Forms */
.form-control,
.form-select {
    border-radius: 6px;
    border-color: var(--border-color);
    background-color: var(--surface-bg);
    color: var(--text-dark);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 0.2rem rgba(27, 57, 106, 0.25);
}

.form-label {
    font-weight: 600;
    color: inherit;
    margin-bottom: 0.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.input-group {
    display: flex;
    align-items: stretch;
}

.input-group-text {
    background-color: var(--soft-bg);
    border-color: var(--border-color);
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .form-group {
        margin-bottom: 1.25rem;
    }

    .form-control,
    .form-select {
        font-size: 1rem;
        padding: 0.6rem 0.75rem;
    }

    .form-label {
        font-size: 0.95rem;
        margin-bottom: 0.4rem;
    }
}

@media (max-width: 575.98px) {
    .form-group {
        margin-bottom: 1rem;
    }

    .form-control,
    .form-select {
        font-size: 1rem;
        padding: 0.5rem 0.75rem;
    }

    .form-label {
        font-size: 0.9rem;
    }

    .col-form-label {
        font-size: 0.9rem;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
}

/* Hero gradient sections */
.hero-gradient {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    color: white;
    padding: 40px 0;
    position: relative;
    overflow: hidden;
}

.hero-gradient::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="20" cy="20" r="20" fill="%23fff" opacity="0.05"/><circle cx="80" cy="80" r="20" fill="%23fff" opacity="0.05"/></svg>');
    pointer-events: none;
}

.hero-gradient h1, .hero-gradient h2, .hero-gradient h3, .hero-gradient h4, .hero-gradient h5 {
    color: white;
    position: relative;
    z-index: 1;
}

.hero-gradient p {
    position: relative;
    z-index: 1;
}

/* Tables */
.table thead {
    background-color: var(--primary-blue);
}

.table thead th {
    color: white;
    font-weight: 600;
    border-bottom: 2px solid rgba(255,255,255,0.06);
}

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

/* Badge styling */
.badge {
    font-size: 0.85rem;
    padding: 6px 12px;
    display: inline-block;
    border-radius: 12px;
    font-weight: 500;
}

.badge.bg-primary {
    background-color: var(--primary-blue) !important;
}

@media (max-width: 575.98px) {
    .badge {
        font-size: 0.75rem;
        padding: 4px 8px;
    }
}

/* List groups */
.list-group {
    background: var(--surface-bg);
}

.list-group-item {
    background-color: var(--surface-bg);
    color: var(--text-dark);
    border-color: var(--border-color);
    padding: 0.75rem 1.25rem;
    transition: all 0.3s;
}

.list-group-item:hover {
    background-color: rgba(27, 57, 106, 0.05);
}

.list-group-item-action:hover,
.list-group-item-action:focus {
    background-color: rgba(27, 57, 106, 0.08);
    color: var(--primary-blue);
}

.list-group-item h1,
.list-group-item h2,
.list-group-item h3,
.list-group-item h4,
.list-group-item h5,
.list-group-item h6 {
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

@media (max-width: 575.98px) {
    .list-group-item {
        padding: 0.6rem 1rem;
    }

    .list-group-item h6 {
        font-size: 0.9rem;
    }
}

/* Dropdown menu */
.dropdown-menu {
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 8px;
    padding: 0.5rem 0;
}

.dropdown-item {
    padding: 0.75rem 1rem;
    transition: all 0.3s;
    font-size: 0.95rem;
}

.dropdown-item:hover {
    background-color: #f8f9fa;
    color: var(--primary-blue);
}

.dropdown-item.active,
.dropdown-item:active {
    background-color: rgba(27, 57, 106, 0.12);
    color: var(--primary-blue);
    font-weight: 600;
}

.dropdown-header {
    padding: 0.5rem 1rem;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: var(--text-muted);
}

@media (max-width: 575.98px) {
    .dropdown-menu {
        font-size: 0.9rem;
        padding: 0.3rem 0;
    }

    .dropdown-item {
        padding: 0.6rem 0.8rem;
    }

    .dropdown-header {
        padding: 0.4rem 0.8rem;
    }
}

html.grayscale-mode {
    filter: grayscale(1);
}

/* Modals */
.modal-header {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
    color: white;
    border: none;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

.modal-body {
    padding: 1.5rem;
}

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

@media (max-width: 575.98px) {
    .modal-body {
        padding: 1rem;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
    }

    .modal-content {
        border-radius: 12px;
    }
}

.management-menu {
    min-width: min(760px, calc(100vw - 24px));
    padding: 14px;
}

.management-menu-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 8px 14px;
}

.management-menu .dropdown-header {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 6px 12px;
    text-transform: uppercase;
}

.management-menu .dropdown-item,
.dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 6px;
}

.dropdown-menu .dropdown-item.active,
.dropdown-menu .dropdown-item:active {
    background-color: rgba(27, 57, 106, 0.12);
    color: var(--primary-blue);
    font-weight: 600;
}

/* Sidebar styling */
.sidebar {
    background-color: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    min-height: 100vh;
    padding: 20px 0;
    width: 250px;
    flex-shrink: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
    margin-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.sidebar-profile-photo {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-dark);
    text-decoration: none;
    transition: all 0.3s;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-item:hover {
    background-color: #e9ecef;
    border-left-color: var(--primary-blue);
    color: var(--primary-blue);
}

.sidebar-item.active {
    background-color: rgba(27, 57, 106, 0.1);
    border-left-color: var(--primary-blue);
    color: var(--primary-blue);
    font-weight: 600;
}

.sidebar-group {
    margin: 0;
    padding: 0;
}

.sidebar-group summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: all 0.3s;
    color: var(--text-dark);
    border-left: 3px solid transparent;
}

.sidebar-group summary:hover {
    background-color: #e9ecef;
    border-left-color: var(--primary-blue);
    color: var(--primary-blue);
}

.sidebar-group[open] summary {
    background-color: rgba(27, 57, 106, 0.1);
    border-left-color: var(--primary-blue);
    color: var(--primary-blue);
}

.sidebar-subitem {
    padding-left: 50px !important;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -250px;
        top: 70px;
        bottom: 0;
        width: 250px;
        z-index: 999;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        border-right: none;
        border-bottom: none;
    }

    .sidebar.show {
        left: 0;
    }

    .sidebar-item,
    .sidebar-group summary {
        padding-left: 15px;
        padding-right: 15px;
    }
}

@media (max-width: 575.98px) {
    .sidebar {
        width: 100%;
        max-width: 200px;
        top: 60px;
    }

    .sidebar-profile {
        flex-direction: column;
        text-align: center;
        padding: 10px 15px;
    }

    .sidebar-item,
    .sidebar-group summary {
        font-size: 0.9rem;
        padding-top: 10px;
        padding-bottom: 10px;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        display: none;
        position: fixed;
        left: -250px;
        top: 60px;
        bottom: 0;
        width: 250px;
        z-index: 999;
        transition: left 0.3s;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }

    .sidebar.show {
        left: 0;
    }

    .section-title {
        font-size: 2rem;
    }

    .hero-gradient {
        padding: 30px 0;
    }

    .navbar-brand {
        font-size: 0.9rem;
    }

    .navbar-brand img {
        height: 35px;
    }

    .navbar-brand-text span:first-child {
        font-size: 0.75rem;
    }

    .navbar-brand-text span:last-child {
        font-size: 0.9rem;
    }

    .container-xl {
        padding: 0 15px;
    }

    .section {
        padding: 40px 0;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-number {
        font-size: 1.8rem;
    }

    .management-menu {
        min-width: calc(100vw - 32px) !important;
    }

    .management-menu-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .card {
        margin-bottom: 15px;
    }

    .row.g-4 > * {
        padding-right: 0.5rem;
        padding-left: 0.5rem;
    }
}

/* Extra Small Devices (< 576px) */
@media (max-width: 575.98px) {
    .navbar {
        padding: 0.5rem 0;
    }

    .navbar-brand {
        font-size: 0.8rem;
        gap: 8px;
    }

    .navbar-brand img {
        height: 30px;
    }

    .navbar-brand-text {
        display: none;
    }

    .nav-link {
        font-size: 0.85rem;
        margin: 0 2px;
        padding: 0.5rem 0.5rem !important;
    }

    .container-xl {
        padding: 0 12px;
    }

    .section {
        padding: 30px 0;
    }

    .section-title {
        font-size: 1.5rem;
    }

    .section-subtitle {
        font-size: 0.95rem;
    }

    .display-3 {
        font-size: 1.8rem;
    }

    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.25rem !important;
    }

    h3 {
        font-size: 1.1rem !important;
    }

    .card {
        border-radius: 6px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .badge {
        font-size: 0.75rem;
        padding: 4px 8px;
    }

    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }

    .btn-lg {
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }

    .table {
        font-size: 0.85rem;
    }

    .table thead th {
        padding: 0.5rem 0.25rem;
    }

    .table tbody td {
        padding: 0.5rem 0.25rem;
    }

    .form-control,
    .form-select {
        font-size: 1rem;
    }

    .form-label {
        font-size: 0.9rem;
    }

    .dropdown-menu {
        font-size: 0.9rem;
    }

    .management-menu-grid {
        grid-template-columns: 1fr !important;
    }

    .management-menu {
        min-width: calc(100vw - 24px) !important;
        padding: 10px;
    }

    .modal {
        --bs-modal-margin: 0.5rem;
    }

    .modal-body {
        padding: 15px;
    }

    .px-4 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .py-4 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    .gap-4 {
        gap: 1rem !important;
    }

    .footer {
        padding: 25px 0 15px;
    }

    .hero-gradient h1,
    .hero-gradient h2 {
        margin-bottom: 15px;
    }

    .hero-gradient {
        padding: 20px 0;
    }

    .breadcrumb {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
}

/* Small Devices (576px - 768px) */
@media (min-width: 576px) and (max-width: 768px) {
    .navbar {
        padding: 0.75rem 0;
    }

    .navbar-brand {
        font-size: 0.95rem;
    }

    .navbar-brand img {
        height: 40px;
    }

    .container-xl {
        padding: 0 15px;
    }

    .section {
        padding: 45px 0;
    }

    .section-title {
        font-size: 1.75rem;
    }

    .stat-card {
        padding: 15px;
    }

    .stat-number {
        font-size: 2rem;
    }

    .management-menu-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .table {
        font-size: 0.9rem;
    }

    .px-4 {
        padding-left: 1.25rem !important;
        padding-right: 1.25rem !important;
    }
}

/* Medium Devices (768px - 992px) */
@media (min-width: 769px) and (max-width: 991.98px) {
    .sidebar {
        width: 200px;
    }

    .container-xl {
        padding: 0 20px;
    }

    .section {
        padding: 50px 0;
    }

    .section-title {
        font-size: 2rem;
    }

    .stat-number {
        font-size: 2.2rem;
    }

    .management-menu {
        min-width: min(650px, calc(100vw - 24px)) !important;
    }

    .management-menu-grid {
        grid-template-columns: repeat(3, minmax(120px, 1fr)) !important;
    }

    .col-md-6 {
        flex: 0 0 auto;
        width: 100%;
    }
}

/* Large Devices (992px+) */
@media (min-width: 992px) {
    .sidebar {
        position: relative;
        width: 250px;
    }

    .content-wrapper {
        flex-direction: row;
    }

    .main-content {
        flex: 1;
    }

    .container-xl {
        padding: 0 24px;
    }

    .section {
        padding: 60px 0;
    }

    .management-menu-grid {
        grid-template-columns: repeat(4, minmax(150px, 1fr)) !important;
    }
}

/* Extra Large Devices (1200px+) */
@media (min-width: 1200px) {
    .container-xl {
        max-width: 1170px;
    }

    .section {
        padding: 70px 0;
    }

    .section-title {
        font-size: 2.5rem;
    }
}

/* Loading spinner */
.spinner-custom {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(27, 57, 106, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-blue);
    animation: spin 1s linear infinite;
}

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

/* Utility classes */
.min-vh-100 {
    min-height: 100vh;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.content-wrapper {
    display: flex;
    min-height: 100vh;
    flex-direction: row;
    width: 100%;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
}

/* Theme, contrast and mobile hardening */
.card,
.modal-content {
    background: var(--surface-bg);
    color: var(--text-dark);
}

.stat-card {
    background: var(--surface-bg);
}

.table thead,
.table thead.table-primary {
    background-color: var(--table-head-bg) !important;
}

.table thead th,
.table thead.table-primary th {
    background-color: var(--table-head-bg) !important;
    color: #fff !important;
    border-bottom-color: var(--table-head-border);
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
    width: 100%;
    max-width: 100%;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .table-responsive {
        border: 1px solid #dee2e6;
        border-radius: 4px;
    }

    .table {
        margin-bottom: 0;
        font-size: 0.875rem;
    }
}

:root[data-theme="dark"] .text-muted {
    color: var(--text-muted) !important;
}

:root[data-theme="dark"] .bg-light {
    background-color: var(--soft-bg) !important;
    color: var(--text-dark) !important;
}

:root[data-theme="dark"] .table {
    --bs-table-bg: var(--surface-bg);
    --bs-table-color: var(--text-dark);
    --bs-table-hover-bg: #243149;
    --bs-table-hover-color: var(--text-dark);
    border-color: var(--border-color);
}

:root[data-theme="dark"] .table-light {
    --bs-table-bg: #202a3d;
    --bs-table-color: var(--text-dark);
    color: var(--text-dark);
}

.card-header[style*="linear-gradient"],
.card-header[style*="#1B396A"],
.card-header.bg-primary {
    background: var(--dashboard-header-bg) !important;
    color: #fff !important;
    border-color: transparent !important;
}

.card-header h1,
.card-header h2,
.card-header h3,
.card-header h4,
.card-header h5,
.card-header h6 {
    color: inherit !important;
}

.stat-card [style*="#1B396A"],
.list-group-item [style*="#1B396A"] {
    color: var(--dashboard-accent) !important;
}

.stat-card [style*="#2D5A96"],
.list-group-item [style*="#2D5A96"] {
    color: var(--dashboard-accent-soft) !important;
}

.stat-card [style*="#28a745"] {
    color: var(--success-accent) !important;
}

.stat-card [style*="#ffc107"] {
    color: var(--warning-accent) !important;
}

.list-group,
.list-group-flush {
    background: var(--surface-bg);
}

.list-group-item {
    background-color: var(--surface-bg);
    color: var(--text-dark);
    border-color: var(--border-color);
}

.list-group-item h1,
.list-group-item h2,
.list-group-item h3,
.list-group-item h4,
.list-group-item h5,
.list-group-item h6 {
    color: var(--text-dark);
}

.list-group-item-action:hover,
.list-group-item-action:focus {
    background-color: rgba(27, 57, 106, 0.08);
    color: var(--primary-blue);
}

:root[data-theme="dark"] .list-group-item-action:hover,
:root[data-theme="dark"] .list-group-item-action:focus {
    background-color: #243149;
    color: var(--dashboard-accent);
}

:root[data-theme="dark"] .btn-primary,
:root[data-theme="dark"] .btn-outline-primary:hover {
    background-color: #345d92;
    border-color: #7fb3f4;
    color: #fff;
}

:root[data-theme="dark"] .btn-outline-primary {
    color: var(--dashboard-accent);
    border-color: #5f8fc8;
}

:root[data-theme="dark"] .badge.bg-primary,
:root[data-theme="dark"] .text-bg-primary {
    background-color: #345d92 !important;
    color: #fff !important;
}

:root[data-theme="dark"] .navbar,
:root[data-theme="dark"] .footer,
:root[data-theme="dark"] .hero-gradient {
    background: linear-gradient(135deg, #162235 0%, #243955 100%) !important;
}

:root[data-theme="dark"] .alert-primary {
    background-color: rgba(127, 179, 244, 0.12);
    border-color: #5f8fc8;
    color: var(--dashboard-accent);
}

:root[data-theme="dark"] .btn-light {
    background-color: #e8eef7;
    border-color: #e8eef7;
    color: #172033;
}

:root[data-theme="dark"] .btn-secondary {
    background-color: #3b4659;
    border-color: #58657a;
    color: #fff;
}

:root[data-theme="dark"] .btn-outline-secondary {
    color: #cad5e6;
    border-color: #62718a;
}

:root[data-theme="dark"] .btn-outline-secondary:hover {
    background-color: #3b4659;
    color: #fff;
}

/* Additional responsive improvements */
.container-fluid {
    width: 100%;
    padding-right: 0.75rem;
    padding-left: 0.75rem;
    margin-right: auto;
    margin-left: auto;
}

/* Mejorar el overflow de contenido */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Mejorar links y interactividad en móvil */
a, button, input[type="button"], input[type="submit"] {
    min-height: 44px;
    display: inline-block;
}

/* Mejorar spacing en móviles */
@media (max-width: 575.98px) {
    .mx-3 { margin-left: 0.75rem !important; margin-right: 0.75rem !important; }
    .my-3 { margin-top: 0.75rem !important; margin-bottom: 0.75rem !important; }
    .px-3 { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
    .py-3 { padding-top: 0.75rem !important; padding-bottom: 0.75rem !important; }

    .mx-4 { margin-left: 1rem !important; margin-right: 1rem !important; }
    .my-4 { margin-top: 1rem !important; margin-bottom: 1rem !important; }

    .w-100 { width: 100% !important; }
    .h-auto { height: auto !important; }
}

/* Asegurar que los containers sean responsive */
.container,
.container-sm,
.container-md,
.container-lg,
.container-xl,
.container-xxl {
    width: 100%;
    padding-right: 0.75rem;
    padding-left: 0.75rem;
    margin-right: auto;
    margin-left: auto;
}

@media (max-width: 576px) {
    .container, .container-sm { max-width: 100%; }
}

@media (min-width: 576px) {
    .container, .container-sm { max-width: 540px; }
}

@media (min-width: 768px) {
    .container, .container-sm, .container-md { max-width: 720px; }
}

@media (min-width: 992px) {
    .container, .container-sm, .container-md, .container-lg { max-width: 960px; }
}

@media (min-width: 1200px) {
    .container, .container-sm, .container-md, .container-lg, .container-xl { max-width: 1140px; }
}

@media (min-width: 1400px) {
    .container, .container-sm, .container-md, .container-lg, .container-xl, .container-xxl { max-width: 1320px; }
}

/* Asegurar que row y col sean responsive */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -0.75rem;
    margin-left: -0.75rem;
}

.col {
    flex: 1 0 0%;
    padding-right: 0.75rem;
    padding-left: 0.75rem;
}

/* Mejorar navegación en móviles */
@media (max-width: 991.98px) {
    .navbar-brand {
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .navbar-nav {
        flex-direction: column;
        width: 100%;
    }

    .nav-item {
        width: 100%;
    }
}

/* Usar font-size responsivo */
@media (max-width: 575.98px) {
    html {
        font-size: 14px;
    }

    body {
        font-size: 14px;
        line-height: 1.5;
    }

    h1, .h1 { font-size: 1.75rem; }
    h2, .h2 { font-size: 1.5rem; }
    h3, .h3 { font-size: 1.25rem; }
    h4, .h4 { font-size: 1.1rem; }
    h5, .h5 { font-size: 1rem; }
    h6, .h6 { font-size: 0.875rem; }
}

/* Hacer que los modales sean responsivos */
@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-body {
        max-height: calc(100vh - 200px);
        overflow-y: auto;
    }
}

/* Mejorar tooltips y popovers en móviles */
@media (max-width: 768px) {
    .tooltip,
    .popover {
        max-width: calc(100vw - 20px) !important;
    }
}

/* Asegurar que los inputs sean usables en móviles */
input,
textarea,
select {
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 4px;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-blue);
}

/* Mejorar button touch targets */
.btn,
a[role="button"],
input[type="submit"],
input[type="button"],
input[type="reset"] {
    min-width: 44px;
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
}

@media (max-width: 768px) {
    .btn {
        min-width: 40px;
        min-height: 40px;
    }
}

.global-system-notice {
    position: sticky;
    top: 0;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: #fff3cd;
    color: #533f03;
    border-top: 1px solid #ffe69c;
    border-bottom: 1px solid #ffe69c;
    box-shadow: 0 4px 10px rgba(83, 63, 3, 0.08);
    font-size: 0.95rem;
}

.navbar.has-global-system-notice {
    top: var(--sgpi-global-notice-height, 0px);
}

:root[data-theme="dark"] .global-system-notice {
    background: #332b16;
    color: #ffe8a3;
    border-color: #5a4718;
}

.advisor-metric {
    background: var(--soft-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
}

.advisor-metric strong,
.advisor-metric span {
    display: block;
}

.advisor-metric strong {
    color: var(--primary-blue);
    font-size: 1.35rem;
    line-height: 1.1;
}

.advisor-metric span {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.advisor-project-list {
    display: grid;
    gap: 12px;
}

.advisor-project-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
    background: var(--soft-bg);
}

.advisor-row-editing td:first-child {
    border-left: 6px solid #f0ad4e;
}

.advisor-row-editing td {
    box-shadow: inset 0 1px 0 rgba(240, 173, 78, 0.25), inset 0 -1px 0 rgba(240, 173, 78, 0.25);
}

.advisor-admin-badge {
    background-color: #6f42c1;
    color: #fff;
}

.repository-reader-card .card-body {
    padding: 0;
}

.repository-reader {
    min-height: 640px;
    background: var(--surface-bg);
}

.repository-reader-frame {
    display: block;
    width: 100%;
    min-height: 72vh;
    border: 0;
    background: #fff;
}

@media (max-width: 768px) {
    .repository-reader-frame {
        min-height: 60vh;
    }
}

@media (max-width: 575.98px) {
    .repository-reader-frame {
        min-height: 50vh;
    }
}

.repository-word-preview {
    max-width: 820px;
    min-height: 640px;
    margin: 0 auto;
    padding: 42px;
    background: #fff;
    color: #1f2937;
    line-height: 1.65;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
}

@media (max-width: 768px) {
    .repository-word-preview {
        padding: 24px;
        min-height: 500px;
    }
}

@media (max-width: 575.98px) {
    .repository-word-preview {
        padding: 16px;
        min-height: 400px;
    }
}

.repository-word-preview img {
    max-width: 100%;
    height: auto;
    display: block;
}

.repository-epub-viewer {
    min-height: 620px;
    background: #fff;
    color: #1f2937;
    border: 1px solid var(--border-color);
}

:root[data-theme="dark"] .advisor-teacher-card .card-header .badge.bg-light {
    background-color: #e8eef7 !important;
    color: #172033 !important;
}

:root[data-theme="dark"] .advisor-admin-badge {
    background-color: #9b7be8;
    color: #111827;
}

.form-control,
.form-select {
    background-color: var(--surface-bg);
    color: var(--text-dark);
    border-color: var(--border-color);
}

.form-control:disabled {
    background-color: var(--soft-bg);
    color: var(--text-muted);
}

:root[data-theme="dark"] .dropdown-menu {
    background-color: var(--surface-bg);
    border: 1px solid var(--border-color);
}

:root[data-theme="dark"] .dropdown-item {
    color: var(--text-dark);
}

:root[data-theme="dark"] .dropdown-item:hover {
    background-color: var(--soft-bg);
    color: var(--secondary-blue);
}

:root[data-theme="dark"] .dropdown-menu .dropdown-item.active,
:root[data-theme="dark"] .dropdown-menu .dropdown-item:active {
    background-color: #243149;
    color: var(--dashboard-accent);
}

:root[data-theme="dark"] .swal2-container.swal2-backdrop-show,
:root[data-theme="dark"] .swal2-container.swal2-noanimation {
    background: rgba(6, 11, 22, 0.76);
}

:root[data-theme="dark"] .swal2-popup,
:root[data-theme="dark"] .swal2-toast {
    background: var(--surface-bg) !important;
    color: var(--text-dark) !important;
    border: 1px solid var(--border-color);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
}

.swal2-toast.system-notice-toast,
:root[data-theme="dark"] .swal2-toast.system-notice-toast {
    box-shadow: none !important;
}

.swal2-container:has(.system-notice-toast) {
    background: transparent !important;
    pointer-events: none;
}

.swal2-container:has(.system-notice-toast) .system-notice-toast {
    pointer-events: auto;
}

:root[data-theme="dark"] .swal2-title,
:root[data-theme="dark"] .swal2-html-container,
:root[data-theme="dark"] .swal2-content,
:root[data-theme="dark"] .swal2-input-label,
:root[data-theme="dark"] .swal2-validation-message {
    color: var(--text-dark) !important;
}

:root[data-theme="dark"] .swal2-html-container,
:root[data-theme="dark"] .swal2-content {
    color: var(--text-muted) !important;
}

:root[data-theme="dark"] .swal2-input,
:root[data-theme="dark"] .swal2-textarea,
:root[data-theme="dark"] .swal2-select {
    background-color: var(--soft-bg) !important;
    color: var(--text-dark) !important;
    border-color: var(--border-color) !important;
    box-shadow: none !important;
}

:root[data-theme="dark"] .swal2-input:focus,
:root[data-theme="dark"] .swal2-textarea:focus,
:root[data-theme="dark"] .swal2-select:focus {
    border-color: var(--dashboard-accent) !important;
    box-shadow: 0 0 0 0.2rem rgba(159, 199, 255, 0.18) !important;
}

:root[data-theme="dark"] .swal2-input::placeholder,
:root[data-theme="dark"] .swal2-textarea::placeholder {
    color: var(--text-muted);
}

:root[data-theme="dark"] .swal2-validation-message {
    background: #2a2030;
    border: 1px solid #6f3d5b;
}

:root[data-theme="dark"] .swal2-styled.swal2-confirm {
    background-color: var(--dashboard-accent) !important;
    color: #111827 !important;
}

:root[data-theme="dark"] .swal2-styled.swal2-cancel,
:root[data-theme="dark"] .swal2-styled.swal2-deny {
    background-color: var(--soft-bg) !important;
    color: var(--text-dark) !important;
    border: 1px solid var(--border-color) !important;
}

:root[data-theme="dark"] .swal2-timer-progress-bar {
    background: var(--dashboard-accent) !important;
}

.sidebar {
    background-color: var(--soft-bg);
    border-right-color: var(--border-color);
}

.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px 20px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-profile-photo,
.profile-thumb {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.5);
}

.sidebar-profile-photo {
    width: 44px;
    height: 44px;
    border-color: var(--border-color);
}

.sidebar-profile strong,
.sidebar-profile small {
    display: block;
    line-height: 1.2;
}

.sidebar-profile small {
    color: var(--text-muted);
}

.user-nav-link {
    display: flex !important;
    align-items: center;
    gap: 8px;
}

.sidebar-group summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-dark);
    cursor: pointer;
    list-style: none;
}

.sidebar-group summary::-webkit-details-marker {
    display: none;
}

.sidebar-group[open] summary .bi-chevron-down {
    transform: rotate(180deg);
}

.sidebar-subitem {
    padding-left: 42px;
}

@media (max-width: 768px) {
    .content-wrapper {
        flex-direction: column;
    }

    .sidebar {
        display: block;
        width: 100%;
        min-height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border-color);
        padding: 12px 0;
    }

    .sidebar-item,
    .sidebar-group summary {
        padding: 10px 16px;
    }

    .sidebar-profile {
        padding: 0 16px 12px;
    }

    .container-xl {
        padding-left: 14px;
        padding-right: 14px;
    }

    .navbar-brand img {
        height: 38px;
    }

    .navbar-brand-text span:first-child {
        font-size: 0.75rem;
    }

    .navbar-brand-text span:last-child {
        font-size: 0.9rem;
    }

    .btn-group {
        flex-wrap: wrap;
    }

    .management-menu {
        min-width: 100%;
    }

    .management-menu-grid {
        grid-template-columns: 1fr;
    }

    .repository-reader {
        min-height: 460px;
    }

    .repository-reader-frame {
        min-height: 68vh;
    }

    .repository-word-preview {
        min-height: 460px;
        padding: 22px;
    }

    .repository-epub-viewer {
        min-height: 500px;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-card .card-body {
        padding: 12px;
    }
}

/* Mobile hardening overrides */
html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    min-width: 320px;
}

.navbar .container-xl {
    gap: 10px;
}

.navbar-brand {
    min-width: 0;
}

.navbar-brand-text {
    min-width: 0;
}

.navbar-collapse {
    overflow: visible;
}

.dropdown-menu {
    max-width: calc(100vw - 24px);
}

.content-wrapper {
    align-items: stretch;
}

.main-content {
    min-width: 0;
}

.card,
.stat-card,
.list-group-item,
.modal-content {
    min-width: 0;
}

.card {
    height: auto;
}

.table {
    vertical-align: middle;
}

.table th,
.table td {
    white-space: nowrap;
}

.table td {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn,
.dropdown-item,
.nav-link {
    white-space: normal;
}

.btn-group,
.btn-toolbar,
.d-flex {
    min-width: 0;
}

.form-control,
.form-select,
.form-check-input {
    -webkit-appearance: auto;
    appearance: auto;
}

input,
textarea,
select {
    max-width: 100%;
}

.modal-dialog {
    width: auto;
}

.footer .row {
    display: flex;
}

.sidebar {
    min-width: 250px;
}

@media (max-width: 991.98px) {
    .navbar-collapse {
        background: linear-gradient(135deg, var(--primary-blue) 0%, var(--secondary-blue) 100%);
        max-height: calc(100vh - 64px);
        overflow-y: auto;
    }

    .management-menu {
        min-width: 100% !important;
    }

    .management-menu-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .col-md-6 {
        flex: 0 0 auto;
        width: 50%;
    }
}

@media (max-width: 768px) {
    .content-wrapper {
        display: block !important;
    }

    .sidebar {
        position: static !important;
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        min-width: 0;
        min-height: auto;
        max-height: 48vh;
        overflow-y: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border-color);
        box-shadow: none;
        padding: 10px 0;
    }

    .sidebar-profile {
        flex-direction: row;
        text-align: left;
        padding: 0 14px 10px;
    }

    .sidebar-item,
    .sidebar-group summary {
        padding: 10px 14px;
    }

    .sidebar-subitem {
        padding-left: 38px !important;
    }

    .main-content > .container-xl,
    .container-xl {
        padding-left: 12px;
        padding-right: 12px;
    }

    .main-content .d-flex.justify-content-between,
    .main-content .d-flex.align-items-center.justify-content-between,
    .main-content .d-flex.align-items-center {
        flex-wrap: wrap;
        gap: 12px;
    }

    .main-content .d-flex.justify-content-between > *,
    .main-content .d-flex.align-items-center.justify-content-between > * {
        min-width: 0;
    }

    .main-content h1 {
        overflow-wrap: anywhere;
    }

    .table-responsive {
        border: 1px solid var(--border-color);
        border-radius: 8px;
    }

    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl {
        max-width: calc(100vw - 16px);
    }
}

@media (max-width: 575.98px) {
    html {
        font-size: 100%;
    }

    .navbar-brand img {
        height: 34px;
    }

    .navbar-brand-text {
        display: flex;
    }

    .navbar-brand-text span:first-child {
        font-size: 0.68rem;
    }

    .navbar-brand-text span:last-child {
        font-size: 0.8rem;
    }

    .container,
    .container-sm,
    .container-md,
    .container-lg,
    .container-xl,
    .container-xxl {
        padding-left: 12px;
        padding-right: 12px;
    }

    .hero-gradient .d-flex,
    .container-xl > .d-flex.justify-content-between,
    .container-xl > .d-flex.align-items-center.justify-content-between {
        flex-wrap: wrap;
        gap: 12px;
    }

    .hero-gradient h1,
    .display-3 {
        font-size: 1.65rem !important;
        line-height: 1.2;
    }

    .section-title,
    h1 {
        font-size: 1.45rem !important;
        line-height: 1.25;
    }

    .btn {
        min-height: 40px;
        max-width: 100%;
    }

    .btn-lg {
        width: auto;
    }

    .d-grid .btn,
    .w-100.btn {
        width: 100%;
    }

    .btn-group {
        display: flex;
        flex-wrap: wrap;
    }

    .btn-group > .btn {
        flex: 1 1 auto;
    }

    .modal-dialog {
        margin: 8px;
        max-width: calc(100vw - 16px);
    }

    .modal-body {
        max-height: calc(100vh - 150px);
        overflow-y: auto;
    }

    .footer .row {
        gap: 12px;
    }
}
