/* ============================================================
   Weekly School ERP — Design System
   ============================================================ */

:root {
  /* Primary palette */
  --primary: #002444;
  --primary-container: #1B3A5C;
  --primary-light: #2E5984;
  --on-primary: #ffffff;
  --on-primary-container: #87A4CC;
  --primary-fixed-dim: #ABC9F2;

  /* Secondary (green) */
  --secondary: #006D36;
  --secondary-container: #83FBA5;
  --on-secondary: #ffffff;

  /* Tertiary (orange) */
  --tertiary: #F38500;
  --tertiary-container: #592D00;
  --tertiary-fixed: #FFDCC3;

  /* Error */
  --error: #BA1A1A;
  --error-container: #FFDAD6;
  --on-error: #ffffff;

  /* Surface */
  --surface: #F8F9FF;
  --surface-dim: #C4DCFF;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #EFF4FF;
  --surface-container: #E5EEFF;
  --surface-container-high: #DCE9FF;
  --surface-container-highest: #D2E4FF;
  --on-surface: #001C38;
  --on-surface-variant: #43474E;

  /* Outline */
  --outline: #73777F;
  --outline-variant: #C3C6CF;

  /* Misc */
  --yellow: #EAB308;
  --inverse-surface: #113253;

  /* Layout */
  --sidebar-width: 240px;
  --topbar-height: 64px;

  /* Typography */
  --font-headline: 'Public Sans', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  /* Shadows — refined for depth */
  --shadow-sm: 0 1px 4px rgba(0,24,68,0.06), 0 1px 2px rgba(0,24,68,0.04);
  --shadow-md: 0 4px 16px rgba(0,24,68,0.08), 0 2px 4px rgba(0,24,68,0.04);
  --shadow-lg: 0 8px 32px rgba(0,24,68,0.12), 0 4px 8px rgba(0,24,68,0.06);
}

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

/* UIcons alignment override — fix display:block and line-height from CDN */
.fi {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  line-height: 1 !important;
  vertical-align: middle;
  font-style: normal;
}

body {
  font-family: var(--font-body);
  background: var(--surface);
  color: var(--on-surface);
  min-height: 100vh;
  display: flex;
  font-size: 13px;
  line-height: 1.5;
}

h1, h2, h3, h4, .font-headline {
  font-family: var(--font-headline);
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  cursor: pointer;
  font-family: var(--font-body);
  border: none;
  background: none;
}

table {
  border-collapse: collapse;
  width: 100%;
}

input, select, textarea {
  font-family: var(--font-body);
  font-size: 13px;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--primary) 0%, #001830 100%);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  z-index: 50;
  box-shadow: 4px 0 24px rgba(0,20,50,0.25);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
  margin-bottom: 32px;
}

.sidebar-logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #ffffff, #e0ecff);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.sidebar-logo-icon .fi {
  color: var(--primary);
  font-size: 24px;
}

.sidebar-title {
  font-size: 18px;
  font-weight: 900;
  color: white;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.sidebar-subtitle {
  font-size: 10px;
  color: #94a3b8;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 3px;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: rgba(255,255,255,0.55);
  font-size: 13px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  border-radius: 8px;
  border-left: none;
  transition: all 0.2s;
}

.sidebar-nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.9);
}

.sidebar-nav-item.active {
  background: rgba(255,255,255,0.12);
  color: white;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--secondary);
}

.sidebar-nav-item .fi {
  font-size: 20px;
}

.sidebar-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 8px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ============================================================
   Main Wrapper
   ============================================================ */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
  max-width: calc(100vw - var(--sidebar-width));
}

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  height: var(--topbar-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 32px;
  background: var(--surface-container-lowest);
  border-bottom: 1px solid rgba(0,24,68,0.08);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 1px 3px rgba(0,24,68,0.04);
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
}

.breadcrumb-prefix {
  color: #94a3b8;
  font-weight: 500;
  font-size: 14px;
}

.breadcrumb-separator {
  color: #94a3b8;
  font-size: 12px;
}

