﻿:root {
    --primary: #1E3A8A;
    --primary-light: #3B82F6;
    --primary-gradient: linear-gradient(135deg, #1E3A8A 0%, #2563EB 100%);
    --secondary: #EFF6FF;
    --success: #059669;
    --warning: #D97706;
    --danger: #DC2626;
    --text-dark: #0F172A;
    --text-muted: #64748B;
    --border: #E2E8F0;
    --background: #F1F5F9;
    --card-bg: #FFFFFF;
    --hover-bg: #F8FAFC;
    --sidebar-bg: linear-gradient(180deg, #0F1F4F 0%, #1E3A8A 60%, #1e40af 100%);
    --sidebar-text: rgba(255,255,255,0.75);
    --sidebar-active: rgba(255,255,255,0.15);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --primary: #3B82F6;
    --primary-light: #60A5FA;
    --primary-gradient: linear-gradient(135deg, #1D4ED8 0%, #3B82F6 100%);
    --secondary: #1E293B;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --text-dark: #F1F5F9;
    --text-muted: #94A3B8;
    --border: #334155;
    --background: #0F172A;
    --card-bg: #1E293B;
    --hover-bg: #334155;
    --sidebar-bg: linear-gradient(180deg, #020617 0%, #0F172A 60%, #1E293B 100%);
    --sidebar-text: rgba(255,255,255,0.65);
    --sidebar-active: rgba(255,255,255,0.12);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.25);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.3);
}

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

html {
    overflow-x: hidden;  /* fallback untuk browser lama */
    overflow-x: clip;    /* modern: clips tanpa membuat scroll container (iOS fix) */
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--background);
    color: var(--text-dark);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    max-inline-size: 100vw;
}

/* =====================================================
   LAYOUT
   ===================================================== */
.layout {
    display: flex;
    min-block-size: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────────── */
.sidebar {
    inline-size: 270px;
    background: var(--sidebar-bg);
    border-inline-end: none;
    position: fixed;
    block-size: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
}
.sidebar::-webkit-scrollbar { inline-size: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.sidebar-header {
    padding: 1.5rem 1.5rem 1.25rem;
    border-block-end: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 0.875rem;
    flex-shrink: 0;
}

.sidebar-logo {
    inline-size: 40px;
    block-size: 40px;
    background: rgba(255,255,255,0.18);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.sidebar-title {
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.02em;
    font-size: 0.95rem;
}

.sidebar-subtitle {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
    margin-block-start: 1px;
}

.sidebar-nav {
    padding: 1rem 0.875rem;
    flex: 1;
}

.sidebar-nav-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
    padding: 0.75rem 0.75rem 0.35rem;
    margin-block-start: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 10px;
    margin-block-end: 0.2rem;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    font-weight: 450;
    position: relative;
}
.nav-item:hover {
    background: var(--sidebar-active);
    color: rgba(255,255,255,0.95);
}
.nav-item.active {
    background: rgba(255,255,255,0.18);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.nav-item.active::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    inset-block-start: 20%;
    block-size: 60%;
    inline-size: 3px;
    background: rgba(255,255,255,0.85);
    border-radius: 0 2px 2px 0;
}
.nav-item i {
    inline-size: 20px;
    text-align: center;
    font-size: 0.9rem;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-block-start: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
    background: rgba(0,0,0,0.15);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-block-end: 0.875rem;
}

.user-avatar {
    inline-size: 38px;
    block-size: 38px;
    background: rgba(255,255,255,0.18);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.user-name {
    font-weight: 600;
    color: #ffffff;
    font-size: 0.8rem;
    letter-spacing: 0.01em;
}

.user-role {
    font-size: 0.68rem;
    color: rgba(255,255,255,0.45);
    margin-block-start: 1px;
}

.sidebar-footer .btn-secondary {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    border: 1px solid rgba(255,255,255,0.15);
    inline-size: 100%;
    justify-content: center;
    font-size: 0.8rem;
}
.sidebar-footer .btn-secondary:hover {
    background: rgba(255,255,255,0.18);
    color: #ffffff;
}

/* ── MAIN CONTENT ──────────────────────────────────── */
.main-content {
    flex: 1;
    margin-inline-start: 270px;
    min-block-size: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── TOPBAR ──────────────────────────────────────── */
.topbar {
    block-size: 64px;
    background: var(--card-bg);
    border-block-end: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    position: sticky;
    inset-block-start: 0;
    z-index: 50;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.page-title h1 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-dark);
    letter-spacing: -0.01em;
}
.page-title p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-block-start: 1px;
}

.content {
    padding: 1.75rem;
    flex: 1;
}

/* =====================================================
   CARDS
   ===================================================== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: background-color 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease;
}
.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 1.1rem 1.5rem;
    border-block-end: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.card-title {
    font-size: 0.9375rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.01em;
}
.card-title i {
    color: var(--primary);
    font-size: 0.9rem;
}

.card-body {
    padding: 1.5rem;
}

/* Metric cards */
.card-metric {
    border-block-start: none;
    border-inline-start: 4px solid var(--primary);
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
}
.card-metric::after {
    content: '';
    position: absolute;
    inset-block-start: 0; inset-inline-end: 0; inset-block-end: 0;
    inline-size: 40%;
    background: linear-gradient(135deg, transparent 0%, rgba(30,58,138,0.03) 100%);
    pointer-events: none;
}
.card-metric.green  { border-inline-start-color: var(--success); }
.card-metric.green::after  { background: linear-gradient(135deg, transparent 0%, rgba(5,150,105,0.03) 100%); }
.card-metric.blue   { border-inline-start-color: var(--primary-light); }
.card-metric.blue::after   { background: linear-gradient(135deg, transparent 0%, rgba(59,130,246,0.03) 100%); }
.card-metric.yellow { border-inline-start-color: var(--warning); }
.card-metric.yellow::after { background: linear-gradient(135deg, transparent 0%, rgba(217,119,6,0.03) 100%); }

.metric-value {
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--text-dark);
    letter-spacing: -0.03em;
    line-height: 1.1;
}
.metric-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.125rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.btn-primary {
    background: var(--primary-gradient);
    box-shadow: 0 2px 10px rgba(30,58,138,0.25);
    color: white;
}
.btn-primary:hover {
    background: linear-gradient(135deg, #152e6e 0%, #1d4ed8 100%);
    box-shadow: 0 4px 16px rgba(30,58,138,0.38);
    transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-dark);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--hover-bg);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-success {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    box-shadow: 0 2px 8px rgba(5,150,105,0.25);
    color: white;
}
.btn-success:hover { box-shadow: 0 4px 14px rgba(5,150,105,0.35); transform: translateY(-1px); }

.btn-warning {
    background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
    box-shadow: 0 2px 8px rgba(217,119,6,0.25);
    color: white;
}
.btn-danger {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    box-shadow: 0 2px 8px rgba(220,38,38,0.25);
    color: white;
}
.btn-danger:hover { box-shadow: 0 4px 14px rgba(220,38,38,0.35); transform: translateY(-1px); }

.btn-sm {
    padding: 0.4rem 0.875rem;
    font-size: 0.75rem;
    border-radius: 6px;
}
.btn-icon {
    padding: 0.5rem;
    inline-size: 36px;
    block-size: 36px;
    justify-content: center;
    border-radius: 8px;
}

/* =====================================================
   FORMS
   ===================================================== */
.form-group {
    margin-block-end: 1rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-dark);
    margin-block-end: 0.375rem;
}

.form-control {
    inline-size: 100%;
    padding: 0.625rem 0.875rem;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    background: var(--card-bg);
    color: var(--text-dark);
    transition: all 0.2s ease;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,58,138,0.1);
}
.form-control::placeholder { color: var(--text-muted); opacity: 0.7; }

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-inline-end: 2.5rem;
}

