/* =============================================================
   GHARTEY HALL MANAGEMENT SYSTEM — global.css
   University of Education, Winneba
   =============================================================

   TABLE OF CONTENTS
   -----------------
   1.  CSS CUSTOM PROPERTIES (Design Tokens)
   2.  RESET & BASE
   3.  TYPOGRAPHY
   4.  LAYOUT UTILITIES
   5.  BUTTONS — global variants
   6.  FORM CONTROLS — global inputs, selects, labels
   7.  CARDS & PANELS
   8.  BADGES & STATUS PILLS
   9.  TOPBAR / NAVBAR
   10. SIDEBAR NAVIGATION
   11. STAT / KPI CARDS
   12. DATA TABLES (DataTables wrapper)
   13. MODAL / OVERLAY
   14. TOAST NOTIFICATIONS
   15. LOADING SPINNER
   16. FOOTER NOTE
   17. SCROLLBAR
   18. RESPONSIVE HELPERS
   ============================================================= */


/* ─────────────────────────────────────────────────────────────
   1. CSS CUSTOM PROPERTIES
───────────────────────────────────────────────────────────── */
:root {
  /* Brand palette */
  --brand-primary:   #1a56db;   /* UEW blue */
  --brand-secondary: #0e9f6e;   /* success green */
  --brand-accent:    #ff8c00;   /* amber accent */
  --brand-danger:    #e02424;
  --brand-warning:   #f59e0b;
  --brand-info:      #3abff8;

  /* Surface */
  --bg-body:         #f4f6fb;
  --bg-sidebar:      #0f172a;
  --bg-sidebar-hover:#1e293b;
  --bg-card:         #ffffff;
  --bg-table-head:   #1e3a5f;
  --bg-table-stripe: #f8faff;
  --bg-overlay:      rgba(15,23,42,0.65);

  /* Text */
  --text-heading:    #0f172a;
  --text-body:       #374151;
  --text-muted:      #6b7280;
  --text-inverse:    #f8fafc;
  --text-link:       #1a56db;

  /* Borders */
  --border-light:    #e5e7eb;
  --border-card:     #d1d9f0;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0,0,0,.06);
  --shadow-sm:  0 2px 8px rgba(0,0,0,.08);
  --shadow-md:  0 4px 20px rgba(0,0,0,.10);
  --shadow-lg:  0 8px 40px rgba(0,0,0,.14);

  /* Radii */
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --radius-pill:9999px;

  /* Sidebar */
  --sidebar-w:  260px;
  --sidebar-collapsed: 68px;

  /* Topbar */
  --topbar-h:   64px;

  /* Transitions */
  --transition: 0.22s ease;
}


/* ─────────────────────────────────────────────────────────────
   2. RESET & BASE
───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', 'Segoe UI', sans-serif;
  background: var(--bg-body);
  color: var(--text-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

img, svg { display: block; max-width: 100%; }

ul, ol { list-style: none; }


/* ─────────────────────────────────────────────────────────────
   3. TYPOGRAPHY
───────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', 'DM Sans', sans-serif;
  color: var(--text-heading);
  font-weight: 700;
  line-height: 1.25;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.page-title i { color: var(--brand-primary); }

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-heading);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .45rem;
}
.section-title i { color: var(--brand-primary); font-size: .9rem; }

small, .text-sm  { font-size: .8rem; }
.text-muted      { color: var(--text-muted); }


/* ─────────────────────────────────────────────────────────────
   4. LAYOUT UTILITIES
───────────────────────────────────────────────────────────── */
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .25rem; } .gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; } .gap-4 { gap: 1rem; }
.w-full { width: 100%; }
.hidden { display: none !important; }

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

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-w);
  transition: margin-left var(--transition);
}

.main-wrapper.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed);
}

.page-content {
  padding: 1.75rem 2rem;
  flex: 1;
}

/* grid helpers */
.grid-cols-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.grid-cols-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.grid-cols-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; }


