/* =========================================================
   EduSphere — base tokens & components
   ========================================================= */
:root {
  --primary: #3730A3;
  --primary-600: #4338CA;
  --primary-800: #2E2A85;
  --primary-soft: #EEF0FD;
  --teal: #0F8F83;
  --teal-soft: #E3F5F2;
  --bg: #F5F7FB;
  --surface: #FFFFFF;
  --surface-2: #F9FAFD;
  --border: #E3E7F0;
  --border-strong: #CFD5E3;
  --text: #18213A;
  --text-2: #3B4660;
  --muted: #6A748C;
  --success: #15803D;  --success-soft: #E7F6EC;
  --warning: #C2410C;  --warning-soft: #FFF1E6;
  --danger: #DC2626;   --danger-soft: #FDECEC;
  --info: #0369A1;     --info-soft: #E6F2FA;
  --sidebar: #171B45;
  --sidebar-text: #B9BEDD;
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(20, 27, 58, .05);
  --shadow: 0 1px 2px rgba(20, 27, 58, .04), 0 4px 14px rgba(20, 27, 58, .05);
  --shadow-lg: 0 18px 48px rgba(20, 27, 58, .16);
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --bs-primary: var(--primary);
  --bs-primary-rgb: 55, 48, 163;
  --bs-body-font-family: var(--font);
  --bs-body-color: var(--text);
  --bs-body-bg: var(--bg);
  --bs-border-color: var(--border);
  --bs-link-color: var(--primary);
  --bs-link-hover-color: var(--primary-800);
}

* { -webkit-tap-highlight-color: transparent; }
html, body { overflow-x: hidden; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: .9375rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.num, .stat-value, .money, td.text-end, .table .num { font-variant-numeric: tabular-nums; }
h1, h2, h3, h4, h5, h6 { color: var(--text); font-weight: 700; letter-spacing: -.01em; }
a { text-decoration: none; }
:focus-visible { outline: 3px solid rgba(55, 48, 163, .35); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--primary-soft); }

/* ---- Buttons ---- */
.btn { font-weight: 600; border-radius: 10px; padding: .5rem 1rem; font-size: .875rem; display: inline-flex; align-items: center; justify-content: center; gap: .25rem; }
.btn-sm { padding: .35rem .7rem; font-size: .8125rem; border-radius: 8px; }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary-800); --bs-btn-hover-border-color: var(--primary-800);
  --bs-btn-active-bg: var(--primary-800); --bs-btn-disabled-bg: var(--primary); --bs-btn-disabled-border-color: var(--primary); }
