:root {
    --primary: #0f172a;
    --secondary: #334155;
    --accent: #38bdf8;
    --accent-hover: #0ea5e9;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --sidebar-width: 280px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary) 0%, #1e293b 100%);
    color: white;
    height: 100vh;
    position: fixed;
    padding: 1.5rem 1.25rem;
    transition: var(--transition);
    z-index: 100;
    overflow-y: auto;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--accent);
}

.nav-group {
    margin-bottom: 1.5rem;
}

.nav-label {
    text-transform: uppercase;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.6rem 0.8rem;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: 10px;
    transition: var(--transition);
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent);
}

/* Collapsible Sidebar Sections */
.nav-section {
    margin-bottom: 0.5rem;
}

.nav-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.8rem;
    color: #94a3b8;
    cursor: pointer;
    border-radius: 10px;
    transition: var(--transition);
    user-select: none;
}

.nav-section-header:hover {
    background: rgba(255, 255, 100, 0.05);
    color: white;
}

.nav-section-header .header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.nav-section-header i.chevron {
    font-size: 0.7rem;
    transition: transform 0.3s ease;
}

.nav-section.active .nav-section-header i.chevron {
    transform: rotate(180deg);
}

.nav-section.active .nav-section-header {
    color: var(--accent);
}

.nav-children {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0, 1, 0, 1);
    padding-left: 0.5rem;
}

.nav-section.active .nav-children {
    max-height: 1000px;
    transition: max-height 0.4s ease-in-out;
}

.nav-child-link {
    font-size: 0.85rem;
    padding: 0.5rem 0.8rem;
    margin-bottom: 2px;
}

.nav-child-link i {
    width: 20px;
    text-align: center;
    font-size: 0.8rem;
    opacity: 0.7;
}

html, body {
    width: 100%;
    min-height: 100%;
    background-color: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    padding: 0;
}

body {
    display: flex;
}

/* Permanent Fixed Top Navbar Across All Menus */
.top-navbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: 56px;
    z-index: 900;
    background: #ffffff !important;
    padding: 0 1.25rem;
    margin: 0;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: 56px;
    flex: 1;
    min-width: 0;
    width: calc(100% - var(--sidebar-width));
    min-height: calc(100vh - 56px);
    padding: 0.85rem 1.25rem 2rem 1.25rem;
    display: flex;
    flex-direction: column;
}

/* Sticky Action Header & Filter Toolbar Across All Menus */
.header, .sticky-toolbar, .sticky-filter, .table-toolbar {
    position: sticky;
    top: 56px;
    z-index: 850;
    background: var(--bg-main);
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
    margin-bottom: 0.5rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.35rem 0.85rem;
    background: white;
    border-radius: 50px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Global Print Support */
@media print {
    .sidebar, .top-navbar {
        display: none !important;
    }
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    max-width: 100%;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Data Tables & Sticky Table Header */
.table-container, .table-container-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    margin-top: 0.5rem;
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.table-container table thead th,
.table-container-scroll table thead th,
table thead th {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #f8fafc !important;
    box-shadow: inset 0 -1px 0 #e2e8f0;
    white-space: nowrap;
}

.table-container table td,
.table-container-scroll table td {
    white-space: nowrap;
}

/* Pinned Left Columns for Tables */
.table-container th.sticky-col-1,
.table-container-scroll th.sticky-col-1 {
    position: sticky;
    left: 0;
    z-index: 30;
    background: #f8fafc;
}
.table-container td.sticky-col-1,
.table-container-scroll td.sticky-col-1 {
    position: sticky;
    left: 0;
    z-index: 15;
    background: white;
}

.table-container th.sticky-col-2,
.table-container-scroll th.sticky-col-2 {
    position: sticky;
    left: 40px;
    z-index: 30;
    background: #f8fafc;
    box-shadow: 2px 0 5px -2px rgba(0, 0, 0, 0.08);
}
.table-container td.sticky-col-2,
.table-container-scroll td.sticky-col-2 {
    position: sticky;
    left: 40px;
    z-index: 15;
    background: white;
    box-shadow: 2px 0 5px -2px rgba(0, 0, 0, 0.08);
}

.santri-row:hover td.sticky-col-1,
.santri-row:hover td.sticky-col-2 {
    background-color: #f8fafc;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 1rem;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid #e2e8f0;
}

td {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    outline: none;
    transition: var(--transition);
}

input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Login Page Specific */
.login-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--primary) 0%, #1e293b 100%);
}

.login-card {
    width: 400px;
    padding: 3rem;
    background: white;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Micro-animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeInUp 0.5s ease-out forwards;
}

/* Compact Interactive Cards */
.unit-card-compact {
    padding: 1rem 1.25rem !important;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.reveal-on-hover {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 0;
}

.unit-card-compact:hover .reveal-on-hover {
    max-height: 200px;
    opacity: 1;
    margin-top: 1rem;
}

.unit-card-compact .arrow-icon {
    transform: translateX(10px);
    opacity: 0;
    transition: all 0.3s ease;
}

.unit-card-compact:hover .arrow-icon {
    transform: translateX(0);
    opacity: 1;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: var(--transition);
}

.modal-content {
    background-color: var(--bg-card);
    margin: 5% auto;
    padding: 2rem;
    border: 1px solid #e2e8f0;
    width: 90%;
    max-width: 600px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: fadeInUp 0.3s ease-out forwards;
}

.close {
    color: var(--text-muted);
    float: right;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}

.close:hover,
.close:focus {
    color: var(--text-main);
    text-decoration: none;
}