/* =========================================
   COLLEGE ERP — DESIGN SYSTEM
========================================= */
:root {
  --bg: #f5f7fb;
  --bg-elev: #ffffff;
  --bg-soft: #f0f3f9;
  --text: #1c2433;
  --text-muted: #5f6b85;
  --text-soft: #8a93a8;
  --border: #e4e8f1;
  --border-strong: #d1d7e3;
  --primary: #2f54eb;
  --primary-hover: #1d3fc4;
  --primary-soft: #e6efff;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #0891b2;
  --info-soft: #cffafe;
  --purple: #7c3aed;
  --purple-soft: #ede9fe;
  --pink: #db2777;
  --shadow-sm: 0 1px 2px rgba(20, 30, 60, 0.06);
  --shadow: 0 4px 16px rgba(20, 30, 60, 0.06);
  --shadow-lg: 0 12px 40px rgba(20, 30, 60, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --transition: 0.15s ease;
  --sidebar-w: 240px;
  --topbar-h: 64px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[hidden], .hidden { display: none !important; }

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

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }

p { margin: 0; }
code, pre { font-family: var(--font-mono); font-size: 12.5px; }
code { background: var(--bg-soft); padding: 1px 6px; border-radius: 4px; }
.muted { color: var(--text-muted); font-size: 12.5px; }

/* =========================================
   LOGIN
========================================= */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg);
  position: relative;
  z-index: 2;
}

