/* ==========================================================================
   MAYOR OF AGRO - CORE DESIGN SYSTEM & STYLING
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-dark: #070d0a;
  --bg-sidebar: #0b1410;
  --bg-card: #101c16;
  --bg-card-hover: #15241d;
  --bg-card-subtle: rgba(16, 28, 22, 0.6);
  --bg-input: #0c1611;
  
  /* Primary & Brand Accents */
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-light: #34d399;
  --primary-glow: rgba(16, 185, 129, 0.25);
  --primary-gradient: linear-gradient(135deg, #10b981 0%, #047857 100%);
  
  /* Luxury Gold Accents */
  --gold: #f59e0b;
  --gold-hover: #d97706;
  --gold-light: #fbbf24;
  --gold-glow: rgba(245, 158, 11, 0.2);
  --gold-gradient: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);

  /* Status Colors */
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.12);

  /* Typography Colors */
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --text-gold: #fcd34d;

  /* Borders & Glass */
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(16, 185, 129, 0.35);
  --border-gold: rgba(245, 158, 11, 0.3);
  --glass-bg: rgba(16, 28, 22, 0.75);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);

  /* Spacing & Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Mode Overrides if toggled */
body.light-theme {
  --bg-dark: #f8faf9;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f3;
  --bg-card-subtle: rgba(255, 255, 255, 0.8);
  --bg-input: #f3f6f4;
  --text-main: #111827;
  --text-muted: #4b5563;
  --text-dim: #9ca3af;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(16, 185, 129, 0.5);
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}

/* Box Sizing & Defaults */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Main Layout Structure */
.app-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* Ambient glow in background */
.app-container::before {
  content: '';
  position: fixed;
  top: -200px;
  left: 20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.app-container::after {
  content: '';
  position: fixed;
  bottom: -200px;
  right: 5%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border-color);
}

.brand-logo-img {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  object-fit: cover;
  box-shadow: 0 4px 14px var(--primary-glow);
  border: 1.5px solid rgba(245, 158, 11, 0.4);
}

.brand-text-wrap {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 40%, #fbbf24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--primary-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

/* Nav Menu */
.sidebar-nav {
  flex: 1;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 12px 12px 6px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  color: #ffffff;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.22) 0%, rgba(16, 185, 129, 0.06) 100%);
  border-color: rgba(16, 185, 129, 0.35);
  font-weight: 600;
}

.nav-item.active .nav-icon {
  color: var(--primary-light);
  filter: drop-shadow(0 0 6px var(--primary-glow));
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.nav-badge {
  margin-left: auto;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.nav-badge.alert {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

/* Sidebar Footer / User Profile */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
}

.current-user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #ffffff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: var(--radius-full);
  margin-top: 2px;
}

.role-admin {
  background: var(--gold-glow);
  color: var(--gold-light);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.role-sales-manager {
  background: var(--primary-glow);
  color: var(--primary-light);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.role-viewer {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.role-store-person {
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(14, 165, 233, 0.35);
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  z-index: 10;
}

/* Top Navigation Bar */
.topbar {
  height: 72px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 25;
}

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

.menu-toggle-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 1.4rem;
  cursor: pointer;
}

.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.page-breadcrumb .current {
  color: var(--text-main);
  font-weight: 600;
}

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

/* Active Logged-In User Pill (Read-only status in topbar) */
.active-user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  padding: 5px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

/* Role Capabilities Alert Banner */
.role-banner {
  padding: 10px 32px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid transparent;
  transition: all var(--transition-normal);
}

.role-banner.admin {
  background: rgba(245, 158, 11, 0.1);
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.2);
}

.role-banner.sales {
  background: rgba(16, 185, 129, 0.1);
  color: #a7f3d0;
  border-color: rgba(16, 185, 129, 0.2);
}

.role-banner.viewer {
  background: rgba(59, 130, 246, 0.1);
  color: #bfdbfe;
  border-color: rgba(59, 130, 246, 0.25);
}

.role-banner.store-person {
  background: rgba(14, 165, 233, 0.12);
  color: #bae6fd;
  border-color: rgba(14, 165, 233, 0.3);
}

.role-banner-badge {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
}

/* Page Content View */
.content-view {
  flex: 1;
  padding: 28px 32px 60px 32px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* Page Header */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.view-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.view-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 12px;
}

.view-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
}

.view-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Mobile Sidebar Backdrop Scrim */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
}
.sidebar-backdrop.active {
  display: block;
}

/* Sidebar Close Button */
.sidebar-close-btn {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  font-size: 1rem;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: auto;
  transition: all var(--transition-fast);
}
.sidebar-close-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.16);
}

