/* ==========================================================================
   MAIKWANO ANIMAL FEEDS - MODERN DESIGN SYSTEM
   Theme: Forest Green, Agricultural Gold, Clean Slate, Glassmorphism
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Brand Colors */
  --primary-900: #062110;
  --primary-800: #0E4424;
  --primary-700: #14532D;
  --primary-600: #166534;
  --primary-500: #1B5E20;
  --primary-400: #22C55E;
  --primary-100: #DCFCE7;
  --primary-50:  #F0FDF4;

  /* Accent Gold */
  --gold-700: #B45309;
  --gold-600: #D97706;
  --gold-500: #F59E0B;
  --gold-400: #FBBF24;
  --gold-100: #FEF3C7;
  --gold-50:  #FFFBEB;

  /* Status Colors */
  --success: #10B981;
  --warning: #F59E0B;
  --danger:  #EF4444;
  --info:    #3B82F6;

  /* Neutrals */
  --slate-900: #0F172A;
  --slate-800: #1E293B;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748B;
  --slate-400: #94A3B8;
  --slate-300: #CBD5E1;
  --slate-200: #E2E8F0;
  --slate-100: #F1F5F9;
  --slate-50:  #F8FAF8;

  --body-bg: #F3F6F3;
  --card-bg: #FFFFFF;
  --sidebar-width: 270px;
  --topbar-height: 70px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 16px rgba(14, 68, 36, 0.08);
  --shadow-lg: 0 10px 30px rgba(14, 68, 36, 0.12);
  --shadow-glow: 0 0 20px rgba(34, 197, 94, 0.3);
  --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--body-bg);
  color: var(--slate-800);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #071F11 0%, #0B331A 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  overflow-y: auto;
  transition: var(--transition);
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}

.sidebar-header {
  padding: 24px 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo-img {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
  background: #fff;
  padding: 2px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.sidebar-brand-text h1 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #FFFFFF;
  line-height: 1.2;
}

.sidebar-brand-text span {
  font-size: 11px;
  color: var(--gold-400);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-top: 2px;
}

.sidebar-nav {
  padding: 18px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255, 255, 255, 0.4);
  padding: 12px 12px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  border-radius: var(--radius-md);
  transition: var(--transition);
  position: relative;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transform: translateX(3px);
}

.nav-link.active {
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.22) 0%, rgba(34, 197, 94, 0.06) 100%);
  color: #4ADE80;
  font-weight: 600;
  border-left: 3.5px solid #4ADE80;
}

.nav-link svg {
  width: 19px;
  height: 19px;
  stroke-width: 2;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
}

.user-snippet {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary-600);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.user-details {
  overflow: hidden;
  flex: 1;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  font-size: 10.5px;
  color: var(--gold-400);
  font-weight: 600;
  text-transform: capitalize;
}

/* Main Content Area */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
.topbar {
  height: var(--topbar-height);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
}

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

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--slate-700);
  border-radius: var(--radius-sm);
}

.topbar-page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--slate-900);
}

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

/* Page Container */
.page-container {
  padding: 26px 28px 40px;
  flex: 1;
}

/* ==========================================================================
   COMPONENTS: BUTTONS, BADGES, CARDS, INPUTS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
  line-height: 1.2;
}

.btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.2;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-800) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(14, 68, 36, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
  box-shadow: 0 6px 16px rgba(14, 68, 36, 0.35);
  transform: translateY(-1px);
}

.btn-accent {
  background: linear-gradient(135deg, var(--gold-500) 0%, var(--gold-600) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.25);
}

.btn-accent:hover {
  background: linear-gradient(135deg, var(--gold-400) 0%, var(--gold-500) 100%);
  transform: translateY(-1px);
}

.btn-outline {
  background: #fff;
  border-color: var(--slate-300);
  color: var(--slate-700);
}

.btn-outline:hover {
  background: var(--slate-50);
  border-color: var(--slate-400);
}

.btn-danger {
  background: #FEE2E2;
  color: #DC2626;
  border-color: #FECACA;
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 12px 22px;
  font-size: 15px;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-md);
  padding: 22px;
  position: relative;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--slate-900);
}

.card-subtitle {
  font-size: 12.5px;
  color: var(--slate-500);
  margin-top: 2px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-success {
  background: #DCFCE7;
  color: #15803D;
}

.badge-warning {
  background: #FEF3C7;
  color: #B45309;
}

.badge-danger {
  background: #FEE2E2;
  color: #B91C1C;
}

.badge-info {
  background: #DBEAFE;
  color: #1D4ED8;
}

.badge-secondary {
  background: var(--slate-100);
  color: var(--slate-700);
}

/* Inputs & Form Controls */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 6px;
}

