/* ============================================================
   Main Application Styles
   ============================================================ */

:root {
  --color-primary:    #0078d4;  /* MS blue */
  --color-primary-dk: #005a9e;
  --color-success:    #107c10;
  --color-danger:     #d13438;
  --color-warning:    #c7a800;
  --color-bg:         #f3f2f1;
  --color-surface:    #ffffff;
  --color-border:     #e0e0e0;
  --color-text:       #323130;
  --color-text-mute:  #605e5c;
  --color-nav-bg:     #ffffff;
  --color-nav-text:   #323130;
  --color-nav-hover:  #eeeded;
  --color-nav-active: #0078d4;

  --font-main:   'Segoe UI', Arial, sans-serif;
  --font-mono:   'Consolas', 'Courier New', monospace;
  --radius:      4px;
  --shadow:      0 2px 6px rgba(0,0,0,0.12);
  --nav-width:   220px;
  --header-h:    48px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font-main);
  font-size: 13px;
  color: var(--color-text);
  background: var(--color-bg);
  height: 100%;
  overflow: hidden;
}

/* ── Navigation ─────────────────────────────────────────────── */
.app-nav {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--nav-width);
  background: var(--color-nav-bg);
  color: var(--color-nav-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  border-right: 1px solid var(--color-border);
}
.nav-top {
  position: relative;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
}
.nav-brand {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--color-nav-text);
}
.nav-brand:hover { opacity: .85; }
.nav-icon { font-size: 20px; }
.nav-links {
  list-style: none;
  flex: 1;
  padding: 8px 0;
}
.nav-links > li > a,
.nav-links ul li a {
  display: block;
  padding: 7px 16px;
  color: var(--color-nav-text);
  text-decoration: none;
  border-radius: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-links > li > a:hover,
.nav-links ul li a:hover { background: var(--color-nav-hover); }
.nav-links > li > a.active,
.nav-links ul li a.active {
  background: var(--color-primary);
  color: #fff;
}
.nav-group { margin-top: 8px; }
.nav-group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px 2px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--color-text-mute);
  cursor: pointer;
  user-select: none;
}
.nav-chevron {
  flex-shrink: 0;
  opacity: 0.55;
  transition: transform 0.15s ease;
  margin-left: 4px;
}
.nav-group.collapsed > .nav-group-label .nav-chevron { transform: rotate(-90deg); }
.nav-group.collapsed > ul { display: none; }
.nav-group ul { list-style: none; }
.nav-group ul li a { padding-left: 28px; font-size: 12.5px; }
.nav-group-nested { margin-top: 4px; }
.nav-group-nested > .nav-group-label { font-size: 11px; padding-left: 28px; }
.nav-group-nested ul li a { padding-left: 40px; }

/* ── Sidebar collapse toggle (desktop only) ──────────────────── */
#nav-sidebar-toggle {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  left: var(--nav-width);
  z-index: 101;
  width: 18px;
  height: 48px;
  background: var(--color-nav-bg);
  border: 1px solid var(--color-border);
  border-left: none;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-mute);
  box-shadow: 2px 0 6px rgba(0,0,0,0.08);
  padding: 0;
}
#nav-sidebar-toggle:hover {
  background: var(--color-nav-hover);
  color: var(--color-text);
}

@media (min-width: 769px) {
  .app-nav    { transition: width .25s cubic-bezier(.4,0,.2,1); }
  .app-main   { transition: margin-left .25s cubic-bezier(.4,0,.2,1); }
  #nav-sidebar-toggle { transition: left .25s cubic-bezier(.4,0,.2,1), background .12s; }

  body.nav-collapsed .app-nav            { width: 0; overflow: hidden; }
  body.nav-collapsed .app-main          { margin-left: 0; }
  body.nav-collapsed #nav-sidebar-toggle {
    left: 0;
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    border-radius: 0 6px 6px 0;
  }

  body.no-nav-transition .app-nav,
  body.no-nav-transition .app-main,
  body.no-nav-transition #nav-sidebar-toggle { transition: none !important; }
}

.badge-count {
  display: inline-block;
  background: var(--color-danger);
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 10px;
  margin-left: 4px;
  vertical-align: middle;
}
.badge-count:empty { display: none; }
.nav-user {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  font-size: 12px;
}
.nav-bell-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 6px;
  margin-right: 12px;
  color: var(--color-nav-text);
  cursor: pointer;
  border-radius: 6px;
  opacity: .85;
}
.nav-bell-btn:hover { opacity: 1; }
.nav-bell-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  margin: 0;
}
.notif-panel {
  /* position: fixed with top/left set inline via JS from the bell's position — this
     lets the panel escape .app-nav's overflow-x: hidden (a plain fixed sidebar doesn't
     establish a containing block for fixed descendants, so it isn't clipped). */
  position: fixed;
  width: 340px;
  max-width: calc(100vw - 32px);
  max-height: 420px;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  z-index: 500;
}
.notif-panel.hidden { display: none; }
.notif-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 8px 8px 12px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.notif-tabs { display: flex; gap: 4px; }
.notif-tab {
  background: none;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--color-text-mute);
}
.notif-tab.active { background: rgba(0,120,212,.12); color: var(--color-text); font-weight: 600; }
[data-theme="dark"] .notif-tab.active { background: rgba(26,134,216,.25); }
.notif-mark-all {
  background: none;
  border: none;
  padding: 4px 8px;
  font-size: 12px;
  color: #0078d4;
  cursor: pointer;
}
.notif-mark-all:hover { text-decoration: underline; }
/* Prefixed bell- (not notif-) below to avoid colliding with the unrelated admin
   "Policy Milestones" banner's .notif-list/.notif-item classes further down this file. */