/* =====================================================
   TABLES
   ===================================================== */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    overscroll-behavior-x: contain;
}

.table {
    inline-size: 100%;
    border-collapse: collapse;
}

.table th {
    background: var(--secondary);
    padding: 0.7rem 1rem;
    text-align: start;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    white-space: nowrap;
}
.table td {
    padding: 0.875rem 1rem;
    border-block-end: 1px solid var(--border);
    font-size: 0.875rem;
    vertical-align: middle;
}
.table tbody tr:hover {
    background: var(--hover-bg);
    transition: background 0.15s;
}
.table tbody tr:last-child td { border-block-end: none; }

.table-actions {
    display: flex;
    gap: 0.5rem;
}

/* =====================================================
   BADGES
   ===================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}
.badge-success  { background: #D1FAE5; color: #065F46; }
.badge-warning  { background: #FEF3C7; color: #92400E; }
.badge-danger   { background: #FEE2E2; color: #991B1B; }
.badge-info     { background: #DBEAFE; color: #1E40AF; }

/* =====================================================
   GRID
   ===================================================== */
.grid {
    display: grid;
    gap: 1.5rem;
}

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

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* =====================================================
   LOGIN PAGE  — Modern Animated Design
   ===================================================== */

/* ── Keyframes ─────────────────────────────────────── */
@keyframes loginFadeUp {
    from { opacity: 0; transform: translateY(28px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes loginFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes loginSlideRight {
    from { opacity: 0; transform: translateX(-40px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes floatBlob {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%       { transform: translate(24px, -20px) scale(1.06); }
    66%       { transform: translate(-16px, 18px) scale(0.96); }
}
@keyframes particleFall {
    0%   { transform: translateY(-10vh) rotate(0deg); opacity: 0; }
    10%  { opacity: 0.6; }
    90%  { opacity: 0.3; }
    100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}
@keyframes rippleOut {
    from { inline-size: 0; block-size: 0; opacity: 0.4; }
    to   { inline-size: 300px; block-size: 300px; opacity: 0; }
}
@keyframes focusBar {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}
@keyframes pulse-ring {
    0%   { box-shadow: 0 0 0 0 rgba(59,130,246,0.5); }
    70%  { box-shadow: 0 0 0 12px rgba(59,130,246,0); }
    100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); }
}
@keyframes shake {
    0%,100% { transform: translateX(0); }
    20%,60% { transform: translateX(-6px); }
    40%,80% { transform: translateX(6px); }
}

/* ── Body ──────────────────────────────────────────── */
body.login-body {
    background: linear-gradient(135deg, #0F1F4F 0%, #1E3A8A 50%, #1e40af 100%);
    overflow: hidden;
}

/* ── Animated particles ──────────────────────────── */
.login-particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}
.login-particles span {
    position: absolute;
    display: block;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    animation: particleFall linear infinite;
}
.login-particles span:nth-child(1)  { inline-size:10px;  block-size:10px;  inset-inline-start:5%;   animation-duration:14s; animation-delay:0s;   }
.login-particles span:nth-child(2)  { inline-size:20px;  block-size:20px;  inset-inline-start:15%;  animation-duration:18s; animation-delay:2s;   }
.login-particles span:nth-child(3)  { inline-size:8px;   block-size:8px;   inset-inline-start:27%;  animation-duration:12s; animation-delay:4s;   }
.login-particles span:nth-child(4)  { inline-size:16px;  block-size:16px;  inset-inline-start:40%;  animation-duration:20s; animation-delay:1s;   }
.login-particles span:nth-child(5)  { inline-size:12px;  block-size:12px;  inset-inline-start:55%;  animation-duration:16s; animation-delay:3s;   }
.login-particles span:nth-child(6)  { inline-size:6px;   block-size:6px;   inset-inline-start:65%;  animation-duration:11s; animation-delay:5s;   }
.login-particles span:nth-child(7)  { inline-size:22px;  block-size:22px;  inset-inline-start:75%;  animation-duration:22s; animation-delay:2.5s; }
.login-particles span:nth-child(8)  { inline-size:9px;   block-size:9px;   inset-inline-start:85%;  animation-duration:13s; animation-delay:0.5s; }
.login-particles span:nth-child(9)  { inline-size:14px;  block-size:14px;  inset-inline-start:90%;  animation-duration:17s; animation-delay:4.5s; }
.login-particles span:nth-child(10) { inline-size:18px;  block-size:18px;  inset-inline-start:48%;  animation-duration:15s; animation-delay:1.5s; }
.login-particles span:nth-child(11) { inline-size:7px;   block-size:7px;   inset-inline-start:33%;  animation-duration:19s; animation-delay:3.5s; }
.login-particles span:nth-child(12) { inline-size:24px;  block-size:24px;  inset-inline-start:70%;  animation-duration:23s; animation-delay:6s;   }

/* ── Page wrapper ──────────────────────────────────── */
.login-page {
    position: relative;
    z-index: 1;
    min-block-size: 100vh;
    display: flex;
}

/* ── Left Panel ─────────────────────────────────────── */
.login-left {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: white;
    position: relative;
    overflow: hidden;
}

/* Animated decorative blobs */
.login-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.25;
    animation: floatBlob 10s ease-in-out infinite;
    pointer-events: none;
}
.login-blob-1 {
    inline-size: 400px;
    block-size: 400px;
    background: radial-gradient(circle, #60A5FA, #2563EB);
    inset-block-start: -100px;
    inset-inline-start: -80px;
    animation-delay: 0s;
}
.login-blob-2 {
    inline-size: 320px;
    block-size: 320px;
    background: radial-gradient(circle, #a78bfa, #7c3aed);
    inset-block-end: -80px;
    inset-inline-end: -60px;
    animation-delay: -5s;
}

.login-left-inner {
    position: relative;
    z-index: 1;
    max-inline-size: 460px;
    inline-size: 100%;
}

/* Brand */
.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-block-end: 3rem;
    animation: loginSlideRight 0.7s ease both;
}
.login-brand-icon {
    inline-size: 54px;
    block-size: 54px;
    border-radius: 16px;
    background: rgba(255,255,255,0.18);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
    padding: 6px;
}
.login-brand-icon img {
    inline-size: 100%;
    block-size: 100%;
    object-fit: contain;
    display: block;
}
.login-brand-icon:hover {
    transform: rotate(-6deg) scale(1.08);
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.login-brand-name {
    display: block;
    font-weight: 700;
    font-size: 1.125rem;
    letter-spacing: -0.01em;
}
.login-brand-sub {
    display: block;
    font-size: 0.8125rem;
    opacity: 0.75;
}

/* Headline */
.login-headline {
    margin-block-end: 2.5rem;
    animation: loginSlideRight 0.7s 0.1s ease both;
}
.login-headline h1 {
    font-size: clamp(2rem, 3vw, 2.75rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin-block-end: 1rem;
}
.login-headline h1 span {
    background: linear-gradient(90deg, #93c5fd, #c4b5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.login-headline p {
    font-size: 1rem;
    opacity: 0.8;
    line-height: 1.6;
    max-inline-size: 380px;
}

/* Feature pills */
.login-features {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-block-end: 2.5rem;
    animation: loginSlideRight 0.7s 0.2s ease both;
}
.login-feature-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    font-size: 0.8125rem;
    backdrop-filter: blur(6px);
    transition: background 0.25s, transform 0.25s;
    cursor: default;
}
.login-feature-pill:hover {
    background: rgba(255,255,255,0.22);
    transform: translateY(-2px);
}

/* Security badge */
.login-security {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    opacity: 0.65;
    animation: loginSlideRight 0.7s 0.3s ease both;
}

/* ── Right Panel (Card) ─────────────────────────────── */
.login-right {
    inline-size: 500px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: rgba(255,255,255,0.04);
    backdrop-filter: blur(2px);
}

.login-card {
    position: relative;
    inline-size: 100%;
    max-inline-size: 420px;
    background: #ffffff;
    border-radius: 24px;
    padding: 2.5rem 2.5rem 2rem;
    box-shadow:
        0 24px 64px rgba(0,0,0,0.22),
        0 8px 24px rgba(0,0,0,0.12),
        inset 0 1px 0 rgba(255,255,255,0.8);
    overflow: hidden;
    animation: loginFadeUp 0.65s 0.15s ease both;
}

/* Corner decoration dots */
.login-card-dot {
    position: absolute;
    inline-size: 80px;
    block-size: 80px;
    border-radius: 50%;
    pointer-events: none;
}
.login-card-dot-tl {
    inset-block-start: -30px;
    inset-inline-start: -30px;
    background: radial-gradient(circle, rgba(59,130,246,0.18), transparent 70%);
}
.login-card-dot-br {
    inset-block-end: -30px;
    inset-inline-end: -30px;
    background: radial-gradient(circle, rgba(124,58,237,0.15), transparent 70%);
}

/* Card header */
.login-card-header {
    text-align: center;
    margin-block-end: 1.75rem;
    animation: loginFadeUp 0.6s 0.3s ease both;
}
.login-card-avatar {
    inline-size: 80px;
    block-size: 80px;
    border-radius: 20px;
    background: #ffffff;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    box-shadow: 0 8px 24px rgba(30,58,138,0.15);
    animation: pulse-ring 2.5s ease 1.2s infinite;
    overflow: hidden;
    padding: 8px;
}
.login-card-avatar img {
    inline-size: 100%;
    block-size: 100%;
    object-fit: contain;
    display: block;
}
.login-card-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-block-end: 0.375rem;
    letter-spacing: -0.02em;
}
.login-card-header .subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Alert */
.login-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 0.875rem;
    margin-block-end: 1.25rem;
    animation: shake 0.45s ease;
}
.login-alert-error {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    color: #B91C1C;
}
.login-alert i { flex-shrink: 0; margin-block-start: 2px; }

/* Form */
.login-form-inner {
    display: flex;
    flex-direction: column;
    gap: 1.125rem;
    animation: loginFadeUp 0.6s 0.4s ease both;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.login-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-dark);
    letter-spacing: 0.01em;
}

.login-input-wrap {
    position: relative;
}
.login-input-icon {
    position: absolute;
    inset-inline-start: 14px;
    inset-block-start: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.875rem;
    pointer-events: none;
    transition: color 0.25s;
    z-index: 1;
}
.login-input-wrap.focused .login-input-icon {
    color: var(--primary-light);
}

.login-input {
    inline-size: 100%;
    padding: 12px 14px 12px 42px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--text-dark);
    background: #F8FAFC;
    transition: border-color 0.25s, background 0.25s, box-shadow 0.25s;
    outline: none;
    position: relative;
    z-index: 0;
}
.login-input::placeholder { color: #a0aec0; }
.login-input:focus {
    border-color: var(--primary-light);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(59,130,246,0.12);
}
.login-input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* animated underline bar on focus */
.login-input-focus-bar {
    position: absolute;
    inset-block-end: 0;
    inset-inline-start: 0;
    block-size: 2px;
    inline-size: 100%;
    background: var(--primary-gradient);
    border-radius: 0 0 12px 12px;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0s;
    pointer-events: none;
}
.login-input-wrap.focused .login-input-focus-bar {
    animation: focusBar 0.3s ease forwards;
}

/* Password toggle */
.login-pw-toggle {
    position: absolute;
    inset-inline-end: 12px;
    inset-block-start: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    font-size: 0.875rem;
    transition: color 0.2s;
    z-index: 2;
}
.login-pw-toggle:hover { color: var(--primary-light); }
/* Shift password input right to avoid overlap */
.login-input-wrap:has(.login-pw-toggle) .login-input {
    padding-inline-end: 40px;
}

/* Submit button */
.login-btn {
    position: relative;
    overflow: hidden;
    margin-block-start: 0.5rem;
    inline-size: 100%;
    padding: 13px;
    border: none;
    border-radius: 12px;
    background: var(--primary-gradient);
    color: white;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    box-shadow: 0 4px 20px rgba(30,58,138,0.35);
}
.login-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(30,58,138,0.45);
}
.login-btn:active:not(:disabled) {
    transform: translateY(0);
}
.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-btn-loader { display: none; }
.login-btn.loading .login-btn-text  { display: none; }
.login-btn.loading .login-btn-loader { display: inline-block; }

/* Ripple */
.login-btn-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.35);
    transform: translate(-50%, -50%);
    pointer-events: none;
}
.login-btn-ripple.animate {
    animation: rippleOut 0.6s linear forwards;
}