/* ─────────────────────────────────────────────────────────────
   5. BUTTONS — global variants
───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem 1.2rem;
  border-radius: var(--radius-md);
  font-size: .875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}
.btn:hover  { opacity: .9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary   { background: var(--brand-primary);   color: #fff; box-shadow: 0 2px 8px rgba(26,86,219,.35); }
.btn-success   { background: var(--brand-secondary); color: #fff; }
.btn-danger    { background: var(--brand-danger);    color: #fff; }
.btn-warning   { background: var(--brand-warning);   color: #fff; }
.btn-info      { background: var(--brand-info);      color: #fff; }
.btn-outline   { background: transparent; border: 1.5px solid var(--brand-primary); color: var(--brand-primary); }
.btn-ghost     { background: transparent; color: var(--text-body); }
.btn-ghost:hover { background: var(--border-light); }
.btn-sm        { padding: .32rem .8rem; font-size: .78rem; }
.btn-lg        { padding: .7rem 1.8rem; font-size: 1rem; }
.btn-icon      { padding: .45rem; border-radius: var(--radius-sm); }
.btn-block     { width: 100%; justify-content: center; }


/* ─────────────────────────────────────────────────────────────
   6. FORM CONTROLS
───────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: 1rem;
}

.form-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: .3rem;
}
.form-label i { color: var(--brand-primary); font-size: .78rem; }

.form-control {
  width: 100%;
  padding: .55rem .9rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-body);
  font-size: .875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}
.form-control:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}
.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8rem center;
  padding-right: 2.2rem;
}

textarea.form-control { resize: vertical; min-height: 90px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.input-icon-wrap {
  position: relative;
}
.input-icon-wrap i {
  position: absolute;
  left: .85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .85rem;
  pointer-events: none;
}
.input-icon-wrap .form-control {
  padding-left: 2.4rem;
}


/* ─────────────────────────────────────────────────────────────
   7. CARDS & PANELS
───────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: .85rem;
  border-bottom: 1px solid var(--border-light);
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: .45rem;
}
.card-title i { color: var(--brand-primary); }

.card-body  { padding: 0; }
.card-footer{
  margin-top: 1.25rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border-light);
  font-size: .82rem;
  color: var(--text-muted);
}


/* ─────────────────────────────────────────────────────────────
   8. BADGES & STATUS PILLS
───────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .2rem .65rem;
  border-radius: var(--radius-pill);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.badge-primary  { background: rgba(26,86,219,.12);  color: var(--brand-primary); }
.badge-success  { background: rgba(14,159,110,.12); color: var(--brand-secondary); }
.badge-danger   { background: rgba(224,36,36,.12);  color: var(--brand-danger); }
.badge-warning  { background: rgba(245,158,11,.15); color: #b45309; }
.badge-info     { background: rgba(58,191,248,.12); color: #0369a1; }
.badge-muted    { background: var(--border-light);  color: var(--text-muted); }

/* dot indicator */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: .3rem;
}
.dot-success { background: var(--brand-secondary); }
.dot-danger  { background: var(--brand-danger); }
.dot-warning { background: var(--brand-warning); }
.dot-info    { background: var(--brand-info); }
.dot-muted   { background: var(--text-muted); }


/* ─────────────────────────────────────────────────────────────
   9. TOPBAR / NAVBAR
───────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: .4rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 1.1rem;
  transition: background var(--transition), color var(--transition);
}
.topbar-toggle:hover {
  background: var(--border-light);
  color: var(--brand-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: .6rem;
  cursor: pointer;
}
.topbar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-info));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
}
.topbar-username {
  font-weight: 600;
  font-size: .875rem;
  color: var(--text-heading);
}
.topbar-role {
  font-size: .72rem;
  color: var(--text-muted);
}

/* notification bell */
.btn-notif {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  padding: .45rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.btn-notif:hover { background: var(--border-light); color: var(--brand-primary); }
.notif-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  background: var(--brand-danger);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}


/* ─────────────────────────────────────────────────────────────
   10. SIDEBAR NAVIGATION
───────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  min-height: 100vh;
  position: fixed;
  left: 0; top: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  transition: width var(--transition);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-info));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  flex-shrink: 0;
}
.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  overflow: hidden;
  white-space: nowrap;
}
.sidebar-logo-text strong {
  font-size: .85rem;
  color: #fff;
  font-weight: 800;
  letter-spacing: .03em;
}
.sidebar-logo-text span {
  font-size: .67rem;
  color: rgba(255,255,255,.45);
  letter-spacing: .04em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 0;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  padding: 1rem 1.2rem .35rem;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .62rem 1.2rem;
  color: rgba(255,255,255,.6);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border-radius: 0;
  white-space: nowrap;
  position: relative;
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
}
.nav-item i {
  width: 20px;
  text-align: center;
  font-size: .95rem;
  flex-shrink: 0;
}
.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}
.nav-item.active {
  background: rgba(26,86,219,.25);
  color: #fff;
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--brand-primary);
  border-radius: 0 3px 3px 0;
}
.nav-item-label { overflow: hidden; text-overflow: ellipsis; }

.nav-badge {
  margin-left: auto;
  background: var(--brand-danger);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: .1rem .45rem;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-item-label { display: none; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.07);
  padding: .8rem 0;
}


/* ─────────────────────────────────────────────────────────────
   11. STAT / KPI CARDS
───────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card.blue::after   { background: var(--brand-primary); }
.stat-card.green::after  { background: var(--brand-secondary); }
.stat-card.orange::after { background: var(--brand-accent); }
.stat-card.red::after    { background: var(--brand-danger); }
.stat-card.teal::after   { background: var(--brand-info); }

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.stat-icon.blue   { background: rgba(26,86,219,.1);   color: var(--brand-primary); }
.stat-icon.green  { background: rgba(14,159,110,.1);  color: var(--brand-secondary); }
.stat-icon.orange { background: rgba(255,140,0,.1);   color: var(--brand-accent); }
.stat-icon.red    { background: rgba(224,36,36,.1);   color: var(--brand-danger); }
.stat-icon.teal   { background: rgba(58,191,248,.1);  color: var(--brand-info); }

.stat-content { flex: 1; min-width: 0; }
.stat-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .25rem;
}
.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-heading);
  line-height: 1;
  font-family: 'Outfit', sans-serif;
}
.stat-sub {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .3rem;
}
.stat-trend {
  font-size: .75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .2rem;
  margin-top: .3rem;
}
.stat-trend.up   { color: var(--brand-secondary); }
.stat-trend.down { color: var(--brand-danger); }


/* ─────────────────────────────────────────────────────────────
   12. DATA TABLES (DataTables wrapper)
───────────────────────────────────────────────────────────── */
.dt-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.dt-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
  gap: .75rem;
}