.form-control, .form-select {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--slate-800);
  background: #fff;
  border: 1.5px solid var(--slate-300);
  border-radius: var(--radius-md);
  outline: none;
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-600);
  box-shadow: 0 0 0 3px rgba(27, 94, 32, 0.12);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* Search Box with Integrated Search Button Icon */
.search-box-wrapper {
  display: flex;
  align-items: center;
  position: relative;
  width: 100%;
  max-width: 320px;
}

.search-box-wrapper .form-control {
  padding-right: 42px;
}

.search-box-wrapper .btn-search-icon {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  background: var(--primary-700);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.search-box-wrapper .btn-search-icon:hover {
  background: var(--primary-600);
  transform: translateY(-50%) scale(1.05);
}

.search-box-wrapper .btn-search-icon svg {
  width: 15px;
  height: 15px;
  stroke-width: 2.2;
}

/* ==========================================================================
   KPI CARDS GRID (12 CARDS ON DASHBOARD)
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 26px;
}

.kpi-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3.5px;
  background: var(--primary-600);
}

.kpi-card.gold::before { background: var(--gold-500); }
.kpi-card.danger::before { background: var(--danger); }
.kpi-card.info::before { background: var(--info); }
.kpi-card.success::before { background: var(--success); }

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kpi-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-icon-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-50);
  color: var(--primary-700);
}

.kpi-icon-badge.gold { background: var(--gold-50); color: var(--gold-700); }
.kpi-icon-badge.danger { background: #FEF2F2; color: var(--danger); }
.kpi-icon-badge.info { background: #EFF6FF; color: var(--info); }

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--slate-900);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.kpi-subtext {
  font-size: 11.5px;
  color: var(--slate-500);
  margin-top: 6px;
}

/* ==========================================================================
   CHARTS GRID
   ========================================================================== */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 22px;
  margin-bottom: 26px;
}

.chart-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.chart-container {
  position: relative;
  height: 280px;
  width: 100%;
}

/* ==========================================================================
   TABLES
   ========================================================================== */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--slate-200);
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

.table th {
  background: var(--slate-50);
  color: var(--slate-700);
  font-weight: 700;
  padding: 13px 16px;
  border-bottom: 1.5px solid var(--slate-200);
  white-space: nowrap;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--slate-200);
  color: var(--slate-800);
  vertical-align: middle;
}

.table tbody tr {
  transition: background-color 0.15s;
}

.table tbody tr:hover {
  background-color: rgba(240, 253, 244, 0.4);
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: #fff;
  border-radius: var(--radius-xl);
  max-width: 600px;
  width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
  position: relative;
  margin: auto;
}

.modal-backdrop.show .modal-dialog {
  transform: scale(1);
}

/* Ensure forms inside modals stretch and allow body scrolling */
.modal-dialog form,
.modal-dialog > form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  margin: 0;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--slate-900);
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--slate-400);
  padding: 4px;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.modal-close:hover {
  color: var(--slate-800);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(88vh - 130px);
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--slate-300) transparent;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--slate-400);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: var(--slate-50);
  flex-shrink: 0;
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  border-left: 5px solid var(--primary-600);
  padding: 14px 18px;
  min-width: 300px;
  max-width: 420px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transform: translateX(120%);
  animation: slideInToast 0.3s forwards cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes slideInToast {
  to { transform: translateX(0); }
}

/* ==========================================================================
   POS TERMINAL CUSTOM STYLES & MOBILE OPTIMIZATIONS
   ========================================================================== */
.pos-layout-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 20px;
  align-items: start;
}

.pos-catalog-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pos-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  max-height: calc(100vh - 230px);
  overflow-y: auto;
  padding-right: 4px;
}

.pos-item-card {
  cursor: pointer;
  user-select: none;
  background: #fff;
  border-radius: 12px;
  border: 1.5px solid #E2E8F0;
  padding: 14px;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.pos-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #0E4424;
  margin: 6px 0 4px;
  line-height: 1.3;
  min-height: 34px;
}

.pos-card-btn-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding-top: 8px;
  border-top: 1px dashed #E2E8F0;
}

.pos-item-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary-600) !important;
  box-shadow: 0 8px 20px rgba(14, 68, 36, 0.12);
}

.pos-item-card.out-of-stock {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
  background: #F8FAFC;
}

