/* ====================================================================
   Talent Hub Training Institute — CRM
   Design system

   Palette is taken from the THTI logo: deep navy, mid blue, bright
   cyan-blue, on a cool near-white ground. Nothing here loads from a
   CDN — shared hosting plus a slow connection at a branch office is
   exactly where external stylesheets fail.
   ==================================================================== */

:root {
  /* Brand — straight off the logo */
  --navy-900: #0C2E52;
  --navy-800: #12406F;
  --navy-700: #17497C;
  --brand-600: #1B5FA8;
  --brand-500: #2277C4;
  --accent-400: #2E9BE8;
  --accent-300: #5CB4EF;
  --accent-100: #D6EAFA;

  /* Neutrals, biased slightly blue so they sit with the brand */
  --ground: #F4F7FC;
  --surface: #FFFFFF;
  --surface-2: #EDF3FA;
  --surface-3: #E2EBF5;
  --line: #D4DFEC;
  --line-soft: #E6EDF6;

  --ink: #0F2340;
  --ink-2: #44587A;
  --ink-3: #6E819C;
  --ink-4: #93A3BA;

  /* Semantic — deliberately separate from the brand blue */
  --good: #16764F;
  --good-bg: #E3F3EC;
  --good-line: #A9DAC6;
  --warn: #8A5A0B;
  --warn-bg: #FBF0DA;
  --warn-line: #E9CE94;
  --risk: #9E2B28;
  --risk-bg: #FBE7E6;
  --risk-line: #EFB6B3;
  --info: #17497C;
  --info-bg: #E4EEF9;
  --info-line: #B3CFEA;

  --radius: 6px;
  --radius-sm: 4px;
  --radius-lg: 10px;

  --shadow-sm: 0 1px 2px rgba(15, 35, 64, .07);
  --shadow: 0 1px 3px rgba(15, 35, 64, .08), 0 6px 16px -8px rgba(15, 35, 64, .18);
  --shadow-lg: 0 2px 6px rgba(15, 35, 64, .10), 0 18px 40px -18px rgba(15, 35, 64, .35);

  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  --sidebar-w: 248px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

:focus-visible {
  outline: 2px solid var(--accent-400);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p  { margin: 0 0 .75rem; }

.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.mono  { font-family: var(--font-mono); }
.num   { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ====================================================================
   APP SHELL
   ==================================================================== */

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

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-800) 45%, #14456F 100%);
  color: #C9DEF2;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden; /* brand and search stay put; only .nav scrolls */
}

/* A thin brand bar the same height as the top bar, so the two line up. */
.brand {
  height: var(--topbar-h);
  padding: 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  flex: none;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand img { max-width: 150px; max-height: 40px; width: auto; height: auto; display: block; }

/* Menu search — fixed under the brand, MilesWeb-style. */
.nav-search {
  flex: none;
  position: relative;
  padding: 10px 12px;
}
.nav-search svg {
  position: absolute;
  left: 22px; top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: #6E97BE;
  pointer-events: none;
}
.nav-search input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  font-size: .82rem;
  color: #EAF2FB;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--radius-sm);
  outline: none;
}
.nav-search input::placeholder { color: #6E97BE; }
.nav-search input:focus { border-color: var(--accent-400); background: rgba(255, 255, 255, .12); }

/* Only the nav list scrolls, with a thin scrollbar that stays hidden
   until the pointer is over it. */
.nav {
  padding: 6px 10px 20px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.nav:hover { scrollbar-color: rgba(255, 255, 255, .28) transparent; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.nav:hover::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .25); }

/* Filtered-out items and any group heading left empty by the filter. */
.nav-item.is-hidden, .nav-group-label.is-hidden { display: none; }

.nav-group-label {
  font-size: .66rem;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: #6E97BE;
  padding: 14px 10px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  color: #C9DEF2;
  font-size: .88rem;
  margin-bottom: 1px;
  transition: background .13s ease, color .13s ease;
}

.nav-item:hover { background: rgba(255, 255, 255, .09); color: #fff; text-decoration: none; }

.nav-item.active {
  background: var(--brand-600);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent-400);
}

.nav-item .ico { width: 17px; height: 17px; flex: none; opacity: .9; }
.nav-item .badge-count {
  margin-left: auto;
  background: var(--accent-400);
  color: #06253F;
  font-size: .68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  flex: none;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title { font-weight: 650; font-size: 1rem; }
.topbar-spacer { flex: 1; }

.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  cursor: pointer;
  color: var(--ink-2);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px 5px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}

.user-chip:hover { background: var(--surface-2); }

.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand-600);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: .78rem;
  font-weight: 650;
  flex: none;
}

