/* Agrasen FMS Admin Portal - shared styles */
:root {
  --bg: #F4F5F6;
  --surface: #FFFFFF;
  --ink: #171B20;
  --muted: #646E7A;
  --border: #E3E6EA;
  --primary: #122336;
  --primary-2: #1B3654;
  --accent: #C4601F;
  --accent-soft: #FBE8DA;
  --success: #1F7A4D;
  --success-soft: #E4F3EA;
  --warning: #8A5A12;
  --warning-soft: #FBF0DE;
  --danger: #B3261E;
  --danger-soft: #FBE6E4;
  --info: #1F4E8C;
  --info-soft: #E7EEF9;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
}

a {
  color: inherit;
}

/* ==========================================================================
       TOPBAR NAVIGATION HEADER (3 TABS: MAIN DASHBOARD, LOADING, UN-LOADING)
       ========================================================================== */
.app-topbar {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  height: 64px;
  background: #FFFFFF;
  border-bottom: 1px solid #E5E7EB;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-toggle-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #4B5563;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.topbar-toggle-btn:hover {
  background: #F3F4F6;
  color: #111827;
  border-color: #E5E7EB;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.topbar-brand:hover {
  opacity: 0.92;
  transform: translateY(-0.5px);
}

.topbar-brand-logo {
  height: 34px;
  width: auto;
  max-width: 175px;
  object-fit: contain;
  display: block;
}

.topbar-brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: #0F172A;
  color: #00A6E8;
  border: 1px solid rgba(0, 166, 232, 0.3);
  padding: 2px 7px;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.topbar-brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 2px 4px rgba(196, 96, 31, 0.25);
}

.topbar-brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  color: #111827;
  letter-spacing: -0.01em;
}

/* Center Tab Pills Container */
.topbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-pill-group {
  display: inline-flex;
  align-items: center;
  background: #F3F4F6;
  padding: 4px;
  border-radius: 9999px;
  gap: 4px;
  border: 1px solid #E5E7EB;
}

.topbar-tab-wrapper {
  position: relative;
}

.topbar-tab-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 9999px;
  font-size: 13.5px;
  font-weight: 500;
  color: #4B5563;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
  white-space: nowrap;
}

.topbar-tab-pill .tab-ic {
  flex-shrink: 0;
  opacity: 0.85;
}

.topbar-tab-pill .tab-arrow {
  opacity: 0.55;
  transition: transform 0.2s ease;
  margin-left: -2px;
}

.topbar-tab-wrapper:hover .tab-arrow,
.topbar-tab-wrapper.open .tab-arrow {
  transform: rotate(180deg);
  opacity: 0.9;
}

.topbar-tab-pill:hover {
  color: #111827;
  background: rgba(0, 0, 0, 0.04);
}

/* Active Tab Style (Brand Orange Pill) */
.topbar-tab-wrapper.active .topbar-tab-pill {
  background: var(--accent);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(196, 96, 31, 0.35);
}

.topbar-tab-wrapper.active .topbar-tab-pill .tab-ic {
  opacity: 1;
}

.topbar-tab-wrapper.active .topbar-tab-pill .tab-arrow {
  opacity: 0.85;
}

/* Hover Bridge on tab wrapper - bridges gap between pill and dropdown */
.topbar-tab-wrapper::after {
  content: '';
  position: absolute;
  top: 100%;
  left: -40px;
  right: -40px;
  height: 24px;
  background: transparent;
  pointer-events: auto;
  z-index: 1049;
}

/* Topbar Dropdowns (Mega Menu & Single Column) */
.topbar-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-6px);
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 14px;
  box-shadow: 0 16px 36px -4px rgba(0, 0, 0, 0.12), 0 6px 12px -2px rgba(0, 0, 0, 0.04);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s;
  transition-delay: 0.2s;
  z-index: 1050;
}

/* Top bridge extending above dropdown across its entire width */
.topbar-dropdown::after {
  content: '';
  position: absolute;
  top: -16px;
  left: -30px;
  right: -30px;
  height: 22px;
  background: transparent;
  pointer-events: auto;
  z-index: 1;
}

/* Hover, open class, or dropdown hover triggers and keeps dropdown visible immediately */
.topbar-tab-wrapper:hover .topbar-dropdown,
.topbar-tab-wrapper.open .topbar-dropdown,
.topbar-dropdown:hover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
  transition-delay: 0s;
}

/* Little arrow pointer at top of dropdown */
.topbar-dropdown::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: #FFFFFF;
  border-left: 1px solid #E5E7EB;
  border-top: 1px solid #E5E7EB;
  border-top-left-radius: 2px;
  z-index: 2;
}

/* Mega Menu Grid */
.mega-menu {
  width: min(840px, 94vw);
  max-height: calc(100vh - 84px);
  overflow-y: auto;
  padding: 18px 22px;
}

.mega-menu::-webkit-scrollbar {
  width: 5px;
}

.mega-menu::-webkit-scrollbar-thumb {
  background: #D1D5DB;
  border-radius: 4px;
}

.mega-menu-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.mega-col {
  display: flex;
  flex-direction: column;
}

.mega-section-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.mega-list,
.dropdown-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mega-list li a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  color: #374151;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.15s ease;
}

