:root {
  --z-content: 1;
  --z-topbar: 100;
  --z-sidebar-backdrop: 900;
  --z-sidebar: 910;

  --z-dropdown: 1000;

  --z-modal-backdrop: 1040;
  --z-modal: 1050;

  --z-toast: 1080;
  --z-alertify: 1090;

  --bs-modal-padding: 20px;
}

:root,
[data-bs-theme="light"] {

  /* Backgrounds */
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-alt: #f5f5f5;
  --surface-muted: #eeeeee;

  /* Sidebar */
  --sidebar-bg: #ffffff;
  --sidebar-bg-2: #f8f9fa;
  --sidebar-border: #e5e7eb;
  --sidebar-text: #3c4043;
  --sidebar-text-muted: #5f6368;
  --sidebar-hover: #f1f3f4;
  --sidebar-active: #1a73e8;
  --sidebar-active-text: #ffffff;

  /* Text */
  --text: #202124;
  --muted: #5f6368;
  --border: #dadce0;

  /* Brand */
  --primary: #1a73e8;
  --primary-contrast: #ffffff;

  --accent: #0f9d58;
  --accent-contrast: #ffffff;

  --danger: #d93025;
  --danger-contrast: #ffffff;

  --shadow: 0 1px 3px rgba(60, 64, 67, .15),
    0 4px 8px rgba(60, 64, 67, .12);

  --sidebar-width: 280px;
  --sidebar-width-collapsed: 86px;
  --topbar-height: 72px;
  --radius-lg: 18px;
  --radius-md: 12px;

  /* Bootstrap */
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-heading-color: #202124;
  --bs-border-color: var(--border);

  --bs-primary: #1a73e8;
  --bs-secondary: #5f6368;
  --bs-success: #188038;
  --bs-info: #1a73e8;
  --bs-warning: #f9ab00;
  --bs-danger: #d93025;

  --bs-light: #f8f9fa;
  --bs-dark: #202124;

  --bs-nav-pills-link-active-color: #ffffff;
  --bs-nav-pills-link-active-bg: var(--accent);

  --bs-link-color: #1a73e8;
  --bs-link-hover-color: #185abc;
}

/* Solarized Dark (unchanged except minor cleanup) */

[data-bs-theme="dark"] {

  --bg: #002b36;
  --surface: #073642;
  --surface-alt: #002b36;
  --surface-muted: #073642;

  /* Sidebar */
  --sidebar-bg: #00252f;
  --sidebar-bg-2: #002b36;
  --sidebar-border: #073642;
  --sidebar-text: #93a1a1;
  --sidebar-text-muted: #839496;
  --sidebar-hover: #073642;
  --sidebar-active: #268bd2;
  --sidebar-active-text: #ffffff;

  --text: #839496;
  --muted: #586e75;
  --border: #073642;

  --primary: #268bd2;
  --accent: #2aa198;
  --danger: #dc322f;

  --bs-body-bg: var(--bg);
  --bs-body-bg-rgb: 0, 43, 54;

  --bs-body-color: var(--text);
  --bs-body-color-rgb: 131, 148, 150;

  --bs-heading-color: #93a1a1;
  --bs-border-color: var(--border);

  --bs-primary: #268bd2;
  --bs-secondary: #586e75;
  --bs-success: #859900;
  --bs-info: #2aa198;
  --bs-warning: #b58900;
  --bs-danger: #dc322f;

  --bs-light: #073642;
  --bs-dark: #002b36;

  --bs-secondary-bg: #002b36;
  --bs-tertiary-bg: #073642;

  --bs-nav-pills-link-active-color: #ffffff;
  --bs-nav-pills-link-active-bg: var(--accent);
}

/* Ensure cards and widgets adopt the proper Solarized surface colors */
.card,
.modal-content,
.dropdown-menu {
  background-color: var(--bs-tertiary-bg, var(--bs-body-bg));
  border-color: var(--bs-border-color);
}