/* Topbar Brand & Active User on Mobile */
.topbar-brand-mobile {
  display: none;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.topbar-logo-img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.topbar-brand-name {
  font-family: 'Cinzel', 'Outfit', serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.active-user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.active-user-pill:hover {
  background: rgba(255, 255, 255, 0.08);
}
.active-user-pill .user-avatar {
  width: 24px;
  height: 24px;
  font-size: 0.7rem;
}

/* Responsive Styles */
@media (max-width: 1024px) {
  .topbar-brand-mobile {
    display: flex;
  }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(300px, 85vw);
    max-width: 85vw;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.85);
    background: #09130e;
    padding-top: max(0px, env(safe-area-inset-top));
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close-btn {
    display: flex;
  }
  .menu-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 1.15rem;
    cursor: pointer;
    flex-shrink: 0;
  }
  .topbar {
    padding: 0 16px;
  }
  .content-view {
    padding: 16px max(14px, env(safe-area-inset-right)) max(44px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }
  .active-user-pill {
    padding: 3px 8px;
  }
}

/* Sidebar Backdrop Overlay on Mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  transition: opacity var(--transition-normal);
  pointer-events: none;
}
.sidebar-backdrop.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 768px) {
  .topbar {
    height: 58px;
    padding: 0 12px;
  }
  .topbar-left {
    gap: 8px;
  }
  .topbar-right {
    gap: 6px;
    margin-left: auto;
  }
  .topbar-btn-text {
    display: none;
  }
  .topbar-right .btn {
    padding: 6px 10px;
    min-height: 34px;
    font-size: 0.8rem;
  }
  .topbar-right #topbarUserName {
    display: none;
  }
  .active-user-pill {
    padding: 4px 8px !important;
    gap: 6px !important;
  }
  .active-user-pill #topbarUserAvatar {
    width: 20px;
    height: 20px;
    font-size: 0.65rem;
  }
  .active-user-pill #topbarUserRoleBadge {
    font-size: 0.65rem;
    padding: 2px 5px;
  }

  /* Prevent iOS Safari 16px input zoom */
  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px !important;
  }

  .role-banner {
    padding: 8px 12px;
    font-size: 0.78rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .view-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
  }
  .view-title {
    font-size: 1.35rem;
  }
  .view-desc {
    font-size: 0.8rem;
  }
  .view-actions {
    width: 100%;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
  .view-actions .btn {
    flex: 1;
    min-width: 130px;
    justify-content: center;
    padding: 9px 12px;
    font-size: 0.82rem;
  }

  .backend-login-screen {
    padding: 16px 12px;
    min-height: 100dvh;
  }
  .backend-login-card {
    padding: 24px 16px;
    border-radius: var(--radius-lg);
  }
  .login-brand-title {
    font-size: 1.55rem;
  }
  .gate-acc-header {
    flex-wrap: wrap;
    gap: 4px;
  }
  .gate-acc-desc {
    font-size: 0.7rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .topbar-right a.btn[title="View Public Website"] {
    display: none;
  }
  .view-actions {
    flex-direction: column;
  }
  .view-actions .btn {
    width: 100%;
  }
  .content-view {
    padding: 12px 10px 40px 10px;
  }
}

/* Dashboard & Views Responsive Grid Containers */
.dashboard-quick-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.dashboard-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 24px;
  margin-bottom: 28px;
}