.breadcrumb-current {
  color: var(--primary);
  font-weight: 700;
  font-size: 14px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.topbar-location {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  transition: background 0.2s;
}

.topbar-location:hover {
  background: var(--surface-container-low);
}

.location-flag {
  font-size: 16px;
}

.location-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
}

.topbar-notifications {
  position: relative;
  cursor: pointer;
}

.topbar-notifications .fi {
  color: #64748b;
  font-size: 24px;
  transition: color 0.2s;
}

.topbar-notifications:hover .fi {
  color: var(--primary);
}

.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: var(--error);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 16px;
  border-left: 1px solid #e2e8f0;
}

.user-info {
  text-align: right;
}

.user-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.user-role {
  font-size: 11px;
  color: #64748b;
  font-weight: 500;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1B3A5C 0%, #002444 100%);
  color: rgba(255,255,255,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid var(--surface-container-high);
  box-shadow: 0 2px 8px rgba(0,24,68,0.15);
}

/* ============================================================
   Content Area
   ============================================================ */
.content-area {
  padding: 32px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  transition: opacity 0.2s ease;
}

/* ============================================================
   Card
   ============================================================ */
.card {
  background: var(--surface-container-lowest);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,24,68,0.06);
  padding: 24px;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(0,24,68,0.1);
}

/* ============================================================
   Metric Cards
   ============================================================ */
.metric-cards {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
}

.metric-card {
  background: var(--surface-container-lowest);
  padding: 20px;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,24,68,0.06);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s;
}

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

.metric-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.metric-icon {
  width: 40px;
  height: 40px;
  background: var(--surface-container-high);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.metric-icon .fi {
  font-size: 22px;
}

.metric-trend {
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 2px;
}

.metric-trend.up {
  color: var(--secondary);
}

.metric-trend.down {
  color: var(--error);
}

.metric-trend.neutral {
  color: var(--tertiary);
}

.metric-trend .fi {
  font-size: 14px;
}

.metric-value {
  font-size: 28px;
  font-weight: 900;
  color: var(--primary);
  font-family: var(--font-headline);
  line-height: 1;
}

.metric-label {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-top: 4px;
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  text-align: left;
  min-width: 700px;
}

.data-table thead th {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #e2e8f0;
  background: rgba(239,244,255,0.4);
}

.data-table tbody td {
  padding: 14px 16px;
  font-size: 13px;
  border-bottom: 1px solid #f1f5f9;
}

.data-table tbody tr {
  transition: background 0.15s;
}

.data-table tbody tr:hover {
  background: var(--surface-container-low);
}

.data-table tbody tr.clickable {
  cursor: pointer;
}

.data-table tbody tr.clickable:hover {
  background: var(--surface-container-low);
}

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-green {
  background: rgba(0,109,54,0.1);
  color: var(--secondary);
}

.badge-orange {
  background: rgba(243,133,0,0.1);
  color: var(--tertiary);
}

.badge-red {
  background: rgba(186,26,26,0.1);
  color: var(--error);
}

.badge-blue {
  background: rgba(0,36,68,0.1);
  color: var(--primary);
}

.badge-gray {
  background: #f1f5f9;
  color: #64748b;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  border: none;
  cursor: pointer;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 6px rgba(0,36,68,0.2);
}

.btn-primary:hover {
  background: var(--primary-container);
  box-shadow: 0 4px 12px rgba(0,36,68,0.25);
}

.btn-success {
  background: var(--secondary);
  color: white;
}

.btn-success:hover {
  background: #005a2c;
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-danger:hover {
  background: #9c1515;
}

.btn-warning {
  background: var(--tertiary);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--outline-variant);
  color: var(--on-surface);
}

.btn-outline:hover {
  background: var(--surface-container-low);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

/* ============================================================
   Tabs
   ============================================================ */
.tabs {
  display: flex;
  background: var(--surface-container);
  padding: 4px;
  border-radius: 8px;
  gap: 2px;
}

.tab-item {
  padding: 8px 20px;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: none;
}

.tab-item:hover {
  color: var(--primary);
}

.tab-item.active {
  background: white;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ============================================================
   Progress Bars
   ============================================================ */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--surface-container);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease;
}

.progress-bar-fill.green { background: var(--secondary); }
.progress-bar-fill.blue { background: var(--primary-container); }
.progress-bar-fill.orange { background: var(--tertiary); }
.progress-bar-fill.red { background: var(--error); }
.progress-bar-fill.yellow { background: var(--yellow); }

/* ============================================================
   Slide-Over
   ============================================================ */
.slide-over {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
}

.slide-over.open {
  display: flex;
}

.slide-over-backdrop {
  flex: 1;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(2px);
}

.slide-over-panel {
  width: 55%;
  max-width: 720px;
  background: white;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -12px 0 40px rgba(0,24,68,0.15);
}

.slide-over.open .slide-over-panel {
  transform: translateX(0);
}

.slide-over-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #f1f5f9;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.slide-over-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.slide-over-close:hover {
  background: #f1f5f9;
}