.nav-pills {
  --bs-nav-pills-border-radius: var(--bs-border-radius);
  --bs-nav-pills-link-active-color: var(--bs-body-bg);
  --bs-nav-pills-link-active-bg: var(--accent);
}


.table-light {
  --bs-table-bg: var(--bs-light);
  --bs-table-color: var(--bs-body-color);
  --bs-table-border-color: var(--bs-border-color);
  --bs-table-striped-bg: var(--bs-light);
  --bs-table-striped-color: var(--bs-body-color);
  --bs-table-active-bg: var(--bs-light);
  --bs-table-active-color: var(--bs-body-color);
  --bs-table-hover-bg: var(--bs-light);
  --bs-table-hover-color: var(--bs-body-color);
}

[data-bs-theme="dark"] .table-light {
  --bs-table-bg: var(--bs-dark);
  --bs-table-color: var(--bs-body-color);
  --bs-table-border-color: var(--bs-border-color);
  --bs-table-striped-bg: var(--bs-dark);
  --bs-table-striped-color: var(--bs-body-color);
  --bs-table-active-bg: var(--bs-dark);
  --bs-table-active-color: var(--bs-body-color);
  --bs-table-hover-bg: var(--bs-dark);
  --bs-table-hover-color: var(--bs-body-color);
}

.bg-light {
  background-color: var(--bs-light) !important;
}


/** Alertify Color Scheme Overrides **/
.alertify {
  font-family: inherit;
}

.alertify .ajs-dialog {
  background-color: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow) !important;
}

.alertify .ajs-header {
  background-color: var(--surface-alt) !important;
  color: var(--text) !important;
  border-bottom: 1px solid var(--border) !important;
  border-top-left-radius: var(--radius-md) !important;
  border-top-right-radius: var(--radius-md) !important;
  font-weight: 600;
}

.alertify .ajs-body {
  color: var(--text) !important;
  background-color: var(--surface) !important;
}

.alertify .ajs-footer {
  background-color: var(--surface-alt) !important;
  border-top: 1px solid var(--border) !important;
  border-bottom-left-radius: var(--radius-md) !important;
  border-bottom-right-radius: var(--radius-md) !important;
}

.alertify .ajs-buttons .ajs-button {
  border-radius: calc(var(--radius-md) - 4px) !important;
  transition: all 0.2s ease;
}

.alertify .ajs-buttons .ajs-button.ajs-ok {
  background-color: var(--primary) !important;
  color: var(--primary-contrast) !important;
  border: 1px solid var(--primary) !important;
}

.alertify .ajs-buttons .ajs-button.ajs-cancel {
  background-color: var(--surface-muted) !important;
  color: var(--muted) !important;
  border: 1px solid var(--border) !important;
}

.alertify-notifier .ajs-message {
  background-color: var(--surface-alt) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow) !important;
}

.alertify-notifier .ajs-message.ajs-success {
  background-color: var(--accent) !important;
  color: var(--accent-contrast) !important;
  border-color: var(--accent) !important;
}

.alertify-notifier .ajs-message.ajs-error {
  background-color: var(--danger) !important;
  color: var(--danger-contrast) !important;
  border-color: var(--danger) !important;
}

.blank-template {
  min-height: 100vh;
  background: var(--blank-bg);
}