.mega-list li a .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #9CA3AF;
  transition: transform 0.15s, background 0.15s;
}

.mega-list li a .step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #F3F4F6;
  color: #6B7280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.mega-list li a:hover,
.mega-list li.active a,
.mega-list li a.active {
  background: #FFF7ED;
  color: var(--accent);
}

.mega-list li a:hover .dot,
.mega-list li.active a .dot,
.mega-list li a.active .dot {
  background: var(--accent);
  transform: scale(1.3);
}

.mega-list li a:hover .step-num,
.mega-list li.active a .step-num,
.mega-list li a.active .step-num {
  background: var(--accent);
  color: #FFFFFF;
}

/* Single Menu (Loading / Un-Loading) */
.single-menu {
  width: 280px;
  padding: 12px;
}

.dropdown-head {
  padding: 6px 10px 10px;
  border-bottom: 1px solid #F3F4F6;
  margin-bottom: 6px;
}

.dropdown-title {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: #111827;
}

.dropdown-sub {
  display: block;
  font-size: 11.5px;
  color: #6B7280;
  margin-top: 1px;
}

.dropdown-list li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: #374151;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.15s ease;
}

.dropdown-list li a .step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #F3F4F6;
  color: #6B7280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.dropdown-list li a svg {
  flex-shrink: 0;
}

.dropdown-list li a:hover,
.dropdown-list li.active a,
.dropdown-list li a.active {
  background: #FFF7ED;
  color: var(--accent);
}

.dropdown-list li a:hover .step-num,
.dropdown-list li.active a .step-num,
.dropdown-list li a.active .step-num {
  background: var(--accent);
  color: #FFFFFF;
}

/* Right Section: Search & User */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-search-wrap {
  position: relative;
  width: 220px;
}

.topbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9CA3AF;
  pointer-events: none;
}

.topbar-search-input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 9999px;
  font-size: 13px;
  color: #1F2937;
  outline: none;
  transition: all 0.15s ease;
}

.topbar-search-input:focus {
  background: #FFFFFF;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196, 96, 31, 0.15);
  width: 260px;
}

.search-quick-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 280px;
  background: #fff;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.1);
  display: none;
  max-height: 320px;
  overflow-y: auto;
  z-index: 1060;
  padding: 6px;
}

/* User Profile Pill */
.topbar-user-wrap {
  position: relative;
}

.topbar-user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 9999px;
  border: 1px solid #E5E7EB;
  background: #FFFFFF;
  cursor: pointer;
  transition: all 0.15s ease;
}

.topbar-user-pill:hover {
  background: #F9FAFB;
  border-color: #D1D5DB;
}

.topbar-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #1F2937;
}

.topbar-user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: #FFFFFF;
  border: 1px solid #E5E7EB;
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.1);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px);
  transition: all 0.18s ease;
  z-index: 1050;
  padding: 8px;
}

.topbar-user-wrap:hover .topbar-user-menu,
.topbar-user-wrap.open .topbar-user-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.user-menu-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}

.user-menu-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-menu-info .name {
  font-size: 13px;
  font-weight: 600;
  color: #111827;
}

.user-menu-info .role {
  font-size: 11px;
  color: #6B7280;
}

.user-menu-divider {
  height: 1px;
  background: #F3F4F6;
  margin: 6px 0;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: #374151;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.15s ease;
}

.user-menu-item:hover {
  background: #F3F4F6;
  color: #111827;
}

.user-menu-item.logout-btn:hover {
  background: #FEE2E2;
  color: #DC2626;
}

/* Shell & Layout */
.app-shell {
  display: flex;
  width: 100%;
  min-height: calc(100vh - 64px);
  background: var(--bg);
  overflow-x: clip;
  position: relative;
}

.screen-wrap {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar */
.sidebar {
  width: 252px;
  min-width: 252px;
  max-width: 252px;
  flex-shrink: 0;
  background: var(--primary);
  color: #C9D2DC;
  display: flex;
  flex-direction: column;
  padding: 16px 14px 20px;
  gap: 16px;
  box-sizing: border-box;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-left: 0;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, visibility 0.25s;
}

/* Sidebar Toggle Collapsed State */
body.sidebar-collapsed .sidebar,
html.sidebar-collapsed .sidebar {
  margin-left: -252px !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Slim scrollbar for the sidebar's own overflow */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: #fff;
}

.brand-sub {
  font-size: 10.5px;
  color: #8DA0B4;
  letter-spacing: .03em;
}

.nav-group-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #6C8098;
  padding: 12px 12px 4px;
  font-weight: 600;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: #B7C3D1;
  font-size: 13.5px;
  font-weight: 500;
}

