/* ── Reset & Variables ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #eef2ff;
  --bg2:       #f5f7ff;
  --card:      #ffffff;
  --border:    rgba(0,0,0,0.09);
  --t1:        #111827;
  --t2:        #4b5563;
  --t3:        #9ca3af;
  --red:       #942A25;
  --blue:      #2563eb;
  --indigo:    #4f46e5;
  --purple:    #7c3aed;
  --green:     #16a34a;
  --danger:    #ef4444;
  --shadow:    0 4px 24px rgba(0,0,0,.08);
}

[data-theme="dark"] {
  --bg:     #0f1117;
  --bg2:    #13151f;
  --card:   #1c1f2e;
  --border: rgba(255,255,255,0.08);
  --t1:     #f1f5f9;
  --t2:     #94a3b8;
  --t3:     #475569;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--t1);
  min-height: 100vh;
  transition: background .3s, color .3s;
  line-height: 1.6;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Typography ────────────────────────────────────────────────────────────── */
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1rem;  font-weight: 700; }
.muted { color: var(--t3); }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 20px; border-radius: 10px;
  font-size: 14px; font-weight: 600;
  border: 1px solid var(--border);
  cursor: pointer; transition: all .2s;
  background: transparent; color: var(--t1);
  text-decoration: none;
}
.btn:hover { background: var(--bg2); opacity: .9; text-decoration: none; }
.btn:active { transform: scale(.97); }

