/* ============================================================
   LoanLabor Demo — Styles
   Matches real app: Bootstrap 5 + Font Awesome + LL design system
   ============================================================ */

:root {
  --primary: #0052CC;
  --primary-dark: #0747A6;
  --primary-light: #DEEBFF;
  --secondary: #00A3BF;
  --success: #00875A;
  --warning: #FF991F;
  --danger: #DE350B;
  --purple: #6554C0;
  --bg: #F4F5F7;
  --bg-card: #FFFFFF;
  --text: #172B4D;
  --text-muted: #6B778C;
  --border: #DFE1E6;
  --shadow: 0 1px 3px rgba(23,43,77,.12), 0 2px 8px rgba(23,43,77,.08);
  --radius: 6px;
  --sidebar-w: 240px;
  /* --topbar-h is the total chrome offset from viewport top to start of content.
     Kept as a CSS var so all downstream `top` / `margin-top` / `calc(100vh - ...)` math
     references one source of truth. */
  --topbar-h: 60px;
  --topbar-bar-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }

/* ── Layout ─────────────────────────────────────────────────── */

#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-bar-h);
  background: linear-gradient(135deg, #0052CC 0%, #0747A6 100%);
  display: flex; align-items: center; padding: 0 20px;
  z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

#topbar .brand {
  display: flex; align-items: center; gap: 10px;
  color: #fff; font-weight: 700; font-size: 18px;
  flex-shrink: 0; width: var(--sidebar-w);
}

#topbar .brand i { font-size: 20px; color: #7FC6FF; }

#topbar .top-search {
  flex: 1; max-width: 400px; margin-left: 20px;
}

#topbar .top-search input {
  width: 100%; padding: 6px 14px 6px 36px;
  border: none; border-radius: 20px;
  background: rgba(255,255,255,.15); color: #fff;
  font-size: 13px;
}

#topbar .top-search input::placeholder { color: rgba(255,255,255,.6); }
#topbar .top-search { position: relative; }
#topbar .top-search i {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: rgba(255,255,255,.6); font-size: 12px;
}

#topbar .top-actions {
  display: flex; align-items: center; gap: 6px; margin-left: auto;
}

.top-btn {
  position: relative; background: none; border: none;
  color: rgba(255,255,255,.85); padding: 8px; border-radius: 6px;
  font-size: 16px; transition: background .15s;
}
.top-btn:hover { background: rgba(255,255,255,.15); color: #fff; }

.top-badge {
  position: absolute; top: 2px; right: 2px;
  background: #DE350B; color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
  padding: 2px 5px; border-radius: 10px; min-width: 16px; text-align: center;
}

.top-user {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none; color: #fff;
  padding: 4px 10px; border-radius: 20px; cursor: pointer;
  transition: background .15s;
}
.top-user:hover { background: rgba(255,255,255,.15); }

.avatar-sm {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #7FC6FF, #DEEBFF);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; color: #0052CC;
  flex-shrink: 0;
}

.avatar-md {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, #7FC6FF, #DEEBFF);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: #0052CC;
  flex-shrink: 0;
}

.avatar-lg {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, #7FC6FF, #DEEBFF);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 24px; color: #0052CC;
  flex-shrink: 0;
}

#sidebar {
  position: fixed; left: 0; top: var(--topbar-h); bottom: 0;
  width: var(--sidebar-w); background: #fff;
  border-right: 1px solid var(--border);
  overflow-y: auto; padding: 12px 0;
  z-index: 90;
}

.nav-section-label {
  padding: 8px 20px 4px;
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  color: var(--text-muted); text-transform: uppercase;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; color: #42526E;
  font-size: 14px; font-weight: 500;
  border-radius: 0; transition: all .15s;
  cursor: pointer; border: none; background: none;
  width: 100%; text-align: left;
}

.nav-item i { width: 18px; text-align: center; font-size: 14px; }

.nav-item:hover { background: var(--bg); color: var(--primary); }

.nav-item.active {
  background: var(--primary-light); color: var(--primary);
  font-weight: 600; border-left: 3px solid var(--primary);
}

.nav-badge-item {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; padding: 1px 6px;
  border-radius: 10px; min-width: 18px; text-align: center;
}

.nav-divider { height: 1px; background: var(--border); margin: 8px 16px; }

#main {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 28px;
  min-height: calc(100vh - var(--topbar-h));
}

/* ── PWA install banner ─────────────────────────────────────── */
#pwa-install-banner {
  display: none;
  position: fixed; top: var(--topbar-bar-h); left: 0; right: 0;
  height: 44px; z-index: 99;
  background: var(--primary-dark);
  color: #fff;
  align-items: center; gap: 10px;
  padding: 0 16px 0 20px;
  font-size: 13px;
}
#pwa-install-banner.visible { display: flex; }
#pwa-install-banner > i { font-size: 15px; opacity: .85; flex-shrink: 0; }
#pwa-install-banner > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#pwa-install-btn {
  background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.4);
  color: #fff; border-radius: var(--radius); padding: 4px 14px;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}
#pwa-install-btn:hover { background: rgba(255,255,255,.32); }
#pwa-dismiss-btn {
  background: none; border: none; color: rgba(255,255,255,.65);
  font-size: 20px; line-height: 1; padding: 4px 8px 4px 4px; flex-shrink: 0;
}
#pwa-dismiss-btn:hover { color: #fff; }

/* Shift all --topbar-h consumers down by the banner height (44px). */
body.has-install-banner { --topbar-h: 104px; }

/* ── Cards ──────────────────────────────────────────────────── */

.card {
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 15px; display: flex;
  align-items: center; justify-content: space-between;
}

.card-body { padding: 20px; }

/* ── KPI Cards ─────────────────────────────────────────────── */

.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-bottom: 24px;
}

/* 4-stat summary rows used by Jobs and Activity pages */
.stat-grid-4 {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  padding: 20px; display: flex; align-items: flex-start; gap: 16px;
  cursor: pointer; transition: box-shadow .2s;
}
.kpi-card:hover { box-shadow: 0 4px 16px rgba(23,43,77,.15); }

.kpi-icon {
  width: 48px; height: 48px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}

.kpi-data { flex: 1; }
.kpi-value { font-size: 28px; font-weight: 700; line-height: 1; color: var(--text); }
.kpi-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.kpi-delta { font-size: 12px; margin-top: 6px; font-weight: 500; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }

/* ── Page Header ─────────────────────────────────────────────── */

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}