.nav-item .ic {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-item.active,
.nav-item.active-nav {
  background: var(--accent);
  color: #fff;
}

.nav-item .count {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}

.nav-item.active .count,
.nav-item.active-nav .count {
  background: rgba(255, 255, 255, 0.28);
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.user-name {
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
}

.user-role {
  font-size: 10.5px;
  color: #8DA0B4;
}

/* Main */
.main {
  flex: 1;
  min-width: 0;
  padding: 28px 36px 60px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  position: relative;
  border-left: 3.5px solid var(--accent);
  transition: box-shadow 0.2s ease;
}

.topbar:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.crumb {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.crumb a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.crumb a:hover {
  color: var(--accent);
}

.topbar-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(196, 96, 31, 0.1) 0%, rgba(245, 158, 11, 0.12) 100%);
  border: 1px solid rgba(196, 96, 31, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(196, 96, 31, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.topbar:hover .topbar-icon-box {
  transform: scale(1.03);
  box-shadow: 0 2px 6px rgba(196, 96, 31, 0.12);
}

.topbar-icon-box svg {
  width: 18px;
  height: 18px;
}

.topbar-heading-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.page-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: var(--ink);
  line-height: 1.2;
}

.topbar-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #EFF6FF;
  color: #1D4ED8;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1.5px 7px;
  border-radius: 10px;
  border: 1px solid #DBEAFE;
  letter-spacing: 0.02em;
}

.topbar-badge .badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #0EA5E9;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
}

.page-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 1px;
  line-height: 1.35;
}

.topbar-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #F8FAFC;
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--muted);
}

.topbar-stat-pill strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

.btn-cta {
  background: linear-gradient(135deg, #D46B28 0%, #C4601F 100%) !important;
  color: #fff !important;
  border: 1px solid rgba(196, 96, 31, 0.35) !important;
  box-shadow: 0 2px 6px rgba(196, 96, 31, 0.25);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 12px rgba(196, 96, 31, 0.35);
  filter: brightness(1.05);
  color: #fff !important;
}

.btn-cta:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(196, 96, 31, 0.2);
}

@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 18px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--font-body);
  white-space: nowrap;
}

.btn .ic {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-secondary {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--ink);
}

.btn-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #991B1B;
  color: #fff;
}

.btn-warning {
  background: #D97706;
  color: #fff;
}

.btn-warning:hover {
  background: #B45309;
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: #166534;
  color: #fff;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}

/* KPI */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kpi-label {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
}

.kpi-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-icon .ic {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 29px;
  font-weight: 700;
  color: var(--ink);
}

.kpi-value.warn {
  color: var(--warning);
}

.kpi-value.danger {
  color: var(--danger);
}

.kpi-value.success {
  color: var(--success);
}

.kpi-delta {
  font-size: 11.5px;
  color: var(--muted);
}

/* Panel / card */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
}

.panel+.panel {
  margin-top: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.panel-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.row-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  align-items: start;
}

.row-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.panel .table-wrap:has(.dataTables_wrapper),
.panel .table-wrap:has(.dataTables_scroll) {
  overflow: visible;
}

.table-wrap::-webkit-scrollbar {
  height: 6px;
}

.table-wrap::-webkit-scrollbar-track {
  background: #F1F5F9;
  border-radius: 4px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 4px;
}

.table-wrap::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}

table.data-table,
table.dataTable {
  width: 100% !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  font-size: 12.8px;
}

.data-table th,
table.dataTable th {
  text-align: left;
  font-size: 10.8px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  font-weight: 700;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background-color: var(--surface);
}

.data-table td,
table.dataTable td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  white-space: nowrap;
  background-color: var(--surface);
}

.data-table tr:last-child td,
table.dataTable tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td,
table.dataTable tr:hover td {
  background: #FAFAF9 !important;
}

table.dataTable th.dtfc-fixed-left,
table.dataTable td.dtfc-fixed-left {
  background-color: #FFFFFF !important;
  z-index: 2;
}

table.dataTable thead th.dtfc-fixed-left {
  background-color: var(--surface) !important;
  z-index: 5 !important;
}

table.dataTable th.dtfc-fixed-right,
table.dataTable td.dtfc-fixed-right {
  background-color: #FFFFFF !important;
  z-index: 2;
}

table.dataTable thead th.dtfc-fixed-right {
  background-color: var(--surface) !important;
  z-index: 5 !important;
}

table.dataTable tr:hover td.dtfc-fixed-left,
table.dataTable tr:hover td.dtfc-fixed-right {
  background-color: #FAFAF9 !important;
}

.data-table tr.empty-row td {
  color: transparent;
  pointer-events: none;
}

.data-table tr.empty-row:hover td {
  background: transparent !important;
}

.cell-muted {
  color: var(--muted);
}

.cell-strong {
  font-weight: 700;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3.5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}

