/*
 * BCT Training Matrix — Fluent UI Theme
 * Sky Blue (#0078D4) + Orange (#D04E00) palette, Microsoft Fluent Design System
 */

/* ─── DESIGN TOKENS ──────────────────────────────────────── */
:root {
  /* Brand: Fluent sky blue */
  --brand-dark:    #005A9E;
  --brand:         #0078D4;
  --brand-mid:     #106EBE;
  --brand-light:   #C7E0F4;
  --brand-xlight:  #EBF3FB;

  /* Accent: Fluent communication orange */
  --accent-dark:   #A33200;
  --accent:        #D04E00;
  --accent-light:  #F7D2B8;
  --accent-xlight: #FDF0E8;

  /* Status */
  --green:         #107C10;
  --green-light:   #DFF6DD;
  --amber:         #B46300;
  --amber-light:   #FFF4CE;
  --red:           #C50F1F;
  --red-light:     #FDE7E9;
  --grey-status:   #605E5C;
  --grey-light:    #F3F2F1;

  /* Neutrals — Fluent palette */
  --white:         #FFFFFF;
  --gray-10:       #FAF9F8;
  --gray-20:       #F3F2F1;
  --gray-30:       #EDEBE9;
  --gray-40:       #E1DFDD;
  --gray-50:       #C8C6C4;
  --gray-60:       #A19F9D;
  --gray-70:       #605E5C;
  --gray-80:       #323130;
  --gray-90:       #201F1E;
  --black:         #000000;

  /* Typography — Fluent uses Segoe UI */
  --font-ui:   'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Cascadia Code', 'Consolas', monospace;

  /* Spacing (4px grid) */
  --sp-2:  2px;
  --sp-4:  4px;
  --sp-6:  6px;
  --sp-8:  8px;
  --sp-12: 12px;
  --sp-16: 16px;
  --sp-20: 20px;
  --sp-24: 24px;
  --sp-32: 32px;
  --sp-40: 40px;

  /* Fluent radii — small and consistent */
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --radius-xl: 8px;

  /* Fluent shadows — very subtle depth */
  --shadow-2:  0 1px 2px rgba(0,0,0,.12), 0 0 2px rgba(0,0,0,.08);
  --shadow-4:  0 2px 4px rgba(0,0,0,.14), 0 0 2px rgba(0,0,0,.12);
  --shadow-8:  0 4px 8px rgba(0,0,0,.14), 0 0 2px rgba(0,0,0,.12);
  --shadow-16: 0 8px 16px rgba(0,0,0,.14), 0 0 2px rgba(0,0,0,.12);

  /* Transitions */
  --t-fast:   100ms ease;
  --t-mid:    200ms ease;
  --t-slow:   300ms ease;
}

/* ─── RESET & BASE ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }

body {
  font-family: var(--font-ui);
  background: var(--gray-10);
  color: var(--gray-80);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── APP HEADER ─────────────────────────────────────────── */
.app-header {
  background: var(--brand);
  color: var(--white);
  height: 48px;
  padding: 0 var(--sp-20);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-4);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
}

/* The BCT badge uses the orange accent */
.brand-badge {
  background: var(--accent);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
}

.brand-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--white);
  letter-spacing: -0.01em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
}

.db-status {
  font-size: 12px;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.92);
  padding: 4px 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  border: 1px solid rgba(255,255,255,0.2);
}

.db-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6BC72F;
}

/* ─── NAV TABS ───────────────────────────────────────────── */
.nav-tabs {
  background: var(--white);
  border-bottom: 1px solid var(--gray-40);
  display: flex;
  padding: 0 var(--sp-20);
  overflow-x: auto;
  scrollbar-width: none;
  box-shadow: var(--shadow-2);
}
.nav-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 0 var(--sp-16);
  height: 44px;
  border: none;
  background: none;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 400;
  color: var(--gray-70);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-6);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.tab-btn:hover {
  color: var(--gray-90);
  background: var(--gray-10);
}

.tab-btn.active {
  color: var(--brand);
  font-weight: 600;
  border-bottom-color: var(--brand);
}

/* ─── MAIN CONTENT ───────────────────────────────────────── */
.main {
  padding: var(--sp-20) var(--sp-24);
  max-width: 1920px;
  margin: 0 auto;
}

.page { display: none; }
.page.active { display: block; }