.slide-over-body {
  padding: 24px;
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
}

.modal-overlay.open {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,24,68,0.18), 0 4px 12px rgba(0,24,68,0.08);
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid rgba(0,24,68,0.06);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #f1f5f9;
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid #f1f5f9;
}

/* ============================================================
   Grid Utilities
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; }

.grid-60-40 {
  display: grid;
  grid-template-columns: 1fr 0.66fr;
  gap: 24px;
}

.grid-50-50 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.grid-45-55 {
  display: grid;
  grid-template-columns: 45% 55%;
  gap: 0;
}

/* ============================================================
   Spacing Utilities
   ============================================================ */
.space-y-4 > * + * { margin-top: 16px; }
.space-y-6 > * + * { margin-top: 24px; }
.space-y-8 > * + * { margin-top: 32px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mt-8 { margin-top: 32px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mb-8 { margin-bottom: 32px; }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }

/* ============================================================
   Text Utilities
   ============================================================ */
.text-primary { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-error { color: var(--error); }
.text-tertiary { color: var(--tertiary); }
.text-muted { color: #64748b; }
.text-xs { font-size: 11px; }
.text-sm { font-size: 13px; }
.text-base { font-size: 14px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 22px; }
.text-2xl { font-size: 28px; }
.font-bold { font-weight: 700; }
.font-black { font-weight: 900; }
.uppercase { text-transform: uppercase; }
.tracking-wide { letter-spacing: 1px; }

/* ============================================================
   Form Elements
   ============================================================ */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #dce1e8;
  border-radius: 8px;
  font-size: 13px;
  color: var(--on-surface);
  transition: all 0.2s;
  background: #fafbfd;
}

.form-input:hover {
  border-color: #b0b8c4;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-container);
  box-shadow: 0 0 0 3px rgba(27,58,92,0.08);
  background: white;
}

.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--outline-variant);
  border-radius: 8px;
  font-size: 13px;
  color: var(--on-surface);
  background: white;
  cursor: pointer;
}

textarea.form-input {
  resize: vertical;
  min-height: 80px;
}

/* ============================================================
   Filter Bar
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  flex-wrap: wrap;
}

.filter-bar .form-input,
.filter-bar .form-select {
  width: auto;
  min-width: 180px;
}

.search-input {
  position: relative;
}

.search-input .fi {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: #94a3b8;
}

.search-input input {
  padding-left: 40px;
}

/* ============================================================
   Summary Cards Row
   ============================================================ */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.summary-card {
  background: var(--surface-container-lowest);
  padding: 20px;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,24,68,0.06);
  transition: box-shadow 0.2s;
}

.summary-card:hover {
  box-shadow: var(--shadow-md);
}

.summary-card-label {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.summary-card-value {
  font-size: 28px;
  font-weight: 900;
  color: var(--primary);
  font-family: var(--font-headline);
}

.summary-card-sub {
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
}

/* ============================================================
   Score / Gauge
   ============================================================ */
.score-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.score-bar-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  min-width: 100px;
}