:root,
[data-bs-theme="light"] {
  --blank-bg:
    radial-gradient(circle at top left, rgba(26, 115, 232, .12), transparent 40%),
    radial-gradient(circle at bottom right, rgba(15, 157, 88, .10), transparent 35%),
    linear-gradient(135deg, #f8fbff 0%, #eef4ff 50%, #f8f9fa 100%);
}

[data-bs-theme="dark"] {
  --blank-bg:
    radial-gradient(circle at top left, rgba(38, 139, 210, .18), transparent 35%),
    radial-gradient(circle at bottom right, rgba(42, 161, 152, .15), transparent 35%),
    linear-gradient(135deg, #002b36 0%, #073642 55%, #00252f 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  background: var(--bg);
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  padding: 1rem 0.85rem;
  border-right: 1px solid var(--sidebar-border);
  background: var(--sidebar-bg);
  box-shadow: var(--shadow);
  transition: width 0.2s ease, transform 0.2s ease;
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
}

.sidebar-collapsed .sidebar {
  width: var(--sidebar-width-collapsed);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin: -1rem -.85rem 1rem;
  padding: 1rem .85rem;
  border-bottom: 1px solid var(--sidebar-border);
  background: rgba(0, 0, 0, .03);
  flex-shrink: 0;
}

[data-bs-theme="dark"] .sidebar-header {
  background: rgba(255, 255, 255, .04);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--sidebar-text);
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  width: 2.3rem;
  height: 2.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.85rem;
  background: var(--primary);
  color: var(--primary-contrast);
  box-shadow: 0 8px 18px rgba(53, 99, 233, 0.2);
}

.brand-name {
  white-space: nowrap;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.sidebar-toggle,
.mobile-toggle {
  border: 1px solid var(--border);
  background: var(--sidebar-bg);
  border-color: var(--sidebar-border);
  color: var(--sidebar-text);
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================
   SIDEBAR NAVIGATION & CUSTOM SCROLLBAR
   ========================================== */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
  min-height: 0;
  overflow-y: auto;

  /* Firefox Scrollbar Styling */
  scrollbar-width: thin;
  scrollbar-color: var(--sidebar-border, rgba(0, 0, 0, 0.2)) transparent;
}

/* WebKit (Chrome, Edge, Safari) Scrollbar Styling */
.sidebar-nav::-webkit-scrollbar {
  width: 6px;
  /* Thin, elegant width */
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
  /* Seamless blend with sidebar background */
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background-color: var(--sidebar-border, rgba(0, 0, 0, 0.15));
  border-radius: 10px;
  /* Fully rounded edges */
  transition: background-color 0.2s ease;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background-color: var(--sidebar-text-muted, rgba(0, 0, 0, 0.3));
  /* Darker on hover */
}

/* Dark theme adaptation for WebKit scrollbars */
[data-bs-theme="dark"] .sidebar-nav::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.15);
}

[data-bs-theme="dark"] .sidebar-nav::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

.sidebar .nav-link {
  color: var(--sidebar-text);
  padding: .82rem .95rem;
  gap: 0.9rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  white-space: nowrap;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar .nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
}

.sidebar .nav-link.active {
  background: var(--sidebar-hover);
  color: var(--sidebar-text);
  font-weight: 600;
  border-left: 4px solid var(--accent);
}

.sidebar .nav-link i {
  width: 22px;
  text-align: center;
  color: var(--sidebar-text-muted);
  transition: .2s;
}

.sidebar .nav-link:hover i {
  color: var(--sidebar-text);
}

.sidebar .nav-link.active i {
  color: var(--accent);
}

.sidebar-collapsed .sidebar .nav-link span,
.sidebar-collapsed .brand-name {
  display: none;
}

.sidebar-footer {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.main-panel {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease, width 0.2s ease;
}

.sidebar-collapsed .main-panel {
  margin-left: var(--sidebar-width-collapsed);
  width: calc(100% - var(--sidebar-width-collapsed));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  height: var(--topbar-height);
  padding: 0 1.25rem;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.theme-select {
  min-width: 120px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
}

.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text);
  border: 1px solid var(--border);
}

.user-avatar {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: var(--primary-contrast);
  font-weight: 700;
  text-transform: uppercase;
}

.content-shell {
  padding: 1.25rem;
  flex: 1;
}

.content-area .card,
.content-area .list-group,
.content-area .table {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow);
}

.content-area .card-body {
  color: var(--text);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-contrast);
}

.btn-outline-secondary {
  color: var(--text);
  border-color: var(--border);
  background: var(--surface);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 19, 27, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: var(--z-sidebar-backdrop);
  pointer-events: none;

  transition:
    opacity .2s ease,
    visibility .2s ease;
}

body.sidebar-open .sidebar-backdrop {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.app-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.app-modal .modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(4px);
  z-index: 0;
}