.dashboard-bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1.05fr);
  gap: 24px;
  align-items: start;
}

.pnl-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.staff-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 22px;
  margin-bottom: 32px;
}

.settings-accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}

.flocks-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.flock-tabs-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

@media (max-width: 980px) {
  .dashboard-charts-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 20px;
  }
  .dashboard-bottom-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

@media (max-width: 768px) {
  .dashboard-quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin-bottom: 20px;
  }
  .dashboard-quick-actions .btn {
    width: 100%;
    justify-content: center;
    padding: 10px 8px;
    font-size: 0.8rem;
    min-height: 42px;
  }
  .pnl-charts-grid,
  .staff-cards-grid,
  .settings-accounts-grid,
  .flocks-card-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .flock-tabs-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: 6px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .flock-tabs-wrap::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 420px) {
  .dashboard-quick-actions {
    grid-template-columns: 1fr;
  }
}

/* =========================================================================
   FARM STOCK STATUS CARD (Dashboard)
   ========================================================================= */
.dashboard-stock-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Custom Sleek Scrollbar */
.dashboard-stock-wrap::-webkit-scrollbar {
  width: 5px;
}
.dashboard-stock-wrap::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 4px;
}
.dashboard-stock-wrap::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}
.dashboard-stock-wrap::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}

.stock-filter-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.stock-filter-pill {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.73rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.stock-filter-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.stock-filter-pill.active {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.35);
  color: #34d399;
}

.stock-item-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.28);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all var(--transition-fast);
}

.stock-item-row:hover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.38);
  transform: translateY(-1px);
}