.btn-primary { background: linear-gradient(135deg, var(--blue), var(--indigo)); color: #fff; border-color: transparent; }
.btn-indigo  { background: linear-gradient(135deg, var(--indigo), var(--purple)); color: #fff; border-color: transparent; }
.btn-ghost   { background: var(--card); border-color: var(--border); color: var(--t2); }
.btn-danger  { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.btn-sm      { padding: 5px 12px; font-size: 12px; border-radius: 7px; }

/* ── Flash Messages ────────────────────────────────────────────────────────── */
.flash-container {
  position: fixed; top: 70px; right: 1rem; z-index: 9000;
  display: flex; flex-direction: column; gap: .5rem; max-width: 360px;
}
.flash {
  padding: 12px 16px; border-radius: 10px;
  font-size: 14px; font-weight: 500;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: var(--shadow);
  animation: slideIn .3s ease;
}
.flash-success { background: #dcfce7; color: #15803d; }
.flash-error   { background: #fee2e2; color: #b91c1c; }
.flash-close   { background: none; border: none; cursor: pointer; font-size: 16px; color: inherit; opacity: .6; }
@keyframes slideIn { from { opacity:0; transform:translateY(-10px); } to { opacity:1; transform:translateY(0); } }

/* ── Dark Mode Toggle ──────────────────────────────────────────────────────── */
.dark-toggle {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 500;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--border);
  cursor: pointer; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow); transition: all .2s;
}
.dark-toggle:hover { transform: scale(1.12); }

/* ── Top Nav ───────────────────────────────────────────────────────────────── */
.topnav {
  background: var(--card); border-bottom: 1px solid var(--border);
  padding: 0 1.5rem; height: 58px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.nav-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: .95rem; color: var(--red);
}
.nav-logo {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-user  { font-size: 13px; color: var(--t2); }

/* ── Homepage ──────────────────────────────────────────────────────────────── */
.home-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  padding: 2rem 1rem;
  background: radial-gradient(ellipse 60% 40% at 20% 20%, rgba(99,102,241,.1) 0%, transparent 60%),
              radial-gradient(ellipse 50% 40% at 80% 80%, rgba(168,85,247,.08) 0%, transparent 60%),
              var(--bg);
}
.home-wrap { max-width: 860px; width: 100%; }
.home-header { text-align: center; margin-bottom: 2.5rem; }
.college-row {
  display: flex; align-items: center; justify-content: center;
  gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.clg-logo {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px; flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(148,42,37,.25);
}
.clg-name { font-size: clamp(1rem,3vw,1.35rem); font-weight: 700; color: var(--red); max-width:460px; text-align:left; line-height:1.3; }
.portal-title { font-size: clamp(1.4rem,4vw,2rem); font-weight:700; color:var(--t1); margin-bottom:.4rem; }
.portal-sub   { font-size: 1rem; color: var(--t2); }
.home-footer  { text-align:center; color:var(--t3); font-size:.88rem; margin-top:2rem; }

/* ── Flip Cards ────────────────────────────────────────────────────────────── */
.cards-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:1.8rem; margin-bottom:1.5rem; }
.flip-wrap  { perspective:1000px; height:290px; cursor:pointer; }
.flip-inner { position:relative; width:100%; height:100%; transform-style:preserve-3d; transition:transform .65s cubic-bezier(.4,.2,.2,1); }
.flip-wrap:hover .flip-inner { transform:rotateY(180deg); }
.flip-f, .flip-b {
  position:absolute; inset:0;
  backface-visibility:hidden; -webkit-backface-visibility:hidden;
  border-radius:20px; border:1px solid var(--border);
  background:var(--card); padding:1.8rem;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  transition:background .3s;
}
.flip-b { transform:rotateY(180deg); box-shadow:0 16px 48px rgba(0,0,0,.12); }
.ico    { width:68px; height:68px; border-radius:50%; display:flex; align-items:center; justify-content:center; margin-bottom:1.1rem; font-size:28px; }
.ico-blue { background:#dbeafe; }
.ico-ind  { background:#e0e7ff; }
[data-theme="dark"] .ico-blue { background:rgba(37,99,235,.15); }
[data-theme="dark"] .ico-ind  { background:rgba(79,70,229,.15); }
.card-title  { font-size:1.2rem; font-weight:700; color:var(--t1); margin-bottom:.4rem; }
.card-desc   { font-size:.85rem; color:var(--t2); text-align:center; line-height:1.6; margin-bottom:1rem; }
.card-feats  { font-size:.8rem; color:var(--t3); line-height:2.1; text-align:left; }
.enter-btn   { display:flex; align-items:center; gap:8px; padding:10px 22px; border-radius:12px; font-weight:700; font-size:.88rem; color:#fff; border:none; cursor:pointer; margin-top:1rem; }
.enter-btn.blue { background:linear-gradient(135deg,var(--blue),var(--indigo)); }
.enter-btn.ind  { background:linear-gradient(135deg,var(--indigo),var(--purple)); }
.back-sub { font-size:.8rem; color:var(--t3); margin-top:.2rem; }

/* ── Auth Pages ────────────────────────────────────────────────────────────── */
.auth-page { min-height:100vh; display:flex; align-items:center; justify-content:center; padding:2rem 1rem; }
.auth-card { background:var(--card); border:1px solid var(--border); border-radius:20px; padding:2.5rem 2rem; width:100%; max-width:420px; }
.auth-head { text-align:center; margin-bottom:1.8rem; }
.auth-head h2 { margin-bottom:.25rem; }
.auth-head p  { font-size:.88rem; color:var(--t2); }
.back-link { text-align:center; margin-top:1.2rem; font-size:13px; color:var(--t3); }

/* ── Form elements ─────────────────────────────────────────────────────────── */
.form-group { margin-bottom:1.1rem; }
.form-group label { display:block; font-size:13px; font-weight:600; color:var(--t2); margin-bottom:.35rem; }
.form-group input,
.form-group select,
.form-group textarea {
  width:100%; padding:10px 14px;
  border-radius:9px; border:1px solid var(--border);
  background:var(--bg); color:var(--t1);
  font-size:14px; font-family:inherit;
  transition:border .2s; outline:none;
}
.form-group input:focus,
.form-group select:focus { border-color:var(--blue); }
.form-hint { font-size:11px; color:var(--t3); margin-top:.2rem; display:block; }
.form-row  { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:1rem; }
.divider   { border:none; border-top:1px solid var(--border); margin:1.2rem 0; }

/* ── Dashboard ─────────────────────────────────────────────────────────────── */
.dash-page { min-height:calc(100vh - 58px); }
.dash-body { max-width:1060px; margin:0 auto; padding:2rem 1.5rem; }
.dash-greeting { margin-bottom:1.5rem; }
.dash-greeting h1 { font-size:1.4rem; margin-bottom:.2rem; }
.dash-greeting p  { color:var(--t2); font-size:.9rem; }

.sem-tabs { display:flex; gap:.5rem; flex-wrap:wrap; margin-bottom:1.5rem; }
.sem-tab  {
  padding:6px 16px; border-radius:20px; font-size:13px; font-weight:600;
  border:1px solid var(--border); background:var(--card); color:var(--t2);
  cursor:pointer; text-decoration:none; transition:all .2s;
}
.sem-tab.active { background:var(--blue); color:#fff; border-color:var(--blue); }
.sem-tab:hover:not(.active) { background:var(--bg2); text-decoration:none; }

.stats-row { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:1rem; margin-bottom:1.8rem; }
.stat-card { background:var(--card); border:1px solid var(--border); border-radius:14px; padding:1.2rem 1.3rem; }
.stat-label { font-size:11px; color:var(--t3); font-weight:600; text-transform:uppercase; letter-spacing:.5px; margin-bottom:.4rem; }
.stat-val   { font-size:1.7rem; font-weight:700; color:var(--t1); line-height:1.1; }
.stat-denom { font-size:1rem; font-weight:400; color:var(--t3); }
.stat-sub   { font-size:12px; color:var(--t2); margin-top:.2rem; }

.status-pass { color:#16a34a; }
.status-fail { color:#dc2626; }
.status-back { color:#d97706; }

.section-title { font-size:.95rem; font-weight:700; color:var(--t1); margin-bottom:1rem; }

.table-wrap { background:var(--card); border:1px solid var(--border); border-radius:14px; overflow:auto; }
.data-table { width:100%; border-collapse:collapse; font-size:14px; }
.data-table th {
  background:var(--bg); color:var(--t3);
  font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.4px;
  padding:11px 16px; text-align:left; border-bottom:1px solid var(--border); white-space:nowrap;
}
.data-table td { padding:12px 16px; border-bottom:1px solid var(--border); color:var(--t1); }
.data-table tr:last-child td { border-bottom:none; }
.data-table tbody tr:hover td { background:var(--bg); }
.data-table tfoot td { background:var(--bg2); font-weight:600; }
.empty-row { text-align:center; padding:2.5rem; color:var(--t3); font-style:italic; }

.badge { display:inline-block; padding:3px 10px; border-radius:20px; font-size:12px; font-weight:600; }
.badge-pass { background:#dcfce7; color:#15803d; }
.badge-fail { background:#fee2e2; color:#b91c1c; }
.badge-back { background:#fef3c7; color:#92400e; }

[data-theme="dark"] .badge-pass { background:rgba(22,163,74,.15); color:#4ade80; }
[data-theme="dark"] .badge-fail { background:rgba(239,68,68,.15); color:#f87171; }
[data-theme="dark"] .badge-back { background:rgba(245,158,11,.15); color:#fbbf24; }

.no-result { text-align:center; padding:4rem 2rem; }
.no-result-icon { font-size:3rem; margin-bottom:1rem; }
.no-result h3 { color:var(--t1); margin-bottom:.5rem; }
.no-result p  { color:var(--t2); font-size:.9rem; }

.print-bar { display:flex; align-items:center; justify-content:space-between; margin-top:1.2rem; flex-wrap:wrap; gap:.5rem; }

/* ── Admin Layout ──────────────────────────────────────────────────────────── */
.admin-layout { display:flex; min-height:calc(100vh - 58px); }
.sidebar {
  width:210px; flex-shrink:0; background:var(--card);
  border-right:1px solid var(--border);
  padding:1.2rem .75rem;
  display:flex; flex-direction:column; gap:.25rem;
}
.sidebar-link {
  display:block; padding:10px 14px; border-radius:10px;
  font-size:.88rem; font-weight:600; color:var(--t2);
  text-decoration:none; transition:all .2s;
}
.sidebar-link:hover { background:var(--bg2); color:var(--t1); text-decoration:none; }
.sidebar-link.active { background:rgba(37,99,235,.1); color:var(--blue); }

.admin-main { flex:1; padding:2rem 2rem; overflow:auto; }
.page-header { margin-bottom:1.8rem; }
.page-header h1 { margin-bottom:.25rem; }
.page-header p { color:var(--t2); font-size:.9rem; }

/* ── Upload form ───────────────────────────────────────────────────────────── */
.upload-card { background:var(--card); border:1px solid var(--border); border-radius:16px; padding:1.8rem; }
.upload-card h3 { margin-bottom:1.2rem; }

.subjects-head {
  display:flex; gap:.5rem; align-items:center;
  padding:6px 0; border-bottom:1px solid var(--border);
  font-size:11px; font-weight:700; color:var(--t3);
  text-transform:uppercase; letter-spacing:.4px;
  margin-bottom:.5rem;
}
.subjects-head span { flex-shrink:0; }

.subj-row { display:flex; gap:.5rem; align-items:center; margin-bottom:.5rem; }
.subj-row input { padding:8px 10px; border-radius:8px; border:1px solid var(--border); background:var(--bg); color:var(--t1); font-size:13px; font-family:inherit; outline:none; }
.subj-row input:focus { border-color:var(--blue); }
.subj-name  { flex:2; min-width:120px; }
.subj-code  { width:90px; }
.subj-intmax, .subj-extmax { width:70px; }
.subj-int,  .subj-ext  { width:70px; }
.del-row-btn { background:#fee2e2; color:#b91c1c; border:none; border-radius:7px; padding:7px 10px; cursor:pointer; font-size:13px; font-weight:700; flex-shrink:0; }
.del-row-btn:hover { opacity:.8; }

/* ── Filter bar ────────────────────────────────────────────────────────────── */
.filter-bar { display:flex; gap:.75rem; align-items:center; flex-wrap:wrap; margin-bottom:1.2rem; }
.filter-input { flex:1; min-width:180px; max-width:280px; padding:8px 12px; border-radius:9px; border:1px solid var(--border); background:var(--card); color:var(--t1); font-size:14px; font-family:inherit; outline:none; }
.filter-input:focus { border-color:var(--blue); }
.filter-select { padding:8px 12px; border-radius:9px; border:1px solid var(--border); background:var(--card); color:var(--t1); font-size:14px; font-family:inherit; outline:none; cursor:pointer; }

/* ── Animations ────────────────────────────────────────────────────────────── */
@keyframes fadeUp { from { opacity:0; transform:translateY(20px); } to { opacity:1; transform:translateY(0); } }
.fadein { animation:fadeUp .4s ease both; }

/* ── Print ─────────────────────────────────────────────────────────────────── */
@media print {
  .topnav, .dark-toggle, .sem-tabs, .print-bar, .flash-container, nav { display:none !important; }
  body { background:#fff; color:#000; }
  .table-wrap { border:1px solid #ddd; }
  .data-table th { background:#f5f5f5; }
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width:640px) {
  .admin-layout { flex-direction:column; }
  .sidebar { width:100%; flex-direction:row; flex-wrap:wrap; border-right:none; border-bottom:1px solid var(--border); padding:.75rem; }
  .admin-main { padding:1.2rem 1rem; }
  .subjects-head { display:none; }
  .subj-row { flex-wrap:wrap; }
  .subj-name { min-width:100%; }
  h1 { font-size:1.3rem; }
}

/* ── Student Info Card ─────────────────────────────────────────────────────── */
.student-info-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem 1.8rem;
  margin-bottom: 1.5rem;
}
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0 2.5rem;
}
.info-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.info-row:last-child { border-bottom: none; }
.info-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.info-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--t1);
  text-align: right;
}
.info-val.mono { font-family: 'Courier New', monospace; font-size: 13px; }
.mono { font-family: 'Courier New', monospace; }

/* ── 3-col form row ────────────────────────────────────────────────────────── */
.form-row-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

/* ── Section subtitle ──────────────────────────────────────────────────────── */
.section-sub {
  font-size: 13px;
  font-weight: 400;
  color: var(--t3);
  margin-left: .75rem;
}