.pos-cart-panel {
  padding: 20px;
  position: sticky;
  top: 90px;
  border: 1.5px solid #E2E8F0;
  box-shadow: 0 10px 25px rgba(0,0,0,0.06);
}

.pos-cart-table-wrapper {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  margin-bottom: 16px;
  background: #FAFAFA;
}

.pos-unit-btn {
  border: 1px solid #CBD5E1;
  background: #F8FAF8;
  color: #334155;
  border-radius: 6px;
  font-weight: 700;
  transition: all 0.15s ease;
  cursor: pointer;
}

.pos-unit-btn:hover {
  filter: brightness(0.95);
}

.pos-unit-btn.active-bag {
  background: #0E4424 !important;
  color: #fff !important;
  border-color: #0E4424 !important;
  box-shadow: 0 2px 4px rgba(14, 68, 36, 0.2);
}

.pos-unit-btn.active-half {
  background: #D97706 !important;
  color: #fff !important;
  border-color: #D97706 !important;
  box-shadow: 0 2px 4px rgba(217, 119, 6, 0.2);
}

.pos-unit-btn.active-subunit {
  background: #2563EB !important;
  color: #fff !important;
  border-color: #2563EB !important;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.pay-method-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

/* Floating Mobile Cart Banner */
.pos-mobile-cart-bar {
  display: none;
  background: linear-gradient(135deg, #0E4424 0%, #166534 100%);
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 14px;
  box-shadow: 0 4px 15px rgba(14, 68, 36, 0.25);
  cursor: pointer;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

/* Sidebar Backdrop on Mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 95;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

/* ==========================================================================
   COMPREHENSIVE RESPONSIVE DESIGN FOR ALL MODULES (PHONE & TABLET)
   ========================================================================== */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 100;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 10px 0 30px rgba(0,0,0,0.3);
  }
  .main-content {
    margin-left: 0;
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

/* Tablet & Mobile Breakpoint (<= 992px) */
@media (max-width: 992px) {
  .pos-layout-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .pos-cart-panel {
    position: static;
    top: auto;
  }
  .pos-mobile-cart-bar {
    display: flex;
  }
  .pos-products-grid {
    max-height: 480px;
  }
}

/* Phone View Breakpoint (<= 768px) */
@media (max-width: 768px) {
  .page-container {
    padding: 12px 10px 30px;
  }
  
  .topbar {
    padding: 0 12px;
    height: 56px;
  }
  
  .topbar-page-title {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
  }

  .topbar-btn-text {
    display: none;
  }

  .topbar-right {
    gap: 6px;
  }

  .topbar-right .btn-sm {
    padding: 6px 9px;
    font-size: 12px;
  }
  
  /* KPI Cards Grid across all modules */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    margin-bottom: 16px !important;
  }
  
  .kpi-card {
    padding: 12px 10px !important;
  }
  
  .kpi-value {
    font-size: 18px !important;
  }

  .kpi-subtext {
    font-size: 10.5px !important;
  }
  
  /* Filter Bars across Inventory, Sales History, Expenses, Debtors */
  .pos-search-wrapper,
  .filter-bar,
  .search-filter-wrapper,
  .card > div:first-child[style*="display: flex"],
  .card > div:first-child[style*="display:flex"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
  }
  
  .card input,
  .card select,
  .form-control,
  .form-select,
  .pos-search-wrapper select,
  .filter-bar select,
  .filter-bar input,
  .search-filter-wrapper select,
  .search-filter-wrapper input {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Form grids inside modals */
  .modal-dialog form .form-grid,
  .form-row-2col,
  .modal-dialog [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .pay-method-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  
  .pay-method-btn {
    padding: 8px 4px;
    font-size: 12.5px;
  }

  /* Universal Table Responsive Styling on Phones */
  .table-responsive {
    border: none;
    background: transparent;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
  }

  .table-responsive table {
    min-width: 580px;
  }

  /* Modals on Phone View */
  .modal-dialog {
    max-width: 95vw !important;
    margin: auto !important;
    max-height: 90vh !important;
    border-radius: 12px !important;
  }

  .modal-dialog form,
  .modal-dialog > form {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }
  
  .modal-body {
    padding: 16px 14px !important;
    max-height: calc(90vh - 125px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  
  .modal-footer {
    flex-direction: column-reverse !important;
    gap: 8px !important;
    padding: 12px 14px !important;
    flex-shrink: 0 !important;
  }
  
  .modal-footer button {
    width: 100% !important;
  }
}

/* Compact Mobile Phones (<= 640px) */
@media (max-width: 640px) {
  .login-container {
    padding: 24px 16px !important;
    border-radius: 16px !important;
  }

  .login-logo {
    width: 68px !important;
    height: 68px !important;
  }

  .login-title {
    font-size: 19px !important;
  }

  /* Date presets in Reports and Analytics */
  .date-preset-grid,
  div:has(> .date-preset-btn) {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 4px !important;
    width: 100% !important;
  }

  .date-preset-btn {
    padding: 5px 2px !important;
    font-size: 11px !important;
    text-align: center !important;
  }

  /* Export Button Groups */
  div:has(> button[onclick*="export"]) {
    display: flex !important;
    width: 100% !important;
    gap: 6px !important;
  }

  div:has(> button[onclick*="export"]) > button {
    flex: 1 !important;
    padding: 6px 4px !important;
    font-size: 11.5px !important;
    justify-content: center !important;
  }

  /* Date inputs row */
  div:has(> input[type="date"]) {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 6px !important;
  }

  div:has(> input[type="date"]) > input[type="date"] {
    width: 100% !important;
  }

  div:has(> input[type="date"]) > button {
    width: 100% !important;
  }

  .pos-products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    max-height: 420px;
  }

  .pos-item-card {
    padding: 10px;
  }

  .pos-card-title {
    font-size: 12px;
    min-height: 28px;
    margin: 4px 0 2px;
  }

  .pos-card-btn-grid button {
    font-size: 10px !important;
    padding: 4px 1px !important;
  }

  /* Stack Cart Table into Modern Mobile Touch Cards */
  .pos-cart-table thead {
    display: none;
  }

  .pos-cart-table,
  .pos-cart-table tbody,
  .pos-cart-table tr,
  .pos-cart-table td {
    display: block;
    width: 100%;
  }

  .pos-cart-table tbody tr {
    background: #fff;
    border: 1.5px solid #E2E8F0;
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    position: relative;
  }

  .pos-cart-table tbody td {
    padding: 3px 0 !important;
    border: none !important;
    text-align: left !important;
  }

  .pos-cart-table tbody td:last-child {
    position: absolute;
    top: 8px;
    right: 8px;
    width: auto !important;
    padding: 0 !important;
  }

  .pos-cart-table tbody td:last-child button {
    font-size: 22px !important;
    color: #DC2626;
    padding: 2px 6px;
    line-height: 1;
  }

  .pos-cart-table tbody td:nth-child(2) {
    margin: 6px 0;
  }

  .pos-cart-table tbody td:nth-child(2) .pos-unit-btn {
    flex: 1;
    text-align: center;
    padding: 6px 4px !important;
    font-size: 11.5px !important;
  }

  .pos-cart-table tbody td:nth-child(3),
  .pos-cart-table tbody td:nth-child(4),
  .pos-cart-table tbody td:nth-child(5) {
    display: inline-block;
    vertical-align: middle;
  }

  .pos-cart-table tbody td:nth-child(3) {
    width: 25% !important;
  }

  .pos-cart-table tbody td:nth-child(4) {
    width: 35% !important;
    text-align: center !important;
  }

  .pos-cart-table tbody td:nth-child(5) {
    width: 40% !important;
    text-align: right !important;
  }
}

/* Ultra-Compact Phones (<= 380px) */
@media (max-width: 380px) {
  .pos-products-grid {
    grid-template-columns: 1fr;
  }
  .kpi-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ==========================================================================
   USER PROFILE MODULE STYLING
   ========================================================================== */
.profile-tab-btn.active {
  background: var(--primary-800) !important;
  color: #ffffff !important;
  border-color: var(--primary-800) !important;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 768px) {
  .profile-layout-grid {
    grid-template-columns: 1fr !important;
  }
  .form-row-2col {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .profile-tabs {
    justify-content: stretch;
  }
  .profile-tab-btn {
    flex: 1 1 auto;
    text-align: center;
    justify-content: center;
  }
  .pagination-container {
    flex-direction: column;
    align-items: center !important;
    text-align: center;
    gap: 10px !important;
  }
}

/* ==========================================================================
   PAGINATION STYLING
   ========================================================================== */
.page-btn:hover:not(:disabled) {
  background: var(--primary-50) !important;
  border-color: var(--primary-600) !important;
  color: var(--primary-800) !important;
}

.page-btn.active {
  background: var(--primary-800) !important;
  border-color: var(--primary-800) !important;
  color: #ffffff !important;
}