.bell-list { overflow-y: auto; }
.notif-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--color-text-mute);
  font-size: 14px;
}
.bell-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  font-size: 12px;
}
.bell-item:last-child { border-bottom: none; }
.bell-item-msg {
  color: var(--color-text);
  text-decoration: none;
  line-height: 1.4;
  flex: 1;
  min-width: 0;
}
.bell-item-msg:hover { text-decoration: underline; }
/* .bell-item-time { color: var(--color-text-mute); font-size: 10px; margin-top: 3px; } */
.bell-item-actions { flex-shrink: 0; }
.bell-mark-read {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 10px;
  white-space: nowrap;
  cursor: pointer;
  color: var(--color-text-mute);
  white-space: nowrap;
}
.bell-mark-read:hover { color: var(--color-text); border-color: var(--color-text-mute); }
.nav-user-profile {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--color-text);
  border-radius: 6px;
  padding: 3px 4px;
  margin: -3px -4px 2px;
  transition: background .15s;
}
.nav-user-profile:hover,
.nav-user-profile.active { background: rgba(0,0,0,.06); }
[data-theme="dark"] .nav-user-profile:hover,
[data-theme="dark"] .nav-user-profile.active { background: rgba(255,255,255,.07); }
.nav-user-avatar {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--color-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-mute);
}
.user-name {
  display: block;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.badge-role-admin     { color: #c47d00; }
.badge-role-supervisor{ color: #0078d4; }
.badge-role-employee  { color: #107c10; }
.badge-pct-ts {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #0078d4;
  color: #fff;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 700;
  margin-left: 5px;
  vertical-align: middle;
  opacity: .85;
}
.btn-switch-user { margin-left: 8px; background: #0078d4; color: #fff; border-color: #0078d4; }
.btn-switch-user:hover { color: var(--color-text); }
[data-theme="dark"] .btn-switch-user { background: #1a86d8; border-color: #1a86d8; color: #fff; }
[data-theme="dark"] .btn-switch-user:hover { background: #2894e6; border-color: #2894e6; }
.btn-logout {
  display: inline-block;
  margin-top: 6px;
  color: var(--color-text-mute);
  text-decoration: none;
  font-size: 11px;
}
.btn-logout:hover { color: var(--color-text); }

/* ── Impersonation Banner ────────────────────────────────────── */
.impersonation-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 44px;
  background: linear-gradient(90deg, #d97706, #b45309);
  color: #fff;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  flex-shrink: 0;
}
.impersonation-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 900px;
  width: 100%;
}
.impersonation-icon { flex-shrink: 0; opacity: .9; }
.impersonation-text {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.impersonation-text strong { font-weight: 700; }
.impersonation-role-badge {
  display: inline-block;
  background: rgba(255,255,255,.22);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  color: #fff !important;
  margin-left: 4px;
  vertical-align: middle;
}
.btn-switch-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: rgba(255,255,255,.18);
  color: #fff;
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s;
  flex-shrink: 0;
}
.btn-switch-back:hover {
  background: rgba(255,255,255,.32);
  color: #fff;
}
/* Push everything down when banner is visible */
.is-impersonating .app-nav      { top: 44px; }
.is-impersonating .app-main     { margin-top: 44px; height: calc(100vh - 44px); }
.is-impersonating .mobile-topbar{ top: 44px; }

/* ── Main Content ────────────────────────────────────────────── */
.app-main {
  margin-left: var(--nav-width);
  height: 100vh;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
}
.page-login .app-main { margin-left: 0; }

/* Categories page scrolls the full page, not the app-main container */
html:has(body.page-admin_categories) { overflow-y: auto; height: auto; }
.page-admin_categories { overflow-y: auto; height: auto; }
.page-admin_categories .app-main { height: auto; min-height: 100vh; overflow-y: visible; }

/* Voucher pages scroll the full page, not the app-main container */
html:has(body.page-vouchers),
html:has(body.page-admin_vouchers) { overflow-y: auto; height: auto; }
.page-vouchers,
.page-admin_vouchers { overflow-y: auto; height: auto; }
.page-vouchers .app-main,
.page-admin_vouchers .app-main { height: auto; min-height: 100vh; overflow-y: visible; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .12s, opacity .12s;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary   { background: var(--color-primary);  color: #fff; }
.btn-primary:hover   { background: var(--color-primary-dk); }
.btn-success   { background: var(--color-success);  color: #fff; }
.btn-success:hover   { background: #0b5c0b; }
.btn-danger    { background: var(--color-danger);   color: #fff; }
.btn-danger:hover    { background: #b02428; }
.btn-secondary { background: #fff; color: var(--color-text); border-color: var(--color-border); text-decoration: none; }
.btn-secondary:hover { background: var(--color-bg); }
.btn-sm { padding: 4px 10px; font-size: 14px; }
.btn-icon { background: none; border: 1px solid var(--color-border); padding: 5px 10px; }
.btn-ms-login {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: #fff;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: box-shadow .15s;
  width: 100%;
  justify-content: center;
}
.btn-ms-login:hover { box-shadow: 0 2px 8px rgba(0,0,0,.15); }

/* ── Forms ───────────────────────────────────────────────────── */
.form-input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-main);
  font-size: 13px;
  color: var(--color-text);
  background: #fff;
}
.form-input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(0,120,212,.2); }
.form-input-color { padding: 2px; height: 34px; width: 60px; }
.form-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.form-hint, .form-hint-inline { font-size: 11px; color: var(--color-text-mute); }
.form-hint { margin-top: 2px; }
.form-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500;
}
.form-checkbox { width: auto; cursor: pointer; accent-color: var(--color-primary); }
.form-group { margin-bottom: 14px; }
.form-row   { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.form-row.three-col .form-group { flex: 1; }
.form-check { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }
.form-check input[type=checkbox] { width: 14px; height: 14px; cursor: pointer; }
.form-footer { display: flex; gap: 8px; padding-top: 8px; border-top: 1px solid var(--color-border); margin-top: 8px; }
.form-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-mute);
  margin: 16px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--color-border);
}
.search-input { max-width: 280px; }

/* ── Data Tables ─────────────────────────────────────────────── */
.data-table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: #f8f8f7;
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
.data-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #ebebeb;
  vertical-align: middle;
}
.data-table tr:hover td { background: #f5f5f5; }
.loading-cell { text-align: center; color: var(--color-text-mute); padding: 24px; }
.sortable-col { cursor: pointer; user-select: none; }
.sortable-col:hover { background: #efefee; }
.sortable-col.sort-active { color: var(--color-primary, #0078d4); }
.sort-ind { font-size: 10px; opacity: .55; margin-left: 3px; }
.sort-active .sort-ind { opacity: 1; }

/* ── Modals ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: #fff;
  border-radius: 6px;
  padding: 24px;
  width: 520px;
  max-width: 95vw;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.modal-box.modal-lg { width: 720px; }
.modal-close {
  position: absolute;
  top: 12px; right: 14px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--color-text-mute);
}
.modal-close:hover { color: var(--color-text); }
.modal-box h2 { font-size: 16px; margin-bottom: 16px; }
.modal-subtitle { color: var(--color-text-mute); font-size: 12px; margin-top: -10px; margin-bottom: 14px; }

/* ── Confirm dialog ─────────────────────────────────────────── */
.confirm-message {
  font-size: 14px;
  line-height: 1.55;
  color: var(--color-text);
  margin-bottom: 24px;
}
.confirm-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
@media (max-width: 768px) {
  .confirm-buttons { flex-direction: column-reverse; }
  .confirm-buttons .btn { width: 100%; justify-content: center; }
}

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
}
.alert-error   { background: #fde7e9; color: #a4262c; border-left: 3px solid #d13438; }
.alert-warning { background: #fff4ce; color: #7a6200; border-left: 3px solid #c7a800; }
.alert-success { background: #dff6dd; color: #107c10; border-left: 3px solid #107c10; }

/* ── Admin notification accordion ───────────────────────────── */
.notif-banner {
  border: 1px solid var(--color-warning);
  border-radius: var(--radius);
  background: #fffde7;
  overflow: hidden;
}
.notif-banner-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #5a4a00;
  cursor: pointer;
  user-select: none;
}
.notif-banner-title:hover { background: #fff8c0; }
.notif-chevron {
  font-size: 9px;
  display: inline-block;
  transition: transform 0.15s ease;
}
.notif-badge { background: var(--color-warning); }
.notif-accordion-body { padding: 0 14px 12px; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px;
  border-bottom: 1px solid #f0e090;
  font-size: 13px;
}
.notif-item:last-child { border-bottom: none; }
[data-theme="dark"] .notif-banner { background: #2a2200; border-color: var(--color-warning); }
[data-theme="dark"] .notif-banner-title { color: #f5c842; }
[data-theme="dark"] .notif-banner-title:hover { background: #332b00; }
[data-theme="dark"] .notif-item { border-bottom-color: #3a3000; }

/* ── Toast notifications ─────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}
.toast {
  padding: 10px 16px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
  animation: toast-in .2s ease;
  min-width: 220px;
}
.toast-success { background: var(--color-success); }
.toast-error   { background: var(--color-danger); }
.toast-info    { background: var(--color-primary); }
.toast-warning { background: var(--color-warning); color: #222; }
@keyframes toast-in { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:none; } }

/* ── Page headers ────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}
.page-header h1 { font-size: 18px; font-weight: 600; flex: 1; }
.page-subtitle  { color: var(--color-text-mute); font-size: 12px; margin-top: 2px; }
.page-hint, .hint-text { color: var(--color-text-mute); font-size: 12px; margin-bottom: 12px; }

/* Settings page is long — keep the title + Save Settings button in view while scrolling */
.page-admin_settings .page-header {
  position: sticky;
  top: -16px;             /* matches app-main padding so header is flush to viewport top */
  z-index: 50;
  background: var(--color-surface);
  margin-top: -16px;      /* counteract app-main's 16px top padding */
  padding: 12px 10px 10px 10px;
}

/* ── Login page ──────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--color-bg);
}
.login-card {
  background: #fff;
  border-radius: 8px;
  padding: 40px 36px;
  width: 380px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-logo    { font-size: 48px; margin-bottom: 12px; }
.login-title   { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.login-subtitle{ font-size: 13px; color: var(--color-text-mute); margin-bottom: 24px; }
.login-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 18px 0; color: var(--color-text-mute); font-size: 12px;
}
.login-divider::before,
.login-divider::after { content: ''; flex: 1; border-top: 1px solid var(--color-border); }
.login-pw-section { text-align: left; margin-top: 4px; }
.login-pw-section summary {
  font-size: 12px; color: var(--color-text-mute); cursor: pointer;
  text-align: center; list-style: none; padding: 4px 0;
}
.login-pw-section summary::-webkit-details-marker { display: none; }
.login-pw-section summary:hover { color: var(--color-primary); }

/* ── Dashboard stats ─────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: #fff;
  border-radius: 6px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
}
.stat-card.stat-alert { border-left: 3px solid var(--color-danger); }
.stat-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(0,120,212,.10);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}
.stat-icon svg { display: block; }
.stat-card.stat-alert .stat-icon { background: rgba(196,49,75,.10); color: var(--color-danger); }
.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--color-primary); line-height: 1.2; }
.stat-card.stat-alert .stat-value { color: var(--color-danger); }
.stat-label { font-size: 13px; color: var(--color-text-mute); margin-top: 1px; }
.stat-link  { display: block; font-size: 13px; margin-top: 3px; color: var(--color-primary); }
.dashboard-sections { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }
.dash-section { background: #fff; border-radius: 6px; padding: 16px; box-shadow: var(--shadow); }
.chart-wrap {
  position: relative;
  height: 320px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 16px;
}
[data-theme="dark"] .chart-wrap { background: #252a42; border-color: var(--color-border); }
.dash-section h2 { font-size: 14px; margin-bottom: 12px; }
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  color: var(--color-text);
  white-space: nowrap;
}
.quick-btn svg { flex-shrink: 0; }
.quick-btn:hover { background: #e6e6e6; }

/* ── Table filters ───────────────────────────────────────────── */
.table-filters, .pending-filters, .report-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.table-filters .form-input,
.pending-filters .form-input,
.report-filters .form-input { width: auto; }

/* ── Report tabs ─────────────────────────────────────────────── */
.report-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--color-border);
}
.tab-btn {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 14px;
  margin-bottom: -2px;
  color: var(--color-text-mute);
}
.tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }
.report-output  { background: #fff; border-radius: 6px; padding: 0 16px 16px; box-shadow: var(--shadow); min-height: 200px; max-height: 72vh; overflow-x: auto; overflow-y: auto; }
.report-output.alloc-split-mode { display: flex; gap: 16px; overflow: visible; max-height: none; padding: 0; background: transparent; box-shadow: none; min-height: 0; }
.alloc-panel { background: #fff; border-radius: 6px; padding: 0 16px 16px; box-shadow: var(--shadow); overflow-x: auto; overflow-y: auto; max-height: 72vh; }
.alloc-panel:first-child { flex: 1 1 0; min-width: 0; }
.alloc-panel:last-child  { flex: 0 0 260px; }
.report-totals-row td { font-weight: 700; border-top: 2px solid #b0bec5; background: #f0f4f8; }
.due-date-summary-table thead, .allocation-summary-table thead { position: sticky; top: 0; z-index: 3; }
.due-date-summary-table thead th, .allocation-summary-table thead th { position: static; top: auto; z-index: auto; }
.due-date-period-row th { font-weight: normal; color: #888; border-bottom: 1px solid var(--color-border); }

@media (max-width: 768px) {
  .report-output.alloc-split-mode { flex-direction: column; }
  .alloc-panel:first-child,
  .alloc-panel:last-child { flex: 1 1 auto; width: 100%; max-height: 60vh; }
}
@media (max-width: 768px) {
  .report-tabs {
    flex-wrap: wrap;
    gap: 6px;
    border-bottom: none;
    margin-bottom: 10px;
  }
  .tab-btn {
    border: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    border-radius: 20px;
    margin-bottom: 0;
    padding: 6px 14px;
    font-size: 12px;
    background: #f4f6f9;
  }
  .tab-btn.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
    border-bottom-color: var(--color-primary);
  }
}

/* ── Settings ────────────────────────────────────────────────── */
.settings-sections { display: flex; flex-direction: column; gap: 20px; max-width: 700px; }
.settings-section  { background: #fff; border-radius: 6px; padding: 20px; box-shadow: var(--shadow); }
.settings-section h2 { font-size: 15px; margin-bottom: 4px; }
.section-hint { font-size: 12px; color: var(--color-text-mute); margin-bottom: 14px; }

/* Settings sections are collapsible <details> — arrow sits left of the title */
.settings-section > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.settings-section > summary::-webkit-details-marker { display: none; }
.settings-section > summary h2 { margin: 0; }
.settings-accordion-arrow {
  font-size: 9px;
  display: inline-block;
  flex-shrink: 0;
  transition: transform .15s;
  color: var(--color-text-mute);
}
.settings-accordion-arrow::before { content: '▶'; }
.settings-section[open] > summary .settings-accordion-arrow { transform: rotate(90deg); }
.settings-section > summary:hover .settings-accordion-arrow { color: var(--color-text); }
.settings-section-body { margin-top: 14px; }
.settings-footer { margin-top: 16px; display: flex; align-items: center; gap: 12px; }
.save-status { font-size: 12px; color: var(--color-success); }

/* ── Leave type tabs ─────────────────────────────────────────── */
.leave-type-tabs { display: flex; gap: 4px; margin-bottom: 12px; }

/* ── Column sort list ────────────────────────────────────────── */
.col-sort-list { list-style: none; }
.col-sort-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 4px;
  cursor: grab;
}
.col-sort-list li .drag-handle { color: #bbb; cursor: grab; }
.col-sort-list li label { flex: 1; font-size: 13px; cursor: pointer; }

/* ── Pending approvals ───────────────────────────────────────── */
.pending-list { display: flex; flex-direction: column; gap: 8px; max-width: 780px; }
.pending-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.pending-card { cursor: pointer; }
.pending-card:hover { border-color: var(--color-primary); }
.pending-name  { font-weight: 600; }
.pending-meta  { font-size: 12px; color: var(--color-text-mute); }
.pending-period{ font-size: 13px; color: var(--color-text-mute); }
.pending-hours { font-size: 13px; font-weight: 600; color: var(--color-text); white-space: nowrap; }

/* ── Profile page ────────────────────────────────────────────── */
.profile-layout { display: flex; flex-direction: column; gap: 24px; max-width: 600px; }
.profile-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 24px;
}
.profile-section-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.profile-actions { display: flex; align-items: center; gap: 12px; margin-top: 20px; }

/* Timesheet preference radio cards */
.pref-radio-group { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.pref-radio-option {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.pref-radio-option:hover { border-color: var(--color-primary); background: rgba(0,120,212,.04); }
.pref-radio-option.selected { border-color: var(--color-primary); background: rgba(0,120,212,.05); }
.pref-radio-option input[type=radio] { margin-top: 3px; flex-shrink: 0; accent-color: var(--color-primary); width: 16px; height: 16px; cursor: pointer; }
.pref-radio-content { display: flex; flex-direction: column; gap: 3px; }
.pref-radio-content strong { font-size: 14px; color: var(--color-text); }
.pref-radio-content span { font-size: 13px; color: var(--color-text-mute); line-height: 1.4; }
[data-theme="dark"] .pref-radio-option:hover  { background: rgba(91,168,245,.07); }
[data-theme="dark"] .pref-radio-option.selected { background: rgba(91,168,245,.1); }

/* Save button highlight when keyboard nav reaches it */
.ts-save-ready {
  outline: 2px solid var(--color-primary) !important;
  box-shadow: 0 0 0 4px rgba(0,120,212,.25) !important;
}
[data-theme="dark"] .ts-save-ready { box-shadow: 0 0 0 4px rgba(91,168,245,.3) !important; }

/* Signature within profile card */
.sig-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--color-border);
}
.sig-tab-btn {
  padding: 8px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-mute);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.sig-tab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.sig-font-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.sig-font-btn {
  font-size: 21px;
  padding: 4px 14px;
  border: 2px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  cursor: pointer;
  color: var(--color-text);
  transition: border-color .15s, background .15s;
}
.sig-font-btn.active { border-color: var(--color-primary); background: #e3f2fd; }
[data-theme="dark"] .sig-font-btn.active { background: #1a3a5c; }
.sig-canvas {
  border-radius: 4px;
  display: block;
  max-width: 100%;
}
.sig-canvas-preview { border: 1px solid var(--color-border); background: repeating-linear-gradient(45deg,#f8f8f8,#f8f8f8 10px,#fff 10px,#fff 20px); }
.sig-canvas-draw    { border: 2px solid var(--color-border); cursor: crosshair; touch-action: none; background: repeating-linear-gradient(45deg,#f8f8f8,#f8f8f8 10px,#fff 10px,#fff 20px); }
[data-theme="dark"] .sig-canvas-preview { background: #f0f0f0; }
[data-theme="dark"] .sig-canvas-draw { background: repeating-linear-gradient(45deg,#1e2235,#1e2235 10px,#252a3d 10px,#252a3d 20px); }
.sig-saved-img { max-height: 80px; border: 1px solid var(--color-border); border-radius: 4px; padding: 6px; background: #fff; }

@media (max-width: 480px) {
  .form-row-2 { grid-template-columns: 1fr; }
}

/* ── Allocation defaults (profile + timesheet banner) ─────────── */
.pct-defaults-grid    { display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.pct-defaults-row     { display: flex; align-items: center; gap: 10px; }
.pct-defaults-swatch  { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.pct-defaults-name    { flex: 1; font-size: 13px; }
.pct-defaults-input-wrap { display: flex; align-items: center; gap: 4px; }
.pct-defaults-input   { width: 64px; text-align: right; padding: 4px 6px; }
.hint-ok   { color: #107c10; }
.hint-warn { color: #a4262c; }

.pct-defaults-banner  { display: none; }
.pct-banner-inner     { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
                         background: var(--color-surface); border: 1px solid var(--color-border);
                         border-radius: 6px; padding: 8px 14px; margin-bottom: 10px; font-size: 13px; }
.pct-banner-label     { font-weight: 600; color: var(--color-text-mute); white-space: nowrap; }
.pct-banner-summary   { color: var(--color-text); flex: 1; }
.pct-banner-none      { color: var(--color-text-mute); font-style: italic; }
.pct-banner-btn       { margin-left: auto; white-space: nowrap; }

/* ── Review tabs (admin pending) ─────────────────────────────── */
.ts-review-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 2px solid var(--color-border); }
.ts-review-tab  {
  padding: 8px 18px;
  border: none;
  background: transparent;
  color: var(--color-text-mute);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.ts-review-tab:hover { color: var(--color-text); }
.ts-review-tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }
.ts-review-tab-count {
  display: inline-block;
  background: var(--color-border);
  color: var(--color-text-mute);
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: middle;
}
.ts-review-tab.active .ts-review-tab-count { background: var(--color-primary); color: #fff; }
[data-theme="dark"] .ts-review-tab.active { color: #60a5fa; border-bottom-color: #60a5fa; }
[data-theme="dark"] .ts-review-tab.active .ts-review-tab-count { background: #60a5fa; color: #0f172a; }

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

/* ── Status badges ───────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.status-draft     { background: #e8e8e8;  color: #666; }
.status-submitted { background: #cfe2ff;  color: #0a3069; }
.status-approved  { background: #dff6dd;  color: #107c10; }
.status-rejected  { background: #fde7e9;  color: #a4262c; }
.status-not_started { background: #f5f5f5; color: #999; }
.status-payroll   { background: #ede7f6;  color: #5e35b1; }

/* ── Comments ────────────────────────────────────────────────── */
.comments-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.comment-item {
  padding: 8px 12px;
  border-radius: var(--radius);
  border-left: 3px solid var(--color-border);
  background: var(--color-bg);
}
.comment-item.action-approved  { border-left-color: var(--color-success); }
.comment-item.action-rejected  { border-left-color: var(--color-danger); }
.comment-item.action-submitted { border-left-color: var(--color-primary); }
.comment-meta  { font-size: 11px; color: var(--color-text-mute); margin-bottom: 2px; }
.comment-text  { font-size: 13px; }
.comment-form  { display: flex; flex-direction: column; gap: 6px; }
.comment-form textarea { font-family: var(--font-main); }

/* ── Error page ──────────────────────────────────────────────── */
.error-page { text-align: center; padding: 60px 20px; }
.error-code { font-size: 80px; font-weight: 700; color: #e0e0e0; }
.error-page h1 { font-size: 24px; margin-bottom: 12px; }

/* ── Dark Theme ──────────────────────────────────────────────── */
/*    "Dim" — comfortably dark, not near-black                   */
[data-theme="dark"] {
  --color-primary:    #5ba8f5;
  --color-primary-dk: #4890e0;
  --color-success:    #56c464;
  --color-danger:     #f07070;
  --color-warning:    #f5c842;
  --color-bg:         #2b2f45;
  --color-surface:    #353a54;
  --color-border:     #4a5070;
  --color-text:       #dce3f5;
  --color-text-mute:  #909ab8;
  --color-nav-bg:     #22253a;
  --color-nav-text:   #dce3f5;
  --color-nav-hover:  #2d3250;
  --color-nav-active: #5ba8f5;
  --shadow:           0 2px 10px rgba(0,0,0,0.35);
}

/* Smooth transition when switching */
html, body, .app-nav, .modal-box, .stat-card, .dash-section,
.report-output, .settings-section, .pending-card, .form-input,
.data-table th, .data-table td {
  transition: background-color .25s ease, color .2s ease, border-color .2s ease;
}

/* Surfaces that use hardcoded #fff */
[data-theme="dark"] .btn-secondary        { background: #404666; color: var(--color-text); border-color: var(--color-border); }
[data-theme="dark"] .btn-secondary:hover  { background: #4a5070; }
[data-theme="dark"] .btn-ms-login         { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
[data-theme="dark"] .form-input           { background: #252840; color: var(--color-text); border-color: var(--color-border); }
[data-theme="dark"] .form-input:focus     { border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(91,168,245,.2); }
[data-theme="dark"] .modal-box            { background: var(--color-surface); }
[data-theme="dark"] .login-card           { background: var(--color-surface); }
[data-theme="dark"] .stat-card            { background: var(--color-surface); }
[data-theme="dark"] .stat-icon           { background: rgba(0,120,212,.18); }
[data-theme="dark"] .stat-card.stat-alert .stat-icon { background: rgba(196,49,75,.18); }
[data-theme="dark"] .badge-role-admin      { color: #f9a825; }
[data-theme="dark"] .badge-role-supervisor { color: #64b5f6; }
[data-theme="dark"] .badge-role-employee   { color: #a5d6a7; }
[data-theme="dark"] .dash-section         { background: var(--color-surface); }
[data-theme="dark"] .report-output        { background: var(--color-surface); }
[data-theme="dark"] .report-output.alloc-split-mode { background: transparent; }
[data-theme="dark"] .alloc-panel          { background: var(--color-surface); }
[data-theme="dark"] .pdf-packet-desc      { color: #fff !important; }
[data-theme="dark"] .mobile-topbar        { box-shadow: 0 1px 6px rgba(0,0,0,.35); }
[data-theme="dark"] .report-totals-row td { background: #404666; border-top-color: var(--color-border); }
[data-theme="dark"] .settings-section     { background: var(--color-surface); }
[data-theme="dark"] .pending-card         { background: var(--color-surface); border-color: var(--color-border); }
[data-theme="dark"] .col-sort-list li     { background: var(--color-bg); border-color: var(--color-border); }
[data-theme="dark"] .comment-item         { background: #2b2f45; }
[data-theme="dark"] .quick-btn            { background: #404666; color: var(--color-text); border-color: var(--color-border); }
[data-theme="dark"] .quick-btn:hover      { background: #4a5070; }
[data-theme="dark"] .data-table th        { background: #404666; color: var(--color-text); border-bottom-color: var(--color-border); }
[data-theme="dark"] .data-table td        { border-bottom-color: var(--color-border); }
[data-theme="dark"] .data-table tr:hover td { background: #3d4260; }
[data-theme="dark"] .sortable-col:hover   { background: #4a5070; }
[data-theme="dark"] .alert-error          { background: #4a2828; color: #f5aaaa; }
[data-theme="dark"] .alert-warning        { background: #3d3520; color: #f5d080; }
[data-theme="dark"] .alert-success        { background: #253828; color: #90d89a; }
[data-theme="dark"] .status-draft         { background: #404666; color: #909ab8; }
[data-theme="dark"] .status-submitted     { background: #28355a; color: #90bff5; }
[data-theme="dark"] .status-approved      { background: #253828; color: #90d89a; }
[data-theme="dark"] .status-rejected      { background: #4a2828; color: #f5aaaa; }
[data-theme="dark"] .status-payroll       { background: #2a2140; color: #b39ddb; }

/* Theme toggle button in nav */
.btn-theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 16px;
  background: none;
  border: none;
  color: var(--color-nav-text);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  opacity: .75;
}
.btn-theme-toggle:hover { opacity: 1; background: var(--color-nav-hover); }
.theme-icon { font-size: 14px; }

/* ── Mobile elements (hidden on desktop) ─────────────────────── */
.mobile-topbar  { display: none; }
.hamburger-btn  { display: none; }
.mobile-theme-btn { display: none; }
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 190;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.nav-backdrop.visible { opacity: 1; pointer-events: auto; }

/* ── Responsive: mobile nav drawer + layout ──────────────────── */
@media (max-width: 768px) {
  #nav-sidebar-toggle { display: none; }
  /* Top bar */
  .mobile-topbar {
    display: flex;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    background: var(--color-nav-bg);
    border-bottom: 1px solid var(--color-border);
    align-items: center;
    padding: 0 6px;
    gap: 2px;
    z-index: 150;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
  }
  .mobile-page-title {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    color: var(--color-nav-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 4px;
  }
  .hamburger-btn, .mobile-theme-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    color: var(--color-nav-text);
    cursor: pointer;
    border-radius: var(--radius);
    flex-shrink: 0;
    touch-action: manipulation;
  }
  .hamburger-btn:hover, .mobile-theme-btn:hover { background: var(--color-nav-hover); }

  /* Nav slides in as a drawer */
  .app-nav {
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4, 0, .2, 1);
    z-index: 200;
    width: 260px;
    box-shadow: none;
  }
  .app-nav.nav-open {
    transform: translateX(0);
    box-shadow: 6px 0 24px rgba(0,0,0,.25);
  }

  /* Switch to native page scroll — fixed-height overflow-y containers
     are unreliable for touch scrolling on iOS / Android              */
  html, body {
    overflow-y: auto;
    height: auto;
  }

  /* Main content shifts up under topbar */
  .app-main {
    margin-left: 0;
    padding-top: calc(var(--header-h) + 14px);
    height: auto;
    min-height: 100vh;
    overflow-y: visible;
  }
  .page-login .app-main { padding-top: 0; }

  /* Impersonation banner on mobile */
  .impersonation-banner { height: auto; min-height: 40px; padding: 6px 12px; }
  .impersonation-inner  { flex-wrap: wrap; gap: 6px; }
  .impersonation-text   { font-size: 12px; }
  .btn-switch-back      { font-size: 11px; padding: 3px 10px; }
  .is-impersonating .mobile-topbar { top: 40px; }
  .is-impersonating .app-main      { padding-top: calc(var(--header-h) + 40px + 14px); margin-top: 0; height: auto; }

  /* Layout adjustments */
  .dashboard-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-sections { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 0; }
  .page-header { flex-wrap: wrap; }
  /* Pending card: stack name+meta / period+meta on left, button on right */
  .pending-card {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 4px 10px;
  }
  .pending-card > div:first-child  { grid-column: 1; grid-row: 1; }
  .pending-card .pending-period    { grid-column: 1; grid-row: 2; }
  .pending-card .pending-hours     { grid-column: 1; grid-row: 2; display: inline; margin-left: 8px; }
  .pending-card .pending-meta:last-of-type { display: none; } /* hide "Submitted X" date on mobile */
  .pending-card .btn-open-review   { grid-column: 2; grid-row: 1 / span 2; align-self: center; }

  /* Pending filters: scroll horizontally */
  .pending-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  .pending-filters::-webkit-scrollbar { display: none; }
  .pending-filters .form-input { flex-shrink: 0; }

  /* Modals become bottom sheets on mobile */
  .modal-overlay {
    align-items: flex-end;
    justify-content: stretch;
  }
  .modal-box,
  .modal-box.modal-lg {
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    border-radius: 16px 16px 0 0;
    padding: 20px 16px 32px;
    /* slide-up animation */
    animation: sheet-up .28s cubic-bezier(.4,0,.2,1);
  }
  @keyframes sheet-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  /* Handle bar at top of sheet */
  .modal-box::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    margin: 0 auto 16px;
  }
  .modal-close { top: 16px; }

  /* Filter bars scroll horizontally instead of wrapping */
  #tor-filter-bar, #tora-filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  #tor-filter-bar::-webkit-scrollbar,
  #tora-filter-bar::-webkit-scrollbar { display: none; }

  /* Hide desktop action buttons — FAB replaces them */
  .btn-new-tor-desktop,
  .btn-add-user-desktop,
  .btn-add-dd-desktop { display: none; }

  /* Bigger tap targets */
  .btn { min-height: 36px; }
  .btn-sm { min-height: 30px; }
  .nav-links > li > a,
  .nav-links ul li a { padding: 10px 16px; }
  .nav-group ul li a { padding: 10px 16px 10px 28px; }
}

/* ── Pull-to-refresh indicator ───────────────────────────────────────────── */
#ptr-indicator {
  display: none;
  position: fixed;
  top: 0; left: 50%;
  transform: translate(-50%, -48px);
  width: 40px; height: 40px;
  background: var(--color-surface);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  align-items: center;
  justify-content: center;
  z-index: 300;
  transition: transform .15s ease;
}
#ptr-indicator.ptr-visible { display: flex; }
.ptr-spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  transition: border-color .2s;
}
#ptr-indicator.ptr-ready .ptr-spinner { border-top-color: var(--color-success); }
#ptr-indicator.ptr-spinning .ptr-spinner { animation: ptr-spin .7s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* ── Floating Action Button (mobile only) ────────────────────────────────── */
.fab {
  display: none;
}
@media (max-width: 768px) {
  .fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 24px; right: 20px;
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: 26px;
    line-height: 1;
    border: none;
    box-shadow: 0 4px 14px rgba(0,0,0,.25);
    z-index: 90;
    cursor: pointer;
    touch-action: manipulation;
  }
  .fab:hover { background: var(--color-primary-dk); }
}

/* ── Time Off Requests ───────────────────────────────────────────────────── */
.tora-section-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-mute);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}
.tor-filter-btn {
  padding: 5px 14px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  color: var(--color-text-mute);
  transition: all .15s;
}
.tor-filter-btn.active,
.tor-filter-btn:hover {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.tor-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  max-width: 820px;
}
.tor-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,.10); border-color: var(--color-primary); }
.tor-card-stripe { width: 4px; min-height: 54px; border-radius: 3px; flex-shrink: 0; }
.tor-card-body { flex: 1; min-width: 0; }
.tor-card-top { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:4px; }
.tor-card-type { font-weight: 700; font-size: 14px; }
.tor-card-dates { font-size: 13px; color: var(--color-text-mute); }
.tor-card-hrs { font-size: 13px; font-weight: 600; color: var(--color-text); margin-left:auto; }
.tor-card-reason { font-size: 12px; color: var(--color-text-mute); margin-top:4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:480px; }
.tor-card-actions { display:flex; gap:8px; margin-top:10px; }
.tor-badge { display:inline-block; padding:2px 10px; border-radius:12px; font-size:11px; font-weight:700; }
.tor-badge-draft     { background:#f0f0f0; color:#666; }
.tor-badge-submitted { background:#fff8e1; color:#d06c00; }
.tor-badge-in_review { background:#e3f2fd; color:#0d47a1; }
.tor-badge-approved  { background:#e8f5e9; color:#1b5e20; }
.tor-badge-rejected  { background:#fce4ec; color:#c62828; }
.tor-empty { text-align:center; padding: 48px 20px; color: var(--color-text-mute); }
.tor-empty-icon { display:flex; justify-content:center; margin-bottom:12px; opacity:.45; }
.tor-detail-table { width:100%; border-collapse:collapse; margin:14px 0; }
.tor-detail-table th { text-align:left; padding:8px 10px; background:var(--color-bg); font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.06em; color:var(--color-text-mute); width:36%; border-bottom:1px solid var(--color-border); }
.tor-detail-table td { padding:9px 10px; border-bottom:1px solid var(--color-border); font-size:13px; }
.tor-detail-table tr:last-child th, .tor-detail-table tr:last-child td { border-bottom:none; }
.tor-comment { padding:10px 14px; background:var(--color-bg); border-radius:6px; margin-bottom:8px; }
.tor-comment-meta { font-size:11px; color:var(--color-text-mute); margin-bottom:4px; }
.tor-comment-text { font-size:13px; }
[data-theme="dark"] .tor-card { background: var(--color-surface); border-color: var(--color-border); }
[data-theme="dark"] .tor-filter-btn { background: var(--color-surface); border-color: var(--color-border); color: var(--color-text-mute); }
[data-theme="dark"] .tor-filter-btn.active,
[data-theme="dark"] .tor-filter-btn:hover { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
[data-theme="dark"] .tor-badge-draft     { background:#3a3a3a; color:#bbb; }
[data-theme="dark"] .tor-badge-submitted { background:#4a3a00; color:#f9c25a; }
[data-theme="dark"] .tor-badge-in_review { background:#00265a; color:#82b1ff; }
[data-theme="dark"] .tor-badge-approved  { background:#1a3a1a; color:#81c784; }
[data-theme="dark"] .tor-badge-rejected  { background:#4a1a1a; color:#ef9a9a; }
[data-theme="dark"] .tor-detail-table th { background: var(--color-bg); color: var(--color-text-mute); border-color: var(--color-border); }
[data-theme="dark"] .tor-detail-table td { border-color: var(--color-border); color: #fff; }
[data-theme="dark"] .tor-comment { background: var(--color-bg); }

/* ── Who's Out Calendar ──────────────────────────────────────────────────── */
.tora-cal-header { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:10px; margin-bottom:14px; }
.tora-cal-controls { display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.tora-cal-nav {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 3px 11px;
  font-size: 20px;
  line-height: 1.2;
  cursor: pointer;
  color: var(--color-text-mute);
  transition: background .12s, color .12s;
}
.tora-cal-nav:hover { background: var(--color-bg); color: var(--color-text); }
.tora-cal-label { font-size: 13px; font-weight: 600; min-width: 170px; text-align: center; color: var(--color-text); }
.tora-cal-view-toggle { display:flex; border:1px solid var(--color-border); border-radius:4px; overflow:hidden; margin-left:2px; }
.tora-cal-view-btn {
  background: var(--color-surface);
  border: none;
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--color-text-mute);
  transition: background .12s, color .12s;
}
.tora-cal-view-btn.active { background: var(--color-primary); color: #fff; }
.tora-cal-view-btn:not(.active):hover { background: var(--color-bg); color: var(--color-text); }

.tora-cal-wrap { overflow-x: auto; }
.tora-cal-grid { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 420px; }
.tora-cal-grid th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-mute);
  padding: 6px 6px 8px;
  text-align: center;
  border-bottom: 2px solid var(--color-border);
}
.tora-cal-cell {
  vertical-align: top;
  padding: 5px 5px 6px;
  border: 1px solid var(--color-border);
  min-height: 48px;
  background: var(--color-surface);
}
.tora-cal-today { background: rgba(0,120,212,.05); }
.tora-cal-weekend { background: var(--color-bg); }
.tora-cal-other-month { background: var(--color-bg); opacity: .7; }
.tora-cal-day-num {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-mute);
  text-align: right;
  margin-bottom: 4px;
  line-height: 1;
}
.tora-cal-day-num.today {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 10px;
  float: right;
}
.tora-cal-pill {
  display: block;
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
  line-height: 1.5;
  cursor: default;
}
.tora-cal-more { display:block; font-size:10px; color:var(--color-text-mute); padding:1px 2px; }
.tora-cal-empty-msg { text-align:center; padding:24px 0; color:var(--color-text-mute); font-size:13px; font-style:italic; }
.tora-cal-loading { display:flex; align-items:center; justify-content:center; padding:30px 0; }

[data-theme="dark"] .tora-cal-nav { background: var(--color-surface); border-color: var(--color-border); }
[data-theme="dark"] .tora-cal-nav:hover { background: var(--color-bg); }
[data-theme="dark"] .tora-cal-view-btn { background: var(--color-surface); }
[data-theme="dark"] .tora-cal-cell { background: var(--color-surface); border-color: var(--color-border); }
[data-theme="dark"] .tora-cal-today { background: rgba(0,120,212,.12); }
[data-theme="dark"] .tora-cal-weekend { background: var(--color-bg); }
[data-theme="dark"] .tora-cal-other-month { background: var(--color-bg); }

@media (max-width: 768px) {
  /* Cards fill full width, slightly bigger touch target */
  .tor-card { padding: 14px 14px; margin-bottom: 8px; }
  .tor-card-actions { flex-wrap: wrap; }
  .tor-card-actions .btn-sm { flex: 1; min-width: 70px; justify-content: center; }
  .tor-card-reason { max-width: 100%; white-space: normal; }

  /* Bottom sheet handle already added via ::before — also push title down slightly */
  .modal-box h2 { margin-top: 4px; }

  .tora-cal-label { min-width: 120px; }
}

/* ── Due date cards (admin due dates page, mobile) ───────────────────────── */
.dd-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-bottom: 8px;
  display: flex;
  align-items: stretch;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  overflow: hidden;
}
.dd-card-past { opacity: 0.5; }
.dd-card-stripe { width: 4px; flex-shrink: 0; }
.dd-card-body { flex: 1; padding: 12px 14px; }
.dd-card-date { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.dd-card-label { font-size: 12px; color: var(--color-text-mute); margin-bottom: 4px; }
.dd-card-meta { font-size: 11px; color: var(--color-text-mute); margin-bottom: 10px; }
.dd-card-actions { display: flex; align-items: center; gap: 8px; }
.dd-card-past-badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--color-text-mute);
}
[data-theme="dark"] .dd-card { background: var(--color-surface); border-color: var(--color-border); }

.favicon-upload-row {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
}
.favicon-preview-box {
  width: 48px;
  height: 48px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  flex-shrink: 0;
  padding: 6px;
}
.favicon-upload-controls { flex: 1; min-width: 220px; }

.dd-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.dd-filter-bar label { font-size: 13px; font-weight: 600; white-space: nowrap; }
.dd-filter-year-sel { width: auto; min-width: 120px; padding: 5px 10px; font-size: 13px; }

/* ── User cards (admin users page, mobile) ───────────────────────────────── */
.user-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.user-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.user-card-name   { font-weight: 700; font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card-role   { flex-shrink: 0; }
.user-card-email  { font-size: 12px; color: var(--color-text-mute); margin-bottom: 4px; }
.user-card-details{ display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.user-card-meta   { font-size: 12px; color: var(--color-text-mute); }
.user-card-actions{ display: flex; gap: 8px; }
.user-card-actions .btn { flex: 1; justify-content: center; }
[data-theme="dark"] .user-card { background: var(--color-surface); border-color: var(--color-border); }

/* ── Admin generic cards (categories, leave policies — mobile) ───────────── */
.admin-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.admin-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.admin-card-name {
  font-weight: 700;
  font-size: 14px;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.admin-card-meta {
  font-size: 12px;
  color: var(--color-text-mute);
  margin-bottom: 4px;
}
.admin-card-meta-strong {
  font-weight: 600;
  color: var(--color-text);
}
.admin-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.admin-card-actions .btn { flex: 1; justify-content: center; }
.admin-card-color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}
[data-theme="dark"] .admin-card { background: var(--color-surface); border-color: var(--color-border); }

/* ── Admin / Supervisor pages — mobile ──────────────────────────────────── */
@media (max-width: 768px) {
  /* Tables scroll horizontally with touch momentum */
  .data-table-wrap {
    -webkit-overflow-scrolling: touch;
    border-radius: 6px;
  }
  /* Minimum column widths so content doesn't collapse */
  .data-table th,
  .data-table td { white-space: nowrap; }

  /* Filter bars scroll horizontally */
  .table-filters .form-input,
  .report-filters .form-input { flex-shrink: 0; }

  /* Page header: title on top, action button below */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .page-header h1 { font-size: 20px; }

  /* Dashboard stat grid: 2 columns */
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card  { padding: 12px 14px; gap: 12px; }
  .stat-icon  { width: 34px; height: 34px; }
  .stat-value { font-size: 20px; }

  /* Dashboard sections stack */
  .dashboard-sections { grid-template-columns: 1fr; }

  /* Report output: scrollable */
  .report-output { max-height: 60vh; }

  /* Leave policy / categories tables: same horizontal scroll treatment */
  .settings-section { padding: 16px; }

  /* Action buttons in table cells: stack if multiple */
  .data-table td .btn + .btn { margin-left: 4px; }
}

/* ── Year-End Rollover Modal ─────────────────────────────────────────────── */
.yer-explainer {
  background: var(--color-bg);
  border-radius: 6px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid var(--color-border);
}
.yer-explainer p { margin-bottom: 8px; }
.yer-explainer ul { padding-left: 18px; margin: 0; }
.yer-explainer li { margin-bottom: 4px; }

.yer-rules { margin-top: 14px; }
.yer-rules-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-mute);
  margin-bottom: 8px;
}
.yer-rules-list { display: flex; flex-direction: column; gap: 6px; }
.yer-rule-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 7px 12px;
}
.yer-rule-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.yer-rule-name { font-weight: 600; flex: 1; }
.yer-rule-cap  { font-size: 12px; color: var(--color-text-mute); text-align: right; }

[data-theme="dark"] .yer-explainer { background: var(--color-bg); border-color: var(--color-border); }
[data-theme="dark"] .yer-rule-row  { background: var(--color-bg); border-color: var(--color-border); }

/* ── Select2 dark mode (global) ──────────────────────────────── */
[data-theme="dark"] .select2-dropdown {
  background: #353a54;
  border-color: #4a5070;
  color: #dce3f5;
}
[data-theme="dark"] .select2-search--dropdown .select2-search__field,
[data-theme="dark"] .select2-search--inline .select2-search__field {
  background: #2b2f45;
  border-color: #4a5070;
  color: #dce3f5;
  outline: none;
}
[data-theme="dark"] .select2-results__option {
  color: #dce3f5;
}
[data-theme="dark"] .select2-results__option--highlighted {
  background: #0078d4 !important;
  color: #fff !important;
}
.select2-container--default .select2-results__option[aria-selected="true"] {
  background-color: #e8f4e8 !important;
  color: #1a5c1a !important;
}
[data-theme="dark"] .select2-container--default .select2-results__option[aria-selected="true"] {
  background: #1e3d1e !important;
  color: #7dd87d !important;
}
.sel2-check { color: #2e7d32; font-weight: 700; }
[data-theme="dark"] .sel2-check { color: #7dd87d; }
[data-theme="dark"] .select2-results__message {
  color: #909ab8;
}
/* Single-select closed box */
[data-theme="dark"] .select2-container--default .select2-selection--single {
  background: #2b2f45 !important;
  border-color: #4a5070 !important;
}
[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered {
  color: #dce3f5 !important;
}
[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__placeholder {
  color: #909ab8 !important;
}
[data-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__arrow b {
  border-color: #909ab8 transparent transparent transparent;
}
/* Multi-select container and pills */
[data-theme="dark"] .select2-container--default .select2-selection--multiple {
  background: #2b2f45 !important;
  border-color: #4a5070 !important;
}
[data-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice {
  background: #3a3f5c !important;
  border-color: #4a5070 !important;
  color: #dce3f5 !important;
}
[data-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice__display {
  color: #dce3f5 !important;
}
[data-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
  color: #909ab8 !important;
  border-color: #4a5070 !important;
}
[data-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
  background: #e74c3c !important;
  color: #fff !important;
}

/* Remove number input spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