/* ─── PAGE HEADER ────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: var(--sp-12);
  margin-bottom: var(--sp-16);
}

.page-header .title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.page-header .section-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--gray-90);
  letter-spacing: -0.01em;
}

.page-header .section-sub {
  font-size: 13px;
  color: var(--gray-60);
  font-weight: 400;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  flex-wrap: wrap;
  flex: 1;
  justify-content: flex-end;
}

/* ─── STAT CARDS ─────────────────────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-12);
  margin-bottom: var(--sp-16);
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-40);
  border-radius: var(--radius-lg);
  padding: var(--sp-16);
  box-shadow: var(--shadow-2);
  cursor: pointer;
  transition: box-shadow var(--t-mid), border-color var(--t-mid);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  transition: background var(--t-mid);
}

.stat-card:hover {
  box-shadow: var(--shadow-8);
  border-color: var(--gray-50);
}

.stat-card.active-filter {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

.stat-card.green-card::after  { background: var(--green); }
.stat-card.amber-card::after  { background: var(--amber); }
.stat-card.red-card::after    { background: var(--red); }
.stat-card.blue-card::after   { background: var(--brand); }

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-60);
  margin-bottom: var(--sp-4);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-90);
  line-height: 1;
  margin-bottom: var(--sp-4);
}

.stat-sub {
  font-size: 12px;
  color: var(--gray-60);
}

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn {
  padding: 6px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--sp-6);
  white-space: nowrap;
  height: 32px;
}

.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.btn:active { opacity: 0.85; }

/* Primary — orange #ED7D31 */
.btn-primary {
  background: #ED7D31;
  color: var(--white);
  border-color: #C55A11;
}
.btn-primary:hover { background: #C55A11; border-color: #A33200; }

/* Success — orange for export buttons */
.btn-success {
  background: var(--accent);
  color: var(--white);
  border-color: var(--accent-dark);
}
.btn-success:hover { background: var(--accent-dark); }

/* Save — #4472C4 blue for Matrix Save Changes */
.btn-save {
  background: #4472C4;
  color: var(--white);
  border-color: #2F5496;
}
.btn-save:hover { background: #3660A8; border-color: #2F5496; }

/* Danger */
.btn-danger {
  background: var(--red);
  color: var(--white);
  border-color: #A4000E;
}
.btn-danger:hover { background: #A4000E; }

/* Ghost — Fluent "default" button style */
.btn-ghost {
  background: var(--white);
  color: var(--gray-80);
  border-color: var(--gray-50);
}
.btn-ghost:hover { background: var(--gray-20); border-color: var(--gray-60); }

.btn-sm {
  height: 28px;
  padding: 4px 12px;
  font-size: 12px;
}

/* ─── SEARCH & FILTERS ───────────────────────────────────── */
.search-wrap {
  position: relative;
  display: inline-block;
  min-width: 200px;
  flex: 1;
  max-width: 300px;
}

.search-icon {
  position: absolute;
  left: var(--sp-8);
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-60);
  font-size: 14px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 6px 12px 6px 32px;
  border: 1px solid var(--gray-50);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: 14px;
  background: var(--white);
  color: var(--gray-90);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  height: 32px;
}

.search-input:hover { border-color: var(--gray-70); }
.search-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

.filter-select {
  padding: 6px 32px 6px 12px;
  border: 1px solid var(--gray-50);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: 14px;
  background: var(--white);
  color: var(--gray-90);
  outline: none;
  cursor: pointer;
  height: 32px;
  width: 20%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  /* Modern custom dropdown arrow */
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23605E5C' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.filter-select:hover {
  border-color: var(--gray-70);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23201F1E' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.filter-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%230078D4' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ─── TABLES ─────────────────────────────────────────────── */
.table-wrap {
  background: var(--white);
  border: 1px solid var(--gray-40);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  overflow: auto;
  max-height: 70vh;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}

thead th {
  background: #4472C4;
  color: #D6E4F7;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 2px solid #2F5496;
  cursor: pointer;
  user-select: none;
}

thead th:hover { background: #3660A8; }

tbody tr {
  border-bottom: 1px solid var(--gray-30);
  transition: background var(--t-fast);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--gray-10); }
tbody tr:nth-child(even) { background: var(--gray-20); }
tbody tr:nth-child(even):hover { background: var(--gray-30); }

td {
  padding: 10px 14px;
  color: var(--gray-80);
  vertical-align: middle;
}

td.mono {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--gray-70);
}

td.actions { white-space: nowrap; }

.no-data {
  text-align: center;
  color: var(--gray-60);
  padding: 48px;
  font-style: italic;
}

/* ─── STATUS BADGES ──────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: var(--radius-xl);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  height: 22px;
  letter-spacing: 0.02em;
}

.badge-green  { background: var(--green-light);   color: var(--green); }
.badge-amber  { background: var(--amber-light);   color: var(--amber); }
.badge-orange { background: var(--accent-xlight); color: var(--accent); }
.badge-red    { background: var(--red-light);     color: var(--red); }
.badge-blue   { background: var(--brand-xlight);  color: var(--brand-dark); }
.badge-grey   { background: var(--gray-20);       color: var(--gray-70); }

/* ─── ROW STATUS TINTS ───────────────────────────────────── */
tbody tr.row-valid     { background: #F1FBF1; }
tbody tr.row-valid:hover { background: #E6F8E6; }
tbody tr.row-expiring  { background: var(--amber-light); }
tbody tr.row-expiring:hover { background: #FFF0BB; }
tbody tr.row-expired   { background: var(--red-light); }
tbody tr.row-expired:hover { background: #FBDBDE; }
tbody tr.row-notstarted { background: var(--gray-10); }
tbody tr.row-notstarted:hover { background: var(--gray-20); }

/* ─── SELECTED ROW HIGHLIGHT (matrix & records) ──────────── */
/* Matrix: selected job row */
.matrix-table tbody tr.row-selected .matrix-cell,
.matrix-table tbody tr.row-selected .job-col {
  background: #4472c424 !important;
}
.matrix-table tbody tr.row-selected .job-col {
  background: #ED7D31 !important;
  color: #fff !important;
}

/* Records: selected employee row */
.rec-grid tbody tr.row-selected .rg-data-cell,
.rec-grid tbody tr.row-selected .rg-not-required {
  background: #4472c424 !important;
}
.rec-grid tbody tr.row-selected .rg-emp-cell {
  background: #ED7D31 !important;
  color: #fff !important;
}
.rec-grid tbody tr.row-selected .rg-emp-cell strong { color: #fff !important; }
.rec-grid tbody tr.row-selected .rg-emp-cell span   { color: rgba(255,255,255,0.8) !important; }

/* ─── FORMS ──────────────────────────────────────────────── */
.form-grid {
  display: grid;
  gap: var(--sp-16);
}
.form-grid.single { grid-template-columns: 1fr; }
.form-grid.double { grid-template-columns: 1fr 1fr; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.form-group.span2 { grid-column: span 2; }

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-80);
  text-transform: none;
  letter-spacing: 0;
}

input[type=text],
input[type=date],
input[type=email],
input[type=number],
select,
textarea {
  padding: 6px 12px;
  border: 1px solid var(--gray-50);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: 14px;
  background: var(--white);
  color: var(--gray-90);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  width: 100%;
  height: 32px;
}

textarea { height: auto; min-height: 88px; resize: vertical; }

input:hover, select:hover, textarea:hover { border-color: var(--gray-70); }
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

.field-note  { font-size: 12px; color: var(--gray-60); margin-top: 2px; }
.required-mark { color: var(--red); margin-left: 2px; }

input[type=checkbox] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--brand);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
}

.checkbox-row label {
  font-size: 14px;
  font-weight: 400;
  color: var(--gray-80);
  cursor: pointer;
}

/* ─── MODALS ─────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: var(--sp-20);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-16);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: var(--sp-16) var(--sp-24);
  border-bottom: 1px solid var(--gray-30);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--brand-xlight);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-dark);
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--gray-60);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast), color var(--t-fast);
}
.modal-close:hover { background: var(--gray-30); color: var(--gray-90); }

.modal-body {
  padding: var(--sp-24);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: var(--sp-12) var(--sp-24);
  border-top: 1px solid var(--gray-30);
  display: flex;
  gap: var(--sp-8);
  justify-content: flex-end;
  background: var(--gray-10);
}

/* ─── INFO CARD ──────────────────────────────────────────── */
.info-card {
  background: var(--brand-xlight);
  border: 1px solid var(--brand-light);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius-md);
  padding: var(--sp-12) var(--sp-16);
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--brand-dark);
  line-height: 1.5;
}

.info-card strong {
  font-weight: 700;
  display: block;
  margin-bottom: var(--sp-4);
}

/* ─── PAGINATION ─────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-top: var(--sp-12);
  flex-wrap: wrap;
}

.page-btn {
  padding: 5px 12px;
  border: 1px solid var(--gray-40);
  border-radius: var(--radius-md);
  background: var(--white);
  font-family: var(--font-ui);
  font-size: 13px;
  cursor: pointer;
  color: var(--gray-70);
  height: 30px;
  transition: background var(--t-fast), border-color var(--t-fast);
}

.page-btn:hover { background: var(--gray-20); border-color: var(--gray-50); }
.page-btn.active { background: var(--brand); color: var(--white); border-color: var(--brand); }

.page-info {
  font-size: 13px;
  color: var(--gray-60);
  margin-left: auto;
}

/* ─── TOOLBAR ────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  margin-bottom: var(--sp-16);
  flex-wrap: wrap;
}

/* ─── MATRIX TABLE ───────────────────────────────────────── */
.matrix-wrap {
  overflow: auto;
  max-height: 70vh;
  border: 1px solid var(--gray-40);
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: var(--shadow-2);
}

.matrix-table {
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

/* Sticky top-left corner cell */
.matrix-table .corner-cell {
  background: #4472C4;
  color: #D6E4F7;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 10px;
  position: sticky;
  left: 0;
  top: 0;
  z-index: 4;
  min-width: 180px;
  width: 180px;
  border-right: 2px solid #2F5496;
  border-bottom: 3px solid #2F5496;
  border-top: none;
}

/* Course column headers — #ED7D31 orange, equal width, multiline */
.matrix-table .hdr-top {
  background: #ED7D31;
  color: #FFF0E6;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 6px;
  text-align: center;
  vertical-align: bottom;
  white-space: normal;
  word-break: break-word;
  width: 90px;
  min-width: 90px;
  max-width: 90px;
  position: sticky;
  top: 0;
  z-index: 3;
  border-bottom: 3px solid #C55A11;
  border-right: 1px solid #C55A11;
  border-top: none;
  line-height: 1.3;
}

/* Job name column — sticky left, #4472C4 blue */
.matrix-table .job-col {
  background: #4472C4;
  color: #D6E4F7;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  white-space: nowrap;
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 180px;
  width: 180px;
  border-right: 2px solid #2F5496;
  border-bottom: 1px solid #2F5496;
  border-top: none;
}

/* First data row — no top border so header bottom-shadow is the sole separator */
.matrix-table tbody tr:first-child .job-col,
.matrix-table tbody tr:first-child .matrix-cell {
  border-top: none;
}

.matrix-table .matrix-cell {
  text-align: center;
  padding: 4px;
  border-top: 1px solid var(--gray-30);
  border-right: 1px solid var(--gray-30);
  border-bottom: 1px solid var(--gray-30);
  border-left: none;
  width: 90px;
  min-width: 90px;
  background: var(--white);
}

.matrix-table .matrix-cell input[type=checkbox] {
  display: block;
  margin: auto;
  accent-color: var(--brand);
}

/* ─── RECORDS GRID ───────────────────────────────────────── */
.rec-grid-wrap {
  overflow: auto;
  max-height: 70vh;
  border: 1px solid var(--gray-40);
  border-radius: var(--radius-lg);
  background: var(--white);
  box-shadow: var(--shadow-2);
}

.rec-grid {
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

/* Sticky top-left corner */
.rec-grid .rg-corner {
  background: #4472C4;
  color: #D6E4F7;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 10px;
  position: sticky;
  left: 0;
  top: 0;
  z-index: 4;
  min-width: 220px;
  width: 220px;
  border-right: 2px solid #2F5496;
  border-bottom: 3px solid #2F5496;
  border-top: none;
}

/* Course column headers — #ED7D31 orange, equal width, multiline */
.rec-grid .rg-course-hdr {
  background: #ED7D31;
  color: #FFF0E6;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 6px;
  text-align: center;
  vertical-align: bottom;
  white-space: normal;
  word-break: break-word;
  width: 100px;
  min-width: 100px;
  max-width: 100px;
  position: sticky;
  top: 0;
  z-index: 3;
  border-bottom: 3px solid #C55A11;
  border-right: 1px solid #C55A11;
  border-top: none;
  line-height: 1.3;
}

/* Employee row header cells — #4472C4 blue */
.rec-grid .rg-emp-cell {
  background: #4472C4;
  color: #D6E4F7;
  font-size: 12px;
  padding: 6px 10px;
  white-space: nowrap;
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 220px;
  width: 220px;
  border-right: 2px solid #2F5496;
  border-bottom: 1px solid #2F5496;
  border-top: none;
}

/* First data row — no top border so header shadow is the sole separator */
.rec-grid tbody tr:first-child .rg-emp-cell,
.rec-grid tbody tr:first-child .rg-data-cell,
.rec-grid tbody tr:first-child .rg-not-required {
  border-top: none;
}

.rec-grid .rg-emp-cell strong { display: block; font-weight: 700; color: #D6E4F7; }
.rec-grid .rg-emp-cell span   { font-size: 11px; color: #BDD3F0; }

/* Data cells */
.rec-grid .rg-data-cell {
  font-size: 11px;
  text-align: center;
  padding: 4px 4px;
  border-top: 1px solid var(--gray-30);
  border-right: 1px solid var(--gray-30);
  border-bottom: 1px solid var(--gray-30);
  border-left: none;
  cursor: pointer;
  width: 100px;
  min-width: 100px;
  vertical-align: middle;
  background: var(--white);
}

.rec-grid .rg-data-cell:hover { opacity: 0.85; }

.rec-grid .rg-not-required {
  background: var(--gray-10);
  color: var(--gray-50);
  text-align: center;
  cursor: default;
  border-top: 1px solid var(--gray-30);
  border-right: 1px solid var(--gray-30);
  border-bottom: 1px solid var(--gray-30);
  border-left: none;
}

.rg-status-pill {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border-radius: 3px;
  margin-bottom: 2px;
  background: rgba(0,0,0,0.12);
  color: inherit;
}

.rg-dates { font-size: 10px; line-height: 1.4; }
.rg-comp  { color: inherit; opacity: 0.85; }
.rg-exp   { color: inherit; opacity: 0.7; font-style: italic; }

/* Cell status colours */
.rec-grid td.rg-valid      { background: var(--green-light);    color: var(--green); }
.rec-grid td.rg-expiring   { background: var(--amber-light);    color: var(--amber); }
.rec-grid td.rg-late       { background: var(--accent-xlight);  color: var(--accent-dark); }
.rec-grid td.rg-expired    { background: var(--red-light);      color: var(--red); }
.rec-grid td.rg-notstarted { background: var(--gray-20);        color: var(--gray-60); }

/* ─── TOASTS ─────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--sp-20);
  right: var(--sp-20);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
}

.toast {
  padding: var(--sp-12) var(--sp-16);
  border-radius: var(--radius-md);
  color: var(--white);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-8);
  min-width: 240px;
  animation: slideIn 0.2s ease;
  display: flex;
  align-items: center;
  gap: var(--sp-8);
}

.toast::before {
  font-size: 16px;
  flex-shrink: 0;
}

.toast.success { background: var(--green); }
.toast.success::before { content: '✓'; }
.toast.error   { background: var(--red); }
.toast.error::before { content: '✕'; }
.toast.info    { background: var(--brand); }
.toast.info::before { content: 'ℹ'; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  .main { padding: var(--sp-16); }
  .form-grid.double { grid-template-columns: 1fr; }
  .form-group.span2 { grid-column: 1; }
  .stats-bar { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

@media (max-width: 768px) {
  .app-header { height: 44px; padding: 0 var(--sp-16); }
  .brand-name { font-size: 14px; }
  .nav-tabs   { padding: 0 var(--sp-12); }
  .tab-btn    { padding: 0 var(--sp-12); font-size: 13px; }
  .main       { padding: var(--sp-12); }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-8);
  }

  .header-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .toolbar { flex-direction: column; align-items: stretch; }

  .search-wrap, .filter-select { width: 100%; max-width: none; }
  .stats-bar { grid-template-columns: 1fr 1fr; }

  .modal { margin: var(--sp-12); }
  .modal-body { padding: var(--sp-16); }
  .modal-footer { flex-direction: column; align-items: stretch; }
  .modal-footer > * { width: 100%; }
}

/* ─── PRINT ──────────────────────────────────────────────── */
@media print {
  .app-header, .nav-tabs, .toolbar, .pagination, .modal-overlay { display: none !important; }
  body { background: white; }
  .table-wrap, .stat-card { box-shadow: none; border: 1px solid var(--gray-40); }
}

#page-dashboard .table-wrap{
  max-height: 61vh
}
#page-employees .table-wrap,#page-courses .table-wrap, #page-jobs .table-wrap{
  max-height: 78vh
}
