:root {
  --sidebar-width: 280px;
  --sidebar-mini-width: 84px;
  --admin-bg: #f5f7fb;
  --admin-surface: #ffffff;
  --admin-surface-soft: #f8fafc;
  --admin-border: #dbe4ef;
  --admin-text: #1f2937;
  --admin-muted: #6b7280;
  --admin-primary: #2563eb;
  --admin-primary-dark: #1d4ed8;
  --admin-success: #0f766e;
  --admin-warning: #d97706;
  --admin-danger: #dc2626;
  --admin-sidebar: #111827;
  --admin-sidebar-soft: #1f2937;
  --admin-shadow-sm: 0 10px 24px rgba(15, 23, 42, 0.06);
  --admin-shadow: 0 18px 46px rgba(15, 23, 42, 0.09);
  --admin-shadow-lg: 0 26px 70px rgba(15, 23, 42, 0.12);
  --admin-ring: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(180deg, #f8fbff 0%, var(--admin-bg) 42%, #eef4fa 100%);
  color: var(--admin-text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  text-decoration: none;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.25;
}

.admin-shell {
  min-height: 100vh;
}

.admin-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  /* Reserve scrollbar gutter to keep inner content width stable so header/footer dividers align with scrollbar */
  scrollbar-gutter: stable;
  background: var(--admin-sidebar);
  color: #ffffff;
  box-shadow: 18px 0 42px rgba(15, 23, 42, 0.18);
  transform: translateX(0);
  transition: width 0.2s ease, transform 0.2s ease;
}

/* Sidebar scroll indicators */
.admin-sidebar::after {
  content: '';
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  height: 24px;
  background: linear-gradient(to top, var(--admin-sidebar), transparent);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  flex-shrink: 0;
  margin-top: auto;
}
.admin-sidebar.sidebar-scrolled-bottom::after {
  opacity: 1;
}

.sidebar-header {
  padding: 1.35rem 1.25rem 1.15rem;
  margin-inline: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-close-btn {
  display: none;
  background: none;
  border: 1px solid var(--admin-sidebar-border, rgba(255,255,255,0.2));
  color: var(--admin-sidebar-text, #ffffff);
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  margin-left: auto;
  align-self: center;
}
.sidebar-close-btn:hover,
.sidebar-close-btn:focus {
  background: var(--admin-sidebar-icon-bg, rgba(255,255,255,0.12));
  color: var(--admin-sidebar-text-strong, #fff);
  border-color: var(--admin-sidebar-icon, #2563eb);
}

/* Default (light) theme override — ensure X is always visible on white sidebar */
html:not([data-theme="dark"]) .sidebar-close-btn {
  color: #475569;
  border-color: #dbe4ef;
  background: #f1f5f9;
}
html:not([data-theme="dark"]) .sidebar-close-btn:hover,
html:not([data-theme="dark"]) .sidebar-close-btn:focus {
  color: #0f172a;
  background: #e2e8f0;
  border-color: #2563eb;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  color: #ffffff;
}

.brand-mark:hover,
.brand-mark:focus {
  color: #ffffff;
}

.brand-icon,
.profile-avatar,
.metric-icon,
.nav-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  font-weight: 700;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #0f766e);
  color: #ffffff;
}

.brand-copy,
.brand-title,
.brand-subtitle,
.nav-text,
.sidebar-footer-text {
  min-width: 0;
  transition: opacity 0.16s ease, width 0.16s ease;
}

.brand-title,
.brand-subtitle {
  display: block;
  line-height: 1.2;
  white-space: nowrap;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.brand-subtitle {
  color: #9ca3af;
  font-size: 0.78rem;
}

.sidebar-nav {
  display: grid;
  gap: 0.2rem;
  padding: 0.6rem 1rem;
}

.sidebar-nav .nav-section {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
  padding: 0.6rem 0.9rem 0.2rem;
  user-select: none;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 48px;
  padding: 0.78rem 0.9rem;
  border-radius: 8px;
  color: #d1d5db;
  font-weight: 600;
  transition: background 0.16s ease, color 0.16s ease;
  white-space: nowrap;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link:focus,
.sidebar-nav .nav-link.active {
  background: var(--admin-sidebar-soft);
  color: #ffffff;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link:focus {
  transform: none;
}

.nav-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #bfdbfe;
  font-size: 0.76rem;
}

/* --- Sidebar dropdown submenu --- */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  position: relative;
  cursor: pointer;
  width: 100%;
  border: none;
  background: none;
  font: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 48px;
  padding: 0.78rem 0.9rem;
  border-radius: 8px;
  color: inherit;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav-dropdown-toggle:focus-visible {
  outline: 2px solid var(--admin-sidebar-icon, #2563eb);
  outline-offset: -2px;
}

.nav-dropdown-toggle .nav-chevron {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  transition: transform 0.25s ease, background 0.16s ease;
  color: inherit;
  opacity: 0.6;
  flex-shrink: 0;
}

.nav-dropdown-toggle:hover .nav-chevron,
.nav-dropdown-toggle.active .nav-chevron {
  opacity: 0.9;
}

.nav-dropdown.open .nav-dropdown-toggle .nav-chevron {
  transform: rotate(180deg);
}

/* Parent highlighted when open or active */
.nav-dropdown-toggle.active,
.nav-dropdown.open .nav-dropdown-toggle {
  background: var(--admin-sidebar-soft);
  color: #ffffff;
}

/* Dropdown menu container */
.nav-dropdown-menu {
  display: none;
  padding: 0.15rem 0 0.3rem 0;
  margin: 0 0.5rem 0.1rem 0;
  border-radius: 6px;
}

.nav-dropdown.open .nav-dropdown-menu {
  display: block;
}

/* Child items: indented, clear hierarchy */
.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 40px;
  padding: 0.5rem 0.85rem 0.5rem 2.8rem;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.88rem;
  color: #d1d5db;
  transition: background 0.16s ease, color 0.16s ease;
  position: relative;
}

.nav-dropdown-item .nav-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  font-size: 0.7rem;
  flex-shrink: 0;
}

.nav-dropdown-item:hover,
.nav-dropdown-item:focus {
  background: var(--admin-sidebar-soft);
  color: #ffffff;
}

/* Active child: accent bar + highlight */
.nav-dropdown-item.active {
  background: var(--admin-sidebar-soft);
  color: #ffffff;
  font-weight: 600;
}

.nav-dropdown-item.active::before {
  content: '';
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 55%;
  border-radius: 2px;
  background: var(--admin-sidebar-icon, #2563eb);
}

/* Theme-aware dropdown styles */
html:not([data-theme="dark"]) .nav-dropdown-item {
  color: var(--admin-sidebar-text);
}

html:not([data-theme="dark"]) .nav-dropdown-item:hover,
html:not([data-theme="dark"]) .nav-dropdown-item:focus,
html:not([data-theme="dark"]) .nav-dropdown-item.active {
  color: var(--admin-sidebar-text-strong);
}

html:not([data-theme="dark"]) .nav-dropdown.open .nav-dropdown-toggle,
html:not([data-theme="dark"]) .nav-dropdown-toggle.active {
  background: var(--admin-sidebar-soft);
  color: var(--admin-sidebar-text-strong);
}

/* Desktop mini sidebar: flyout on hover */
@media (min-width: 992px) {
  body.sidebar-mini .nav-dropdown-toggle .nav-chevron {
    display: none;
  }

  body.sidebar-mini .nav-dropdown-menu {
    display: none !important;
  }

  body.sidebar-mini .nav-dropdown:hover .nav-dropdown-menu {
    display: block !important;
    position: absolute;
    left: calc(100% + 0.5rem);
    top: -0.25rem;
    min-width: 210px;
    padding: 0.35rem;
    margin: 0;
    background: var(--admin-sidebar);
    border: 1px solid var(--admin-sidebar-border);
    border-radius: 8px;
    box-shadow: var(--admin-sidebar-shadow);
    z-index: 1050;
  }

  body.sidebar-mini .nav-dropdown:hover .nav-dropdown-item {
    color: var(--admin-sidebar-text);
    padding-left: 1.2rem;
  }

  body.sidebar-mini .nav-dropdown:hover .nav-dropdown-item.active::before {
    left: 0.35rem;
  }

  body.sidebar-mini .nav-dropdown:hover .nav-dropdown-item:hover,
  body.sidebar-mini .nav-dropdown:hover .nav-dropdown-item.active {
    color: var(--admin-sidebar-text-strong);
  }
}

/* Mobile sidebar dropdown: touch-friendly */
@media (max-width: 991.98px) {
  .nav-dropdown-item {
    min-height: 46px;
    padding: 0.6rem 0.9rem 0.6rem 3rem;
    font-size: 0.92rem;
    touch-action: manipulation;
  }

  .nav-dropdown-toggle {
    min-height: 50px;
    padding: 0.8rem 0.9rem;
    -webkit-tap-highlight-color: transparent;
  }

  .nav-dropdown-toggle .nav-chevron {
    opacity: 0.7;
    width: 20px;
    height: 20px;
  }
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: auto;
  margin-inline: 1.25rem;
  padding: 1rem 0;
  color: #d1d5db;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.9rem;
  white-space: nowrap;
}

.sidebar-user {
  margin: auto 1rem 1rem;
  padding: 0.85rem;
  display: grid;
  justify-items: center;
  gap: 0.22rem;
  border: 1px solid var(--admin-sidebar-border);
  border-radius: 8px;
  background: var(--admin-sidebar-soft);
  text-align: center;
}

.sidebar-user-avatar {
  border: 3px solid #53e9b9;
}

.sidebar-user strong {
  color: var(--admin-sidebar-text-strong);
  font-size: 1rem;
  line-height: 1.1;
}

.sidebar-user small {
  color: var(--admin-sidebar-muted);
  font-size: 0.84rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: #22c55e;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1030;
  display: none;
  background: rgba(15, 23, 42, 0.5);
}

.admin-main {
  width: auto;
  min-width: 0;
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  transition: margin-left 0.2s ease;
}

.admin-navbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  min-height: 72px;
  border-bottom: 1px solid var(--admin-border);
  box-shadow: var(--admin-shadow-sm);
}

.admin-navbar.bg-white {
  background-color: rgba(255, 255, 255, 0.94) !important;
  backdrop-filter: blur(14px);
}

.sidebar-toggle {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  gap: 4px;
  padding: 9px;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus {
  border-color: #bfdbfe;
  background: #f8fbff;
  box-shadow: var(--admin-ring);
}

.sidebar-toggle span {
  width: 18px;
  height: 2px;
  display: block;
  background: var(--admin-text);
  border-radius: 999px;
}

.search-input {
  flex: 1 1 0;
  min-width: 0;
  max-width: 520px;
  border-color: var(--admin-border);
  border-radius: 8px;
  background: var(--admin-surface-soft);
  min-height: 42px;
  box-shadow: none;
}

.search-input:focus {
  border-color: #93c5fd;
  box-shadow: var(--admin-ring);
}

/* Global search results dropdown */
.global-search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  width: 100%;
  min-width: 280px;
  max-width: 560px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--admin-surface, #fff);
  border: 1px solid var(--admin-border);
  border-radius: 0.5rem;
  box-shadow: var(--admin-shadow-lg);
  z-index: 1100;
  margin-top: 4px;
}
.global-search-results.active {
  display: block;
}
.global-search-results .gs-group-label {
  display: block;
  padding: 0.45rem 0.85rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--admin-muted, #6b7280);
  background: var(--admin-surface-soft, #f8fafc);
  border-bottom: 1px solid var(--admin-border);
  position: sticky;
  top: 0;
  z-index: 1;
}
.global-search-results .gs-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.85rem;
  text-decoration: none;
  color: var(--admin-text, #1f2937);
  transition: background 0.1s;
  cursor: pointer;
}
.global-search-results .gs-item:hover,
.global-search-results .gs-item:focus {
  background: var(--admin-surface-soft, #f8fafc);
  outline: none;
}
.global-search-results .gs-item .gs-icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
}
.global-search-results .gs-item .gs-icon.gs-worker   { background: #2563eb; }
.global-search-results .gs-item .gs-icon.gs-farm      { background: #0f766e; }
.global-search-results .gs-item .gs-icon.gs-estate    { background: #7c3aed; }
.global-search-results .gs-item .gs-icon.gs-expense   { background: #dc2626; }
.global-search-results .gs-item .gs-icon.gs-store     { background: #d97706; }
.global-search-results .gs-item .gs-icon.gs-activity,
.global-search-results .gs-item .gs-icon.gs-activity_type { background: #0891b2; }
.global-search-results .gs-item .gs-text {
  min-width: 0;
}
.global-search-results .gs-item .gs-label {
  font-weight: 500;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.global-search-results .gs-item .gs-sub {
  font-size: 0.75rem;
  color: var(--admin-muted, #6b7280);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.global-search-results .gs-empty {
  padding: 1.25rem;
  text-align: center;
  color: var(--admin-muted, #6b7280);
  font-size: 0.875rem;
}
.global-search-results .gs-hint {
  padding: 0.45rem 0.85rem;
  font-size: 0.72rem;
  color: var(--admin-muted, #6b7280);
  border-top: 1px solid var(--admin-border);
  text-align: center;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.icon-button,
.profile-button {
  border: 1px solid var(--admin-border);
  background: #ffffff;
  color: var(--admin-text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.icon-button:hover,
.icon-button:focus,
.profile-button:hover,
.profile-button:focus {
  border-color: #bfdbfe;
  box-shadow: var(--admin-ring);
}

.icon-button {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  font-weight: 600;
}

.notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--admin-danger);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 600;
  line-height: 1;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  pointer-events: none;
}

.notification-menu {
  width: min(320px, calc(100vw - 2rem));
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  box-shadow: var(--admin-shadow);
}

.notification-menu .dropdown-item {
  display: grid;
  gap: 0.2rem;
  padding-block: 0.7rem;
}

.profile-button {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 42px;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  font-weight: 600;
}

.profile-avatar {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #e0ecff;
  color: var(--admin-primary-dark);
  font-size: 0.76rem;
}

.avatar-img {
  display: block;
  flex: 0 0 auto;
  object-fit: cover;
  object-position: center;
}

.avatar-sm {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.avatar-md {
  width: 56px;
  height: 56px;
  border-radius: 50%;
}

.avatar-xl {
  width: 78px;
  height: 78px;
  border-radius: 50%;
}

.profile-button .avatar-sm {
  border: 2px solid #52e7b8;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.08);
}

html[data-theme="dark"] .profile-button .avatar-sm {
  border-color: #54f0be;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.dashboard-content {
  min-height: calc(100vh - 132px);
}

.dashboard-content > .container-fluid {
  padding-top: 1.75rem !important;
  padding-bottom: 1.75rem !important;
}

.page-heading,
.panel-header,
.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.page-heading {
  margin-bottom: 1.35rem;
}

.page-heading h1 {
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.eyebrow {
  color: var(--admin-primary);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.heading-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.65rem;
}

.btn {
  border-radius: 8px;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.btn:hover,
.btn:focus {
  transform: none;
}

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

.btn-primary:hover,
.btn-primary:focus {
  border-color: var(--admin-primary-dark);
  background: var(--admin-primary-dark);
}

.metric-card,
.panel {
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  background: var(--admin-surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.metric-card {
  position: relative;
  min-height: 164px;
  padding: 1.35rem;
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--metric-color, var(--admin-primary));
}

.metric-card:hover {
  border-color: #c6d5e8;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.metric-primary {
  --metric-color: var(--admin-primary);
}

.metric-success {
  --metric-color: var(--admin-success);
}

.metric-warning {
  --metric-color: var(--admin-warning);
}

.metric-danger {
  --metric-color: var(--admin-danger);
}

.metric-info {
  --metric-color: #0dcaf0;
}

.metric-label {
  color: var(--admin-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.metric-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #eaf2ff;
  color: var(--metric-color, var(--admin-primary));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.metric-success .metric-icon {
  background: #e7f6f3;
}

.metric-warning .metric-icon {
  background: #fff4df;
}

.metric-danger .metric-icon {
  background: #ffecec;
}

.metric-info .metric-icon {
  background: #e0f7fa;
}

.metric-value {
  margin-top: 0.85rem;
  color: var(--admin-text);
  font-size: 2.18rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.metric-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
  color: var(--admin-muted);
  font-size: 0.88rem;
  font-weight: 500;
}

.panel {
  padding: 1.35rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.panel:hover {
  border-color: #c6d5e8;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.panel-header {
  margin-bottom: 1.25rem;
}

.panel-header p {
  font-size: 0.92rem;
}

.table {
  --bs-table-bg: transparent;
}

.table thead th {
  color: var(--admin-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.table tbody td {
  min-width: 120px;
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.table tbody tr {
  transition: background 0.16s ease;
}

.table tbody tr:hover {
  background: #f8fbff;
}

.badge {
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font-weight: 600;
}

.card-title {
  font-weight: 600;
  line-height: 1.3;
}

.card-text {
  font-weight: 500;
  line-height: 1.5;
}

.card-text.small {
  font-weight: 500;
}

.table-search {
  width: min(260px, 100%);
  border-color: var(--admin-border);
  border-radius: 8px;
}

.profile-avatar-lg {
  width: 92px;
  height: 92px;
  border-radius: 8px;
  font-size: 1.5rem;
}

.profile-hero {
  display: grid;
  justify-items: center;
}

.profile-card {
  overflow: hidden;
}

.profile-cover {
  margin: -1.35rem -1.35rem 0.9rem;
  height: 96px;
  border-bottom: 1px solid var(--admin-border);
}

.profile-cover img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
}

.profile-photo {
  margin-top: -44px;
  border: 4px solid var(--admin-surface);
  box-shadow: var(--admin-shadow-sm);
}

.info-list {
  display: grid;
  gap: 0.85rem;
}

.info-list div,
.settings-row {
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  background: var(--admin-surface-soft);
}

.info-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem;
}

.info-list span,
.settings-row small {
  color: var(--admin-muted);
  font-size: 0.84rem;
}

.info-list strong {
  text-align: right;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  cursor: pointer;
}

.settings-row span {
  display: grid;
  gap: 0.2rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.progress {
  height: 1.15rem;
  border-radius: 8px;
  background: #e8eef6;
}

.progress-bar {
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
}

.auth-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #f8fbff 0%, #eaf2ff 44%, #eef8f6 100%);
}

.auth-page,
.error-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-card,
.error-card {
  width: min(100%, 460px);
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--admin-shadow-lg);
}

.auth-card {
  padding: 1.5rem;
}

.auth-visual {
  margin-bottom: 1rem;
  height: 96px;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  overflow: hidden;
}

.auth-visual img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
}

.error-card {
  padding: 2rem;
  text-align: center;
}

.error-illustration {
  width: min(260px, 100%);
  max-height: 132px;
  object-fit: contain;
  margin: 0 auto 0.55rem;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  color: var(--admin-text);
}

.auth-brand:hover,
.auth-brand:focus {
  color: var(--admin-text);
}

.auth-brand span:last-child {
  display: grid;
  line-height: 1.2;
}

.auth-brand small,
.auth-footer {
  color: var(--admin-muted);
}

.auth-footer {
  margin-top: 1.2rem;
  text-align: center;
  font-size: 0.92rem;
}

.error-code {
  color: var(--admin-primary);
  font-size: clamp(5rem, 18vw, 8rem);
  font-weight: 700;
  line-height: 1;
}

.admin-footer {
  padding: 1.1rem 0 1.35rem;
  color: var(--admin-muted);
  font-size: 0.9rem;
}

.admin-footer .container-fluid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

@media (min-width: 992px) {
  body.sidebar-mini .admin-sidebar {
    width: var(--sidebar-mini-width);
  }

  body.sidebar-mini .admin-main {
    margin-left: var(--sidebar-mini-width);
  }

  body.sidebar-mini .brand-copy,
  body.sidebar-mini .nav-text,
  body.sidebar-mini .sidebar-footer-text {
    width: 0;
    opacity: 0;
    overflow: hidden;
  }

  body.sidebar-mini .sidebar-header,
  body.sidebar-mini .sidebar-footer {
    margin-inline: 1rem;
    padding-inline: 0;
  }

  body.sidebar-mini .sidebar-nav .nav-link {
    justify-content: center;
    padding-inline: 0.65rem;
  }

  body.sidebar-mini .sidebar-nav .nav-link:hover,
  body.sidebar-mini .sidebar-nav .nav-link:focus {
    transform: none;
  }
}

@media (max-width: 991.98px) {
  .admin-sidebar {
    width: min(var(--sidebar-width), calc(100vw - 48px));
    transform: translateX(-100%);
  }

  .admin-main {
    margin-left: 0;
  }

  body.sidebar-open {
    overflow: hidden;
  }

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

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .sidebar-close-btn {
    display: grid;
    place-items: center;
  }
}

@media (max-width: 575.98px) {
  .page-heading,
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .heading-actions {
    width: 100%;
    justify-content: stretch;
  }

  .heading-actions .btn {
    flex: 1 1 0;
  }

  .metric-value {
    font-size: 1.95rem;
  }

  .metric-card,
  .panel {
    padding: 1.1rem;
  }

  .admin-footer .container-fluid {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar-nav .nav-link,
  .sidebar-toggle,
  .icon-button,
  .profile-button,
  .btn,
  .metric-card,
  .panel,
  .table tbody tr {
    transition: none;
  }

  .btn:hover,
  .btn:focus,
  .metric-card:hover {
    transform: none;
  }
}

html[data-theme="dark"] {
  --admin-bg: #0f172a;
  --admin-surface: #182235;
  --admin-surface-soft: #111827;
  --admin-border: #2f3b52;
  --admin-text: #e5edf7;
  --admin-muted: #9aa8bd;
  --admin-primary: #60a5fa;
  --admin-primary-dark: #3b82f6;
  --admin-success: #2dd4bf;
  --admin-warning: #fbbf24;
  --admin-danger: #f87171;
  --admin-sidebar: #090f1d;
  --admin-sidebar-soft: #172033;
  --admin-shadow-sm: 0 10px 24px rgba(0, 0, 0, 0.24);
  --admin-shadow: 0 18px 46px rgba(0, 0, 0, 0.32);
  --admin-shadow-lg: 0 26px 70px rgba(0, 0, 0, 0.42);
  --admin-ring: 0 0 0 4px rgba(96, 165, 250, 0.18);
}

html[data-theme="dark"] body {
  background: linear-gradient(180deg, #111827 0%, var(--admin-bg) 48%, #0b1120 100%);
}

.brand-icon {
  font-size: 1.1rem;
}

.nav-icon {
  font-size: 0.95rem;
}

.theme-toggle i {
  font-size: 1rem;
}

.admin-navbar.bg-white,
.sidebar-toggle,
.icon-button,
.profile-button {
  background-color: var(--admin-surface) !important;
  color: var(--admin-text);
}

html[data-theme="dark"] .admin-navbar.bg-white {
  background-color: rgba(24, 34, 53, 0.92) !important;
}

html[data-theme="dark"] .profile-avatar {
  background: #1e3a5f;
  color: #bfdbfe;
}

.page-heading-copy {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
  min-width: 0;
}

.page-icon,
.section-title i {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.page-icon {
  width: 48px;
  height: 48px;
  font-size: 1.25rem;
  border-radius: 8px;
  background: #eaf2ff;
  color: var(--admin-primary-dark);
}

.section-title {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.section-title i {
  color: var(--admin-muted);
  font-size: 0.85rem;
  opacity: 0.7;
}

html[data-theme="dark"] .page-icon {
  background: #1e3a5f;
  color: #bfdbfe;
}

html[data-theme="dark"] .section-title i {
  color: #94a3b8;
  opacity: 0.6;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn-light {
  border-color: var(--admin-border);
  background: var(--admin-surface-soft);
  color: var(--admin-text);
}

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

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
  border-color: var(--admin-primary);
  background: #eaf2ff;
  color: var(--admin-primary-dark);
}

html[data-theme="dark"] .btn-outline-secondary:hover,
html[data-theme="dark"] .btn-outline-secondary:focus {
  background: #1e3a5f;
  color: #bfdbfe;
}

html[data-theme="dark"] .table tbody tr:hover {
  background: #111827;
}

html[data-theme="dark"] .progress {
  background: #243149;
}

html[data-theme="dark"] .auth-body {
  background: linear-gradient(135deg, #0b1120 0%, #111827 48%, #10201f 100%);
}

.auth-card,
.error-card {
  background: var(--admin-surface);
}

.auth-theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10;
}

.dropdown-menu,
.modal-content,
.accordion-item,
.accordion-button {
  border-color: var(--admin-border);
  background-color: var(--admin-surface);
  color: var(--admin-text);
}

.dropdown-item,
.accordion-body {
  color: var(--admin-text);
}

.dropdown-item:hover,
.dropdown-item:focus,
.accordion-button:not(.collapsed) {
  background-color: var(--admin-surface-soft);
  color: var(--admin-text);
}

.form-control,
.form-select {
  border-color: var(--admin-border);
  background-color: var(--admin-surface);
  color: var(--admin-text);
}

.form-control:focus,
.form-select:focus {
  border-color: #93c5fd;
  background-color: var(--admin-surface);
  color: var(--admin-text);
  box-shadow: var(--admin-ring);
}

.form-control::placeholder {
  color: var(--admin-muted);
}

.text-muted {
  color: var(--admin-muted) !important;
}

html[data-theme="dark"] .text-body {
  color: var(--admin-text) !important;
}

html[data-theme="dark"] .text-bg-secondary {
  background-color: #334155 !important;
  color: #e5edf7 !important;
}

@media (max-width: 767.98px) {
  .navbar-actions {
    gap: 0.5rem;
  }

  .icon-button,
  .profile-button,
  .sidebar-toggle {
    width: 44px;
    height: 44px;
  }

  .profile-button {
    padding: 0.3rem;
  }

  .page-heading-copy {
    align-items: flex-start;
  }
}

@media (max-width: 575.98px) {
  .page-heading-copy {
    width: 100%;
  }

  .page-icon {
    width: 44px;
    height: 44px;
  }

  .panel-header .d-flex,
  .panel-header .form-control,
  .panel-header .form-select {
    width: 100%;
  }
}

html[data-theme="light"] {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

body,
.admin-navbar,
.admin-sidebar,
.admin-main,
.metric-card,
.panel,
.auth-card,
.error-card,
.dropdown-menu,
.modal-content,
.form-control,
.form-select {
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.table {
  --bs-table-color: var(--admin-text);
  --bs-table-border-color: var(--admin-border);
  color: var(--admin-text);
}

.page-link {
  border-color: var(--admin-border);
  background: var(--admin-surface);
  color: var(--admin-text);
}

.page-link:hover,
.page-link:focus {
  border-color: var(--admin-primary);
  background: var(--admin-surface-soft);
  color: var(--admin-primary);
}

.page-item.active .page-link {
  border-color: var(--admin-primary);
  background: var(--admin-primary);
  color: #ffffff;
}

.page-item.disabled .page-link {
  border-color: var(--admin-border);
  background: var(--admin-surface-soft);
  color: var(--admin-muted);
}

.alert {
  border-radius: 8px;
}

html[data-theme="dark"] .alert-primary {
  border-color: #1d4ed8;
  background: rgba(37, 99, 235, 0.16);
  color: #bfdbfe;
}

html[data-theme="dark"] .alert-success {
  border-color: #0f766e;
  background: rgba(15, 118, 110, 0.18);
  color: #99f6e4;
}

html[data-theme="dark"] .alert-warning {
  border-color: #d97706;
  background: rgba(217, 119, 6, 0.18);
  color: #fde68a;
}

html[data-theme="dark"] .alert-danger {
  border-color: #dc2626;
  background: rgba(220, 38, 38, 0.16);
  color: #fecaca;
}

html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer,
html[data-theme="dark"] .accordion-item {
  border-color: var(--admin-border);
}

html[data-theme="dark"] .btn-close {
  filter: invert(1) grayscale(100%) brightness(180%);
}

html[data-theme="dark"] .text-bg-info {
  background-color: #0e7490 !important;
  color: #ecfeff !important;
}

html[data-theme="dark"] .text-bg-warning {
  background-color: #b45309 !important;
  color: #fff7ed !important;
}

html[data-theme="dark"] .text-bg-success {
  background-color: #0f766e !important;
  color: #ecfdf5 !important;
}

html[data-theme="dark"] .text-bg-danger {
  background-color: #b91c1c !important;
  color: #fef2f2 !important;
}

@media (max-width: 991.98px) {
  .dashboard-content > .container-fluid {
    padding-top: 1.25rem !important;
    padding-bottom: 1.25rem !important;
  }

  .admin-sidebar {
    box-shadow: 18px 0 48px rgba(0, 0, 0, 0.28);
  }
}

@media (max-width: 767.98px) {
  .panel-header {
    align-items: flex-start;
  }

  .panel-header > .d-flex {
    width: 100%;
  }

  .table-search {
    width: 100%;
  }

  .auth-page,
  .error-page {
    padding: 1rem;
  }

  .auth-card,
  .error-card {
    padding: 1.15rem;
  }
}

@media (max-width: 420px) {
  .heading-actions {
    width: 100%;
  }

  .heading-actions .btn {
    width: 100%;
  }

  .metric-card {
    min-height: 152px;
    padding: 1rem;
  }

  .metric-value {
    font-size: 1.75rem;
  }

  .metric-label {
    font-size: 0.72rem;
  }

  .metric-meta {
    font-size: 0.82rem;
  }

  .metric-icon {
    width: 36px;
    height: 36px;
    font-size: 0.85rem;
  }

  .profile-avatar-lg {
    width: 76px;
    height: 76px;
  }
}

@media (max-width: 575.98px) {
  .avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .avatar-xl {
    width: 70px;
    height: 70px;
  }

  .profile-cover {
    height: 82px;
    margin-bottom: 0.75rem;
  }

  .profile-photo {
    margin-top: -38px;
  }

  .auth-visual {
    height: 82px;
  }

}

html:not([data-theme="dark"]) {
  --admin-sidebar: #ffffff;
  --admin-sidebar-soft: #eef4ff;
  --admin-sidebar-border: #dbe4ef;
  --admin-sidebar-text: #475569;
  --admin-sidebar-text-strong: #0f172a;
  --admin-sidebar-muted: #64748b;
  --admin-sidebar-icon-bg: #eaf2ff;
  --admin-sidebar-icon: #2563eb;
  --admin-sidebar-shadow: 18px 0 42px rgba(15, 23, 42, 0.08);
}

html[data-theme="dark"] {
  --admin-sidebar-border: rgba(255, 255, 255, 0.08);
  --admin-sidebar-text: #d1d5db;
  --admin-sidebar-text-strong: #ffffff;
  --admin-sidebar-muted: #9ca3af;
  --admin-sidebar-icon-bg: rgba(255, 255, 255, 0.08);
  --admin-sidebar-icon: #bfdbfe;
  --admin-sidebar-shadow: 18px 0 42px rgba(0, 0, 0, 0.34);
}

.admin-sidebar {
  border-right: 1px solid var(--admin-sidebar-border);
  background: var(--admin-sidebar);
  color: var(--admin-sidebar-text-strong);
  box-shadow: var(--admin-sidebar-shadow);
}

.sidebar-header {
  border-bottom-color: var(--admin-sidebar-border);
}

.brand-mark,
.brand-mark:hover,
.brand-mark:focus {
  color: var(--admin-sidebar-text-strong);
}

.brand-subtitle {
  color: var(--admin-sidebar-muted);
}

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

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link:focus,
.sidebar-nav .nav-link.active {
  background: var(--admin-sidebar-soft);
  color: var(--admin-sidebar-text-strong);
}

.nav-icon {
  background: var(--admin-sidebar-icon-bg);
  color: var(--admin-sidebar-icon);
}

.sidebar-footer {
  border-top-color: var(--admin-sidebar-border);
  color: var(--admin-sidebar-text);
}

/* SweetAlert2 — the bundled CSS sets position:static which breaks the
   centered overlay.  Restore the default fixed positioning. */
.swal2-container {
  position: fixed !important;
  z-index: 1060 !important;
}

/* SVG icon system */
.ft-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  line-height: 1;
}

/* =====================================================
   MOBILE-FIRST IMPROVEMENTS
   ===================================================== */

/* Fix 1: Table cells - reduce min-width on mobile */
@media (max-width: 767.98px) {
  .table tbody td,
  .table thead th {
    min-width: 0;
  }
  .table-responsive {
    border: none;
  }
}

/* Fix 2: Bigger touch targets for small buttons on mobile */
@media (max-width: 767.98px) {
  .btn-sm {
    min-height: 44px;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
  }
  .btn-group-sm > .btn,
  .input-group-sm > .btn {
    min-height: 44px;
  }
}

/* Fix 3: Mobile search overlay */
.mobile-search-toggle {
  display: none;
}
@media (max-width: 767.98px) {
  .mobile-search-toggle {
    display: inline-flex;
  }
  .topbar-search {
    display: none !important;
  }
  .topbar-search.mobile-active {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    background: var(--admin-topbar-bg, #fff);
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    gap: 0.5rem;
    align-items: center;
  }
  .topbar-search.mobile-active .form-control {
    flex: 1 1 0;
    min-width: 0;
    min-height: 44px;
    font-size: 1rem;
    max-width: none;
  }
  .topbar-search.mobile-active .search-close-btn {
    display: inline-flex;
    flex-shrink: 0;
    min-height: 40px;
    padding: 0 12px;
    font-size: 0.85rem;
    white-space: nowrap;
  }
  .topbar-search.mobile-active .global-search-results {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    min-width: 0;
    max-width: none;
    max-height: none;
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--admin-border);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Fix 4: Notification dropdown - remove overflow on small screens */
@media (max-width: 575.98px) {
  .notification-menu {
    width: calc(100vw - 1rem) !important;
    min-width: 0 !important;
    max-width: 320px;
    right: -0.5rem;
  }
}

/* Fix 5: Collapsible filter panels on mobile */
@media (max-width: 767.98px) {
  .filter-collapse-toggle {
    display: inline-flex;
  }
  .filter-collapse-body {
    display: none;
  }
  .filter-collapse-body.show {
    display: block;
  }
}
@media (min-width: 768px) {
  .filter-collapse-toggle {
    display: none;
  }
  .filter-collapse-body {
    display: block !important;
  }
}

/* Bulk actions toolbar */
.bulk-toolbar {
  border-bottom: 1px solid var(--admin-border);
}
.bulk-check-cell {
  width: 40px;
  text-align: center;
}
.bulk-check-cell .form-check-input {
  margin: 0;
}

/* Worker search - inline activity selector */
.worker-add-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.worker-add-activity {
  display: flex;
  align-items: center;
  gap: 4px;
}
.worker-add-activity select {
  width: auto;
  min-width: 130px;
}

/* ==========================================================================
   Mobile Attendance (Phase 17 Item 13)
   ========================================================================== */

/* Hide the "Today's activities" panel on mobile — it's read-only context */
@media (max-width: 991.98px) {
  .attendance-activities-panel {
    display: none;
  }
}

/* --- Mobile: single-column stacked layout --- */
@media (max-width: 767.98px) {
  .attendance-layout .col-lg-4 {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
  }

  /* Sticky context bar: date + farm + supervisor */
  .attendance-ctx-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bs-body-bg, #fff);
    border-bottom: 1px solid var(--admin-border);
    padding: 0.5rem 0;
    margin-bottom: 0.75rem;
  }
  .attendance-ctx-bar .form-label {
    font-size: 0.75rem;
    margin-bottom: 0.1rem;
  }
  .attendance-ctx-bar .form-select,
  .attendance-ctx-bar .form-control {
    font-size: 0.875rem;
    padding: 0.35rem 0.5rem;
  }

  /* Search bar */
  .attendance-search-bar {
    position: sticky;
    top: auto;
    z-index: 99;
    background: var(--bs-body-bg, #fff);
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--admin-border);
    margin-bottom: 0.75rem;
  }
  .attendance-search-bar #worker_q {
    font-size: 1rem;
    padding: 0.6rem 0.75rem;
    min-height: 48px;
  }
  .attendance-search-bar #worker_search {
    min-height: 48px;
    font-size: 1rem;
  }

  /* Worker search results: full-width cards */
  .worker-search-item {
    padding: 0.6rem 0.5rem;
    gap: 0.5rem;
  }
  .worker-search-photo {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
  }
  .worker-search-info {
    font-size: 0.875rem;
  }

  /* Inline activity selector: stack vertically on mobile */
  .worker-add-wrap {
    align-items: stretch;
    width: 100%;
    margin-top: 0.35rem;
  }
  .worker-add-wrap .worker-add {
    width: 100%;
    min-height: 44px;
    font-size: 1rem;
  }
  .worker-add-activity {
    flex-direction: column;
    gap: 6px;
    width: 100%;
  }
  .worker-add-activity select {
    width: 100%;
    min-height: 48px;
    font-size: 1rem;
  }
  .worker-add-activity .btn {
    min-height: 44px;
    font-size: 1rem;
    width: 100%;
  }

  /* Staged table: card-style rows */
  .staged-mobile-cards {
    display: block !important;
  }
  .staged-mobile-cards .table-responsive {
    display: none;
  }
  .staged-mobile-card {
    border: 1px solid var(--admin-border);
    border-radius: 0.5rem;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bs-body-bg, #fff);
  }
  .staged-mobile-card .staged-card-name {
    font-weight: 600;
    font-size: 0.95rem;
  }
  .staged-mobile-card .staged-card-id {
    font-size: 0.8rem;
    color: var(--bs-secondary-color, #6c757d);
  }
  .staged-mobile-card select {
    width: 100%;
    min-height: 44px;
    margin-top: 0.35rem;
    font-size: 0.95rem;
  }
  .staged-mobile-card .staged-card-remove {
    margin-top: 0.35rem;
  }
  .staged-mobile-card .staged-card-remove .btn {
    width: 100%;
    min-height: 40px;
  }

  /* Hide desktop staged table on mobile */
  .staged-desktop-table {
    display: none;
  }

  /* Sticky save bar at bottom */
  .attendance-save-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--bs-body-bg, #fff);
    border-top: 2px solid var(--bs-primary, #0d6efd);
    padding: 0.6rem 1rem;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }
  .attendance-save-bar .save-count {
    font-size: 0.875rem;
    color: var(--bs-secondary-color, #6c757d);
  }
  .attendance-save-bar .btn {
    flex: 0 0 auto;
    min-height: 48px;
    min-width: 80px;
    font-size: 1rem;
    padding: 0.5rem 1.25rem;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  /* Prevent body from hiding behind fixed save bar */
  .attendance-save-bar-spacer {
    height: 70px;
  }
}

/* --- Attendance hub: batch form mobile grid --- */
@media (max-width: 767.98px) {
  #batchSection .row.g-3 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
  #batchSection .row.g-3 > [class*="col-12"] {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
  }
  #batchSection .form-control,
  #batchSection .form-select {
    min-height: 44px;
    font-size: 0.95rem;
  }
  #batchSection .work-type-btn {
    flex: 1;
    min-height: 44px;
    font-size: 0.9rem;
  }

  #batchSection .panel-header .d-flex {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.5rem;
  }
  #batchSection .panel-header .form-control,
  #batchSection .panel-header .form-control-sm {
    width: 100%;
  }

  #batchSection .p-3.d-flex.gap-2 {
    flex-direction: column;
  }
  #batchSection .p-3.d-flex.gap-2 .btn {
    width: 100%;
  }

  /* Individual tab: full-width button */
  #importSection .row.g-3 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  #importSection .row.g-3 > [class*="col-"] {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
  }
  #importSection .form-control-lg,
  #importSection .btn-lg {
    min-height: 48px;
    font-size: 1rem;
  }

  /* Individual tab CTA */
  .attendance-hub-individual .btn-lg {
    width: 100%;
    min-height: 52px;
    font-size: 1.1rem;
    padding: 0.75rem 1.5rem;
  }

  /* Attendance record modal: full width on small screens */
  .attendance-record-modal .modal-dialog {
    margin: 0.5rem;
    max-height: calc(100vh - 1rem);
  }
  .attendance-record-modal .modal-body {
    max-height: calc(100vh - 10rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .attendance-record-modal .work-type-toggle-modal {
    flex-direction: column;
    gap: 0.5rem;
  }
  .attendance-record-modal .work-type-toggle-modal .btn {
    width: 100%;
    min-height: 44px;
  }

  /* Work type buttons on batch: stack on very small screens */
  #batchSection .work-type-btn {
    min-height: 48px;
    font-size: 0.85rem;
  }
}

/* --- Very small screens: single column batch grid --- */
@media (max-width: 420px) {
  #batchSection .row.g-3 {
    grid-template-columns: 1fr;
  }
  #batchSection .panel-header .d-flex {
    flex-direction: column;
    align-items: stretch !important;
  }
}

/* Desktop: hide mobile-only elements */
@media (min-width: 768px) {
  .staged-mobile-cards {
    display: none !important;
  }
  .attendance-save-bar,
  .attendance-save-bar-spacer {
    display: none !important;
  }
}

/* ==========================================================================
   Shared Mobile Patterns — Hub Pages (Phase 17 Item 13 expansion)
   ========================================================================== */

@media (max-width: 767.98px) {
  /* --- Filter panels: collapse to 2-column grid --- */
  .mobile-filter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .mobile-filter-grid .form-label {
    font-size: 0.75rem;
    margin-bottom: 0.1rem;
  }
  .mobile-filter-grid .form-select,
  .mobile-filter-grid .form-control {
    font-size: 0.875rem;
    padding: 0.35rem 0.5rem;
  }
  .mobile-filter-grid .col-12,
  .mobile-filter-grid [class*="col-md"] {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
  }
  .mobile-filter-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.5rem;
  }
  .mobile-filter-actions .btn {
    flex: 1;
    min-height: 44px;
  }

  /* --- Metric cards row: 2x2 grid on mobile --- */
  .mobile-metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }
  .mobile-metrics-grid .metric-card {
    padding: 0.6rem 0.75rem;
  }
  .mobile-metrics-grid .metric-value {
    font-size: 1.25rem;
  }

  /* --- Data tables: card rows on mobile --- */
  .mobile-card-table thead {
    display: none;
  }
  .mobile-card-table tbody tr {
    display: block;
    border: 1px solid var(--admin-border);
    border-radius: 0.5rem;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bs-body-bg, #fff);
  }
  .mobile-card-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.2rem 0;
    border: none;
    font-size: 0.875rem;
  }
  .mobile-card-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--bs-secondary-color, #6c757d);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex: 0 0 35%;
  }
  .mobile-card-table tbody td:last-child {
    justify-content: flex-end;
    padding-top: 0.4rem;
    border-top: 1px solid var(--admin-border);
    margin-top: 0.2rem;
  }
  .mobile-card-table tbody td.bulk-check-cell {
    display: none;
  }

  /* Hide desktop-only columns */
  .mobile-hide {
    display: none !important;
  }

  /* --- Sticky action buttons --- */
  .mobile-sticky-action {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--bs-body-bg, #fff);
    border-top: 2px solid var(--bs-primary, #0d6efd);
    padding: 0.6rem 1rem;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
  }
  .mobile-sticky-action .btn {
    min-height: 48px;
    font-size: 1rem;
    padding: 0.5rem 1.5rem;
  }
  .mobile-sticky-action-spacer {
    height: 70px;
  }

  /* --- Tabs: horizontal scroll --- */
  .mobile-scroll-tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0;
    border-bottom: 2px solid var(--admin-border);
    padding: 0;
  }
  .mobile-scroll-tabs::-webkit-scrollbar {
    display: none;
  }
  .mobile-scroll-tabs .nav-link,
  .mobile-scroll-tabs .tab-link {
    white-space: nowrap;
    flex: 0 0 auto;
    padding: 0.6rem 1rem;
    font-size: 0.875rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
  }
  .mobile-scroll-tabs .nav-link.active,
  .mobile-scroll-tabs .tab-link.active {
    border-bottom-color: var(--bs-primary, #0d6efd);
    font-weight: 600;
  }

  /* --- Page heading: compact on mobile --- */
  .page-heading .heading-actions {
    margin-top: 0.5rem;
  }
  .page-heading .heading-actions .btn {
    min-height: 44px;
    font-size: 0.95rem;
  }

  /* --- Sections with heading-actions: stack --- */
  .panel-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.5rem;
  }
}

/* Desktop: hide mobile-only elements */
@media (min-width: 768px) {
  .mobile-sticky-action,
  .mobile-sticky-action-spacer {
    display: none !important;
  }
}

/* Sticky table headers on mobile */
@media (max-width: 767.98px) {
  .table-responsive thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bs-body-bg, #fff);
    box-shadow: 0 1px 0 var(--bs-border-color, #dee2e6);
  }
  .ft-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    flex-wrap: nowrap;
  }
  .ft-tabs .ft-tab {
    flex-shrink: 0;
  }
  .farm-view-actions-desktop { display: none !important; }
  .farm-view-actions-mobile { display: flex !important; }
}
@media (min-width: 768px) {
  .farm-view-actions-mobile { display: none !important; }
}