.stock-item-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.stock-item-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.stock-item-icon-box {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.stock-item-text {
  min-width: 0;
  flex: 1;
}

.stock-item-name {
  font-weight: 600;
  color: #ffffff;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stock-item-cat {
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stock-item-metrics {
  text-align: right;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.stock-item-qty {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}

.stock-item-qty.healthy {
  color: #34d399;
}

.stock-item-qty.depleted {
  color: #f87171;
}

.stock-item-unit {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 2px;
}

.stock-item-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.stock-health-bar-track {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.stock-health-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.stock-health-bar-fill.full {
  background: linear-gradient(90deg, #059669, #34d399);
}

.stock-health-bar-fill.warning {
  background: linear-gradient(90deg, #d97706, #fbbf24);
}

.stock-health-bar-fill.empty {
  width: 0%;
  background: #f87171;
}

.stock-restock-btn {
  padding: 3px 8px !important;
  font-size: 0.72rem !important;
  border-radius: 6px !important;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Vector Sign Out Icon */
.icon-signout {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
  display: inline-block;
  vertical-align: middle;
}

.btn:hover .icon-signout {
  transform: translateX(2px);
}

/* Mobile Card Views for Ledger Tables (Expenses, Sales, Stores, Dashboard) */
.recent-sales-mobile-cards,
.expenses-mobile-cards,
.sales-mobile-cards,
.stores-sales-mobile-cards {
  display: none;
}

@media (max-width: 768px) {
  .recent-sales-table-wrap,
  .expenses-desktop-table-wrap,
  .sales-desktop-table-wrap,
  .stores-sales-desktop-table-wrap {
    display: none;
  }

  .recent-sales-mobile-cards,
  .expenses-mobile-cards,
  .sales-mobile-cards,
  .stores-sales-mobile-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 10px 14px 10px;
  }

  .recent-sale-mobile-item,
  .expense-mobile-item,
  .sale-mobile-item,
  .store-sale-mobile-item {
    padding: 13px 14px;
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: background var(--transition-fast);
  }

  .recent-sale-mobile-item:active,
  .expense-mobile-item:active,
  .sale-mobile-item:active,
  .store-sale-mobile-item:active {
    background: rgba(255, 255, 255, 0.04);
  }

  .recent-sale-mobile-top,
  .expense-mobile-top,
  .sale-mobile-top,
  .store-sale-mobile-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
  }

  .recent-sale-mobile-product,
  .sale-mobile-product,
  .store-sale-mobile-product {
    font-weight: 700;
    color: #ffffff;
    font-size: 0.95rem;
    line-height: 1.25;
  }

  .recent-sale-mobile-customer,
  .sale-mobile-customer,
  .store-sale-mobile-customer {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 3px;
  }

  .recent-sale-mobile-amount,
  .sale-mobile-amount,
  .store-sale-mobile-amount {
    font-weight: 800;
    color: var(--primary-light);
    font-size: 1.05rem;
    line-height: 1.2;
    margin-bottom: 4px;
    font-family: 'Outfit', sans-serif;
  }

  .recent-sale-mobile-meta,
  .expense-mobile-meta,
  .sale-mobile-meta,
  .store-sale-mobile-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.74rem;
    color: var(--text-dim);
    padding: 6px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
  }

  .expense-mobile-footer,
  .sale-mobile-footer,
  .store-sale-mobile-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding-top: 6px;
    border-top: 1px dashed rgba(255, 255, 255, 0.06);
  }
}

/* ==========================================================================
   BACKEND INITIAL LOGIN GATEWAY SCREEN
   ========================================================================== */
.backend-login-screen {
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background: radial-gradient(circle at 50% 15%, #0d1e16 0%, #050a08 100%);
  position: relative;
  overflow-x: hidden;
  z-index: 1000;
}

.backend-login-screen::before {
  content: '';
  position: absolute;
  top: -160px;
  left: 50%;
  transform: translateX(-50%);
  width: 650px;
  height: 650px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.16) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.backend-login-screen::after {
  content: '';
  position: absolute;
  bottom: -150px;
  right: 12%;
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.backend-login-card {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 500px;
  background: rgba(16, 28, 22, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 50px rgba(16, 185, 129, 0.12);
  animation: fadeInGate 0.35s ease-out;
}

@keyframes fadeInGate {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-brand-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo-glow-wrapper {
  display: inline-block;
  position: relative;
  margin-bottom: 14px;
}

.login-logo-glow-wrapper::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 22px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.4) 0%, rgba(16, 185, 129, 0.2) 60%, transparent 80%);
  filter: blur(10px);
  z-index: -1;
}

.login-logo-img {
  width: 76px;
  height: 76px;
  border-radius: 20px;
  object-fit: cover;
  border: 2px solid rgba(245, 158, 11, 0.6);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  display: block;
  background: #ffffff;
}

.login-brand-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  margin-bottom: 4px;
}

.login-brand-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.login-badge-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-light);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

.gate-error-alert {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.gate-login-btn {
  width: 100%;
  padding: 13px;
  font-size: 0.98rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.gate-quick-accounts-section {
  margin-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 20px;
}

.gate-quick-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 12px;
  text-align: center;
}

.gate-accounts-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gate-account-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  width: 100%;
}

.gate-account-card:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

.gate-account-card.admin-card:hover {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.06);
}

.gate-account-card.sales-card:hover {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.06);
}

.gate-account-card.viewer-card:hover {
  border-color: rgba(148, 163, 184, 0.4);
  background: rgba(148, 163, 184, 0.06);
}

.gate-acc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gate-acc-badge {
  font-size: 0.82rem;
  font-weight: 600;
}

.gate-acc-badge.admin {
  color: var(--gold-light);
}

.gate-acc-badge.sales {
  color: var(--primary-light);
}

.gate-acc-badge.viewer {
  color: #94a3b8;
}

.gate-acc-creds {
  font-size: 0.74rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
}

.gate-acc-desc {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.35;
}

.gate-footer-note {
  margin-top: 18px;
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-dim);
}