.dt-toolbar-left,
.dt-toolbar-right {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
}

/* DataTables overrides */
table.dataTable {
  width: 100% !important;
  border-collapse: collapse;
  font-size: .86rem;
}

table.dataTable thead th {
  background: var(--bg-table-head);
  color: #fff;
  font-weight: 700;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .85rem 1rem;
  border: none;
  white-space: nowrap;
}

table.dataTable thead th::after,
table.dataTable thead th::before { opacity: .5; }

table.dataTable tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}

table.dataTable tbody tr:nth-child(even) { background: var(--bg-table-stripe); }
table.dataTable tbody tr:hover { background: rgba(26,86,219,.05); }

table.dataTable tbody td {
  padding: .75rem 1rem;
  color: var(--text-body);
  vertical-align: middle;
}

/* action buttons inside table */
.tbl-actions { display: flex; gap: .4rem; flex-wrap: nowrap; }

/* DataTables pagination & info */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
  font-size: .82rem;
  color: var(--text-muted);
  padding: .75rem 1.4rem;
}

.dataTables_wrapper .dataTables_filter input {
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: .38rem .7rem;
  font-size: .82rem;
  color: var(--text-body);
  background: var(--bg-body);
  transition: border-color var(--transition);
  margin-left: .4rem;
}
.dataTables_wrapper .dataTables_filter input:focus {
  outline: none;
  border-color: var(--brand-primary);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: var(--radius-sm);
  padding: .3rem .65rem;
  font-size: .8rem;
  cursor: pointer;
  color: var(--text-body) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--brand-primary) !important;
  color: #fff !important;
  border: none !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.current) {
  background: var(--border-light) !important;
  color: var(--brand-primary) !important;
  border: none !important;
}