.btn-teal { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn-teal:hover { background: #0B766C; color: #fff; }
.btn-light { --bs-btn-bg: #fff; --bs-btn-border-color: var(--border); --bs-btn-color: var(--text-2); --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-border-color: var(--border-strong); }
.btn-soft { background: var(--primary-soft); color: var(--primary); border: 0; }
.btn-soft:hover { background: #E0E3FB; color: var(--primary-800); }
.btn-outline-secondary { --bs-btn-border-color: var(--border); --bs-btn-color: var(--muted); --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: var(--border-strong); }
.btn-icon { width: 40px; height: 40px; border: 0; background: transparent; border-radius: 10px; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; }
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn .spinner-border { width: 1rem; height: 1rem; border-width: .15em; }
.btn.is-loading { pointer-events: none; opacity: .85; }

/* ---- Forms ---- */
.form-label { font-weight: 600; font-size: .8125rem; color: var(--text-2); margin-bottom: .35rem; }
.form-control, .form-select { border-radius: 10px; border-color: var(--border); padding: .55rem .8rem; font-size: .9rem; color: var(--text); background-color: #fff; }
.form-control-sm, .form-select-sm { border-radius: 8px; padding-top: .35rem; padding-bottom: .35rem; font-size: .8125rem; }
.form-control:focus, .form-select:focus { border-color: var(--primary-600); box-shadow: 0 0 0 4px rgba(67, 56, 202, .12); }
.form-control::placeholder { color: #9AA3B8; }
.form-control.is-invalid, .form-select.is-invalid, .ms-box.is-invalid { border-color: var(--danger); }
.invalid-feedback { font-size: .78rem; font-weight: 500; }
.field.has-error .invalid-feedback { display: block; }
.form-text { font-size: .75rem; color: var(--muted); }
.req { color: var(--danger); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-section { font-weight: 700; font-size: .8125rem; color: var(--primary); padding-top: .5rem; border-top: 1px dashed var(--border); margin-top: .25rem; }
.row > .col-12:first-child > .form-section { border-top: 0; padding-top: 0; margin-top: 0; }
.input-group > .btn { border-radius: 0 10px 10px 0; }

/* Multi-select checklist */
.ms-box { border: 1px solid var(--border); border-radius: 10px; background: #fff; overflow: hidden; }
.ms-search { display: flex; align-items: center; gap: .5rem; padding: .4rem .7rem; border-bottom: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }
.ms-search input { border: 0; outline: 0; flex: 1; background: transparent; font-size: .85rem; min-width: 0; }
.ms-count { font-size: .75rem; font-weight: 600; color: var(--primary); white-space: nowrap; }
.ms-list { max-height: 190px; overflow-y: auto; padding: .35rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 2px; }
.ms-item { display: flex; align-items: center; gap: .5rem; padding: .35rem .5rem; border-radius: 6px; font-size: .85rem; cursor: pointer; margin: 0; }
.ms-item:hover { background: var(--primary-soft); }
.ms-item .form-check-input { margin: 0; flex-shrink: 0; }
.ms-empty { padding: .75rem; color: var(--muted); font-size: .85rem; }

/* Upload */
.upload-field { display: flex; align-items: center; gap: .75rem; }
.img-preview { width: 56px; height: 56px; border-radius: 14px; background: var(--surface-2); border: 1px dashed var(--border-strong); display: grid; place-items: center; color: var(--muted); overflow: hidden; flex-shrink: 0; }
.img-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---- Cards ---- */
.card { border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); background: var(--surface); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); padding: 1rem 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.card-header h2, .card-header h3, .card-title { font-size: 1rem; margin: 0; font-weight: 700; }
.card-body { padding: 1.25rem; }
.card-sub { color: var(--muted); font-size: .8125rem; margin: 0; }

/* ---- Badges ---- */
.badge-status { display: inline-flex; align-items: center; gap: .35rem; padding: .22rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; line-height: 1.4; }
.badge-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.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-primary { background: var(--primary-soft); color: var(--primary); }
.badge-muted { background: #EEF0F5; color: #5B6479; }
.pill { display: inline-block; padding: .15rem .55rem; border-radius: 6px; background: #EEF0F5; color: var(--text-2); font-size: .75rem; font-weight: 700; }

/* ---- Avatars ---- */
.avatar { border-radius: 50%; object-fit: cover; flex-shrink: 0; display: inline-grid; place-items: center; }
.avatar-sm { width: 34px; height: 34px; font-size: .75rem; }
.avatar-md { width: 40px; height: 40px; font-size: .8rem; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.15rem; }
.avatar-xl { width: 96px; height: 96px; font-size: 1.6rem; }
.avatar-initials { background: hsl(var(--hue, 240), 55%, 93%); color: hsl(var(--hue, 240), 45%, 32%); font-weight: 800; }
.person { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.person-name { font-weight: 700; color: var(--text); display: block; line-height: 1.25; }
a.person-name:hover { color: var(--primary); }
.person-sub { color: var(--muted); font-size: .78rem; display: block; }

/* ---- Tables ---- */
.card-table { overflow: hidden; }
.table-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.search-box { position: relative; flex: 1 1 240px; max-width: 340px; }
.search-box i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .9rem; }
.search-box .form-control { padding-left: 2.2rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; flex: 1 1 auto; }
.filters .form-select { width: auto; max-width: 200px; }
.daterange { display: flex; align-items: center; gap: .35rem; }
.daterange .form-control { width: 140px; }
.toolbar-actions { display: flex; gap: .4rem; margin-left: auto; }
.data-table { --bs-table-bg: transparent; font-size: .875rem; }
.data-table thead th { background: var(--surface-2); color: var(--muted); font-weight: 700; font-size: .75rem; border-bottom: 1px solid var(--border); padding: .7rem 1rem; white-space: nowrap; user-select: none; }
.data-table thead th.sortable { cursor: pointer; }
.data-table thead th.sortable:hover { color: var(--text); }
.data-table thead th .sort-ind { opacity: .35; margin-left: .2rem; font-size: .7rem; }
.data-table thead th.sorted .sort-ind { opacity: 1; color: var(--primary); }
.data-table tbody td { padding: .8rem 1rem; border-color: var(--border); color: var(--text-2); vertical-align: middle; }
.data-table tbody tr:hover td { background: #FBFCFE; }
.data-table .cell-title { font-weight: 700; color: var(--text); display: block; line-height: 1.3; }
.data-table a.cell-title:hover { color: var(--primary); }
.data-table .cell-sub { color: var(--muted); font-size: .78rem; display: block; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table .cell-clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.data-table td.actions-cell { text-align: right; white-space: nowrap; width: 1%; }
.capacity { display: flex; align-items: center; gap: .5rem; min-width: 110px; }
.capacity .progress { height: 6px; flex: 1; background: #EDF0F6; border-radius: 99px; }
.capacity .progress-bar { background: var(--teal); border-radius: 99px; }
.table-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; padding: .85rem 1.25rem; border-top: 1px solid var(--border); }
.pagination { --bs-pagination-color: var(--text-2); --bs-pagination-border-color: var(--border); --bs-pagination-active-bg: var(--primary); --bs-pagination-active-border-color: var(--primary); --bs-pagination-hover-bg: var(--surface-2); --bs-pagination-focus-box-shadow: 0 0 0 3px rgba(55,48,163,.15); }
.pagination .page-link { border-radius: 8px !important; margin: 0 2px; min-width: 32px; text-align: center; font-weight: 600; }

.tabs-bar { display: flex; gap: .25rem; padding: .6rem 1.25rem 0; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab-btn { border: 0; background: none; padding: .6rem .9rem; font-weight: 700; font-size: .85rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Row action menu */
.row-actions { display: inline-flex; gap: .25rem; align-items: center; }
.row-actions .btn-icon { width: 32px; height: 32px; font-size: .95rem; }
.dropdown-menu { border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: .35rem; font-size: .875rem; }
.dropdown-item { border-radius: 8px; padding: .45rem .7rem; font-weight: 500; }
.dropdown-item:active { background: var(--primary); }
.dropdown-item i { width: 1.1rem; display: inline-block; }

/* Skeleton */
.skeleton { display: block; height: .8rem; border-radius: 6px; background: linear-gradient(90deg, #EEF1F6 25%, #F6F8FB 37%, #EEF1F6 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } * { scroll-behavior: auto !important; } }

/* Empty & error states */
.empty-state { text-align: center; padding: 2.75rem 1rem; color: var(--muted); }
.empty-state .empty-icon { width: 56px; height: 56px; margin: 0 auto .9rem; border-radius: 16px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 1.5rem; }
.empty-state h3 { font-size: 1rem; margin-bottom: .25rem; }
.empty-state p { font-size: .875rem; margin: 0 auto .9rem; max-width: 380px; }

/* Modals */
.modal-content { border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--border); padding: 1rem 1.25rem; }
.modal-title { font-size: 1.05rem; font-weight: 800; }
.modal-footer { border-top: 1px solid var(--border); padding: .85rem 1.25rem; }
.modal-body { padding: 1.25rem; }
.confirm-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto; background: var(--danger-soft); color: var(--danger); font-size: 1.5rem; }
.confirm-icon.is-primary { background: var(--primary-soft); color: var(--primary); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem 1.5rem; margin: 0; }
.detail-grid dt { font-size: .75rem; color: var(--muted); font-weight: 600; margin-bottom: .15rem; }
.detail-grid dd { margin: 0; font-weight: 600; color: var(--text); word-break: break-word; }
.detail-grid .wide { grid-column: 1 / -1; }

/* Toasts */
.toast-stack { position: fixed; right: 1rem; bottom: 1rem; z-index: 1100; display: flex; flex-direction: column; gap: .5rem; max-width: calc(100vw - 2rem); }
.app-toast { display: flex; align-items: flex-start; gap: .65rem; min-width: 280px; max-width: 400px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: .8rem .9rem; box-shadow: var(--shadow-lg); font-size: .875rem; font-weight: 600; animation: toastIn .2s ease; }
.app-toast i { font-size: 1.1rem; margin-top: 1px; }
.app-toast.success i { color: var(--success); }
.app-toast.error i { color: var(--danger); }
.app-toast.info i { color: var(--primary); }
.app-toast .toast-close { margin-left: auto; border: 0; background: none; color: var(--muted); padding: 0 0 0 .5rem; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.alert { border-radius: 12px; border: 0; font-size: .875rem; font-weight: 500; }
.alert-danger { background: var(--danger-soft); color: #991B1B; }
.alert-success { background: var(--success-soft); color: #14532D; }
.alert-warning { background: var(--warning-soft); color: #7C2D12; }
.alert-info { background: var(--info-soft); color: #0C4A6E; }
.breadcrumb { font-size: .78rem; margin-bottom: .25rem; --bs-breadcrumb-divider-color: var(--muted); }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }
.progress { background: #EDF0F6; border-radius: 99px; }
.progress-bar { background: var(--primary); }
.text-muted { color: var(--muted) !important; }
.text-teal { color: var(--teal) !important; }
.bg-surface-2 { background: var(--surface-2); }
.list-clean { list-style: none; margin: 0; padding: 0; }
.nav-tabs-clean { border-bottom: 1px solid var(--border); gap: .25rem; }
.nav-tabs-clean .nav-link { border: 0; color: var(--muted); font-weight: 700; font-size: .875rem; padding: .7rem .9rem; border-bottom: 2px solid transparent; border-radius: 0; }
.nav-tabs-clean .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); background: none; }
.accordion-button { font-weight: 700; }
.accordion-button:not(.collapsed) { background: var(--primary-soft); color: var(--primary); box-shadow: none; }

/* ---- Auth pages ---- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.auth-side { background: var(--sidebar); color: #E5E7F7; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; border: 56px solid rgba(15, 143, 131, .22); }
.auth-side h1 { color: #fff; font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1.15; max-width: 14ch; font-weight: 800; }
.auth-side p { color: var(--sidebar-text); max-width: 42ch; }
.auth-points { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: .75rem; position: relative; z-index: 1; }
.auth-points li { display: flex; gap: .65rem; align-items: center; color: #D7DAF0; font-weight: 500; }
.auth-points i { color: #5EEAD4; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card h2 { font-size: 1.6rem; font-weight: 800; }
.demo-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: .8rem 1rem; font-size: .8rem; }
.demo-box button { border: 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: .3rem .6rem; font-weight: 600; font-size: .75rem; color: var(--text-2); }
.demo-box button:hover { border-color: var(--primary); color: var(--primary); }

/* ---- Print page ---- */
.print-page { background: #fff; padding: 28px; color: #111827; font-size: 12px; }
.print-actions { position: fixed; top: 12px; right: 12px; display: flex; gap: 8px; }
.print-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid var(--primary); padding-bottom: 12px; margin-bottom: 16px; gap: 16px; }
.print-org { font-weight: 800; font-size: 18px; color: var(--primary); }
.print-title { font-size: 18px; margin: 0; }
.print-meta { color: #4B5563; font-size: 11px; }
.print-table { width: 100%; border-collapse: collapse; }
.print-table th { background: #F3F4F8; text-align: left; font-size: 11px; padding: 7px 8px; border-bottom: 1px solid #D1D5DB; }
.print-table td { padding: 6px 8px; border-bottom: 1px solid #E5E7EB; vertical-align: top; }
.print-table .num { text-align: right; font-variant-numeric: tabular-nums; }
[hidden]{display:none !important;}