.app-modal .modal-window {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: calc(100vh - 48px);
  overflow: hidden;
  z-index: 1;
}

.modal-sm {
  max-width: 420px;
}

.modal-md {
  max-width: 560px;
}

.modal-lg {
  max-width: 760px;
}

.modal-xl {
  max-width: 1000px;
}

.app-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
}

.app-modal .modal-header h5 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.app-modal .modal-close {
  border: 0;
  background: none;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
}

.app-modal .modal-close:hover {
  color: var(--text);
}

.app-modal .modal-body {
  overflow: auto;
  flex: 1;
}

/* Padded wrapper used for htmx-loaded (url:) content, or plain string/Node
   content passed directly — NOT used by Search, which lays out its own
   header/results as direct children of .modal-body (see below). */
.app-modal .modal-content-body {
  padding: 24px;
}

.app-modal .modal-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}

.app-modal .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 18px 22px;
  border-top: 1px solid var(--border-soft);
}

/* Entrance animation */
.app-modal {
  animation: fadeIn .15s ease;
}

.app-modal .modal-window {
  animation: modalScale .18s ease;
}

/* Lock page scroll while one or more modals are open (ModalManager toggles
   this on <body> whenever its stack is non-empty). */
body.modal-open {
  overflow: hidden;
}

/* ─────────────────────────────────────────────
   Search Modal
   Just a thin skin on top of the generic modal —
   opened via ModalManager.open({ id: 'search-modal', closable: false, ... })
   so it gets the same backdrop, stacking, and Escape/close behavior as
   every other modal in the app. No separate modal system, no fixed
   z-index override needed: JS manages stacking order for all of them.
───────────────────────────────────────────── */
#search-modal .modal-window {
  max-width: 720px;
}

#search-modal .modal-body {
  display: flex;
  flex-direction: column;
  padding: 0;
}

.search-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
}

.search-header svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-header input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
  color: var(--text);
}

.search-header kbd {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface-alt);
}

#search-results {
  overflow-y: auto;
  max-height: 65vh;
}

.search-empty {
  padding: 36px 24px;
  text-align: center;
  color: var(--text-muted);
}

.search-empty svg {
  width: 40px;
  height: 40px;
  opacity: .3;
  margin: 0 auto 12px;
  display: block;
}

/* ==========================================
   Clock-In Page Styles
   ==========================================*/

[data-init="ClockIn"] {
  background-color: var(--surface);
  color: var(--text);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

[data-init="ClockIn"] .pin-box {
  background-color: var(--surface-alt);
  border-color: var(--border) !important;
  color: var(--text);
  transition: all 0.2s ease-in-out;
}

[data-init="ClockIn"] .pin-box.bg-light {
  background-color: var(--surface-muted) !important;
}

[data-init="ClockIn"] .keypad-btn {
  background-color: var(--surface-alt);
  border-color: var(--border) !important;
  color: var(--text);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: background-color 0.15s ease, transform 0.05s ease;
}

[data-init="ClockIn"] .keypad-btn:hover {
  background-color: var(--surface-muted);
  color: var(--primary);
}

[data-init="ClockIn"] .keypad-btn:active {
  transform: scale(0.96);
}

[data-init="ClockIn"] #keypadBackBtn {
  border-color: var(--border) !important;
  background-color: var(--surface-alt);
  color: var(--danger);
  border-radius: var(--radius-md);
  transition: background-color 0.15s ease;
}

[data-init="ClockIn"] #keypadBackBtn:hover {
  background-color: var(--surface-muted);
}

[data-init="ClockIn"] #actionScreen h4 {
  color: var(--bs-heading-color);
}

[data-init="ClockIn"] #actionButtonsContainer .btn {
  border-radius: var(--radius-md);
  font-weight: 500;
}

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .main-panel {
    margin-left: 0;
    width: 100%;
  }

  .sidebar-collapsed .main-panel {
    margin-left: 0;
    width: 100%;
  }

  .mobile-toggle {
    display: inline-flex;
  }
}

@media (min-width: 992px) {
  .mobile-toggle {
    display: none;
  }
}