:root {
  --bg: #f4f8fb;
  --surface: #ffffff;
  --surface-2: #eef6f7;
  --text: #142033;
  --muted: #66768a;
  --line: #dce8ef;
  --primary: #1267d8;
  --primary-2: #13a2c5;
  --success: #0baa69;
  --warning: #e7a322;
  --danger: #dc3545;
  --shadow: 0 18px 50px rgba(31, 62, 94, .11);
  --radius: 8px;
}

[data-bs-theme="dark"] {
  --bg: #0d1421;
  --surface: #131e2e;
  --surface-2: #182538;
  --text: #eef5ff;
  --muted: #9aaabd;
  --line: #26384d;
  --shadow: 0 18px 50px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(18, 103, 216, .12), transparent 34rem),
    linear-gradient(135deg, rgba(19, 162, 197, .08), rgba(11, 170, 105, .08)),
    var(--bg);
  letter-spacing: 0;
}

.login-body { min-height: 100vh; background: linear-gradient(135deg, rgba(18,103,216,.16), rgba(11,170,105,.12)), var(--bg); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-panel { width: min(100%, 430px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); padding: 28px; }
.login-brand { color: var(--text); padding: 0 0 22px; }
.login-panel h1 { margin: 0 0 6px; font-size: 1.55rem; font-weight: 800; }
.login-panel p { color: var(--muted); margin-bottom: 20px; }

.app-shell { min-height: 100vh; display: flex; }

.sidebar {
  width: 284px;
  position: fixed;
  inset: 0 auto 0 0;
  background: linear-gradient(180deg, #063e78 0%, #075c8c 42%, #087c76 100%);
  color: #fff;
  padding: 18px 14px;
  overflow-y: auto;
  z-index: 1035;
  box-shadow: 16px 0 42px rgba(6, 62, 120, .18);
}

.brand-wrap { display: flex; align-items: center; gap: 12px; padding: 10px 10px 22px; }
.brand-mark { width: 46px; height: 46px; display: grid; place-items: center; border-radius: var(--radius); background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.24); font-size: 1.35rem; overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-title { font-weight: 800; font-size: 1.08rem; line-height: 1.1; }
.brand-subtitle { color: rgba(255,255,255,.7); font-size: .78rem; margin-top: 3px; }
.sidebar-label { color: rgba(255,255,255,.54); text-transform: uppercase; font-size: .68rem; font-weight: 800; letter-spacing: .08em; padding: 14px 14px 6px; }

.sidebar-nav { gap: 4px; }
.sidebar-nav .nav-link {
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.78);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  width: 100%;
  text-align: left;
  transition: transform .18s ease, background .18s ease, color .18s ease;
}
.sidebar-nav .nav-link i { width: 22px; text-align: center; }
.sidebar-nav .nav-link:hover, .sidebar-nav .nav-link.active { color: #fff; background: rgba(255,255,255,.16); transform: translateX(3px); }

.main { margin-left: 284px; width: calc(100% - 284px); min-height: 100vh; }

.topbar {
  min-height: 78px;
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px);
}
.page-kicker { color: var(--primary-2); font-weight: 800; font-size: .74rem; text-transform: uppercase; }
.topbar h1 { font-size: 1.42rem; margin: 0; font-weight: 800; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.search-pill { align-items: center; gap: 10px; min-width: 330px; height: 42px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; box-shadow: 0 8px 22px rgba(16, 64, 104, .05); }
.search-pill input { border: 0; outline: 0; width: 100%; background: transparent; color: var(--text); font-size: .9rem; }
.icon-btn { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); display: inline-grid; place-items: center; transition: transform .18s ease, border-color .18s ease; }
.icon-btn:hover { transform: translateY(-1px); border-color: var(--primary-2); }
.notification-dot { position: absolute; top: 9px; right: 9px; width: 9px; height: 9px; border-radius: 999px; background: var(--danger); border: 2px solid var(--surface); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 5px 10px 5px 5px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; background: linear-gradient(135deg, var(--primary), var(--success)); }
.user-name { font-size: .86rem; font-weight: 800; line-height: 1.1; }
.user-role { font-size: .72rem; color: var(--muted); }

.hero-panel {
  margin: 24px 28px 0;
  border-radius: var(--radius);
  padding: 28px;
  color: #fff;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  min-height: 190px;
  background:
    linear-gradient(115deg, rgba(5, 58, 112, .95), rgba(18, 103, 216, .9) 46%, rgba(11, 170, 105, .9)),
    url("https://images.unsplash.com/photo-1576091160550-2173dba999ef?auto=format&fit=crop&w=1600&q=80") center/cover;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}
.hero-panel::after { content: ""; position: absolute; inset: auto -20px -52px auto; width: 290px; height: 170px; border: 1px solid rgba(255,255,255,.18); transform: rotate(-12deg); }
.hero-panel > * { position: relative; z-index: 1; }
.hero-panel h2 { max-width: 760px; font-size: clamp(1.55rem, 3vw, 2.7rem); font-weight: 800; margin: 16px 0 10px; }
.hero-panel p { max-width: 760px; margin: 0; color: rgba(255,255,255,.84); }
.medical-badge { color: #075c8c !important; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.content { padding: 24px 28px 48px; }
.page-section { display: none; animation: rise .28s ease both; }
.page-section.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 18px; }
.section-heading h3 { font-size: 1.18rem; font-weight: 800; margin: 0 0 4px; }
.section-heading p { color: var(--muted); margin: 0; }
.segmented { background: var(--surface); border: 1px solid var(--line); padding: 4px; border-radius: var(--radius); display: flex; gap: 4px; }
.segmented button { border: 0; background: transparent; color: var(--muted); border-radius: 6px; padding: 7px 12px; font-weight: 700; font-size: .84rem; }
.segmented button.active { color: #fff; background: var(--primary); }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.kpi-card, .panel, .module-card, .report-card, .form-panel {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.kpi-card { padding: 18px; position: relative; overflow: hidden; transition: transform .2s ease; }
.kpi-card:hover { transform: translateY(-3px); }
.kpi-card::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent, var(--primary)); }
.kpi-card i { width: 42px; height: 42px; display: grid; place-items: center; border-radius: var(--radius); color: #fff; background: var(--accent, var(--primary)); margin-bottom: 16px; }
.kpi-card span { display: block; color: var(--muted); font-weight: 700; font-size: .84rem; }
.kpi-card strong { display: block; font-size: 1.78rem; margin: 4px 0; }
.kpi-card small { color: var(--muted); }
.accent-blue { --accent: #1267d8; } .accent-green { --accent: #0baa69; } .accent-amber { --accent: #e7a322; } .accent-red { --accent: #dc3545; } .accent-cyan { --accent: #13a2c5; }

.dashboard-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; }
.panel { padding: 18px; min-width: 0; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.panel-header h4 { font-size: 1rem; font-weight: 800; margin: 0; }
.chart-box { min-height: 285px; }
.status-pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 10px; font-size: .74rem; font-weight: 800; color: var(--primary); background: rgba(18,103,216,.1); }
.status-pill.success { color: var(--success); background: rgba(11,170,105,.12); }
.status-pill.warning { color: #9b6700; background: rgba(231,163,34,.14); }
.stats-columns, .student-profile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.mini-stat-list { display: grid; gap: 10px; }
.mini-stat { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.mini-stat:last-child { border-bottom: 0; }
.mini-stat span { color: var(--muted); font-weight: 700; }
.mini-stat strong { font-weight: 800; }

.form-panel { padding: 22px; }
.form-banner { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px; border-radius: var(--radius); background: linear-gradient(135deg, rgba(18,103,216,.1), rgba(11,170,105,.12)); margin-bottom: 20px; }
.form-banner strong { display: block; font-size: 1.15rem; }
.form-banner span { color: var(--muted); }
.form-section { border-top: 1px solid var(--line); margin: 24px 0 14px; padding-top: 18px; }
.form-section h4 { margin: 0; font-size: 1rem; font-weight: 800; color: var(--primary); }
.form-label { font-weight: 700; color: var(--text); font-size: .84rem; }
.form-control, .form-select { border-color: var(--line); border-radius: var(--radius); background-color: var(--surface); color: var(--text); min-height: 42px; }
.form-control:focus, .form-select:focus { box-shadow: 0 0 0 .2rem rgba(18,103,216,.12); border-color: var(--primary); }
.upload-tile { min-height: 140px; border: 1px dashed var(--primary-2); border-radius: var(--radius); background: rgba(19,162,197,.07); display: grid; place-items: center; align-content: center; gap: 8px; cursor: pointer; color: var(--primary); font-weight: 800; }
.upload-tile i { font-size: 1.7rem; }
.fee-policy { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); color: var(--text); font-weight: 700; }
.form-table-wrap { border: 1px solid var(--line); border-radius: var(--radius); }
.form-table { margin: 0; }
.form-table th { background: var(--surface-2); color: var(--muted); font-size: .8rem; }
.document-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.document-grid label { display: flex; align-items: center; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); font-weight: 700; }

.profile-card { text-align: center; }
.profile-photo { width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; color: #fff; font-size: 1.4rem; font-weight: 800; background: linear-gradient(135deg, var(--primary), var(--success)); }
.profile-card h4 { font-weight: 800; margin-bottom: 4px; }
.profile-card p { color: var(--muted); }
.profile-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 18px 0; }
.profile-metrics span { padding: 10px; border-radius: var(--radius); background: var(--surface-2); color: var(--muted); font-size: .75rem; }
.profile-metrics strong { display: block; color: var(--text); font-size: .95rem; }

.course-grid, .module-grid, .report-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.course-card { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.course-card .course-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.course-icon, .module-card i, .report-card i, .fee-widget i { width: 42px; height: 42px; border-radius: var(--radius); display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--primary), var(--success)); }
.course-card h4 { font-weight: 800; margin: 0; }
.course-meta { display: grid; gap: 8px; color: var(--muted); font-size: .86rem; }
.course-meta span { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding-bottom: 7px; }
.module-card, .report-card { padding: 18px; transition: transform .18s ease; }
.module-card:hover, .report-card:hover { transform: translateY(-3px); }
.module-card h4, .report-card h4 { font-size: 1rem; font-weight: 800; margin: 14px 0 6px; }
.module-card p, .report-card p { color: var(--muted); margin: 0; }
.fee-widget { display: flex; align-items: center; gap: 14px; }
.fee-widget span { display: block; color: var(--muted); font-weight: 700; }
.fee-widget strong { font-size: 1.4rem; }
.timeline { display: grid; gap: 14px; }
.timeline div { display: grid; grid-template-columns: 42px 1fr; column-gap: 12px; align-items: start; padding-bottom: 14px; border-bottom: 1px dashed var(--line); }
.timeline span { grid-row: span 2; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; background: var(--primary); }
.timeline strong { font-weight: 800; }
.timeline p { grid-column: 2; color: var(--muted); margin: 3px 0 0; }