.page-title { font-size: 22px; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Buttons ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; border: none;
  transition: all .15s; cursor: pointer;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #006644; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #BF2600; }

.btn-outline {
  background: transparent; color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn:disabled,
.btn[disabled] {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: auto; /* keep title= tooltips reachable */
}
.btn:disabled:hover,
.btn[disabled]:hover { background: inherit; color: inherit; }

/* ── Accessibility ──────────────────────────────────────────── */

/* Skip-to-main-content link (only visible when focused) */
.skip-link {
  position: absolute;
  top: -40px;
  left: 8px;
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  z-index: 99999;
  transition: top .15s;
}
.skip-link:focus {
  top: 8px;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Visible focus ring for keyboard users on clickable divs and tab targets */
[role="button"]:focus-visible,
.kpi-card:focus-visible,
.activity-item:focus-visible,
.convo-item:focus-visible,
.job-card:focus-visible,
.notif-item:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Badges / Status ─────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 600;
}

.badge-success { background: #E3FCEF; color: #006644; }
.badge-warning { background: #FFFAE6; color: #974F0C; }
.badge-danger  { background: #FFEBE6; color: #BF2600; }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-muted   { background: #EBECF0; color: #42526E; }
.badge-purple  { background: #EAE6FF; color: #403294; }

/* ── Tables ──────────────────────────────────────────────────── */

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 10px 16px;
  font-size: 11px; font-weight: 600; letter-spacing: .04em;
  color: var(--text-muted); text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.data-table td {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg); }

/* ── Forms ───────────────────────────────────────────────────── */

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-control {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13px; font-family: inherit;
  color: var(--text); background: #fff; transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0,82,204,.15); }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Modal ───────────────────────────────────────────────────── */

.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(23,43,77,.5); z-index: 1000;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: #fff; border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,.25);
  width: 100%; max-width: 580px;
  max-height: 90vh; overflow-y: auto;
  animation: modalIn .2s ease;
}

.modal-box.modal-lg { max-width: 760px; }

@keyframes modalIn {
  from { transform: translateY(-20px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

.modal-header {
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 17px; font-weight: 700;
}

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}

.modal-close {
  background: none; border: none; font-size: 20px;
  color: var(--text-muted); line-height: 1; cursor: pointer;
}
.modal-close:hover { color: var(--text); }

/* ── Tabs ────────────────────────────────────────────────────── */

.tab-bar {
  display: flex; border-bottom: 2px solid var(--border);
  margin-bottom: 20px; gap: 0;
}

.tab-btn {
  padding: 10px 20px; background: none; border: none;
  font-size: 14px; font-weight: 500; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  cursor: pointer; transition: all .15s;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ── Worker Card ─────────────────────────────────────────────── */

.worker-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.worker-card {
  background: #fff; border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  padding: 20px; cursor: pointer; transition: box-shadow .2s;
}
.worker-card:hover { box-shadow: 0 4px 16px rgba(23,43,77,.15); }

.worker-card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.worker-name { font-weight: 700; font-size: 15px; }
.worker-trade { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

.worker-certs { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 14px; }
.cert-tag {
  padding: 2px 7px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 4px;
  font-size: 11px; color: var(--text-muted);
}

.worker-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 12px; border-top: 1px solid var(--border);
}

.worker-rate { font-size: 15px; font-weight: 700; color: var(--text); }
.worker-actions { display: flex; gap: 6px; }

/* ── Activity Feed ───────────────────────────────────────────── */

.activity-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 6px; border-bottom: 1px solid var(--border);
  margin: 0 -6px; cursor: pointer; transition: background .15s; border-radius: 4px;
}
.activity-item:hover { background: var(--bg); }
.activity-item:last-child { border-bottom: none; }

.activity-icon {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-light); display: flex;
  align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}

.activity-text { flex: 1; font-size: 13px; line-height: 1.5; }
.activity-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── Messages ────────────────────────────────────────────────── */

.messages-layout { display: flex; gap: 0; height: calc(100vh - var(--topbar-h) - 80px); min-height: 500px; }

.convo-list {
  width: 300px; flex-shrink: 0; border-right: 1px solid var(--border);
  background: #fff; overflow-y: auto; border-radius: var(--radius) 0 0 var(--radius);
}

.convo-item {
  display: flex; gap: 12px; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .15s;
}
.convo-item:hover { background: var(--bg); }
.convo-item.active { background: var(--primary-light); }

.convo-info { flex: 1; min-width: 0; }
.convo-name { font-weight: 600; font-size: 14px; }
.convo-preview { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.convo-time { font-size: 11px; color: var(--text-muted); }
.convo-unread { background: var(--primary); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 1px 6px; min-width: 18px; text-align: center; }

.chat-pane {
  flex: 1; display: flex; flex-direction: column;
  background: #fff; border-radius: 0 var(--radius) var(--radius) 0;
}

.chat-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}

.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }

.msg { max-width: 70%; }
.msg.me { align-self: flex-end; }
.msg.them { align-self: flex-start; }

.msg-bubble {
  padding: 10px 14px; border-radius: 14px; font-size: 13px; line-height: 1.5;
}
.msg.me .msg-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.them .msg-bubble { background: var(--bg); color: var(--text); border-bottom-left-radius: 4px; }

.msg-time { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.msg.me .msg-time { text-align: right; }

.chat-input-area {
  padding: 16px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 10px;
}
.chat-input-area input {
  flex: 1; padding: 9px 14px; border: 1px solid var(--border);
  border-radius: 20px; font-size: 13px; outline: none;
}
.chat-input-area input:focus { border-color: var(--primary); }

/* ── Notification Dropdown ───────────────────────────────────── */

.notif-dropdown {
  display: none; position: absolute; right: 10px; top: calc(var(--topbar-h) + 4px);
  width: 360px; background: #fff; border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,.2); z-index: 200;
  border: 1px solid var(--border);
}
.notif-dropdown.open { display: block; }
.notif-header { padding: 14px 16px; font-weight: 700; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.notif-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .15s; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: #F0F7FF; }
.notif-icon { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.notif-text { font-size: 13px; flex: 1; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── Filter Bar ──────────────────────────────────────────────── */

.filter-bar {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 20px; flex-wrap: wrap;
}
.filter-bar input, .filter-bar select {
  padding: 7px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; background: #fff; color: var(--text);
}
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--primary); }

/* ── Job Cards ───────────────────────────────────────────────── */

.job-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

.job-card {
  background: #fff; border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  padding: 20px; cursor: pointer; transition: box-shadow .2s;
}
.job-card:hover { box-shadow: 0 4px 16px rgba(23,43,77,.15); }
.job-card-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.job-card-company { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.job-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }
.job-meta i { margin-right: 3px; }
.job-footer { display: flex; align-items: center; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--border); }

/* ── Profile ─────────────────────────────────────────────────── */

.profile-header-card {
  background: linear-gradient(135deg, #0052CC 0%, #0747A6 100%);
  border-radius: var(--radius); padding: 32px;
  display: flex; align-items: center; gap: 24px;
  margin-bottom: 24px; color: #fff;
}

.profile-name { font-size: 24px; font-weight: 700; }
.profile-title-text { font-size: 14px; opacity: .85; margin-top: 4px; }
.profile-company { font-size: 15px; opacity: .9; margin-top: 8px; font-weight: 500; }

/* ── Settings Tabs ───────────────────────────────────────────── */

.settings-layout { display: flex; gap: 24px; }
.settings-sidebar { width: 200px; flex-shrink: 0; }
.settings-content { flex: 1; }

.settings-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-radius: var(--radius);
  font-size: 14px; color: var(--text-muted);
  cursor: pointer; transition: all .15s; border: none; background: none;
  width: 100%; text-align: left;
}
.settings-nav-item:hover { background: var(--bg); color: var(--text); }
.settings-nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

/* ── Profile completeness meter (Endowed Progress Effect) ────── */
.profile-meter-bar {
  padding: 16px 20px;
}

/* ── Save-flash microinteraction (NNGroup: immediate feedback) ── */
.save-flash {
  background: var(--success) !important;
  border-color: var(--success) !important;
  color: #fff !important;
  transition: background .2s, border-color .2s;
}
@keyframes saveFlash {
  0%   { transform: scale(1.04); }
  40%  { transform: scale(1); }
  100% { transform: scale(1); }
}
.save-flash { animation: saveFlash .3s ease; }

/* ── Misc ────────────────────────────────────────────────────── */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-primary { color: var(--primary) !important; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }

.online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--success); margin-right: 4px; }
.offline-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--border); margin-right: 4px; }

.info-row { display: flex; gap: 8px; font-size: 13px; margin-bottom: 8px; }
.info-row i { color: var(--text-muted); width: 16px; text-align: center; margin-top: 1px; flex-shrink: 0; }

/* -- Demo pill + Coming-Soon Toast --------------------------- */
.demo-pill {
  display: inline-flex; align-items: center;
  background: linear-gradient(135deg,#FF991F,#DE350B);
  color: #fff; font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 10px;
  letter-spacing: .08em; margin-left: 8px;
  vertical-align: middle;
  box-shadow: 0 2px 6px rgba(222,53,11,.3);
  cursor: help;
  text-transform: uppercase;
}
.demo-pill i { margin-right: 4px; font-size: 9px; }

.cs-toast { position: fixed; bottom: 24px; right: 24px; z-index: 99999; background: #fff; border: 1px solid var(--border); border-left: 5px solid var(--warning); border-radius: 10px; padding: 14px 18px; display: flex; align-items: center; gap: 14px; min-width: 320px; max-width: 420px; box-shadow: 0 10px 32px rgba(9,30,66,.18); transform: translateX(450px); opacity: 0; transition: transform .3s cubic-bezier(.4,0,.2,1), opacity .3s; pointer-events: none; }
.cs-toast.show { transform: translateX(0); opacity: 1; pointer-events: auto; }
.cs-toast-icon { width: 38px; height: 38px; background: linear-gradient(135deg,#FFFAE6,#FFF0B3); color: #974F0C; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.cs-toast-title { font-weight: 700; font-size: 14px; color: var(--text); margin-bottom: 2px; }
.cs-toast-sub { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.cs-toast-close { background: none; border: none; font-size: 22px; line-height: 1; color: var(--text-muted); cursor: pointer; padding: 0 4px; align-self: flex-start; transition: color .15s; }
.cs-toast-close:hover { color: var(--text); }

/* ── Phase 2: Magic Pass ─────────────────────────────────────── */

/* Card hover elevation */
.card { transition: box-shadow .18s ease; }

/* KPI pop-in */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.kpi-card { animation: fadeInUp .4s ease both; }
.kpi-card:nth-child(1) { animation-delay: .00s; }
.kpi-card:nth-child(2) { animation-delay: .07s; }
.kpi-card:nth-child(3) { animation-delay: .14s; }
.kpi-card:nth-child(4) { animation-delay: .21s; }

/* Form focus glow — enhance existing rule */
.form-control:focus {
  box-shadow: 0 0 0 3px rgba(0,82,204,.15) !important;
}

/* Bell hover ring */
@keyframes bellRing {
  0%,100%{ transform: rotate(0); }
  25%    { transform: rotate(-14deg); }
  50%    { transform: rotate(14deg); }
  75%    { transform: rotate(-7deg); }
}
.top-btn:hover .fa-bell { animation: bellRing .45s ease; }

/* Brand is clickable */
.brand { cursor: pointer; user-select: none; }

/* Avatar photos — circular real headshots */
.avatar-photo {
  border-radius: 50%; object-fit: cover;
  border: 2px solid var(--border); background: var(--bg);
  display: block; flex-shrink: 0;
}
.avatar-photo.lg { width: 60px; height: 60px; }
.avatar-photo.md { width: 40px; height: 40px; }
.avatar-photo.sm { width: 30px; height: 30px; }
.avatar-photo.xs { width: 22px; height: 22px; border-width: 1.5px; }

/* Loan progress bar */
.loan-progress { height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; margin-top: 4px; min-width: 60px; }
.loan-progress-fill { height: 100%; border-radius: 2px; background: var(--primary); transition: width .6s ease; }

/* Company / project image chips */
.company-thumb {
  width: 100%; height: 120px; object-fit: cover;
  border-radius: var(--radius) var(--radius) 0 0;
  display: block;
}
.company-thumb-sm {
  width: 36px; height: 36px; object-fit: cover;
  border-radius: 4px; flex-shrink: 0;
}

/* ── Worker headshot hover tooltip ───────────────────────────── */
.worker-card { position: relative; }

.worker-photo-tooltip {
  position: absolute;
  top: -110px; left: 50%; transform: translateX(-50%);
  width: 90px; height: 90px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(9,30,66,.22);
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease, top .18s ease;
  z-index: 50;
  background: var(--bg);
}
.worker-photo-tooltip img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.worker-card:hover .worker-photo-tooltip {
  opacity: 1;
  top: -118px;
}

/* ── Hamburger ───────────────────────────────────────────────── */
.hamburger {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: 8px; flex-direction: column; gap: 5px;
  margin-right: 4px; flex-shrink: 0;
}
.hamburger span {
  display: block; width: 20px; height: 2px;
  background: rgba(255,255,255,.9); border-radius: 1px;
  transition: transform .2s ease, opacity .2s ease;
}

/* Sidebar backdrop */
#sidebarBackdrop {
  display: none; position: fixed; inset: 0;
  z-index: 199; background: rgba(9,30,66,.4);
  backdrop-filter: blur(1px);
}
#sidebarBackdrop.visible { display: block; }

/* ══════════════════════════════════════════════════════════════
   MOBILE — Phase 1 (critical) + Phase 2 (nav/sticky) + Phase 3 (polish)
   ════════════════════════════════════════════════════════════════ */

/* ── Bottom Tab Bar (shown only on mobile) ──────────────────── */
#bottomNav { display: none; }

@media (max-width: 768px) {
  #bottomNav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(9,30,66,.08);
    z-index: 150;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bn-item {
    background: none; border: none;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 8px 4px 6px;
    color: var(--text-muted); font-size: 10px; font-weight: 600;
    min-height: 56px; position: relative;
    transition: color .15s;
  }
  .bn-item i { font-size: 18px; }
  .bn-item.active { color: var(--primary); }
  .bn-item.active::before {
    content: ''; position: absolute; top: 0; left: 50%;
    transform: translateX(-50%);
    width: 32px; height: 3px; border-radius: 0 0 3px 3px;
    background: var(--primary);
  }
  .bn-item .bn-badge {
    position: absolute; top: 4px; right: calc(50% - 18px);
    background: var(--danger); color: #fff;
    font-size: 9px; font-weight: 700; line-height: 1;
    padding: 2px 5px; border-radius: 10px; min-width: 14px; text-align: center;
  }
}

/* ── Phase 1: critical fixes ────────────────────────────────── */
@media (max-width: 768px) {
  /* PWA install banner: hide text on very small screens to keep buttons visible */
  #pwa-install-banner > span { display: none; }

  /* Sidebar slide-in (was here before) */
  #sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 200;
    box-shadow: 4px 0 20px rgba(0,0,0,.15);
  }
  #sidebar.open { transform: translateX(0); }

  /* Layout */
  #main {
    margin-left: 0 !important;
    padding: 16px 14px 84px 14px !important; /* leave room for bottom nav + safe area */
    padding-bottom: calc(84px + env(safe-area-inset-bottom)) !important;
  }

  /* Top bar — brand width unlocked, user label hidden on phones */
  #topbar { padding: 0 10px; padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  #topbar .brand {
    width: auto !important;
    font-size: 16px !important;
    gap: 8px !important;
    margin-right: auto;
  }
  .demo-pill { padding: 2px 6px !important; font-size: 9px !important; margin-left: 4px !important; }
  .top-search { display: none !important; }
  .top-user span,
  .top-user .fa-chevron-down { display: none !important; }
  .top-user { padding: 4px !important; }
  .top-actions { gap: 2px !important; }

  /* Notification dropdown sized to viewport */
  .notif-dropdown {
    right: 8px !important; left: 8px !important;
    width: auto !important;
    max-height: calc(100vh - var(--topbar-h) - 24px);
    overflow-y: auto;
  }

  /* Inputs: prevent iOS auto-zoom (must be ≥16px) */
  input, select, textarea, .form-control, .chat-input-area input,
  #topbar .top-search input, .filter-bar input, .filter-bar select {
    font-size: 16px !important;
  }

  /* Tap targets — minimum 44×44 for icon-only buttons */
  .top-btn, .modal-close, .hamburger { min-width: 44px; min-height: 44px; }
  .top-btn { padding: 12px !important; }
  .modal-close { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .chat-input-area .btn { min-width: 44px; min-height: 44px; padding: 10px 12px; }

  /* KPI grid: tighten */
  .kpi-grid { grid-template-columns: repeat(2,1fr) !important; gap: 10px !important; margin-bottom: 16px !important; }
  .kpi-card { padding: 14px !important; gap: 10px !important; }
  .kpi-icon { width: 38px !important; height: 38px !important; font-size: 16px !important; }
  .kpi-value { font-size: 22px !important; }
  .kpi-label { font-size: 11px !important; }
  .kpi-delta { font-size: 11px !important; }

  /* 4-stat summary rows (Jobs, Activity) collapse to 2×2 */
  .stat-grid-4 { grid-template-columns: repeat(2,1fr) !important; gap: 10px !important; margin-bottom: 16px !important; }

  /* Card defaults */
  .card-body { padding: 14px !important; }
  .card-header { padding: 12px 14px !important; font-size: 14px !important; }

  /* Page header — stacked, action button full-width chip */
  .page-header {
    flex-direction: column; align-items: stretch !important;
    gap: 10px; margin-bottom: 16px !important;
  }
  .page-header > div:first-child { width: 100%; }
  .page-header > div:last-child,
  .page-header > button:last-child { display: flex; gap: 8px; flex-wrap: wrap; }
  .page-header .btn { flex: 1; justify-content: center; min-height: 44px; }
  .page-title { font-size: 20px !important; }

  /* Modal — full-width, sit above bottom nav */
  #modalBox {
    width: calc(100vw - 16px) !important;
    max-height: calc(100dvh - 80px) !important;
    overflow-y: auto;
    margin-bottom: env(safe-area-inset-bottom);
  }
  .modal-overlay { padding: 8px !important; align-items: flex-end !important; }
  @keyframes modalIn { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
  .modal-box { animation: modalIn .25s cubic-bezier(.2,.8,.3,1) !important; border-radius: 14px 14px 8px 8px !important; }
  .modal-footer { padding: 12px 16px !important; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; min-height: 44px; justify-content: center; }

  /* Grid de-stacking (kept from previous mobile block) */
  [style*="grid-template-columns:1fr 340px"],
  [style*="grid-template-columns: 1fr 340px"] { display: block !important; }
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; gap: 12px !important; }
  [style*="grid-template-columns:repeat(4,1fr)"],
  [style*="grid-template-columns: repeat(4,1fr)"],
  [style*="grid-template-columns:repeat(4, 1fr)"] { grid-template-columns: repeat(2,1fr) !important; gap: 10px !important; }
  [style*="grid-template-columns:1fr 1fr 1fr"],
  [style*="grid-template-columns: repeat(3,1fr)"] { grid-template-columns: 1fr !important; }

  /* Utility grids — collapse to single column (used in form modals on all pages) */
  .grid-2 { grid-template-columns: 1fr !important; gap: 12px !important; }
  .grid-3 { grid-template-columns: 1fr !important; gap: 12px !important; }

  /* Page-level grids */
  .worker-grid { grid-template-columns: 1fr !important; gap: 12px; }
  .job-grid { grid-template-columns: 1fr !important; gap: 12px; }
  .settings-layout { flex-direction: column !important; gap: 14px !important; }
  .settings-sidebar { width: 100% !important; }
  .profile-header-card { flex-wrap: wrap; padding: 20px !important; gap: 14px !important; text-align: center; }
  .profile-header-card > * { width: 100%; }
  .profile-header-card .avatar-lg { margin: 0 auto; }
  .profile-name { font-size: 20px !important; }

  /* Worker hover tooltip disabled (touch) */
  .worker-photo-tooltip { display: none; }

  /* Hamburger */
  .hamburger { display: flex !important; }

  /* Toast — above bottom nav, full-width */
  .cs-toast {
    bottom: calc(76px + env(safe-area-inset-bottom)) !important;
    left: 8px !important; right: 8px !important;
    min-width: 0 !important; max-width: none !important;
    transform: translateY(180%) !important;
  }
  .cs-toast.show { transform: translateY(0) !important; }
}

/* ── Phase 2: sticky page-header + tab-bar, scroll-lock, hamburger X ── */
@media (max-width: 768px) {
  body.no-scroll { overflow: hidden; touch-action: none; }

  /* Sticky tab bar */
  .tab-bar {
    position: sticky;
    top: var(--topbar-h);
    background: var(--bg);
    z-index: 80;
    padding-top: 4px;
    margin-left: -14px; margin-right: -14px;
    padding-left: 14px; padding-right: 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .tab-bar::-webkit-scrollbar { display: none; }
  .tab-btn { white-space: nowrap; padding: 12px 16px !important; min-height: 44px; }

  /* Hamburger → X animation */
  body.sidebar-open .hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  body.sidebar-open .hamburger span:nth-child(2) { opacity: 0; }
  body.sidebar-open .hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
}

/* ── Phase 3: card-stack tables, filter chips, messages master/detail ── */
@media (max-width: 768px) {

  /* Card-stack tables — JS adds data-label="…" on each td */
  .data-table { display: block; width: 100%; }
  .data-table thead { display: none; }
  .data-table tbody { display: block; }
  .data-table tr {
    display: block;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
  }
  .data-table tbody tr:hover { background: #fff; }
  .data-table tbody tr:last-child td { border-bottom: 1px solid var(--border); }
  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 0 !important;
    border-bottom: 1px dashed var(--border) !important;
    text-align: right;
    white-space: normal !important;
    overflow: visible !important;
    max-width: none !important;
  }
  .data-table td:last-child { border-bottom: none !important; }
  .data-table td::before {
    content: attr(data-label);
    flex: 0 0 40%;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
  }
  .data-table td:not([data-label])::before { display: none; }
  .data-table td > * { text-align: right; }
  .data-table td > div { justify-content: flex-end !important; }

  /* Filter bar → horizontal scrolling chips */
  .filter-bar {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-left: -14px; margin-right: -14px;
    padding: 4px 14px 8px 14px;
  }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-bar > * { flex-shrink: 0; }
  .filter-bar input { min-width: 180px; }
  .filter-bar select {
    background: var(--bg);
    border-radius: 18px;
    padding: 8px 12px;
    border: 1px solid var(--border);
  }

  /* Messages master/detail */
  .messages-layout {
    flex-direction: row !important;
    height: calc(100dvh - var(--topbar-h) - 32px) !important;
    min-height: 0 !important;
    position: relative;
    overflow: hidden;
  }
  .messages-layout .convo-list {
    width: 100% !important;
    flex: 0 0 100% !important;
    border-right: none !important;
    transition: transform .25s ease;
    max-height: none !important;
  }
  .messages-layout .chat-pane {
    position: absolute;
    inset: 0;
    transform: translateX(100%);
    transition: transform .25s ease;
    background: #fff;
    min-height: 0 !important;
  }
  .messages-layout.show-chat .convo-list { transform: translateX(-100%); }
  .messages-layout.show-chat .chat-pane { transform: translateX(0); }
  .chat-back-btn {
    background: none; border: none;
    color: var(--primary); font-size: 16px;
    padding: 8px 4px 8px 0; margin-right: 4px;
    display: inline-flex !important; align-items: center; gap: 4px;
    min-height: 44px; min-width: 44px;
  }
  .chat-input-area { padding: 10px 12px !important; padding-bottom: calc(10px + env(safe-area-inset-bottom)) !important; }

  /* Card footer actions: wrap, equal width, larger tap */
  .worker-footer, .job-footer { flex-wrap: wrap; gap: 8px; }
  .worker-actions { width: 100%; }
  .worker-actions .btn, .job-footer .btn { flex: 1; min-height: 40px; justify-content: center; }

  /* Job posting card alerts/banners — stack */
  .card-body [style*="display:flex"][style*="align-items:center"][style*="gap:16px"] { flex-wrap: wrap; }
}

/* ── 100vh → dvh upgrades (all screens, Safari URL bar fix) ── */
.messages-layout { height: calc(100dvh - var(--topbar-h) - 80px); }

/* ── Cross-cutting polish (all screens) ─────────────────────── */
:root { color-scheme: light; }

/* Press-state on tappable cards (subtle) */
@media (hover: none) {
  .kpi-card:active, .worker-card:active, .job-card:active,
  .activity-item:active, .convo-item:active, .notif-item:active {
    transform: scale(.985);
    transition: transform .08s ease;
  }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* Smooth page transitions */
#main { transition: opacity .15s ease; }
#main.page-leaving { opacity: 0; }

/* Larger landscape phones: keep 2-col KPIs but more breathing room */
@media (min-width: 481px) and (max-width: 768px) {
  #main { padding: 18px !important; padding-bottom: calc(84px + env(safe-area-inset-bottom)) !important; }
}

/* ============================================================
   FINAL POLISH PASS
   ============================================================ */

/* ── Visible keyboard focus rings ─────────────────────────────── */
.btn:focus-visible,
.nav-item:focus-visible,
.bn-item:focus-visible,
.tab-btn:focus-visible,
.top-btn:focus-visible,
.top-user:focus-visible,
.hamburger:focus-visible,
.kpi-card:focus-visible,
.worker-card:focus-visible,
.job-card:focus-visible,
.convo-item:focus-visible,
.activity-item:focus-visible,
.notif-item:focus-visible,
.modal-close:focus-visible,
.chat-back-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ── Stagger entrance for list items ──────────────────────────── */
@keyframes staggerIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Pulsing alert dot (pending banner) ───────────────────────── */
@keyframes pulseDot {
  0%   { box-shadow: 0 0 0 0   rgba(255,153,31,.65); }
  70%  { box-shadow: 0 0 0 14px rgba(255,153,31,0); }
  100% { box-shadow: 0 0 0 0   rgba(255,153,31,0); }
}
.pulse-dot {
  display: inline-block;
  width: 10px; height: 10px;
  background: #FF991F;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  animation: pulseDot 1.6s infinite;
  flex-shrink: 0;
}

/* ── KPI sparkline ─────────────────────────────────────────────── */
.kpi-spark {
  display: inline-block;
  vertical-align: middle;
  margin-left: 10px;
  width: 60px; height: 22px;
  opacity: .85;
}

/* ── Date subtitle on dashboard greeting ──────────────────────── */
.greeting-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
  letter-spacing: .02em;
}

/* ── Confetti ──────────────────────────────────────────────────── */
.confetti {
  position: fixed; inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 9999;
}
.confetti i {
  position: absolute;
  top: -14px;
  width: 8px; height: 14px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to {
    top: 110vh;
    transform: rotate(720deg) translateX(40px);
    opacity: .85;
  }
}

/* ── Welcome card (first-visit) ───────────────────────────────── */
.welcome-card {
  position: fixed;
  z-index: 1500;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  width: min(420px, calc(100vw - 24px));
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(9,30,66,.25), 0 2px 8px rgba(9,30,66,.12);
  padding: 22px 22px 20px;
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  border: 1px solid var(--border);
}
.welcome-card.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.welcome-close {
  position: absolute;
  top: 8px; right: 10px;
  background: none; border: none;
  font-size: 24px; color: var(--text-muted);
  cursor: pointer; line-height: 1;
  width: 32px; height: 32px;
  border-radius: 50%;
}
.welcome-close:hover { background: var(--bg); color: var(--text); }
.welcome-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #DEEBFF, #B3D4FF);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
}
.welcome-title {
  font-size: 17px; font-weight: 700; margin-bottom: 4px;
}
.welcome-sub {
  font-size: 13px; color: var(--text-muted); margin-bottom: 12px;
}
.welcome-list {
  margin: 0 0 16px;
  padding-left: 20px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
}
.welcome-list li { margin-bottom: 4px; }
.welcome-cta { width: 100%; }
@media (max-width: 480px) {
  .welcome-card { bottom: max(82px, env(safe-area-inset-bottom)); }
}
/* ── 360px extreme-small screens (#15) ───────────────────────── */
@media (max-width: 360px) {
  .kpi-value { font-size: 18px !important; }
  .kpi-data  { min-width: 0; }
  .kpi-card  { gap: 8px !important; padding: 10px !important; }
  .kpi-icon  { width: 32px !important; height: 32px !important; font-size: 14px !important; }
  .kpi-num   { font-size: 17px !important; }
}
@media (prefers-reduced-motion: reduce) {
  .welcome-card { transition: opacity .15s ease; transform: translate(-50%, 0); }
}

/* ── Worker tooltip flip (when card is near top) ──────────────── */
.worker-card.tooltip-below .worker-photo-tooltip {
  top: auto; bottom: -110px;
}
.worker-card.tooltip-below:hover .worker-photo-tooltip {
  top: auto; bottom: -118px;
}

/* ── Mobile FAB (page-aware primary action) ──────────────────── */
@media (max-width: 768px) {
  #fab {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(72px + max(12px, env(safe-area-inset-bottom)));
    width: 56px; height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #0747A6);
    color: #fff;
    border: none;
    box-shadow: 0 8px 20px rgba(0,82,204,.45), 0 2px 4px rgba(9,30,66,.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    z-index: 90;
    cursor: pointer;
    transition: transform .15s ease;
  }
  #fab:active { transform: scale(.92); }
}
#fab.hide { display: none; }
@media (min-width: 769px) { #fab { display: none; } }

/* ── Feedback FAB (always visible, all breakpoints) ─────────── */
#feedback-fab {
  position: fixed;
  right: max(24px, env(safe-area-inset-right));
  bottom: 24px;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #36B37E, #00875A);
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px rgba(54,179,126,.4), 0 2px 4px rgba(9,30,66,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  z-index: 92;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
#feedback-fab:hover {
  transform: scale(1.09);
  box-shadow: 0 6px 20px rgba(54,179,126,.5), 0 2px 4px rgba(9,30,66,.2);
}
#feedback-fab:active { transform: scale(.92); }
@media (max-width: 768px) {
  #feedback-fab {
    left: max(16px, env(safe-area-inset-left));
    right: auto;
    bottom: calc(72px + max(12px, env(safe-area-inset-bottom)));
  }
}

/* ── Empty-state ──────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .es-icon {
  font-size: 42px; opacity: .5; margin-bottom: 10px;
}
.empty-state .es-title {
  font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px;
}

/* ── KPI value baseline (so count-up doesn't shift) ──────────── */
.kpi-value { font-variant-numeric: tabular-nums; }


/* ══════════════════════════════════════════════════
   ROUND 2 POLISH — Command palette, shortcuts, lift
   ══════════════════════════════════════════════════ */

/* Universal card lift on hover (subtle) */
.kpi-card, .worker-card, .job-card, .card.lift-on-hover {
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.kpi-card:hover, .worker-card:hover, .job-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(9, 30, 66, 0.12);
}

/* Header live clock */
.header-clock {
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  font-variant-numeric: tabular-nums;
  margin-right: 10px;
  padding: 4px 10px;
  background: rgba(255,255,255,0.08);
  border-radius: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
@media (max-width: 768px) { .header-clock { display: none; } }

/* ── Command palette (Cmd/Ctrl+K) ─────────────────────────────── */
.cmdk-overlay {
  position: fixed; inset: 0;
  background: rgba(9, 30, 66, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  z-index: 10000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14vh;
  animation: cmdkFadeIn .15s ease;
}
.cmdk-overlay.open { display: flex; }
@keyframes cmdkFadeIn { from { opacity: 0; } to { opacity: 1; } }
.cmdk-box {
  width: min(640px, 92vw);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(9,30,66,0.35), 0 4px 12px rgba(9,30,66,0.15);
  overflow: hidden;
  animation: cmdkSlideIn .2s cubic-bezier(.2,.9,.3,1);
}
@keyframes cmdkSlideIn { from { transform: translateY(-8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.cmdk-input-row {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.cmdk-search-icon { color: var(--text-muted); font-size: 16px; }
.cmdk-input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font-size: 16px; color: var(--text);
  font-family: inherit;
}
.cmdk-esc, .kbd-row kbd, .cmdk-footer kbd {
  display: inline-block;
  padding: 2px 7px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #F4F5F7;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--text-muted);
  line-height: 1.4;
}
.cmdk-results {
  max-height: 50vh; overflow-y: auto;
  padding: 6px;
}
.cmdk-group-label {
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  color: var(--text-muted); text-transform: uppercase;
  padding: 10px 12px 4px;
}
.cmdk-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.cmdk-item .cmdk-icon {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  background: var(--primary-light); color: var(--primary);
  font-size: 13px;
}
.cmdk-item .cmdk-label { flex: 1; color: var(--text); }
.cmdk-item .cmdk-hint { font-size: 11px; color: var(--text-muted); }
.cmdk-item.active, .cmdk-item:hover {
  background: var(--primary-light);
}
.cmdk-item.active .cmdk-label { color: var(--primary); font-weight: 600; }
.cmdk-empty {
  padding: 28px 18px; text-align: center;
  color: var(--text-muted); font-size: 13px;
}
.cmdk-footer {
  display: flex; gap: 16px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: #FAFBFC;
  font-size: 11px;
  color: var(--text-muted);
}
.cmdk-footer kbd { padding: 1px 5px; font-size: 10px; }

/* ── Keyboard cheatsheet ──────────────────────────────────────── */
.kbd-overlay {
  position: fixed; inset: 0;
  background: rgba(9, 30, 66, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  animation: cmdkFadeIn .15s ease;
}
.kbd-overlay.open { display: flex; }
.kbd-box {
  width: min(560px, 92vw);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(9,30,66,0.35);
  overflow: hidden;
  animation: cmdkSlideIn .2s cubic-bezier(.2,.9,.3,1);
}
.kbd-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 15px;
}
.kbd-body { padding: 14px 18px 18px; }
.kbd-section + .kbd-section { margin-top: 16px; }
.kbd-section-title {
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  color: var(--text-muted); text-transform: uppercase;
  margin-bottom: 8px;
}
.kbd-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text);
}
.kbd-row + .kbd-row { border-top: 1px solid #F4F5F7; }

/* ── Chat typing indicator ────────────────────────────────────── */
.typing-indicator {
  display: inline-flex; gap: 4px;
  align-items: center;
  padding: 10px 14px;
}
.typing-indicator span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.4;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ── Reduced motion ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .kpi-card:hover, .worker-card:hover, .job-card:hover { transform: none; }
  .cmdk-overlay, .cmdk-box, .kbd-overlay, .kbd-box { animation: none; }
  .typing-indicator span { animation: none; opacity: 0.6; }
}


/* ══════════════════════════════════════════════════
   ROUND 3 POLISH — Dark mode, skeleton, toast stack, PTR
   ══════════════════════════════════════════════════ */

/* ── Dark mode tokens ─────────────────────────────────────────── */
body.dark {
  --bg: #0B1220;
  --card-bg: #131C2E;
  --text: #E6EAF2;
  --text-muted: #93A0B8;
  --border: #21304A;
  --primary-light: #1A2E4F;
}
body.dark .card,
body.dark .kpi-card,
body.dark .worker-card,
body.dark .job-card,
body.dark .convo-item,
body.dark .chat-pane,
body.dark .messages-layout,
body.dark .filter-bar,
body.dark .settings-sidebar .card,
body.dark .form-control,
body.dark select,
body.dark input[type="text"],
body.dark input[type="email"],
body.dark input[type="tel"],
body.dark input[type="number"],
body.dark input[type="date"],
body.dark input[type="search"] {
  background: var(--card-bg);
  color: var(--text);
  border-color: var(--border);
}
body.dark .form-control, body.dark select,
body.dark input[type="text"], body.dark input[type="email"],
body.dark input[type="tel"], body.dark input[type="number"],
body.dark input[type="date"], body.dark input[type="search"] {
  background: #0F1828;
}
body.dark .cmdk-box, body.dark .kbd-box, body.dark .welcome-card, body.dark .modal-box {
  background: #131C2E; color: var(--text);
}
body.dark .cmdk-input { color: var(--text); }
body.dark .cmdk-footer { background: #0F1828; }
body.dark .kbd-row kbd, body.dark .cmdk-esc, body.dark .cmdk-footer kbd { background: #1A2440; color: var(--text-muted); border-color: var(--border); }
body.dark .cs-toast, body.dark .toast { background: #131C2E; color: var(--text); }
body.dark .activity-item:hover, body.dark .convo-item:hover, body.dark .notif-item:hover { background: rgba(255,255,255,0.04); }
body.dark .convo-item.active { background: var(--primary-light); }
body.dark .table th { background: #0F1828; color: var(--text-muted); }
body.dark .table tr:hover { background: rgba(255,255,255,0.03); }
body.dark .greeting-date, body.dark .page-subtitle { color: var(--text-muted); }
body.dark .empty-state, body.dark .es-icon { color: var(--text-muted); }
body.dark .cs-toast-sub { color: var(--text-muted); }
body.dark .pulse-dot, body.dark .badge-success, body.dark .badge-primary, body.dark .badge-warning {
  /* keep badges colorful */
}
body.dark #topbar {
  /* keep the dark blue gradient header */
}

/* ── Dark-mode parity patch (issue #14) ───────────────────────────
   Override the Atlassian-style "subtle" tint backgrounds that
   appear inline in render functions (kpi-icon, status pills,
   filter chips) and the .badge-* color classes so they don't
   render as pale-on-pale or invisible blue-on-blue in dark mode.
   Uses attribute selectors with !important to defeat inline styles.
   Keeps the same hue family but at WCAG-AA-passing dark-mode levels. */

/* Tinted-background overrides (inline style="background:#XYZ"). */
body.dark [style*="#DEEBFF"], body.dark [style*="background:#DEEBFF"] {
  background: rgba(0,82,204,0.20) !important;
  color: #7FB5FF !important;
  border-color: rgba(127,181,255,0.35) !important;
}
body.dark [style*="#E3FCEF"], body.dark [style*="background:#E3FCEF"] {
  background: rgba(0,135,90,0.20) !important;
  color: #79F2C0 !important;
  border-color: rgba(121,242,192,0.35) !important;
}
body.dark [style*="#FFFAE6"], body.dark [style*="background:#FFFAE6"] {
  background: rgba(255,153,31,0.18) !important;
  color: #FFCC80 !important;
  border-color: rgba(255,204,128,0.35) !important;
}
body.dark [style*="#FFEBE6"], body.dark [style*="background:#FFEBE6"] {
  background: rgba(222,53,11,0.22) !important;
  color: #FF8F73 !important;
  border-color: rgba(255,143,115,0.35) !important;
}
body.dark [style*="#EAE6FF"], body.dark [style*="background:#EAE6FF"] {
  background: rgba(151,131,255,0.22) !important;
  color: #C0B6F2 !important;
  border-color: rgba(192,182,242,0.35) !important;
}
body.dark [style*="#EBECF0"], body.dark [style*="background:#EBECF0"] {
  background: rgba(255,255,255,0.06) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
/* "background:#fff" inline pills (workforce "All" filter) */
body.dark [style*="background:#fff"] {
  background: var(--card-bg) !important;
  color: var(--text) !important;
}
/* Profile / workforce chips that use var(--primary-light) bg + var(--primary) text
   — in dark mode --primary-light becomes navy and --primary stays dark blue, so
   the text disappears. Brighten the text. */
body.dark [style*="--primary-light"],
body.dark [style*="var(--primary-light)"] {
  color: #7FB5FF !important;
}
/* But not when the chip is also using a dark text via var(--text) already. */
body.dark [style*="color:var(--text)"][style*="--primary-light"] {
  color: var(--text) !important;
}

/* Badges — keep hue, raise contrast against dark card bg. */
body.dark .badge-primary { background: rgba(0,82,204,0.22); color: #7FB5FF; }
body.dark .badge-success { background: rgba(0,135,90,0.22); color: #79F2C0; }
body.dark .badge-warning { background: rgba(255,153,31,0.20); color: #FFCC80; }
body.dark .badge-danger  { background: rgba(222,53,11,0.22); color: #FF8F73; }
body.dark .badge-muted   { background: rgba(255,255,255,0.08); color: #B7C0D3; }
body.dark .badge-purple  { background: rgba(151,131,255,0.22); color: #C0B6F2; }

/* Outline buttons (View All, View Full Roster, etc.) */
body.dark .btn-outline {
  color: #7FB5FF;
  border-color: rgba(127,181,255,0.45);
  background: transparent;
}
body.dark .btn-outline:hover {
  background: rgba(127,181,255,0.12);
  color: #B3D4FF;
}
body.dark .btn-ghost { color: var(--text); }
body.dark .btn-ghost:hover { background: rgba(255,255,255,0.06); }

/* Misc small-text contrast lifts. */
body.dark .text-muted,
body.dark .activity-meta,
body.dark .small-meta { color: #93A0B8; }

/* Danger Zone header / button: brighten the red so it still reads as warning. */
body.dark .card-header[style*="color:#DE350B"],
body.dark [style*="color:#DE350B"] { color: #FF8F73 !important; }
body.dark [style*="color: rgb(222, 53, 11)"] { color: #FF8F73 !important; }

/* Inline color overrides — brighten dark Atlassian palette text colors when
   on the dark card background. These match the literal hex strings written
   into inline style="" attributes in the page render functions. */
body.dark [style*="color:#0052CC"], body.dark [style*="color: #0052CC"] { color: #7FB5FF !important; }
body.dark [style*="color:#0747A6"], body.dark [style*="color: #0747A6"] { color: #7FB5FF !important; }
body.dark [style*="color:#00875A"], body.dark [style*="color: #00875A"] { color: #79F2C0 !important; }
body.dark [style*="color:#006644"], body.dark [style*="color: #006644"] { color: #79F2C0 !important; }
body.dark [style*="color:#974F0C"], body.dark [style*="color: #974F0C"] { color: #FFCC80 !important; }
body.dark [style*="color:#403294"], body.dark [style*="color: #403294"] { color: #C0B6F2 !important; }
body.dark [style*="color:#BF2600"], body.dark [style*="color: #BF2600"] { color: #FF8F73 !important; }
body.dark [style*="color:#42526E"], body.dark [style*="color: #42526E"] { color: #B7C0D3 !important; }
body.dark [style*="color:#6B778C"], body.dark [style*="color: #6B778C"] { color: #B7C0D3 !important; }
body.dark [style*="color:#172B4D"], body.dark [style*="color: #172B4D"] { color: var(--text) !important; }

/* Hardcoded dark-text background fills (e.g. avatars using background:var(--primary-light)
   with bare text) — text becomes invisible in dark mode. Lift the contrast. */
body.dark .avatar-sm,
body.dark .avatar-xs { color: #7FB5FF !important; }

/* CSS-var color references used inline — brighten emphasis text in dark mode.
   These only target color (not background or border), so badge/button surfaces
   that depend on --primary, --danger, --success stay intact. */
body.dark [style*="color:var(--primary)"],
body.dark [style*="color: var(--primary)"] { color: #7FB5FF !important; }
body.dark [style*="color:var(--danger)"],
body.dark [style*="color: var(--danger)"] { color: #FF8F73 !important; }
body.dark [style*="color:var(--success)"],
body.dark [style*="color: var(--success)"] { color: #79F2C0 !important; }
body.dark [style*="color:var(--warning)"],
body.dark [style*="color: var(--warning)"] { color: #FFCC80 !important; }

/* Auto-dark via OS preference, only if the user hasn't explicitly chosen
   a theme via the in-app toggle (which sets body.dark or body.light). */
@media (prefers-color-scheme: dark) {
  body:not(.dark):not(.light) {
    --bg: #0B1220;
    --card-bg: #131C2E;
    --text: #E6EAF2;
    --text-muted: #93A0B8;
    --border: #21304A;
    --primary-light: #1A2E4F;
    background: var(--bg);
    color: var(--text);
  }
}

/* Smooth theme switch */
body, .card, .kpi-card, .worker-card, .job-card, .convo-item, .chat-pane, .messages-layout {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

/* ── Skeleton shimmer ─────────────────────────────────────────── */
.skel-wrap { padding: 4px 0; }
.skel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 16px; }
.skel-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.skel-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  min-height: 120px;
}
.skel-line, .skel-block, .skel-circle {
  background: linear-gradient(90deg, rgba(9,30,66,0.06) 25%, rgba(9,30,66,0.12) 50%, rgba(9,30,66,0.06) 75%);
  background-size: 200% 100%;
  animation: skelShimmer 1.3s linear infinite;
  border-radius: 4px;
}
body.dark .skel-line, body.dark .skel-block, body.dark .skel-circle {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.09) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
}
.skel-line { height: 12px; margin-bottom: 10px; }
.skel-line.short { width: 40%; }
.skel-line.med { width: 70%; }
.skel-line.long { width: 95%; }
.skel-block { height: 220px; width: 100%; border-radius: 8px; }
.skel-circle { width: 40px; height: 40px; border-radius: 50%; }
.skel-card-flex { display: flex; gap: 12px; align-items: center; }
@keyframes skelShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Toast stack ─────────────────────────────────────────────── */
#toastStack {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column-reverse; gap: 10px;
  z-index: 11000; pointer-events: none;
}
@media (max-width: 600px) {
  #toastStack { right: 12px; left: 12px; bottom: 80px; }
}
.toast {
  pointer-events: auto;
  min-width: 260px; max-width: 380px;
  background: #172B4D; color: #fff;
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(9,30,66,0.25);
  display: flex; align-items: flex-start; gap: 12px;
  font-size: 13.5px;
  border-left: 4px solid #6B778C;
  animation: toastIn .25s cubic-bezier(.2,.9,.3,1);
}
.toast.toast-out { animation: toastOut .2s ease forwards; }
.toast .toast-icon { font-size: 16px; margin-top: 1px; }
.toast .toast-body { flex: 1; line-height: 1.4; }
.toast .toast-title { font-weight: 700; margin-bottom: 2px; }
.toast .toast-close {
  background: transparent; border: 0; color: rgba(255,255,255,0.6);
  cursor: pointer; font-size: 14px; line-height: 1;
  padding: 0; margin-left: 6px;
}
.toast .toast-close:hover { color: #fff; }
.toast.success { border-left-color: #00875A; }
.toast.success .toast-icon { color: #00C781; }
.toast.error   { border-left-color: #DE350B; }
.toast.error   .toast-icon { color: #FF5630; }
.toast.warning { border-left-color: #FF991F; }
.toast.warning .toast-icon { color: #FFAB00; }
.toast.info    { border-left-color: #0052CC; }
.toast.info    .toast-icon { color: #4C9AFF; }
@keyframes toastIn  { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { to   { transform: translateX(24px); opacity: 0; } }

/* ── Pull-to-refresh ─────────────────────────────────────────── */
.ptr-indicator {
  position: fixed; top: 56px; left: 50%; transform: translateX(-50%) translateY(-60px);
  width: 40px; height: 40px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(9,30,66,0.15);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  z-index: 1500;
  transition: transform .2s ease, opacity .2s ease;
  opacity: 0;
}
body.dark .ptr-indicator { background: #131C2E; }
.ptr-indicator.visible { opacity: 1; }
.ptr-indicator.refreshing i { animation: ptrSpin .8s linear infinite; }
@keyframes ptrSpin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .skel-line, .skel-block, .skel-circle { animation: none; }
  .toast { animation: none; }
  .ptr-indicator.refreshing i { animation: none; }
}


/* ══════════════════════════════════════════════════
   ROUND 4 — Dark mode pass + bigger avatars + hover zoom
   ══════════════════════════════════════════════════ */

/* ── Dark mode: top bar, sidebar, bottom nav ──────────────── */
body.dark #topbar {
  background: linear-gradient(135deg, #0A1428 0%, #060C1A 100%);
  box-shadow: 0 1px 0 var(--border), 0 2px 8px rgba(0,0,0,.5);
}
body.dark #topbar .top-search input {
  background: rgba(255,255,255,.06);
  color: #fff;
}
body.dark #topbar .top-search input::placeholder { color: rgba(255,255,255,.45); }
body.dark #sidebar {
  background: var(--card-bg);
  border-right-color: var(--border);
}
body.dark .nav-item { color: var(--text-muted); }
body.dark .nav-item:hover { background: rgba(255,255,255,.04); color: var(--text); }
body.dark .nav-item.active {
  background: rgba(0,82,204,.18);
  color: #7FB3FF;
  border-left-color: #4C9AFF;
}
body.dark .nav-section-label { color: var(--text-muted); }

body.dark #bottomNav {
  background: var(--card-bg);
  border-top-color: var(--border);
  box-shadow: 0 -2px 12px rgba(0,0,0,.4);
}
body.dark .bn-item { color: var(--text-muted); }
body.dark .bn-item.active { color: #7FB3FF; }
body.dark .bn-item.active::before { background: #4C9AFF; }

body.dark body, body.dark #main { background: var(--bg); }

/* ── Dark mode: messages page ──────────────────────────────── */
body.dark .convo-list { background: var(--card-bg); }
body.dark .convo-item { border-bottom-color: var(--border); color: var(--text); }
body.dark .convo-item:hover { background: rgba(255,255,255,.06); }
body.dark .convo-item:hover .convo-name,
body.dark .convo-item:hover .convo-preview { color: var(--text); }
body.dark .convo-item.active { background: rgba(0,82,204,.22); }
body.dark .convo-item.active .convo-name { color: #E6EAF2; }
body.dark .convo-item.active .convo-preview { color: #B8C4D9; }
body.dark .convo-name { color: var(--text); }
body.dark .convo-preview, body.dark .convo-time { color: var(--text-muted); }
body.dark .chat-pane { background: var(--card-bg); }
body.dark .chat-header { border-bottom-color: var(--border); }
body.dark .msg.them .msg-bubble { background: #1B273D; color: var(--text); }
body.dark .chat-input-area { border-top-color: var(--border); background: var(--card-bg); }
body.dark .chat-input-area input {
  background: #0F1828; color: var(--text); border-color: var(--border);
}

/* ── Dark mode: notifications & dropdowns ──────────────────── */
body.dark .notif-dropdown { background: var(--card-bg); border-color: var(--border); box-shadow: 0 8px 30px rgba(0,0,0,.55); }
body.dark .notif-header { border-bottom-color: var(--border); }
body.dark .notif-item { border-bottom-color: var(--border); color: var(--text); }
body.dark .notif-item.unread { background: rgba(0,82,204,.12); }
body.dark .notif-item:hover { background: rgba(255,255,255,.05); }
body.dark .notif-time { color: var(--text-muted); }

/* ── Dark mode: filter bar & forms ─────────────────────────── */
body.dark .filter-bar input, body.dark .filter-bar select {
  background: #0F1828; color: var(--text); border-color: var(--border);
}
body.dark .filter-bar input::placeholder { color: var(--text-muted); }

/* ── Dark mode: tables ─────────────────────────────────────── */
body.dark .table { color: var(--text); }
body.dark .table td { border-bottom-color: var(--border); }

/* ── Dark mode: misc cards & headers ───────────────────────── */
body.dark .card-header { border-bottom-color: var(--border); color: var(--text); }
body.dark .worker-footer, body.dark .job-footer { border-top-color: var(--border); }
body.dark .cert-tag { background: #0F1828; border-color: var(--border); color: var(--text-muted); }
body.dark .loan-progress { background: var(--border); }
body.dark .avatar-photo { border-color: var(--border); background: var(--card-bg); }
body.dark .top-search i { color: rgba(255,255,255,.45); }

/* Modal/dialog in dark */
body.dark .modal-overlay { background: rgba(0,0,0,.6); }

/* ── Bigger avatars (desktop bump) ─────────────────────────── */
.avatar-photo.lg { width: 72px; height: 72px; }
.avatar-photo.md { width: 48px; height: 48px; }
.avatar-photo.sm { width: 36px; height: 36px; }
.avatar-photo.xs { width: 26px; height: 26px; }

/* ── Bigger avatars on mobile (extra bump) ─────────────────── */
@media (max-width: 768px) {
  .avatar-photo.lg { width: 88px; height: 88px; border-width: 3px; }
  .avatar-photo.md { width: 56px; height: 56px; border-width: 2.5px; }
  .avatar-photo.sm { width: 44px; height: 44px; border-width: 2px; }
  .avatar-photo.xs { width: 32px; height: 32px; border-width: 2px; }
  .worker-card-top { gap: 14px; }
}

/* ── Bigger worker tooltip on workforce page ───────────────── */
.worker-photo-tooltip { width: 110px; height: 110px; top: -130px; }
.worker-card:hover .worker-photo-tooltip { top: -138px; }

/* ── Employee photo hover-tooltip (generalized from workforce) ── */
.employee-photo-tooltip {
  position: absolute;
  top: -118px; left: 50%;
  transform: translateX(-50%);
  width: 110px; height: 110px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(9,30,66,.28);
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease, top .18s ease;
  z-index: 1500;
  background: var(--bg);
}
.employee-photo-tooltip img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
/* Show only when the avatar's direct parent is hovered.
   Using the direct-child combinator avoids cascading triggers from grandparents. */
*:hover > .employee-photo-tooltip {
  opacity: 1;
  top: -126px;
}
body.dark .employee-photo-tooltip {
  border-color: #4C9AFF;
  background: var(--card-bg);
  box-shadow: 0 10px 28px rgba(0,0,0,.55);
}
/* Hide on touch / small screens — popups dont make sense there */
@media (hover: none), (max-width: 600px) {
  .employee-photo-tooltip { display: none; }
}

/* ── Tooltip flip-below (used when host is near the top of viewport) ── */
.tooltip-below > .employee-photo-tooltip,
.tooltip-below > .worker-photo-tooltip {
  top: auto !important;
  bottom: -130px;
}
.tooltip-below:hover > .employee-photo-tooltip,
.tooltip-below:hover > .worker-photo-tooltip {
  bottom: -138px;
  top: auto !important;
}

/* ── Dark mode: modal interior (overlay already darkened) ────── */
body.dark .modal-box {
  background: var(--card-bg);
  color: var(--text);
  box-shadow: 0 10px 50px rgba(0,0,0,.7);
  border: 1px solid var(--border);
}
body.dark .modal-header {
  border-bottom-color: var(--border);
  color: var(--text);
}
body.dark .modal-footer {
  border-top-color: var(--border);
  background: rgba(255,255,255,0.02);
}
body.dark .modal-close { color: var(--text-muted); }
body.dark .modal-close:hover { color: var(--text); }
body.dark .modal-body { color: var(--text); }
body.dark .modal-body .form-label,
body.dark .modal-body label { color: var(--text); }
body.dark .modal-body .form-control,
body.dark .modal-body select,
body.dark .modal-body input[type="text"],
body.dark .modal-body input[type="email"],
body.dark .modal-body input[type="tel"],
body.dark .modal-body input[type="number"],
body.dark .modal-body textarea {
  background: #0F1828;
  color: var(--text);
  border-color: var(--border);
}
body.dark .modal-body .form-control::placeholder,
body.dark .modal-body textarea::placeholder { color: var(--text-muted); }
/* Light cards/strips inside modal bodies (background: var(--bg)) need a dark mode tone */
body.dark .modal-body [style*="background:var(--bg)"],
body.dark .modal-body [style*="background: var(--bg)"] {
  background: #0F1828 !important;
}
body.dark .modal-body hr,
body.dark .modal-body [style*="border-top:1px solid var(--border)"],
body.dark .modal-body [style*="border-bottom:1px solid var(--border)"] {
  border-color: var(--border) !important;
}
/* Success/info modal callouts (the big emoji confirmation panels) */
body.dark .modal-body [style*="color:var(--text-muted)"],
body.dark .modal-body [style*="color: var(--text-muted)"] {
  color: var(--text-muted) !important;
}

/* ============================================================
   CALENDAR PAGE  ----------------------------------------------
   Month grid, week strip, day agenda, filter chips, event pills,
   plus dashboard mini-widget. Tokens use existing CSS vars so
   dark mode flips for free where possible.
   ============================================================ */
.cal-toolbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:12px;flex-wrap:wrap;}
.cal-nav-group{display:flex;align-items:center;gap:6px;}
.cal-nav-btn{width:32px;height:32px;padding:0;display:inline-flex;align-items:center;justify-content:center;}
.cal-period-label{font-size:18px;font-weight:700;color:var(--text);margin-left:8px;}
.cal-view-switch{display:inline-flex;background:var(--bg);border:1px solid var(--border);border-radius:8px;padding:2px;}
.cal-view-btn{background:transparent;border:0;padding:6px 14px;font-size:13px;font-weight:600;color:var(--text-muted);border-radius:6px;cursor:pointer;}
.cal-view-btn.active{background:var(--surface);color:var(--text);box-shadow:0 1px 2px rgba(9,30,66,.12);}
body.dark .cal-view-btn.active{background:#1B2A41;color:#E6EDF7;}

.cal-filter-row{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:12px;}
.cal-filter{display:inline-flex;align-items:center;gap:6px;background:var(--surface);border:1px solid var(--border);border-radius:999px;padding:5px 12px;font-size:12px;font-weight:600;color:var(--text-muted);cursor:pointer;transition:all .15s;}
.cal-filter:hover{border-color:var(--primary);color:var(--text);}
.cal-filter.active{background:var(--primary);color:#fff;border-color:var(--primary);}
.cal-filter.active .cal-dot{box-shadow:0 0 0 2px rgba(255,255,255,.5);}
.cal-dot{width:8px;height:8px;border-radius:50%;display:inline-block;}

/* Month grid */
.cal-month-grid{display:grid;grid-template-columns:repeat(7,1fr);grid-auto-rows:minmax(108px,auto);background:var(--border);gap:1px;border:1px solid var(--border);border-radius:10px;overflow:hidden;}
.cal-weekday-row{display:contents;}
.cal-weekday{background:var(--surface);padding:8px 10px;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:var(--text-muted);text-align:left;}
.cal-cell{background:var(--surface);padding:6px 8px 8px;cursor:pointer;display:flex;flex-direction:column;gap:4px;min-height:108px;transition:background .12s;}
.cal-cell:hover{background:var(--bg);}
.cal-cell.out{background:color-mix(in srgb, var(--surface) 70%, var(--border));}
.cal-cell.out .cal-daynum{color:var(--text-muted);opacity:.55;}
.cal-cell.weekend{background:color-mix(in srgb, var(--surface) 94%, var(--primary) 6%);}
.cal-cell.today{outline:2px solid var(--primary);outline-offset:-2px;}
.cal-cell.today .cal-daynum{background:var(--primary);color:#fff;border-radius:50%;width:24px;height:24px;display:inline-flex;align-items:center;justify-content:center;font-weight:700;}
.cal-cell.holiday{background:color-mix(in srgb, var(--surface) 88%, #DE350B 12%);}
.cal-cell-head{display:flex;align-items:center;justify-content:space-between;gap:6px;}
.cal-daynum{font-size:13px;font-weight:600;color:var(--text);}
.cal-holiday-tag{font-size:10px;font-weight:700;color:#DE350B;background:rgba(222,53,11,.12);padding:2px 6px;border-radius:4px;text-transform:uppercase;letter-spacing:.03em;max-width:120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.cal-chips{display:flex;flex-direction:column;gap:3px;min-height:0;}
.cal-chip{display:inline-flex;align-items:center;gap:5px;background:#0052CC;color:#fff;border:0;padding:2px 7px;border-radius:4px;font-size:11px;font-weight:600;cursor:pointer;text-align:left;line-height:1.3;}
.cal-chip i{font-size:9px;flex:0 0 auto;}
.cal-chip-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.cal-chip:hover{filter:brightness(1.08);}
.cal-chip.more{background:transparent;color:var(--text-muted);border:1px dashed var(--border);white-space:nowrap;}
.cal-chip.more:hover{color:var(--text);border-color:var(--primary);}
.cal-chip.span-start{border-top-right-radius:0;border-bottom-right-radius:0;}
.cal-chip.span-end{border-top-left-radius:0;border-bottom-left-radius:0;}
.cal-chip.span-mid{border-radius:0;}

/* Week view */
.cal-week-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:1px;background:var(--border);border:1px solid var(--border);border-radius:10px;overflow:hidden;}
.cal-week-col{background:var(--surface);min-height:380px;display:flex;flex-direction:column;}
.cal-week-col.today{background:color-mix(in srgb, var(--surface) 92%, var(--primary) 8%);}
.cal-week-head{padding:10px 12px;border-bottom:1px solid var(--border);}
.cal-week-dow{font-size:11px;font-weight:700;text-transform:uppercase;color:var(--text-muted);letter-spacing:.04em;}
.cal-week-day{font-size:22px;font-weight:700;color:var(--text);margin-top:2px;}
.cal-week-body{flex:1;padding:8px;display:flex;flex-direction:column;gap:6px;}
.cal-week-empty{color:var(--text-muted);font-size:12px;font-style:italic;padding:8px 4px;}
.cal-week-evt{text-align:left;background:var(--bg);border:0;border-left:3px solid var(--primary);padding:8px 10px;border-radius:4px;cursor:pointer;}
.cal-week-evt:hover{background:color-mix(in srgb, var(--bg) 80%, var(--primary) 20%);}
.cal-week-evt-title{font-size:12px;font-weight:600;color:var(--text);}
.cal-week-evt-sub{font-size:11px;color:var(--text-muted);margin-top:2px;}

/* Day view (agenda) */
.cal-day-view{display:flex;flex-direction:column;gap:18px;}
.cal-day-empty{padding:60px 20px;text-align:center;background:var(--surface);border:1px solid var(--border);border-radius:10px;}
.cal-day-section-title{font-size:12px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--text-muted);margin-bottom:8px;display:flex;align-items:center;gap:8px;}
.cal-count{background:var(--bg);color:var(--text);font-size:11px;padding:1px 8px;border-radius:999px;font-weight:700;}
.cal-day-list{display:flex;flex-direction:column;gap:8px;}
.cal-day-evt{display:flex;align-items:center;gap:12px;background:var(--surface);border:1px solid var(--border);border-left:4px solid var(--primary);padding:12px 14px;border-radius:8px;text-align:left;cursor:pointer;width:100%;}
.cal-day-evt:hover{background:var(--bg);}
.cal-day-evt-icon{width:36px;height:36px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;color:#fff;flex:0 0 auto;}
.cal-day-evt-body{flex:1;min-width:0;}
.cal-day-evt-title{font-size:14px;font-weight:600;color:var(--text);}
.cal-day-evt-sub{font-size:12px;color:var(--text-muted);margin-top:2px;}
.cal-day-evt-range{font-size:11px;color:var(--text-muted);margin-top:4px;font-weight:600;}
.cal-day-evt-arrow{color:var(--text-muted);}

/* Legend */
.cal-legend{display:flex;flex-wrap:wrap;gap:14px;margin-top:14px;font-size:11px;color:var(--text-muted);}
.cal-legend-item{display:inline-flex;align-items:center;gap:6px;}

/* Dashboard mini-widget */
.cal-widget .mini-cal{user-select:none;}
.cal-widget .mini-weekrow{display:grid;grid-template-columns:repeat(7,1fr);gap:2px;margin-bottom:4px;}
.cal-widget .mini-weekrow span{text-align:center;font-size:10px;font-weight:700;color:var(--text-muted);text-transform:uppercase;}
.cal-widget .mini-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:2px;}
.cal-widget .mini-cell{background:var(--bg);border:0;border-radius:4px;padding:4px 2px 2px;min-height:38px;display:flex;flex-direction:column;align-items:center;gap:2px;cursor:pointer;}
.cal-widget .mini-cell:hover{background:color-mix(in srgb, var(--bg) 70%, var(--primary) 30%);}
.cal-widget .mini-cell.out{opacity:.4;}
.cal-widget .mini-cell.today{background:var(--primary);color:#fff;}
.cal-widget .mini-cell.today .mini-num{color:#fff;font-weight:700;}
.cal-widget .mini-num{font-size:11px;color:var(--text);font-weight:600;}
.cal-widget .mini-dots{display:flex;gap:2px;}
.cal-widget .mini-dot{width:4px;height:4px;border-radius:50%;}
.cal-widget .widget-up-title{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.04em;color:var(--text-muted);margin:14px 0 8px;}
.cal-widget .widget-up-list{display:flex;flex-direction:column;gap:6px;}
.cal-widget .widget-evt{display:flex;align-items:center;gap:10px;background:var(--bg);border:0;border-left:3px solid var(--primary);padding:8px 10px;border-radius:4px;cursor:pointer;text-align:left;}
.cal-widget .widget-evt:hover{background:color-mix(in srgb, var(--bg) 80%, var(--primary) 20%);}
.cal-widget .widget-evt-day{display:flex;flex-direction:column;align-items:center;justify-content:center;min-width:34px;}
.cal-widget .widget-evt-dow{font-size:9px;font-weight:700;color:var(--text-muted);text-transform:uppercase;}
.cal-widget .widget-evt-num{font-size:16px;font-weight:700;color:var(--text);line-height:1;}
.cal-widget .widget-evt-body{flex:1;min-width:0;}
.cal-widget .widget-evt-title{font-size:12px;font-weight:600;color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.cal-widget .widget-evt-sub{font-size:11px;color:var(--text-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}

/* Dark-mode tweaks */
body.dark .cal-cell.out{background:#0B1626;}
body.dark .cal-cell.weekend{background:#101E33;}
body.dark .cal-cell.holiday{background:#2A0F0A;}
body.dark .cal-holiday-tag{background:rgba(222,53,11,.18);color:#FF7A5C;}
body.dark .cal-filter{background:#1B2A41;}
body.dark .cal-week-col.today{background:#102339;}
body.dark .cal-widget .mini-cell{background:#1B2A41;}
body.dark .cal-widget .widget-evt{background:#1B2A41;}

/* Responsive */
@media (max-width: 720px){
  .cal-month-grid{grid-auto-rows:minmax(72px,auto);}
  .cal-cell{min-height:72px;padding:4px;}
  .cal-chip-text{display:none;}
  .cal-chip{padding:2px 5px;}
  .cal-week-grid{grid-template-columns:1fr;}
  .cal-week-col{min-height:0;}
  .cal-period-label{font-size:16px;}
}