.score-bar-track {
  flex: 1;
  height: 6px;
  background: var(--surface-container);
  border-radius: 999px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 999px;
}

.score-bar-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  min-width: 35px;
  text-align: right;
}

/* ============================================================
   Stepper
   ============================================================ */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 24px 0;
}

.stepper-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
}

.stepper-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  z-index: 1;
}

.stepper-circle.done {
  background: var(--secondary);
  color: white;
}

.stepper-circle.current {
  background: var(--primary-container);
  color: white;
}

.stepper-circle.pending {
  background: #e2e8f0;
  color: #94a3b8;
}

.stepper-label {
  font-size: 10px;
  font-weight: 600;
  color: #64748b;
  text-align: center;
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.stepper-line {
  height: 3px;
  flex: 1;
  margin-top: -18px;
}

.stepper-line.done { background: var(--secondary); }
.stepper-line.pending { background: #e2e8f0; }

/* ============================================================
   Accordion
   ============================================================ */
.accordion-item {
  border: 1px solid #f1f5f9;
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}

.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  cursor: pointer;
  background: var(--surface-container-low);
  transition: background 0.2s;
}

.accordion-header:hover {
  background: var(--surface-container);
}

.accordion-body {
  padding: 0 16px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.accordion-item.open .accordion-body {
  max-height: 500px;
  padding: 16px;
}

.accordion-item.open .accordion-chevron {
  transform: rotate(180deg);
}

.accordion-chevron {
  transition: transform 0.2s;
}

/* ============================================================
   Tag / Pill
   ============================================================ */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: var(--surface-container);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
}

.tag .remove-tag {
  cursor: pointer;
  font-size: 14px;
  color: #94a3b8;
}

/* ============================================================
   Section Heading
   ============================================================ */
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  font-family: var(--font-headline);
}

/* ============================================================
   Hamburger (hidden on desktop)
   ============================================================ */
.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary);
  transition: background 0.2s;
  flex-shrink: 0;
}

.hamburger:hover {
  background: var(--surface-container-low);
}

.hamburger .fi {
  font-size: 24px;
}

/* Sidebar overlay (hidden on desktop) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
  z-index: 45;
}

/* ============================================================
   Responsive — Large tablets / small desktops (1280px)
   ============================================================ */
@media (max-width: 1280px) {
  .metric-cards {
    grid-template-columns: repeat(3, 1fr);
  }
  .grid-60-40,
  .grid-50-50 {
    grid-template-columns: 1fr;
  }
  .summary-cards {
    grid-template-columns: repeat(4, 1fr);
  }
  .summary-cards[style*="repeat(5"] {
    grid-template-columns: repeat(5, 1fr) !important;
  }
}

/* ============================================================
   Responsive — Tablet (768px)
   ============================================================ */