.table { --bs-table-bg: transparent; --bs-table-color: var(--text); --bs-table-border-color: var(--line); }
.table thead th { color: var(--muted); font-size: .78rem; text-transform: uppercase; }
.badge-soft { border-radius: 999px; padding: 6px 10px; font-size: .72rem; font-weight: 800; }
.badge-paid { color: var(--success); background: rgba(11,170,105,.12); }
.badge-due { color: #9b6700; background: rgba(231,163,34,.14); }

.sidebar-backdrop { display: none; }

@media (max-width: 1199px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .course-grid, .module-grid, .report-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
}

@media (max-width: 991px) {
  .sidebar { transform: translateX(-105%); transition: transform .24s ease; }
  .sidebar.show { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(13,20,33,.48); z-index: 1030; }
  .main { margin-left: 0; width: 100%; }
  .topbar, .content { padding-left: 18px; padding-right: 18px; }
  .hero-panel { margin-left: 18px; margin-right: 18px; flex-direction: column; align-items: flex-start; }
  .kpi-grid, .stats-columns, .student-profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .course-grid, .module-grid, .report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 575px) {
  .topbar { align-items: flex-start; }
  .topbar-actions { gap: 6px; }
  .hero-panel { padding: 20px; min-height: 0; }
  .section-heading { flex-direction: column; align-items: stretch; }
  .kpi-grid, .stats-columns, .student-profile-grid, .course-grid, .module-grid, .report-grid, .document-grid { grid-template-columns: 1fr; }
  .content { padding-top: 18px; }
  .panel, .form-panel { padding: 14px; }
}

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .hero-panel, .sidebar-backdrop, .btn, .segmented, .toast-container { display: none !important; }
  .main { margin: 0; width: 100%; }
  .content { padding: 0; }
  .page-section { display: block !important; page-break-after: always; }
  .panel, .form-panel, .kpi-card, .course-card, .module-card, .report-card { box-shadow: none; border-color: #b8c8d6; }
}