.badge-pending {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-progress {
  background: var(--info-soft);
  color: var(--info);
}

.badge-done {
  background: var(--success-soft);
  color: var(--success);
}

.badge-delay {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-neutral {
  background: #EEF0F2;
  color: var(--muted);
}

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
}

.field input,
.field select,
.field textarea {
  padding: 9.5px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #A7AFB8;
}

.field-hint {
  font-size: 11px;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.checkbox-row:last-child {
  border-bottom: none;
}

.chk {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.6px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chk.on {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.chk.off {
  background: #fff;
}

.chk.warn {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

/* Stepper */
.stepper {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}

.step {
  flex: 1;
  text-align: center;
  font-size: 10.8px;
  color: var(--muted);
  padding-bottom: 9px;
  border-bottom: 3px solid var(--border);
  font-weight: 600;
}

.step.done {
  color: var(--success);
  border-color: var(--success);
}

.step.active {
  color: var(--accent);
  border-color: var(--accent);
}

/* Misc */
.pill-tabs {
  display: flex;
  gap: 4px;
  background: #EEF0F2;
  border-radius: 9px;
  padding: 4px;
  width: fit-content;
}

.pill-tab {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.pill-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 18px 0;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.stat-line {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12.8px;
}

.stat-line:last-child {
  border-bottom: none;
}

.stat-line .k {
  color: var(--muted);
}

.stat-line .v {
  font-weight: 700;
}

.timeline {
  display: flex;
  flex-direction: column;
}

.tl-item {
  display: flex;
  gap: 12px;
  padding-bottom: 18px;
  position: relative;
}

.tl-item:last-child {
  padding-bottom: 0;
}

.tl-dot-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tl-dot {
  width: 13px;
  height: 13px;
  border-radius: 999px;
  border: 3px solid var(--surface);
  flex-shrink: 0;
}

.tl-line {
  width: 2px;
  flex: 1;
  background: var(--border);
}

.tl-content {
  flex: 1;
  padding-bottom: 2px;
}

.tl-title {
  font-size: 12.8px;
  font-weight: 700;
  color: var(--ink);
}

.tl-meta {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}


.app-shell {
  width: 100%;
  min-height: 100vh;
}

.screen-wrap {
  flex: 1;
  min-width: 0;
}

.module-screen {
  display: none;
}

.module-screen.active-module {
  display: block;
}

.sub-view {
  display: none;
}

.sub-view.active-view {
  display: block;
}

.sub-tabs {
  display: flex;
  gap: 4px;
  background: #EEF0F2;
  border-radius: 9px;
  padding: 4px;
  width: fit-content;
  margin-bottom: 18px;
}

.sub-tab {
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 12.8px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  display: flex;
  align-items: center;
  gap: 7px;
}

.sub-tab.active-tab {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.sub-tab .ic {
  width: 14px;
  height: 14px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.field-row:last-child {
  border-bottom: none;
}

.field-row .frow-label {
  font-size: 12.8px;
  font-weight: 700;
  color: var(--ink);
}

/* Readonly date/time inputs: hide the native picker so the value cannot be changed */
input[type="date"][readonly]::-webkit-calendar-picker-indicator,
input[type="time"][readonly]::-webkit-calendar-picker-indicator,
input[type="datetime-local"][readonly]::-webkit-calendar-picker-indicator {
  display: none;
}

.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  background: #fff;
  white-space: nowrap;
}

.radio-pill input[type=radio] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  margin: 0;
}

.field-note {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.5;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 6px;
}

.required-star {
  color: var(--danger);
  font-weight: 700;
}

.form-required-hint {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 14px;
}

.who-when {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.who-when b {
  color: var(--ink);
}

/* Action Dropdown */
.action-dropdown {
  position: relative;
  display: inline-block;
}

.action-dots-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-dots-btn:hover,
.action-dots-btn.active {
  background: #F4F5F6;
  color: var(--ink);
  border-color: #D1D5DB;
}

.action-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  z-index: 100;
  min-width: 145px;
  padding: 4px 0;
}

.action-menu.show {
  display: block;
}

.action-dropdown.dropup .action-menu {
  top: auto;
  bottom: calc(100% + 4px);
}

.action-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.action-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.action-menu-item:hover {
  background: #F4F5F6;
  color: var(--accent);
}

.action-menu-item.text-danger {
  color: var(--danger);
}

.action-menu-item.text-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.action-menu-item .ic {
  width: 13px;
  height: 13px;
  stroke-width: 2;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 35, 54, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal-card {
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  width: 100%;
  max-width: 520px;
  overflow: hidden;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Input with Leading Icon */
.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: #8C96A3;
  pointer-events: none;
  stroke-width: 1.8;
}

.input-with-icon input {
  padding-left: 38px !important;
  width: 100%;
}

/* DataTables Custom Styling */
.dataTables_wrapper {
  position: relative;
  clear: both;
  font-family: var(--font-body);
  font-size: 13px;
}

.dataTables_wrapper .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  clear: both;
}

.dataTables_wrapper .bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  clear: both;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_processing,
.dataTables_wrapper .dataTables_paginate {
  color: var(--muted);
  font-size: 12.5px;
}

.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  margin: 0 4px;
}

.dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  margin-left: 6px;
  outline: none;
  transition: border-color .15s;
}

.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--primary);
}

.dataTables_wrapper .dataTables_info {
  float: none !important;
  padding-top: 0 !important;
  font-size: 12.5px;
  color: var(--muted);
  margin: 0;
}

.dataTables_wrapper .dataTables_paginate {
  float: none !important;
  padding-top: 0 !important;
  text-align: right;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 3px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  margin-left: 2px;
  text-align: center;
  text-decoration: none !important;
  cursor: pointer;
  color: var(--ink) !important;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--bg) !important;
  color: var(--primary) !important;
  border-color: #CCD2D9;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background-color: var(--accent) !important;
  background: var(--accent) !important;
  color: #ffffff !important;
  border-color: var(--accent) !important;
  font-weight: 700 !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
  cursor: not-allowed;
  opacity: 0.4;
  background: #FAFAFA !important;
  border-color: var(--border) !important;
  color: var(--muted) !important;
}

.dataTables_wrapper .dataTables_processing {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  z-index: 10;
}

table.dataTable.no-footer {
  border-bottom: 1px solid var(--border) !important;
}

.dataTables_wrapper.no-footer .dataTables_scrollBody {
  border-bottom: 1px solid var(--border) !important;
}

/* FixedColumns and Empty Table Styling */
.dataTables_wrapper .dataTables_empty {
  padding: 30px 16px !important;
  color: var(--muted) !important;
  font-size: 13px !important;
  text-align: center !important;
  background: transparent !important;
}

.DTFC_LeftBodyWrapper,
.DTFC_RightBodyWrapper {
  background: transparent !important;
}

/* Select2 Theme Integration */
.select2-container {
  width: 100% !important;
}

.select2-container--default .select2-selection--single {
  height: 40px !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  background: #fff !important;
  display: flex !important;
  align-items: center !important;
  padding: 0 4px !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(18, 35, 54, 0.08) !important;
  outline: none !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--ink) !important;
  font-size: 13px !important;
  font-family: inherit !important;
  line-height: 38px !important;
  padding-left: 8px !important;
  padding-right: 28px !important;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
  color: #A7AFB8 !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 38px !important;
  right: 10px !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
  border-color: var(--muted) transparent transparent transparent !important;
  border-width: 5px 4px 0 4px !important;
}

