:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #0b1120;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #475569;
    --border: #e2e8f0;
    --sidebar-width: 260px;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: system-ui, -apple-system, sans-serif; }
body { background: var(--bg-body); color: var(--text-main); }
.hidden { display: none !important; }

/* === Typography & Globals === */
h1, h2, h3, h4 { color: var(--secondary); line-height: 1.2; }
a { text-decoration: none; color: inherit; }
.btn-main { background: var(--primary); color: white; padding: 14px 24px; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; }
.btn-main:hover { background: var(--primary-dark); }
.text-center { text-align: center; }

/* === Modal Logic === */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(11, 17, 32, 0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.login-card { background: white; padding: 3rem; border-radius: 16px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); color: var(--text-main); width: 90%; max-width: 440px; position: relative; }
.close-modal { position: absolute; top: 15px; right: 15px; background: #f1f5f9; border: none; width: 35px; height: 35px; border-radius: 50%; font-size: 1.2rem; cursor: pointer; color: var(--text-muted); transition: 0.2s; }
.close-modal:hover { background: #e2e8f0; color: #000; }
.login-card h2 { margin-bottom: 0.5rem; text-align: center;}
.login-card p { color: var(--text-muted); margin-bottom: 2rem; font-size: 0.95rem; text-align: center; }
.brand-badge { background: #eff6ff; padding: 8px 16px; border-radius: 50px; font-size: 0.85rem; font-weight: bold; width: fit-content; color: var(--primary); text-align: center;}

/* === Forms === */
.input-group { margin-bottom: 1.5rem; }
.input-group label { display: block; font-size: 0.85rem; font-weight: 700; margin-bottom: 0.5rem; }
.input-group input, .admin-select { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 1rem; }
.input-group input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.error-box { color:#dc2626; background: #fef2f2; padding: 12px; border-radius: 8px; margin-top:1.5rem; text-align:center; font-weight:600; border: 1px solid #fecaca; }

/* === Dashboard Layout === */
#dashboard { display: flex; min-height: 100vh; }
aside { width: var(--sidebar-width); background: white; border-right: 1px solid var(--border); padding: 2rem 1.5rem; position: fixed; height: 100vh; display: flex; flex-direction: column; }
.brand-logo { font-size: 1.5rem; font-weight: 800; margin-bottom: 2rem; }
.sidebar-label { font-size: 0.75rem; text-transform: uppercase; font-weight: 800; color: var(--text-muted); letter-spacing: 0.5px; margin-bottom: 10px; padding-left: 10px; }
.nav-btn { padding: 12px 16px; margin-bottom: 8px; border-radius: 8px; border: none; background: transparent; text-align: left; font-weight: 600; cursor: pointer; color: var(--text-muted); width: 100%; display: block; transition: 0.2s;}
.nav-btn.active, .nav-btn:hover { background: var(--bg-body); color: var(--primary); }
.logout-btn { color: #dc2626; background: #fef2f2; }

.dash-main-area { margin-left: var(--sidebar-width); flex: 1; display: flex; flex-direction: column; }
header { background: white; padding: 1rem 3rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 10; }
.search-box input { padding: 12px 24px; border-radius: 50px; border: 1px solid var(--border); width: 350px; outline: none; }
.user-profile-tag { font-weight: 700; background: #e2e8f0; padding: 8px 16px; border-radius: 50px; }

.dash-content { padding: 3rem; max-width: 1400px; margin: 0 auto; width: 100%; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 2rem; }
.pill { padding: 8px 16px; border-radius: 50px; border: 1px solid var(--border); background: white; cursor: pointer; font-weight: 600; }
.pill.active { background: var(--secondary); color: white; border-color: var(--secondary); }

/* === Grid & Cards === */
.data-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; }
.data-card { background: white; border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; display: flex; flex-direction: column; justify-content: space-between; transition: 0.2s; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.data-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--primary); }
.locked-card { background: #f8fafc; opacity: 0.8; }
.locked-card:hover { border-color: #fbbf24; }

.inst-tag { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; color: var(--primary); background: #eff6ff; padding: 4px 8px; border-radius: 4px; display: inline-block; margin-bottom: 1rem; }
.topic-tag { color: #059669; background: #d1fae5; }
.data-title { font-size: 1.1rem; margin-bottom: 1.5rem; }

/* === Action Buttons & Load More === */
.action-link { padding: 12px; background: #f1f5f9; color: var(--primary-dark); text-align: center; border-radius: 8px; font-weight: 600; display: block; transition: 0.2s; cursor: pointer;}
.action-link:hover { background: var(--primary); color: white; }
.free-link { background: #e0e7ff; color: var(--primary-dark); border: 1px dashed var(--primary); }
.primary-link { background: var(--primary); color: white; }
.locked-link { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.locked-link:hover { background: #fbbf24; color: white; border-color: #fbbf24;}

/* NEW: Load More Button Styling */
.load-more-btn { width: 100%; padding: 14px; margin-top: 1.5rem; border: 2px dashed var(--border); border-radius: 12px; background: transparent; font-weight: 700; color: var(--text-muted); cursor: pointer; transition: 0.2s; }
.load-more-btn:hover { border-color: var(--primary); color: var(--primary); background: #eff6ff; }

.group-title { margin: 2rem 0 1rem; }
.badge { background: var(--primary); color: white; font-size: 0.8rem; padding: 4px 8px; border-radius: 50px; vertical-align: middle; margin-left: 10px;}

/* === Profile Page Specific === */
.profile-page-body { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: var(--bg-body); padding: 2rem; }
.profile-card { background: white; width: 100%; max-width: 600px; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.p-header { background: var(--secondary); padding: 2rem; color: white; text-align: center; }
.avatar { width: 80px; height: 80px; background: white; color: var(--secondary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: bold; margin: 0 auto 1rem; }
.details-grid { padding: 2rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.detail-item { border-bottom: 1px solid var(--border); padding-bottom: 10px;}
.detail-item .label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; font-weight: 700; display: block; margin-bottom: 0.25rem; }
.detail-item .value { font-weight: 600; font-size: 1.1rem; color: var(--secondary); }
.expiry-alert { color: #dc2626 !important; }

/* === Admin Specific === */
.admin-body { padding: 3rem; background: var(--bg-body); }
.admin-container { max-width: 700px; margin: 0 auto; background: white; padding: 2rem; border-radius: 16px; box-shadow: var(--shadow); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.admin-textarea { width: 100%; height: 150px; margin-top: 1rem; background: var(--secondary); color: #4ade80; padding: 1rem; font-family: monospace; border-radius: 8px; resize: none;}

/* Responsiveness */
@media (max-width: 900px) {
    aside { display: none; }
    .dash-main-area { margin-left: 0; }
    header { padding: 1rem; flex-direction: column; gap: 1rem; align-items: stretch;}
    .dash-content { padding: 1.5rem; }
    .search-box input { width: 100%; }
    .details-grid { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
}