/* Hint box */
.login-hint-box {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-block-start: 1.25rem;
    padding: 12px 14px;
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    border-radius: 12px;
    font-size: 0.8125rem;
    color: #1E40AF;
    animation: loginFadeUp 0.6s 0.5s ease both;
}
.login-hint-box i { flex-shrink: 0; margin-block-start: 2px; color: #3B82F6; }

/* Verify button */
.login-verify-wrap {
    margin-block-start: 1.25rem;
    padding-block-start: 1.25rem;
    border-block-start: 1px solid var(--border);
    animation: loginFadeUp 0.6s 0.55s ease both;
}
.login-verify-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    inline-size: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
    color: white;
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 16px rgba(47,133,90,0.3);
}
.login-verify-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(47,133,90,0.4);
}
.login-verify-arrow {
    margin-inline-start: auto;
    transition: transform 0.25s;
}
.login-verify-btn:hover .login-verify-arrow {
    transform: translateX(4px);
}
.login-verify-caption {
    margin-block-start: 6px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Footer */
.login-footer-text {
    margin-block-start: 1.5rem;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-muted);
    animation: loginFadeUp 0.6s 0.6s ease both;
}

/* =====================================================
   MODAL
   ===================================================== */
.modal {
    display: none;
    position: fixed;
    inset-block-start: 0;
    inset-inline-start: 0;
    inset-inline-end: 0;
    inset-block-end: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    inline-size: 100%;
    max-inline-size: 500px;
    max-block-size: 90vh;
    overflow-y: auto;
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-block-end: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-block-start: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* =====================================================
   UTILITIES
   ===================================================== */
.text-center  { text-align: center; }
.text-right   { text-align: end; }
.text-left    { text-align: start; }
.text-muted   { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-sm      { font-size: 0.875rem; }
.text-xs      { font-size: 0.75rem; }
.font-bold    { font-weight: 700; }
.font-semi    { font-weight: 600; }
.font-mono    { font-family: 'Courier New', monospace; }

.mt-1 { margin-block-start: 0.25rem; }
.mt-2 { margin-block-start: 0.5rem; }
.mt-3 { margin-block-start: 0.75rem; }
.mt-4 { margin-block-start: 1rem; }
.mt-6 { margin-block-start: 1.5rem; }
.mb-1 { margin-block-end: 0.25rem; }
.mb-2 { margin-block-end: 0.5rem; }
.mb-3 { margin-block-end: 0.75rem; }
.mb-4 { margin-block-end: 1rem; }
.mb-6 { margin-block-end: 1.5rem; }
.p-0  { padding: 0 !important; }

.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.flex-wrap    { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.justify-end     { justify-content: flex-end; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.flex-1 { flex: 1; }
.shrink-0 { flex-shrink: 0; }
.w-full { inline-size: 100%; }

.hidden  { display: none; }
.block   { display: block; }
.rounded { border-radius: var(--radius-sm); }
.shadow  { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.overflow-hidden { overflow: hidden; }

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .main-content { margin-inline-start: 270px; }
}

@media (max-width: 768px) {
    /* Sidebar Mobile */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        inline-size: 270px;
        box-shadow: 6px 0 32px rgba(0,0,0,0.25);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset-block-start: 0; inset-inline-start: 0; inset-inline-end: 0; inset-block-end: 0;
        background: rgba(0,0,0,0.55);
        backdrop-filter: blur(2px);
        z-index: 99;
    }
    .sidebar-overlay.active { display: block; }
    .main-content { margin-inline-start: 0; max-inline-size: 100vw; overflow-x: hidden; }
    
    .content { padding: 1rem; }
    
    /* Mobile Menu Toggle */
    .mobile-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        inline-size: 40px;
        block-size: 40px;
        background: var(--secondary);
        border: none;
        border-radius: 8px;
        font-size: 1.25rem;
        cursor: pointer;
        color: var(--text-dark);
    }
    
    /* Grid Mobile */
    .grid-4, .grid-3, .grid-2 {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }
    /* Force all grid children to 1 column (overrides inline grid-column: span N) */
    .grid-2 > *, .grid-3 > *, .grid-4 > * {
        grid-column: 1 !important;
    }
    
    /* Login Mobile */
    .login-left {
        display: none;
    }

    .login-right {
        inline-size: 100%;
        padding: 1.25rem;
        background: transparent;
        min-block-size: 100vh;
        align-items: flex-start;
        padding-block-start: 2rem;
    }

    .login-card {
        padding: 2rem 1.5rem 1.5rem;
        border-radius: 20px;
        animation-delay: 0.05s;
    }

    .login-card-header h2 {
        font-size: 1.25rem;
    }

    .login-particles span { opacity: 0.12; }
    
    /* Topbar Mobile */
    .topbar {
        padding: 0 1rem;
        block-size: 56px;
    }
    
    .page-title h1 {
        font-size: 1rem;
    }
    
    .page-title p {
        display: none;
    }
    
    .content {
        padding: 1rem;
    }
    
    /* Card Mobile */
    .card-body {
        padding: 1rem;
    }
    .card-header {
        padding: 0.875rem 1rem;
        flex-wrap: wrap;
        gap: 0.625rem;
    }
    .card-header .btn {
        font-size: 0.75rem;
        padding: 0.4rem 0.75rem;
    }
    /* Metric Card Mobile */
    .metric-value { font-size: 1.5rem; }
    .metric-label { font-size: 0.7rem; }
    .card-metric .card-body { padding: 0.875rem 1rem; }
    
    /* Table Mobile */
    .table th, .table td {
        padding: 0.625rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .table th {
        font-size: 0.65rem;
    }
    
    .table-container {
        margin: 0 -1rem;
        inline-size: calc(100% + 2rem);
    }
    
    .table-actions {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .table-actions .btn-icon {
        inline-size: 28px;
        block-size: 28px;
        padding: 0.25rem;
        font-size: 0.75rem;
    }
    
    /* Form Mobile */
    .form-control {
        font-size: 16px; /* Prevents iOS zoom */
        padding: 0.75rem;
    }
    
    .form-select {
        font-size: 16px;
    }
    
    /* Modal Mobile */
    .modal-content {
        margin: 1rem;
        max-inline-size: calc(100% - 2rem);
        max-block-size: calc(100vh - 2rem);
        border-radius: 12px;
    }
    
    .modal-header, .modal-body, .modal-footer {
        padding: 1rem;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        inline-size: 100%;
        justify-content: center;
    }
    
    /* Buttons Mobile */
    .btn {
        padding: 0.625rem 1rem;
        font-size: 0.8125rem;
    }
    
    .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
    
    /* Action Bar Mobile */
    .flex.justify-between {
        flex-direction: column;
        gap: 1rem;
    }
    
    .flex.gap-2 {
        flex-wrap: wrap;
    }
    
    /* Inline Edit Mobile */
    .inline-edit-mhs, .inline-edit-nilai {
        inline-size: 100% !important;
        max-inline-size: 80px;
        padding: 4px !important;
        font-size: 0.75rem !important;
    }
    
    /* Badge Mobile */
    .badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.5rem;
    }
    
    /* Profile Card Mobile */
    .card .flex.items-center.gap-4 {
        gap: 0.75rem;
    }
    
    .card .flex.items-center.gap-4 > div:first-child {
        flex-shrink: 0;
    }
    
    /* Stats Grid on Dashboard */
    .grid-4 .card-body {
        padding: 0.875rem;
    }
    
    .grid-4 .card-body .flex {
        gap: 0.5rem;
    }
    
    .grid-4 .card-body div[style*="inline-size: 48px"] {
        inline-size: 40px !important;
        block-size: 40px !important;
    }
    
    /* Filter Form Mobile */
    form.flex.gap-2 {
        inline-size: 100%;
    }
    
    form.flex.gap-2 select,
    form.flex.gap-2 input[type="text"] {
        flex: 1;
        min-inline-size: 0;
    }
    
    /* Message Item Mobile */
    .pesan-item {
        padding: 0.75rem !important;
    }
    
    .pesan-item .flex.items-center.gap-3 {
        gap: 0.5rem;
    }
    
    .pesan-item div[style*="inline-size: 36px"] {
        inline-size: 28px !important;
        block-size: 28px !important;
        flex-shrink: 0;
    }
    
    /* Hide some columns on mobile */
    .hide-mobile {
        display: none !important;
    }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 480px) {
    .login-card {
        padding: 1.5rem 1.25rem;
    }

    .login-headline h1 {
        font-size: 1.75rem;
    }
    
    .metric-value {
        font-size: 1.25rem;
    }
    
    .card .grid-4 {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .card .grid-4 > div {
        font-size: 0.75rem;
    }
    
    /* Photo in profile smaller */
    .card div[style*="inline-size: 80px"] {
        inline-size: 60px !important;
        block-size: 60px !important;
    }
    
    .card h2[style*="font-size: 1.5rem"] {
        font-size: 1.125rem !important;
    }
    
    /* Status Cards in Dashboard */
    .grid-4[class*="mb-6"] .card-body {
        padding: 0.75rem;
    }
    
    .grid-4[class*="mb-6"] div[style*="font-size: 1.5rem"] {
        font-size: 1.125rem !important;
    }
}

/* =====================================================
   DARK MODE TOGGLE
   ===================================================== */
.theme-toggle {
    position: relative;
    inline-size: 52px;
    block-size: 28px;
    background: var(--border);
    border-radius: 14px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    padding: 0 3px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    flex-shrink: 0;
}
[data-theme="dark"] .theme-toggle {
    background: #334155;
}
.theme-toggle:hover { opacity: 0.88; }

.theme-toggle-slider {
    position: absolute;
    inline-size: 22px;
    block-size: 22px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
[data-theme="dark"] .theme-toggle-slider {
    transform: translateX(24px);
    background: var(--primary);
}
.theme-toggle-icon {
    font-size: 11px;
    color: var(--primary);
}
[data-theme="dark"] .theme-toggle-icon { color: white; 
    border-radius: 50%;
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

[data-theme="dark"] .theme-toggle-slider {
    transform: translateX(30px);
    background: var(--primary);
}

.theme-toggle-icon {
    font-size: 12px;
    color: var(--primary);
}

[data-theme="dark"] .theme-toggle-icon {
    color: white;
}

/* Notification Badge */
.notification-badge {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

.notification-badge .badge {
    position: absolute;
    inset-block-start: -5px;
    inset-inline-end: -5px;
    background: var(--danger);
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    min-inline-size: 18px;
    text-align: center;
}

/* Chart Container */
.chart-container {
    position: relative;
    block-size: 300px;
    margin: 1rem 0;
}

@media (max-width: 768px) {
    .chart-container {
        block-size: 250px;
    }
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--border);
    border-block-start: 3px solid var(--primary);
    border-radius: 50%;
    inline-size: 40px;
    block-size: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Smooth transitions for theme change */
body, .sidebar, .topbar, .card, .sidebar-footer,
.form-control, .modal-content, .table th, .btn {
    transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

/* =====================================================
   MAHASISWA — PROFILE HERO CARD
   ===================================================== */
.profile-hero {
    background: linear-gradient(135deg, #0F1F4F 0%, #1E3A8A 55%, #2563EB 100%);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    padding: 2rem 1.75rem 1.5rem;
    color: white;
    position: relative;
    overflow: hidden;
}
.profile-hero::before {
    content: '';
    position: absolute;
    inset-block-start: -40px; inset-inline-end: -40px;
    inline-size: 200px; block-size: 200px;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
    pointer-events: none;
}
.profile-hero::after {
    content: '';
    position: absolute;
    inset-block-end: -60px; inset-inline-start: -30px;
    inline-size: 160px; block-size: 160px;
    background: rgba(255,255,255,0.04);
    border-radius: 50%;
    pointer-events: none;
}
.profile-hero > * { position: relative; z-index: 1; }
.profile-avatar {
    inline-size: 76px; block-size: 76px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.35);
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
.profile-avatar-placeholder {
    inline-size: 76px; block-size: 76px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 800;
    color: white;
    flex-shrink: 0;
    letter-spacing: -0.02em;
}
.profile-meta-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    padding: 1.25rem 1.75rem;
    background: var(--card-bg);
    border-block-start: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.profile-meta-item { padding: 0.5rem 0; }
.profile-meta-item .label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-block-end: 2px;
}
.profile-meta-item .value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-dark);
}
@media (max-width: 768px) {
    .profile-meta-grid { grid-template-columns: repeat(2, 1fr); padding: 1rem; }
    .profile-hero { padding: 1.5rem 1rem 1.25rem; }
}
@media (max-width: 480px) {
    .profile-meta-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
}

/* =====================================================
   MAHASISWA — STAT CARDS
   ===================================================== */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.375rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon {
    inline-size: 52px; block-size: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.stat-icon.blue   { background: rgba(30,58,138,0.1);   color: #1E3A8A; }
.stat-icon.green  { background: rgba(5,150,105,0.1);   color: #059669; }
.stat-icon.indigo { background: rgba(79,70,229,0.1);   color: #4F46E5; }
.stat-icon.amber  { background: rgba(217,119,6,0.1);   color: #D97706; }
.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-dark);
    letter-spacing: -0.03em;
    line-height: 1.1;
}
.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.stat-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-block-start: 2px;
}
@media (max-width: 768px) {
    .stat-card { padding: 1rem; gap: 0.75rem; }
    .stat-icon { inline-size: 44px; block-size: 44px; font-size: 1.1rem; border-radius: 11px; }
    .stat-value { font-size: 1.5rem; }
}

/* =====================================================
   MAHASISWA — SEMESTER IPS CARDS
   ===================================================== */
.semester-cards-scroll {
    display: flex;
    gap: 0.875rem;
    overflow-x: auto;
    padding-block-end: 0.5rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}
.semester-cards-scroll::-webkit-scrollbar { block-size: 4px; }
.semester-cards-scroll::-webkit-scrollbar-track { background: var(--secondary); border-radius: 2px; }
.semester-cards-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.semester-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.125rem 1rem;
    min-inline-size: 148px;
    flex: 0 0 auto;
    text-align: center;
    scroll-snap-align: start;
    transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
    position: relative;
    overflow: hidden;
}
.semester-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--primary);
}
.semester-card::before {
    content: '';
    position: absolute;
    inset-block-start: 0; inset-inline-start: 0; inset-inline-end: 0;
    block-size: 3px;
    background: var(--primary-gradient);
    border-radius: 3px 3px 0 0;
}
.semester-num {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-block-end: 2px;
}
.semester-year {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-block-end: 0.625rem;
}
.semester-ips {
    font-size: 1.625rem;
    font-weight: 800;
    color: var(--text-dark);
    letter-spacing: -0.03em;
    line-height: 1;
    margin-block-end: 2px;
}
.semester-sks {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-block-end: 0.75rem;
}
.semester-actions { display: flex; gap: 0.375rem; justify-content: center; flex-wrap: wrap; }
@media (max-width: 480px) {
    .semester-card { min-inline-size: 132px; padding: 0.875rem 0.75rem; }
    .semester-ips { font-size: 1.375rem; }
}

/* =====================================================
   MOBILE RESPONSIVENESS — COMPREHENSIVE ENHANCEMENTS
   ===================================================== */

/* Prevent horizontal page overflow on all screens */
html {
    overflow-x: hidden;  /* fallback */
    overflow-x: clip;    /* modern: tidak memblok child horizontal scroll */
}
body {
    overflow-x: hidden;
    /* Safe area for full-screen / PWA mode */
    padding-block-end: env(safe-area-inset-bottom, 0px);
}

/* ── MOBILE (≤ 768px) ─────────────────────────────── */
@media (max-width: 768px) {

    /* ── 1. Prevent body overflow when sidebar opens ── */
    body.sidebar-open {
        overflow: hidden;
    }

    /* ── 2. Fix filter form wrapping ──────────────────
       Forms with class="flex gap-2" or "flex gap-3"
       that contain filter selects/inputs                */
    form.flex,
    form[class*="flex"] {
        flex-wrap: wrap !important;
        inline-size: 100%;
        gap: 0.5rem;
    }

    /* Override hardcoded inline-size on filter controls */
    form .form-control,
    form .form-select {
        inline-size: auto !important;
        min-inline-size: 0;
        flex: 1 1 120px;
        max-inline-size: 100%;
    }

    /* Keep table inline-edit inputs narrow */
    td .form-control,
    td input.form-control,
    .inline-edit-mhs,
    .inline-edit-nilai {
        inline-size: auto !important;
        flex: none !important;
    }

    /* ── 3. Fix flex containers: allow wrapping ───────
       Filter bars / action rows above/below tables     */
    .flex.items-center.gap-2,
    .flex.items-center.gap-3,
    .flex.gap-2:not(.table-actions):not(.semester-actions),
    .flex.gap-3:not(.btn-group) {
        flex-wrap: wrap;
    }

    /* Card header button groups should wrap */
    .card-header {
        flex-wrap: wrap !important;
        align-items: flex-start;
    }
    .card-header > * {
        flex-shrink: 0;
    }

    /* ── 4. Modal maximum width override ─────────────
       CSS cannot override inline style without
       !important when set as max-inline-size attr      */
    .modal-content {
        max-inline-size: calc(100vw - 1.5rem) !important;
        inline-size: calc(100vw - 1.5rem) !important;
        margin: 0.75rem auto !important;
        max-block-size: calc(100dvh - 1.5rem) !important;
        overflow-y: auto;
    }

    /* ── 5. Table scroll container ───────────────────
       Table needs a hard min-width so overflow-x works */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table {
        min-inline-size: 560px;
    }

    /* ── 6. Page title — prevent overflow ──────────── */
    .page-title {
        flex: 1;
        min-inline-size: 0;
        overflow: hidden;
    }
    .page-title h1 {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* ── 7. Topbar right-side actions – compact ──────  */
    .topbar > div:last-child {
        gap: 0.5rem;
        flex-shrink: 0;
    }

    /* ── 8. Dashboard metric cards: ensure 2 columns ─ */
    .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem;
    }
    .grid-4 > * {
        grid-column: auto !important;
    }

    /* ── 9. Touch target minimums ─────────────────────
       iOS/Android HIG: 44×44 pt minimum tap target    */
    .btn {
        min-block-size: 40px;
    }
    .btn-icon {
        min-inline-size: 40px;
        min-block-size: 40px;
    }
    .nav-item {
        min-block-size: 44px;
    }

    /* ── 10. Sidebar safe-area (notch) ───────────────  */
    .sidebar {
        padding-inline-start: env(safe-area-inset-left, 0px);
    }
    .sidebar-footer {
        padding-block-end: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    }

    /* ── 11. Main content bottom safe area ───────────  */
    .main-content {
        padding-block-end: env(safe-area-inset-bottom, 0px);
    }

    /* ── 12. Login page tweaks ────────────────────────
       Card should not overflow on narrow phones        */
    .login-card {
        inline-size: 100%;
        max-inline-size: 420px;
    }

    /* ── 13. Action tools row (above tables) ─────────
       e.g. batch select + bulk action + search         */
    .flex[class*="mb"] > form,
    .mb-4 > .flex > form {
        flex-wrap: wrap;
    }

    /* ── 14. Responsive filter bar container ─────────
       The full row containing form + result info       */
    .content .flex.items-center {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* ── 15. Scroll hint for table areas ─────────────  */
    .table-container::after {
        content: '';
        display: block;
    }

    /* ── 16. Sidebar overlay close area ─────────────  */
    .sidebar-overlay {
        cursor: pointer;
    }

    /* ── 17. Compact verification page on mobile ──── */
    .verifikasi-card {
        margin: 0.75rem;
        padding: 1.25rem;
    }
}

/* ── EXTRA SMALL (≤ 480px) ────────────────────────────── */
@media (max-width: 480px) {

    /* Metric grid: 2-column stays */
    .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem;
    }

    /* Topbar height reduction */
    .topbar {
        block-size: 52px;
        padding: 0 0.75rem;
    }

    /* Content padding */
    .content {
        padding: 0.75rem;
    }

    /* Card body */
    .card-body {
        padding: 0.875rem;
    }

    /* Page title smaller */
    .page-title h1 {
        font-size: 0.9rem;
    }

    /* Filter inputs: each takes full row on tiny phones */
    form .form-control,
    form .form-select {
        flex: 1 0 100%;
    }

    /* Buttons in modal footer: stack */
    .modal-footer {
        flex-direction: column;
        gap: 0.5rem;
    }
    .modal-footer .btn {
        inline-size: 100%;
        justify-content: center;
    }

    /* Table: even smaller text */
    .table th {
        font-size: 0.6rem;
        padding: 0.5rem 0.4rem;
    }
    .table td {
        font-size: 0.75rem;
        padding: 0.5rem 0.4rem;
    }

    /* Stat cards compact */
    .stat-card {
        padding: 0.875rem;
        gap: 0.625rem;
    }
    .stat-icon {
        inline-size: 40px;
        block-size: 40px;
        border-radius: 10px;
    }
    .stat-value {
        font-size: 1.25rem;
    }

    /* Badge compact */
    .badge {
        font-size: 0.6rem;
        padding: 1px 5px;
    }

    /* Sidebar header compact */
    .sidebar-header {
        padding: 1.125rem 1rem;
    }

    /* Quick action buttons: stack */
    .card .flex.gap-2 a.btn {
        flex: 1 1 130px;
    }
}

/* ── BOTTOM NAVIGATION BAR (mobile mahasiswa & admin) ─── */
/* Shown only on small screens as a supplemental tab bar   */
/* Default: hidden — shown only via max-width media query  */
.bottom-nav {
    display: none;
}
@media (max-width: 768px) {
    /* Bottom nav bar */
    .bottom-nav {
        display: flex;
        position: fixed;
        inset-block-end: 0;
        inset-inline-start: 0;
        inset-inline-end: 0;
        background: var(--card-bg);
        border-block-start: 1px solid var(--border);
        box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
        z-index: 98;
        padding-block-end: env(safe-area-inset-bottom, 0px);
        block-size: calc(56px + env(safe-area-inset-bottom, 0px));
    }
    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: var(--text-muted);
        text-decoration: none;
        font-size: 0.6rem;
        font-weight: 500;
        padding: 6px 4px 4px;
        transition: color 0.2s ease, background 0.2s ease;
        -webkit-tap-highlight-color: transparent;
        min-block-size: 44px;
        position: relative;
    }
    .bottom-nav-item i {
        font-size: 1.1rem;
        line-height: 1;
    }
    .bottom-nav-item.active {
        color: var(--primary);
    }
    .bottom-nav-item.active::before {
        content: '';
        position: absolute;
        inset-block-start: 0;
        inset-inline-start: 20%;
        inline-size: 60%;
        block-size: 2px;
        background: var(--primary);
        border-radius: 0 0 2px 2px;
    }
    .bottom-nav-item:hover {
        color: var(--primary);
        background: var(--secondary);
    }
    .bottom-nav-badge {
        position: absolute;
        inset-block-start: 4px;
        inset-inline-end: calc(50% - 18px);
        background: var(--danger);
        color: white;
        font-size: 0.55rem;
        font-weight: 700;
        border-radius: 10px;
        padding: 1px 4px;
        min-inline-size: 14px;
        text-align: center;
    }
    /* Button-type item (Menu toggle) */
    button.bottom-nav-item {
        border: none;
        background: none;
        cursor: pointer;
        font-family: inherit;
    }
    /* Push main content above the bottom nav */
    .main-content {
        padding-block-end: calc(56px + env(safe-area-inset-bottom, 0px));
    }
}
/* Hide bottom nav on desktop */
@media (min-width: 769px) {
    .bottom-nav { display: none !important; }
}

/* ── PWA Install Banner — above bottom nav on mobile ─ */
@media (max-width: 768px) {
    #install-banner {
        inset-block-end: calc(56px + 16px + env(safe-area-inset-bottom, 0px)) !important;
        inset-inline-end: 0.75rem !important;
        max-inline-size: calc(100vw - 1.5rem) !important;
        border-radius: 12px !important;
    }
}

/* ── Smooth content transition when sidebar opens ──── */
.main-content {
    transition: none; /* Avoid layout jank on mobile */
}

/* ── Scroll bounce / rubber band fix on iOS ─────────  */
.modal-content,
.sidebar {
    -webkit-overflow-scrolling: touch;
}

/* ── Print: hide sidebar + bottom nav ───────────────── */
@media print {
    .sidebar,
    .topbar,
    .bottom-nav,
    .sidebar-overlay,
    #install-banner {
        display: none !important;
    }
    .main-content {
        margin-inline-start: 0 !important;
        padding-block-end: 0 !important;
    }
    .content {
        padding: 0 !important;
    }
}

/* =====================================================
   ENHANCED MOBILE RESPONSIVENESS (HP / Phone View)
   Target: ≤768px primary, ≤480px secondary
   ===================================================== */

/* ── Smooth scrolling for the whole app ────────────── */
html {
    scroll-behavior: smooth;
}

/* ── Table: Card-style layout on mobile ─────────────── */
@media (max-width: 768px) {

    /* ── General layout fix: constrain media & block elements only ── */
    /* NOTE: Do NOT use * here — it breaks horizontal scroll containers */
    /* NOTE: canvas excluded — block-size:auto breaks Chart.js height calculation */
    img, video, object, embed {
        max-inline-size: 100%;
        block-size: auto;
    }
    /* iframe max-width only, no height reset */
    iframe {
        max-inline-size: 100%;
    }
    .card, .btn, .form-control, .form-select,
    .table-container, .modal-content, .topbar,
    .content, .main-content {
        max-inline-size: 100%;
    }

    /* ── Topbar: compact & clean ─────────────────────── */
    .topbar {
        padding: 0 0.875rem;
        block-size: 56px;
        gap: 0.5rem;
    }
    .topbar .flex.items-center.gap-3 {
        gap: 0.625rem;
    }

    /* ── Page title: no subtitle on very small screens ── */
    .page-title {
        flex: 1;
        min-inline-size: 0;
    }
    .page-title h1 {
        font-size: 0.95rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* ── Content area ─────────────────────────────────── */
    .content {
        padding: 0.875rem;
    }

    /* ── Cards ────────────────────────────────────────── */
    .card {
        border-radius: var(--radius-sm);
    }
    .card-header {
        padding: 0.875rem 1rem;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    .card-body {
        padding: 1rem;
    }
    .card-title {
        font-size: 0.875rem;
    }

    /* ── Quick-action banner on dashboard ────────────── */
    .card[style*="667EEA"] .card-body,
    .card[style*="764BA2"] .card-body {
        padding: 1rem !important;
    }
    .card[style*="667EEA"] .flex.gap-2,
    .card[style*="764BA2"] .flex.gap-2 {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .card[style*="667EEA"] .btn,
    .card[style*="764BA2"] .btn {
        flex: 1 1 auto;
        justify-content: center;
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }

    /* ── Grid overrides ───────────────────────────────── */
    .grid-2 {
        grid-template-columns: 1fr !important;
    }
    .grid-3 {
        grid-template-columns: 1fr !important;
    }
    /* grid-4 stays 2-col (metric cards) via earlier rule */

    /* ── Filter forms: full-width controls ───────────── */
    /* Override inline-style fixed widths (both inline-size: and inline-size:) */
    form .form-control,
    form .form-select,
    form select,
    form input[type="text"],
    form input[type="search"],
    form input[type="date"] {
        inline-size: 100% !important;
        inline-size: 100% !important;
        max-inline-size: 100% !important;
        min-inline-size: 0 !important;
        flex: 1 1 120px;
    }

    /* Keep table cell inputs narrow — not full-width */
    td .form-control,
    td input.form-control,
    td select.form-control,
    .inline-edit-mhs,
    .inline-edit-nilai {
        inline-size: auto !important;
        inline-size: auto !important;
        flex: none !important;
    }

    /* Selects that are used as standalone filters */
    select.form-control,
    select.form-select {
        inline-size: 100% !important;
        inline-size: 100% !important;
        flex: 1 1 auto;
    }

    /* ── Filter bar row ───────────────────────────────── */
    form.flex,
    .flex.gap-2.mb-4,
    .flex.items-center.mb-4,
    .flex.items-center.gap-2.mb-6 {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    /* ── Table: scrollable with visual scroll hint ──────  */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius-sm);
        /* Scroll shadow hint */
        background:
            linear-gradient(to right, var(--card-bg) 30%, transparent) left / 20px 100% no-repeat,
            linear-gradient(to left,  var(--card-bg) 30%, transparent) right / 20px 100% no-repeat,
            radial-gradient(farthest-side at 0 50%, rgba(0,0,0,0.1), transparent) left / 10px 100% no-repeat,
            radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.1), transparent) right / 10px 100% no-repeat,
            var(--card-bg);
        background-attachment: local, local, scroll, scroll, local;
    }
    .table {
        min-inline-size: 520px;
    }

    /* ── Table cells more compact ────────────────────── */
    .table th {
        font-size: 0.65rem;
        padding: 0.6rem 0.625rem;
        white-space: nowrap;
    }
    .table td {
        font-size: 0.8rem;
        padding: 0.75rem 0.625rem;
        vertical-align: middle;
    }

    /* ── Table action column ─────────────────────────── */
    .table-actions {
        display: flex;
        flex-direction: row;
        gap: 0.25rem;
        flex-wrap: nowrap;
    }
    .table-actions .btn-icon,
    .table-actions a.btn-icon,
    .table-actions button.btn-icon {
        inline-size: 32px;
        block-size: 32px;
        min-inline-size: 32px;
        padding: 0;
        font-size: 0.75rem;
    }

    /* ── Buttons ──────────────────────────────────────── */
    .btn {
        padding: 0.5625rem 0.875rem;
        font-size: 0.8125rem;
        min-block-size: 40px;
    }
    .btn-sm {
        padding: 0.4375rem 0.6875rem;
        font-size: 0.75rem;
        min-block-size: 36px;
    }
    .btn-icon {
        inline-size: 38px;
        block-size: 38px;
        min-inline-size: 38px;
        min-block-size: 38px;
        padding: 0;
    }

    /* ── Badge ────────────────────────────────────────── */
    .badge {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    /* ── Metric cards: 2-col ─────────────────────────── */
    .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
    /* Allow children to auto-place across both columns */
    .grid-4 > * {
        grid-column: auto !important;
    }
    .grid-4 .card-body {
        padding: 0.875rem 1rem;
    }
    .metric-value {
        font-size: 1.5rem;
    }
    .metric-label {
        font-size: 0.7rem;
    }

    /* ── Stat cards ───────────────────────────────────── */
    .stat-card {
        padding: 0.875rem 1rem;
        gap: 0.75rem;
    }
    .stat-icon {
        inline-size: 44px;
        block-size: 44px;
        border-radius: 12px;
        font-size: 1.1rem;
        flex-shrink: 0;
    }
    .stat-value {
        font-size: 1.5rem;
    }

    /* ── Profile hero ─────────────────────────────────── */
    .profile-hero {
        padding: 1.25rem 1rem 1rem;
    }
    .profile-meta-grid {
        grid-template-columns: repeat(2, 1fr);
        padding: 1rem;
        gap: 0.75rem;
    }

    /* ── Modal ────────────────────────────────────────── */
    .modal {
        align-items: flex-end !important;
    }
    .modal-content {
        border-radius: 16px 16px 0 0 !important;
        inline-size: 100% !important;
        max-inline-size: 100% !important;
        margin: 0 !important;
        max-block-size: 90dvh !important;
    }
    .modal-header {
        padding: 1rem 1.25rem;
    }
    .modal-body {
        padding: 1.25rem;
    }
    .modal-footer {
        padding: 0.875rem 1.25rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    .modal-footer .btn {
        inline-size: 100%;
        justify-content: center;
    }

    /* ── Form controls ────────────────────────────────── */
    .form-control,
    .form-select {
        font-size: 16px; /* prevents iOS zoom */
        padding: 0.6875rem 0.875rem;
    }
    .form-label {
        font-size: 0.8125rem;
    }
    .form-group {
        margin-block-end: 0.875rem;
    }

    /* ── Topbar notification icon touch target ────────── */
    .notification-badge a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        block-size: 40px;
        inline-size: 40px;
    }

    /* ── Mobile toggle button ─────────────────────────── */
    .mobile-toggle {
        inline-size: 40px !important;
        block-size: 40px !important;
        border-radius: var(--radius-sm) !important;
        font-size: 1.1rem !important;
        flex-shrink: 0;
    }

    /* ── Chart ────────────────────────────────────────── */
    .chart-container {
        block-size: 240px;
    }

    /* ── Inline-edit inputs in table ─────────────────── */
    .inline-edit-mhs,
    .inline-edit-nilai,
    td input[type="number"],
    td input[type="text"] {
        inline-size: 70px !important;
        font-size: 0.75rem !important;
        padding: 4px 6px !important;
    }

    /* ── Semester scroll cards ────────────────────────── */
    .semester-cards-scroll {
        overflow-x: auto !important;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x pan-y;
        overscroll-behavior-x: contain;
        scroll-snap-type: x mandatory;
        scroll-padding-inline: 0.875rem;
        /* Prevent shadow clipping on first/last card */
        padding-inline: 0.25rem;
        padding-block-end: 0.75rem;
        /* Ensure the container fills its parent width */
        inline-size: 100%;
        max-inline-size: 100%;
    }
    .semester-card {
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        min-inline-size: 140px !important;
        max-inline-size: none !important; /* must NOT be limited to 100% */
        inline-size: auto !important;
    }

    /* ── Empty state ──────────────────────────────────── */
    td[colspan] > div {
        padding: 2rem 1rem;
    }

    /* ── Breadcrumb / pills row ───────────────────────── */
    .flex.gap-2.flex-wrap,
    .flex.gap-3.flex-wrap {
        gap: 0.4rem;
    }

    /* ── Text overflow protection ─────────────────────── */
    .card-title,
    .page-title h1 {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-inline-size: 100%;
    }
}

/* ── EXTRA SMALL phones (≤ 480px) ────────────────────── */
@media (max-width: 480px) {
    .content {
        padding: 0.625rem;
    }
    .card-body {
        padding: 0.75rem;
    }
    .card-header {
        padding: 0.75rem;
    }

    /* Topbar */
    .topbar {
        padding: 0 0.625rem;
        block-size: 52px;
    }

    /* Page title */
    .page-title h1 {
        font-size: 0.875rem;
    }

    /* Metric grid: 2-col compact */
    .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }
    .grid-4 > * {
        grid-column: auto !important;
    }
    .metric-value { font-size: 1.25rem; }
    .card-metric .card-body { padding: 0.75rem !important; }

    /* Table */
    .table th {
        font-size: 0.6rem;
        padding: 0.5rem 0.4rem;
    }
    .table td {
        font-size: 0.75rem;
        padding: 0.625rem 0.4rem;
    }

    /* Buttons: full width in stacked contexts */
    .card-header .btn,
    .flex.flex-col .btn {
        inline-size: 100%;
        justify-content: center;
    }

    /* Stat cards */
    .stat-card {
        padding: 0.75rem;
        gap: 0.625rem;
    }
    .stat-icon {
        inline-size: 40px;
        block-size: 40px;
        border-radius: 10px;
        font-size: 1rem;
    }
    .stat-value { font-size: 1.25rem; }
    .stat-label { font-size: 0.7rem; }

    /* Profile meta: 2-col compact */
    .profile-meta-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        padding: 0.75rem;
    }
    .profile-hero {
        padding: 1rem 0.875rem;
    }

    /* Sidebar header compact */
    .sidebar-header {
        padding: 1rem;
    }

    /* Filter: full-width selects */
    form .form-control,
    form .form-select,
    form select {
        flex: 1 0 100% !important;
        inline-size: 100% !important;
        max-inline-size: 100% !important;
    }

    /* Chart */
    .chart-container {
        block-size: 200px;
    }

    /* Semester cards */
    .semester-card {
        min-inline-size: 120px;
        padding: 0.75rem 0.625rem;
    }
    .semester-ips { font-size: 1.25rem; }

    /* Modal */
    .modal-header,
    .modal-body {
        padding: 1rem;
    }

    /* Bottom nav labels */
    .bottom-nav-item span {
        font-size: 0.55rem;
    }
    .bottom-nav-item i {
        font-size: 1rem;
    }
}

/* ── LANDSCAPE phones (short but wide) ───────────────── */
@media (max-width: 896px) and (max-height: 430px) {
    .sidebar {
        overflow-y: auto;
        padding-block-end: 0.5rem;
    }
    .bottom-nav {
        display: none !important;
    }
    .main-content {
        padding-block-end: 0 !important;
    }
    .content {
        padding: 0.5rem 0.875rem;
    }
    .topbar {
        block-size: 48px;
    }
}

/* ── SWIPE-FRIENDLY sidebar overlay ──────────────────── */
@media (max-width: 768px) {
    .sidebar-overlay {
        touch-action: pan-y;
    }
    /* Tap highlight removal for all interactive mobile elements */
    .nav-item,
    .bottom-nav-item,
    .btn,
    .theme-toggle,
    .mobile-toggle {
        -webkit-tap-highlight-color: transparent;
    }
}

/* ── CARD-STYLE TABLE ROWS on very small screens ────── */
/* Apply .table-mobile-cards class to .table-container for card view */
@media (max-width: 480px) {
    .table-mobile-cards .table {
        min-inline-size: 0;
    }
    .table-mobile-cards .table thead {
        display: none;
    }
    .table-mobile-cards .table tbody tr {
        display: flex;
        flex-direction: column;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        margin-block-end: 0.75rem;
        padding: 0.75rem;
        background: var(--card-bg);
        box-shadow: var(--shadow-sm);
    }
    .table-mobile-cards .table tbody tr td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 0.25rem 0;
        border-block-end: none;
        font-size: 0.8125rem;
        gap: 0.5rem;
    }
    .table-mobile-cards .table tbody tr td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        white-space: nowrap;
        flex-shrink: 0;
    }
    .table-mobile-cards .table tbody tr td:last-child {
        justify-content: flex-end;
        padding-block-start: 0.5rem;
        margin-block-start: 0.25rem;
        border-block-start: 1px solid var(--border);
    }
    .table-mobile-cards .table tbody tr td:last-child::before {
        display: none;
    }
    .table-mobile-cards .table-actions {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-end;
        gap: 0.375rem;
    }
    .table-mobile-cards .table-actions .btn-icon {
        inline-size: 34px;
        block-size: 34px;
    }
}