@media (max-width: 768px) {
  /* --- Prevent horizontal overflow --- */
  body {
    overflow-x: hidden;
  }
  .main-wrapper {
    overflow-x: hidden;
  }

  /* --- Sidebar: off-canvas overlay --- */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open {
    display: block;
  }
  .hamburger {
    display: flex;
  }

  /* --- Main wrapper full width --- */
  .main-wrapper {
    margin-left: 0;
  }

  /* --- Topbar --- */
  .topbar {
    padding: 0 12px;
    gap: 8px;
  }
  .topbar-breadcrumb {
    flex: 1;
    min-width: 0;
  }
  .breadcrumb-current {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar-right {
    gap: 12px;
    flex-shrink: 0;
  }
  .topbar-location {
    display: none;
  }
  .user-info {
    display: none;
  }
  .topbar-user {
    border-left: none;
    padding-left: 0;
  }

  /* --- Content area --- */
  .content-area {
    padding: 20px 16px;
  }

  /* --- ALL page headings (inline font-size:28px) --- */
  h2[style*="font-size:28px"] {
    font-size: 20px !important;
    letter-spacing: -0.3px !important;
  }

  /* --- ALL cards with inline padding:32px --- */
  .card[style*="padding:32px"],
  .card[style*="padding:24px"] {
    padding: 16px !important;
  }

  /* --- ALL inline padding:24px 32px on card headers --- */
  [style*="padding:24px 32px"] {
    padding: 16px !important;
  }
  [style*="padding:0 32px"] {
    padding: 0 16px !important;
  }

  /* --- Metric cards: 2 columns --- */
  .metric-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  /* --- Grid utilities --- */
  .grid-2 {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .grid-6 {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
  .grid-45-55 {
    grid-template-columns: 1fr;
  }

  /* --- Summary cards --- */
  .summary-cards {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px;
  }

  /* --- Page header flex (title + button side by side) --- */
  [style*="justify-content:space-between"][style*="align-items:flex-end"] {
    flex-wrap: wrap !important;
    gap: 12px !important;
  }

  /* --- Dashboard: Training Progress circle + stats --- */
  [style*="gap:48px"] {
    flex-direction: column !important;
    gap: 24px !important;
    align-items: center !important;
  }
  [style*="width:160px"][style*="height:160px"] {
    width: 120px !important;
    height: 120px !important;
  }
  [style*="font-size:32px"][style*="font-weight:900"] {
    font-size: 24px !important;
  }
  /* Training stats grid */
  [style*="grid-template-columns:1fr 1fr"][style*="gap:24px"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 16px !important;
  }
  [style*="font-size:22px"][style*="font-weight:900"] {
    font-size: 18px !important;
  }

  /* --- Dashboard: Budget section large font --- */
  [style*="font-size:32px"][style*="font-family"] {
    font-size: 22px !important;
  }
  [style*="margin-bottom:32px"] {
    margin-bottom: 16px !important;
  }
  [style*="margin-top:32px"] {
    margin-top: 16px !important;
  }
  [style*="padding-top:24px"] {
    padding-top: 12px !important;
  }
  [style*="padding-bottom:48px"] {
    padding-bottom: 24px !important;
  }

  /* --- Dashboard: inline 2-col grid in budget status --- */
  [style*="grid-template-columns:1fr 1fr"][style*="gap:16px"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  /* --- AI Screening: split view --- */
  [style*="display:flex"][style*="min-height:600px"] {
    flex-direction: column !important;
    min-height: auto !important;
    gap: 16px !important;
  }
  [style*="width:45%"] {
    width: 100% !important;
  }
  [style*="width:55%"] {
    width: 100% !important;
  }
  /* AI screening filter bar */
  [style*="flex:1;max-width:200px"] {
    max-width: 100% !important;
  }

  /* --- Demand/Mandate/Program tabs inline gap:32px and gap:24px --- */
  .demand-tab {
    font-size: 12px !important;
    white-space: nowrap;
    flex-shrink: 0;
  }
  [style*="display:flex"][style*="gap:32px"] {
    gap: 12px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  [style*="display:flex"][style*="gap:24px"][style*="border-bottom"] {
    gap: 12px !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
  }

  /* --- Filter bars with inline min-width --- */
  [style*="min-width:200px"] {
    min-width: 0 !important;
    width: 100% !important;
  }
  [style*="min-width:140px"] {
    min-width: 0 !important;
    flex: 1 !important;
  }
  .form-select[style*="width:auto"] {
    width: 100% !important;
  }
  /* Filter card containers */
  .card[style*="display:flex"][style*="flex-wrap:wrap"] {
    gap: 10px !important;
  }
  .card[style*="display:flex"][style*="align-items:center"][style*="gap:16px"] {
    flex-wrap: wrap !important;
    gap: 10px !important;
  }
  .card[style*="display:flex"][style*="align-items:center"][style*="gap:24px"] {
    flex-wrap: wrap !important;
    gap: 10px !important;
  }

  /* --- Payments: 5-col inline grid override --- */
  .summary-cards[style*="repeat(5"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* --- Settings: sidebar + content layout --- */
  [style*="display:flex"][style*="gap:24px"]:has([style*="width:220px"]) {
    flex-direction: column !important;
  }
  [style*="width:220px"][style*="flex-shrink:0"] {
    width: 100% !important;
    flex-shrink: 1 !important;
  }
  .settings-tab {
    display: inline-flex !important;
    width: auto !important;
    padding: 8px 12px !important;
    font-size: 11px !important;
  }
  [style*="width:220px"] .card[style*="padding:8px"] {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
    padding: 8px !important;
  }

  /* --- Tables: horizontal scroll wrapper --- */
  .card:has(.data-table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .data-table {
    min-width: 600px;
  }

  /* --- Slide-over --- */
  .slide-over-panel {
    width: 80%;
    max-width: none;
  }

  /* --- Filter bar --- */
  .filter-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* --- Stepper: compact --- */
  .stepper-label { font-size: 8px; }
  .stepper-circle { width: 28px; height: 28px; font-size: 11px; }

  /* --- Tabs: scrollable --- */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }
  .tab-item {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 11px;
  }

  /* --- Section heading --- */
  .section-heading {
    flex-wrap: wrap;
    gap: 12px;
  }

  /* --- Cards base: smaller padding --- */
  .card {
    padding: 16px;
  }

  /* --- Metric values --- */
  .metric-value { font-size: 22px; }
  .summary-card-value { font-size: 22px; }

  /* --- KPI sliders --- */
  input[type="range"][style*="width:150px"] {
    width: 100px !important;
  }

  /* --- Inline flex with gap:16px wrap on narrow --- */
  .card[style*="display:flex"][style*="gap:16px"] {
    flex-wrap: wrap !important;
  }
}

/* ============================================================
   Responsive — Mobile (480px)
   ============================================================ */
@media (max-width: 480px) {
  /* --- Topbar --- */
  .topbar {
    height: 56px;
    padding: 0 10px;
  }
  .breadcrumb-prefix,
  .breadcrumb-separator {
    display: none;
  }
  .breadcrumb-current {
    font-size: 14px;
    font-weight: 700;
  }
  .topbar-right {
    gap: 6px;
  }
  .notification-badge {
    width: 16px;
    height: 16px;
    font-size: 9px;
  }
  .hamburger {
    width: 36px;
    height: 36px;
  }
  .user-avatar {
    width: 32px;
    height: 32px;
    font-size: 11px;
  }

  /* --- Content area --- */
  .content-area {
    padding: 16px 12px;
  }

  /* --- Page headings --- */
  h2[style*="font-size:28px"] {
    font-size: 18px !important;
    line-height: 1.3 !important;
  }

  /* --- Page header flex: stack title + button vertically --- */
  [style*="justify-content:space-between"][style*="align-items:flex-end"] {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }

  /* --- Metric cards --- */
  .metric-cards {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .metric-card {
    padding: 12px;
  }
  .metric-value {
    font-size: 18px;
  }
  .metric-label {
    font-size: 10px;
  }
  .metric-icon {
    width: 32px;
    height: 32px;
  }
  .metric-icon .fi {
    font-size: 18px;
  }

  /* --- Grid utilities: single column --- */
  .grid-2,
  .grid-3,
  .grid-4,
  .grid-6 {
    grid-template-columns: 1fr !important;
  }

  /* --- Summary cards: 2 columns on mobile --- */
  .summary-cards {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px;
  }
  .summary-card {
    padding: 12px;
  }
  .summary-card-value {
    font-size: 16px;
  }
  .summary-card-label {
    font-size: 9px;
    letter-spacing: 0.5px;
  }

  /* --- Dashboard: circle smaller --- */
  [style*="width:160px"][style*="height:160px"] {
    width: 100px !important;
    height: 100px !important;
  }
  [style*="font-size:32px"][style*="font-weight:900"] {
    font-size: 20px !important;
  }
  [style*="font-size:22px"][style*="font-weight:900"] {
    font-size: 16px !important;
  }
  /* Budget large font */
  [style*="font-size:32px"][style*="font-family"] {
    font-size: 18px !important;
  }
  [style*="font-size:20px"][style*="font-weight:900"]:not(.metric-value):not(.summary-card-value) {
    font-size: 16px !important;
  }

  /* --- Training stats grid: single column --- */
  [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }

  /* --- Payments: 5-col → 1-col --- */
  .summary-cards[style*="repeat(5"] {
    grid-template-columns: 1fr !important;
  }

  /* --- Settings sidebar: inline horizontal tabs --- */
  [style*="width:220px"][style*="flex-shrink:0"] {
    width: 100% !important;
  }
  .settings-tab {
    font-size: 10px !important;
    padding: 6px 8px !important;
  }

  /* --- Inline cards padding override --- */
  .card[style*="padding:32px"],
  .card[style*="padding:24px"] {
    padding: 14px !important;
  }
  .card[style*="text-align:center"][style*="padding:60px"] {
    padding: 32px 14px !important;
  }
  [style*="padding:24px 32px"],
  [style*="padding:0 32px"] {
    padding: 0 14px !important;
  }
  [style*="padding:20px 24px"] {
    padding: 14px !important;
  }

  /* --- All inline gap:24px containers --- */
  [style*="gap:24px"] {
    gap: 12px !important;
  }
  [style*="gap:48px"] {
    gap: 16px !important;
  }

  /* --- Demand tabs --- */
  .demand-tab {
    font-size: 11px !important;
    padding: 0 0 8px !important;
  }

  /* --- Slide-over: full width --- */
  .slide-over-panel {
    width: 100%;
  }
  .slide-over-header {
    padding: 16px;
  }
  .slide-over-body {
    padding: 16px;
  }

  /* --- Modal --- */
  .modal-content {
    width: 95%;
    max-height: 90vh;
    border-radius: 10px;
  }
  .modal-header { padding: 16px; }
  .modal-body { padding: 16px; }
  .modal-footer {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  /* --- Cards base --- */
  .card {
    padding: 14px;
    border-radius: 8px;
  }
  .section-title {
    font-size: 16px;
  }

  /* --- Buttons --- */
  .btn {
    padding: 8px 14px;
    font-size: 12px;
  }

  /* --- Stepper: vertical on mobile --- */
  .stepper {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }
  .stepper-step {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px 0;
  }
  .stepper-circle {
    width: 30px;
    height: 30px;
    font-size: 12px;
    flex-shrink: 0;
  }
  .stepper-label {
    font-size: 11px;
    text-align: left;
    margin-top: 0;
  }
  .stepper-line {
    display: none;
  }

  /* --- Filter bar --- */
  .filter-bar .form-input,
  .filter-bar .form-select {
    min-width: 100%;
  }

  /* --- Tabs --- */
  .tab-item {
    padding: 6px 10px;
    font-size: 10px;
  }

  /* --- Score bars --- */
  .score-bar {
    flex-wrap: wrap;
    gap: 4px;
  }
  .score-bar-label {
    min-width: 80px;
    font-size: 11px;
  }

  /* --- Spacing overrides --- */
  .space-y-8 > * + * { margin-top: 20px; }
  .space-y-6 > * + * { margin-top: 16px; }
  .mb-8 { margin-bottom: 20px; }
  .mb-6 { margin-bottom: 16px; }

  /* --- Accordion --- */
  .accordion-header {
    padding: 12px 14px;
    font-size: 12px;
  }

  /* --- Tag --- */
  .tag {
    font-size: 10px;
    padding: 3px 8px;
  }

  /* --- KPI sliders --- */
  input[type="range"][style*="width:150px"] {
    width: 80px !important;
  }

  /* --- Candidate actions in AI screening --- */
  [style*="padding:16px 24px"][style*="display:flex"][style*="gap:12px"] {
    flex-wrap: wrap !important;
    padding: 12px !important;
  }
}