/* Buttons (DataTables export) */
.dt-buttons {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}
.dt-button {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .38rem .85rem;
  background: var(--bg-body);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-body);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  font-family: inherit;
}
.dt-button:hover {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}
/* custom export bar shown above table */
.export-bar {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  align-items: center;
}
.export-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .36rem .85rem;
  background: var(--bg-body);
  border: 1.5px solid var(--border-card);
  border-radius: var(--radius-md);
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-body);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.export-btn:hover { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.export-btn.pdf   { border-color: #e02424; color: #e02424; }
.export-btn.pdf:hover { background: #e02424; color: #fff; }
.export-btn.excel { border-color: #0e9f6e; color: #0e9f6e; }
.export-btn.excel:hover { background: #0e9f6e; color: #fff; }
.export-btn.csv   { border-color: #7c3aed; color: #7c3aed; }
.export-btn.csv:hover { background: #7c3aed; color: #fff; }


/* ─────────────────────────────────────────────────────────────
   13. MODAL / OVERLAY
───────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  animation: modalIn .22s ease;
}
.modal-box.wide { max-width: 720px; }
.modal-box.narrow { max-width: 380px; }

@keyframes modalIn {
  from { transform: scale(.95) translateY(10px); opacity: 0; }
  to   { transform: scale(1) translateY(0);      opacity: 1; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.6rem;
  border-bottom: 1px solid var(--border-light);
}
.modal-head h3 {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: .45rem;
}
.modal-head h3 i { color: var(--brand-primary); }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text-muted);
  padding: .25rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--border-light); color: var(--brand-danger); }

.modal-body  { padding: 1.5rem 1.6rem; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
  padding: 1rem 1.6rem;
  border-top: 1px solid var(--border-light);
}


/* ─────────────────────────────────────────────────────────────
   14. TOAST NOTIFICATIONS
───────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--bg-card);
  border-left: 4px solid var(--brand-primary);
  border-radius: var(--radius-md);
  padding: .75rem 1.1rem;
  box-shadow: var(--shadow-md);
  min-width: 280px;
  max-width: 380px;
  animation: toastIn .25s ease;
}
.toast.success { border-color: var(--brand-secondary); }
.toast.error   { border-color: var(--brand-danger); }
.toast.warning { border-color: var(--brand-warning); }

.toast i { font-size: 1rem; flex-shrink: 0; }
.toast.success i { color: var(--brand-secondary); }
.toast.error   i { color: var(--brand-danger); }
.toast.warning i { color: var(--brand-warning); }
.toast p { font-size: .84rem; font-weight: 500; color: var(--text-heading); flex: 1; }

@keyframes toastIn {
  from { transform: translateX(30px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}


/* ─────────────────────────────────────────────────────────────
   15. LOADING SPINNER
───────────────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--border-light);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ─────────────────────────────────────────────────────────────
   16. FOOTER NOTE
───────────────────────────────────────────────────────────── */
.footer-bar {
  background: var(--bg-card);
  border-top: 1px solid var(--border-card);
  padding: .75rem 2rem;
  font-size: .75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.footer-bar i { color: var(--brand-primary); }


/* ─────────────────────────────────────────────────────────────
   17. SCROLLBAR
───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }


/* ─────────────────────────────────────────────────────────────
   18. RESPONSIVE HELPERS
───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
  .stat-grid   { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); width: 260px; }
  .main-wrapper { margin-left: 0 !important; }
  .page-content { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4,
  .stat-grid { grid-template-columns: 1fr; }
}

/* ─────────────────────────────────────────────────────────────
   19. STICKY FOOTER — app shell
───────────────────────────────────────────────────────────── */
.main-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.main-wrapper .page-content {
  flex: 1 1 auto;        /* push footer to bottom */
}
.footer-bar {
  flex-shrink: 0;
  position: sticky;      /* sticks at bottom of viewport when content is short */
  bottom: 0;
  z-index: 90;
}

/* ─────────────────────────────────────────────────────────────
   20. FULL-WIDTH LAYOUT HELPERS (dashboard sections)
       Forces stat/quick/chart grids to use available width
───────────────────────────────────────────────────────────── */
.stat-grid {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  width: 100%;
}
.quick-grid {
  width: 100%;
}

/* ─────────────────────────────────────────────────────────────
   21. TOPBAR USER DROPDOWN
───────────────────────────────────────────────────────────── */
.topbar-user-wrap {
  position: relative;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: .6rem;
  cursor: pointer;
  padding: .35rem .55rem;
  border-radius: var(--radius-md);
  transition: background var(--transition);
  user-select: none;
}
.topbar-user:hover {
  background: var(--border-light);
}
.topbar-user .chevron {
  font-size: .65rem;
  color: var(--text-muted);
  transition: transform .2s;
  margin-left: .1rem;
}
.topbar-user-wrap.open .chevron {
  transform: rotate(180deg);
}

/* Dropdown panel */
.user-dropdown {
  position: absolute;
  top: calc(100% + .5rem);
  right: 0;
  width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 999;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity .18s ease, transform .18s ease;
}
.topbar-user-wrap.open .user-dropdown {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.user-dropdown-header {
  padding: .95rem 1.1rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.udh-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: .88rem;
  color: #fff;
  flex-shrink: 0;
}
.udh-name {
  font-size: .88rem;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.2;
}
.udh-role {
  font-size: .72rem;
  color: var(--text-muted);
}

.user-dropdown-body {
  padding: .4rem 0;
}
.dd-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem 1.1rem;
  font-size: .84rem;
  color: var(--text-body);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}
.dd-item i {
  width: 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: .85rem;
  flex-shrink: 0;
}
.dd-item:hover {
  background: var(--bg-body);
  color: var(--brand-primary);
  text-decoration: none;
}
.dd-item:hover i { color: var(--brand-primary); }

.dd-divider {
  height: 1px;
  background: var(--border-light);
  margin: .3rem 0;
}

.dd-item.danger     { color: var(--brand-danger); }
.dd-item.danger i   { color: var(--brand-danger); }
.dd-item.danger:hover { background: rgba(224,36,36,.06); color: var(--brand-danger); }