.user-meta { text-align: left; line-height: 1.15; }
.user-meta .nm { font-size: .82rem; font-weight: 600; }
.user-meta .rl { font-size: .69rem; color: var(--ink-3); }

.content { padding: 22px; flex: 1; }

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.page-head h1 { margin: 0; }
.page-head .sub { color: var(--ink-3); font-size: .9rem; margin-top: 3px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ====================================================================
   CARDS
   ==================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-head h3 { flex: 1; }
.card-body { padding: 18px; }
.card-foot {
  padding: 13px 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
  display: flex;
  gap: 8px;
  align-items: center;
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* KPI tile — the number leads, the label supports it */
.kpi { padding: 16px 18px; }
.kpi .label {
  font-size: .69rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.kpi .value {
  font-size: 1.75rem;
  font-weight: 680;
  letter-spacing: -.02em;
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi .delta { font-size: .8rem; margin-top: 3px; }
.kpi .delta.up { color: var(--good); }
.kpi .delta.down { color: var(--risk); }

/* ====================================================================
   BUTTONS
   ==================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.4;
  transition: background .13s ease, border-color .13s ease, color .13s ease;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-700); }

.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--ink-4); }

.btn-danger { background: var(--risk); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #872421; }

.btn-ghost { background: transparent; color: var(--brand-600); }
.btn-ghost:hover:not(:disabled) { background: var(--accent-100); }

.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-block { width: 100%; }

/* ====================================================================
   FORMS
   ==================================================================== */

.form-grid { display: grid; gap: 15px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.col-span-2 { grid-column: span 2; }
.field.col-span-full { grid-column: 1 / -1; }

label {
  font-size: .81rem;
  font-weight: 600;
  color: var(--ink-2);
}

label .req { color: var(--risk); margin-left: 2px; }

.input, .select, .textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-size: .89rem;
  color: var(--ink);
  transition: border-color .13s ease, box-shadow .13s ease;
}

.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-4); }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(46, 155, 232, .18);
}

.input:disabled, .input[readonly] {
  background: var(--surface-2);
  color: var(--ink-3);
  cursor: not-allowed;
}

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

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236E819C' stroke-width='1.6'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 15px;
  padding-right: 30px;
}

.hint { font-size: .76rem; color: var(--ink-3); }
.field-error { font-size: .78rem; color: var(--risk); font-weight: 500; }
.input.is-invalid, .select.is-invalid { border-color: var(--risk); }
.input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(158, 43, 40, .16); }

.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: .87rem;
  color: var(--ink-2);
  font-weight: 400;
  cursor: pointer;
}

.check input { margin-top: 3px; width: 15px; height: 15px; accent-color: var(--brand-600); flex: none; }

.input-group { display: flex; }
.input-group .input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ====================================================================
   TABLES
   ==================================================================== */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table.data { width: 100%; border-collapse: collapse; font-size: .87rem; }

table.data thead th {
  background: var(--surface-2);
  text-align: left;
  padding: 9px 14px;
  font-size: .69rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 700;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

table.data td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #F7FAFD; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

.empty { padding: 44px 20px; text-align: center; color: var(--ink-3); }
.empty .big { font-size: .98rem; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }

/* ====================================================================
   BADGES & ALERTS
   ==================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 650;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-good { background: var(--good-bg); color: var(--good); border-color: var(--good-line); }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.badge-risk { background: var(--risk-bg); color: var(--risk); border-color: var(--risk-line); }
.badge-info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.badge-mute { background: var(--surface-3); color: var(--ink-2); border-color: var(--line); }

.alert {
  display: flex;
  gap: 11px;
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: .88rem;
  margin-bottom: 16px;
  align-items: flex-start;
}

.alert-good { background: var(--good-bg); border-color: var(--good-line); color: #0E5637; }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-line); color: #6D4708; }
.alert-risk { background: var(--risk-bg); border-color: var(--risk-line); color: #7E211F; }
.alert-info { background: var(--info-bg); border-color: var(--info-line); color: var(--navy-800); }

.alert strong { display: block; margin-bottom: 2px; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* ====================================================================
   AUTH PAGES
   ==================================================================== */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 12% -8%, rgba(46, 155, 232, .16), transparent 62%),
    radial-gradient(900px 480px at 92% 108%, rgba(27, 95, 168, .14), transparent 60%),
    var(--ground);
}