.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
  border-color: transparent transparent var(--muted) transparent !important;
  border-width: 0 4px 5px 4px !important;
}

.select2-dropdown {
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1) !important;
  font-size: 13px !important;
  font-family: inherit !important;
  background: #fff !important;
  z-index: 9999 !important;
  overflow: hidden;
}

.select2-search--dropdown {
  padding: 8px 10px !important;
}

.select2-search--dropdown .select2-search__field {
  border: 1px solid var(--border) !important;
  border-radius: 6px !important;
  padding: 6px 10px !important;
  font-size: 12.5px !important;
  font-family: inherit !important;
  color: var(--ink) !important;
  outline: none !important;
}

.select2-search--dropdown .select2-search__field:focus {
  border-color: var(--primary) !important;
}

.select2-results__option {
  padding: 7px 12px !important;
  font-size: 13px !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: var(--primary) !important;
  color: #fff !important;
}

.select2-container--default .select2-results__option[aria-selected="true"] {
  background-color: #f1f5f9 !important;
  color: var(--ink) !important;
  font-weight: 600;
}

/* Quick Add Button */
.btn-quick-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid #fed7aa;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.4;
  text-decoration: none;
}

.btn-quick-add:hover {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(196, 96, 31, 0.25);
}

/* Global Responsive Table Container */
.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   AGRASEN FMS - COMPREHENSIVE MOBILE RESPONSIVE SYSTEM
   Supports: Small Phones (320px-390px), Standard Phones (390px-480px),
             Large Phones & Phablets (480px-768px), Tablets (768px-991px)
   ========================================================================== */

/* 1. Mobile Sidebar Backdrop & Drawer Overlay */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.68);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 1150;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

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

body.sidebar-mobile-open {
  overflow: hidden !important;
}

/* Mobile Sidebar Header & Close Button */
.sidebar-mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 12px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 8px;
  flex-shrink: 0;
}

.sidebar-mobile-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #FFFFFF;
  font-weight: 700;
  font-size: 14px;
  font-family: var(--font-display);
}

.sidebar-mobile-close {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.sidebar-mobile-close:hover,
.sidebar-mobile-close:active {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.05);
}