#loginView, #appView {
  min-height: 100vh;
}
.login-card {
  align-self: center;
  justify-self: center;
  width: 100%;
  max-width: 420px;
  padding: 48px 40px;
  background: var(--bg-elev);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin: 32px;
}
.login-brand { text-align: center; margin-bottom: 28px; }
.brand-logo { font-size: 36px; margin-bottom: 8px; }
.login-brand h1 { font-size: 22px; margin-bottom: 4px; }
.login-brand p { color: var(--text-muted); font-size: 13px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; }
.login-form input,
.form-grid input,
.form-grid select,
.form-grid textarea {
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  font: inherit;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.login-form input:focus,
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.login-hint {
  margin-top: 24px;
  padding: 14px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
}
.login-hint strong { color: var(--text); display: block; margin-bottom: 8px; }
.login-hint ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.login-hint code { font-size: 11.5px; }

.login-side {
  background: linear-gradient(135deg, #2f54eb 0%, #5b3df5 50%, #7c3aed 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}
.login-side::before, .login-side::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
}
.login-side::before { width: 320px; height: 320px; top: -80px; right: -80px; }
.login-side::after { width: 240px; height: 240px; bottom: -60px; left: -60px; }
.login-side-inner { max-width: 380px; position: relative; }
.login-side h2 { font-size: 28px; margin-bottom: 12px; line-height: 1.2; }
.login-side p { opacity: 0.85; font-size: 14px; margin-bottom: 28px; }
.side-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.side-list li { font-size: 14px; padding: 10px 14px; background: rgba(255,255,255,0.1); border-radius: var(--radius-sm); }

@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .login-card { margin: 16px; }
}

/* =========================================
   APP SHELL
========================================= */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.sidebar {
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  padding: 20px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand .brand-logo { font-size: 24px; }
.brand-name { color: white; font-weight: 600; font-size: 15px; }
.brand-sub { color: #94a3b8; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-group-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 12px 12px 6px;
  font-weight: 600;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  font-size: 13.5px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  font-family: inherit;
}
.nav-link:hover { background: rgba(255,255,255,0.05); color: white; text-decoration: none; }
.nav-link.active { background: var(--primary); color: white; }
.nav-link .icon { width: 18px; text-align: center; font-size: 15px; }

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-foot .btn { color: #cbd5e1; }
.sidebar-foot .btn:hover { background: rgba(255,255,255,0.05); color: white; }

/* =========================================
   MAIN
========================================= */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: var(--topbar-h);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left h2 { font-size: 18px; }
.breadcrumb { color: var(--text-soft); font-size: 12px; margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.search input {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--bg-soft);
  width: 240px;
  font-size: 13px;
  transition: all var(--transition);
}
.search input:focus { outline: none; background: white; border-color: var(--primary); width: 300px; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}
.user-chip:hover { background: var(--bg-soft); }
.user-chip > div:last-child { line-height: 1.25; }
.user-chip > div:last-child > div:first-child { font-size: 13px; font-weight: 500; }
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: white;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 13px;
}

.page-content {
  flex: 1;
  padding: 24px;
  overflow-x: hidden;
}
.page-loading { color: var(--text-muted); padding: 32px; text-align: center; }

/* =========================================
   BUTTONS
========================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-soft); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-success:hover { background: #15803d; border-color: #15803d; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px 8px; }

.btn .spinner {
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================
   CARDS / PANELS
========================================= */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.page-header h1 { font-size: 22px; }
.page-header p { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* =========================================
   STATS GRID
========================================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon {
  position: absolute;
  top: 16px; right: 16px;
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  font-size: 18px;
}
.stat-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 600; margin-top: 6px; letter-spacing: -0.02em; }
.stat-foot { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

.bg-blue { background: var(--primary-soft); color: var(--primary); }
.bg-green { background: var(--success-soft); color: var(--success); }
.bg-amber { background: var(--warning-soft); color: var(--warning); }
.bg-red { background: var(--danger-soft); color: var(--danger); }
.bg-cyan { background: var(--info-soft); color: var(--info); }
.bg-purple { background: var(--purple-soft); color: var(--purple); }
.bg-pink { background: #fce7f3; color: var(--pink); }

/* =========================================
   TABLES
========================================= */
.table-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.table-toolbar .spacer { flex: 1; }
.table-toolbar input,
.table-toolbar select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  font: inherit;
  font-size: 13px;
}
.table-toolbar input { min-width: 200px; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data th, table.data td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data th {
  background: var(--bg-soft);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
table.data tbody tr:hover { background: var(--bg-soft); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data td.actions .btn { margin-left: 4px; }

.empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}
.empty-icon { font-size: 36px; opacity: 0.4; margin-bottom: 8px; }

/* =========================================
   BADGES
========================================= */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--bg-soft);
  color: var(--text-muted);
}
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-gray { background: #e5e7eb; color: #374151; }

/* =========================================
   FORMS / MODALS
========================================= */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 500; }
.form-grid label > span { color: var(--text-muted); }
.form-grid textarea { resize: vertical; min-height: 80px; font: inherit; }
.form-help { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 10px;
}

dialog.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: 600px;
  width: 90%;
  background: var(--bg-elev);
  box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(2px); }
.modal-card { display: flex; flex-direction: column; gap: 0; }
.modal-card header, .modal-card footer {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-card footer { border-bottom: none; border-top: 1px solid var(--border); justify-content: flex-end; gap: 8px; }
.modal-card form-body, .modal-card .modal-body { padding: 20px; }
.modal-card form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-card .form-grid { padding: 0; }

/* =========================================
   TOASTS
========================================= */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 400px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  animation: slideIn 0.2s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* =========================================
   UTILITIES
========================================= */
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.hidden { display: none !important; }

.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 1024px) {
  .charts-grid { grid-template-columns: 1fr; }
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bar-row {
  display: grid;
  grid-template-columns: 130px 1fr 60px;
  align-items: center;
  gap: 12px;
}
.bar-row .label { font-size: 12.5px; color: var(--text-muted); }
.bar-row .count { font-size: 12.5px; font-weight: 600; text-align: right; }
.bar-track {
  height: 10px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--purple));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  font-size: 13px;
}
.list-item .icon { font-size: 16px; }
.list-item .meta { margin-left: auto; color: var(--text-muted); font-size: 12px; }

.kbd {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }

.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.profile-header .avatar {
  width: 64px; height: 64px;
  font-size: 22px;
}
.profile-header h2 { font-size: 20px; }
.profile-header .muted { margin-top: 4px; }
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.profile-grid .item {
  padding: 12px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
}
.profile-grid .item .k { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.profile-grid .item .v { font-size: 14px; font-weight: 500; margin-top: 2px; word-break: break-word; }

@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -240px; transition: left 0.2s ease; z-index: 100; }
  .sidebar.open { left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .search input { width: 140px; }
  .page-content { padding: 16px; }
}