.auth-card {
  width: 100%;
  max-width: 412px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.auth-head {
  padding: 28px 30px 18px;
  text-align: center;
  background: #fff;
  border-bottom: 1px solid var(--line-soft);
}

.auth-head img {
  width: auto; max-width: 250px; height: auto;
  display: block; margin: 0 auto 14px;
}

.auth-head h1 { font-size: 1.1rem; color: var(--ink); }
.auth-head .sub { font-size: .8rem; color: var(--ink-3); margin-top: 4px; }

.auth-body { padding: 26px 30px 30px; }
.auth-body .field + .field { margin-top: 15px; }
.auth-body .btn { margin-top: 20px; }

.auth-foot {
  padding: 14px 30px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  text-align: center;
  font-size: .82rem;
  color: var(--ink-3);
}

.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 40px; }
.pw-toggle {
  position: absolute;
  right: 4px; top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--ink-3);
  border-radius: var(--radius-sm);
}
.pw-toggle:hover { color: var(--ink); background: var(--surface-2); }

/* Password strength meter */
.pw-meter { display: flex; gap: 4px; margin-top: 7px; }
.pw-meter i {
  height: 3px;
  flex: 1;
  background: var(--surface-3);
  border-radius: 2px;
  transition: background .2s ease;
}
.pw-meter.s1 i:nth-child(1) { background: var(--risk); }
.pw-meter.s2 i:nth-child(-n+2) { background: #C97B12; }
.pw-meter.s3 i:nth-child(-n+3) { background: #B08808; }
.pw-meter.s4 i { background: var(--good); }

/* ====================================================================
   HOVER CARDS

   A panel that explains the cell it is anchored to — the installment
   badge on the course catalogue is the first of them.

   It is positioned fixed and moved to the end of <body> by app.js,
   because the thing it usually hangs off sits inside .table-wrap, and an
   element that scrolls its own overflow clips anything that tries to
   escape it.
   ==================================================================== */

.hovercard {
  position: fixed;
  z-index: 60;
  width: 310px;
  max-width: calc(100vw - 16px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 14px;
  font-size: .82rem;
  color: var(--ink-2);
  line-height: 1.45;
}
.hovercard[hidden] { display: none; }

.hovercard .hc-title {
  font-size: .7rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 700;
  margin-bottom: 8px;
}

.hovercard table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.hovercard table td { padding: 4px 0; vertical-align: top; }
.hovercard table td + td { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 10px; }
.hovercard table tr + tr td { border-top: 1px solid var(--line-soft); }
.hovercard table tr.hc-total td {
  border-top: 1px solid var(--line);
  font-weight: 700;
  color: var(--ink);
  padding-top: 7px;
}
.hovercard .hc-foot { margin-top: 9px; font-size: .75rem; color: var(--ink-3); }

/* The trigger. Dotted underline so it is visibly worth pointing at. */
.has-hovercard { cursor: help; }
.has-hovercard:focus-visible { outline: 2px solid var(--accent-400); outline-offset: 2px; }

/* ====================================================================
   MODAL
   ==================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(12, 46, 82, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 14px;
  overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h3 { flex: 1; margin: 0; font-size: 1rem; }
.modal-head .sub { font-size: .82rem; color: var(--ink-3); margin-top: 3px; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--ink-3);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--surface-2); color: var(--ink); }

.modal-body { padding: 18px; }
.modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ====================================================================
   DETAIL SCREENS — label/value pairs
   ==================================================================== */

.detail-list { display: grid; gap: 0; }
.detail-list .row {
  display: flex;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: .87rem;
}
.detail-list .row:last-child { border-bottom: none; }
.detail-list .row .k { color: var(--ink-3); flex: 0 0 42%; }
.detail-list .row .v { flex: 1; min-width: 0; color: var(--ink); font-weight: 550; }

/* ====================================================================
   RESPONSIVE
   ==================================================================== */

@media (max-width: 980px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .content { padding: 16px; }
  .scrim {
    position: fixed;
    inset: 0;
    background: rgba(12, 46, 82, .45);
    z-index: 35;
  }
}

@media (max-width: 560px) {
  .field.col-span-2 { grid-column: span 1; }
  .user-meta { display: none; }
  .topbar { padding: 0 14px; }
  /* The page heading repeats the title, so drop it here and give the
     search box the room on a phone. */
  .topbar-title { display: none; }
  .topbar-search { max-width: none !important; margin: 0 8px !important; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ====================================================================
   PRINT — receipts and invoices get their own stylesheet, this just
   keeps accidental prints of admin screens from wasting paper.
   ==================================================================== */

@media print {
  .sidebar, .topbar, .page-head .actions, .btn { display: none !important; }
  body { background: #fff; }
  .card { border: 1px solid #999; box-shadow: none; }
}