/* Base Mobile Responsive Helpers */
@media (max-width: 991px) {
  html, body {
    overflow-x: clip;
  }

  .app-shell {
    min-height: calc(100vh - 56px);
  }

  /* Sidebar transforms into an off-canvas drawer */
  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: -290px !important;
    width: 280px !important;
    max-width: 85vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    z-index: 1200 !important;
    margin-left: 0 !important;
    transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.28s ease !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    box-shadow: none !important;
    padding-top: 14px !important;
  }

  body.sidebar-mobile-open .sidebar {
    left: 0 !important;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.65) !important;
  }

  /* Disable desktop margin collapse on mobile */
  body.sidebar-collapsed .sidebar,
  html.sidebar-collapsed .sidebar {
    margin-left: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  .sidebar-mobile-header {
    display: flex !important;
  }

  /* ==========================================================================
     MOBILE APP TWO-TIER TOPBAR (max-width: 991px)
     Row 1 (52px): [=] [AF] Agrasen FMS  ................  [🔍] [A]
     Row 2 (44px): [📊 Main Dashboard] [🚚 Loading] [📦 Un-Loading] (Swipeable)
     ========================================================================== */
  .app-topbar {
    height: auto !important;
    min-height: 52px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0 !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 1000 !important;
    background: #FFFFFF !important;
    border-bottom: 1px solid #E5E7EB !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05) !important;
  }

  /* Row 1 Left: Hamburger + Brand Mark + Brand Title */
  .topbar-left {
    height: 52px !important;
    padding-left: 12px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex: 0 0 auto !important;
  }

  .topbar-toggle-btn {
    width: 36px !important;
    height: 36px !important;
    color: #374151 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .topbar-brand {
    gap: 6px !important;
    display: flex !important;
    align-items: center !important;
  }

  .topbar-brand-logo {
    height: 26px !important;
    max-width: 135px !important;
  }

  .topbar-brand-badge {
    font-size: 9.5px !important;
    padding: 1px 5px !important;
  }

  .topbar-brand-mark {
    width: 30px !important;
    height: 30px !important;
    font-size: 13px !important;
    border-radius: 7px !important;
    flex-shrink: 0 !important;
  }

  .topbar-brand-title {
    font-size: 15px !important;
    font-weight: 700 !important;
    color: #0F172A !important;
    display: inline-block !important;
    letter-spacing: -0.01em !important;
    white-space: nowrap !important;
  }

  /* Row 1 Right: Search Icon Button + User Profile Avatar */
  .topbar-right {
    height: 52px !important;
    padding-right: 12px !important;
    margin-left: auto !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    flex: 0 0 auto !important;
  }

  .topbar-search-wrap {
    width: 36px !important;
    height: 36px !important;
    transition: all 0.25s ease !important;
    position: relative !important;
  }

  .topbar-search-input {
    width: 100% !important;
    height: 36px !important;
    padding-left: 32px !important;
    padding-right: 8px !important;
    font-size: 13px !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    border-radius: 20px !important;
    cursor: pointer !important;
  }

  .topbar-search-icon {
    left: 10px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 16px !important;
    height: 16px !important;
    color: #64748B !important;
  }

  .topbar-search-wrap:focus-within {
    position: absolute !important;
    top: 8px !important;
    left: 54px !important;
    right: 54px !important;
    width: auto !important;
    z-index: 1060 !important;
  }

  .topbar-search-wrap:focus-within .topbar-search-input {
    background: #FFFFFF !important;
    border-color: var(--accent) !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12) !important;
    cursor: text !important;
  }

  .topbar-user-pill {
    padding: 0 !important;
    gap: 0 !important;
    border-radius: 50% !important;
    width: 36px !important;
    height: 36px !important;
    justify-content: center !important;
    border: 1px solid #E2E8F0 !important;
    background: #F8FAFC !important;
    display: flex !important;
    align-items: center !important;
  }

  .topbar-user-avatar {
    width: 30px !important;
    height: 30px !important;
    font-size: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .topbar-user-name,
  .topbar-user-pill .tab-arrow {
    display: none !important;
  }

  .topbar-user-menu {
    position: fixed !important;
    top: 54px !important;
    right: 8px !important;
    left: auto !important;
    width: 250px !important;
    max-width: calc(100vw - 16px) !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12) !important;
    z-index: 1060 !important;
  }

  /* Row 2: Full-Width Mobile App Segmented Tabs Bar */
  .topbar-center {
    order: 3 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 44px !important;
    background: #F8FAFC !important;
    border-top: 1px solid #F1F5F9 !important;
    border-bottom: 1px solid #E2E8F0 !important;
    padding: 0 12px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
  }

  .topbar-center::-webkit-scrollbar {
    display: none !important;
  }

  .topbar-pill-group {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    width: max-content !important;
    flex-shrink: 0 !important;
  }

  .topbar-tab-wrapper {
    flex-shrink: 0 !important;
  }

  .topbar-tab-pill {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 6px 14px !important;
    font-size: 12.5px !important;
    font-weight: 600 !important;
    border-radius: 20px !important;
    background: #FFFFFF !important;
    border: 1px solid #E2E8F0 !important;
    color: #475569 !important;
    white-space: nowrap !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03) !important;
    user-select: none !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
  }

  .topbar-tab-pill .tab-ic {
    width: 15px !important;
    height: 15px !important;
    flex-shrink: 0 !important;
  }

  .topbar-tab-pill .tab-arrow {
    display: none !important;
  }

  /* Active Pill Highlight */
  .topbar-tab-wrapper.active .topbar-tab-pill {
    background: var(--accent) !important;
    color: #FFFFFF !important;
    border-color: var(--accent) !important;
    box-shadow: 0 2px 6px rgba(196, 96, 31, 0.32) !important;
  }

  .topbar-tab-wrapper.active .topbar-tab-pill .tab-ic {
    color: #FFFFFF !important;
  }

  /* Dropdown mega-menus floating beneath Row 2 */
  .topbar-dropdown {
    position: fixed !important;
    top: 98px !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: calc(100vw - 16px) !important;
    max-height: calc(100vh - 110px) !important;
    overflow-y: auto !important;
    transform: none !important;
    border-radius: 14px !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15) !important;
    z-index: 1050 !important;
  }

  .topbar-tab-wrapper.open .topbar-dropdown,
  .topbar-tab-wrapper:hover .topbar-dropdown {
    transform: none !important;
  }

  .topbar-dropdown::before {
    display: none !important;
  }

  .mega-menu-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  .screen-wrap {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* Main Container */
  .main {
    padding: 14px 12px 48px !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  /* KPI Grid */
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 12px !important;
  }

  /* Row layouts */
  .row-2 {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .row-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
  }

  /* Page Topbar Container */
  .topbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 12px 14px !important;
  }

  .crumb {
    font-size: 10px !important;
    flex-wrap: wrap !important;
    gap: 3px !important;
  }

  .topbar-title-group {
    align-items: flex-start !important;
    gap: 8px !important;
  }

  .topbar-heading-row {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  .page-title {
    font-size: 17px !important;
    line-height: 1.3 !important;
  }

  .page-sub {
    font-size: 11.5px !important;
  }

  .topbar-actions {
    width: 100% !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-top: 4px !important;
  }

  .topbar-actions .btn {
    flex: 1 1 auto !important;
    min-width: 120px !important;
    justify-content: center !important;
    font-size: 12px !important;
    padding: 8px 12px !important;
  }

  .topbar-stat-pill {
    font-size: 11px !important;
    padding: 4px 8px !important;
  }

  /* KPI Stat Grids */
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .kpi-card {
    padding: 10px 12px !important;
  }

  .kpi-value {
    font-size: 20px !important;
  }

  .kpi-val {
    font-size: 18px !important;
  }

  .kpi-icon {
    width: 22px !important;
    height: 22px !important;
  }

  /* Panels and Cards */
  .panel {
    padding: 14px 12px !important;
    border-radius: 10px !important;
    margin-bottom: 14px !important;
  }

  .panel-head {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
  }

  .row-3 {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Forms, Cards & Input Fields Everywhere */
  .form-grid,
  .form-grid.cols-3,
  .address-grid,
  .requisition-layout {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:repeat(2, 1fr)"],
  [style*="grid-template-columns: repeat(2, 1fr)"],
  [style*="grid-template-columns:repeat(2, minmax"],
  [style*="grid-template-columns: repeat(2, minmax"],
  [style*="grid-template-columns:repeat(3, minmax"],
  [style*="grid-template-columns: repeat(3, minmax"],
  [style*="grid-template-columns:repeat(4, minmax"],
  [style*="grid-template-columns: repeat(4, minmax"],
  [style*="grid-template-columns:repeat(auto-fit"],
  [style*="grid-template-columns: repeat(auto-fit"],
  [style*="grid-template-columns:1.2fr 0.8fr"],
  [style*="grid-template-columns: 1.2fr 0.8fr"],
  [style*="grid-template-columns:1.5fr 1fr"],
  [style*="grid-template-columns: 1.5fr 1fr"],
  [style*="grid-template-columns: 2fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  [style*="grid-column: span"],
  [style*="grid-column:span"],
  [style*="grid-column: 1 / -1"],
  [style*="grid-column:1 / -1"] {
    grid-column: span 1 !important;
  }

  .field,
  .form-group {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .field input,
  .field select,
  .field textarea,
  .form-control,
  input[type="text"],
  input[type="datetime-local"],
  input[type="date"],
  input[type="month"],
  input[type="tel"],
  input[type="number"],
  input[type="email"],
  input[type="password"] {
    width: 100% !important;
    max-width: 100% !important;
    font-size: 15px !important;
    min-height: 42px !important;
    box-sizing: border-box !important;
    border-radius: 8px !important;
  }

  .field textarea,
  textarea.form-control {
    min-height: 72px !important;
  }

  .radio-group {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .radio-pill {
    flex: 1 1 auto !important;
    justify-content: center !important;
    min-height: 38px !important;
    text-align: center !important;
  }

  /* Form action buttons on mobile */
  div[style*="justify-content:flex-end"],
  div[style*="justify-content: flex-end"],
  .form-actions {
    flex-direction: column-reverse !important;
    width: 100% !important;
    gap: 8px !important;
    align-items: stretch !important;
  }

  div[style*="justify-content:flex-end"] .btn,
  div[style*="justify-content: flex-end"] .btn,
  .form-actions .btn {
    width: 100% !important;
    justify-content: center !important;
    min-height: 42px !important;
    font-size: 13.5px !important;
  }

  /* Panels and Masters Headers */
  .panel-head {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .panel-head > div:last-child {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  .panel-head > div:last-child input,
  .panel-head > div:last-child select,
  .panel-head > div:last-child .btn,
  .panel-head > div:last-child a.btn,
  .panel-head > div:last-child button,
  .panel-head > div:last-child > div {
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Modals Everywhere */
  .modal-overlay {
    padding: 0 !important;
    align-items: flex-end !important;
    justify-content: center !important;
    z-index: 1300 !important;
  }

  .modal-card,
  [class*="modal-card"] {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh !important;
    max-height: 92dvh !important;
    border-radius: 16px 16px 0 0 !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    animation: modalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  @keyframes modalSlideUp {
    from {
      transform: translateY(100%);
      opacity: 0.5;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  .modal-card > div:first-child,
  .modal-card header {
    padding: 14px 16px !important;
    flex-shrink: 0 !important;
    border-radius: 16px 16px 0 0 !important;
  }

  .modal-body,
  #stage_modal_body,
  .modal-card form > div:nth-child(1),
  .modal-card form > div:nth-child(2),
  [id*="modal"][id*="body"],
  [id*="Modal"][id*="Body"] {
    padding: 14px 16px 20px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    flex: 1 1 auto !important;
    max-height: calc(88vh - 120px) !important;
  }

  .modal-card table {
    width: 100% !important;
  }

  .modal-card div[style*="justify-content:flex-end"],
  .modal-card div[style*="justify-content: flex-end"] {
    padding: 12px 16px !important;
    flex-direction: column-reverse !important;
    gap: 8px !important;
    flex-shrink: 0 !important;
    width: 100% !important;
    border-radius: 0 !important;
  }

  /* Spreadsheet Toolbars */
  .sheet-toolbar {
    padding: 12px 12px !important;
    gap: 10px !important;
  }

  .sheet-filter-group {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    gap: 10px !important;
  }

  .sheet-filter-group > div,
  .sheet-filter-group select,
  .sheet-filter-group input {
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .sheet-filter-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .sheet-filter-item {
    width: 100% !important;
    min-width: 0 !important;
    flex: 1 1 100% !important;
    margin: 0 !important;
  }

  .sheet-filter-select {
    width: 100% !important;
    min-height: 42px !important;
    font-size: 13.5px !important;
  }

  .sheet-month-wrap {
    width: 100% !important;
    display: flex !important;
    min-height: 42px !important;
  }

  .sheet-month-chip {
    font-size: 10.5px !important;
    padding: 0 8px !important;
  }

  .sheet-month-input {
    flex: 1 1 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 42px !important;
  }

  .sheet-action-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    width: 100% !important;
    padding-top: 10px !important;
  }

  .sheet-action-group {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .sheet-search-wrap {
    width: 100% !important;
    min-width: 0 !important;
  }

  .sheet-search-input {
    width: 100% !important;
    min-height: 40px !important;
    font-size: 13.5px !important;
  }

  .sheet-btn-apply,
  .sheet-btn-reset {
    min-height: 40px !important;
    justify-content: center !important;
    font-size: 13px !important;
    flex: 1 1 auto !important;
  }

  .sheet-record-count {
    text-align: center !important;
    width: 100% !important;
    font-size: 11.5px !important;
    margin: 4px 0 !important;
  }

  .sheet-btn-export,
  .sheet-btn-cta,
  [class*="sheet-btn-export"] {
    width: 100% !important;
    justify-content: center !important;
    min-height: 40px !important;
    font-size: 12.5px !important;
  }

  /* DataTables & Tables Swipe Experience */
  .sheet-table-wrap,
  .table-wrap,
  .table-responsive {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    position: relative !important;
    border-radius: 0 0 8px 8px !important;
  }

  .dataTables_wrapper .top {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }

  .dataTables_wrapper .bottom {
    flex-direction: column !important;
    align-items: center !important;
    gap: 10px !important;
    text-align: center !important;
    width: 100% !important;
  }

  .dataTables_wrapper .dataTables_info {
    width: 100% !important;
    text-align: center !important;
    font-size: 11.5px !important;
  }

  .dataTables_wrapper .dataTables_paginate {
    width: 100% !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
  }

  .dataTables_wrapper .dataTables_paginate .paginate_button {
    min-width: 32px !important;
    height: 32px !important;
    font-size: 12px !important;
  }

  /* Select2 Mobile Touch Enhancement */
  .field > .select2-container,
  .sheet-filter-item > .select2-container {
    width: 100% !important;
  }

  .select2-container--default .select2-selection--single {
    min-height: 42px !important;
    height: auto !important;
  }

  .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 40px !important;
    font-size: 13.5px !important;
  }

  .select2-dropdown {
    z-index: 100002 !important;
    border-radius: 10px !important;
    max-width: calc(100vw - 20px) !important;
  }

  .select2-search--dropdown .select2-search__field {
    min-height: 38px !important;
    font-size: 13.5px !important;
  }
}

/* ==========================================================================
   3. EXTRA SMALL PHONES (max-width: 480px)
   ========================================================================== */
@media (max-width: 480px) {
  .app-topbar {
    padding: 0 !important;
  }

  .topbar-left {
    padding-left: 10px !important;
    gap: 6px !important;
  }

  .topbar-right {
    padding-right: 10px !important;
    gap: 6px !important;
  }

  .topbar-brand-title {
    font-size: 14px !important;
    font-weight: 700 !important;
    display: inline-block !important;
  }

  .topbar-center {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 10px !important;
  }

  .main {
    padding: 10px 8px 48px !important;
  }

  .topbar {
    padding: 10px 12px !important;
  }

  .page-title {
    font-size: 16px !important;
  }

  .kpi-grid,
  .kpi-row {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .kpi-card {
    padding: 10px !important;
  }

  .kpi-value {
    font-size: 19px !important;
  }

  .kpi-val {
    font-size: 17px !important;
  }

  .topbar-actions {
    flex-direction: column !important;
    gap: 6px !important;
  }

  .topbar-actions .btn {
    width: 100% !important;
  }

  .sheet-btn-row {
    flex-direction: column !important;
  }

  .sheet-btn-row .sheet-btn-apply,
  .sheet-btn-row .sheet-btn-reset {
    width: 100% !important;
    flex: 1 1 100% !important;
  }

  .modal-card > div:first-child,
  .modal-card header {
    padding: 12px 14px !important;
  }

  .modal-body,
  #stage_modal_body {
    padding: 12px 14px 18px !important;
  }

  .sheet-card .dataTables_length,
  .sheet-card .dataTables_info,
  .sheet-card .dataTables_paginate {
    padding: 8px 10px !important;
    font-size: 11px !important;
  }
}