/* ===========================
   AMFE Admin - Global Styles
   =========================== */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --primary: #1e4d3a;
  --primary-light: #2d6b50;
  --primary-bg: #e8f0ec;
  --accent-green: #4caf7d;
  --accent-green-light: #d4edda;
  --sidebar-width: 220px;
  --text-dark: #1a1a1a;
  --text-muted: #6c757d;
  --text-light: #9ca3af;
  --border: #e5e7eb;
  --card-bg: #ffffff;
  --body-bg: #f4f6f5;
  --status-approved: #28a745;
  --status-pending: #ffc107;
  --status-rejected: #dc3545;
  --status-paid: #28a745;
  --status-unpaid: #ffc107;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.10);
}

* { box-sizing: border-box; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--body-bg);
  color: var(--text-dark);
  font-size: 14px;
  margin: 0;
  overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  padding: 0;
}

.sidebar-brand {
  padding: 20px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .brand-name {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  color: var(--primary);
  line-height: 1;
  letter-spacing: -0.5px;
}
.sidebar-brand .brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
  overflow-y: auto;
}

.sidebar-nav .nav-item .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: var(--text-dark);
  font-size: 13.5px;
  font-weight: 400;
  border-radius: 0;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.sidebar-nav .nav-item .nav-link i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.sidebar-nav .nav-item .nav-link:hover {
  background: var(--primary-bg);
  color: var(--primary);
}
.sidebar-nav .nav-item .nav-link:hover i { color: var(--primary); }
.sidebar-nav .nav-item .nav-link.active {
  background: var(--primary);
  color: #fff !important;
  font-weight: 500;
}
.sidebar-nav .nav-item .nav-link.active i { color: #fff !important; }

.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}
.sidebar-footer .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13.5px;
  text-decoration: none;
  padding: 6px 0;
}
.sidebar-footer .nav-link:hover { color: var(--status-rejected); }

/* Language switch styles live in global.css (loaded on every page).
   Sidebar spacing tweak only: */
.sidebar-footer .lang-switch-sidebar { margin-bottom: 10px; }

/* ===== MAIN CONTENT ===== */
.ra-topbar-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 22px;
  white-space: nowrap;
  border: none;
  border-radius: 50px;
  background: var(--primary);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.ra-topbar-action:hover,
.ra-topbar-action:focus,
.ra-topbar-action.show { background: var(--primary-light); color: #fff; }
.ra-record-chevron { font-size: 11px; margin-left: 2px; }
.ra-record-menu { min-width: 220px; padding: 6px; border-radius: 10px; }
.ra-record-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 13px;
}
.ra-record-menu .dropdown-item i { color: var(--primary); }
.ra-record-menu .dropdown-item:hover,
.ra-record-menu .dropdown-item:focus { background: #eef5f0; color: var(--primary); }

/* Resource Allocation has a longer second action than the shared sales
   menu. Keep the full desktop label on one line; phones may wrap it. */
body.admin-shell .ra-resource-topbar-add .ra-record-menu {
  width: 390px;
  max-width: calc(100vw - 24px);
}
.ra-resource-topbar-add .ra-record-menu .dropdown-item {
  min-height: 44px;
  white-space: nowrap;
  line-height: 1.35;
}
body.admin-shell .ra-floating-add .ra-record-menu {
  width: 390px;
  max-width: calc(100vw - 24px);
}
body.admin-shell .ra-floating-add .ra-record-menu .dropdown-item {
  min-height: 44px;
  padding-inline: clamp(8px, 3vw, 12px);
  gap: clamp(6px, 2vw, 8px);
  font-size: clamp(12px, 3.7vw, 14px);
  white-space: nowrap;
  line-height: 1.35;
}

.ra-floating-add {
  display: none;
  position: fixed;
  right: 28px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 1035;
}
.ra-floating-add-btn {
  min-width: 132px;
  min-height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 24px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(18, 55, 42, .28);
  transition: transform .15s ease, background .15s ease;
}
.ra-floating-add-btn i { font-size: 21px; }
.ra-floating-add-btn:hover,
.ra-floating-add-btn:focus,
.ra-floating-add-btn.show { background: var(--primary-light); color: #fff; }
.ra-floating-add-btn:active { transform: scale(.97); }

@media (min-width: 768px) and (max-width: 991px) {
  .ra-record-dropdown {
    position: fixed;
    top: 8px;
    right: 150px;
    z-index: 1031;
  }
  .ra-record-dropdown .ra-topbar-action {
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #fff;
    font-size: 20px;
  }
  .ra-record-dropdown .ra-topbar-action span,
  .ra-record-dropdown .ra-record-chevron { display: none; }
  .ra-record-dropdown .ra-topbar-action:hover { background: rgba(255,255,255,0.12); }
}
@media (max-width: 767.98px) {
  .ra-record-dropdown { align-self: flex-end; margin-bottom: 12px; }
  .ra-resource-topbar-add { display: none !important; }
  .ra-floating-add {
    display: block;
    right: 16px;
    bottom: calc(18px + env(safe-area-inset-bottom));
  }
  .ra-floating-add-btn {
    min-width: 118px;
    min-height: 56px;
    padding: 13px 22px;
    font-size: 16px;
  }
  main.main-content:has(.ra-floating-add),
  #main-content:has(.ra-floating-add) {
    padding-bottom: calc(92px + env(safe-area-inset-bottom)) !important;
  }
}
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: 28px 30px 80px;
  display: flex;
  flex-direction: column;
}

/* ===== PAGE TITLE ===== */
/* Scoped to .main-content (Admin's own <main> class — Farmer/Entrepreneur
   use #main-content as an id, never this class, by design) so this doesn't
   silently outrank farmer.css/entrepreneur.css's unscoped .page-title
   (margin-bottom: 2px) on their desktop pages via later load order. */
.main-content .page-title {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(2rem, 2vw, 2.25rem);
  color: var(--text-dark);
  margin-bottom: 28px;
  font-weight: 400;
}

/* ===== CARDS ===== */
.amfe-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow-y: auto;
  overflow: hidden;
}

/* ===== STAT CARDS ===== */
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 30px 20px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  text-align: left;
}
.stat-card .stat-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--primary-bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  font-size: 18px;
  flex-shrink: 0;
}
.stat-card .stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .stat-value { font-size: 20px; font-weight: 600; color: var(--text-dark); line-height: 1.2; margin-top: 2px; white-space: nowrap; }

/* ── Dashboard stat card accent colors: white card, a light low-contrast
   border per stat, and the color payoff kept in the icon badge — label/
   value stay neutral so the row reads as a clean dashboard rather than
   five solid-tinted blocks. Same variables apply on every breakpoint
   (desktop included). ────────────────────────────────────────────── */
.stat-card[class*="stat-card--"] { box-shadow: var(--shadow); }
.stat-card.stat-card--green { border-color: #8fc4a8; }
.stat-card.stat-card--green .stat-icon { background: #e3f1e9; color: #1e4d3a; }

.stat-card.stat-card--gold { border-color: #d9c07a; }
.stat-card.stat-card--gold .stat-icon { background: #fbeecb; color: #8a6410; }

.stat-card.stat-card--orange { border-color: #ddac83; }
.stat-card.stat-card--orange .stat-icon { background: #f8e2d1; color: #8a4a1f; }

.stat-card.stat-card--blue { border-color: #a5a1e0; }
.stat-card.stat-card--blue .stat-icon { background: #e7e9fa; color: #3d3f8f; }

.stat-card.stat-card--purple { border-color: #cf9fbe; }
.stat-card.stat-card--purple .stat-icon { background: #f5e3ee; color: #7a3d63; }

.stat-card--clickable {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.stat-card--clickable:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(45, 106, 79, 0.12);
  text-decoration: none;
  color: inherit;
}
.stat-card--clickable:active {
  transform: translateY(-1px);
}

/* ===== BADGES / STATUS ===== */
.badge-approved, .badge-paid {
  background: var(--accent-green-light);
  color: var(--status-approved);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 500;
}
.badge-pending {
  background: #fff8e1;
  color: #b45309;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 500;
}
.badge-rejected {
  background: #fde8e8;
  color: var(--status-rejected);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 500;
}
.badge-unpaid {
  background: #fff8e1;
  color: #b45309;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 500;
}
.badge-empty {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f1f3f2;
  color: #68736e;
  border: 1px solid #e1e5e3;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.payroll-type-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px !important;
}
.payroll-overdue-alert {
  margin-top: 0 !important;
  margin-bottom: 12px !important;
  padding: 8px 14px !important;
}
.payroll-type-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.payroll-type-tab {
  display: inline-flex;
  min-width: 0;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 14px 6px 8px;
  border: 1px solid var(--primary);
  border-radius: 999px;
  background: #fff;
  color: var(--primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, box-shadow .15s ease, transform .15s ease;
}
.payroll-type-tab:hover,
.payroll-type-tab:focus-visible {
  background: #edf7f1;
  box-shadow: 0 4px 12px rgba(30, 77, 58, .12);
}
.payroll-type-tab:focus-visible { outline: 3px solid rgba(30, 77, 58, .18); outline-offset: 2px; }
.payroll-type-tab:active { transform: scale(.985); }
.payroll-type-tab.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 3px 9px rgba(30, 77, 58, .18);
}
.payroll-type-tab-icon {
  display: inline-grid;
  flex: 0 0 27px;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  background: #e8f4ed;
  color: var(--primary);
  font-size: 13px;
}
.payroll-leaf-icon {
  width: 1.15em;
  height: 1.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.payroll-type-tab.active .payroll-type-tab-icon {
  background: rgba(255, 255, 255, .17);
  color: #fff;
}
.btn-payroll-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--primary, #1e4d3a);
  color: #ffffff !important;
  border: 1px solid var(--primary, #1e4d3a);
  border-radius: 9999px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(30, 77, 58, 0.15);
  transition: all 0.15s ease;
}
.btn-payroll-pill:hover {
  background: var(--primary-light, #2d6a4f);
  border-color: var(--primary-light, #2d6a4f);
  color: #ffffff !important;
}
.btn-finalize-payroll {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background-color: #e8f5ee;
  color: #1e4d3a;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.btn-finalize-payroll:hover {
  background-color: #d8eee1;
  color: #163e2e;
  border-color: #a3d4b8;
}

.btn-finalize-payroll:disabled,
.btn-finalize-payroll:disabled:hover {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
}
.payroll-type-filters {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.payroll-type-filters .amfe-input {
  width: auto;
  min-width: 120px;
  height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--border, #d1d5db);
  border-radius: 8px;
  background-color: #fff;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dark, #1f2937);
}
.payroll-type-filters input[type="month"] {
  min-width: 172px;
  padding-right: 12px;
}

@media (max-width: 991px) {
  .payroll-type-selector {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }
  .payroll-type-filters {
    align-self: stretch;
    margin-left: 0;
    width: 100%;
  }
  .payroll-type-filters .amfe-input { flex: 1 1 0; }
}

/* Payroll Blocked / Empty State Card */
.payroll-blocked-card {
  border-radius: 16px;
  border: 1.5px solid #fde68a !important;
  background: linear-gradient(180deg, #fffdf8 0%, #ffffff 100%) !important;
  padding: 36px 32px !important;
  box-shadow: 0 4px 20px rgba(217, 119, 6, 0.06);
  margin-top: 6px;
  margin-bottom: 24px;
}

.payroll-blocked-content {
  display: flex;
  align-items: flex-start;
  gap: 22px;
}

.payroll-blocked-icon-badge {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: #fef3c7;
  color: #d97706;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.12);
}

.payroll-blocked-body {
  flex: 1;
  min-width: 0;
}

.payroll-blocked-title {
  font-family: 'DM Serif Display', serif;
  font-size: 22px;
  font-weight: 500;
  color: #1e293b;
  margin: 0;
  line-height: 1.25;
}

.payroll-period-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f1f5f9;
  color: #475569;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 20px;
  border: 1px solid #e2e8f0;
}

.payroll-blocked-desc {
  color: #64748b;
  font-size: 14px;
  line-height: 1.6;
  margin-top: 8px;
  margin-bottom: 20px;
  max-width: 640px;
}

.payroll-blocked-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.payroll-blocked-actions .btn-primary-amfe {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  background: #183126;
  color: #ffffff !important;
  border: 1.5px solid #183126;
  box-shadow: 0 2px 6px rgba(24, 49, 38, 0.18);
  transition: all 0.15s ease-in-out;
}
.payroll-blocked-actions .btn-primary-amfe:hover {
  background: #0f2119;
  border-color: #0f2119;
  color: #ffffff !important;
  transform: translateY(-1px);
}

.payroll-blocked-actions .btn-outline-amfe {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  background: #ffffff;
  color: #334155 !important;
  border: 1.5px solid #cbd5e1;
  transition: all 0.15s ease-in-out;
}
.payroll-blocked-actions .btn-outline-amfe:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a !important;
}

.payroll-blocked-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px dashed #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #64748b;
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 639.98px) {
  .payroll-blocked-card {
    padding: 24px 18px !important;
  }
  .payroll-blocked-content {
    flex-direction: column;
    gap: 16px;
    align-items: center;
    text-align: center;
  }
  .payroll-blocked-actions {
    justify-content: center;
    width: 100%;
  }
  .payroll-blocked-actions a {
    width: 100%;
    justify-content: center;
  }
  .payroll-blocked-footer {
    justify-content: center;
    text-align: center;
  }
}
.badge-pts {
  background: #eaf5ee;
  color: #183126;
  border: 1px solid #c2e2d3;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
/* Dashboard's Top Performing Farmers list only — a differing digit count
   per row (e.g. "1169.83" vs "994.5") otherwise gives each pill a different
   width, staggering the row instead of lining up in a clean column. Scoped
   to this modifier rather than the base .badge-pts so table usages
   elsewhere (which can have much longer figures) are unaffected. */
.badge-pts--fixed {
  display: inline-block;
  min-width: 78px;
  text-align: center;
}
.badge-pts-total {
  font-size: 12px;
}
.badge-rank {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  color: #fff;
}
.badge-pts--month {
  background: #2d6b50 !important;
  color: #ffffff !important;
  border: 1px solid #2d6b50 !important;
  font-weight: 700 !important;
  font-size: 12px !important;
  padding: 3px 11px !important;
  border-radius: 20px !important;
  white-space: nowrap !important;
  display: inline-block !important;
  min-width: 80px !important;
  text-align: center !important;
}
.badge-pts--subtle {
  background: #eaf5ee !important;
  color: #166534 !important;
  border: 1px solid #c2e2d3 !important;
  font-weight: 600 !important;
  font-size: 11.5px !important;
  padding: 2.5px 10px !important;
  border-radius: 20px !important;
  white-space: nowrap !important;
  display: inline-block !important;
  min-width: 80px !important;
  text-align: center !important;
}

/* Compact, polished action edit button */
.action-btn-edit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  color: #1b4332;
  border: 1.5px solid #2d6a4f;
  border-radius: 9999px;
  padding: 3.5px 14px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  line-height: 1.4;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.action-btn-edit:hover {
  background: #f0fdf4;
  border-color: #15803d;
  color: #15803d;
}
.action-btn-edit i {
  font-size: 12px;
  color: inherit;
}
.action-btn-edit:hover i {
  color: #15803d;
}

/* Modal stat boxes in Production Management */
.modal-box .row.g-2 .detail-field,
.prod-stat-card {
  background: #ffffff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(24, 49, 38, 0.04);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  height: 100%;
}
.modal-box .row.g-2 .detail-field:hover,
.prod-stat-card:hover {
  box-shadow: 0 4px 12px rgba(24, 49, 38, 0.08);
  transform: translateY(-1px);
}

.modal-box .row.g-2 .detail-field .prod-stat-icon,
.prod-stat-card .prod-stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

/* Subtle, system-aligned tinted borders for each stat card ("kahit yung border lang may color") */
/* Green tone (Total Fresh / Total Himay) */
.prod-stat-card--green,
.modal-box .row.g-2 .detail-field:has(.prod-stat-icon.green) {
  border-color: #8fc4a8;
}
.prod-stat-card--green:hover,
.modal-box .row.g-2 .detail-field:has(.prod-stat-icon.green):hover {
  border-color: #2d6a4f;
}
.prod-stat-card .prod-stat-icon.green,
.prod-stat-card--green .prod-stat-icon,
.modal-box .row.g-2 .detail-field .prod-stat-icon.green {
  background: #e3f1e9;
  color: #1e4d3a;
  border: 1px solid #c2e2cf;
}

/* Blue tone (Fresh Entries) */
.prod-stat-card--blue,
.modal-box .row.g-2 .detail-field:has(.prod-stat-icon.blue),
.modal-box .row.g-2 .detail-field:has(.prod-stat-icon.indigo) {
  border-color: #a5a1e0;
}
.prod-stat-card--blue:hover,
.modal-box .row.g-2 .detail-field:has(.prod-stat-icon.blue):hover,
.modal-box .row.g-2 .detail-field:has(.prod-stat-icon.indigo):hover {
  border-color: #3d3f8f;
}
.prod-stat-card .prod-stat-icon.blue,
.prod-stat-card .prod-stat-icon.indigo,
.prod-stat-card--blue .prod-stat-icon,
.modal-box .row.g-2 .detail-field .prod-stat-icon.blue,
.modal-box .row.g-2 .detail-field .prod-stat-icon.indigo {
  background: #e7e9fa;
  color: #3d3f8f;
  border: 1px solid #d0d3f7;
}

/* Gold / Amber tone (Total Points - soft warm honey gold; NOT dark yellow) */
.prod-stat-card--gold,
.modal-box .row.g-2 .detail-field:has(.prod-stat-icon.gold),
.modal-box .row.g-2 .detail-field:has(.prod-stat-icon.amber) {
  border-color: #d9c07a;
}
.prod-stat-card--gold:hover,
.modal-box .row.g-2 .detail-field:has(.prod-stat-icon.gold):hover,
.modal-box .row.g-2 .detail-field:has(.prod-stat-icon.amber):hover {
  border-color: #8a6410;
}
.prod-stat-card .prod-stat-icon.gold,
.prod-stat-card .prod-stat-icon.amber,
.prod-stat-card--gold .prod-stat-icon,
.modal-box .row.g-2 .detail-field .prod-stat-icon.gold,
.modal-box .row.g-2 .detail-field .prod-stat-icon.amber {
  background: #fbeecb;
  color: #8a6410;
  border: 1px solid #f3deb0;
}

/* Orange tone (Total Bilad/Giling - soft warm sunrise coral) */
.prod-stat-card--orange,
.modal-box .row.g-2 .detail-field:has(.prod-stat-icon.orange) {
  border-color: #ddac83;
}
.prod-stat-card--orange:hover,
.modal-box .row.g-2 .detail-field:has(.prod-stat-icon.orange):hover {
  border-color: #8a4a1f;
}
.prod-stat-card .prod-stat-icon.orange,
.prod-stat-card--orange .prod-stat-icon,
.modal-box .row.g-2 .detail-field .prod-stat-icon.orange {
  background: #f8e2d1;
  color: #8a4a1f;
  border: 1px solid #f0cbaf;
}

/* Teal tone (Dried Entries - soft seafoam / mint; NOT dark violet) */
.prod-stat-card--teal,
.modal-box .row.g-2 .detail-field:has(.prod-stat-icon.teal) {
  border-color: #99dcd0;
}
.prod-stat-card--teal:hover,
.modal-box .row.g-2 .detail-field:has(.prod-stat-icon.teal):hover {
  border-color: #0d9488;
}
.prod-stat-card .prod-stat-icon.teal,
.prod-stat-card--teal .prod-stat-icon,
.modal-box .row.g-2 .detail-field .prod-stat-icon.teal {
  background: #e6fffa;
  color: #0d9488;
  border: 1px solid #bbf2e7;
}

/* Soft lavender fallback (NOT dark violet) */
.prod-stat-card .prod-stat-icon.purple,
.prod-stat-card--purple .prod-stat-icon,
.modal-box .row.g-2 .detail-field .prod-stat-icon.purple {
  background: #f5e3ee;
  color: #7a3d63;
  border: 1px solid #eed0e2;
}

.modal-box .row.g-2 .detail-field .prod-stat-content,
.prod-stat-card .prod-stat-content {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.modal-box .row.g-2 .detail-field .field-label,
.modal-box-lg .detail-field.prod-stat-card .field-label,
.prod-stat-card .field-label {
  font-size: 11px !important;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #55685d;
  line-height: 1.25;
  margin-bottom: 2px;
  height: 28px;
  display: flex;
  align-items: flex-start;
  overflow: hidden;
}

.modal-box .row.g-2 .detail-field .field-value,
.modal-box-lg .detail-field.prod-stat-card .field-value,
.prod-stat-card .field-value {
  font-size: 18px !important;
  font-weight: 700;
  color: #183126;
  line-height: 1.2;
  white-space: nowrap;
}

/* Production record table date & inline verification chip */
.prod-row-date {
  color: #1e293b;
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
}

.prod-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2.5px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  letter-spacing: 0.2px;
  vertical-align: middle;
}
.prod-status-chip.badge-verified {
  background: #ecfdf5;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.prod-status-chip.badge-rejected {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.prod-status-chip.badge-pending {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

#memberFreshTable td,
#memberFreshTable th,
#memberDriedTable td,
#memberDriedTable th {
  vertical-align: middle !important;
}

@media (min-width: 576px) {
  .modal-box-lg .detail-field.prod-stat-card {
    padding: 12px 14px !important;
  }
}

@media (max-width: 575.98px) {
  .modal-box .row.g-2 .detail-field.prod-stat-card,
  .prod-stat-card {
    padding: 10px 12px !important;
    gap: 10px;
    border-radius: 10px;
  }
  .modal-box .row.g-2 .detail-field .prod-stat-icon,
  .prod-stat-card .prod-stat-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
    border-radius: 8px;
  }
  .modal-box .row.g-2 .detail-field .field-label,
  .modal-box-lg .detail-field.prod-stat-card .field-label,
  .prod-stat-card .field-label {
    font-size: 10px !important;
    height: 25px;
  }
  .modal-box .row.g-2 .detail-field .field-value,
  .modal-box-lg .detail-field.prod-stat-card .field-value,
  .prod-stat-card .field-value {
    font-size: 16px !important;
  }
}

/* Centered table action headers and cells across production tables */
.amfe-table th.text-center,
.amfe-table thead th.text-center,
.amfe-table thead tr th.text-center,
.amfe-table td.prod-actions.text-center,
#memberFreshTable th.text-center,
#memberFreshTable thead th.text-center,
#memberFreshTable td.prod-actions.text-center,
#memberDriedTable th.text-center,
#memberDriedTable thead th.text-center,
#memberDriedTable td.prod-actions.text-center,
#byMemberTable th.text-center,
#byMemberTable thead th.text-center,
#byMemberTable td.prod-actions.text-center,
#freshTable th.text-center,
#freshTable thead th.text-center,
#freshTable td.prod-actions.text-center,
#driedTable th.text-center,
#driedTable thead th.text-center,
#driedTable td.prod-actions.text-center,
.recorded-dried-batches-table th.text-center,
.recorded-dried-batches-table thead th.text-center,
.recorded-dried-batches-table td.prod-actions.text-center {
  text-align: center !important;
}

/* Unified Production Action Buttons */
.prod-btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 29px;
  height: 29px;
  padding: 2px 10px;
  border-radius: 9999px;
  border: 1.5px solid transparent;
  outline: none;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  flex-shrink: 0 !important;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

#memberFreshTable th,
#memberFreshTable td,
#memberDriedTable th,
#memberDriedTable td {
  white-space: nowrap !important;
  vertical-align: middle !important;
}

#memberFreshTable th,
#memberFreshTable td:not(.mg-label),
#memberDriedTable th:not(.dried-date-th):not(:first-child),
#memberDriedTable td:not(.mg-label):not(.dried-date-cell):not(:first-child) {
  text-align: center !important;
}

#memberFreshTable td[data-label="Date & Time"] > div {
  justify-content: center !important;
}

#memberDriedTable th.dried-date-th,
#memberDriedTable th:first-child,
#memberDriedTable td.dried-date-cell,
#memberDriedTable td:first-child:not(.mg-label),
#memberDriedTable td[data-label="Date & Time"],
#memberDriedTable td[data-label="Petsa at Oras"] {
  text-align: left !important;
  padding-left: 14px !important;
}

#memberDriedTable td.dried-date-cell > div,
#memberDriedTable td:first-child:not(.mg-label) > div,
#memberDriedTable td[data-label="Date & Time"] > div,
#memberDriedTable td[data-label="Petsa at Oras"] > div {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  text-align: left !important;
  margin-left: 0 !important;
  margin-right: auto !important;
}

#memberFreshTable th,
#memberDriedTable th {
  padding: 10px 14px !important;
}

#memberFreshTable td,
#memberDriedTable td {
  padding: 9px 14px !important;
}

#memberDriedTable .mg-himay,
#memberDriedTable td[data-label="Himay"] {
  min-width: 95px !important;
  white-space: nowrap !important;
}

#memberDriedTable .mg-bilad-giling,
#memberDriedTable td[data-label="Bilad/Giling"] {
  min-width: 110px !important;
  white-space: nowrap !important;
}

#memberDriedTable .mg-total,
#memberDriedTable td[data-label="Total Points"] {
  min-width: 105px !important;
  white-space: nowrap !important;
}

#memberFreshTable td[data-label="Quantity (kg)"] {
  min-width: 110px !important;
  white-space: nowrap !important;
}

#memberFreshTable th:last-child,
#memberDriedTable th:last-child,
#memberFreshTable td.prod-actions,
#memberDriedTable td.prod-actions {
  white-space: nowrap !important;
  min-width: 270px !important;
}

#memberFreshTable td.prod-actions > div,
#memberDriedTable td.prod-actions > div {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-wrap: nowrap !important;
  white-space: nowrap !important;
  gap: 5px !important;
}

/* Edit - Green Outline */
.prod-btn-edit {
  background: #ffffff;
  color: #1b4332;
  border: 1.5px solid #2d6a4f;
}
.prod-btn-edit:hover,
.prod-btn-edit:focus-visible {
  background: #f0fdf4;
  border-color: #15803d;
  color: #15803d;
}

/* Reject - Red Outline */
.prod-btn-reject {
  background: #ffffff;
  color: #dc2626;
  border: 1.5px solid #ef4444;
}
.prod-btn-reject:hover,
.prod-btn-reject:focus-visible {
  background: #fef2f2;
  border-color: #b91c1c;
  color: #b91c1c;
}

/* Verify - Green Solid/Outline */
.prod-btn-verify {
  background: #ffffff;
  color: #16a34a;
  border: 1.5px solid #22c55e;
}
.prod-btn-verify:hover,
.prod-btn-verify:focus-visible {
  background: #f0fdf4;
  border-color: #15803d;
  color: #15803d;
}

/* Mark Paid - Solid Emerald */
.prod-btn-pay {
  background: #183126;
  color: #ffffff;
  border: 1.5px solid #183126;
}
.prod-btn-pay:hover,
.prod-btn-pay:focus-visible {
  background: #0f2119;
  border-color: #0f2119;
  color: #ffffff;
}

/* Mark Unpaid - Outline Neutral */
.prod-btn-unpay {
  background: #ffffff;
  color: #334155;
  border: 1.5px solid #cbd5e1;
}
.prod-btn-unpay:hover,
.prod-btn-unpay:focus-visible {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

/* Locked Pill Badge */
.badge-prod-locked {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 31px;
  padding: 4px 11px;
  border-radius: 9999px;
  background: #f1f5f9;
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid #e2e8f0;
}

/* Consistent Edit Modal Input Controls */
.admin-edit-label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
  display: block;
}
.admin-edit-control {
  width: 100%;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  padding: 0 14px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  color: #1e293b;
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
  font-family: inherit;
}
.admin-edit-control:focus {
  border-color: #2d5a3d;
  box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.12);
}
.admin-edit-static-box {
  width: 100%;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  padding: 0 12px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
}

/* Bilad / Giling Participation Checkbox Card (Admin Edit Form) */
.prod-checkbox-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 48px;
  box-sizing: border-box;
  padding: 0 14px;
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  margin-bottom: 0;
}
.prod-checkbox-card:hover {
  background: #fffdf5;
  border-color: #f59e0b;
}
.prod-checkbox-card.checked {
  background: #fffbeb;
  border-color: #d97706;
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.15);
}
.prod-card-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: #fef3c7;
  color: #d97706;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.prod-checkbox-card.checked .prod-card-icon {
  background: #d97706;
  color: #ffffff;
}
.prod-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #1f2937;
}
.prod-custom-check {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #d97706;
  margin: 0;
}

/* ===== BUTTONS ===== */
.ana-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.ana-download-report {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 2.5rem;
  padding: .55rem 1rem;
  border: 1.5px solid var(--primary);
  border-radius: 999px;
  color: var(--primary);
  background: #fff;
  font-size: .82rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}
.ana-download-report:hover,
.ana-download-report:focus-visible { color: #fff; background: var(--primary); }
.ana-download-report:disabled { cursor: wait; opacity: .65; }
@media (max-width: 575.98px) {
  .ana-page-header { align-items: stretch; flex-direction: column; }
  .ana-download-report { width: 100%; }
}

.btn-primary-amfe {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary-amfe:hover { background: var(--primary-light); color: #fff; }

.btn-outline-amfe {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  border-radius: 50px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-outline-amfe:hover { background: var(--primary); color: #fff; }
.btn-outline-amfe:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-outline-amfe:disabled:hover { background: transparent; color: var(--primary); }

/* One archive action language across Admin modules (Products intentionally
   keeps its compact product-card control). */
.btn-archive-amfe {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 2.5rem;
  padding: .45rem .85rem;
  border: 1.5px solid var(--status-rejected, #dc3545);
  border-radius: 999px;
  color: var(--status-rejected, #dc3545);
  background: #fff;
  font: inherit;
  font-size: .78rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, border-color .15s ease, transform .15s ease;
}
.btn-archive-amfe:hover,
.btn-archive-amfe:focus-visible {
  border-color: var(--status-rejected, #dc3545);
  color: var(--status-rejected, #dc3545);
  background: #fde8e8;
}
.btn-archive-amfe:focus-visible { outline: 3px solid rgba(220, 53, 69, .25); outline-offset: 2px; }
.btn-archive-amfe:disabled { cursor: not-allowed; opacity: .45; transform: none; }

.btn-danger-amfe {
  background: var(--status-rejected);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.btn-danger-amfe:hover { background: #c0392b; }

.btn-approve-amfe {
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.btn-approve-amfe:hover { background: #15803d; color: #fff; }
.btn-approve-amfe:disabled { opacity: .55; cursor: not-allowed; }

/* Members table actions share one footprint on desktop instead of allowing
   their label length or individual visual style to determine button size. */
#membersTable td.members-actions {
  white-space: nowrap;
}

#membersTable td.members-actions > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  min-height: 34px;
  padding: 7px 8px;
  line-height: 1.15;
  vertical-align: middle;
}

/* Wide-screen table actions need explicit separation; mobile card actions
   define their own spacing further below and are intentionally untouched. */
@media (min-width: 768px) {
  .recorded-dried-batches-table td.prod-actions {
    white-space: nowrap;
  }
  .recorded-dried-batches-table td.prod-actions .btn-primary-amfe,
  .recorded-dried-batches-table td.prod-actions .btn-outline-amfe,
  .recorded-dried-batches-table td.prod-actions .btn-archive-amfe {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto !important;
    min-width: 0;
    min-height: 2.25rem;
    padding: .38rem .9rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    transition: all .15s ease;
  }
  .recorded-dried-batches-table td.prod-actions > button + button {
    margin-left: .5rem;
  }
  #membersTable td.members-actions > button + button {
    margin-left: .55rem;
  }
}

/* ===== TABLES ===== */
.amfe-table {
  width: 100%;
  border-collapse: collapse;
}
.amfe-table thead th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  border-bottom: 1.5px solid var(--border);
  background: #fafafa;
}
.amfe-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
.amfe-table tbody tr:last-child td { border-bottom: none; }
.amfe-table tbody tr:hover { background: #f9fafb; }
.amfe-table tr.month-group-row td {
  background: #f1f5f9;
  border-top: 2px solid #cbd5e1;
  border-bottom: 1.5px solid #e2e8f0;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  color: #1e293b;
}
.amfe-table tr.month-group-row:first-child td {
  border-top: none;
}
.amfe-table tr.month-group-row:hover td { background: #e9eef4; }

/* ===== SEARCH/FILTER ===== */
.search-input {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px 10px 36px;
  font-size: 13px;
  outline: none;
  background: #fff;
  width: 220px;
  transition: border 0.15s;
}
.search-input:focus { border-color: var(--primary); }
.search-wrap { position: relative; display: inline-block; }
.search-wrap i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-light); font-size: 14px; }

.filter-select {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 6px 24px 6px 10px;
  font-size: 13px;
  outline: none;
  background-color: #fff;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  color: var(--text-dark);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236c757d' stroke-width='1.6' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.filter-select:focus { border-color: var(--primary); }

/* ===== MODALS ===== */
.modal-content {
  border-radius: var(--radius);
  border: none;
  box-shadow: var(--shadow-lg);
}
.modal-header { border-bottom: 1px solid var(--border); padding: 18px 22px; }
.modal-header h5 { font-family: 'DM Serif Display', serif; font-size: 20px; font-weight: 400; }
.modal-body { padding: 20px 22px; }
.modal-footer { border-top: 1px solid var(--border); padding: 14px 22px; }

/* Bootstrap's scrollable-modal rules assume .modal-body and .modal-footer are
   direct children of .modal-content. Ours sit inside a <form>, so the form is
   the flex item — and a block flex item can't shrink below its content. The
   modal-content then blows past its max-height and its overflow:hidden clips
   the footer (Cancel / Save) right off the bottom. Let the form be the flex
   column instead so the body scrolls and the footer stays pinned. */
.modal-dialog-scrollable .modal-content > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.detail-field {
  background: #f8f9fa;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 10px;
}
.detail-field .field-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.detail-field .field-value { font-size: 14px; font-weight: 500; color: var(--text-dark); }
.section-heading {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-dark);
  margin: 16px 0 8px;
}

/* ===== FORM INPUTS ===== */
.amfe-input {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13.5px;
  width: 100%;
  outline: none;
  transition: border 0.15s;
  background: #fff;
  font-family: 'DM Sans', sans-serif;
}
.amfe-input:focus { border-color: var(--primary); }
.amfe-label { font-size: 13px; font-weight: 500; color: var(--text-dark); margin-bottom: 5px; display: block; }

/* Utility: ensure flex children can truncate without overflowing */
.min-w-0 {
  min-width: 0 !important;
}

/* ===== ALERT CARDS ===== */
.alert-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  text-decoration: none;
  color: inherit;
  border: 1px solid transparent;
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

button.alert-item {
  background: none;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  text-align: left;
}

.alert-item.alert-red { background: #fff5f5; border-color: rgba(220, 38, 38, 0.2); }
.alert-item.alert-yellow { background: #fffbeb; border-color: rgba(217, 119, 6, 0.2); }
.alert-item.alert-blue { background: #eff6ff; border-color: rgba(37, 99, 235, 0.2); }
.alert-item .alert-dot {
  width: 8px; height: 8px; border-radius: 50%;
  margin-top: 4px; flex-shrink: 0;
}
.alert-dot.red { background: #ef4444; }
.alert-dot.yellow { background: #f59e0b; }
.alert-dot.blue { background: #3b82f6; }

.alert-item--clickable {
  cursor: pointer;
  outline: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}
.alert-item--clickable.alert-item--amber:hover {
  background-color: #fffefb !important;
  border-color: #fcd34d !important;
  border-left-color: #d97706 !important;
  transform: translateY(-2px);
  text-decoration: none;
  color: inherit;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.14) !important;
}
.alert-item--clickable.alert-item--red:hover {
  background-color: #fffbfb !important;
  border-color: #fca5a5 !important;
  border-left-color: #dc2626 !important;
  transform: translateY(-2px);
  text-decoration: none;
  color: inherit;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.14) !important;
}
.alert-item--clickable:hover .bi-chevron-right {
  color: #334155 !important;
  transform: translateX(2px);
}
.alert-item--clickable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.alert-item__icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.alert-item__content {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.alert-item__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
}

.alert-item__title {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
}

.alert-item__badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 9999px;
  flex-shrink: 0;
  white-space: nowrap;
  line-height: 1.25;
}

.alert-item__subtitle {
  font-size: 11.5px;
  color: #4b5563;
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.alert-item__chevron {
  color: #9ca3af;
  font-size: 12px;
  flex-shrink: 0;
  margin-left: 2px;
  transition: transform 0.15s ease, color 0.15s ease;
}

.alert-item--clickable:hover .alert-item__chevron {
  color: #374151;
  transform: translateX(2px);
}

.dashboard-farmer-row {
  transition: background-color 0.15s ease, padding-left 0.15s ease;
  border-radius: 6px;
  padding-left: 6px;
  padding-right: 6px;
  cursor: pointer;
}
.dashboard-farmer-row:hover {
  background-color: #f3f8f5;
  padding-left: 10px;
}

/* ===== ACTIVITY ===== */
.dashboard-activity-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 8px;
  text-decoration: none !important;
  color: inherit !important;
  transition: background-color 0.15s ease, padding-left 0.15s ease;
  cursor: pointer;
}
.dashboard-activity-row:hover {
  background-color: #f8fafc !important;
  padding-left: 12px !important;
  text-decoration: none !important;
  color: inherit !important;
}
.dashboard-activity-row:hover .dashboard-activity-chevron {
  color: #334155 !important;
  transform: translateX(2px);
}
.dashboard-activity-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  margin-top: 1px;
}
.dashboard-activity-chevron {
  font-size: 11px;
  color: #cbd5e1;
  margin-top: 4px;
  flex-shrink: 0;
  transition: transform 0.15s ease, color 0.15s ease;
}
.activity-item:not(.dashboard-activity-row) {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.activity-item:not(.dashboard-activity-row):last-child { border-bottom: none; }
.activity-time:not(.dashboard-activity-row .activity-time) { font-size: 11px; color: var(--text-muted); }

/* ===== TABS ===== */
.amfe-tabs { display: flex; flex-wrap: wrap; row-gap: 8px; gap: 4px; margin-bottom: 20px; }
.amfe-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text-dark);
  transition: all 0.15s;
  text-decoration: none;
}
.amfe-tab:hover { border-color: var(--primary); color: var(--primary); }
.amfe-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Production's search bar + tabs: stacked (search full-width, tabs below)
   on narrow screens; side by side — search left, tabs right — once
   there's room, matching Members' filter-row pairing. */
.prod-search-tabs-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
  /* One shared backdrop card around the search bar + tabs pair, instead
     of two pills floating separately on the page — matches Members'
     filter row, where the search box and controls beside it read as one
     connected unit rather than two disconnected pieces. */
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}
.prod-search-tabs-row .amfe-tabs { margin-bottom: 0; flex-shrink: 0; }
.prod-search-tabs-row .amfe-tab { white-space: nowrap; }
.prod-search-tabs-row .search-wrap { display: block; width: 100%; }
/* Stacked (mobile) layout: the tab row only ever took up as much width
   as its 3 pills needed, so it fell short of the search bar's full
   width above it and looked misaligned/lopsided on the right. Stretch
   the tabs to fill the same width, splitting it evenly between them. */
.prod-search-tabs-row .amfe-tabs { width: 100%; }
.prod-search-tabs-row .amfe-tab { flex: 1; text-align: center; }
/* A two-column grid keeps the longer tab labels inside the card on phones.
   The final tab spans both columns instead of being squeezed into a third
   min-content-width flex item. */
@media (max-width: 479.98px) {
  .prod-search-tabs-row .amfe-tabs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .prod-search-tabs-row .amfe-tab {
    min-width: 0;
    padding-inline: 10px;
  }
  .prod-search-tabs-row .amfe-tab:nth-child(odd):last-child {
    grid-column: 1 / -1;
  }
}
@media (min-width: 640px) {
  .prod-search-tabs-row {
    flex-direction: row;
    align-items: center;
    gap: 20px;
  }
  /* Grows to fill the row instead of sitting at a fixed 220px with
     space-between shoving the tabs off to the far edge — that left a
     big dead gap in the middle. Matches Members' filter row, where the
     search box and the controls beside it sit close together. */
  .prod-search-tabs-row .search-wrap { flex: 1 1 auto; }
  /* Row mode: tabs sit beside the search box and should size to their
     own content again, not stretch to fill/split full width. */
  .prod-search-tabs-row .amfe-tabs { width: auto; }
  .prod-search-tabs-row .amfe-tab { flex: 0 0 auto; }
}

/* ===== CHARTS PLACEHOLDER ===== */
.chart-box {
  background: #f8f9fa;
  border-radius: var(--radius-sm);
  padding: 16px;
  height: 200px;
  display: flex; align-items: center; justify-content: center;
}

/* ===== PRODUCT GRID CARDS ===== */
.products-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.product-card-v {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Matches the public catalog: the product shots are tall subjects on white,
   so `cover` cropped their tops and bottoms off. `contain` shows each product
   whole, and the surround is white rather than grey so the letterboxing is
   invisible against the image's own background. */
.product-img-wrap {
  position: relative;
  width: 100%;
  /* Compact landscape frame; `contain` below keeps the entire square
     product artwork visible without making every card excessively tall. */
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #fff;
}

.product-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.product-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 6px;
}

.product-name-v {
  font-size: 17px;
  font-weight: 600;
  color: var(--primary);
}

.product-desc-v {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
  flex: 1;
}

.product-price-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 8px;
}

.product-price-v {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1;
}

.product-unit-v {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.product-stock-v {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dark);
  align-self: flex-end;
}

.product-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.btn-edit-product {
  flex: 1;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s;
  font-family: 'DM Sans', sans-serif;
}
.btn-edit-product:hover { background: var(--primary-light); }

.btn-delete-product {
  background: #fde8e8;
  color: var(--status-rejected);
  border: none;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.btn-delete-product:hover { background: #f5c6c6; }

/* Add Product pill button */
.btn-add-product {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
}
.btn-add-product:hover { background: var(--primary-light); }

/* Admin-assisted member registration */
.add-member-modal-dialog { max-width: 680px; }
.add-member-modal { overflow: hidden; border-radius: 16px; border: 1px solid #d2e2d8; }
.add-member-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.add-member-modal-subtitle {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 12.5px;
}
.add-member-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #ebf2ee;
}
.add-member-stepper .step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.2s ease;
}
.add-member-stepper .step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e5ece8;
  color: #4f6b5b;
  font-size: 12px;
  font-weight: 700;
  transition: all 0.2s ease;
}
.add-member-stepper .step-item.is-active {
  color: var(--primary-dark, #174c38);
}
.add-member-stepper .step-item.is-active .step-number {
  background: var(--primary, #1b6b44);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(27, 107, 68, 0.15);
}
.add-member-stepper .step-item.is-complete {
  color: var(--primary, #1b6b44);
}
.add-member-stepper .step-item.is-complete .step-number {
  background: #d4ebd9;
  color: #145c38;
}
.add-member-stepper .step-divider {
  flex: 1;
  height: 2px;
  margin: 0 10px;
  background: #e2ece6;
  border-radius: 1px;
}
.add-member-card {
  padding: 16px 18px;
  background: #fff;
  border: 1px solid #dce8e0;
  border-radius: 12px;
}
.add-member-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--primary-dark, #174c38);
  font-size: 13.5px;
  font-weight: 700;
}
.add-member-card-title i {
  color: var(--primary, #1b6b44);
}
.add-member-role-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.add-member-role-card {
  display: flex;
  flex-direction: column;
  padding: 14px;
  background: #fff;
  border: 1.5px solid #d2e2d8;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}
.add-member-role-card:hover {
  border-color: #208c55;
  background: #f7fbf8;
}
.add-member-role-card.is-selected {
  border-color: #145c38;
  background: #f0f8f3;
  box-shadow: 0 0 0 1px #145c38;
}
.role-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.role-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #e8f4ed;
  color: var(--primary, #1b6b44);
  font-size: 16px;
}
.add-member-role-card.is-selected .role-card-icon {
  background: #145c38;
  color: #fff;
}
.role-card-radio {
  font-size: 16px;
  color: #9cb5a5;
}
.add-member-role-card.is-selected .role-card-radio {
  color: #145c38;
}
.role-card-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 2px;
}
.role-card-desc {
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--text-muted);
}
.add-member-review-card {
  padding: 14px 16px;
  background: #f8faf8;
  border: 1px solid #d6e5dc;
  border-radius: 10px;
}
.review-card-title {
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark, #174c38);
}
.review-edit-link {
  color: #1b6b44 !important;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.review-edit-link:hover {
  color: #0f4429 !important;
  text-decoration: underline !important;
}
.review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}
.review-grid > div {
  display: flex;
  flex-direction: column;
}
.review-grid span {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 1px;
}
.review-grid strong {
  font-size: 13px;
  color: var(--text-dark);
  font-weight: 600;
  word-break: break-word;
}
.add-member-section {
  padding: 0 0 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.add-member-section:last-child { margin-bottom: 0; border-bottom: 0; padding-bottom: 0; }
.add-member-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--primary-dark, #174c38);
  font-size: 14px;
  font-weight: 700;
}
.add-member-section-title i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #e8f4ed;
  color: var(--primary);
}
.add-member-verification {
  padding: 16px;
  border: 1px solid #cfe3d6;
  border-radius: 12px;
  background: #f7fbf8;
}
.add-member-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  color: var(--text-dark);
  font-size: 13px;
  line-height: 1.45;
  cursor: pointer;
}
.add-member-check + .add-member-check { border-top: 1px dashed #dce8e0; }
.add-member-check input {
  width: 17px;
  height: 17px;
  margin-top: 1px;
  accent-color: var(--primary);
  flex: 0 0 auto;
}
.add-member-actions { gap: 8px; }
.add-member-actions .btn-primary-amfe,
.add-member-actions .btn-outline-amfe { min-width: 140px; justify-content: center; }
.add-member-success {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid #b9ddc6;
  border-radius: 12px;
  background: #edf9f1;
}
.add-member-success-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #208c55;
  color: #fff;
  font-size: 22px;
  flex: 0 0 auto;
}
.add-member-success h6 { margin: 0 0 3px; color: #145c38; font-size: 15px; font-weight: 700; }
.add-member-success p { margin: 0; color: #4b6657; font-size: 12.5px; }
.add-member-credential-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.add-member-credential-card > div {
  display: grid;
  grid-template-columns: minmax(125px, .7fr) minmax(0, 1.3fr);
  gap: 14px;
  padding: 13px 16px;
  align-items: center;
}
.add-member-credential-card > div + div { border-top: 1px solid var(--border); }
.add-member-credential-card span { color: var(--text-muted); font-size: 12px; }
.add-member-credential-card strong,
.add-member-credential-card code { min-width: 0; overflow-wrap: anywhere; color: var(--text-dark); font-size: 13px; }
.add-member-credential-card code { color: #145c38; font-weight: 700; }

@media (max-width: 576.98px) {
  .members-topbar-add { display: none !important; }
  .add-member-modal .modal-header,
  .add-member-modal .modal-body,
  .add-member-modal .modal-footer { padding-inline: 16px; }
  .add-member-stepper .step-label { display: none; }
  .add-member-stepper .step-item { gap: 4px; }
  .add-member-role-grid { grid-template-columns: 1fr; }
  .review-grid { grid-template-columns: 1fr; gap: 8px; }
  .add-member-actions { display: grid; grid-template-columns: 1fr; }
  .add-member-actions .btn-primary-amfe,
  .add-member-actions .btn-outline-amfe { width: 100%; }
  .add-member-credential-card > div { grid-template-columns: 1fr; gap: 3px; }
}

/* Sidebar role label */
.sidebar-brand .brand-role {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Add/Edit form action buttons — equal width, stack on small mobile */
.prod-form-actions {
  display: flex;
  gap: 10px;
}
.prod-form-actions .btn-primary-amfe,
.prod-form-actions .btn-outline-amfe {
  flex: 1 1 0;
  min-width: 0;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
}

/* ===== PRODUCTS GRID RESPONSIVE ===== */
@media (max-width: 991px) {
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
  }
}

@media (max-width: 576px) {
  .products-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .product-name-v { font-size: 15px; }
  .product-price-v { font-size: 19px; }

  /* Tabs: tighter so 3 in a row (Production's By Member / Fresh
     Malunggay / Dried Processing) need less width before wrapping. */
  .amfe-tab { padding: 10px 12px; font-size: 12px; }
}

/* ===== STAT CARD ICON ON RIGHT ===== */
.stat-card { justify-content: space-between; }

/* ===== ANALYTICS INSIGHT BOXES ===== */
.insight-box {
  border-radius: 14px;
  padding: 18px 20px;
  height: 100%;
  border: 1px solid #e2e8f0;
  border-left: 4px solid transparent;
  transition: transform .2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow .2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 3px rgba(18, 55, 42, 0.03);
}
.insight-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(18, 55, 42, 0.07);
}
.insight-box .insight-title { font-size: 15.5px; font-weight: 750; margin-bottom: 7px; letter-spacing: -0.01em; }
.insight-box .insight-text  { font-size: 13.5px; color: #475569; line-height: 1.6; }
.insight-box.green  { background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%); border-left-color: #16a34a; border-color: #dcfce7; } .insight-box.green  .insight-title { color: #15803d; }
.insight-box.blue   { background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%); border-left-color: #2563eb; border-color: #dbeafe; } .insight-box.blue   .insight-title { color: #2563eb; }
.insight-box.purple { background: linear-gradient(180deg, #f5f3ff 0%, #ffffff 100%); border-left-color: #7c3aed; border-color: #ede9fe; } .insight-box.purple .insight-title { color: #7c3aed; }
.insight-box.amber  { background: linear-gradient(180deg, #fffbeb 0%, #ffffff 100%); border-left-color: #d97706; border-color: #fef3c7; } .insight-box.amber  .insight-title { color: #b45309; }
.insight-box.teal   { background: linear-gradient(180deg, #f0fdfa 0%, #ffffff 100%); border-left-color: #0d9488; border-color: #ccfbf1; } .insight-box.teal   .insight-title { color: #0f766e; }
.insight-box.red    { background: linear-gradient(180deg, #fef2f2 0%, #ffffff 100%); border-left-color: #dc2626; border-color: #fee2e2; } .insight-box.red    .insight-title { color: #b91c1c; }
.analytics-ranking { margin-top: 14px; }
.analytics-ranking-toggle {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; padding: 7px 14px;
  border: 1.5px solid #bfdbfe; border-radius: 999px; color: #1d4ed8;
  background: #ffffff; font-size: 12.5px; font-weight: 700; cursor: pointer;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.06);
  transition: all .2s cubic-bezier(0.4, 0, 0.2, 1);
}
.analytics-ranking-toggle:hover {
  background: #2563eb; color: #ffffff; border-color: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.22);
}
.analytics-ranking-toggle:active { transform: translateY(0); }
.analytics-ranking-toggle-arrow { font-size: 12px; transition: transform .2s ease; }
.analytics-ranking-toggle:hover .analytics-ranking-toggle-arrow { transform: translate(2px, -2px); }
.analytics-ranking-subtitle,
.analytics-ranking-note { margin-top: 3px; color: #64748b; font-size: 12px; }
.analytics-ranking-groups { margin-top: 8px; }
.analytics-ranking-groups-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.analytics-ranking-group-title {
  margin-bottom: 8px; color: #334155; font-size: 12px; font-weight: 800;
  letter-spacing: .04em; text-transform: uppercase;
}
.analytics-ranking-table-header {
  display: flex; align-items: center; gap: 12px; padding: 0 12px 6px;
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: #94a3b8;
}
.analytics-th-rank { flex: 0 0 32px; text-align: center; }
.analytics-th-period { flex: 1; min-width: 0; }
.analytics-th-value { text-align: right; }
.analytics-ranking-list { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.analytics-ranking-row {
  display: flex; align-items: center; gap: 12px; min-height: 42px;
  padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff;
  transition: all .16s ease;
}
.analytics-ranking-row:hover {
  border-color: #cbd5e1; background: #f8fafc; transform: translateX(2px);
}
.analytics-ranking-row.rank-gold {
  background: linear-gradient(90deg, #fffdf2 0%, #ffffff 100%);
  border-color: #fde68a;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.08);
}
.analytics-ranking-row.rank-gold:hover {
  background: linear-gradient(90deg, #fffbeb 0%, #fefce8 100%);
  border-color: #fcd34d;
}
.analytics-ranking-row.rank-gold .analytics-ranking-period {
  color: #0f172a; font-weight: 700;
}
.analytics-ranking-row.rank-gold .analytics-ranking-value {
  color: #b45309; font-weight: 800; font-size: 14.5px;
}
.analytics-ranking-row.rank-silver {
  background: linear-gradient(90deg, #f8fafc 0%, #ffffff 100%);
  border-color: #e2e8f0;
}
.analytics-ranking-row.rank-silver .analytics-ranking-period {
  color: #0f172a; font-weight: 600;
}
.analytics-ranking-row.rank-silver .analytics-ranking-value {
  color: #1e293b; font-weight: 700;
}
.analytics-ranking-row.rank-bronze {
  background: linear-gradient(90deg, #fffaf5 0%, #ffffff 100%);
  border-color: #fed7aa;
}
.analytics-ranking-row.rank-bronze .analytics-ranking-period {
  color: #0f172a; font-weight: 600;
}
.analytics-ranking-row.rank-bronze .analytics-ranking-value {
  color: #9a3412; font-weight: 700;
}
.analytics-ranking-number {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 28px; height: 28px;
  border-radius: 8px; color: #64748b; background: #f1f5f9; font-size: 12px; font-weight: 700;
}
.analytics-ranking-number.rank-gold {
  background: #fef3c7; color: #b45309; border: 1px solid #fde68a; font-weight: 800;
}
.analytics-ranking-number.rank-silver {
  background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; font-weight: 800;
}
.analytics-ranking-number.rank-bronze {
  background: #ffedd5; color: #9a3412; border: 1px solid #fed7aa; font-weight: 800;
}
.analytics-ranking-period { min-width: 0; flex: 1; color: #334155; font-size: 13.5px; }
.analytics-ranking-value { color: #1e293b; font-size: 14px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.analytics-ranking-empty { margin-top: 12px; color: #64748b; font-size: 13px; }
.analytics-modal-open { overflow: hidden; }
.analytics-ranking-modal {
  position: fixed; z-index: 1060; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 20px 16px; background: rgba(15, 23, 42, .55); backdrop-filter: blur(6px);
  overflow-y: auto;
  animation: analytics-modal-in .2s ease-out;
}
.analytics-ranking-modal-panel {
  display: flex; flex-direction: column;
  width: min(560px, 100%);
  max-height: min(720px, calc(100vh - 40px));
  max-height: min(720px, calc(100dvh - 40px));
  margin: auto;
  overflow: hidden;
  border: 1px solid rgba(226, 232, 240, 0.9); border-radius: 20px; background: #fff;
  box-shadow: 0 25px 60px -15px rgba(15, 23, 42, .25), 0 0 0 1px rgba(15, 23, 42, .05);
  animation: analytics-panel-in .22s cubic-bezier(0.16, 1, 0.3, 1);
}
.analytics-ranking-modal-panel:has(.analytics-ranking-groups-split) {
  width: min(720px, 100%);
}
.analytics-ranking-modal-header {
  flex-shrink: 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
  padding: 20px 24px 16px; border-bottom: 1px solid #f1f5f9; background: #ffffff;
}
.analytics-ranking-modal-kicker {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 6px; padding: 4px 10px;
  border-radius: 999px; background: #eff6ff; border: 1px solid #dbeafe;
  color: #2563eb; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
}
.analytics-ranking-modal-kicker i { font-size: 11px; }
.analytics-ranking-modal h2 { margin: 4px 0 2px; color: #0f172a; font-size: 20px; font-weight: 800; letter-spacing: -.025em; }
.analytics-ranking-modal-header p { margin: 0; color: #64748b; font-size: 12.5px; }
.analytics-ranking-modal-close {
  display: grid; place-items: center; flex: 0 0 34px; width: 34px; height: 34px;
  border: 1px solid #e2e8f0; border-radius: 50%; color: #64748b; background: #f8fafc; cursor: pointer;
  transition: all .16s ease;
}
.analytics-ranking-modal-close:hover { color: #0f172a; background: #f1f5f9; border-color: #cbd5e1; transform: rotate(90deg); }
.analytics-ranking-modal .analytics-ranking-groups {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 24px 20px;
}
.analytics-ranking-modal-footer {
  flex-shrink: 0;
  display: flex; justify-content: flex-end; padding: 12px 24px;
  border-top: 1px solid #f1f5f9; background: #f8fafc; border-radius: 0 0 20px 20px;
}
.analytics-ranking-modal-btn-close {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 7px 18px; border-radius: 8px; border: 1px solid #d1d5db; background: #ffffff;
  color: #374151; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .16s ease;
}
.analytics-ranking-modal-btn-close:hover {
  background: #f3f4f6; color: #111827; border-color: #9ca3af;
}
@keyframes analytics-modal-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes analytics-panel-in { from { opacity: 0; transform: scale(0.97) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@media (max-width: 767px) { .analytics-ranking-groups-split { grid-template-columns: 1fr; } }
@media (max-width: 767px) { .analytics-ranking-modal { padding: 12px; } .analytics-ranking-modal-header { padding: 20px 18px 16px; } .analytics-ranking-modal .analytics-ranking-groups { padding: 16px 18px 20px; } }
.recommendations-panel { padding: 18px 20px; }
.recommendations-list { display: grid; gap: 10px; margin-top: 10px; }
.recommendation-row { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; padding: 13px 14px; border: 1px solid #e7e2f5; border-radius: 12px; background: rgba(255,255,255,.78); }
.recommendation-number { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 9px; background: #ede9fe; color: #6d28d9; font-size: 12px; font-weight: 800; }
.recommendation-content { min-width: 0; }
.recommendation-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.recommendation-heading strong { color: #26332e; font-size: 13px; }
.recommendation-priority { flex: 0 0 auto; padding: 3px 8px; border-radius: 999px; font-size: 9.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.recommendation-priority.priority-high { color: #b42318; background: #fee4e2; }
.recommendation-priority.priority-medium { color: #9a6700; background: #fff3cd; }
.recommendation-priority.priority-advisory { color: #175cd3; background: #e8f1ff; }
.recommendation-detail { color: #5f6d66; font-size: 13px; line-height: 1.55; }
.recommendation-detail + .recommendation-detail { margin-top: 4px; }
.recommendation-detail span { margin-right: 6px; color: #47564f; font-weight: 750; }
.recommendation-detail.action { color: #33463e; }
.analytics-insights-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.analytics-insights-range { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; color: #1e5943; background: #edf7f2; border: 1px solid #d7ebe0; font-size: 10.5px; font-weight: 700; }
.analytics-insights-card { display: flex; flex-direction: column; }
.analytics-insights-card > .analytics-insights-heading { order: 1; }
.analytics-insights-card > .row { order: 2; }
.analytics-insights-card > .analytics-diagnostic-insight { order: 3; }
.analytics-insights-card > .analytics-method-note { order: 4; }
.resource-planning-column { margin-top: 4px; }
.resource-planning-panel {
  overflow: hidden;
  border: 1px solid #d8e8df;
  border-radius: 18px;
  background: linear-gradient(145deg, #f7fcf9 0%, #ffffff 62%);
  box-shadow: 0 8px 24px rgba(24, 70, 51, .06);
}
.resource-planning-header {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 18px 20px;
  border-bottom: 1px solid #e8f1ec;
  background: linear-gradient(90deg, rgba(230, 246, 237, .78), rgba(255, 255, 255, .25));
}
.resource-planning-header-icon {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  color: #166534;
  background: #dcfce7;
  box-shadow: inset 0 0 0 1px #bbf7d0;
  font-size: 18px;
}
.resource-planning-header h3 {
  margin: 0;
  color: #183c2d;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.015em;
}
.resource-planning-header p {
  margin: 3px 0 0;
  color: #6b7c74;
  font-size: 12.5px;
}
.resource-planning-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 20px;
}
.resource-planning-metric {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  min-height: 82px;
  padding: 13px 14px;
  border: 1px solid #e3ebe7;
  border-radius: 14px;
  background: rgba(255, 255, 255, .92);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.resource-planning-metric:hover {
  transform: translateY(-1px);
  border-color: #cbded4;
  box-shadow: 0 7px 18px rgba(30, 77, 58, .07);
}
.resource-planning-metric-icon {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  color: #2563eb;
  background: #eff6ff;
  font-size: 15px;
}
.resource-planning-metric > div { min-width: 0; }
.resource-planning-metric > div > span {
  display: block;
  color: #718078;
  font-size: 10.5px;
  font-weight: 750;
  line-height: 1.25;
  text-transform: uppercase;
  letter-spacing: .035em;
}
.resource-planning-metric strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  color: #1f3028;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
}
.resource-planning-metric.tone-indigo .resource-planning-metric-icon { color: #4f46e5; background: #eef2ff; }
.resource-planning-metric.tone-green .resource-planning-metric-icon { color: #15803d; background: #ecfdf3; }
.resource-planning-metric.tone-amber .resource-planning-metric-icon { color: #b45309; background: #fffbeb; }
.resource-planning-metric.tone-red .resource-planning-metric-icon { color: #dc2626; background: #fef2f2; }
.resource-planning-metric.tone-red strong { color: #c62828; }
.resource-planning-actions {
  margin: 0 20px 18px;
  padding: 15px 17px;
  border: 1px solid #e7dfc5;
  border-radius: 14px;
  background: #fffdf5;
}
.resource-planning-actions-title {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #6f5518;
  font-size: 12px;
  font-weight: 800;
}
.resource-planning-actions ul {
  display: grid;
  gap: 6px;
  margin: 9px 0 0;
  padding-left: 21px;
  color: #554f40;
  font-size: 13px;
  line-height: 1.5;
}
.resource-planning-footer {
  display: flex;
  justify-content: flex-end;
  padding: 13px 20px;
  border-top: 1px solid #e8f1ec;
  background: rgba(248, 251, 249, .9);
}
.resource-planning-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border: 1px solid #7fbd9d;
  border-radius: 9px;
  color: #176b45;
  background: #ffffff;
  font-size: 12.5px;
  font-weight: 750;
  text-decoration: none;
  transition: color .16s ease, background .16s ease, border-color .16s ease, transform .16s ease;
}
.resource-planning-link:hover {
  transform: translateY(-1px);
  border-color: #1f7a51;
  color: #ffffff;
  background: #1f7a51;
}
@media (max-width: 991px) and (min-width: 576px) {
  .resource-planning-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.analytics-diagnostic-insight {
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid #d5e5dc;
  border-left: 5px solid #1b4332;
  border-radius: 16px;
  background: linear-gradient(180deg, #f7faf8 0%, #ffffff 85%);
  box-shadow: 0 4px 18px rgba(24, 49, 38, 0.05);
  transition: all 0.2s ease-in-out;
}

.analytics-diagnostic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 16px;
  border-bottom: 1px solid #edf4f0;
}

.analytics-diagnostic-title-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.analytics-diagnostic-icon {
  display: grid;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 12px;
  color: #166534;
  background: #eaf5ee;
  border: 1.5px solid #c2e2d3;
  font-size: 19px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.analytics-diagnostic-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
  color: #166534;
  background: #eaf5ee;
  border: 1px solid #c2e2d3;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.analytics-diagnostic-header h3 {
  margin: 2px 0 2px;
  color: #0f172a;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.analytics-diagnostic-header p {
  margin: 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.4;
}

.analytics-diagnostic-period {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 6px 14px;
  border: 1.5px solid #c2e2d3;
  border-radius: 9999px;
  color: #166534;
  background: #ffffff;
  font-size: 12px;
  font-weight: 750;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.analytics-diagnostic-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 22px 14px;
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
}

.analytics-diagnostic-summary .diagnostic-summary-card {
  min-width: 0;
  padding: 13px 15px;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.analytics-diagnostic-summary .diagnostic-summary-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.04);
}

.analytics-diagnostic-summary .diagnostic-summary-label {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
  color: #64748b;
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.analytics-diagnostic-summary .diagnostic-summary-val-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.analytics-diagnostic-summary .diagnostic-summary-value {
  display: block;
  overflow: hidden;
  color: #0f172a;
  font-size: 15.5px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.analytics-diagnostic-summary .diagnostic-summary-sub {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  overflow: hidden;
  color: #475569;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-diagnostic-summary .diagnostic-summary-card.is-change.is-up {
  background: linear-gradient(145deg, #f0fdf4 0%, #ffffff 100%);
  border-color: #bbf7d0;
}
.analytics-diagnostic-summary .diagnostic-summary-card.is-change.is-up .diagnostic-summary-value {
  color: #166534;
}
.analytics-diagnostic-summary .diagnostic-summary-card.is-change.is-up .diagnostic-summary-sub {
  color: #15803d;
}

.analytics-diagnostic-summary .diagnostic-summary-card.is-change.is-down {
  background: linear-gradient(145deg, #fef2f2 0%, #ffffff 100%);
  border-color: #fecaca;
}
.analytics-diagnostic-summary .diagnostic-summary-card.is-change.is-down .diagnostic-summary-value {
  color: #991b1b;
}
.analytics-diagnostic-summary .diagnostic-summary-card.is-change.is-down .diagnostic-summary-sub {
  color: #b91c1c;
}

.analytics-diagnostic-summary .analytics-diagnostic-leaders {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
}

.analytics-diagnostic-summary .diagnostic-leader-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #0f172a;
  font-size: 13.5px;
  font-weight: 750;
  line-height: 1.35;
}

.analytics-diagnostic-explanation {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 0 22px 16px;
}

.analytics-diagnostic-explanation .diagnostic-explanation-card {
  padding: 15px 18px;
  border-radius: 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.analytics-diagnostic-explanation .diagnostic-explanation-card.is-meaning {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
}

.analytics-diagnostic-explanation .diagnostic-explanation-card.is-action {
  background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
  border: 1.5px solid #bbf7d0;
  box-shadow: 0 2px 6px rgba(22, 101, 52, 0.04);
}

.analytics-diagnostic-explanation .diagnostic-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.analytics-diagnostic-explanation .diagnostic-card-badge-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.analytics-diagnostic-explanation .badge-meaning {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.analytics-diagnostic-explanation .badge-action {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.analytics-diagnostic-explanation .diagnostic-card-header-title {
  color: #0f172a;
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.analytics-diagnostic-explanation .diagnostic-card-body p {
  margin: 0;
  color: #334155;
  font-size: 13px;
  line-height: 1.6;
}

.analytics-diagnostic-explanation .diagnostic-explanation-card.is-action .diagnostic-card-body p {
  color: #0f172a;
  font-weight: 550;
}

.analytics-diagnostic-toggle {
  display: flex;
  width: calc(100% - 44px);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 22px 18px;
  padding: 10px 16px;
  border: 1.5px solid #cbd5e1;
  border-radius: 11px;
  color: #1e293b;
  background: #ffffff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.analytics-diagnostic-toggle:hover {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}

.analytics-diagnostic-toggle span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.analytics-diagnostic-toggle span i {
  color: #166534;
  font-size: 14px;
}

.analytics-diagnostic-table {
  border-top: 1.5px solid #e2ece7;
  background: #ffffff;
  padding: 12px 22px 18px;
}

.analytics-diagnostic-table-heading {
  padding: 10px 0 8px;
  color: #166534;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.analytics-diagnostic-table-heading.is-dried {
  padding-top: 18px;
  margin-top: 14px;
  border-top: 1px dashed #cbd5e1;
}

.analytics-diagnostic-method {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #64748b;
  font-size: 12px;
  line-height: 1.5;
}

.analytics-diagnostic-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 20px 18px;
  padding: 14px 16px;
  border-radius: 12px;
  color: #475569;
  background: #f8fafc;
  border: 1.5px dashed #cbd5e1;
  font-size: 13px;
}

.admin-analytics-stat-pill.pill-increase {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.admin-analytics-stat-pill.pill-decrease {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}
.analytics-demand-disclosure { overflow: hidden; padding: 0; }
.analytics-demand-toggle { display: grid; width: 100%; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 17px 20px; border: 0; color: #173c2e; background: linear-gradient(135deg, #f3faf6 0%, #fff 72%); text-align: left; transition: background .2s ease, box-shadow .2s ease; }
.analytics-demand-toggle:hover { background: linear-gradient(135deg, #eaf7f0 0%, #fff 76%); }
.analytics-demand-toggle:focus-visible { outline: 3px solid rgba(36, 98, 75, .2); outline-offset: -3px; }
.analytics-demand-toggle-icon { display: grid; width: 44px; height: 44px; place-items: center; border: 1px solid #cce4d8; border-radius: 13px; color: #1e664c; background: #e5f4ec; font-size: 19px; }
.analytics-demand-toggle-copy { min-width: 0; }
.analytics-demand-toggle-copy strong, .analytics-demand-toggle-copy small { display: block; }
.analytics-demand-toggle-copy strong { color: #142033; font-size: 17px; font-weight: 800; line-height: 1.25; }
.analytics-demand-toggle-copy small { margin-top: 4px; color: #65748a; font-size: 13px; line-height: 1.45; }
.analytics-demand-toggle-meta { display: flex; align-items: center; gap: 7px; }
.analytics-demand-toggle-meta span { padding: 5px 9px; border: 1px solid #d6e8df; border-radius: 999px; color: #2c604c; background: #fff; font-size: 10.5px; font-weight: 750; white-space: nowrap; }
.analytics-demand-chevron { color: #32614f; font-size: 15px; }
.analytics-demand-panel { position: relative; border-top: 1px solid #dce9e3; background: #fff; }
.analytics-demand-close { position: absolute; z-index: 2; top: 14px; right: 18px; display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid #d8e5df; border-radius: 10px; color: #52645d; background: #fff; font-size: 14px; transition: color .18s ease, background .18s ease, border-color .18s ease, transform .18s ease; }
.analytics-demand-close:hover { color: #173c2e; background: #edf7f2; border-color: #bcd8cb; transform: translateY(-1px); }
.analytics-demand-close:focus-visible { outline: 3px solid rgba(36, 98, 75, .18); outline-offset: 2px; }
.analytics-demand-context { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 58px 20px 4px; }
.analytics-demand-context > div { position: relative; min-height: 104px; padding: 17px 18px 16px 58px; border: 1px solid #dce9e3; border-radius: 16px; background: linear-gradient(145deg, #f7fbf9 0%, #fff 100%); }
.analytics-demand-context span, .analytics-demand-context strong, .analytics-demand-context small { display: block; }
.analytics-demand-context span { margin-bottom: 4px; color: #2d7558; font-size: 9.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.analytics-demand-context strong { color: #23372f; font-size: 13px; line-height: 1.45; }
.analytics-demand-context small { margin-top: 3px; color: #6c7973; font-size: 12px; }
.analytics-demand-context .analytics-demand-context-icon { position: absolute; top: 17px; left: 16px; display: grid; width: 30px; height: 30px; place-items: center; margin: 0; border-radius: 9px; color: #24624b; background: #e5f4ec; font-size: 14px; letter-spacing: 0; }
.analytics-demand-panel-heading { padding: 16px 20px 12px; }
.analytics-demand-panel-heading > div { display: flex; align-items: center; gap: 9px; }
.analytics-demand-heading-icon { display: grid; width: 29px; height: 29px; flex: 0 0 29px; place-items: center; border-radius: 8px; color: #24624b; background: #e8f5ee; font-size: 13px; }
.analytics-demand-panel-heading h2 { margin: 0; color: #142033; font-size: 17px; font-weight: 800; }
.analytics-demand-panel-heading p { margin: 4px 0 0; color: #65748a; font-size: 13px; line-height: 1.5; }
.analytics-revenue-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 16px 20px 2px; }
.analytics-revenue-kpi { display: flex; align-items: center; gap: 14px; min-height: 116px; padding: 18px; overflow: hidden; border: 1px solid #d7e7df; border-radius: 16px; background: linear-gradient(135deg, #f5fbf8 0%, #fff 78%); }
.analytics-revenue-kpi.is-leading { border-color: #e8ddbd; background: linear-gradient(135deg, #fffaf0 0%, #fff 78%); }
.analytics-revenue-kpi-icon { display: grid; width: 44px; height: 44px; flex: 0 0 44px; place-items: center; border-radius: 13px; color: #176447; background: #dff3e9; font-size: 19px; }
.analytics-revenue-kpi.is-leading .analytics-revenue-kpi-icon { color: #956b12; background: #fff0c9; }
.analytics-revenue-kpi div { min-width: 0; }
.analytics-revenue-kpi small, .analytics-revenue-kpi strong, .analytics-revenue-kpi span { display: block; }
.analytics-revenue-kpi small { margin-bottom: 3px; color: #66756e; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .035em; }
.analytics-revenue-kpi strong { overflow: hidden; color: #17241f; font-size: clamp(20px, 2vw, 27px); font-weight: 800; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.analytics-revenue-kpi span { margin-top: 5px; color: #61716a; font-size: 12px; }
.analytics-revenue-kpi span i { margin-right: 5px; color: #2f8b67; }
.analytics-revenue-kpi > .analytics-revenue-kpi-icon { display: grid; align-items: center; justify-items: center; margin-top: 0; color: #176447; }
.analytics-revenue-kpi.is-leading > .analytics-revenue-kpi-icon { color: #956b12; }
.analytics-revenue-kpi > .analytics-revenue-kpi-icon i { display: block; margin: 0; color: inherit; line-height: 1; }
.analytics-revenue-products { display: grid; gap: 10px; padding: 0 20px; }
.analytics-revenue-product { display: grid; grid-template-columns: 34px minmax(0, 1fr) minmax(190px, auto); align-items: center; gap: 14px; padding: 16px 18px; border: 1px solid #e0e8e4; border-radius: 15px; background: #fff; transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
.analytics-revenue-product:hover { border-color: #bed8cc; box-shadow: 0 8px 22px rgba(25, 70, 52, .07); transform: translateY(-1px); }
.analytics-revenue-product.is-leading { border-color: #c8dfd4; background: linear-gradient(100deg, #f4fbf7 0%, #fff 62%); }
.analytics-revenue-product-rank { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 10px; color: #32614f; background: #e8f4ee; font-size: 12px; font-weight: 800; }
.analytics-revenue-product.is-leading .analytics-revenue-product-rank { color: #fff; background: #24624b; }
.analytics-revenue-product-main { min-width: 0; }
.analytics-revenue-product-name { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.analytics-revenue-product-name strong, .analytics-revenue-product-name small { display: block; }
.analytics-revenue-product-name strong { color: #24342e; font-size: 14px; font-weight: 800; }
.analytics-revenue-product-name small { margin-top: 1px; color: #7a8781; font-size: 11px; }
.analytics-revenue-leader-badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 7px; border-radius: 999px; color: #7a5a15; background: #fff1c9; font-size: 9.5px; font-weight: 800; white-space: nowrap; }
.analytics-revenue-leader-badge i { font-size: 9px; }
.analytics-revenue-share-track { height: 8px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: #e9efec; }
.analytics-revenue-share-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #2d7659, #62a888); }
.analytics-revenue-product-meta { display: flex; flex-wrap: wrap; gap: 7px 15px; margin-top: 8px; color: #6b7973; font-size: 10.5px; }
.analytics-revenue-product-meta span { display: inline-flex; align-items: center; gap: 5px; }
.analytics-revenue-product-meta i { color: #438068; }
.analytics-revenue-product-meta strong { color: #53645c; font-weight: 750; }
.analytics-revenue-product-value { min-width: 190px; padding-left: 16px; border-left: 1px solid #e6ece9; text-align: right; }
.analytics-revenue-product-value small, .analytics-revenue-product-value strong, .analytics-revenue-product-value span { display: block; }
.analytics-revenue-product-value small { color: #7b8782; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .035em; }
.analytics-revenue-product-value strong { margin-top: 2px; color: #182720; font-size: 20px; font-weight: 800; }
.analytics-revenue-product-value span { display: inline-block; margin-top: 5px; padding: 4px 8px; border: 1px solid #d7e5de; border-radius: 999px; color: #52675e; background: #f8faf9; font-size: 9.5px; font-weight: 700; }
.analytics-revenue-action { display: flex; align-items: flex-start; gap: 12px; margin: 16px 20px 0; padding: 15px 17px; border: 1px solid #e2d9bd; border-radius: 14px; color: #4b493e; background: #fffbef; }
.analytics-revenue-action > span { display: grid; width: 31px; height: 31px; flex: 0 0 31px; place-items: center; border-radius: 9px; color: #8b6717; background: #fff0c2; }
.analytics-revenue-action strong { display: block; margin-bottom: 3px; color: #4d432b; font-size: 12px; }
.analytics-revenue-action p { margin: 0; color: #625d4f; font-size: 12px; line-height: 1.55; }
@media (max-width: 575px) {
  .recommendations-panel { padding: 15px; }
  .recommendation-row { grid-template-columns: 26px minmax(0, 1fr); gap: 9px; padding: 11px; }
  .recommendation-number { width: 26px; height: 26px; }
  .recommendation-heading { align-items: flex-start; }
  .analytics-insights-heading { align-items: flex-start; flex-direction: column; }
  .resource-planning-header { align-items: flex-start; padding: 16px; }
  .resource-planning-grid { grid-template-columns: 1fr; padding: 15px 16px; }
  .resource-planning-metric { min-height: 70px; }
  .resource-planning-actions { margin: 0 16px 15px; }
  .resource-planning-footer { justify-content: stretch; padding: 12px 16px; }
  .resource-planning-link { justify-content: center; width: 100%; }
  .analytics-diagnostic-header { align-items: flex-start; flex-direction: column; padding: 15px; }
  .analytics-diagnostic-summary { grid-template-columns: 1fr 1fr; margin: 0 15px 12px; }
  .analytics-diagnostic-explanation { grid-template-columns: 1fr; margin: 0 15px 12px; }
  .analytics-diagnostic-toggle { width: calc(100% - 30px); margin: 0 15px 14px; }
  .analytics-diagnostic-empty { margin: 0 15px 15px; }
  .analytics-demand-toggle { grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; padding: 14px 15px; }
  .analytics-demand-toggle-icon { width: 38px; height: 38px; border-radius: 11px; font-size: 16px; }
  .analytics-demand-toggle-copy strong { font-size: 14px; }
  .analytics-demand-toggle-copy small { font-size: 12px; }
  .analytics-demand-toggle-meta { grid-column: 2 / -1; flex-wrap: wrap; }
  .analytics-demand-chevron { grid-column: 3; grid-row: 1; }
  .analytics-demand-close { top: 12px; right: 13px; }
  .analytics-demand-context { grid-template-columns: 1fr; padding: 58px 15px 2px; }
  .analytics-demand-context > div { min-height: 0; padding: 14px 14px 14px 52px; }
  .analytics-demand-context .analytics-demand-context-icon { top: 14px; left: 13px; }
  .analytics-demand-panel-heading { padding: 14px 15px 10px; }
  .analytics-revenue-summary { grid-template-columns: 1fr; padding: 14px 15px 2px; }
  .analytics-revenue-kpi { min-height: 0; padding: 15px; }
  .analytics-revenue-kpi strong { font-size: 21px; }
  .analytics-revenue-products { padding: 0 15px; }
  .analytics-revenue-product { grid-template-columns: 30px minmax(0, 1fr); gap: 10px; padding: 14px; }
  .analytics-revenue-product-rank { width: 29px; height: 29px; }
  .analytics-revenue-product-value { grid-column: 2; min-width: 0; padding: 10px 0 0; border-top: 1px solid #e6ece9; border-left: 0; text-align: left; }
  .analytics-revenue-product-value strong { font-size: 18px; }
  .analytics-revenue-leader-badge { display: none; }
  .analytics-revenue-action { margin: 14px 15px 0; }
}
.analytics-method-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}
.analytics-method-note i { color: var(--green-mid); margin-top: 1px; }

/* Forecast reliability keeps the decision-facing message prominent while
   making validation metrics available without overwhelming administrators. */
.forecast-reliability-card { padding: 22px 24px; }
.forecast-reliability-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.forecast-reliability-icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 42px; width: 42px; height: 42px; border-radius: 12px; background: #edf7f2; color: #1e5943; font-size: 20px; }
.forecast-reliability-heading h3 { margin: 0 0 2px; color: #17221e; font-size: 17px; font-weight: 750; letter-spacing: -.01em; }
.forecast-reliability-heading p { margin: 0; color: #64748b; font-size: 12.5px; }
.forecast-reliability-status { height: auto; margin-bottom: 16px; padding: 16px 18px; }
.forecast-technical-details { border: 1px solid #e2e8e5; border-radius: 13px; overflow: hidden; background: #fff; }
.forecast-technical-details summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; color: #334155; font-size: 13px; font-weight: 700; cursor: pointer; list-style: none; background: #f8faf9; }
.forecast-technical-details summary::-webkit-details-marker { display: none; }
.forecast-technical-details summary i { color: #1e5943; transition: transform .18s ease; }
.forecast-technical-details[open] summary { border-bottom: 1px solid #e7ece9; }
.forecast-technical-details[open] summary i { transform: rotate(180deg); }
.forecast-assessment-explainer { margin: 16px 16px 0; padding: 13px 14px; border-left: 3px solid #1e5943; border-radius: 0 10px 10px 0; background: #f3f8f5; }
.forecast-assessment-explainer strong { display: block; margin-bottom: 4px; color: #1e4d3a; font-size: 12.5px; }
.forecast-assessment-explainer p { margin: 0; color: #53615b; font-size: 13px; line-height: 1.55; }
.forecast-metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 16px; }
.forecast-metric { min-width: 0; padding: 14px; border: 1px solid #e7ece9; border-radius: 12px; background: #fbfcfb; }
.forecast-metric-label { display: block; min-height: 34px; color: #53615b; font-size: 12.5px; font-weight: 650; line-height: 1.4; }
.forecast-metric strong { display: block; margin: 5px 0 4px; color: #17221e; font-size: 19px; line-height: 1.2; }
.forecast-metric small { display: block; color: #718078; font-size: 12px; line-height: 1.45; }
.forecast-meaning-box { display: flex; align-items: flex-start; gap: 10px; margin: 0 16px 12px; padding: 12px 14px; border: 1px solid #f2dfaa; border-radius: 10px; background: #fffbeb; color: #594a20; font-size: 13px; line-height: 1.5; }
.forecast-meaning-box strong { flex: 0 0 auto; color: #8a5a0a; }
.forecast-technical-note { display: flex; align-items: flex-start; gap: 8px; margin: 0 16px 16px; padding: 11px 12px; border-radius: 10px; background: #f1f7f4; color: #53615b; font-size: 12.5px; line-height: 1.5; }
.forecast-technical-note i { margin-top: 1px; color: #1e5943; }
@media (max-width: 767px) {
  .forecast-reliability-card { padding: 16px; }
  .forecast-metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; }
  .forecast-technical-note { margin: 0 12px 12px; }
  .forecast-assessment-explainer { margin: 12px 12px 0; }
  .forecast-meaning-box { flex-direction: column; gap: 4px; margin: 0 12px 12px; }
}

/* ===== RECORDED DRIED-TO-FRESH RATIO MODAL ===== */
.ratio-modal-box {
  max-width: 540px !important;
  border-radius: 20px !important;
  padding: 26px 28px !important;
  border: 1px solid #dbe8e1;
  box-shadow: 0 16px 48px rgba(18, 55, 42, 0.16) !important;
}

.ratio-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #edf3ef;
}

.ratio-modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ratio-modal-icon-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #fef7e6 0%, #fdf0cd 100%);
  color: #b45309;
  border: 1px solid #fde68a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(180, 83, 9, 0.08);
}

.ratio-modal-title {
  font-size: 18px !important;
  font-weight: 800 !important;
  color: #172b21 !important;
  margin: 0 0 3px 0 !important;
  line-height: 1.25;
}

.ratio-modal-period {
  font-size: 12px;
  color: #557262;
  display: inline-flex;
  align-items: center;
  background: #f1f7f4;
  border: 1px solid #d6e8df;
  border-radius: 999px;
  padding: 2px 9px;
  font-weight: 600;
}

.ratio-modal-close {
  background-size: 11px;
  padding: 8px;
  margin: 0;
  transition: transform 0.15s ease;
}
.ratio-modal-close:hover {
  transform: rotate(90deg);
}

/* Dual stat cards */
.ratio-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.ratio-stat-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}
.ratio-stat-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(24, 49, 38, 0.06);
}

.ratio-stat-card.fresh {
  background: linear-gradient(145deg, #f6fbf8 0%, #ffffff 100%);
  border: 1.5px solid #cce5d7;
}
.ratio-stat-card.dried {
  background: linear-gradient(145deg, #fffdf7 0%, #ffffff 100%);
  border: 1.5px solid #f6e6bd;
}

.ratio-stat-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.ratio-stat-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}
.ratio-stat-icon.fresh {
  background: #e3f3eb;
  color: #1b633e;
  border: 1px solid #c4e5d3;
}
.ratio-stat-icon.dried {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.ratio-stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4b6355;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ratio-stat-val {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 4px;
}
.ratio-stat-val strong {
  font-size: 22px;
  font-weight: 800;
  color: #13281c;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.ratio-stat-val .ratio-stat-unit {
  font-size: 12px;
  font-weight: 600;
  color: #657e70;
}

.ratio-stat-subtext {
  font-size: 11px;
  color: #687e72;
  display: flex;
  align-items: center;
  gap: 4px;
}
.ratio-stat-card.fresh .ratio-stat-subtext i {
  font-size: 6px;
  color: #1b633e;
}
.ratio-stat-card.dried .ratio-stat-subtext i {
  font-size: 6px;
  color: #b45309;
}

/* Calculation & formula card */
.ratio-calc-card {
  background: linear-gradient(135deg, #f7fbf9 0%, #edf7f2 100%);
  border: 1.5px solid #cfe5d9;
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.ratio-calc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.ratio-calc-tag {
  font-size: 12px;
  font-weight: 750;
  color: #245740;
  display: inline-flex;
  align-items: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ratio-calc-result-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1.5px solid #2d6b50;
  border-radius: 999px;
  padding: 3px 10px 3px 8px;
  box-shadow: 0 1px 3px rgba(45, 107, 80, 0.12);
}
.ratio-calc-pct {
  font-size: 14px;
  font-weight: 800;
  color: #2d6b50;
  font-variant-numeric: tabular-nums;
}
.ratio-calc-name {
  font-size: 10.5px;
  font-weight: 600;
  color: #557262;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ratio-formula-container {
  background: #ffffff;
  border: 1px solid #d5e6dc;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
  text-align: center;
}
.ratio-formula-line {
  font-size: 14px;
  color: #173827;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.ratio-meter-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ratio-meter-track {
  height: 8px;
  background: #e2ede7;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.ratio-meter-fill {
  height: 100%;
  background: linear-gradient(90deg, #3aa374 0%, #1e5c3e 100%);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.ratio-meter-legend {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10.5px;
  color: #63786d;
  font-weight: 500;
}

/* Info Callout */
.ratio-info-callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #fbfdfc;
  border: 1px solid #e2ece6;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 18px;
}
.ratio-info-icon {
  font-size: 15px;
  color: #4a7a63;
  margin-top: 1px;
  flex-shrink: 0;
}
.ratio-info-text {
  font-size: 11.5px;
  color: #4b5d53;
  line-height: 1.45;
}

.ratio-close-btn {
  height: 42px;
  font-size: 13.5px;
}

@media (max-width: 575.98px) {
  .ratio-modal-box {
    padding: 20px 18px !important;
  }
  .ratio-stats-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .ratio-formula-line {
    font-size: 12.5px;
  }
}
@media (max-width: 420px) {
  .forecast-metrics-grid { grid-template-columns: 1fr; }
  .forecast-metric-label { min-height: 0; }
}

/* ===== ANALYTICS PAGE ===== */
.admin-analytics-heading { display: flex; align-items: center; justify-content: flex-start; text-align: left; width: 100%; margin-bottom: 18px; }
.admin-analytics-heading .page-title { margin-bottom: 0; font-weight: 750; letter-spacing: -0.02em; text-align: left !important; }
.admin-analytics-live-badge { display: none; }
.admin-analytics-desc { display: none; }

.admin-analytics-filters { display: flex; flex-direction: column; align-items: stretch; gap: 14px; padding: 14px 16px 16px; border-radius: 16px; border: 1px solid #e5e9e7; background: #ffffff; box-shadow: 0 6px 18px rgba(18, 55, 42, .07) !important; margin-bottom: 0; }
.admin-analytics-tabs-header { display: none; }
.admin-analytics-section-label { color: #334155; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; display: flex; align-items: center; }
.admin-analytics-filters .ana-tabs-slot { width: 100%; min-width: 0; }
.admin-analytics-filters .ana-view-tabs { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); width: 100%; max-width: none; margin: 0; border-radius: 999px; background: #ffffff; border: 1px solid #e4e8e6; padding: 4px; gap: 0; }
.admin-analytics-filters .ana-view-tabs .ana-tab { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; min-height: 52px; border-radius: 999px; font-size: 13px; font-weight: 500; color: #27352f; padding: 7px 12px; transition: all .18s ease; gap: 4px; text-decoration: none; }
.admin-analytics-filters .ana-view-tabs .ana-tab:hover { background: #f2f6f3; color: #1e4d3a; }
.admin-analytics-filters .ana-view-tabs .ana-tab.active { background: #1e5943 !important; color: #ffffff !important; box-shadow: 0 3px 9px rgba(30, 77, 58, .22); }
.admin-analytics-filters .ana-view-tabs .ana-tab i { font-size: 16px; }

.admin-analytics-filter-heading { display: none; }
.admin-analytics-filter-hint { display: none; }
.admin-analytics-current-view { display: none; }

.admin-analytics-filters .ana-filter-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; height: auto; width: 100%; padding: 14px 0 0; margin: 0; border: 0; border-top: 1px solid #edf0ee; border-radius: 0; background: transparent; }
.admin-analytics-filters .ana-period-wrap,
.admin-analytics-filters .ana-year-dropdown,
.admin-analytics-filters .analytics-range { border: 1px solid #d8dfdb; border-radius: 10px; background: #fff; transition: border-color .15s ease, box-shadow .15s ease; }
.admin-analytics-filters .ana-period-wrap:hover,
.admin-analytics-filters .ana-year-dropdown:hover,
.admin-analytics-filters .analytics-range:hover { border-color: #94a3b8; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04); }
.admin-analytics-filters .ana-period-toggle,
.admin-analytics-filters .ana-year-toggle,
.admin-analytics-filters .analytics-range-toggle { min-height: 46px; border-radius: 10px; font-size: 13px; font-weight: 500; color: #245a45; }
.admin-analytics-filters .ana-period-wrap { min-width: 200px; }
.admin-analytics-filters .ana-year-dropdown { min-width: 155px; }
.admin-analytics-filters .ana-year-toggle { width: 100%; display: inline-flex; align-items: center; gap: 12px; padding-left: 16px; text-align: left; }
.admin-analytics-filters .ana-year-toggle i { font-size: 15px; }
.admin-analytics-filters .analytics-range-toggle { min-width: 200px; }
.admin-analytics-filters .analytics-export-dropdown { margin-left: auto; }
.admin-analytics-filters .analytics-export-dropdown .rep-export-btn { min-height: 46px; padding: 8px 18px; border-radius: 10px; background: #ffffff; color: #245a45; font-weight: 500; font-size: 13px; border: 1px solid #d8dfdb; box-shadow: none; transition: all .18s ease; display: inline-flex; align-items: center; gap: 10px; }
.admin-analytics-filters .analytics-export-dropdown .rep-export-btn:hover { background: #f3f7f4; color: #1e4d3a; border-color: #9fb7aa; box-shadow: 0 3px 9px rgba(30, 77, 58, .08); transform: translateY(-1px); }

.admin-analytics-participation-intro { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 18px 0 20px; }
.admin-analytics-participation-intro.is-analytics-overview { position: relative; overflow: hidden; margin: 0 0 16px; padding: 12px 16px; border: 1px solid #d8e8e0; border-radius: 16px; background: linear-gradient(115deg, #f4fbf7 0%, #fff 62%, #f7fbf9 100%); box-shadow: 0 8px 22px rgba(30, 77, 58, .055); }
.admin-analytics-summary-grid,
.analytics-main-charts-row { --bs-gutter-y: 0; row-gap: 16px; }
.admin-analytics-summary-grid { margin-bottom: 16px !important; }
.admin-analytics-participation-intro.is-analytics-overview::after { content: ''; position: absolute; top: -42px; right: 12%; width: 150px; height: 150px; border-radius: 50%; background: radial-gradient(circle, rgba(52, 168, 116, .09), rgba(52, 168, 116, 0) 70%); pointer-events: none; }
.admin-analytics-participation-intro.is-analytics-overview .admin-analytics-intro-icon { width: 44px; height: 44px; border-radius: 12px; background: #e5f6ed; border-color: #aee2c8; box-shadow: inset 0 0 0 4px rgba(255,255,255,.38); }
.admin-analytics-intro-eyebrow { margin-bottom: 3px; color: #28805e; font-size: 9.5px; font-weight: 850; letter-spacing: .1em; line-height: 1.2; text-transform: uppercase; }
.admin-analytics-participation-intro.is-analytics-overview h2 { font-size: 20px; font-weight: 720; }
.admin-analytics-intro-context { position: relative; z-index: 1; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.admin-analytics-intro-context span { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border: 1px solid #d5e7de; border-radius: 999px; color: #315e4c; background: rgba(255,255,255,.88); font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.admin-analytics-intro-context i { color: #24936a; }
.admin-analytics-intro-icon { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, #e8f5ee 0%, #d1fae5 100%); color: #1e4d3a; border: 1px solid #a7f3d0; display: grid; place-items: center; font-size: 20px; flex-shrink: 0; box-shadow: 0 2px 6px rgba(30, 77, 58, 0.08); }
.admin-analytics-participation-intro h2 { margin: 0 0 3px; color: #0f172a; font-size: 20px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.25; }
.admin-analytics-participation-intro p { margin: 0; color: #64748b; font-size: 13.5px; line-height: 1.4; }
.admin-analytics-badge-pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 6px 14px; background: #ffffff; color: #1e4d3a; font-size: 12px; font-weight: 650; border: 1px solid #d1dfd7; flex-shrink: 0; box-shadow: 0 1px 3px rgba(30, 77, 58, 0.05); }
.admin-analytics-badge-pill i { color: #1e4d3a; font-size: 12px; }

.admin-analytics-summary-card { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; min-height: 142px; padding: 22px 24px; border: 1px solid var(--card-border, #8fc4a8); border-radius: 16px; background: #ffffff; box-shadow: 0 7px 18px rgba(30, 77, 58, .07) !important; transition: transform .22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow .22s cubic-bezier(0.16, 1, 0.3, 1); }
.admin-analytics-summary-card::before,
.admin-analytics-summary-card::after { display: none; }
.admin-analytics-summary-card:hover { transform: translateY(-3px); box-shadow: 0 12px 26px rgba(30, 77, 58, .11) !important; }

.admin-analytics-summary-card.card-theme-emerald { --card-border: #8fc4a8; }
.admin-analytics-summary-card.card-theme-slate   { --card-border: #b3bdc9; }
.admin-analytics-summary-card.card-theme-forest  { --card-border: #8fc4a8; }
.admin-analytics-summary-card.card-theme-blue    { --card-border: #a5a1e0; }
.admin-analytics-summary-card.card-theme-teal    { --card-border: #80c9c0; }
.admin-analytics-summary-card.card-theme-indigo  { --card-border: #aaa5e8; }
.admin-analytics-summary-card.card-theme-green   { --card-border: #8fc4a8; }
.admin-analytics-summary-card.card-theme-amber   { --card-border: #d9c07a; }

.admin-analytics-card-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; }
.admin-analytics-summary-copy { min-width: 0; }
.admin-analytics-summary-label { color: #66707c; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .035em; line-height: 1.35; }
.admin-analytics-proj-layout { width: 100%; }
.admin-analytics-proj-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.admin-analytics-proj-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; column-gap: 24px; margin-top: 9px; padding-right: 4px; }
.admin-analytics-proj-metric { min-width: 0; }
.admin-analytics-proj-metric-label { display: flex; align-items: center; gap: 3px; color: #5b6570; font-size: 10px; font-weight: 650; line-height: 1.2; text-transform: uppercase; letter-spacing: .04em; }
.admin-analytics-proj-metric strong { display: block; margin-top: 3px; color: #171717; font-size: 18px; font-weight: 700; line-height: 1.2; white-space: nowrap; }
.admin-analytics-proj-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.admin-analytics-proj-dot.is-fresh { background: #1e4d3a; }
.admin-analytics-proj-dot.is-dried { background: #7c3aed; }
@media (min-width: 992px) {
  .admin-analytics-summary-card { height: 142px !important; min-height: 142px; }
  .admin-analytics-proj-header .admin-analytics-summary-icon { position: absolute; top: 22px; right: 24px; }
  .admin-analytics-proj-header { padding-right: 58px; }
  .admin-analytics-proj-metrics { margin-top: 6px; column-gap: 24px; }
}
.admin-analytics-summary-icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; flex-shrink: 0; border: 0; transition: transform .2s ease; }
.admin-analytics-summary-card:hover .admin-analytics-summary-icon { transform: scale(1.08); }
.admin-analytics-summary-icon.icon-theme-emerald { background: #ecfdf5; color: #059669; border-color: #d1fae5; }
.admin-analytics-summary-icon.icon-theme-slate   { background: #f8fafc; color: #475569; border-color: #e2e8f0; }
.admin-analytics-summary-icon.icon-theme-forest  { background: #f0fdf4; color: #16a34a; border-color: #dcfce7; }
.admin-analytics-summary-icon.icon-theme-blue    { background: #eff6ff; color: #2563eb; border-color: #dbeafe; }
.admin-analytics-summary-icon.icon-theme-teal    { background: #f0fdfa; color: #0d9488; border-color: #ccfbf1; }
.admin-analytics-summary-icon.icon-theme-indigo  { background: #eef2ff; color: #4f46e5; border-color: #e0e7ff; }
.admin-analytics-summary-icon.icon-theme-green   { background: #ecfdf5; color: #15803d; border-color: #dcfce7; }
.admin-analytics-summary-icon.icon-theme-amber   { background: #fffbeb; color: #d97706; border-color: #fef3c7; }

.admin-analytics-summary-value { color: #171717; font-size: 25px; line-height: 1.15; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; margin: 6px 0 0; overflow-wrap: anywhere; }
.admin-analytics-progress-track { height: 8px; background: #f1f5f9; border-radius: 999px; overflow: hidden; margin-top: 10px; width: 100%; border: 1px solid #e2e8f0; padding: 1px; }
.admin-analytics-progress-bar { height: 100%; background: linear-gradient(90deg, #0d9488 0%, #14b8a6 100%); border-radius: 999px; box-shadow: 0 1px 3px rgba(13, 148, 136, 0.35); transition: width .5s cubic-bezier(0.16, 1, 0.3, 1); }
.admin-analytics-tag-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.admin-analytics-tag { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; line-height: 1.35; display: inline-flex; align-items: center; gap: 4px; }
.admin-analytics-tag.tag-pending  { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.admin-analytics-tag.tag-rejected { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.admin-analytics-tag.tag-verified { background: #ecfdf5; color: #166534; border: 1px solid #bbf7d0; box-shadow: 0 1px 2px rgba(22, 101, 52, 0.05); }
.admin-analytics-subtext { font-size: 11.5px; color: #64748b; margin-top: 12px; display: flex; align-items: center; gap: 6px; font-weight: 500; }
.admin-analytics-subtext .subtext-dot { width: 5px; height: 5px; border-radius: 50%; background: #10b981; display: inline-block; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15); }

/* Resource summaries carry two forecast periods and need more room than the
   compact cards used by the other analytics views. Keep this treatment scoped
   so short production, sales, and membership cards remain compact. */
.admin-analytics-summary-grid.is-resource-summary-grid {
  grid-auto-rows: auto;
  align-items: stretch;
}
.admin-analytics-summary-grid.is-resource-summary-grid > [class*="col-"] {
  display: flex;
}
.is-resource-summary-grid .admin-analytics-summary-card.is-resource-summary-card {
  flex: 1 1 auto;
  height: auto !important;
  min-height: 178px;
  justify-content: flex-start;
  padding: 20px;
}
.is-resource-summary-grid .admin-analytics-card-top {
  align-items: flex-start;
}
.is-resource-summary-grid .admin-analytics-summary-copy {
  padding-right: 8px;
}
.is-resource-summary-grid .admin-analytics-summary-label {
  min-height: 32px;
  color: #5f6b78;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.4;
}
.is-resource-summary-grid .admin-analytics-summary-value {
  margin-top: 7px;
  font-size: 27px;
  line-height: 1.08;
}
.is-resource-summary-grid .admin-analytics-summary-icon {
  width: 44px;
  height: 44px;
  font-size: 19px;
}
.is-resource-summary-grid .admin-analytics-subtext {
  align-items: flex-start;
  gap: 7px;
  margin-top: 12px;
  font-size: 11px;
  line-height: 1.45;
}
.is-resource-summary-grid .admin-analytics-subtext.mt-1 {
  margin-top: 7px !important;
}
.is-resource-summary-grid .admin-analytics-subtext .subtext-dot,
.is-resource-summary-grid .admin-analytics-subtext > i {
  margin-top: .42em;
}
.is-resource-summary-grid .admin-analytics-subtext > i {
  flex: 0 0 auto;
  margin-right: 0 !important;
  color: #58708b;
}
.is-resource-summary-grid .admin-analytics-forecast-copy {
  min-width: 0;
  overflow-wrap: anywhere;
}
.is-resource-summary-grid .is-additional-forecast {
  color: #5d6f87;
}

@media (max-width: 576px) {
  .admin-analytics-summary-grid.is-resource-summary-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  .is-resource-summary-grid .admin-analytics-summary-card.is-resource-summary-card {
    min-height: 0 !important;
    padding: 16px !important;
  }
  .is-resource-summary-grid .admin-analytics-summary-label {
    min-height: 0;
    padding-right: 4px;
  }
  .is-resource-summary-grid .admin-analytics-summary-value {
    font-size: 24px !important;
  }
}

/* Farmer analytics: compact, role-specific summaries above the charts. */
.farmer-analytics-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.farmer-analytics-kpi {
  --kpi-border: #8fc4a8;
  min-width: 0;
  min-height: 126px;
  padding: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--kpi-border);
  border-radius: 16px;
  box-shadow: 0 6px 16px rgba(30, 77, 58, .06);
  transition: transform .18s ease, box-shadow .18s ease;
}
.farmer-analytics-kpi:hover { transform: translateY(-2px); box-shadow: 0 10px 22px rgba(30, 77, 58, .1); }
.farmer-analytics-kpi.card-theme-green { --kpi-border: #8fc4a8; }
.farmer-analytics-kpi.card-theme-blue { --kpi-border: #9bbce1; }
.farmer-analytics-kpi.card-theme-indigo { --kpi-border: #aaa5e8; }
.farmer-analytics-kpi.card-theme-amber { --kpi-border: #d9c07a; }
.farmer-analytics-kpi-copy { min-width: 0; }
.farmer-analytics-kpi-label { color: #66707c; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .045em; line-height: 1.35; }
.farmer-analytics-kpi-value { margin-top: 7px; color: #171717; font-size: clamp(20px, 1.8vw, 27px); font-weight: 750; line-height: 1.15; letter-spacing: -.025em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.farmer-analytics-kpi-value span { margin-left: 5px; color: #64748b; font-size: 12px; font-weight: 650; letter-spacing: 0; }
.farmer-analytics-kpi-period { margin-top: 9px; color: #7b8490; font-size: 11.5px; }
.farmer-analytics-kpi-icon { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; font-size: 18px; }
.farmer-analytics-kpi-icon.icon-theme-green { background: #ecfdf5; color: #15803d; }
.farmer-analytics-kpi-icon.icon-theme-blue { background: #eff6ff; color: #2563eb; }
.farmer-analytics-kpi-icon.icon-theme-indigo { background: #eef2ff; color: #4f46e5; }
.farmer-analytics-kpi-icon.icon-theme-amber { background: #fffbeb; color: #d97706; }
.farmer-analytics-doughnut { position: relative; }
.farmer-analytics-doughnut-total { position: absolute; inset: 50% auto auto 50%; width: 54%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; text-align: center; pointer-events: none; }
.farmer-analytics-doughnut-total strong { color: #1e293b; font-size: clamp(17px, 1.45vw, 23px); line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.farmer-analytics-doughnut-total span { margin-top: 4px; color: #7b8490; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.pie-legend .pie-legend-item strong { margin-left: auto; color: #475569; font-size: 12px; font-variant-numeric: tabular-nums; }

@media (max-width: 991px) {
  .farmer-analytics-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 576px) {
  .farmer-analytics-kpis { gap: 10px; }
  .farmer-analytics-kpi { min-height: 108px; padding: 14px; }
  .farmer-analytics-kpi-icon { width: 34px; height: 34px; font-size: 15px; }
  .farmer-analytics-kpi-value { font-size: 20px; }
}

.admin-analytics-ranking-card { padding: 24px; border-radius: 18px; border: 1px solid #e2e8f0; background: #ffffff; box-shadow: 0 4px 20px rgba(18, 55, 42, .04) !important; margin-bottom: 24px; }
.admin-analytics-ranking-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-analytics-trophy-icon { width: 46px; height: 46px; border-radius: 14px; background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); color: #b45309; display: grid; place-items: center; font-size: 22px; flex-shrink: 0; border: 1px solid #fcd34d; box-shadow: 0 3px 10px rgba(217, 119, 6, .18); }
.admin-analytics-ranking-heading h2 { margin: 0 0 3px; font-size: 19px; font-weight: 750; color: #0f172a; letter-spacing: -0.015em; }
.admin-analytics-ranking-heading p { margin: 0; font-size: 13px; color: #64748b; }

.admin-analytics-ranking-table { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.admin-analytics-ranking-table thead th { background: #f8fafc; font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; color: #475569; padding: 13px 18px; border-bottom: 2px solid #e2e8f0; }
.admin-analytics-ranking-table thead th:first-child { border-top-left-radius: 12px; }
.admin-analytics-ranking-table thead th:last-child  { border-top-right-radius: 12px; }
.admin-analytics-ranking-table tbody tr { transition: all .16s ease; }
.admin-analytics-ranking-table tbody tr:hover { background: #f0fdf4 !important; }
.admin-analytics-ranking-table tbody tr.rank-row-1 { background: linear-gradient(90deg, rgba(254, 252, 232, 0.7) 0%, rgba(255, 255, 255, 0.4) 100%); }
.admin-analytics-ranking-table tbody tr.rank-row-1:hover { background: #fef9c3 !important; }
.admin-analytics-ranking-table tbody tr.rank-row-2 { background: linear-gradient(90deg, rgba(248, 250, 252, 0.9) 0%, rgba(255, 255, 255, 0.4) 100%); }
.admin-analytics-ranking-table tbody tr.rank-row-2:hover { background: #f1f5f9 !important; }
.admin-analytics-ranking-table tbody tr.rank-row-3 { background: linear-gradient(90deg, rgba(255, 247, 237, 0.7) 0%, rgba(255, 255, 255, 0.4) 100%); }
.admin-analytics-ranking-table tbody tr.rank-row-3:hover { background: #ffedd5 !important; }
.admin-analytics-ranking-table td { padding: 14px 18px; vertical-align: middle; border-bottom: 1px solid #eef2ef; font-size: 13.5px; }

.admin-analytics-rank { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 10px; font-size: 13px; font-weight: 800; transition: transform .15s ease; }
.admin-analytics-ranking-table tbody tr:hover .admin-analytics-rank { transform: scale(1.06); }
.admin-analytics-rank.rank-1 { background: linear-gradient(135deg, #fef08a, #facc15); color: #713f12; border: 1px solid #eab308; box-shadow: 0 2px 8px rgba(234, 179, 8, .35); }
.admin-analytics-rank.rank-2 { background: linear-gradient(135deg, #ffffff, #cbd5e1); color: #1e293b; border: 1px solid #94a3b8; box-shadow: 0 2px 6px rgba(148, 163, 184, .3); }
.admin-analytics-rank.rank-3 { background: linear-gradient(135deg, #ffedd5, #fb923c); color: #7c2d12; border: 1px solid #f97316; box-shadow: 0 2px 6px rgba(249, 115, 22, .3); }
.admin-analytics-rank.rank-other { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; font-weight: 700; }
.admin-analytics-rank .rank-medal-icon { font-size: 11px; margin-right: 3px; }

.admin-analytics-avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 750; border: 2px solid #ffffff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08); flex-shrink: 0; }
.admin-analytics-member-name { font-weight: 700; color: #0f172a; font-size: 14px; line-height: 1.25; }
.admin-analytics-member-sub { margin-top: 3px; }
.admin-analytics-member-sub .role-tag { font-size: 10.5px; font-weight: 600; color: #166534; background: #dcfce7; padding: 2px 7px; border-radius: 5px; border: 1px solid #bbf7d0; }

.admin-analytics-stat-pill { display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 999px; background: #f8fafc; border: 1px solid #e2e8f0; font-size: 13px; color: #334155; font-variant-numeric: tabular-nums; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03); }
.admin-analytics-points-pill { display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 999px; background: #fffbeb; border: 1px solid #fde68a; font-size: 13px; color: #92400e; font-weight: 750; font-variant-numeric: tabular-nums; box-shadow: 0 1px 3px rgba(217, 119, 6, 0.08); }
.admin-analytics-points-pill .pts-suffix { font-size: 11px; font-weight: 600; color: #b45309; margin-left: 3px; opacity: .9; }
.admin-analytics-kg-pill { display: inline-flex; align-items: center; padding: 5px 12px; border-radius: 999px; font-size: 13px; font-variant-numeric: tabular-nums; }
.admin-analytics-kg-pill.active { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; font-weight: 650; box-shadow: 0 1px 2px rgba(29, 78, 216, 0.06); }
.admin-analytics-kg-pill.zero   { background: transparent; color: #94a3b8; font-weight: 500; }

@media (max-width: 991px) {
  .admin-analytics-filters .ana-view-tabs { display: flex; overflow-x: auto; }
  .admin-analytics-filters .ana-view-tabs .ana-tab { flex: 0 0 130px; }
}
@media (max-width: 768px) {
  .admin-analytics-ranking-heading { flex-direction: column; align-items: flex-start; }
}
.admin-analytics-summary-grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 14px !important;
  margin-top: 14px !important;
  margin-bottom: 24px !important;
}
.admin-analytics-summary-grid > [class*="col-"] {
  width: 100% !important;
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Production-only, explainable early-warning panel. */
.production-risk-panel {
  --risk-accent: #64748b;
  --risk-soft: #f8fafc;
  --risk-border: #cbd5e1;
  position: relative;
  overflow: hidden;
  margin: -8px 0 24px;
  padding: 22px;
  border: 1px solid var(--risk-border);
  border-left: 5px solid var(--risk-accent);
  border-radius: 18px;
  background: linear-gradient(120deg, var(--risk-soft) 0%, #fff 68%);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .055);
}
.production-risk-panel::after {
  content: '';
  position: absolute;
  top: -90px;
  right: -55px;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--risk-accent) 12%, transparent), transparent 68%);
  pointer-events: none;
}
.production-risk-panel.is-low { --risk-accent: #16805b; --risk-soft: #f0fdf6; --risk-border: #9fd8bf; }
.production-risk-panel.is-medium { --risk-accent: #b66a0a; --risk-soft: #fffbeb; --risk-border: #efd18e; }
.production-risk-panel.is-high { --risk-accent: #c33d3d; --risk-soft: #fff5f5; --risk-border: #efb2b2; }
.production-risk-panel.is-insufficient { --risk-accent: #64748b; --risk-soft: #f8fafc; --risk-border: #cbd5e1; }
.production-risk-header,
.production-risk-heading,
.production-risk-action > span,
.production-risk-method { display: flex; align-items: center; }
.production-risk-header { position: relative; z-index: 1; justify-content: space-between; gap: 20px; }
.production-risk-heading { align-items: flex-start; gap: 14px; min-width: 0; }
.production-risk-icon { display: grid; place-items: center; flex: 0 0 auto; width: 46px; height: 46px; border-radius: 14px; color: var(--risk-accent); background: color-mix(in srgb, var(--risk-accent) 10%, white); border: 1px solid color-mix(in srgb, var(--risk-accent) 24%, white); font-size: 20px; }
.production-risk-eyebrow { margin-bottom: 3px; color: var(--risk-accent); font-size: 10px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.production-risk-heading h2 { margin: 0; color: #17211c; font-size: 19px; font-weight: 760; letter-spacing: -.015em; }
.production-risk-heading p { max-width: 760px; margin: 5px 0 0; color: #59666f; font-size: 13px; line-height: 1.5; }
.production-risk-badge { flex: 0 0 auto; padding: 7px 13px; border: 1px solid color-mix(in srgb, var(--risk-accent) 34%, white); border-radius: 999px; color: var(--risk-accent); background: color-mix(in srgb, var(--risk-accent) 9%, white); font-size: 11px; font-weight: 850; letter-spacing: .045em; text-transform: uppercase; }
.production-risk-body { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr); gap: 18px; margin-top: 18px; }
.production-risk-metric-group { min-width: 0; }
.production-risk-metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); overflow: hidden; border: 1px solid color-mix(in srgb, var(--risk-accent) 20%, #e2e8f0); border-radius: 13px; background: rgba(255,255,255,.82); }
.production-risk-metric { grid-column: span 2; min-width: 0; padding: 15px 16px; }
.production-risk-metric:nth-child(1),
.production-risk-metric:nth-child(2),
.production-risk-metric:nth-child(4) { border-right: 1px solid color-mix(in srgb, var(--risk-accent) 16%, #e2e8f0); }
.production-risk-metric:nth-child(4),
.production-risk-metric:nth-child(5) { grid-column: span 3; border-top: 1px solid color-mix(in srgb, var(--risk-accent) 16%, #e2e8f0); }
.production-risk-metric span { display: block; color: #69757d; font-size: 10px; font-weight: 750; letter-spacing: .035em; line-height: 1.35; text-transform: uppercase; }
.production-risk-metric strong { display: block; margin-top: 5px; color: var(--risk-accent); font-size: 19px; font-weight: 780; font-variant-numeric: tabular-nums; }
.production-risk-metric small { display: block; margin-top: 5px; color: #69757d; font-size: 9.5px; line-height: 1.4; }
.production-risk-decrease-counts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 5px; }
.production-risk-decrease-counts strong { margin: 0; font-size: 16px; }
.production-risk-decrease-counts em { display: block; margin-bottom: 1px; color: #69757d; font-size: 9px; font-style: normal; font-weight: 750; letter-spacing: .035em; text-transform: uppercase; }
.production-risk-estimate-note { margin: 7px 2px 0; color: #69757d; font-size: 10px; line-height: 1.4; }
.production-risk-evidence { padding: 13px 15px; border: 1px solid color-mix(in srgb, var(--risk-accent) 17%, #e2e8f0); border-radius: 13px; background: rgba(255,255,255,.72); }
.production-risk-evidence h3 { margin: 0 0 7px; color: #34433b; font-size: 11px; font-weight: 780; text-transform: uppercase; letter-spacing: .04em; }
.production-risk-evidence ul { margin: 0; padding-left: 18px; color: #59666f; font-size: 12px; line-height: 1.45; }
.production-risk-evidence li + li { margin-top: 3px; }
.production-risk-evidence p { margin: 0; color: #64748b; font-size: 12px; line-height: 1.45; }
.production-risk-action { position: relative; z-index: 1; display: grid; grid-template-columns: 165px minmax(0, 1fr); gap: 14px; align-items: start; margin-top: 14px; padding: 12px 14px; border-radius: 12px; color: #31423a; background: rgba(255,255,255,.78); border: 1px solid color-mix(in srgb, var(--risk-accent) 16%, #e2e8f0); }
.production-risk-action > span { gap: 7px; color: var(--risk-accent); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .035em; }
.production-risk-action p { margin: 0; font-size: 12.5px; line-height: 1.48; }
.production-risk-method { position: relative; z-index: 1; gap: 7px; margin-top: 10px; color: #7a858c; font-size: 10.5px; line-height: 1.4; }
.production-risk-method i { color: var(--risk-accent); }
@media (min-width: 992px) {
  .admin-analytics-summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 16px !important;
  }
}
@media (max-width: 768px) {
  .production-risk-panel { margin-top: -4px; padding: 18px; border-radius: 16px; }
  .production-risk-header { align-items: flex-start; }
  .production-risk-body { grid-template-columns: 1fr; gap: 12px; }
  .production-risk-action { grid-template-columns: 1fr; gap: 6px; }
}
@media (max-width: 576px) {
  .production-risk-header { flex-direction: column; gap: 12px; }
  .production-risk-icon { width: 40px; height: 40px; border-radius: 12px; font-size: 18px; }
  .production-risk-heading h2 { font-size: 17px; }
  .production-risk-badge { margin-left: 54px; }
  .production-risk-metrics { grid-template-columns: 1fr; }
  .production-risk-metric,
  .production-risk-metric:nth-child(4),
  .production-risk-metric:nth-child(5) { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 14px; padding: 12px 14px; border-top: 0; border-right: 0; border-bottom: 1px solid color-mix(in srgb, var(--risk-accent) 16%, #e2e8f0); }
  .production-risk-metric:last-child { border-bottom: 0; }
  .production-risk-metric strong { margin-top: 0; font-size: 18px; }
  .production-risk-metric small { grid-column: 1 / -1; margin-top: 0; }
  .production-risk-metric-decreases { grid-template-columns: 1fr; }
  .production-risk-decrease-counts { grid-column: 1 / -1; max-width: 260px; }
  .admin-analytics-filters { padding: 12px; border-radius: 16px; }
  .admin-analytics-filters .ana-filter-bar,
  .admin-analytics-filter-bar {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100% !important;
    height: auto !important;
    gap: 10px !important;
    padding: 12px 0 0 !important;
    margin: 0 !important;
    border: none !important;
    border-top: 1px solid #edf0ee !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  .admin-analytics-filters .ana-period-wrap,
  .admin-analytics-filters .ana-year-dropdown,
  .admin-analytics-filters .analytics-range,
  .admin-analytics-filters .analytics-export-dropdown {
    width: 100% !important;
    min-width: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    position: relative !important;
  }
  .admin-analytics-filters .ana-period-toggle,
  .admin-analytics-filters .ana-year-toggle,
  .admin-analytics-filters .analytics-range-toggle,
  .admin-analytics-filters .analytics-export-dropdown .rep-export-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    width: 100% !important;
    height: 42px !important;
    min-height: 42px !important;
    border: 1px solid #d1d5db !important;
    border-radius: 8px !important;
    background: #ffffff !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
    color: #1e4d3a !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-align: center !important;
    padding: 0 10px !important;
    box-sizing: border-box !important;
    cursor: pointer !important;
  }
  .admin-analytics-filters .ana-period-wrap .ana-period-icon {
    position: absolute !important;
    left: 10px !important;
    font-size: 13px !important;
    color: #1e4d3a !important;
    pointer-events: none !important;
  }
  .admin-analytics-filters .ana-period-wrap::after {
    position: absolute !important;
    right: 10px !important;
  }
  .admin-analytics-filters .ana-period-toggle {
    padding-left: 28px !important;
    padding-right: 22px !important;
    justify-content: flex-start !important;
  }
  .admin-analytics-filters .ana-year-toggle {
    justify-content: center !important;
  }
  .admin-analytics-filters .ana-year-toggle i {
    display: inline-block !important;
    font-size: 13px !important;
    color: #1e4d3a !important;
    margin-right: 4px !important;
  }
  .admin-analytics-filters .ana-year-toggle::after {
    display: inline-block !important;
    margin-left: 6px !important;
    vertical-align: middle !important;
    content: "" !important;
    border-top: .3em solid currentColor !important;
    border-right: .3em solid transparent !important;
    border-bottom: 0 !important;
    border-left: .3em solid transparent !important;
  }
  .admin-analytics-filters .analytics-range-toggle {
    justify-content: space-between !important;
    padding: 0 10px !important;
  }
  .admin-analytics-filters .analytics-range-toggle span {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    flex: 1 1 auto !important;
    text-align: center !important;
  }
  .admin-analytics-filters .analytics-export-dropdown .rep-export-btn {
    justify-content: center !important;
    padding: 0 10px !important;
  }
  .admin-analytics-filters .analytics-export-dropdown .rep-export-btn i {
    font-size: 13px !important;
  }
  .admin-analytics-filters .analytics-export-dropdown .rep-export-btn span {
    flex: 0 1 auto !important;
    overflow: hidden !important;
    text-align: center !important;
    text-overflow: ellipsis !important;
  }
  .admin-analytics-filter-heading { align-items: flex-start; }
  .admin-analytics-current-view { display: none; }
  .admin-analytics-participation-intro { align-items: flex-start; }
  .admin-analytics-participation-intro.is-analytics-overview { width: 100%; min-width: 0; flex-direction: column; margin: 0 0 16px; padding: 12px; }
  .admin-analytics-participation-intro.is-analytics-overview > .d-flex { width: 100%; min-width: 0; align-items: flex-start !important; }
  .admin-analytics-participation-intro.is-analytics-overview > .d-flex > div:last-child { min-width: 0; }
  .admin-analytics-participation-intro.is-analytics-overview h2,
  .admin-analytics-participation-intro.is-analytics-overview p { overflow-wrap: anywhere; }
  .admin-analytics-intro-context { width: 100%; min-width: 0; justify-content: flex-start; }
  .admin-analytics-intro-context span { max-width: 100%; white-space: normal; }
  .admin-analytics-ranking-card { padding: 16px; }
  .admin-analytics-summary-card { min-height: 112px; padding: 14px; }
  .admin-analytics-summary-icon { width: 32px; height: 32px; font-size: 14px; }
  .admin-analytics-summary-value { font-size: clamp(17px, 4.8vw, 21px); }
  .admin-analytics-proj-metrics { column-gap: 8px; margin-top: 6px; }
  .admin-analytics-proj-metric strong { font-size: 14px; }
}
.page-analytics .amfe-card { box-shadow: none; }

/* One continuous pill (segmented-control style): icon above label, active
   segment filled, thin dividers between the inactive ones. Content-sized
   (inline-flex) and left-aligned on desktop/tablet, where there's room
   to spare; the phone override below stretches it edge-to-edge instead. */
.ana-tabs {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 12px;
}

/* Filter bar — same segmented-pill language as .ana-tabs: one continuous
   rounded strip instead of 4 separate bordered pills. Content-sized like
   .ana-tabs so the two can share one row instead of each spanning full
   width (which forced them onto separate stacked rows). */
.ana-filter-bar {
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 16px;
}

/* Holds the tabs + filter bar as one card. The whole card stays in the
   normal document flow and scrolls away with the rest of the page.
   Stacked below 768px — phones and the narrow phone-landscape/small-
   tablet range, where the sidebar is already off-canvas but there still
   isn't quite room for 4 tabs + the full filter bar on one line even at
   their most compact. 768px (iPad portrait) and up gets the side-by-side
   row, just at a smaller size than the full desktop one until 1260px. */
.ana-sticky-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  /* One shared backdrop card around the tabs + filter bar pair, instead
     of two pills floating separately on the page — matches Members'
     filter row, where the search box and controls beside it read as one
     connected unit rather than two disconnected pieces. */
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}
.ana-sticky-group .ana-tabs,
.ana-sticky-group .ana-tabs-slot,
.ana-sticky-group .ana-filter-bar { margin-bottom: 0; }
@media (min-width: 768px) {
  .ana-sticky-group {
    flex-direction: row;
    align-items: center;
    /* Same positioning as the desktop tier below — filter bar pushed to
       the far right, tabs left — so the layout reads the same way at
       every size from here up, not just once you hit 1260px. */
    justify-content: space-between;
  }
  /* Equal, explicit height at the compact tablet size too — same reason
     as the desktop override below, just a smaller shared number. */
  .ana-tabs,
  .ana-filter-bar {
    height: 46px;
  }
}
/* 1260px, not 992 — at exactly 992 the sidebar has just come back
   (main-content loses its margin-left:0 override right at 991.98px),
   so content width is at its narrowest just as the desktop-sized
   version below tries to fit both groups on one row; empirically both
   need ~1240px of content width at that size. Below this breakpoint the
   576px tier above already has them in a row, just more compact. */
@media (min-width: 1260px) {
  .ana-sticky-group {
    gap: 0;
    /* Filter bar pushed to the far right — its edge lines up with the
       notification bell above it (both sit against .main-content's
       right edge) instead of leaving that side of the row empty.
       max-width caps how far space-between can stretch that gap: with
       just 2 items, space-between dumps 100% of the row's leftover
       width into the one gap between them — fine up to a big laptop
       screen, but a multi-thousand-pixel gap on an ultrawide/4K
       monitor is exactly the kind of thing that reads as broken. */
    justify-content: space-between;
    width: 100%;
  }
  /* Explicit, equal height — the two pills' own content (icon-over-label
     vs a single text line) never quite settles on the same height from
     padding alone, so fix it directly instead of chasing it via padding. */
  .ana-tabs,
  .ana-filter-bar {
    height: 58px;
  }
}
/* Keeps the tabs pill and its mobile overflow cue grouped together. */
.ana-tabs-slot {
  display: flex;
}
.ana-tabs-scroll-cue { display: none; }
.ana-filter-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
}
.ana-tab {
  position: relative;
  flex: 0 0 auto;
  width: 72px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 6px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-dark);
  transition: all 0.15s;
  font-family: 'DM Sans', sans-serif;
  text-decoration: none;
  white-space: nowrap;
}
.ana-tab i { font-size: 13px; }
@media (min-width: 1260px) {
  .ana-tab {
    width: 128px;
    gap: 3px;
    padding: 6px 12px;
    font-size: 13px;
  }
  .ana-tab i { font-size: 16px; }
}
.ana-tab.active { background: var(--primary); color: #fff; }
.ana-tab:hover:not(.active) { color: var(--primary); }
.ana-tab:not(.active):not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0; top: 25%; bottom: 25%;
  width: 1px;
  background: var(--border);
}
.ana-tab:has(+ .ana-tab.active)::after { display: none; }

/* flex-shrink:0 — the select's intrinsic width is its longest option
   ("Monthly View"), but as a flex item it would shrink below that and clip
   the label. Most visible under (pointer: coarse), where responsive.css
   forces font-size:16px on .ana-period to stop iOS zooming the page on
   focus: the text grows, the box doesn't, and the chevron eats the "w". */
.ana-period-wrap { position: relative; display: inline-flex; align-items: center; flex-shrink: 0; }
.ana-year-dropdown, .ana-chart-btn { flex-shrink: 0; }
.ana-chart-btn { white-space: nowrap; }

/* responsive.css raises .ana-period to font-size:16px under (pointer:
   coarse) so iOS doesn't zoom the page when the select takes focus. But a
   <select>'s intrinsic width comes from its <option> metrics, which don't
   pick that override up — so the box stays sized for 11px text while the
   label renders at 16px, and "Monthly View" clips to "Monthly Viev".
   Pin a width that clears the longest label in either language at 16px
   ("Monthly View" / "Buwanang View") plus the 24px icon and 20px chevron
   padding. :not() because .ana-year-toggle shares this class and only ever
   holds a 4-digit year — it must stay narrow. */
@media (pointer: coarse) {
  .ana-period:not(.ana-year-toggle) { min-width: 164px; }
}

/* ── Phones, touch ──────────────────────────────────────────────────
   The 16px above is an iOS guard, not a design choice, and at phone width
   it blows the filter bar up — controls tower over the tabs and Bar gets
   pushed onto a second row. Bring the select back to the 11px this
   breakpoint already uses for everything else so the row stays compact and
   fits on one line, and drop the min-width that 16px needed.
   Trade-off: iOS Safari may zoom the page when this select takes focus,
   which the 16px rule exists to prevent. Sizing is what was asked for here;
   the zoom only affects that one browser, on focus, and is undone by
   pinch-out. */
@media (pointer: coarse) and (max-width: 576px) {
  .ana-filter-bar .ana-period {
    font-size: 11px !important;
    padding-top: 6px;
    padding-bottom: 6px;
  }
  /* Not 0: <select> intrinsic width is computed from <option> metrics and
     comes up short, so FIL's longer "Buwanang View" still clipped at 11px
     even though "Monthly View" fit. 126px clears the longer of the two
     plus the 24px icon / 20px chevron padding. */
  .ana-filter-bar .ana-period:not(.ana-year-toggle) { min-width: 126px; }
  .ana-filter-bar .ana-chart-btn { font-size: 11px; padding: 6px 9px; }
}
.ana-period-icon {
  position: absolute; left: 10px;
  font-size: 11px;
  color: var(--text-muted);
  pointer-events: none;
}
/* stroked chevron, matching the thin caret macOS draws on a popup button */
.ana-period-wrap::after {
  content: '';
  position: absolute; right: 11px; top: 50%;
  width: 6px; height: 6px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: translateY(-4px) rotate(45deg);
  pointer-events: none;
}
.ana-period-toggle {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  text-align: left;
}
.ana-period-menu {
  z-index: 1060;
  min-width: 168px;
  max-width: min(220px, calc(100vw - 24px));
  max-height: min(248px, 50vh);
  overflow-y: auto;
  margin-top: 7px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .18);
}
.ana-period-menu .dropdown-item {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dark);
  font: 500 14px/1.25 'DM Sans', sans-serif;
  white-space: nowrap;
}
.ana-period-menu .dropdown-item:hover,
.ana-period-menu .dropdown-item:focus {
  background: var(--green-light, #e8f5ed);
  color: var(--primary);
}
.ana-period-menu .dropdown-item.active {
  background: var(--primary);
  color: #fff;
}
.ana-period {
  border: none;
  border-radius: 999px;
  /* left padding reserves room for .ana-period-icon, right for the chevron above */
  padding: 6px 20px 6px 24px;
  font-size: 11px;
  line-height: 1;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  color: var(--text-dark);
  transition: background 0.15s, color 0.15s;
}
.ana-period:hover { background: rgba(0,0,0,0.035); }
.sales-filter-select { min-width: 118px; }
.analytics-range { position: relative; flex-shrink: 0; }
.analytics-range-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 150px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dark);
  font: 500 11px/1 'DM Sans', sans-serif;
  cursor: pointer;
}
.analytics-range-toggle span { flex: 1; text-align: left; white-space: nowrap; }
.analytics-range-toggle:hover,
.analytics-range-toggle.active { background: rgba(0,0,0,.035); border-color: var(--border); }
.analytics-range-panel {
  position: absolute;
  z-index: 50;
  top: calc(100% + 10px);
  right: 0;
  width: 280px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 14px 35px rgba(15, 23, 42, .16);
}
.analytics-range-panel label { display: block; color: var(--text-dark); font-size: 14px; font-weight: 600; }
.analytics-range-panel label + label { margin-top: 16px; }
.analytics-range-panel label > span:first-child { display: block; margin-bottom: 8px; }
.analytics-range-field { position: relative; display: block; }
.analytics-range-field select {
  width: 100%;
  padding: 12px 38px 12px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text-dark);
  font: 500 14px/1.2 'DM Sans', sans-serif;
  appearance: none;
  cursor: pointer;
}
.analytics-range-field select:focus { outline: 2px solid rgba(30,77,58,.18); border-color: var(--primary); }
.analytics-range-field i { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.analytics-range-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  margin-top: 18px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--primary);
  font: 600 13px/1 'DM Sans', sans-serif;
  cursor: pointer;
}
.analytics-range-reset:hover:not(:disabled) { background: rgba(30,77,58,.06); border-color: var(--primary); }
.analytics-range-reset:disabled { color: var(--text-muted); cursor: not-allowed; opacity: .55; }
.ana-year-dropdown { position: relative; display: inline-flex; align-items: center; }
/* the Rate History card clips overflow for its rounded corners, which was
   also clipping this dropdown's menu before it could reach its own scroll
   cap — let cards that contain the year dropdown clear their own overflow */
.amfe-card:has(.ana-year-dropdown) { overflow: visible; }
.ana-year-toggle {
  /* snug around the year, the way macOS sizes a popup button */
  padding: 6px 18px 6px 11px;
  position: relative;
}
/* The wrapper already draws the AMFE chevron. Suppress any Bootstrap caret
   so the trigger never displays two down arrows. */
.ana-year-toggle::after { display: none !important; }
@media (min-width: 1260px) {
  .ana-period { padding: 11px 40px 11px 44px; font-size: 13px; }
  .ana-period-icon { left: 14px; font-size: 13px; }
  .ana-period-wrap::after { right: 15px; width: 7px; height: 7px; }
  .ana-year-toggle { padding: 11px 30px 11px 19px; }
  .sales-filter-select { min-width: 154px; }
  .analytics-range-toggle { min-width: 180px; padding: 11px 16px; font-size: 13px; }
  .ana-year-dropdown::after { right: 11px; width: 7px; height: 7px; }
}
.ana-year-dropdown::after {
  content: '';
  position: absolute; right: 11px; top: 50%;
  width: 7px; height: 7px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: translateY(-4px) rotate(45deg);
  pointer-events: none;
}
/* Year menu — mimics the macOS native select popup (dark, ticked item),
   but anchored below the trigger instead of over it. */
.ana-year-dropdown .dropdown-menu {
  min-width: 0;
  width: 116px;
  margin-top: 6px;
  padding: 5px 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 11px;
  background: #58585a;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.34);
  /* the reference is the OS popup, so borrow the OS UI font (SF Pro on macOS)
     rather than the app's DM Sans — falls back to Segoe UI / Roboto elsewhere */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  /* cap the drop so a member with many years of records does not bury the chart —
     tall enough to fit ~8 items with no scroll; below that the list barely
     overflowed its own cap and the scrollbar had only a few px of travel */
  max-height: 280px;
  overflow-y: auto;
}
.ana-year-dropdown .dropdown-item {
  padding: 6px 14px;
  font-size: 14px;
  line-height: 1.5;
  color: #fff;
  text-align: left;
  position: relative;
}
.ana-year-dropdown .dropdown-item:hover,
.ana-year-dropdown .dropdown-item:focus {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.ana-year-dropdown .dropdown-item.active {
  background: transparent;
  color: #fff;
}

.ana-chart-btn {
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-dark);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
}
.ana-chart-btn.active { background: var(--primary); color: #fff; }
.ana-chart-btn:hover:not(.active) { background: rgba(0,0,0,0.035); color: var(--primary); }
@media (min-width: 1260px) {
  .ana-chart-btn { padding: 11px 22px; font-size: 13px; gap: 6px; }
}

/* Trend chart card header — title left, Line/Bar buttons right */
.ana-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.ana-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 750;
  color: #0f172a;
  letter-spacing: -0.015em;
}
.ana-card-title i {
  color: #1e4d3a;
  font-size: 17px;
}
.ana-chart-type-switch {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #f8fafc;
}
.ana-chart-type-switch .ana-chart-btn {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 0;
  background: transparent;
  color: #64748b;
  transition: all .15s ease;
  cursor: pointer;
}
.ana-chart-type-switch .ana-chart-btn:hover:not(.active) {
  color: #1e4d3a;
  background: rgba(30, 77, 58, 0.06);
}
.ana-chart-type-switch .ana-chart-btn.active {
  background: #1e4d3a !important;
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(30, 77, 58, 0.25);
}
.ana-chart-btns {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-wrap { position: relative; height: 340px; }
.analytics-resource-chart-tooltip {
  position: absolute;
  z-index: 5;
  width: max-content;
  max-width: min(320px, calc(100% - 16px));
  padding: 10px 12px;
  border-radius: 7px;
  background: rgba(31, 31, 31, 0.94);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.22);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  line-height: 1.35;
  pointer-events: auto;
}
.analytics-resource-chart-tooltip-title {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
}
.analytics-resource-chart-tooltip-values {
  display: grid;
  gap: 3px;
}
.analytics-resource-chart-tooltip-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.analytics-resource-chart-tooltip-row i {
  width: 10px;
  height: 10px;
  margin-top: 3px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  flex: 0 0 auto;
}
.analytics-resource-chart-tooltip-breakdown {
  margin-left: 16px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 11px;
}
.analytics-resource-chart-tooltip-breakdown i {
  width: 8px;
  height: 8px;
}
.analytics-resource-chart-tooltip-action {
  display: block;
  margin-top: 7px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font: inherit;
  font-weight: 700;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.analytics-resource-chart-tooltip-action:hover,
.analytics-resource-chart-tooltip-action:focus-visible {
  color: #d1fae5;
  text-decoration: underline;
  text-underline-offset: 2px;
  outline: none;
}
.analytics-trend-card { display: flex; flex-direction: column; }
.analytics-trend-content { display: flex; flex: 1; min-height: 0; flex-direction: column; }
.analytics-trend-content .chart-wrap { flex: 1; height: auto; min-height: 340px; }
.analytics-trend-content .trend-legend { flex-shrink: 0; margin-bottom: 0; }
@media (min-width: 992px) {
  .analytics-main-charts-row > [class*="col-"] { display: flex; min-height: 0; }
  .analytics-main-chart-card { width: 100%; height: 500px !important; min-height: 500px; }
  .analytics-sales-charts-row { align-items: stretch; }
  .analytics-sales-charts-row > [class*="col-"] { align-items: stretch; }
  .analytics-sales-trend-card {
    height: auto !important;
    min-height: 0;
    max-height: none;
    overflow: visible !important;
  }
  .analytics-sales-trend-card .analytics-trend-content {
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
  }
  .analytics-sales-distribution-card {
    height: 100% !important;
    min-height: 0;
    max-height: none;
    align-self: stretch;
  }
  /* Sales chart keeps its own plotting height while the card grows with its content. */
  .analytics-sales-trend-card .analytics-trend-content .chart-wrap {
    flex: 0 0 370px;
    height: 370px;
    min-height: 0;
  }
  .analytics-sales-trend-card .analytics-trend-content .chart-wrap canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
  }
  .analytics-trend-content .chart-wrap { min-height: 0; }
}

/* Pie chart wrapper — fixed height to avoid growing unbounded */
.pie-chart-wrap {
  position: relative;
  height: 220px;
  flex: 1;
  min-height: 160px;
}

.trend-legend { display: flex; gap: 20px; margin-top: 16px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid #f1f5f9; }
.trend-legend.trend-legend-with-timeline {
  border-top: none;
  padding-top: 4px;
  margin-top: 6px;
}
.legend-item  { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: #334155; }

/* Data timeline banner below chart */
.data-timeline-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 16px 10px;
  padding: 8px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}
.data-timeline-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #475569;
  flex-shrink: 0;
}
.data-timeline-icon-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #1e4d3a;
  font-size: 12px;
}
.data-timeline-items {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.data-timeline-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 12px;
  line-height: 1.4;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.data-timeline-chip-actual {
  border: 1px solid rgba(30, 77, 58, 0.28);
  color: #1e4d3a;
}
.data-timeline-chip-actual .data-timeline-dot {
  background: #1e4d3a;
  box-shadow: 0 0 0 2.5px rgba(30, 77, 58, 0.16);
}
.data-timeline-chip-missing {
  border: 1px solid #e2e8f0;
  color: #475569;
}
.data-timeline-chip-missing .data-timeline-dot {
  background: #94a3b8;
  box-shadow: 0 0 0 2.5px #f1f5f9;
}
.data-timeline-chip-forecast {
  border: 1px solid rgba(245, 158, 11, 0.38);
  color: #92400e;
}
.data-timeline-chip-forecast .data-timeline-dot {
  background: #f59e0b;
  box-shadow: 0 0 0 2.5px rgba(245, 158, 11, 0.22);
}
.data-timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.data-timeline-chip-content {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.data-timeline-chip-label {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
}
.data-timeline-chip-actual .data-timeline-chip-label {
  color: #2d5e4a;
}
.data-timeline-chip-actual .data-timeline-chip-val {
  color: #1e4d3a;
}
.data-timeline-chip-missing .data-timeline-chip-label {
  color: #64748b;
}
.data-timeline-chip-missing .data-timeline-chip-val {
  color: #475569;
}
.data-timeline-chip-forecast .data-timeline-chip-label {
  color: #b45309;
}
.data-timeline-chip-forecast .data-timeline-chip-val {
  color: #b45309;
}
.data-timeline-chip-divider {
  color: #cbd5e1;
  font-weight: 400;
}
.data-timeline-chip-val {
  font-weight: 600;
  font-size: 12px;
}
.data-timeline-arrow {
  color: #94a3b8;
  font-size: 11px;
  opacity: 0.5;
}

.sales-allocation {
  padding: 3px 7px;
  margin-bottom: 4px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  box-shadow: 0 1px 3px rgba(18, 55, 42, 0.03);
}
.sales-allocation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2px;
  color: #475569;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.analytics-sales-trend-card .sales-allocation-month-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}
.analytics-sales-trend-card .sales-allocation-month-wrap::after {
  content: '';
  position: absolute;
  right: 13px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid #64748b;
  border-bottom: 1.5px solid #64748b;
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.analytics-sales-trend-card .sales-allocation-month-wrap select {
  min-width: 124px;
  height: 36px;
  padding: 0 32px 0 12px;
  border: 1px solid #d4ded8;
  border-radius: 9px;
  background: #fff;
  background-image: none;
  color: #1e293b;
  font: 700 12px/1.25 'DM Sans', sans-serif;
  text-transform: uppercase;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
  box-shadow: none;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.analytics-sales-trend-card .sales-allocation-month-wrap select:hover { border-color: #a8c6b5; }
.analytics-sales-trend-card .sales-allocation-month-wrap select:focus {
  border-color: #6da487;
  box-shadow: 0 0 0 2px rgba(30, 77, 58, .1);
}
.sales-allocation-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}
.sales-allocation-item {
  padding: 3px 7px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}
.sales-allocation-item.sales-total   { background: #f8fafc; border-color: #e2e8f0; }
.sales-allocation-item.sales-sharing { background: #fffbeb; border-color: #fde68a; }
.sales-allocation-item.sales-income  { background: #eff6ff; border-color: #bfdbfe; }
.sales-allocation-item span {
  display: block;
  margin-bottom: 1px;
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.sales-allocation-item strong {
  display: block;
  overflow: hidden;
  color: #0f172a;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sales-sharing strong { color: #b45309; }
.sales-income strong { color: #1d4ed8; }
.sales-allocation-op {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f1f5f9;
  color: #64748b;
  font-size: 15px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 1px solid #e2e8f0;
}
.sales-allocation-help { margin-top: 4px; color: #64748b; font-size: 10px; display: flex; align-items: center; }

.pie-legend { display: flex; justify-content: center; gap: 14px; margin-top: 16px; flex-wrap: wrap; }
.pie-legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: #334155; padding: 4px 10px; border-radius: 8px; background: #f8fafc; border: 1px solid #e2e8f0; }
.pie-legend-sq { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* ── Analytics responsive ─────────────────────── */
@media (max-width: 991px) {
  /* Trend chart taller when full-width */
  .chart-wrap { height: 320px; }
  .analytics-trend-content .chart-wrap { min-height: 320px; }
  /* Pie chart a bit taller when beside nothing */
  .pie-chart-wrap { height: 240px; }
}

@media (max-width: 575px) {
  .sales-allocation-grid { grid-template-columns: 1fr; gap: 7px; }
  .sales-allocation-op { display: none; }
  .sales-allocation-item { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
  .sales-allocation-item span { margin-bottom: 0; }
  .sales-allocation-item strong { font-size: 15px; }
}

@media (max-width: 576px) {
  /* Tabs: stretch the segmented pill edge-to-edge and split it evenly
     between the 4 tabs (desktop/tablet leave it content-sized instead,
     since they have room to spare) — and run everything more compact. */
  .ana-tabs { display: flex; width: 100%; }
  .ana-tabs-slot {
    position: relative;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
  }
  .ana-tabs-slot .ana-view-tabs {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    scrollbar-color: rgba(30, 77, 58, .55) transparent;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    cursor: grab;
  }
  .ana-view-tabs:active { cursor: grabbing; }
  .ana-view-tabs::-webkit-scrollbar { height: 4px; }
  .ana-view-tabs::-webkit-scrollbar-track { background: transparent; }
  .ana-view-tabs::-webkit-scrollbar-thumb { background: rgba(30, 77, 58, .55); border-radius: 999px; }
  .ana-tab {
    flex: 1 1 0;
    min-width: 0;
    gap: 2px;
    padding: 8px 4px;
    font-size: 10.5px;
  }
  .ana-tab i { font-size: 16px; }
  .ana-view-tabs .ana-tab {
    flex: 0 0 112px;
    width: 112px;
    min-width: 112px;
    min-height: 58px;
    padding: 8px 12px;
    white-space: nowrap;
    scroll-snap-align: start;
  }
  .ana-tabs-scroll-cue {
    position: absolute;
    z-index: 3;
    right: 1px;
    top: 1px;
    bottom: 5px;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 9px 0 28px;
    background: linear-gradient(90deg, rgba(255,255,255,0), #fff 38%);
    color: var(--primary);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .3px;
    text-transform: uppercase;
    pointer-events: none;
  }
  .ana-tabs-scroll-cue i { font-size: 11px; }
  /* Controls: wrap below title inside card header on tablet */
  .ana-card-header { align-items: flex-start; }
  .ana-chart-type-switch .ana-chart-btn { padding: 7px 12px; }
  .ana-controls-sep { display: none; }
  /* Keep all three controls on one row. Overflow stays visible so their
     popup lists can overlay the content below instead of being clipped. */
  .ana-filter-bar {
    display: flex;
    width: 100%;
    flex-wrap: nowrap;
    overflow: visible;
    gap: 5px;
    padding: 6px 8px;
    max-width: 100%;
  }
  .ana-period-wrap { flex: 1 1 0; min-width: 0; }
  .ana-year-dropdown { flex: 0 0 auto; }
  .ana-year-toggle { padding: 6px 27px 6px 9px; font-size: 11px; }
  .ana-filter-sep { flex: 0 0 1px; }
  .analytics-range { flex: 1.12 1 0; min-width: 0; }
  .analytics-range-toggle {
    width: 100%;
    min-width: 0;
    gap: 6px;
    padding: 7px 8px;
  }
  .analytics-range-toggle span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .ana-chart-btn { flex: 0 0 auto; padding: 6px 9px; font-size: 11px; gap: 3px; }
  .ana-chart-btn i { font-size: 11px; }
  /* Charts shorter on small phone */
  .chart-wrap { height: 220px; }
  .analytics-trend-content .chart-wrap { min-height: 220px; }
  .pie-chart-wrap { height: 200px; }
  .ana-filter-bar .ana-period:not(.ana-year-toggle) {
    width: 100%;
    min-width: 0;
    font-size: 11px;
    padding: 6px 18px 6px 22px;
  }
  .ana-period-icon { left: 8px; font-size: 11px; }
  /* Menus overlay the surrounding card and remain comfortably tappable. */
  .ana-year-dropdown .dropdown-menu {
    z-index: 1060;
    width: 112px;
    max-height: min(224px, 45vh);
  }
  .ana-period-menu {
    min-width: 156px;
    max-width: calc(100vw - 24px);
    max-height: min(220px, 45vh);
  }
  .ana-year-dropdown .dropdown-item {
    min-height: 36px;
    display: flex;
    align-items: center;
    font-size: 14px;
  }
  .analytics-range-panel {
    z-index: 1060;
    width: min(280px, calc(100vw - 32px));
    max-height: min(420px, 65vh);
    overflow-y: auto;
  }
}

/* ===== REPORTS PAGE — editorial document/ledger style ===== */
/* A document to export and hand off, not a dashboard: flat surfaces, hairline
   borders, no shadows/gradients. One accent (--primary) reserved for the
   primary export action and any figure that needs attention. */

/* 18px, not 4px — the tabs card sits directly under both the page title
   and the notification bell floating at the content's top-right corner
   (.content-topbar, top:26px), and at 4px its top edge nearly touched
   the bell. This is the breathing room between the header line and the
   card below it. */
.rep-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.rep-topbar .page-title { margin-bottom: 0; }

/* Report type tabs (segmented pill, shared with Analytics — see
   .ana-tabs/.ana-tab) + the Export dropdown, on the same row once
   there's room; the Export button becomes a full-width row of its own
   below the tabs on phones instead of squeezing in beside them. */
.rep-tabs-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
  /* One shared backdrop card around the tabs + Export pair, instead of
     two pills floating separately on the page — matches Members'
     filter row, where the search box and controls beside it read as one
     connected unit rather than two disconnected pieces. */
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  /* The export menu opens below this card. Hidden overflow clipped every
     option at the card edge, leaving only the top of the menu visible. */
  overflow: visible;
  position: relative;
  z-index: 20;
}
.rep-tabs-row .ana-tabs { margin-bottom: 0; }
.rep-type-tabs {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: rgba(30, 77, 58, .55) transparent;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  cursor: grab;
}
.rep-type-tabs:active { cursor: grabbing; }
.rep-type-tabs::-webkit-scrollbar { height: 4px; }
.rep-type-tabs::-webkit-scrollbar-track { background: transparent; }
.rep-type-tabs::-webkit-scrollbar-thumb { background: rgba(30, 77, 58, .55); border-radius: 999px; }
.rep-type-tabs .ana-tab { scroll-snap-align: start; }

/* Reports has seven segments. Unlike the shared Analytics tabs, use the whole
   strip beside Download on laptop and tablet widths and keep readable,
   horizontally scrollable touch targets on phones. */
@media (min-width: 768px) {
  .rep-type-tabs .ana-tab {
    flex: 1 1 0;
    width: auto;
    min-width: 76px;
    padding-inline: 8px;
  }
}

@media (min-width: 1260px) {
  .rep-type-tabs .ana-tab {
    width: auto;
    min-width: 104px;
    padding-inline: 12px;
  }
}

@media (max-width: 767px) {
  .rep-type-tabs {
    width: 100%;
    justify-content: flex-start !important;
    overflow-x: auto !important;
  }
  .rep-type-tabs .ana-tab {
    flex: 0 0 112px !important;
    width: 112px !important;
    min-width: 112px !important;
    min-height: 58px;
    padding: 8px 12px;
    font-size: 11px;
    white-space: nowrap;
  }
  .rep-type-tabs .ana-tab i { font-size: 15px; }
}

/* Settings page tabs: same shell as .rep-tabs-row, and the tabs inside are
   the same segmented-pill language as Analytics/Reports (.ana-tabs/.ana-tab)
   — but section names here ("Two-Factor Authentication") run far longer
   than the single-word labels that pattern's fixed 72/128px width was sized
   for, so .settings-tabs lets each segment size to its own label instead.
   overflow-x: auto is the fallback if five of those ever don't fit a
   narrow phone — the pill scrolls instead of blowing out the page width. */
.settings-tabs-row {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 16px;
  overflow: hidden;
}
.settings-tabs-row .ana-tabs { margin-bottom: 0; }
/* flex: 0 0 auto overrides the ≤576px Analytics rule below, which splits
   .ana-tab evenly via flex:1 1 0 — built for 4 short labels ("Member",
   "Sales"), it crushed "Two-Factor Authentication" into an unreadable
   sliver. Kept at its natural width instead; .settings-tabs-row's
   overflow-x: auto scrolls whatever doesn't fit a narrow phone. */
.settings-tabs {
  display: flex;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: rgba(30, 77, 58, .55) transparent;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  cursor: grab;
}
.settings-tabs:active { cursor: grabbing; }
.settings-tabs::-webkit-scrollbar { height: 4px; }
.settings-tabs::-webkit-scrollbar-track { background: transparent; }
.settings-tabs::-webkit-scrollbar-thumb { background: rgba(30, 77, 58, .55); border-radius: 999px; }
.settings-tabs .ana-tab {
  width: auto;
  min-width: max-content;
  min-height: 46px;
  flex: 0 0 auto;
  padding: 8px 18px;
  scroll-snap-align: start;
}
.settings-tabs .ana-tab > span {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: center;
  text-align: center;
}
/* Tablet, laptop, desktop, and a phone using "Desktop site" divide the
   available width evenly between the three settings sections. */
@media (min-width: 768px) {
  .settings-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
  }
  .settings-tabs .ana-tab {
    width: 100%;
    min-width: 0;
    min-height: 52px;
    padding: 8px 12px;
    text-align: center;
    white-space: normal;
  }
}
@media (min-width: 1260px) {
  .settings-tabs .ana-tab { padding: 10px 20px; }
}

@media (max-width: 767px) {
  .settings-tabs-row { padding: 12px; }
  .settings-tabs .ana-tab {
    flex: 0 0 auto;
    width: auto;
    min-width: 132px;
    min-height: 58px;
    padding: 8px 16px;
    font-size: 11px;
    white-space: nowrap;
  }
  .settings-tabs .ana-tab i { font-size: 15px; }
}

.rep-export-dropdown { width: 100%; position: relative; }
.rep-export-dropdown .dropdown-menu {
  z-index: 1050;
  min-width: 190px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
}
.rep-export-dropdown .dropdown-item {
  border-radius: 7px;
  padding: 9px 12px;
  white-space: nowrap;
}
.rep-export-dropdown .dropdown-menu.rep-export-menu {
  min-width: 180px;
  padding: 7px;
  border: 1px solid #dce5e0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(23, 45, 34, .14);
}
.rep-export-dropdown .dropdown-menu.rep-export-menu .dropdown-item {
  min-height: 44px;
  gap: 10px;
  padding: 10px 11px;
  border: 0;
  border-radius: 9px;
  color: #263b31;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.25;
}
.rep-export-dropdown .dropdown-menu.rep-export-menu .dropdown-item i {
  flex: 0 0 16px;
  width: 16px;
  color: #315f4b;
  font-size: 16px;
  line-height: 1;
  text-align: center;
}
.rep-export-dropdown .dropdown-menu.rep-export-menu .dropdown-item:hover,
.rep-export-dropdown .dropdown-menu.rep-export-menu .dropdown-item:focus,
.rep-export-dropdown .dropdown-menu.rep-export-menu .dropdown-item:active {
  border: 0;
  outline: 0;
  background: #e7f4eb;
  color: #285a43;
  box-shadow: none;
}
.rep-export-btn {
  width: 100%;
  justify-content: center;
  /* .ana-chart-btn is sized for a dense chart toolbar (6px padding, 11px
     text), which left this full-width stacked button only ~24px tall.
     responsive.css lifts it to 44px under (pointer: coarse), but that
     leaves a narrow desktop window at 24px — so set the floor here
     instead of relying on pointer type. Stacked layout only; the ≥768px
     block resets this and sizes the button to the tab pills instead. */
  min-height: 44px;
}
@media (min-width: 768px) {
  .rep-tabs-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .rep-export-dropdown { width: auto; }
  /* Match .ana-tab — the pills beside it — NOT the .ana-tabs shell that
     wraps them. The shell adds 4px padding + 1px border per side, so
     sizing Export from the row (or from the shell) lands it 10px taller
     than the Production pill it should line up with. .ana-chart-btn's
     own padding gives it 23px, hence an explicit height rather than
     padding. min-height resets the 44px stacked-layout floor set above,
     which would otherwise beat this height. */
  .rep-export-btn {
    width: auto;
    height: 36px;
    min-height: 0;
  }
}

/* .ana-tab steps up at this breakpoint (128px wide, 16px icon, 13px
   label), taking the pills from 36px to 48px — Export tracks it. */
@media (min-width: 1260px) {
  .rep-export-btn { height: 48px; }
}

.rep-doc {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: grid;
  grid-template-columns: 200px 1px 1fr;
  column-gap: 28px;
  padding: 28px;
  position: relative;
}
.rep-doc::before {
  /* vertical hairline between the two columns */
  content: "";
  grid-column: 2;
  grid-row: 1 / span 1;
  width: 1px;
  background: var(--border);
}

.rep-doc-side { grid-column: 1; display: flex; flex-direction: column; }
.rep-doc-main { grid-column: 3; min-width: 0; }

.rep-monogram {
  width: 44px; height: 44px; border-radius: 50%;
  object-fit: cover; margin-bottom: 10px;
}
.rep-org-name { font-size: 15px; font-weight: 700; color: var(--text-dark); }
.rep-org-sub  { font-size: 12.5px; color: var(--text-muted); margin-bottom: 16px; }
.rep-doc-divider { height: 1px; background: var(--border); margin-bottom: 16px; }

.rep-field { margin-bottom: 16px; position: relative; }
.rep-field-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.rep-field-static { font-size: 13.5px; color: var(--text-dark); }
.rep-field-trigger {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none; padding: 0;
  font-size: 13.5px; color: var(--text-dark);
  cursor: pointer; text-align: left;
}
.rep-field-trigger i { font-size: 11px; color: var(--text-muted); }
.rep-field-trigger:hover { color: var(--primary); }
.rep-field-trigger:hover i { color: var(--primary); }
.rep-field-popover {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 20;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 26px 8px 8px; min-width: 180px; max-width: calc(100vw - 32px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}
.rep-field-popover-close {
  position: absolute; top: 6px; right: 6px;
  display: flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border: none; border-radius: 4px;
  background: none; color: var(--text-muted); font-size: 10px;
  cursor: pointer; padding: 0;
}
.rep-field-popover-close:hover { background: var(--primary-bg); color: var(--primary); }
.rep-range-fields { display: flex; flex-direction: column; gap: 10px; min-width: 160px; }

.rep-option-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; }
.rep-option-list li {
  padding: 7px 10px; border-radius: 6px; font-size: 13px;
  color: var(--text-dark); cursor: pointer; white-space: nowrap;
}
.rep-option-list li:hover { background: var(--primary-bg); }
.rep-option-list li.active { background: var(--primary); color: #fff; }

.rep-doc-title { font-size: 18px; font-weight: 700; color: var(--text-dark); margin-bottom: 10px; }
.rep-report-context {
  display: flex; flex-direction: column; gap: 3px;
  margin-bottom: 18px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--primary-bg); color: var(--text-dark);
  font-size: 12px; line-height: 1.5;
}
.rep-report-context strong { font-size: 12px; color: var(--primary); }
.rep-report-context span { color: var(--text-muted); }

table.rep-ledger { width: 100%; border-collapse: collapse; font-size: 13px; }
table.rep-ledger th, table.rep-ledger td { text-align: left; padding: 9px 10px; border-bottom: 0.5px solid var(--border); }
table.rep-ledger th { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: none; }
table.rep-ledger thead .rep-ledger-groups th {
  background: #edf5f0;
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .045em;
  text-align: center;
  text-transform: uppercase;
  border-bottom-color: #cfe0d6;
}
table.rep-ledger thead .rep-ledger-groups th:first-child {
  text-align: left;
  vertical-align: middle;
}
table.rep-ledger td { color: var(--text-dark); }
table.rep-ledger tr.current { background: var(--primary-bg); font-weight: 700; }
table.rep-ledger td.attention { color: var(--primary); font-weight: 700; }
.rep-scope-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #d5e5db;
  border-radius: 9px;
  background: #f4f9f6;
  color: #426151;
  font-size: 12px;
  line-height: 1.45;
}
.rep-scope-note i { color: var(--primary); flex: 0 0 auto; margin-top: 1px; }

.rep-summary-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin: 20px 0 8px; }
.rep-summary-text {
  margin: 0;
  color: var(--text-dark);
  font-size: 13.5px;
  line-height: 1.7;
  text-align: justify;
  text-justify: inter-word;
  overflow-wrap: anywhere;
  hyphens: auto;
}

.rep-empty { text-align: center; color: var(--text-muted); font-size: 13px; padding: 32px 0; }
.rep-zero-state {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 12px 0 0; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 12.5px; line-height: 1.5;
}
.rep-zero-state i { color: var(--primary); margin-top: 2px; }

@media (max-width: 720px) {
  .rep-doc { grid-template-columns: 1fr; }
  .rep-doc::before { display: none; }
  .rep-doc-side { grid-column: 1; margin-bottom: 20px; }
  .rep-doc-main { grid-column: 1; }
}

/* ===== EXECUTIVE REPORT ENHANCEMENTS ===== */
.rep-doc {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  display: grid;
  grid-template-columns: 220px 1px 1fr;
  column-gap: 28px;
  padding: 30px;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

.rep-brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.rep-brand-text {
  display: flex;
  flex-direction: column;
}
.rep-brand-block .rep-monogram {
  margin-bottom: 0;
}
.rep-brand-block .rep-org-sub {
  margin-bottom: 0;
}

.rep-field-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 12px;
  background: #f8faf9;
  border: 1px solid #e2e8e5;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}
.rep-field-trigger:hover,
.rep-field-trigger.open {
  background: #ffffff;
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 77, 58, 0.08);
}
.rep-field-trigger i {
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}
.rep-field-trigger:hover i,
.rep-field-trigger.open i {
  color: var(--primary);
}
.rep-field-static {
  padding: 8px 12px;
  background: #fafcfb;
  border: 1px solid #edf2f0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

/* Executive Summary Card */
.rep-exec-summary-card {
  background: #ffffff;
  border: 1px solid #dce4e0;
  border-radius: 14px;
  padding: 24px 26px;
  margin-top: 24px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.rep-exec-summary-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
}
.rep-exec-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f1f5f9;
  flex-wrap: wrap;
}
.rep-exec-summary-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.rep-exec-summary-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #e8f5ee;
  color: #1e4d3a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}
.rep-exec-summary-h3 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 20px;
  font-weight: 600;
  color: #1e4d3a;
  margin: 0;
  letter-spacing: -0.2px;
  line-height: 1.25;
}
.rep-exec-summary-subtitle {
  font-size: 12px;
  color: #64748b;
  display: block;
  margin-top: 2px;
  font-weight: 500;
}
.rep-verified-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  background: #e8f5ee;
  color: #1e4d3a;
  border: 1px solid #bbf7d0;
  font-size: 11.5px;
  font-weight: 600;
}
.rep-exec-summary-body {
  font-size: 14px;
  line-height: 1.75;
  color: #334155;
  text-align: left;
}
.rep-exec-narrative-callout {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 22px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #1e4d3a;
  border-radius: 10px;
  margin-top: 4px;
}
.rep-exec-narrative-icon {
  color: #1e4d3a;
  font-size: 19px;
  margin-top: 2px;
  flex-shrink: 0;
}
.rep-exec-summary-text {
  margin: 0;
  color: #334155;
  font-size: 14px;
  line-height: 1.75;
  font-weight: 500;
}
.rep-exec-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 14px;
  padding: 13px 18px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 4px solid #16a34a;
  border-radius: 10px;
  color: #166534;
  font-size: 13px;
  line-height: 1.6;
}
.rep-exec-notice i {
  font-size: 17px;
  color: #16a34a;
  margin-top: 2px;
  flex-shrink: 0;
}
.rep-exec-notice-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rep-exec-notice-content strong {
  color: #166534;
  font-size: 13px;
  font-weight: 700;
}
.rep-exec-notice-content span {
  color: #14532d;
  font-size: 12.5px;
  line-height: 1.5;
}

/* Standard Report Summary Card (Production, Member, Sales, Income) */
.rep-summary-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 22px 24px;
  margin-top: 24px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.rep-summary-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
}
.rep-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f1f5f9;
  flex-wrap: wrap;
}
.rep-summary-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.rep-summary-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #e8f5ee;
  color: #1e4d3a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.rep-summary-h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 19px;
  font-weight: 600;
  color: #1e4d3a;
  margin: 0;
  letter-spacing: -0.2px;
}
.rep-summary-subtitle {
  font-size: 12px;
  color: #64748b;
  display: block;
  margin-top: 2px;
}
.rep-summary-body {
  font-size: 14px;
  line-height: 1.75;
  color: #334155;
  text-align: left;
}
.rep-summary-callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #1e4d3a;
  border-radius: 10px;
}
.rep-summary-callout-icon {
  color: #1e4d3a;
  font-size: 18px;
  margin-top: 2px;
  flex-shrink: 0;
}
.rep-summary-text {
  margin: 0;
  color: #334155;
  font-size: 14px;
  line-height: 1.75;
  font-weight: 500;
}
.rep-zero-badge {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 14px;
  padding: 13px 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 4px solid #16a34a;
  border-radius: 10px;
  color: #166534;
  font-size: 13px;
  line-height: 1.6;
}
.rep-zero-badge i {
  font-size: 16px;
  color: #16a34a;
  margin-top: 2px;
  flex-shrink: 0;
}

/* Section Header */
.rep-exec-section {
  margin-top: 28px;
}
.rep-exec-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #1e293b;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1.5px solid #edf2f0;
  flex-wrap: wrap;
}
.rep-exec-section-header i {
  font-size: 14px;
}
.rep-section-note {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
}

/* Verified Findings 2-Column Grid */
.rep-findings-grid-2col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
@media (max-width: 900px) {
  .rep-findings-grid-2col {
    grid-template-columns: 1fr;
  }
}
.rep-card-vfinding {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.05), 0 2px 4px -1px rgba(15, 23, 42, 0.03);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: all 0.2s ease;
}
.rep-card-vfinding:hover {
  border-color: #cbd5e1;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  transform: translateY(-2px);
}
.rep-card-vfinding.card-membership { border-top: 4px solid #0284c7; }
.rep-card-vfinding.card-production { border-top: 4px solid #16a34a; }
.rep-card-vfinding.card-sales      { border-top: 4px solid #d97706; }
.rep-card-vfinding.card-finance    { border-top: 4px solid #7c3aed; }

.rep-vfinding-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.rep-vfinding-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.rep-vfinding-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}
.rep-vfinding-icon.icon-membership { background: #e0f2fe; color: #0284c7; }
.rep-vfinding-icon.icon-production { background: #dcfce7; color: #16a34a; }
.rep-vfinding-icon.icon-sales      { background: #fef3c7; color: #d97706; }
.rep-vfinding-icon.icon-finance    { background: #ede9fe; color: #7c3aed; }

.rep-vfinding-title {
  font-size: 16.5px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}
.rep-vfinding-cat {
  font-size: 12px;
  color: #64748b;
  display: block;
  margin-top: 2px;
  font-weight: 500;
}
.rep-vfinding-highlight {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  flex-shrink: 0;
}
.rep-highlight-val {
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.rep-highlight-lbl {
  font-size: 10.5px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 700;
}
.rep-vfinding-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.rep-mini-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 8px;
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.card-membership .rep-mini-pill { background: #f0f9ff; color: #0369a1; border-color: #bae6fd; }
.card-production .rep-mini-pill { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.card-sales .rep-mini-pill      { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.card-finance .rep-mini-pill    { background: #faf5ff; color: #6d28d9; border-color: #ddd6fe; }

.rep-vfinding-body {
  margin-top: auto;
  background: #f8fafc;
  border-radius: 10px;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
}
.rep-vfinding-text {
  font-size: 13.5px;
  line-height: 1.65;
  color: #334155;
  margin: 0;
  font-weight: 450;
}

/* Top Members Ranking Table */
.rep-top-members-card {
  background: #ffffff;
  border: 1px solid #e2e8e5;
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.03);
  overflow: hidden;
}
.rep-top-members-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #f1f5f9;
  background: #fafcfb;
}
.rep-top-members-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.rep-top-members-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: #fef3c7;
  color: #b45309;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.rep-top-members-h3 {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
}
.rep-top-members-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
}
.rep-ranking-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0;
}
.rep-ranking-table th {
  background: #f8fafc;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 18px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
.rep-ranking-table td {
  padding: 13px 18px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
  color: #334155;
  vertical-align: middle;
}
.rep-rank-row {
  transition: background-color 0.15s ease;
}
.rep-rank-row:hover td {
  background: #f8faf9;
}
.rep-th-rank, .rep-td-rank { width: 90px; text-align: center; }
.rep-th-name, .rep-td-name { text-align: left; }
.rep-th-num, .rep-td-num { text-align: right; }

.rep-rank-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 32px;
  height: 28px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 700;
  padding: 0 8px;
}
.rep-rank-pill.rank-1 { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.rep-rank-pill.rank-2 { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.rep-rank-pill.rank-3 { background: #ffedd5; color: #c2410c; border: 1px solid #fed7aa; }
.rep-rank-pill.rank-rest { background: transparent; color: #64748b; font-weight: 600; }
.text-bronze { color: #c2410c !important; }

.rep-member-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.rep-avatar-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 700;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.rep-avatar-circle.rank-1 { background: #fef3c7; color: #b45309; }
.rep-avatar-circle.rank-2 { background: #f1f5f9; color: #475569; }
.rep-avatar-circle.rank-3 { background: #ffedd5; color: #c2410c; }
.rep-member-name-text {
  font-weight: 600;
  color: #1e293b;
}
.rep-num-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: #334155;
}
.rep-points-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  color: #1e293b;
  background: #fffbeb;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #fef3c7;
}
.rep-output-col strong {
  color: var(--primary);
  font-weight: 700;
}

/* Panel cards for issues, recommendations */
.rep-panel-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.rep-panel-item {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 20px 24px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  box-shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.05);
}
.rep-panel-item.issue {
  background: #ffffff;
  border: 1px solid #fecaca;
  border-left: 5px solid #dc2626;
  color: #1e293b;
}
.rep-panel-item.issue strong {
  color: #991b1b;
  font-size: 15px;
  font-weight: 700;
}
.rep-panel-item.healthy {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 5px solid #16a34a;
  color: #14532d;
}
.rep-panel-item.healthy strong {
  color: #166534;
  font-size: 15px;
  font-weight: 700;
}
.rep-panel-item.recommendation {
  background: #f6fbf8;
  border: 1px solid #d8ecdf;
  border-left: 4px solid #1e4d3a;
  color: #1a4d38;
}

/* Resource Requirements */
.rep-resource-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.rep-resource-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.rep-resource-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12.5px;
  background: #f3f7f5;
  border: 1px solid #d7e6dc;
  color: #1f4a38;
  line-height: 1.4;
}
.rep-resource-chip.highlight {
  background: #e8f3ed;
  border-color: #bad3c5;
  font-weight: 600;
  color: var(--primary);
}

/* Action plan cards */
.rep-action-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.rep-action-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 5px solid #1e4d3a;
  border-radius: 16px;
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.05), 0 2px 4px -1px rgba(15, 23, 42, 0.03);
  transition: all 0.2s ease;
}
.rep-action-item:hover {
  border-color: #cbd5e1;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}
.rep-action-item:has(.rep-priority-badge.high) {
  border-left-color: #dc2626;
}
.rep-action-item:has(.rep-priority-badge.medium) {
  border-left-color: #d97706;
}
.rep-action-item:has(.rep-priority-badge.low) {
  border-left-color: #0284c7;
}
.rep-action-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.rep-priority-badge {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 999px;
  letter-spacing: 0.6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.rep-priority-badge.high {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.rep-priority-badge.medium {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}
.rep-priority-badge.low {
  background: #e0f2fe;
  color: #075985;
  border: 1px solid #bae6fd;
}
.rep-action-title {
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.6;
}
.rep-action-issue {
  font-size: 13px;
  color: #475569;
  background: #f8fafc;
  border: 1px solid #edf2f7;
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.6;
}

/* Planning Area Category Badges */
.rep-area-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.3px;
}
.rep-area-badge.production { background: #ecfdf5; color: #047857; }
.rep-area-badge.sales { background: #eff6ff; color: #1d4ed8; }
.rep-area-badge.membership { background: #f0fdf4; color: #15803d; }
.rep-area-badge.resource { background: #fff7ed; color: #c2410c; }
.rep-area-badge.finance { background: #faf5ff; color: #7e22ce; }
.rep-area-badge.general { background: #f1f5f9; color: #475569; }

.rep-planning-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.rep-planning-table-wrap table.rep-ledger {
  margin-bottom: 0;
}
.rep-planning-table-wrap table.rep-ledger th {
  background: #f8faf9;
  padding: 10px 14px;
}
.rep-planning-table-wrap table.rep-ledger td {
  padding: 11px 14px;
  vertical-align: middle;
}

/* ===== MESSAGES LAYOUT ===== */
.messages-layout {
  display: flex;
  gap: 16px;
  height: calc(100vh - 190px);
  min-height: 500px;
}
.inbox-panel {
  width: 300px;
  flex-shrink: 0;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.inbox-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
}
.inbox-list { overflow-y: auto; flex: 1; }

.chat-panel {
  flex: 1;
  position: relative;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
/* Scoped to .main-content: bare, this also wins on the public Catalog
   page's own unrelated .chat-header (catalog.css:232), zeroing out its
   intended bottom padding since both rules share the same specificity and
   this file loads after catalog.css. */
.main-content .chat-header { padding: 14px 20px 0; }
.chat-header-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
}
/* Name/contact block must be allowed to shrink and truncate (flex items
   default to min-width:auto, which refuses to shrink below its content's
   natural width) so a long name can't push the delete button off-panel. */
.chat-header-top .flex-grow-1 { min-width: 0; }
.chat-header-top .flex-grow-1 > div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-header-top .btn-icon-danger { flex-shrink: 0; }
.chat-header-top .btn-archive-amfe {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--status-rejected, #dc3545);
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: opacity .15s ease, color .15s ease;
}
.chat-header-top .btn-archive-amfe i {
  color: var(--status-rejected, #dc3545);
  font-size: 15px;
}
.chat-header-top .btn-archive-amfe span {
  color: var(--status-rejected, #dc3545);
}
.chat-header-top .btn-archive-amfe:hover,
.chat-header-top .btn-archive-amfe:focus-visible {
  background: transparent;
  color: #ff6b6b;
  opacity: 0.85;
}
.chat-header-top .btn-archive-amfe:hover i,
.chat-header-top .btn-archive-amfe:hover span {
  color: #ff6b6b;
}
.chat-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--primary-bg);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  font-size: 16px;
  flex-shrink: 0;
}
.chat-header-divider { border-top: 1px solid var(--border); }
.chat-messages {
  flex: 1;
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Unified Messenger-style message controls for Admin Chat Inquiries. */
.admin-chat-legacy-thread { display: none; }
.admin-chat-modern-thread { display: flex; flex-direction: column; gap: 6px; }
.admin-chat-overlay {
  all: unset;
  position: absolute;
  inset: 72px 0 0;
  z-index: 80;
  display: block;
  background: rgba(16, 42, 31, .15);
  backdrop-filter: blur(1.5px);
  cursor: default;
  animation: adminChatFadeIn .16s ease-out;
}
.admin-chat-date {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 10px 0 12px;
  color: #718078;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}
.admin-chat-date::before,
.admin-chat-date::after { content: ''; flex: 1; height: 1px; background: #e5ece7; }
.admin-chat-date span {
  padding: 5px 11px;
  border: 1px solid #e2eae5;
  border-radius: 999px;
  background: #f7faf8;
  white-space: nowrap;
}
.admin-chat-message { position: relative; display: flex; margin: 3px 0; }
.admin-chat-message.mine { justify-content: flex-end; }
.admin-chat-message.customer { justify-content: flex-start; }
.admin-chat-bubble-wrap {
  position: relative;
  max-width: min(76%, 640px);
  transition: transform .15s ease-out;
  touch-action: pan-y;
}
.admin-chat-bubble-wrap.menu-open { z-index: 100; }
.admin-chat-bubble {
  appearance: none;
  display: block;
  width: fit-content;
  max-width: 100%;
  padding: 10px 14px;
  border: 1px solid #dce8e1;
  border-radius: 17px 17px 17px 5px;
  background: #edf4f0;
  color: #173529;
  box-shadow: 0 1px 2px rgba(15, 50, 35, .06);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.45;
  text-align: left;
  word-break: break-word;
  cursor: pointer;
}
.admin-chat-message.mine .admin-chat-bubble {
  margin-left: auto;
  border-color: var(--primary);
  border-radius: 17px 17px 5px 17px;
  background: var(--primary);
  color: #fff;
}
.admin-chat-bubble:focus-visible { outline: 2px solid #7caf92; outline-offset: 2px; }
.admin-chat-pinned { display: flex; align-items: center; gap: 4px; margin-bottom: 5px; color: #b45309; font-size: 10px; font-weight: 700; }
.admin-chat-message.mine .admin-chat-pinned { color: #fef3c7; }
.admin-chat-quote {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 7px;
  padding: 5px 8px;
  overflow: hidden;
  border-left: 3px solid var(--primary);
  border-radius: 5px;
  background: rgba(0, 0, 0, .06);
  font-size: 11px;
}
.admin-chat-quote span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .88; }
.admin-chat-message.mine .admin-chat-quote { border-left-color: #fff; background: rgba(255, 255, 255, .17); }
.admin-chat-meta { display: flex; flex-direction: column; gap: 1px; margin-top: 5px; color: #94a3b8; font-size: 11px; line-height: 1.3; }
.admin-chat-message.mine .admin-chat-meta { align-items: flex-end; }
.admin-chat-message.customer .admin-chat-meta { align-items: flex-start; }
.admin-chat-meta span:last-child { display: inline-flex; align-items: center; gap: 3px; }
.admin-chat-meta .seen { color: var(--primary); font-weight: 700; }
.admin-chat-reaction-picker {
  position: absolute;
  bottom: calc(100% + 10px);
  z-index: 105;
  display: flex;
  align-items: center;
  gap: 2px;
  width: max-content;
  padding: 6px;
  border: 1px solid #dce7df;
  border-radius: 999px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 12px 32px rgba(15, 50, 35, .2), 0 2px 8px rgba(15, 23, 42, .08);
  animation: adminChatPopIn .15s ease-out;
}
.admin-chat-message.mine .admin-chat-reaction-picker { right: -4px; }
.admin-chat-message.customer .admin-chat-reaction-picker { left: -4px; }
.admin-chat-reaction-picker button {
  all: unset;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}
.admin-chat-reaction-picker button:hover { transform: scale(1.18) translateY(-2px); background: #edf5f0; }
.admin-chat-reaction-chips { display: flex; gap: 3px; margin-top: 3px; }
.admin-chat-message.mine .admin-chat-reaction-chips { justify-content: flex-end; }
.admin-chat-reaction-chips button {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border: 1px solid #dce7df;
  border-radius: 999px;
  background: #fff;
  font-size: 11px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(15, 50, 35, .08);
}
.admin-chat-reaction-chips button.active { border-color: var(--primary); background: #edf5f0; }
.admin-chat-swipe-arrow {
  position: absolute;
  top: 50%;
  left: 0;
  z-index: 2;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: translateY(-50%) scale(.7);
  background: var(--primary);
  color: #fff;
  transition: opacity .15s ease, transform .15s ease;
}
.admin-chat-swipe-arrow.visible { opacity: 1; transform: translateY(-50%) scale(1); }
.admin-chat-swipe-arrow.ready { background: #16734d; box-shadow: 0 0 0 4px rgba(22, 115, 77, .14); }
.admin-chat-action-sheet {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 120;
  padding: 8px 14px 14px;
  border-top: 1px solid #dce7df;
  border-radius: 18px 18px 0 0;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 -14px 36px rgba(15, 50, 35, .14);
  backdrop-filter: blur(10px);
  animation: adminChatSheetIn .2s ease-out;
}
.admin-chat-sheet-handle { display: block; width: 36px; height: 4px; margin: 0 auto 8px; border-radius: 999px; background: #cbd8d0; }
.admin-chat-sheet-grid { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.admin-chat-sheet-grid > button {
  all: unset;
  min-width: 0;
  padding: 6px 4px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: #244f3c;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}
.admin-chat-sheet-grid > button:hover { background: #edf5f0; }
.admin-chat-sheet-grid > button > span { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: #edf5f0; font-size: 18px; }
.admin-chat-sheet-grid > button.danger { color: #b4232d; }
.admin-chat-sheet-grid > button.danger > span { background: #fff0f1; }
@keyframes adminChatFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes adminChatPopIn { from { opacity: 0; transform: scale(.86); } to { opacity: 1; transform: scale(1); } }
@keyframes adminChatSheetIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
.chat-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-footer textarea {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  outline: none;
  resize: none;
  flex: 1;
  font-family: 'DM Sans', sans-serif;
  min-height: 52px;
}
.chat-footer textarea:focus { border-color: var(--primary); }

/* Back button — hidden on desktop/tablet */
.chat-back-btn { display: none; }

/* ===== MESSAGES ACTIVE INBOX ITEM ===== */
.inbox-item.active {
  background: var(--primary) !important;
  border-left: none;
}
.inbox-item.active .inbox-sender,
.inbox-item.active .inbox-preview,
.inbox-item.active .inbox-time { color: rgba(255,255,255,0.9) !important; }
.inbox-item.active .badge-pending {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.5);
  color: rgba(255,255,255,0.9);
}

/* ===== SEND REPLY BUTTON ===== */
.btn-send-reply {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}
.btn-send-reply:hover { background: var(--primary-light); }

/* ===== RESOURCE ALLOCATION ===== */
.ra-available-stock-field {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ra-available-stock-input-wrap {
  flex: 1;
}
.ra-available-stock-input {
  font-weight: 600;
  color: var(--text-dark, #1b4332);
  background-color: #f8fafc;
}
.ra-btn-view-breakdown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 8px;
  border: 1px solid #52b788;
  background: #f0fdf4;
  color: #1b4332;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.18s ease-in-out;
  flex-shrink: 0;
  text-decoration: none;
}
.ra-btn-view-breakdown:hover {
  background: #2d6a4f;
  border-color: #2d6a4f;
  color: #ffffff;
  box-shadow: 0 3px 8px rgba(45, 106, 79, 0.22);
  transform: translateY(-1px);
}
.ra-btn-view-breakdown:active {
  transform: translateY(0);
}
.ra-btn-view-breakdown i {
  font-size: 15px;
  color: #2d6a4f;
  transition: color 0.18s ease-in-out;
}
.ra-btn-view-breakdown:hover i {
  color: #ffffff;
}

@media (max-width: 576px) {
  .ra-available-stock-field {
    flex-direction: column;
    align-items: stretch;
  }
  .ra-btn-view-breakdown {
    justify-content: center;
    width: 100%;
  }
}

/* Modal Styling */
.ra-breakdown-modal-content {
  border: 0;
  border-radius: 16px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.15);
  overflow: hidden;
  background: #ffffff;
}
.ra-breakdown-modal-content .modal-header {
  padding: 20px 24px 16px;
  background: #fafcfb;
  border-bottom: 1px solid #eef3f0;
}
.ra-breakdown-modal-content .modal-body {
  padding: 20px 24px;
}
.ra-breakdown-modal-content .modal-footer {
  padding: 14px 24px 20px;
  background: #fafcfb;
  border-top: 1px solid #eef3f0;
}
.ra-modal-icon-badge {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #e8f5ed;
  color: #2d6a4f;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

/* Hero Banner */
.ra-breakdown-hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1b4332 0%, #2d6a4f 100%);
  color: #ffffff;
  box-shadow: 0 6px 16px rgba(27, 67, 50, 0.18);
}
.ra-breakdown-hero-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.88;
  font-weight: 500;
}
.ra-breakdown-hero-val {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 2px 0;
}
.ra-breakdown-hero-num {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  color: #ffffff;
}
.ra-breakdown-hero-unit {
  font-size: 16px;
  font-weight: 500;
  opacity: 0.9;
}
.ra-breakdown-hero-sub {
  font-size: 12px;
  opacity: 0.85;
}
.ra-breakdown-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(4px);
  border-radius: 50px;
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
}

/* Section Cards */
.ra-modal-section-card {
  padding: 16px;
  border-radius: 12px;
  border: 1px solid #e3ebe6;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}
.ra-modal-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid #f0f4f2;
}

/* Computation rows */
.ra-calc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  transition: background 0.15s ease;
}
.ra-calc-row:hover {
  background: #f7faf8;
}
.ra-calc-detail-group {
  position: relative;
  margin: 0 0 4px 32px;
  padding-left: 12px;
  border-left: 2px solid #e2e8f0;
}
.ra-calc-row-detail {
  padding-left: 4px;
}
.ra-calc-row-detail .ra-calc-pill {
  width: 18px;
  height: 18px;
  font-size: 10px;
}
.ra-calc-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #334155;
}
.ra-calc-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.ra-calc-pill-add {
  background: #e0f2fe;
  color: #0369a1;
}
.ra-calc-pill-sub {
  background: #fee2e2;
  color: #b91c1c;
}
.ra-calc-pill-eq {
  background: #f1f5f9;
  color: #475569;
}
.ra-calc-pill-total {
  background: #dcfce7;
  color: #15803d;
}
.ra-calc-subtotal {
  background: #f8fafc;
  font-weight: 600;
  border: 1px dashed #e2e8f0;
  margin: 4px 0;
}
.ra-calc-total {
  background: #f0fdf4;
  border-top: 1px solid #bbf7d0;
  margin-top: 6px;
  padding: 10px;
  font-size: 14px;
}

@media (max-width: 575.98px) {
  .ra-calc-detail-group {
    margin-left: 22px;
    padding-left: 8px;
  }
}

/* Source Months */
.ra-source-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: #2d6a4f;
  cursor: pointer;
  user-select: none;
}
.ra-source-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 6px;
  background: #f8fafc;
  font-size: 12px;
  margin-bottom: 4px;
}

/* Stock Status Grid */
.ra-stock-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 6px;
}
.ra-stock-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fafafa;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.ra-stock-tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.04);
}
.ra-stock-tile-held {
  border-color: #fef08a;
  background: #fffbeb;
}
.ra-stock-tile-damaged {
  border-color: #fecaca;
  background: #fef2f2;
}
.ra-stock-tile-historical {
  border-color: #e2e8f0;
  background: #f8fafc;
}
.ra-stock-tile-icon {
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ra-stock-tile-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.ra-stock-tile-info span {
  font-size: 12px;
  color: #475569;
  line-height: 1.3;
}
.ra-stock-tile-info strong {
  font-size: 15px;
  font-weight: 700;
  color: #1e293b;
}
.ra-stock-status-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #f8fafc;
  color: #64748b;
  font-size: 12px;
  line-height: 1.45;
}

.ra-balance-breakdown {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 12px;
}
.ra-balance-breakdown > div,
.ra-source-list > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
}
.ra-balance-breakdown strong,
.ra-source-list strong { color: var(--text-dark); white-space: nowrap; }
.ra-balance-breakdown-total {
  margin-top: 4px;
  padding-top: 6px !important;
  border-top: 1px solid #dce8e1;
  color: var(--text-dark);
  font-weight: 600;
}
.ra-source-details { margin-top: 7px; font-size: 12px; }
.ra-source-details summary { color: var(--primary); cursor: pointer; }
.ra-source-list { margin-top: 4px; padding-left: 10px; }
.ra-stock-status {
  margin: -2px 0 18px;
  padding: 14px 16px;
  border: 1px solid #dce8e1;
  border-radius: 10px;
  background: #f7faf8;
}
.ra-stock-status-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 4px 0;
  font-size: 13px;
}
.ra-stock-status-row span { color: var(--text-dark); }
.ra-stock-status-row i { color: var(--primary); margin-right: 6px; }
.ra-stock-status-row strong { white-space: nowrap; }
.ra-stock-status small {
  display: block;
  margin-top: 7px;
  color: var(--text-muted);
  line-height: 1.45;
}
.ra-damage-history-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin: 6px 0 12px;
}
.ra-damage-history-head > div:first-child { display: flex; flex-direction: column; }
.ra-damage-history-head small { color: var(--text-muted); }
.ra-damage-filter { display: flex; align-items: center; gap: 8px; width: min(100%, 430px); }
.ra-damage-filter .amfe-input { min-width: 0; padding: 8px 12px; }
.ra-damage-filter .btn-outline-amfe { padding: 8px 14px; }
.ra-damage-empty {
  padding: 22px 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  text-align: center;
  font-size: 13px;
}
.ra-damage-pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.ra-damage-pagination .btn-outline-amfe { padding: 6px 11px; }
.ra-damage-modal-dialog { width: min(1180px, calc(100vw - 32px)); max-width: 1180px; }
.ra-damage-modal-content { overflow: hidden; border-radius: 18px; }
.ra-damage-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  padding: 5px;
  border: 1px solid #dce8e1;
  border-radius: 12px;
  background: #f1f5f3;
}
.ra-damage-tabs > button,
.ra-damage-tab-btn {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #526359;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
}
.ra-damage-tabs > button:hover,
.ra-damage-tab-btn:hover {
  background: rgba(255, 255, 255, 0.65);
  color: #1e4d3a;
}
.ra-damage-tabs > button.active,
.ra-damage-tab-btn.active {
  background: #ffffff;
  color: #1e4d3a;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(24, 62, 46, 0.08), 0 1px 2px rgba(24, 62, 46, 0.04);
}
.ra-damage-tabs > button:focus-visible,
.ra-damage-tab-btn:focus-visible {
  outline: 2px solid rgba(30, 77, 58, .35);
  outline-offset: 1px;
}
.ra-damage-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e2e9e4;
  color: #5a6d62;
  font-size: 11.5px;
  font-weight: 700;
  border: 1px solid transparent;
  transition: all 0.18s ease;
}
.ra-damage-tabs > button.active .ra-damage-tab-count,
.ra-damage-tab-btn.active .ra-damage-tab-count {
  background: #e2ede6;
  color: #1e4d3a;
  border-color: #c9ded0;
}
.ra-damage-entry-card {
  padding: 22px;
  border: 1px solid #dce8e1;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(24, 62, 46, 0.04);
}
.ra-damage-toolbar {
  padding: 14px;
  border: 1px solid #dfe8e2;
  border-radius: 12px;
  background: #f8fbf9;
}
.ra-damage-search-row { display: flex; gap: 9px; }
.ra-damage-search { position: relative; flex: 1; min-width: 0; }
.ra-damage-search > i {
  position: absolute; top: 50%; left: 13px; z-index: 1;
  transform: translateY(-50%); color: #74857a; font-size: 13px;
}
.ra-damage-search input {
  width: 100%; height: 38px; padding: 8px 38px 8px 36px;
  border: 1px solid #d5e0d8; border-radius: 9px; outline: none;
  background: #fff; color: var(--text-dark); font-size: 13px;
}
.ra-damage-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30, 77, 58, .1); }
.ra-search-clear {
  position: absolute; top: 50%; right: 10px; transform: translateY(-50%);
  border: 0; background: transparent; color: #839087; font-size: 11px;
}
.ra-damage-search-btn { min-width: 90px; height: 38px; padding: 8px 16px; }
.ra-damage-filter-grid {
  display: grid; grid-template-columns: 1.15fr 1fr 1fr 1fr 1.15fr .65fr;
  gap: 10px; margin-top: 12px;
}
.ra-damage-filter-grid label { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ra-damage-filter-grid label > span { color: #607166; font-size: 10px; font-weight: 700; letter-spacing: .045em; text-transform: uppercase; }
.ra-damage-filter-grid select,
.ra-damage-filter-grid input {
  width: 100%; height: 36px; min-width: 0; padding: 7px 10px;
  border: 1px solid #d5e0d8; border-radius: 8px; outline: none;
  background-color: #fff; color: var(--text-dark); font-size: 12px;
}
.ra-damage-filter-grid select:focus,
.ra-damage-filter-grid input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30, 77, 58, .08); }
.ra-record-id { color: #476252; font-size: 11px; font-weight: 700; }
#driedStockDamageModal .table-responsive { scrollbar-width: thin; }
#driedStockDamageModal table thead th { position: sticky; top: 0; z-index: 1; white-space: nowrap; }
#driedStockDamageModal table tbody tr:hover { background: #f7faf8; }
#driedStockDamageModal .pagination-bar { margin: 0; flex-wrap: wrap; }
#driedStockDamageModal .pagination-info { display: none; }
.ra-history-card { padding: 18px 20px; }
.ra-history-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}
.ra-history-title {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-dark);
  font-size: 17px;
  font-weight: 700;
}
.ra-history-title i { color: var(--primary); }
.ra-history-subtitle {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
}
.ra-history-chevron {
  color: var(--primary);
  font-size: 18px;
  transition: transform .2s ease;
}
.ra-history-chevron.is-open { transform: rotate(180deg); }
.ra-history-panel {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.ra-allocation-history-table th { white-space: nowrap; }
@media (max-width: 576px) {
  .ra-damage-history-head { align-items: stretch; flex-direction: column; }
  .ra-damage-filter { width: 100%; }
  .ra-damage-pagination { justify-content: space-between; }
  .ra-history-card { padding: 15px 16px; }
  .ra-history-title { font-size: 15px; }
  .ra-damage-modal-dialog { width: calc(100vw - 14px); margin: 7px auto; }
  .ra-damage-modal-content { border-radius: 13px; }
  #driedStockDamageModal .modal-header,
  #driedStockDamageModal .modal-body { padding-left: 14px !important; padding-right: 14px !important; }
  .ra-damage-entry-card { padding: 15px; }
  .ra-damage-tabs > button { padding: 8px; font-size: 12px; }
  .ra-damage-search-row { align-items: stretch; flex-direction: column; }
  .ra-damage-search-btn { width: 100%; }
  .ra-damage-filter-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 577px) and (max-width: 991px) {
  .ra-damage-filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.ra-card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 18px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.ra-section-icon {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ra-section-icon i {
  font-size: 18px;
  color: var(--primary);
}

/* ===== CURRENT DEMAND LEVELS ===== */
.ra-demand-card {
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(24, 49, 38, 0.04);
}

.ra-demand-header {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f1f5f9;
}

.ra-demand-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ra-demand-icon-badge {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: #e8f5ec;
  color: #1e4d3a;
  border: 1px solid #d0e7da;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.ra-demand-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 19px;
  font-weight: 500;
  color: #183126;
  line-height: 1.25;
}

.ra-demand-sub-badge {
  font-size: 11.5px;
  color: #55685d;
  font-weight: 500;
  background: #f4f7f5;
  border: 1px solid #e2ece6;
  padding: 3px 9px;
  border-radius: 6px;
  display: inline-block;
  white-space: nowrap;
}

.ra-demand-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.ra-demand-select {
  height: 38px;
  border-radius: 9px;
  border: 1.5px solid #d0ded6;
  padding: 6px 30px 6px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #183126;
  background-color: #ffffff;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(24, 49, 38, 0.04);
}
.ra-demand-select:hover {
  border-color: #1e4d3a;
}
.ra-demand-select:focus {
  border-color: #1e4d3a;
  box-shadow: 0 0 0 3px rgba(30, 77, 58, 0.12);
}

.ra-demand-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 12.5px;
  margin-bottom: 16px;
  line-height: 1.4;
}
.ra-demand-alert i {
  font-size: 16px;
}
.ra-demand-alert-info {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}
.ra-demand-alert-warning {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  color: #92400e;
}

.ra-title-with-filters {
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

/* Demand grid */
.demand-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}

.demand-item {
  min-width: 0;
  max-width: 100%;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(24, 49, 38, 0.04);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}
.demand-item:hover {
  border-color: #a3c9b4;
  box-shadow: 0 4px 12px rgba(24, 49, 38, 0.08);
  transform: translateY(-2px);
}

.demand-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-width: 0;
  margin-bottom: 10px;
}

.demand-name {
  min-width: 0;
  flex: 1 1 auto;
  font-size: 15px;
  font-weight: 700;
  color: #183126;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.3;
}

.ra-badge {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 50px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ra-badge i {
  font-size: 11px;
}
.ra-badge-high   { background: #e8f5ec; color: #15803d; border: 1px solid #c6ebd2; }
.ra-badge-medium { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.ra-badge-low    { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

.demand-rate {
  max-width: 100%;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.demand-track {
  width: 100%;
  max-width: 100%;
  height: 8px;
  background: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}

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

.demand-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  margin-top: auto;
  border-top: 1px solid #f1f5f9;
  font-size: 11.5px;
  color: #64748b;
  line-height: 1.35;
}

.demand-footer-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .ra-demand-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: 12px;
  }
  .ra-demand-title-group {
    width: 100%;
  }
  .ra-demand-filters {
    width: 100%;
    margin-left: 0;
    display: grid;
    grid-template-columns: minmax(75px, 1fr) minmax(130px, 1.55fr);
    gap: 8px;
  }
  .ra-demand-select {
    width: 100%;
  }
}

@media (max-width: 350px) {
  .ra-demand-filters {
    grid-template-columns: 1fr;
  }
}

/* Two-column layout */
.ra-two-col {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 24px;
  align-items: start;
}
.ra-two-col-equal {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.ra-allocation-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.ra-resource-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.ra-resource-list-head {
  min-height: 44px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.ra-resource-list-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}
.ra-resource-list-controls label {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}
.ra-resource-list-controls .amfe-input {
  width: 72px;
  padding: 6px 8px;
}

.ra-right-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Allocation form */
.ra-allocate-heading {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  margin: 4px 0 14px;
}

.ra-scroll-panel {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #1b4332 #e2e8f0;
  background: #fdfdfd;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 10px 6px;
  margin-bottom: 12px;
}

/* These lists follow their content when the catalog is small, grow as
   products are added, and become independently scrollable only after the
   useful maximum is reached. This avoids both clipped products and the
   large empty boxes produced by a fixed height. */
.ra-adaptive-product-list {
  height: auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.ra-allocation-product-list {
  max-height: 360px;
}
.ra-estimates-product-list {
  max-height: 440px;
}

/* Product lists stay compact as the catalog grows. Headings, totals and save
   actions remain outside this viewport and therefore stay visible. */
.ra-product-scroll {
  height: 340px;
  max-height: 340px;
  overscroll-behavior: contain;
}
.ra-product-name {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e1e7e3;
  color: #17211c;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.ra-save-actions {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 12px;
}
.ra-save-actions .btn-primary-amfe {
  width: 100%;
  margin-top: 8px;
  padding: 10px 16px;
  border-radius: 50px;
}

.ra-scroll-panel::-webkit-scrollbar {
  width: 7px;
  display: block;
}

.ra-scroll-panel::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 8px;
}

.ra-scroll-panel::-webkit-scrollbar-thumb {
  background: #1b4332;
  border-radius: 8px;
}

.ra-scroll-panel::-webkit-scrollbar-thumb:hover {
  background: #2d6a4f;
}

.ra-scroll-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #1b4332;
  background: #e8f5e9;
  border: 1px solid #c8e6c9;
  padding: 2px 8px;
  border-radius: 20px;
}

.ra-totals {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.ra-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dark);
}

.ra-total-value {
  font-weight: 700;
  color: var(--text-dark);
}

.ra-remaining-value {
  font-weight: 700;
  color: var(--primary);
}

/* Revenue items */
.revenue-item {
  background: #f8f9fa;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.revenue-detail {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.revenue-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.06);
}

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

.revenue-metric-label {
  font-size: 11px;
  color: var(--text-muted);
}

.revenue-metric-value {
  font-size: 14px;
  font-weight: 700;
}

/* The three editable figures inside a Packaging Materials row. A 65px box
   was clipping its own value ("10.00" rendered as "10.0C"): the number
   spinner claims ~17px of a 46px content area, leaving ~29px for a string
   that needs ~34px. Suppressing the spinner buys that space back — these
   are typed, never stepped — and one shared width replaces the ragged
   65/70/65 the three inputs used to carry inline. */
.ra-metric-input {
  width: 72px;
  padding: 4px 8px;
  font-size: 13px;
}
.ra-metric-input::-webkit-outer-spin-button,
.ra-metric-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.ra-metric-input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Restock's input+button pair sits inside one revenue-metric slot, so it
   needs its own compact button — .btn-outline-amfe is sized for a
   standalone pill (e.g. "Use Suggested Split") and looked oversized and
   misaligned squeezed in next to a 72px ra-metric-input. */
.ra-restock-group {
  display: flex;
  gap: 4px;
}
/* Stays at the shared 72px ra-metric-input width, not narrowed — a
   restocked quantity can run to 3-4 digits (buying packaging in bulk),
   and a narrower box reproduces the exact clipping bug fixed above. */
.ra-restock-add {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.ra-restock-add:hover { background: var(--primary); color: #fff; }

/* Kept on space-between (same as .ra-row-summary below) so the last
   field, Cost/unit, lands on the same right edge as Balance underneath it
   — the two rows read as one aligned block instead of a ragged edge. */
.ra-packaging-inputs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding-top: 0;
  border-top: 0;
}
.ra-packaging-stock {
  padding-left: 0;
}
.ra-packaging-item {
  padding: 16px;
  border: 1px solid #dfe7e2;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(27, 67, 50, 0.04);
}
.ra-packaging-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #edf2ef;
}
.ra-packaging-item-head .ra-product-name {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 14px;
  font-weight: 700;
  color: #173829;
}
.ra-packaging-item-subtitle {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 11px;
}
.ra-packaging-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid #cde6d7;
  border-radius: 999px;
  background: #edf8f1;
  color: #166534;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.ra-packaging-status.is-short {
  border-color: #fecaca;
  background: #fff1f2;
  color: #b91c1c;
}
.ra-packaging-status i { font-size: 11px; }
.ra-packaging-field {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #dbe4de;
  border-radius: 8px;
  background: #fafcfb;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ra-packaging-field:focus-within {
  border-color: #2d6a4f;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(45, 106, 79, 0.12);
}
.ra-packaging-field .revenue-metric-label {
  min-height: 28px;
  display: flex;
  align-items: flex-end;
  font-size: 11px;
  font-weight: 600;
  color: #3b5045;
  line-height: 1.25;
}
.ra-packaging-field .ra-metric-input {
  width: 100%;
  min-width: 0;
  margin-top: 4px;
  padding: 6px 9px;
  background: #ffffff;
  border: 1px solid #ced8d2;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  color: #1e3a2b;
}
.ra-packaging-field .ra-metric-input:focus {
  border-color: #2d6a4f;
  box-shadow: none;
}
.ra-row-summary.ra-packaging-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
  padding-top: 0;
  border-top: 0;
}
.ra-packaging-summary > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 7px;
  background: #f5f8f6;
  border: 1px solid #e2ebe5;
}
.ra-packaging-summary small {
  color: #4b6354;
  font-size: 11px;
  font-weight: 500;
}
.ra-row-summary.ra-packaging-summary strong {
  font-size: 12.5px;
  font-weight: 700;
  margin-left: 0;
}
.ra-bulk-packaging-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.ra-labor-item .revenue-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}
.ra-labor-item .revenue-metric:last-child {
  align-items: flex-end;
}

.ra-resource-item {
  margin-bottom: 12px;
  border: 1px solid #dfe7e2;
  background: #ffffff;
}
.ra-resource-item:last-child { margin-bottom: 0; }

.ra-bulk-packaging-option {
  display: block;
  margin-top: 12px;
  padding: 11px 13px;
  border: 1px solid #cce3d5;
  border-radius: 9px;
  background: #f4fbf7;
  color: #3b5045;
  font-size: 11.5px;
}
.ra-bulk-packaging-option strong { color: var(--primary); }
.ra-bulk-packaging-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 9px;
  padding-bottom: 7px;
  border-bottom: 1px dashed #d1e5db;
}
.ra-bulk-packaging-result {
  color: #4b6354;
  font-size: 11.5px;
  text-align: right;
}
.ra-bulk-packaging-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}
.ra-bulk-packaging-stats > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid #d5e5dc;
}
.ra-bulk-packaging-stats small {
  color: #64748b;
  font-size: 10.5px;
  font-weight: 500;
}
.ra-bulk-packaging-stats strong {
  font-size: 12px;
  font-weight: 700;
}
.ra-bulk-packaging-title {
  color: #1e4d3a;
  font-weight: 700;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ra-bulk-packaging-title i { margin-right: 2px; }

.ra-resource-card .ra-product-scroll {
  height: auto;
  min-height: 410px;
  max-height: 600px;
  flex: 1 1 auto;
}
.ra-resource-card .ra-product-scroll:has(.ra-resource-item):not(:has(.ra-resource-item:nth-child(5))) {
  display: flex;
  flex-direction: column;
}
.ra-resource-card .ra-product-scroll:has(.ra-resource-item):not(:has(.ra-resource-item:nth-child(5))) .ra-resource-item {
  flex: 1 0 auto;
}
.ra-resource-card .ra-product-scroll .ra-packaging-item {
  flex: 0 0 auto !important;
}

@media (max-width: 1200px) {
  .ra-packaging-inputs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ra-packaging-stock { padding-left: 0; }
  .ra-bulk-packaging-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .ra-packaging-inputs,
  .ra-bulk-packaging-inputs { grid-template-columns: 1fr; }
  .ra-packaging-item-head,
  .ra-bulk-packaging-head { align-items: stretch; flex-direction: column; }
  .ra-packaging-status { align-self: flex-start; }
  .ra-bulk-packaging-result { text-align: left; }
  .ra-bulk-packaging-stats { grid-template-columns: 1fr; }
}

/* Labor's Planned kg sits in the input row rather than on a summary line
   of its own: with a single input per product, a third stacked line per row
   was pure height — three rows of it ran the Labor card past the Packaging
   card sharing its equal-height grid row. Right-aligned so it lands on the
   same edge as Packaging's Cost/unit column opposite it. */
.ra-labor-planned {
  align-items: flex-end;
  text-align: right;
}
.ra-labor-planned-value {
  padding: 4px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dark);
}

/* Needed/Balance (Packaging) are read-only results, not more fields to
   edit — pulling them out of the four-input row and onto their own quiet
   line keeps the two kinds of information from reading as one
   undifferentiated row of boxes. Labor, with a single input, has no row to
   be mistaken for and keeps its one result inline instead (above). */
.ra-row-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.ra-row-summary strong {
  margin-left: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dark);
}

.revenue-total-box {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  color: #fff;
  margin-top: 4px;
}

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

.revenue-summary-item {
  min-width: 0;
}

.revenue-summary-grid .revenue-total-amount {
  font-size: 18px;
}

.ra-cost-breakdown {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.22);
  font-size: 11px;
}

.ra-cost-breakdown summary {
  cursor: pointer;
  font-weight: 700;
}

.ra-cost-breakdown-note {
  margin: 8px 0;
  color: rgba(255,255,255,0.8);
  line-height: 1.35;
}

.ra-cost-breakdown-reference {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 6px;
  background: rgba(0,0,0,0.12);
}

.ra-cost-breakdown-reference div,
.ra-cost-breakdown-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.ra-cost-breakdown-row {
  padding: 4px 0;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.ra-financial-projection {
  margin-top: 12px;
  padding: 16px 18px;
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
}

.ra-card-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #eef7f2;
  color: #1b4332;
  font-size: 15px;
  flex-shrink: 0;
}
.ra-card-icon-badge i {
  color: #1b4332 !important;
}

.ra-subheading-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #557262;
}

.ra-output-table-wrap {
  border: 1px solid #dce8e1;
  border-radius: 12px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}
.ra-output-table-wrap .ra-scroll-panel {
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 0;
  margin-bottom: 0;
}

.ra-bulk-estimate {
  margin: 0 0 14px;
  border: 1px solid #d5e5dc;
  border-radius: 12px;
  background: #fbfdfc;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.ra-bulk-estimate summary {
  outline: none !important;
}
.ra-bulk-estimate summary:focus,
.ra-bulk-estimate summary:focus-visible {
  outline: none !important;
  box-shadow: 0 0 0 2px rgba(45, 106, 79, 0.25) !important;
}

.ra-bulk-estimate-title {
  display: flex;
  align-items: center;
  padding: 11px 14px;
  color: #1b4332;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  background: #f7faf8;
  border-bottom: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
  user-select: none;
}
.ra-bulk-estimate[open] .ra-bulk-estimate-title {
  border-bottom-color: #e2ede6;
  background: #f4f8f5;
}

.ra-bulk-estimate-title::-webkit-details-marker { display: none; }
.ra-bulk-estimate-title::after {
  content: '›';
  margin-left: 10px;
  font-size: 18px;
  line-height: 1;
  transform: rotate(90deg);
  transition: transform .15s ease;
  color: #4b6b57;
  font-weight: 700;
}
.ra-bulk-estimate[open] .ra-bulk-estimate-title::after { transform: rotate(-90deg); }

.ra-bulk-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-grow: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.ra-bulk-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: #e8f3ed;
  color: #1b4332;
  font-size: 13px;
}

.ra-bulk-label {
  font-weight: 700;
  color: #1b4332;
  font-size: 13.5px;
}

.ra-bulk-estimate-rule {
  color: #4b6353;
  font-size: 11px;
  font-weight: 500;
  background: #e9f2ec;
  border: 1px solid #d5e5dc;
  padding: 2px 8px;
  border-radius: 12px;
}

.ra-bulk-estimate-body {
  padding: 12px 14px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ra-bulk-estimate-note {
  margin: 3px 0 8px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.35;
}

.ra-bulk-estimate-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 11px 13px;
  border: 1px solid #e3ece6;
  border-radius: 8px;
  background: #fafcfb;
  font-size: 12px;
  transition: border-color 0.15s ease;
}
.ra-bulk-estimate-row:hover {
  border-color: #cbdcd0;
}

.ra-bulk-row-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.ra-bulk-prod-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ra-bulk-prod-name {
  font-size: 13px;
  font-weight: 700;
  color: #1f2937;
}
.ra-bulk-allocated-text {
  font-size: 11.5px;
  color: #6b7280;
}

.ra-bulk-estimate-result {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.ra-bulk-badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 14px;
  letter-spacing: 0.01em;
}
.ra-bulk-badge.active {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.ra-bulk-badge.zero {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #e5e7eb;
}

.ra-bulk-covered-text {
  font-size: 11px;
  font-weight: 600;
  color: #4b5563;
}

.ra-bulk-status-line {
  font-size: 11.5px;
}
.ra-bulk-remainder-alert {
  display: inline-flex;
  align-items: center;
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fef3c7;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 500;
}
.ra-bulk-remainder-quiet {
  color: #6b7280;
  font-size: 11px;
}

.ra-output-table-head,
.ra-output-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.4fr) minmax(90px, 1fr) minmax(75px, 0.8fr) minmax(85px, 0.8fr);
  gap: 10px;
  align-items: center;
}

.ra-output-table-head {
  padding: 10px 14px;
  background: #f7faf8;
  border-bottom: 1px solid #e5ede8;
  color: #557262;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ra-output-row {
  padding: 11px 14px;
  border-top: 1px solid #edf3ef;
  font-size: 13px;
  transition: background 0.15s ease;
}

.ra-output-row:first-child { border-top: 0; }
.ra-output-row:hover { background: #fbfdfc; }

.ra-output-prod-name {
  color: #1e293b;
  font-weight: 600;
  font-size: 13.5px;
}

.ra-output-cell-kg,
.ra-output-cell-units,
.ra-output-cell-pkg {
  display: flex;
  flex-direction: column;
}
.ra-output-cell-kg {
  align-items: flex-end;
}
.ra-output-num {
  font-weight: 700;
  color: #1f2937;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.ra-remainder-badge {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  margin-top: 4px;
  padding: 2px 7px 2px 6px;
  border: 1px solid #fde7ae;
  border-radius: 999px;
  background: #fffbeb;
  color: #9a5b09;
  font-size: 9.5px;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
}
.ra-remainder-badge strong {
  color: #b45309;
  font-size: inherit;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ra-remainder-dot {
  flex: 0 0 auto;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 2px #fef3c7;
}

.ra-output-cell-units,
.ra-output-cell-pkg {
  align-items: flex-end;
}
.ra-output-pill {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  font-weight: 700;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  padding: 2px 8px;
  border-radius: 6px;
}
.ra-output-pill.units {
  background: #eef7f2;
  color: #1b4332;
  border: 1px solid #d0e7da;
}
.ra-output-pill.pkg {
  background: #f3f6f4;
  color: #374151;
  border: 1px solid #e2e8e5;
}

.ra-output-row small:not(.ra-remainder-badge) { display: none; }

.ra-output-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 16px;
  border: 1px solid #c9e2d3;
  border-radius: 10px;
  color: #1b4332;
  background: linear-gradient(135deg, #f0f7f3 0%, #e8f4ed 100%);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
}
.ra-output-total strong {
  font-size: 22px;
  font-weight: 800;
  color: #143823;
  font-variant-numeric: tabular-nums;
}

.ra-financial-projection .revenue-total-label,
.ra-financial-projection .ra-financial-note,
.ra-financial-projection .ra-financial-sub-label,
.ra-financial-projection .ra-cost-breakdown-note,
.ra-financial-projection .ra-cost-breakdown-child {
  color: rgba(255,255,255,0.78);
}
.ra-financial-projection .revenue-total-amount { color: #fff; }
.ra-financial-projection .revenue-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.ra-financial-projection .revenue-summary-item {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 11px 10px;
  min-width: 0;
}
.ra-financial-projection .revenue-total-label {
  font-size: 11.5px;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 4px;
  min-height: 28px;
  display: flex;
  align-items: flex-end;
}
.ra-financial-projection .revenue-total-amount {
  margin-top: auto;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ra-financial-projection .ra-cost-breakdown { border-top-color: rgba(255,255,255,0.22); }
.ra-financial-projection .ra-cost-breakdown-reference { background: rgba(0,0,0,0.12); }
.ra-financial-projection .ra-cost-breakdown-row { border-top-color: rgba(255,255,255,0.12); }

.ra-historical-summary {
  width: 100%;
  background: #ffffff;
  border: 1.5px solid #d0e7da;
  border-radius: 16px;
  padding: 24px 26px;
  box-shadow: 0 1px 4px rgba(24, 49, 38, 0.04);
  margin-bottom: 1.5rem;
}

.ra-historical-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f1f5f9;
}

.ra-historical-icon-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #e8f5ec;
  color: #1e4d3a;
  border: 1px solid #d0e7da;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.ra-historical-title-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.ra-historical-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 20px;
  font-weight: 500;
  color: #183126;
  margin: 0;
  line-height: 1.25;
}

.ra-historical-subtitle {
  font-size: 13px;
  color: #64748b;
  font-weight: 400;
  display: block;
  margin-top: 3px;
}

.ra-history-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 9999px;
  white-space: nowrap;
}

.ra-history-pill--reconciled {
  background: #e6f4ea;
  color: #137333;
  border: 1px solid #b7e1cd;
}

.ra-history-pill--locked {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

/* Callout Banner */
.ra-history-banner {
  background: linear-gradient(135deg, rgba(45, 106, 79, 0.05) 0%, rgba(82, 183, 136, 0.09) 100%);
  border: 1px solid rgba(45, 106, 79, 0.18);
  border-left: 4px solid #2d6a4f;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 22px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.ra-history-banner-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #ffffff;
  color: #2d6a4f;
  border: 1px solid rgba(45, 106, 79, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  margin-top: 1px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ra-history-banner-body {
  flex: 1;
  min-width: 0;
}

.ra-history-banner-title {
  font-size: 14px;
  font-weight: 700;
  color: #183126;
  line-height: 1.35;
  margin-bottom: 2px;
}

.ra-history-banner-desc {
  font-size: 13px;
  color: #4b6354;
  line-height: 1.45;
}

.ra-history-banner-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 8px;
  background: #ffffff;
  color: #2d6a4f;
  border: 1px solid rgba(45, 106, 79, 0.2);
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

/* Metric Cards */
.ra-history-card {
  height: 100%;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
}

.ra-history-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(24, 49, 38, 0.06);
  border-color: #cbd5e1;
}

.ra-history-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.ra-history-card-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  letter-spacing: 0.2px;
  line-height: 1.3;
}

.ra-history-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.ra-history-card-icon--green {
  background: #e8f5ec;
  color: #1e4d3a;
  border: 1px solid #cce5d6;
}

.ra-history-card-icon--blue {
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
}

.ra-history-card-icon--amber {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.ra-history-card-icon--emerald {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.ra-history-card-value {
  font-size: 24px;
  font-weight: 700;
  color: #183126;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  margin-bottom: 10px;
  white-space: nowrap;
}

.ra-history-card-unit {
  font-size: 15px;
  font-weight: 500;
  color: #64748b;
  margin-left: 3px;
}

.ra-history-card-sub {
  margin-top: auto;
  font-size: 11.5px;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding-top: 10px;
  border-top: 1px dashed #e9edf1;
}

.ra-history-card-sub i {
  font-size: 12px;
}

/* Reconciliation Strip / Footnote */
.ra-history-strip {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 20px;
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}

.ra-history-strip-items {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
}

.ra-history-strip-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.ra-history-strip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ra-history-strip-label {
  color: #64748b;
  font-weight: 500;
}

.ra-history-strip-val {
  color: #183126;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ra-history-strip-badge {
  font-size: 11px;
  font-weight: 600;
  background: #e6f4ea;
  color: #137333;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid #b7e1cd;
}

.ra-history-strip-badge--muted {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.ra-history-strip-divider {
  width: 1px;
  height: 18px;
  background: #cbd5e1;
}

.ra-history-strip-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: #1e4d3a;
  background: #ffffff;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid #d0e7da;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

/* Fallback for legacy class references */
.ra-history-metric {
  height: 100%;
  padding: 16px;
  border: 1px solid #dce8e1;
  border-radius: 12px;
  background: #f8fbf9;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ra-history-metric span,
.ra-history-footnote span {
  color: var(--text-muted);
  font-size: 12px;
}
.ra-history-metric strong {
  color: var(--primary-green);
  font-size: 20px;
}
.ra-history-footnote {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #e5e7eb;
  display: grid;
  grid-template-columns: max-content max-content max-content max-content;
  align-items: center;
  gap: 8px 16px;
}

@media (max-width: 768px) {
  .ra-historical-summary {
    padding: 18px 16px;
  }
  .ra-history-strip {
    flex-direction: column;
    align-items: flex-start;
  }
  .ra-history-strip-divider {
    display: none;
  }
  .ra-history-strip-items {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    width: 100%;
  }
  .ra-history-strip-status {
    width: 100%;
    justify-content: center;
  }
  .ra-history-footnote { grid-template-columns: 1fr auto; }
}

@media (max-width: 576px) {
  .ra-output-table-head { display: none; }
  .ra-output-row {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
  }
  .ra-output-row > strong { grid-column: 1 / -1; }
  .ra-output-row small:not(.ra-remainder-badge) {
    display: block;
    margin-bottom: 2px;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 500;
  }
  .ra-output-cell-kg,
  .ra-output-cell-units,
  .ra-output-cell-pkg {
    align-items: flex-start;
    text-align: left;
  }
  .ra-remainder-badge { justify-content: flex-start; }
  .ra-output-pill { justify-content: flex-start; }
  .ra-bulk-title-wrap { flex-direction: column; align-items: flex-start; gap: 4px; }
  .ra-bulk-estimate-rule { width: 100%; }
  .ra-bulk-row-main { flex-direction: column; align-items: flex-start; }
  .ra-bulk-estimate-result { align-items: flex-start; }
  .ra-financial-projection .revenue-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 420px) {
  .ra-financial-projection .revenue-summary-grid { grid-template-columns: 1fr; }
}

.ra-financial-heading {
  font-size: 14px;
  font-weight: 700;
}

.ra-financial-note,
.ra-financial-sub-label {
  margin-top: 3px;
  color: rgba(255,255,255,0.78);
  font-size: 10px;
  line-height: 1.35;
}

.ra-financial-note {
  margin-bottom: 12px;
}

.ra-cost-breakdown-child {
  padding-left: 14px;
  color: rgba(255,255,255,0.82);
  border-top-style: dashed;
}

/* Expected Product Output container stretches to match Allocation Input
   height, while letting the product rows and summary sections adapt
   proportionally so neither card leaves an awkward empty space. */
.ra-revenue-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.ra-revenue-card .ra-output-table-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  min-height: 0;
}

.ra-revenue-card .ra-estimates-product-list {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: stretch;
}

.ra-revenue-card .ra-output-row {
  flex: 1 1 0;
  display: grid;
  align-items: center;
  padding: 13px 14px;
  min-height: 52px;
}

.ra-revenue-card .ra-bulk-estimate {
  margin: 0 0 12px;
  flex-shrink: 0;
}

.ra-revenue-card .ra-expected-bottom-section {
  margin-top: auto;
  flex-shrink: 0;
}

.ra-revenue-card .ra-output-total {
  margin-bottom: 10px;
}

.ra-revenue-card .revenue-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 78px;
}

.ra-revenue-card .revenue-total-box {
  margin-top: auto !important;
  flex: 0 0 auto;
}

.revenue-total-label {
  font-size: 13px;
  opacity: 0.85;
  margin-bottom: 4px;
}

.revenue-total-amount {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

/* Suggested Allocation */
.suggested-box {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  background: #ffffff;
  border: 1.5px solid #d0e7da;
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: 0 1px 4px rgba(24, 49, 38, 0.04);
}

.suggested-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f1f5f9;
}

.suggested-icon-badge {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: #e8f5ec;
  color: #1e4d3a;
  border: 1px solid #d0e7da;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.suggested-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 19px;
  font-weight: 500;
  color: #183126;
  margin: 0;
  line-height: 1.25;
  display: flex;
  align-items: center;
  gap: 8px;
}

.suggested-subtitle {
  font-size: 12px;
  color: #64748b;
  font-weight: 400;
  display: block;
  margin-top: 2px;
}

.btn-apply-suggested {
  min-height: 38px;
  border-radius: 50px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  background: #1e4d3a;
  color: #ffffff;
  border: 1.5px solid #1e4d3a;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(30, 77, 58, 0.18);
  cursor: pointer;
  white-space: nowrap;
}
.btn-apply-suggested:hover {
  background: #15382a;
  border-color: #15382a;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(30, 77, 58, 0.25);
  color: #ffffff;
}

.suggested-rows-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
  min-width: 0;
}

.suggested-row {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  transition: all 0.2s ease;
}
.suggested-row:hover {
  border-color: #a3c9b4;
  background: #f4fbf7;
  transform: translateY(-1px);
}

.suggested-row span:first-child {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-weight: 600;
  color: #334155;
}

.suggested-row span:last-child {
  flex: 0 0 auto;
  max-width: 45%;
  font-weight: 700;
  font-size: 15px;
  color: #183126;
  text-align: right;
  white-space: nowrap;
}

.suggested-table-wrap {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
}

.suggested-table {
  width: 100%;
  margin-bottom: 0;
  border-collapse: separate;
  border-spacing: 0;
}

.suggested-table thead th {
  background: #f8fafc;
  color: #55685d;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  border-bottom: 1.5px solid #e2e8f0;
}

.suggested-table tbody td {
  padding: 12px 14px;
  font-size: 13px;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
}
.suggested-table tbody tr:last-child td {
  border-bottom: none;
}
.suggested-table tbody tr:hover td {
  background: #fbfdfc;
}

.suggested-product-name {
  font-weight: 600;
  color: #183126;
}

.suggested-diff-badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 50px;
  display: inline-block;
}
.suggested-diff-badge.pos {
  background: #e8f5ec;
  color: #15803d;
  border: 1px solid #c6ebd2;
}
.suggested-diff-badge.neg {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.suggested-desc {
  max-width: 100%;
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

@media (max-width: 768px) {
  .suggested-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .btn-apply-suggested {
    width: 100%;
    justify-content: center;
  }
  .suggested-rows-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

/* Resource Allocation Responsive */
@media (max-width: 991px) {
  /* Demand grid: 2 cols, last item (Chichalunggay) full-width */
  .demand-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .demand-item:last-child { grid-column: 1 / -1; }
  /* Two-col layout → single column */
  .ra-two-col { grid-template-columns: 1fr; }
  .ra-allocation-card,
  .ra-revenue-card { height: auto; min-height: 0; }
  .ra-two-col-equal { grid-auto-rows: auto; align-items: start; }
  .ra-revenue-card .ra-output-table-wrap { flex: none; }
  .ra-revenue-card .ra-estimates-product-list { flex: none; }
  .ra-revenue-card .ra-output-row { flex: none; min-height: auto; padding: 11px 14px; }
  .ra-revenue-card .ra-expected-bottom-section { margin-top: 14px; }
}

@media (max-width: 576px) {
  /* Demand grid: all single column */
  .demand-grid { grid-template-columns: 1fr; }
  .demand-item:last-child { grid-column: auto; }
  .demand-item { padding: 13px 14px; }
  .demand-header { gap: 10px; }
  .demand-name { font-size: 13.5px; }
  .ra-badge { font-size: 11px; }
  /* Revenue numbers smaller on phone */
  .revenue-metric-value { font-size: 12.5px; }
  .revenue-total-amount { font-size: 20px; }
  /* Allocation card inner spacing */
  .ra-totals { margin-top: 2px; }
  .ra-resource-list-head { align-items: flex-start; flex-direction: column; }
  .ra-resource-list-controls { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .suggested-box { padding: 14px 16px; }
  .suggested-row { align-items: flex-start; padding: 10px 12px; }
  .suggested-row span:last-child { max-width: 38%; }
  .suggested-box .btn-outline-amfe {
    max-width: 100%;
    white-space: normal;
  }
}

/* ===== INBOX ===== */
.inbox-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.inbox-item:hover { background: var(--primary-bg); }
.inbox-item.active { background: var(--primary-bg); border-left: 3px solid var(--primary); }
/* Inquiries never carry a photo (public catalog visitors, not registered
   members) — this is the initials fallback, always shown. */
.inbox-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
}
.inbox-item-body { flex: 1; min-width: 0; }
.inbox-sender { font-weight: 600; font-size: 13.5px; }
.inbox-preview { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-time { font-size: 11px; color: var(--text-light); flex-shrink: 0; }

.chat-bubble {
  background: var(--primary-bg);
  border-radius: 8px 8px 8px 0;
  padding: 10px 14px;
  font-size: 13px;
  max-width: 80%;
  margin-bottom: 6px;
}

/* ===== FOOTER ===== */
footer.admin-footer {
  background: var(--primary);
  color: rgba(255,255,255,0.75);
  text-align: center;
  padding: 14px 30px;
  font-size: 12px;
  margin-left: var(--sidebar-width);
}
footer.admin-footer strong { color: #fff; }

/* ===== RESPONSIVE =====
   The drawer itself (off-canvas position, transform, overlay) is owned by
   role-shell.css at <=991px, which is where the hamburger appears. This block
   used to stop at 768px and carry its own `.sidebar.open` rule, so between
   769-991px — iPad portrait, phone landscape — role-shell pushed the sidebar
   off-screen and nothing brought it back: no navigation at all on those sizes.
   The width now matches role-shell's, and the open state uses the same `show`
   class the farmer and entrepreneur shells use. */
@media (max-width: 991px) {
  .main-content, footer.admin-footer { margin-left: 0; }
}

/* ===== MISC ===== */
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; flex-wrap: wrap; gap: 10px;
}
.section-label {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 10px;
}
.rank-circle {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.green-text { color: var(--primary); }
.divider { border-top: 1px solid var(--border); margin: 14px 0; }
.text-sm { font-size: 12px; }
.fw-semibold { font-weight: 600; }

/* ===== SALES & INVENTORY PAGE HEADER ===== */
.si-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.si-page-header--topbar { padding-right: 0 !important; }

@media (max-width: 991px) {
  /* Keep the page title on its own row at tablet widths. */
  .si-page-header {
    display: block;
  }
}

/* On phones, the header "Add" button(s) collapse into a single floating
   toggle (matching the Catalog page's chat FAB) instead of sitting in
   the header row. One add action opens straight to its form; two (Sales
   & Inventory's Add Expense / Add Sale) show a small choice menu first. */
.mobile-add-fab,
.mobile-add-menu { display: none; }
@media (max-width: 576.98px) {
  .si-topbar-add { display: none !important; }
  .prod-header .si-add-btn,
  .si-page-header .si-add-btn { display: none !important; }

  .mobile-add-fab {
    display: flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    right: 16px;
    bottom: 20px;
    z-index: 1035;
    padding: 12px 18px;
    border-radius: 50px;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
    transition: transform 0.15s ease;
  }
  .mobile-add-fab:active { transform: scale(0.95); }
  .mobile-add-fab i { font-size: 18px; }

  /* The FAB floats over the very bottom of the page, so whatever lands
     last — Production's "Recorded Dried Batches" heading and its Show
     toggle — sat underneath it with no page left to scroll. Reserve the
     FAB's height at the end of any page that renders one; !important and
     the extra specificity are what it takes to beat the blanket phone
     padding in role-shell.css / responsive.css, which load after this. */
  .main-content.has-mobile-fab,
  .main-content:has(.mobile-add-fab),
  .main-content:has(.ra-floating-add),
  .main-content:has(.mobile-add-menu),
  #main-content.has-mobile-fab,
  #main-content:has(.mobile-add-fab),
  #main-content:has(.ra-floating-add),
  #main-content:has(.mobile-add-menu),
  body.admin-shell .admin-main.has-mobile-fab,
  body.admin-shell .admin-main:has(.mobile-add-fab),
  body.admin-shell .admin-main:has(.ra-floating-add),
  body.admin-shell .admin-main:has(.mobile-add-menu),
  body.admin-shell .admin-main:has(#productList) {
    padding-bottom: calc(72px + env(safe-area-inset-bottom)) !important;
  }

  .mobile-add-menu {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    position: fixed;
    right: 16px;
    bottom: 78px;
    z-index: 1034;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  }
  .mobile-add-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  .mobile-add-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 50px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-dark);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.15);
    white-space: nowrap;
  }
  .mobile-add-menu button i { color: var(--primary); font-size: 15px; }
}

/* ===== MEMBERS FILTER BAR ===== */
.members-filter-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* Flex items default to min-width:auto, which refuses to shrink below the
   search input's own content size — that pinned .search-wrap at a wide
   natural width and pushed .members-filter-selects (2 selects + reset +
   download) off the right edge with nothing left to give it. */
.members-filter-row .search-wrap { min-width: 0; }
.members-filter-selects {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.members-filter-selects .filter-select { flex: 1; min-width: 120px; }
.btn-link-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background-color: #fff;
  border: 1.5px solid var(--border);
  border-radius: 50px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.2;
}
.btn-link-reset:hover {
  background-color: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
  text-decoration: none;
  box-shadow: 0 1px 4px rgba(220, 38, 38, 0.08);
}
.btn-link-reset:active {
  transform: scale(0.97);
}
.btn-link-reset:focus-visible {
  outline: none;
  border-color: #fca5a5;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}
.btn-link-reset i {
  font-size: 13px;
  line-height: 1;
  transition: transform 0.25s ease;
}
.btn-link-reset:hover i {
  transform: rotate(-180deg);
}
.members-download-btn { padding: 8px 14px; }

@media (min-width: 640px) {
  .members-filter-row { flex-direction: row; align-items: center; }
  /* Not nowrap: at tablet widths (iPad Mini's 768px portrait included) the
     sidebar is already off-canvas, but the row still has to fit a search
     box + 2 selects + reset link + download button — nowrap forced that
     into a single line with nothing left to give, so the selects/reset/
     download silently ran off the right edge (body hides x-overflow).
     Plain wrap keeps one row wherever there's room (desktop) and drops
     the overflow onto its own line wherever there isn't (tablet). */
  .members-filter-selects { flex-wrap: wrap; row-gap: 8px; }
}

/* Below 640px .members-filter-row stacks (search on its own row), and
   Type/Status/Download used to wrap onto two lines of their own because
   each kept its full desktop size. Shrink them just enough that all
   three share one line even on a narrow phone — flex-wrap stays on as a
   safety net for anything narrower than that. */
@media (max-width: 639.98px) {
  .members-filter-selects { gap: 6px; }
  .members-filter-selects .filter-select {
    min-width: 0;
    flex: 1 1 0;
    font-size: 12px;
    padding: 6px 20px 6px 8px;
    background-position: right 7px center;
  }
  /* Download keeps its natural (content) width instead of sharing space
     equally with the two selects — "Download" was truncating to
     "Downloa…" at an even 1/3 split. Letting it size to content and
     giving the selects the leftover room (still shrinkable, still
     wrapping if it ever gets too tight) keeps the word whole. */
  .members-filter-selects .dropdown { flex: 0 0 auto; min-width: 0; }
  .members-download-btn {
    padding: 6px 10px;
    font-size: 12px;
    white-space: nowrap;
  }
}

/* ================================================
   RESPONSIVE STYLES
================================================ */

/* ── ≤ 991px (tablet + mobile) ───────────────── */
@media (max-width: 991px) {

  /* Cards */
  .amfe-card { padding: 16px; }

  /* Page title */
  .page-title { font-size: 24px; margin-bottom: 16px; }

  /* Resource Allocation: gap tighter when stacked */
  .ra-two-col { gap: 16px; }

  /* Messages layout → stack on tablet */
  .messages-layout { flex-direction: column; height: auto; min-height: unset; }
  .inbox-panel { width: 100%; height: 260px; }
  .chat-panel { min-height: 380px; }

  /* Analytics tabs: tighter gap on tablet */
  .ana-tabs { gap: 6px; }

  /* Payroll: .page-title is pulled into the fixed top bar (role-shell.css),
     so the div that held it is an empty flex item and the month picker is
     all that is left in the header. Pin it to the right, the way it sits on
     desktop, instead of leaving it to whatever the leftover flex layout
     resolves to.
     !important is load-bearing, not laziness: the element carries Bootstrap's
     `justify-content-between` and `align-items-start` utilities, and every
     Bootstrap utility declares !important — a plain rule here loses to them
     no matter how specific it is. */
  .payroll-header {
    justify-content: flex-end !important;
    align-items: flex-end !important;
  }

}

/* ── ≤ 768px (mobile) ─────────────────────────── */
@media (max-width: 768px) {

  /* Stat cards fill their Bootstrap column */
  .stat-card { width: 100%; padding: 24px 16px; }
  .stat-card .stat-value { font-size: 18px; }

  /* Tables: horizontal scroll already via .table-responsive */

  /* Filter bar wrap. Bootstrap's .align-items-end utility (used by
     .activity-filter-bar) carries !important, so cross-axis alignment
     needs it too here — flex-direction:column flips cross-axis to
     horizontal, and without !important flex-end wins, right-aligning
     every stacked control instead of stretching them full-width. */
  .amfe-card .d-flex.flex-wrap { flex-direction: column; align-items: stretch !important; }

  /* Members action buttons stack */
  .amfe-table tbody td.d-flex { flex-wrap: wrap; gap: 4px; }

  /* Products grid → 2 cols */
  .products-grid { grid-template-columns: repeat(2, 1fr); }

  /* Product card vertical */
  .product-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .product-actions { width: 100%; }

  /* Modal full-width on small screens */
  .modal-dialog { margin: 8px; }

  /* RA right col tighter gap on mobile */
  .ra-right-col { gap: 12px; }

}

/* ── Messages: panel-toggle on phone (< 768px) ── */
@media (max-width: 767px) {

  .messages-layout {
    position: relative;
    overflow: hidden;
    height: calc(100dvh - 136px);
    flex-direction: row;
    gap: 0;
  }

  /* Both panels fill the container, stacked by transform */
  .inbox-panel,
  .chat-panel {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
    transition: transform 0.3s ease;
    min-height: unset;
  }

  /* Default: inbox visible, chat hidden to the right */
  .inbox-panel { transform: translateX(0); z-index: 2; }
  .chat-panel  { transform: translateX(100%); z-index: 2; }

  /* chat-open: inbox slides out left, chat slides in */
  .messages-layout.chat-open .inbox-panel { transform: translateX(-100%); }
  .messages-layout.chat-open .chat-panel  { transform: translateX(0); }

  /* Back button — visible only on mobile */
  .chat-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    border: none;
    background: var(--primary-bg);
    color: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 16px;
  }

}

/* ── ≤ 576px (small mobile) ──────────────────── */
@media (max-width: 576px) {

  /* Stat cards fill column, tighter padding on small screens */
  .stat-card { width: 100%; padding: 20px 14px; }
  .stat-card .stat-value { font-size: 17px; }

  /* Dashboard stat cards: first card (Total Members) spans full width,
     the remaining four fall into a 2x2 grid beneath it — phone-only,
     tablet/desktop keep the plain Bootstrap row-cols layout. */
  .dash-stats-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 1.5rem;
    width: 100%;
    min-width: 0;
  }
  .dash-stats-row > .col {
    min-width: 0;
    width: auto;
    max-width: none;
    flex: none;
    padding: 0;
    /* Bootstrap 5 spaces `g-3` rows with `margin-top` on the children, not
       padding — and .row's compensating `margin-top: calc(-1 * gutter-y)`
       is overwritten by the `margin: 0 0 1.5rem` above. So every .col kept
       an uncancelled 16px on top: it stacked under the fixed top bar and
       widened each grid row gap to 28px where `gap` asks for 12px. The
       `padding: 0` above never touched it. */
    margin-top: 0;
  }
  .dash-stats-row > .col:first-child {
    grid-column: 1 / -1;
  }
  .dash-stats-row .stat-card { height: 100%; }
  .dash-stats-row .stat-card {
    min-width: 0;
    max-width: 100%;
    gap: 10px;
  }
  .dash-stats-row .stat-card > div:first-child { min-width: 0; }
  .dash-stats-row .stat-label {
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .dashboard-sections-row {
    width: 100%;
    min-width: 0;
    margin-right: 0;
    margin-left: 0;
  }
  .dashboard-sections-row > [class*="col-"] {
    min-width: 0;
    padding-right: 0;
    padding-left: 0;
  }
  .dashboard-sections-row .amfe-card {
    min-width: 0;
    max-width: 100%;
  }
  .dashboard-farmer-name,
  .activity-item {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* Products grid → single col */
  .products-grid { grid-template-columns: 1fr; }

  /* Page title smaller */
  .page-title { font-size: 22px; }

  /* Modal padding */
  .modal-body { padding: 14px; }
  .modal-header { padding: 12px 14px; }
  .modal-footer { padding: 10px 14px; }

  /* Insight boxes */
  .insight-box { padding: 14px 16px; }

  /* Payroll header: keep title and settings button side-by-side */
  .payroll-header { flex-direction: row; align-items: center !important; justify-content: space-between !important; }
  .payroll-header input[type="month"] { width: auto !important; }

  /* Payroll summary cards: single column so peso figures never get
     squeezed into a ~140px-wide half card. */
  .payroll-cards > [class*="col-"] { flex: 0 0 100%; max-width: 100%; }

  /* Org Deductions rows: let the label/badge group wrap onto its own
     line above the value instead of overflowing sideways. */
  .payroll-deduction-row { flex-wrap: wrap; row-gap: 4px; }

  /* Equation card in cost breakdown: stack operands on mobile */
  .payroll-formula-cards {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  /* Period Summary rows: same — long labels (e.g. "Dried Malunggay
     (Himay + Bilad/Giling)") wrap instead of squeezing the value. */
  .payroll-summary-list > div { flex-wrap: wrap; row-gap: 4px; }

}

/* ── Members table → card layout (≤ 640px) ─── */
@media (max-width: 640px) {

  /* Remove the card's overflow so cards inside can breathe */
  #membersTable,
  #membersTable tbody {
    display: block;
  }

  /* Hide thead */
  #membersTable thead { display: none; }

  /* Each row = a card */
  #membersTable tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 14px;
    background: #fff;
  }

  /* Each cell = label + value row */
  #membersTable tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13px;
    border-right: none;
  }

  /* Auto label from data-label attribute */
  #membersTable tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    flex-shrink: 0;
    min-width: 88px;
  }

  /* Name row — bigger, no label */
  #membersTable tbody td[data-label="Name"] {
    font-size: 15px;
    font-weight: 700;
    border-bottom: 1.5px solid var(--border);
    padding-bottom: 10px;
    margin-bottom: 2px;
  }
  #membersTable tbody td[data-label="Name"]::before { display: none; }

  /* Actions row — full-width buttons */
  #membersTable tbody td.members-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 10px;
    border-bottom: none;
    justify-content: flex-start;
  }
  #membersTable tbody td.members-actions::before { display: none; }
  #membersTable tbody td.members-actions .btn-primary-amfe,
  #membersTable tbody td.members-actions .btn-approve-amfe,
  #membersTable tbody td.members-actions .btn-outline-amfe,
  #membersTable tbody td.members-actions .btn-danger-amfe {
    flex: 1 1 0;
    width: auto;
    min-height: 44px;
    text-align: center;
    justify-content: center;
    min-width: 0;
    padding-inline: 6px;
  }

  /* Main tables converted to cards — disable horizontal scroll wrapper */
  #membersTable ~ .table-responsive,
  #membersTable { overflow-x: visible; }

}

/* ── Production tables → card layout (≤ 768px) ── */
@media (max-width: 768px) {

  #freshTable,
  #freshTable tbody,
  #driedTable,
  #driedTable tbody,
  #byMemberTable,
  #byMemberTable tbody,
  #memberFreshTable,
  #memberFreshTable tbody,
  #memberDriedTable,
  #memberDriedTable tbody {
    display: block;
  }

  #freshTable thead,
  #driedTable thead,
  #byMemberTable thead,
  #memberFreshTable thead,
  #memberDriedTable thead { display: none; }

  #freshTable tbody tr:not(.month-group-row),
  #driedTable tbody tr:not(.month-group-row),
  #byMemberTable tbody tr:not(.month-group-row),
  #memberFreshTable tbody tr:not(.month-group-row),
  #memberDriedTable tbody tr:not(.month-group-row) {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 14px;
    background: #fff;
  }

  #freshTable tbody tr:not(.month-group-row) td,
  #driedTable tbody tr:not(.month-group-row) td,
  #byMemberTable tbody tr:not(.month-group-row) td,
  #memberFreshTable tbody tr:not(.month-group-row) td,
  #memberDriedTable tbody tr:not(.month-group-row) td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13px;
    border-right: none;
    word-break: break-word;
  }

  #freshTable tbody tr:not(.month-group-row) td::before,
  #driedTable tbody tr:not(.month-group-row) td::before,
  #byMemberTable tbody tr:not(.month-group-row) td::before,
  #memberFreshTable tbody tr:not(.month-group-row) td::before,
  #memberDriedTable tbody tr:not(.month-group-row) td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    flex-shrink: 0;
    min-width: 90px;
  }

  /* Farmer name — prominent header row, no label */
  #freshTable tbody td[data-label="Farmer Name"],
  #driedTable tbody td[data-label="Farmer Name"],
  #byMemberTable tbody td[data-label="Member Name"] {
    font-size: 15px;
    font-weight: 700;
    border-bottom: 1.5px solid var(--border);
    padding-bottom: 10px;
    margin-bottom: 2px;
  }
  #freshTable tbody td[data-label="Farmer Name"]::before,
  #driedTable tbody td[data-label="Farmer Name"]::before,
  #byMemberTable tbody td[data-label="Member Name"]::before { display: none; }

  /* Actions cell */
  #freshTable tbody td.prod-actions,
  #driedTable tbody td.prod-actions,
  #byMemberTable tbody td.prod-actions,
  #memberFreshTable tbody td.prod-actions,
  #memberDriedTable tbody td.prod-actions {
    border-bottom: none;
    padding-top: 10px;
    justify-content: flex-end;
  }
  #freshTable tbody td.prod-actions::before,
  #driedTable tbody td.prod-actions::before,
  #byMemberTable tbody td.prod-actions::before,
  #memberFreshTable tbody td.prod-actions::before,
  #memberDriedTable tbody td.prod-actions::before { display: none; }

  #freshTable tbody td.prod-actions .btn-primary-amfe,
  #driedTable tbody td.prod-actions .btn-primary-amfe,
  #byMemberTable tbody td.prod-actions .btn-primary-amfe {
    padding: 7px 20px;
  }

  /* ── Month subtotal row ── */
  #freshTable tbody tr.month-group-row,
  #driedTable tbody tr.month-group-row,
  #memberFreshTable tbody tr.month-group-row,
  #memberDriedTable tbody tr.month-group-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    margin: 16px 0 10px;
  }
  #freshTable tbody tr.month-group-row:first-child,
  #driedTable tbody tr.month-group-row:first-child,
  #memberFreshTable tbody tr.month-group-row:first-child,
  #memberDriedTable tbody tr.month-group-row:first-child {
    margin-top: 0;
  }
  #freshTable tbody tr.month-group-row td,
  #driedTable tbody tr.month-group-row td,
  #memberFreshTable tbody tr.month-group-row td,
  #memberDriedTable tbody tr.month-group-row td {
    display: inline-flex;
    align-items: center;
    padding: 0;
    border: none !important;
    font-size: 13px;
    background: transparent;
  }
  #freshTable tbody tr.month-group-row td::before,
  #driedTable tbody tr.month-group-row td::before,
  #memberFreshTable tbody tr.month-group-row td::before,
  #memberDriedTable tbody tr.month-group-row td::before {
    display: none !important;
  }
  #freshTable tbody tr.month-group-row td.mg-label,
  #driedTable tbody tr.month-group-row td.mg-label,
  #memberFreshTable tbody tr.month-group-row td.mg-label,
  #memberDriedTable tbody tr.month-group-row td.mg-label {
    flex: 1 1 100%;
    min-width: 0;
    margin-bottom: 2px;
  }
  #driedTable tbody tr.month-group-row td.mg-himay,
  #memberDriedTable tbody tr.month-group-row td.mg-himay,
  #driedTable tbody tr.month-group-row td.mg-bilad-giling,
  #memberDriedTable tbody tr.month-group-row td.mg-bilad-giling {
    display: inline-flex;
    align-items: center;
    font-size: 11.5px;
    font-weight: 600;
    color: #475569;
    background: #fff;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
  }
  #freshTable tbody tr.month-group-row td.mg-total,
  #driedTable tbody tr.month-group-row td.mg-total,
  #memberFreshTable tbody tr.month-group-row td.mg-total,
  #memberDriedTable tbody tr.month-group-row td.mg-total {
    flex: 0 0 auto;
    font-weight: 700;
    text-align: right;
    margin-left: auto;
  }
  #freshTable tbody tr.month-group-row td.mg-blank,
  #driedTable tbody tr.month-group-row td.mg-blank,
  #memberFreshTable tbody tr.month-group-row td.mg-blank,
  #memberDriedTable tbody tr.month-group-row td.mg-blank {
    display: none !important;
  }
  #memberDriedTable tbody tr.month-group-row td.mg-payment {
    display: inline-flex !important;
    align-items: center;
    justify-content: flex-end;
    margin-left: auto;
    margin-bottom: 2px;
  }

  /* Modal filter row phone stacking */
  .prod-modal-filter-row.d-flex.flex-wrap {
    flex-direction: row;
  }
  .prod-modal-filter-row > .prod-modal-filter-year,
  .prod-modal-filter-row > .prod-modal-filter-month {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
  }
  .prod-modal-filter-row > .prod-modal-filter-search,
  .prod-modal-filter-row > .prod-modal-filter-payment {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
  }

  /* Points badge — never wrap/clip inside its card row */
  #byMemberTable .badge-pts,
  #driedTable .badge-pts,
  #memberDriedTable .badge-pts {
    white-space: nowrap;
  }

  /* Modal history tables stay scrollable — no card conversion */
  .modal .table-responsive { overflow-x: auto; }

}

/* ── Payroll table → card layout (≤ 768px) ───── */
@media (max-width: 767.98px) {

  .payroll-type-selector {
    align-items: stretch;
    flex-direction: column;
    gap: 9px;
  }

  .payroll-type-selector [role="tablist"] {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .payroll-type-selector button {
    padding-left: 8px;
    padding-right: 8px;
  }

  .payroll-type-filters {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px !important;
    margin-left: 0;
    width: 100%;
  }

  .payroll-type-filters .amfe-input,
  .payroll-type-filters .btn-finalize-payroll,
  .payroll-type-filters .badge {
    min-width: 0;
    width: 100%;
  }

  .payroll-breakdown-header {
    align-items: flex-start !important;
    flex-wrap: wrap;
    gap: 10px;
  }
  .payroll-pending-badge {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #payrollTable,
  #payrollTable tbody { display: block; }

  #payrollTable thead { display: none; }

  #payrollTable tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 14px;
    background: #fff;
  }

  #payrollTable tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13px;
    border-right: none;
  }

  #payrollTable tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    flex-shrink: 0;
    min-width: 90px;
  }

  /* Farmer name — prominent header row, no label */
  #payrollTable tbody td[data-label="Farmer"] {
    font-size: 15px;
    font-weight: 700;
    border-bottom: 1.5px solid var(--border);
    padding-bottom: 10px;
    margin-bottom: 2px;
  }
  #payrollTable tbody td[data-label="Farmer"]::before { display: none; }

  /* Action cell — actions sit on the right, aligned with the amounts and
     status badges above them. */
  #payrollTable tbody td[data-label="Action"] {
    border-bottom: none;
    padding-top: 10px;
    justify-content: flex-end;
  }
  #payrollTable tbody td[data-label="Action"]::before { display: none; }
  #payrollTable tbody td[data-label="Action"] > .d-flex {
    margin-left: auto;
    align-items: flex-end;
  }
  #payrollTable tbody td[data-label="Action"] .btn-primary-amfe,
  #payrollTable tbody td[data-label="Action"] .btn-outline-amfe {
    flex: 0 0 auto;
    text-align: center;
    justify-content: center;
  }

  #payrollTable tfoot {
    display: block !important;
    margin-top: 10px !important;
    background: #f0fdf4 !important;
    border: 1.5px solid #bbf7d0 !important;
    border-radius: var(--radius) !important;
    padding: 12px 14px !important;
  }
  #payrollTable tfoot tr {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    background: transparent !important;
  }
  #payrollTable tfoot td {
    padding: 0 !important;
    border: none !important;
  }
  #payrollTable tfoot td:empty {
    display: none !important;
  }

}

/* ── Sales table → card layout (≤ 640px) ─────── */
@media (max-width: 640px) {

  #salesTable,
  #salesTable tbody { display: block; }

  #salesTable thead { display: none; }

  #salesTable tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 14px;
    background: #fff;
  }

  #salesTable tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13px;
    border-right: none;
  }

  #salesTable tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    flex-shrink: 0;
    min-width: 70px;
  }

  /* Product name — card title, no label */
  #salesTable tbody td[data-label="Product"] {
    font-size: 15px;
    font-weight: 700;
    border-bottom: 1.5px solid var(--border);
    padding-bottom: 10px;
    margin-bottom: 2px;
  }
  #salesTable tbody td[data-label="Product"]::before { display: none; }

  /* Last cell (date) — no bottom border */
  #salesTable tbody td[data-label="Date"] { border-bottom: none; }

}
/* Applications page — reject modal + Members view modal */
.modal-backdrop-custom {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1050;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

/* Session expiry is a compact blocking dialog, not a mobile action sheet. */
.modal-backdrop-custom.idle-logout-backdrop {
    align-items: center;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.idle-logout-modal {
    border-radius: 16px;
    width: min(380px, 100%);
    max-height: calc(100dvh - 32px);
}

@media (min-width: 576px) {
    .modal-backdrop-custom {
        align-items: center;
        padding: 16px;
    }
}

.modal-box {
    background: #fff;
    border-radius: 16px 16px 0 0;
    padding: 24px 20px;
    width: 100%;
    max-width: 100%;
    max-height: 92dvh;
    overflow-y: auto;
    box-shadow: 0 -4px 32px rgba(0,0,0,0.15);
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 576px) {
    .modal-box {
        border-radius: 16px;
        padding: 28px;
        max-width: 480px;
        max-height: calc(100dvh - 40px);
        box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    }
    .modal-box-lg {
        max-width: 880px;
        padding: 32px 36px;
    }
}

/* ── Modal detail field rows — single col on mobile, 2-col on sm+ ── */
.modal-field-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
}
.modal-field-row .detail-field { margin-bottom: 0; }
.modal-field-full { flex: 1 1 100%; }
.modal-field-half { flex: 1 1 100%; }

@media (min-width: 480px) {
    .modal-field-half { flex: 1 1 calc(50% - 5px); }
}

/* ===== SETTINGS PAGE ===== */
.settings-profile-card {
  display: flex;
  align-items: center;
  gap: 16px;
}

.settings-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  flex-shrink: 0;
}

.settings-profile-name {
  font-family: 'DM Serif Display', serif;
  font-size: 17px;
  font-weight: 400;
  color: var(--text-dark);
  line-height: 1.3;
  margin-bottom: 2px;
}

.settings-profile-email {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.settings-section-title {
  font-family: 'DM Serif Display', serif;
  font-size: 16px;
  font-weight: 400;
  color: var(--text-dark);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.settings-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  margin-top: -4px;
}

.settings-field-error {
  font-size: 12px;
  color: var(--status-rejected);
  margin-top: 4px;
}

.settings-save-btn {
  padding: 10px 32px;
  font-size: 14px;
}

@media (max-width: 575px) {
  .settings-save-btn { width: 100%; }
}

/* The save buttons across settings all render disabled while a form is in
   flight, and until now nothing said so — the button stayed fully solid and
   only stopped responding. */
.btn-primary-amfe:disabled,
.btn-danger-amfe:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary-amfe:disabled:hover { background: var(--primary); }
.btn-danger-amfe:disabled:hover  { background: var(--status-rejected); }

/* ===========================
   RATE HISTORY
   =========================== */

/* The collapsible toggle button gets a subtle hover so it feels clickable */
.rate-history-toggle .settings-section-title {
  padding-bottom: 0;
  border-bottom: 0;
}
.rate-history-toggle:hover .settings-section-title { color: var(--primary-light); }
.rate-history-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* Chevron */
.rate-history-chevron {
  font-size: 13px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

/* Filter bar — sits between the header and the table */
.rate-history-filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--body-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}
.rate-history-filter-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  margin-right: 2px;
}

/* Rate History Toolbar */
.rate-history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: #f7faf8;
  border: 1px solid #dce8e1;
  border-radius: 12px;
  padding: 10px 14px;
}
.rate-history-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1 1 auto;
}
.rate-filter-field {
  min-width: 120px;
}
.rate-filter-select {
  border: 1px solid #d0e0d6 !important;
  border-radius: 8px !important;
  background-color: #fff !important;
  font-size: 12.5px !important;
  font-weight: 500 !important;
  color: #1e3a2b !important;
  padding: 6px 28px 6px 10px !important;
  height: 36px !important;
}
.rate-search-wrap {
  position: relative;
  min-width: 180px;
  max-width: 280px;
  flex: 1 1 auto;
}
.rate-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #7a8b82;
  font-size: 13px;
  pointer-events: none;
}
.rate-search-input {
  padding-left: 32px !important;
  padding-right: 28px !important;
  border-radius: 8px !important;
  border: 1px solid #d0e0d6 !important;
  font-size: 12.5px !important;
  height: 36px !important;
  background: #ffffff !important;
}
.rate-search-input:focus {
  border-color: #2d6b50 !important;
  box-shadow: 0 0 0 2px rgba(45, 107, 80, 0.15) !important;
}
.rate-search-wrap .btn-search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: #8c9b93;
  padding: 2px 6px;
  font-size: 14px;
  border-radius: 4px;
  cursor: pointer;
}
.rate-filter-reset-btn {
  height: 36px;
  border-radius: 8px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  padding: 6px 12px !important;
}
.rate-history-count-badge {
  font-size: 12px;
  font-weight: 600;
  color: #3b5a4a;
  background: #e8f4ed;
  border: 1px solid #c9e4d4;
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}

/* Table */
.rate-history-table {
  width: 100%;
}
.rate-history-table thead th {
  background: #f0f7f3 !important;
  color: #1e4d3a !important;
  font-weight: 700 !important;
  font-size: 11.5px !important;
  text-transform: uppercase !important;
  letter-spacing: 0.04em !important;
  border-bottom: 2px solid #c9e2d3 !important;
}
.rate-history-table tbody tr {
  transition: background 0.15s ease;
}
.rate-history-table tbody tr:hover {
  background: #fbfdfc !important;
}
.rate-row-latest {
  background: #f8fbf9 !important;
}
.rate-date-pill {
  background: #e8f5ee;
  color: #1e4d3a;
  font-weight: 600;
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 7px;
  border: 1px solid #c8e5d5;
  font-variant-numeric: tabular-nums;
}
.rate-active-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.rate-val-bold {
  color: #17241e;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.rate-pct-badge {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 600;
  color: #2c4a3b;
  font-variant-numeric: tabular-nums;
  background: #f1f6f3;
  border: 1px solid #dce8e1;
  border-radius: 6px;
  padding: 2px 7px;
}
.rate-history-empty-card {
  background: #fafcfb;
  border: 1.5px dashed #d5e4dc;
  border-radius: 12px;
  padding: 32px 20px;
}
.rate-history-table tbody td {
  padding-top: 11px;
  padding-bottom: 11px;
  vertical-align: middle;
  border-bottom: 1px solid #f0f2f1;
  font-size: 13.5px;
}

/* Date cell */
.rate-history-date {
  font-size: 13.5px;
  color: var(--text-dark);
  font-weight: 500;
}

/* Price cell */
.rate-history-price {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-weight: 500;
  font-size: 13.5px;
  color: var(--text-dark);
}
.rate-history-currency {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  opacity: 0.75;
}

/* Empty state */
.rate-history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 36px 20px;
  color: var(--text-muted);
  font-size: 13.5px;
}
.rate-history-empty-icon {
  font-size: 32px;
  opacity: 0.35;
}

/* Rate History on phones: preserve the desktop card language, but give the
   filters and three-column comparison enough room to remain fully visible. */
@media (max-width: 767.98px) {
  body.admin-shell .rate-history-card {
    padding: 1rem;
    border-radius: 1rem;
    overflow: hidden;
  }
  body.admin-shell .rate-history-toggle {
    padding: .15rem 0 .9rem !important;
    border-bottom: 0 !important;
  }
  body.admin-shell .rate-history-toggle .settings-section-title {
    display: flex;
    align-items: center;
    margin: 0;
    font-size: clamp(1.05rem, 5vw, 1.3rem);
  }
  body.admin-shell .rate-history-toggle .settings-section-title i { font-size: 1.35em; }
  body.admin-shell .rate-history-chevron { font-size: 1rem; }
  body.admin-shell .rate-history-filter-bar {
    align-items: stretch;
    flex-direction: column;
    gap: .75rem;
    margin-top: .9rem;
    padding: .9rem;
    border-radius: .85rem;
  }
  body.admin-shell .rate-history-filter-label {
    display: flex;
    align-items: center;
    gap: .25rem;
    margin: 0;
    font-size: .85rem;
  }
  body.admin-shell .rate-history-filter-bar > .d-flex {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: .65rem !important;
    width: 100%;
  }
  body.admin-shell .rate-history-filter-bar .ana-year-dropdown { width: 100%; }
  body.admin-shell .rate-history-filter-bar .ana-year-toggle {
    justify-content: flex-start;
    width: 100%;
    min-height: 3rem;
    padding: .65rem 2.35rem .65rem .85rem;
    border: 1px solid var(--border);
    border-radius: .7rem;
    background: #fff;
    font-size: .95rem;
    text-align: left;
  }
  body.admin-shell .rate-history-filter-bar .ana-year-dropdown::after { right: 1rem; }
  body.admin-shell .rate-history-filter-bar .dropdown-menu { width: 100%; min-width: 100%; }
  body.admin-shell .rate-history-card .table-responsive {
    width: 100%;
    margin-top: .9rem !important;
    overflow-x: hidden;
    border: 1px solid var(--border);
    border-radius: .8rem;
  }
  body.admin-shell .rate-history-table {
    width: 100%;
    min-width: 0;
    margin: 0;
    table-layout: fixed;
  }
  body.admin-shell .rate-history-table thead th {
    width: 33.333%;
    padding: .8rem .45rem;
    background: var(--primary-bg);
    font-size: clamp(.58rem, 2.8vw, .72rem);
    line-height: 1.35;
    overflow-wrap: anywhere;
  }
  body.admin-shell .rate-history-table tbody td {
    padding: .7rem .4rem;
    font-size: clamp(.65rem, 3vw, .78rem);
    overflow-wrap: anywhere;
  }
  body.admin-shell .rate-history-date,
  body.admin-shell .rate-history-price { font-size: inherit; }
  body.admin-shell .rate-history-date i { display: none; }
}

/* Dashboard overdue payroll dialog: phone-only card layout. */
@media (max-width: 575.98px) {
  body.admin-shell .overdue-payroll-modal-box {
    width: 100% !important;
    max-width: 100% !important;
    padding: 20px 16px calc(18px + env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
  }

  body.admin-shell .overdue-modal-header {
    align-items: center !important;
    margin-bottom: 16px !important;
    padding-bottom: 16px !important;
  }

  body.admin-shell .overdue-modal-heading { gap: 12px !important; min-width: 0; }
  body.admin-shell .overdue-modal-heading-icon {
    width: 48px !important;
    height: 48px !important;
    border-radius: 12px !important;
  }
  body.admin-shell .overdue-modal-heading-icon i { font-size: 23px !important; }
  body.admin-shell .overdue-modal-heading-copy { min-width: 0; }
  body.admin-shell .overdue-modal-title {
    font-size: clamp(20px, 6vw, 25px) !important;
    line-height: 1.05;
  }
  body.admin-shell .overdue-modal-subtitle {
    display: block;
    margin-top: 5px;
    font-size: 13px !important;
    line-height: 1.25;
  }
  body.admin-shell .overdue-modal-dismiss { flex: 0 0 auto; margin-left: 10px; }

  body.admin-shell .overdue-modal-summary { margin-bottom: 16px !important; }
  body.admin-shell .overdue-modal-summary > [class*="col-"] { padding-inline: 4px; }
  body.admin-shell .overdue-modal-kpi {
    display: flex;
    min-height: 92px;
    padding: 12px 5px !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px !important;
  }
  body.admin-shell .overdue-modal-kpi > div:first-child {
    min-height: 30px;
    font-size: clamp(9px, 2.8vw, 11px) !important;
    line-height: 1.25;
  }
  body.admin-shell .overdue-modal-kpi > div:last-child {
    margin-top: 5px;
    font-size: 24px !important;
    line-height: 1;
  }

  body.admin-shell .overdue-modal-list {
    max-height: min(52dvh, 430px) !important;
    gap: 10px !important;
    margin-bottom: 16px !important;
    padding-right: 2px !important;
  }
  body.admin-shell .overdue-modal-period {
    display: grid !important;
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 10px 14px !important;
    padding: 16px !important;
    border-radius: 14px !important;
  }
  body.admin-shell .overdue-modal-period-main { display: contents !important; }
  body.admin-shell .overdue-modal-period-icon {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: 48px !important;
    height: 48px !important;
    border-radius: 12px !important;
    font-size: 18px !important;
  }
  body.admin-shell .overdue-modal-period-copy { grid-column: 2; min-width: 0; }
  body.admin-shell .overdue-modal-period-name { font-size: 18px !important; line-height: 1.2; }
  body.admin-shell .overdue-modal-period-meta {
    align-items: flex-start !important;
    flex-direction: column;
    gap: 7px !important;
    margin-top: 4px;
    font-size: 14px !important;
  }
  body.admin-shell .overdue-modal-days {
    padding: 4px 10px !important;
    font-size: 13px !important;
    line-height: 1.25;
  }
  body.admin-shell .overdue-modal-open {
    grid-column: 2;
    justify-self: end;
    margin-left: 0 !important;
    padding: 7px 13px !important;
    font-size: 13px !important;
  }

  body.admin-shell .overdue-modal-footer {
    gap: 12px;
    padding-top: 14px !important;
  }
  body.admin-shell .overdue-modal-view-all {
    min-width: 0;
    font-size: 12px !important;
    line-height: 1.3;
    text-align: left;
  }
  body.admin-shell .overdue-modal-close {
    flex: 0 0 auto;
    min-height: 40px;
    padding-inline: 18px !important;
    border-radius: 999px !important;
  }
}

/* ===========================
   SECURITY PAGE
   =========================== */

/* Scan-and-verify (or status-and-disable) are two halves of one task, not
   two independent settings the way Account Information and Change Password
   are — so they're one card with an internal divider, not two cards with a
   gap between them. .amfe-card's own padding is reset to 0 here since each
   panel carries its own instead, right up against the divider. */
.twofa-card { padding: 0; }
.twofa-panel { padding: 20px; }
.twofa-panel-end { border-top: 1px solid var(--border); }
@media (min-width: 768px) {
  .twofa-panel-end {
    border-top: none;
    border-left: 1px solid var(--border);
  }
}

/* Sits inside .settings-section-title, which is a plain block with a rule
   under it — floating keeps that rule intact for every other section. */
.twofa-pill {
  float: right;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 50px;
  border: 1px solid transparent;
}
.twofa-pill.is-on {
  background: var(--accent-green-light);
  border-color: #a8d5ba;
  color: #1a6b3c;
}
.twofa-pill.is-off {
  background: #f1f3f2;
  border-color: var(--border);
  color: var(--text-muted);
}

.twofa-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 0 0 20px;
}
.twofa-facts dt {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.twofa-facts dd {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-dark);
  margin: 0;
  font-variant-numeric: tabular-nums;
}

/* A third, lower-stakes sub-action under the facts — a rule separates it
   from the reassurance text above rather than letting the form just run on
   from the paragraph, the way the danger-zone divider used to when disable
   shared this panel. */
.twofa-regenerate {
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Setup and verification are two separate cards now (same pairing as
   Account Information / Change Password), not one card split by an
   internal rule — so each step just needs a short label, not a numbered
   badge arguing for its own position in a stacked list. */
.twofa-step-label {
  display: block;
  font-size: 13px;
  color: var(--text-dark);
  line-height: 1.5;
  margin-bottom: 12px;
}

/* Code entry and its submit sit in one row now that the card has the width
   to spare — was stacked with the button on its own line below. stretch
   (not flex-start) matches the button's height to the input's rather than
   hardcoding it, since .twofa-code-input's larger font makes it taller than
   .settings-save-btn's own padding would otherwise produce. */
.twofa-code-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-wrap: wrap;
}
.twofa-code-row .settings-save-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* A QR needs a light quiet zone around it to stay scannable on a card that
   might sit on any background. */
.twofa-qr {
  display: inline-block;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  line-height: 0;
}
.twofa-qr img { display: block; }

.twofa-secret { margin-top: 14px; }
.twofa-secret-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.twofa-secret-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.twofa-secret-row code {
  flex: 1 1 auto;
  min-width: 0;
  background: #f7f8f8;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-dark);
  word-break: break-all;
  user-select: all;
}
.twofa-copy {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 8px 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.twofa-copy:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-bg);
}
.twofa-copy:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Six characters, not a full-width text field. text-indent cancels the
   trailing letter-space so the digits sit optically centred. */
.twofa-code-input {
  width: 180px;
  max-width: 100%;
  text-align: center;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  font-variant-numeric: tabular-nums;
}
.twofa-code-input::placeholder {
  color: var(--text-light);
  font-weight: 400;
}

/* Shown exactly once. The tint is the only thing on the page that says
   "copy this before you leave". */
.recovery-card {
  background: var(--primary-bg);
  border-color: #b9d3c6;
}
.recovery-card .settings-section-title { border-bottom-color: #b9d3c6; }
.recovery-card .settings-hint { color: #46685a; }

.recovery-code-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.recovery-code-list li { min-width: 0; }
.recovery-code-list code {
  display: block;
  background: #fff;
  border: 1px solid #b9d3c6;
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--text-dark);
  user-select: all;
}

@media (max-width: 991px) {
  .recovery-code-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 575px) {
  .twofa-facts { grid-template-columns: 1fr; gap: 12px; }
  .twofa-code-input { width: 100%; }
  .twofa-copy { width: 100%; justify-content: center; }
}

/* ── Roomier fields + spacing inside the large view modal ── */
@media (min-width: 576px) {
    .modal-box-lg .modal-field-row { gap: 14px; }
    .modal-box-lg .detail-field { padding: 14px 18px; }
    .modal-box-lg .field-label { font-size: 12px; margin-bottom: 4px; }
    .modal-box-lg .field-value { font-size: 15px; }
    .modal-box-lg .section-heading { font-size: 14px; margin: 22px 0 12px; }
    .modal-box-lg .modal-field-half { flex: 1 1 calc(50% - 7px); }
}

/* ===== MEMBER DETAILS MODAL & ACCOUNT ACCESS ===== */
.member-details-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.member-modal-icon-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #e8f5ec;
  color: #1e4d3a;
  border: 1px solid #d0e7da;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.member-modal-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 20px;
  font-weight: 500;
  color: #183126;
  margin: 0;
  line-height: 1.2;
}

.member-modal-sub {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
  display: block;
  margin-top: 2px;
}

.member-header-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50px;
  padding: 6px 16px;
  min-height: 34px;
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.account-access-card {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(24, 49, 38, 0.04);
}

.account-access-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.account-access-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #e8f5ec;
  color: #1e4d3a;
  border: 1px solid #d0e7da;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.account-access-title {
  font-size: 15px;
  font-weight: 700;
  color: #183126;
  margin: 0;
  line-height: 1.2;
}

.account-access-subtitle {
  font-size: 11.5px;
  color: #64748b;
  font-weight: 400;
}

.account-status-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.account-status-badge.active {
  background: #e8f5ec;
  color: #15803d;
  border: 1px solid #c6ebd2;
}
.account-status-badge.deactivated {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.account-status-badge.active .status-dot {
  background: #16a34a;
}
.account-status-badge.deactivated .status-dot {
  background: #dc2626;
}

.account-access-id-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 14px;
}

.account-access-id-label {
  font-size: 10.5px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: block;
}

.account-access-id-value {
  font-size: 15px;
  font-weight: 700;
  color: #183126;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  margin-top: 2px;
}

.account-access-login-state {
  font-size: 12px;
  font-weight: 500;
  color: #475569;
}

.member-access-handoff {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin: 16px 0;
  padding: 18px;
  border: 1px solid #b9d8c5;
  border-left: 4px solid #1f5a43;
  border-radius: 14px;
  background: linear-gradient(135deg, #f7fbf8 0%, #eaf4ee 100%);
  box-shadow: 0 10px 24px rgba(31, 90, 67, 0.08);
}

.member-access-handoff-kicker {
  display: inline-flex;
  align-items: center;
  margin-bottom: 5px;
  color: #287250;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.member-access-handoff h3 {
  margin: 0 0 5px;
  color: #18372a;
  font-size: 16px;
  font-weight: 750;
}

.member-access-handoff p {
  max-width: 660px;
  margin: 0;
  color: #50645a;
  font-size: 12px;
  line-height: 1.5;
}

.member-access-handoff-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 13px;
}

.member-access-handoff-details div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(31, 90, 67, 0.13);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.72);
}

.member-access-handoff-details span,
.member-access-handoff-details strong {
  display: block;
  overflow-wrap: anywhere;
}

.member-access-handoff-details span {
  margin-bottom: 2px;
  color: #6b7c73;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.member-access-handoff-details strong {
  color: #244638;
  font-size: 11px;
}

.member-access-handoff-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 190px;
}

.member-access-handoff-actions button {
  justify-content: center;
  width: 100%;
  white-space: nowrap;
}

@media (max-width: 767px) {
  .member-access-handoff {
    grid-template-columns: 1fr;
    padding: 15px;
  }

  .member-access-handoff-details {
    grid-template-columns: 1fr;
  }

  .member-access-handoff-actions {
    min-width: 0;
  }
}

.account-access-guide {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: #3b5045;
  background: #f0fdf4;
  border: 1px solid #d0e7da;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  line-height: 1.45;
}

.account-verify-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.account-verify-card:hover {
  border-color: #cbd5e1;
}
.account-verify-card.verified {
  border-color: #10b981;
  background: #f0fdf4;
}
.account-verify-text {
  font-size: 12.5px;
  font-weight: 500;
  color: #1e293b;
  line-height: 1.35;
}

.account-admin-pwd-group {
  margin-bottom: 14px;
}

.account-pwd-input {
  height: 42px;
  border-radius: 10px;
  border: 1.5px solid #d1d5db;
  padding: 8px 40px 8px 12px;
  font-size: 13.5px;
  transition: all 0.2s ease;
}
.account-pwd-input:focus {
  border-color: #1e4d3a;
  box-shadow: 0 0 0 3px rgba(30, 77, 58, 0.12);
}

.btn-password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-password-toggle:hover {
  color: #475569;
}

.btn-issue-pwd {
  min-height: 40px;
  border-radius: 50px;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  border: 1.5px solid;
  cursor: pointer;
}
.btn-issue-pwd.btn-issue {
  background: #ffffff;
  color: #1e4d3a;
  border-color: #1e4d3a;
}
.btn-issue-pwd.btn-issue:hover:not(:disabled) {
  background: #1e4d3a;
  color: #ffffff;
  transform: translateY(-1px);
}
.btn-issue-pwd.btn-reactivate {
  background: #1e4d3a;
  color: #ffffff;
  border-color: #1e4d3a;
}
.btn-issue-pwd.btn-reactivate:hover:not(:disabled) {
  background: #183126;
  border-color: #183126;
  transform: translateY(-1px);
}
.btn-issue-pwd:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.account-credentials-alert {
  border-radius: 12px;
  padding: 16px;
  font-size: 13px;
}

.account-credential-box {
  background: #ffffff;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.account-credential-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.account-credential-label {
  color: #64748b;
  font-size: 12px;
  min-width: 140px;
}

.account-credential-pwd {
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

.member-access-control-card {
  border-radius: 14px;
  padding: 14px 18px;
  margin-top: 14px;
  transition: all 0.2s ease;
}
.member-access-control-card.is-active {
  background: #fff8f5;
  border: 1.5px solid #fed7aa;
}
.member-access-control-card.is-deactivated {
  background: #f0fdf4;
  border: 1.5px solid #bbf7d0;
}

.access-control-icon-pill {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.access-control-icon-pill.active {
  background: #fff0eb;
  color: #ea580c;
  border: 1px solid #fdba74;
}
.access-control-icon-pill.deactivated {
  background: #e8f5ec;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.access-control-heading {
  font-size: 13.5px;
  color: #1e293b;
}

.access-status-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 50px;
  margin-left: 4px;
}
.access-status-tag.active {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.access-status-tag.deactivated {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.access-control-desc {
  font-size: 11.5px;
  color: #64748b;
  display: block;
  margin-top: 2px;
}

.btn-deactivate-action {
  background: #dc2626;
  color: #ffffff;
  border: none;
  border-radius: 50px;
  padding: 8px 18px;
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(220, 38, 38, 0.2);
}
.btn-deactivate-action:hover:not(:disabled) {
  background: #b91c1c;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(220, 38, 38, 0.3);
}
.btn-deactivate-action:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}


/* ── Print / Export as PDF ── */
@media print {
    .sidebar,
    .sidebar-overlay,
    .mobile-menu-btn,
    .no-print,
    button,
    .btn,
    .btn-outline-amfe,
    .btn-primary-amfe { display: none !important; }

    .main-content { margin: 0 !important; padding: 16px !important; }
    body { background: white !important; }
    .amfe-card { box-shadow: none !important; border: 1px solid #dee2e6 !important; }
}

/* ===== SALES & INVENTORY — STAT CARD COLOR VARIANTS + CHANGE BADGE ===== */
.stat-icon.stat-icon-orange { background: #fff8e1; color: #b45309; }
.stat-icon.stat-icon-blue   { background: #eef2ff; color: #4f46e5; }
.stat-icon.stat-icon-red    { background: #fde8e8; color: var(--status-rejected); }

.stat-change-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
}
.stat-change-vs { color: var(--text-muted); white-space: nowrap; }
.stat-change {
  font-weight: 600;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 2px;
}
.stat-change-up { color: var(--status-approved); }
.stat-change-down { color: var(--status-rejected); }

/* ===== SALES & INVENTORY — SHARED PRODUCT THUMBNAIL ===== */
.inv-thumb {
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* ===== SALES & INVENTORY — DASHBOARD CARDS ===== */
/* Icon sits left of the text (unlike .stat-card, whose icon is right-aligned)
   and the period comparison reads as its own footer line. */
.si-stat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  height: 100%;
}
.si-stat-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.si-stat-body { flex: 1; min-width: 0; }
.si-stat-label { font-size: 14px; color: var(--text-muted); line-height: 1.3; }
.si-stat-value { font-size: 24px; font-weight: 700; color: var(--text-dark); line-height: 1.25; margin-top: 2px; }
.si-stat-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-top: 6px; font-size: 13px;
}
.si-stat-vs { color: var(--text-muted); }
.si-stat-delta { font-weight: 600; display: inline-flex; align-items: center; gap: 1px; }
.si-stat-delta.up { color: #16a34a; }
.si-stat-delta.down { color: #ef4444; }

/* Small phones: icon centered above the label/value instead of beside
   them — a 48px icon plus text side by side left little room to breathe
   once the cards went 2-per-row, so stack and center instead. */
@media (max-width: 576px) {
  .si-stat {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 16px 12px;
  }
  .si-stat-body { flex: none; width: 100%; }
  .si-stat-foot { flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
}

.si-icon-green  { background: #e7f3ec; color: #2e7d54; }
.si-icon-amber  { background: #fdf1dd; color: #e0912f; }
.si-icon-indigo { background: #ebedfb; color: #5560d4; }
.si-icon-red    { background: #fdeaea; color: #e05252; }

/* Each card's border/glow matches its own icon's color, so the row
   still reads as "one summary strip" (white cards, thin borders) rather
   than solid tinted blocks — just a soft colored aura per card. */
.si-stat--green  { border-color: #2e7d54; box-shadow: 0 0 10px rgba(46,125,84,0.22); }
.si-stat--amber  { border-color: #e0912f; box-shadow: 0 0 10px rgba(224,145,47,0.22); }
.si-stat--indigo { border-color: #5560d4; box-shadow: 0 0 10px rgba(85,96,212,0.22); }
.si-stat--red    { border-color: #e05252; box-shadow: 0 0 10px rgba(224,82,82,0.22); }

/* ===== SALES & INVENTORY — PANEL HEADERS ===== */
.si-breakdown { min-width: 0; padding: 18px 20px; }
.si-breakdown-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px 20px; margin-bottom: 14px; }
.si-breakdown-period { display: block; color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.si-breakdown-controls { display: flex; align-items: center; gap: 8px; }
.si-breakdown-select { width: 160px; min-width: 0; }
.si-breakdown-close { width: 38px; height: 38px; flex: 0 0 38px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 9px; background: #fff; color: var(--text-muted); cursor: pointer; }
.si-breakdown-close:hover { border-color: #e05252; background: #fff5f5; color: #e05252; }
.si-month-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 18px; }
.si-breakdown-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 18px; }
.si-breakdown-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.si-breakdown-metric { min-width: 0; padding: 13px 15px; border: 1px solid var(--border); border-radius: 10px; background: #fafbfa; }
.si-breakdown-metric-head { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.si-breakdown-metric-head span { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.si-breakdown-metric-head strong { white-space: nowrap; color: var(--text-dark); }
.si-breakdown-track { height: 6px; margin-top: 11px; border-radius: 999px; background: #e5ebe7; overflow: hidden; }
.si-breakdown-track span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.si-breakdown--expenses .si-breakdown-track span { background: #e05252; }
.si-breakdown-metric small { display: block; margin-top: 5px; color: var(--text-muted); text-align: right; font-size: 11px; }
.si-month-row, .si-breakdown-line, .si-breakdown-total { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; padding: 8px 0; font-size: 13px; }
.si-month-row, .si-breakdown-line { border-bottom: 1px solid var(--border); }
.si-breakdown-selected { background: var(--primary-bg); border-radius: 6px; padding-left: 8px; padding-right: 8px; color: var(--primary); }
.si-month-row strong, .si-breakdown-line strong, .si-breakdown-total strong { color: var(--text-dark); font-weight: 600; text-align: right; white-space: nowrap; }
.si-breakdown-total { margin-top: 10px; border-top: 2px solid var(--primary); font-weight: 600; }
.si-page-group { display: inline-flex; align-items: center; gap: 6px; }
.si-page-gap { color: var(--text-muted); padding: 0 2px; }
@media (max-width: 1199.98px) {
  .si-month-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .si-breakdown-list, .si-breakdown-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 767.98px) {
  .si-breakdown-list, .si-breakdown-metrics { grid-template-columns: 1fr; }
  .si-month-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; }
  .si-month-row { flex-direction: column; align-items: flex-start; gap: 2px; }
  .si-month-row strong { text-align: left; }
  .si-breakdown-controls { width: 100%; }
  .si-breakdown-select { width: 100%; }
}

.si-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 18px 20px;
}
.si-panel-title { font-size: 18px; font-weight: 600; color: var(--text-dark); }
.si-panel-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Quieter than .amfe-input: these sit inside a card, so they read as controls
   rather than form fields. */
.si-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 9px 32px 9px 14px;
  font-size: 14px;
  color: var(--text-dark);
  outline: none;
  cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236c757d' stroke-width='1.6' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.si-select:focus { border-color: var(--primary); }

.si-ghost-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--primary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.si-ghost-btn:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-bg); }
.si-ghost-btn:disabled { color: var(--text-light); cursor: not-allowed; }

/* ===== SALES & INVENTORY — TABLE CELLS ===== */
.si-prod { display: flex; align-items: center; gap: 12px; }
.si-prod-img {
  width: 44px; height: 44px;
  object-fit: contain;
  background: #f6f7f6;
  border-radius: 8px;
  flex-shrink: 0;
}
.si-prod-name { font-weight: 600; font-size: 14px; color: var(--text-dark); line-height: 1.3; }
.si-prod-unit { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }

.si-row-menu {
  border: none; background: transparent;
  color: var(--text-light);
  font-size: 17px; line-height: 1;
  padding: 4px 8px; border-radius: 6px;
  cursor: pointer;
}
.si-row-menu:hover { background: #f1f3f2; color: var(--text-dark); }

.si-table-foot {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  padding: 16px;
  border-top: 1px solid var(--border);
}
.si-records-scroll {
  max-height: 430px;
  overflow-y: auto;
  scrollbar-color: #b8c9bf transparent;
  scrollbar-width: thin;
}
.si-records-scroll::-webkit-scrollbar { width: 7px; }
.si-records-scroll::-webkit-scrollbar-thumb { background: #b8c9bf; border-radius: 999px; }
.si-records-scroll::-webkit-scrollbar-track { background: transparent; }

.btn-kebab-amfe {
  border: 1px solid #d5dfd9;
  background: #ffffff;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #2d3748;
  transition: all 0.15s ease;
}
.btn-kebab-amfe:hover {
  background: #f1f5f2;
  border-color: #b8c9bf;
  color: #183b2d;
}
.btn-kebab-amfe.active {
  background: #e8f0eb;
  border-color: #183b2d;
  color: #183b2d;
}

.si-action-portal-menu {
  animation: siActionMenuFadeIn 0.12s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: top right;
}
@keyframes siActionMenuFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.si-action-portal-menu .dropdown-item {
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.si-action-portal-menu .dropdown-item:hover {
  background-color: #f1f5f9;
}
.si-action-portal-menu .dropdown-item.text-danger:hover {
  background-color: #fee2e2;
  color: #dc2626;
}

/* ===== SALES & INVENTORY — INVENTORY STATUS ===== */
.si-inv-item {
  display: flex; align-items: center; gap: 14px;
  background: #fafbfa;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.si-inv-item:last-child { margin-bottom: 0; }
.si-inv-img {
  width: 64px; height: 64px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  flex-shrink: 0;
}
.si-inv-body { flex: 1; min-width: 0; }
.si-inv-name { font-size: 16px; font-weight: 600; color: var(--text-dark); }
.si-inv-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.si-inv-stock { font-size: 26px; font-weight: 700; color: var(--text-dark); line-height: 1.2; margin-top: 2px; }

.si-pill {
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.si-pill-in  { background: #e7f3ec; color: #2e7d54; }
.si-pill-low { background: #fdf1dd; color: #b45309; }
.si-pill-best { background: #fff4d6; color: #92660a; display: inline-flex; align-items: center; gap: 4px; }
.si-pill-best i { font-size: 11px; }

.si-inv-pills { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }

/* ===== SALES & INVENTORY — BUYER SUMMARY TRIGGER BANNER & MODAL ===== */
.si-buyer-summary-banner,
.ra-allocation-status-banner {
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(24, 49, 38, 0.05);
  transition: all 0.2s ease;
  overflow: hidden;
}
.si-buyer-summary-banner:hover,
.ra-allocation-status-banner:hover {
  border-color: #b7d5c5;
  box-shadow: 0 4px 14px rgba(24, 49, 38, 0.08);
  transform: translateY(-1px);
}
.ra-allocation-status-banner:hover .ra-allocation-status-cta {
  background: var(--primary, #183126);
  border-color: var(--primary, #183126);
  color: #fff;
}
.ra-allocation-status-banner:hover .ra-allocation-status-cta-arrow {
  transform: translateX(3px);
}

/* ===== RESOURCE ALLOCATION — ALLOCATION STATUS TRIGGER BANNER & MODAL ===== */
.ra-allocation-status-trigger-btn {
  width: 100%;
  padding: 16px 22px;
  background: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  text-align: left;
  border-radius: 12px;
  transition: all 0.2s ease;
}

.ra-allocation-status-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1;
}

.ra-allocation-status-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #ecfdf5;
  color: #166534;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.ra-allocation-status-content {
  min-width: 0;
  flex: 1;
}

.ra-allocation-status-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.ra-allocation-status-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

.ra-allocation-status-period-pill {
  background: #f1f5f9;
  color: #475569;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}

.ra-allocation-status-pct-pill {
  background: #dcfce7;
  color: #166534;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.ra-allocation-status-pct-pill--pending {
  background: #fef3c7;
  color: #92400e;
}

.ra-pending-inventory-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-color: #f4d58d;
  background: linear-gradient(135deg, #fffdf6 0%, #fff 72%);
}

.ra-pending-inventory-copy {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}

.ra-pending-inventory-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #fef3c7;
  color: #a16207;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.ra-pending-inventory-copy h2 {
  margin: 0 0 4px;
  color: #3f3212;
  font-size: 17px;
  font-weight: 700;
}

.ra-pending-inventory-copy p {
  margin: 0;
  color: #6b6250;
  font-size: 13px;
  line-height: 1.5;
  max-width: 570px;
}

.ra-pending-inventory-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(145px, 1fr));
  gap: 12px;
  flex: 1;
  max-width: 680px;
}

.ra-pending-inventory-metrics > div {
  padding: 11px 13px;
  border: 1px solid #eee4cc;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.82);
}

.ra-pending-inventory-metrics span,
.ra-pending-inventory-metrics strong {
  display: block;
}

.ra-pending-inventory-metrics span {
  color: #746b5b;
  font-size: 11px;
  line-height: 1.35;
  margin-bottom: 5px;
}

.ra-pending-inventory-metrics strong {
  color: #183126;
  font-size: 15px;
  white-space: nowrap;
}

.ra-allocation-status-subtitle {
  font-size: 12.5px;
  color: #64748b;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.ra-allocation-status-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 9999px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  color: #183126;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.ra-allocation-status-cta-arrow {
  display: inline-flex;
  align-items: center;
  transition: transform 0.2s ease;
}

@media (max-width: 680px) {
  .ra-allocation-status-trigger-btn {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px;
  }
  .ra-allocation-status-left {
    align-items: flex-start;
    gap: 12px;
    width: 100%;
  }
  .ra-allocation-status-title-row {
    gap: 6px;
    margin-bottom: 5px;
  }
  .ra-allocation-status-title {
    font-size: 15px;
  }
  .ra-allocation-status-subtitle {
    font-size: 12px;
    line-height: 1.45;
  }
  .ra-allocation-status-cta {
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
    font-size: 13px;
  }
}

@media (max-width: 1100px) {
  .ra-pending-inventory-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .ra-pending-inventory-metrics {
    max-width: none;
  }
}

@media (max-width: 680px) {
  .ra-pending-inventory-metrics {
    grid-template-columns: 1fr;
  }
}

/* Allocation Status Modal */
.ra-status-modal-dialog {
  max-width: 780px;
}
.ra-status-modal-content {
  border-radius: 16px;
  overflow: hidden;
}
.ra-status-modal-header {
  padding: 1.5rem 1.5rem 0.5rem;
}
.ra-status-modal-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 22px;
  font-weight: 400;
  color: #0f172a;
}
.ra-status-modal-subtitle {
  font-size: 12.5px;
}
.ra-status-modal-body {
  padding: 1rem 1.5rem 1.5rem;
}
.ra-status-modal-footer {
  padding: 0 1.5rem 1.5rem;
}
.ra-status-kpi-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
  height: 100%;
  transition: border-color 0.15s ease;
}
.ra-status-kpi-card:hover {
  border-color: #b7d5c5;
}
.ra-status-kpi-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.ra-status-kpi-icon.green { background: #ecfdf5; color: #15803d; }
.ra-status-kpi-icon.amber { background: #fef3c7; color: #b45309; }
.ra-status-kpi-icon.sky   { background: #e0f2fe; color: #0369a1; }
.ra-status-kpi-icon.rose  { background: #ffe4e6; color: #be123c; }

.ra-status-kpi-info {
  min-width: 0;
  flex: 1;
}
.ra-status-kpi-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  margin-bottom: 3px;
  overflow-wrap: anywhere;
}
.ra-status-kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
}

@media (max-width: 576px) {
  .ra-status-modal-header {
    padding: 1.25rem 1rem 0.5rem;
  }
  .ra-status-modal-body {
    padding: 0.75rem 1rem 1.25rem;
  }
  .ra-status-modal-footer {
    padding: 0 1rem 1.25rem;
  }
  .ra-status-modal-title {
    font-size: 19px;
  }
  .ra-status-kpi-card {
    padding: 12px 14px;
    gap: 12px;
  }
  .ra-status-kpi-icon {
    width: 40px;
    height: 40px;
    font-size: 18px;
    border-radius: 10px;
  }
  .ra-status-kpi-label {
    font-size: 10.5px;
  }
  .ra-status-kpi-value {
    font-size: 18px;
  }
}
.si-buyer-trigger-btn {
  width: 100%;
  padding: 14px 20px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  text-align: left;
}
.si-buyer-trigger-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.si-buyer-icon-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #e8f5ec;
  color: #1e5e3a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.si-buyer-trigger-info {
  min-width: 0;
}
.si-buyer-trigger-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.si-buyer-trigger-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dark, #183126);
}
.si-buyer-count-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e8f5ec;
  color: #1e5e3a;
}
.si-buyer-trigger-sub {
  font-size: 13px;
  color: var(--text-muted, #6c757d);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.si-buyer-trigger-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f8faf9;
  color: var(--text-dark, #183126);
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.si-buyer-summary-banner:hover .si-buyer-trigger-cta {
  background: var(--primary, #183126);
  border-color: var(--primary, #183126);
  color: #fff;
}
.si-buyer-cta-arrow {
  display: inline-flex;
  align-items: center;
  transition: transform 0.2s ease;
}
.si-buyer-summary-banner:hover .si-buyer-cta-arrow {
  transform: translateX(3px);
}

@media (max-width: 650px) {
  .si-buyer-trigger-btn {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
  }
  .si-buyer-trigger-cta {
    justify-content: center;
    width: 100%;
  }
  .si-buyer-trigger-sub {
    white-space: normal;
  }
}

/* Modal KPI cards */
.si-buyer-kpi-card {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafbfa;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
  transition: border-color 0.15s ease;
}
.si-buyer-kpi-card:hover {
  border-color: #b7d5c5;
}
.si-buyer-kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.si-buyer-kpi-icon.green  { background: #e8f5ec; color: #1e5e3a; }
.si-buyer-kpi-icon.indigo { background: #eef2ff; color: #4338ca; }
.si-buyer-kpi-icon.teal   { background: #e6fffa; color: #0d9488; }
.si-buyer-kpi-icon.amber  { background: #fef3c7; color: #b45309; }
.si-buyer-kpi-icon.purple { background: #f3e8ff; color: #7e22ce; }

.si-buyer-kpi-label {
  font-size: 12px;
  color: var(--text-muted, #6c757d);
  line-height: 1.3;
}
.si-buyer-kpi-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-dark, #183126);
  margin-top: 2px;
}

/* ===== SALES & INVENTORY RESPONSIVE ===== */
/* New, narrowly-scoped ruleset — not a revival of the dead #salesTable /
   #freshTable / #driedTable rules elsewhere in this file (those target IDs
   nothing in the current markup uses). Targets classes, not translated
   label text, so it keeps working in FIL mode. */
@media (max-width: 576px) {
  .si-records-scroll { max-height: 460px; }
  .si-table, .si-table tbody { display: block; }
  .si-table thead { display: none; }

  .si-table tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 14px;
    background: #fff;
  }

  .si-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13px;
    border-right: none;
  }

  .si-table tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    flex-shrink: 0;
    min-width: 70px;
  }

  /* .amfe-table tbody tr:last-child td (outside this media block) has
     higher specificity than the rules above and would otherwise strip
     every divider from the last card in each table — the only card, on a
     single-row table. Re-declare at matching/higher specificity so the
     card layout's own dividers win on the last row too. */
  .si-table tbody tr:last-child td { border-bottom: 1px solid #f3f4f6; }
  .si-table tbody tr:last-child td.si-td-title { border-bottom: 1.5px solid var(--border); }
  .si-table tbody tr:last-child td.si-td-actions { border-bottom: none; }
  .si-table tbody td:last-child { border-bottom: none; }

  /* Empty-state / loading rows (colSpan placeholder, no data-label) —
     center as plain text instead of the flex label/value layout. */
  .si-table tbody td[colspan] { display: block; text-align: center; }
  .si-table tbody td[colspan]::before { display: none; }

  /* .amfe-table tbody tr:hover (outside this media block) tints cards
     grey; mobile browsers keep :hover after a tap, so a tapped card
     could otherwise stay tinted until the next tap. */
  .si-table tbody tr:hover { background: #fff; }

  /* Title cell — card heading. Font/weight come from the cell's own content
     (.si-prod-name, or the fw-semibold utility already on the Category
     cell) — this class only handles the card-header layout treatment. */
  .si-table tbody td.si-td-title {
    border-bottom: 1.5px solid var(--border);
    padding-bottom: 10px;
    margin-bottom: 2px;
  }
  .si-table tbody td.si-td-title::before { display: none; }

  /* Actions cell — right-aligned, no label, no divider (true last cell) */
  .si-table tbody td.si-td-actions {
    border-bottom: none;
    justify-content: flex-end;
    padding-top: 10px;
  }
  .si-table tbody td.si-td-actions::before { display: none; }
}

/* ===== ACTIVITY LOG: DATE RANGE POPOVER ===== */
.date-range-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  cursor: pointer;
  width: auto;
}
.date-range-popover {
  position: fixed;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  border: 1px solid var(--border);
  z-index: 2000;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.date-range-popover > div {
  display: grid;
  gap: 4px;
}
.date-range-popover .amfe-label {
  margin: 0;
  line-height: 1.25;
}
.date-range-popover .amfe-input {
  width: 100%;
  height: 40px;
}

/* ===== ACTIVITY LOG: NUMBERED PAGINATION =====
   Sized/behaves to match .pagination-bar button (role-shell.css), used by
   Archive/Members/Products/Payroll/Production, so the pill look is
   identical wherever a paginator appears. */
.pagination-chevron,
.pagination-page {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-dark);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.pagination-chevron:hover:not(:disabled),
.pagination-page:hover:not(:disabled) {
  background: #f4f7f5;
  border-color: var(--primary);
}
.pagination-chevron:disabled,
.pagination-page:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.pagination-page.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  opacity: 1;
  cursor: default;
}
.pagination-ellipsis {
  padding: 0 4px;
  color: var(--text-muted);
}

/* ===== ACTIVITY LOG: FILLED ACTION BADGES ===== */
.action-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.action-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.row-chevron-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
}
.row-chevron-btn:hover { color: var(--primary); }
.archive-delete-label { display: inline; }

/* Archive actions share one labeled oval-button system at every breakpoint.
   Layout rules below may stack or stretch them, but their visual language
   remains consistent. */
.archive-table td.archive-actions-cell .btn-outline-amfe,
.archive-table td.archive-actions-cell .row-chevron-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  width: 5.75rem;
  min-height: 2.25rem;
  padding: .4rem .7rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
.archive-table td.archive-actions-cell .row-chevron-btn {
  border: 1px solid #dc2626;
  color: #dc2626 !important;
  background: #fff;
}
.archive-table td.archive-actions-cell .row-chevron-btn:hover,
.archive-table td.archive-actions-cell .row-chevron-btn:focus-visible {
  border-color: #b42318;
  color: #b42318 !important;
  background: #fff1f1;
}

/* ===== ACTIVITY LOG: FILTER BAR ===== */
/* Gap lives here rather than on Bootstrap's .gap-2 utility so the mobile
   block below can widen the row-gap without an !important tug-of-war
   (every Bootstrap spacing utility ships !important). */
.activity-filter-bar { gap: 8px; }

/* The date button, select, and search box come from three different base
   classes with different paddings. Pinning one height keeps their labels on a
   single baseline when the row is bottom-aligned. */
.activity-filter-bar .date-range-btn,
.activity-filter-bar .filter-select,
.activity-filter-bar .search-input,
.activity-filter-bar .btn-outline-amfe,
.activity-filter-bar .btn-primary-amfe {
  height: 40px;
}
.activity-filter-bar .amfe-label { margin-bottom: 5px; }
.activity-filter-bar .btn-outline-amfe,
.activity-filter-bar .btn-primary-amfe {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
/* Groups Reset + Apply into one flex item so they stay side by side as a
   pair inside the outer row (desktop) or the stacked column (mobile). */
.activity-filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── ≤ 768px: one shared inspected/mobile treatment for Admin, Farmer and
   Entrepreneur activity logs — Search, Date Range, Action Type, then two
   equal pill actions. The outer .amfe-card .d-flex.flex-wrap rule (above,
   ≤768px) already switches the bar to a column stack. ── */
@media (max-width: 768px) {
  .activity-filter-bar { row-gap: 16px; }
  .activity-filter-bar .filter-group-search { order: 1; }
  .activity-filter-bar .filter-group-date { order: 2; }
  .activity-filter-bar .filter-group-action { order: 3; }
  .activity-filter-bar .filter-group-search,
  .activity-filter-bar .filter-group-date,
  .activity-filter-bar .filter-group-action { width: 100%; }

  /* Every control spans the card at one shared height, so the three
     stacked fields read as a single column of equal blocks. 44px is the
     touch-target floor; the base rule above pins 40px for the desktop row. */
  .activity-filter-bar .date-range-btn,
  .activity-filter-bar .filter-select,
  .activity-filter-bar .search-input {
    width: 100%;
    height: 44px;
  }
  /* .date-range-btn is an inline-flex button (icon · label · chevron), not a
     native control — pushing only its trailing chevron right leaves the icon
     and label grouped at the left, matching the select's arrow placement. */
  .activity-filter-bar .date-range-btn > i:last-child { margin-left: auto; }

  .activity-filter-bar .activity-filter-actions {
    order: 4;
    width: 100%;
    gap: 12px;
    margin-top: 4px;
  }
  .activity-filter-bar .activity-filter-actions .btn-outline-amfe,
  .activity-filter-bar .activity-filter-actions .btn-primary-amfe {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    min-width: 0;
    height: 44px;
    padding: 0 14px;
    border-radius: 999px;
    font-weight: 600;
    white-space: nowrap;
  }
  .activity-filter-bar .activity-filter-actions .btn-outline-amfe {
    border: 1.5px solid var(--primary);
    background: #fff;
    color: var(--primary);
  }
  .activity-filter-bar .activity-filter-actions .btn-outline-amfe:hover {
    background: var(--primary);
    color: #fff;
    text-decoration: none;
  }
}

/* ===== ACTIVITY LOG: MOBILE CARD LAYOUT (≤ 640px) =====
   Shared by admin's own table and the Components/ActivityLogTable used by
   the farmer and entrepreneur pages — scoped to .activity-table so it
   can't touch Members/Payroll/Sales, which have their own treatments
   (or none). Rows become flex cards: timestamp + action badge on one
   line, details below, admin's chevron pinned top-right. */
@media (max-width: 640px) {
  .activity-table,
  .activity-table tbody { display: block; }
  .activity-table thead { display: none; }

  /* Rows are stacked blocks now — nothing to scroll sideways. */
  .table-responsive:has(.activity-table) { overflow-x: visible; }

  /* The wrapping .amfe-card already draws a frame, so a bordered card per
     row would nest one card inside another and sit flush against its edge
     (the wrapper is .p-0). Rows are hairline-separated blocks instead —
     one card holding a list, which is what the desktop table reads as. */
  .activity-table tbody tr {
    display: block;
    position: relative;
    border-bottom: 1px solid var(--border);
    padding: 14px;
    background: #fff;
  }
  .activity-table tbody tr:last-child { border-bottom: none; }
  /* Mobile browsers keep :hover after a tap — don't leave a card tinted. */
  .activity-table tbody tr:hover { background: #fff; }

  /* Each cell is a label/value row so the column names stay visible once
     thead is hidden — same treatment #membersTable, .si-table and
     .archive-table already use. The label text comes from the data-label
     the markup already carries, so it can't drift from the <th>. */
  .activity-table tbody td {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    border: none;
    font-size: 13px;
  }
  .activity-table tbody td::before {
    content: attr(data-label);
    flex: 0 0 82px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    line-height: 1.4;
  }

  .activity-table tbody td[data-label="Date & Time"] { color: var(--text-muted); }

  .activity-table tbody td[data-label="Details"] {
    align-items: flex-start;
    color: var(--text-dark);
    line-height: 1.5;
    /* Descriptions carry product names and IDs that can arrive as one
       unbroken token — wrap them rather than widen the row. */
    overflow-wrap: anywhere;
    min-width: 0;
  }

  /* Out of flow, so the chevron holds one corner regardless of how the
     rows beneath it wrap (.activity-table tbody tr is already
     position:relative). Only the admin table has this cell. */
  .activity-table tbody td.activity-actions-cell {
    position: absolute;
    top: 10px;
    right: 12px;
    padding: 0;
  }
  .activity-table tbody td.activity-actions-cell::before { display: none; }
  /* Reserve the chevron's lane so a long value can't run underneath it. */
  .activity-table tbody tr:has(.activity-actions-cell) { padding-right: 46px; }

  /* Empty-state / loading row (colSpan placeholder, no data-label) */
  .activity-table tbody td[colspan] {
    display: block;
    text-align: center;
    padding: 10px 0;
  }
  .activity-table tbody td[colspan]::before { display: none; }
}

/* ── Touch pointers, wide viewport (tablet / touch laptop) ──────────
   responsive.css raises .btn-primary-amfe, .btn-outline-amfe and select
   to min-height:44px under (pointer: coarse). That beats the 40px this
   bar pins, so on a touch device the two buttons and the Action select
   grew to 44px while the date button and search box stayed at 40px —
   a bottom-aligned row on four different heights. Below 769px the
   mobile block already sets its own 44px, so this only covers the
   widths that still render the row horizontally. ── */
@media (pointer: coarse) and (min-width: 769px) {
  .activity-filter-bar .date-range-btn,
  .activity-filter-bar .filter-select,
  .activity-filter-bar .search-input,
  .activity-filter-bar .btn-outline-amfe,
  .activity-filter-bar .btn-primary-amfe {
    height: 44px;
  }
}

/* ===== ARCHIVE: TYPE FILTER — SEGMENTED CONTROL =====
   Same language as .ana-tabs on Analytics/Reports: one continuous rounded
   strip with hairline dividers and a single filled pill for the active
   item, instead of six separately-bordered buttons.

   Deliberately not reusing .ana-tab itself — that class is a fixed 72px
   (128px ≥1260px) wide, sized for four short labels. Archive has six of
   uneven length ("All" vs "Dried Batch"), so these size to content.
   The markup also drops Bootstrap's .d-flex/.flex-wrap, which is what
   `.amfe-card .d-flex.flex-wrap` was catching to stack it into a column. */
.archive-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  gap: 14px;
}

.archive-type-filter {
  display: inline-flex;
  flex-wrap: nowrap !important;
  gap: 0;
  min-width: 0;
  max-width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  /* Six tabs don't fit a phone. The strip scrolls rather than wrapping —
     wrapping would break the continuous-pill shape and strand a divider
     at the end of each row. */
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  scrollbar-width: thin;
  scrollbar-color: rgba(30, 77, 58, .55) transparent;
  cursor: grab;
}
.archive-type-filter > .archive-type-chip { flex-shrink: 0; }
.archive-type-filter:active { cursor: grabbing; }
.archive-type-filter::-webkit-scrollbar { height: 4px; }
.archive-type-filter::-webkit-scrollbar-track { background: transparent; }
.archive-type-filter::-webkit-scrollbar-thumb { background: rgba(30, 77, 58, .55); border-radius: 999px; }

.archive-type-chip {
  position: relative;
  flex: 0 0 auto;
  /* Fixed width, like .ana-tab — chips must all be the same size, so they
     can't be left to size from their own label ("All" vs "Dried Batch").
     84px is the widest label at this font plus breathing room. */
  width: 84px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 5px 4px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dark);
  font-family: 'DM Sans', sans-serif;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  scroll-snap-align: start;
  transition: all 0.15s;
}
.archive-type-chip i { font-size: 13px; }
.archive-type-chip.active { background: var(--primary); color: #fff; }
.archive-type-chip:hover:not(.active) { color: var(--primary); }

/* Hairline divider between inactive chips, suppressed on the one before
   the active pill so nothing collides with its rounded edge. */
.archive-type-chip:not(.active):not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0; top: 25%; bottom: 25%;
  width: 1px;
  background: var(--border);
}
.archive-type-chip:has(+ .archive-type-chip.active)::after { display: none; }

.archive-extra-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}
.archive-extra-filters .search-input,
.archive-extra-filters .filter-select,
.archive-extra-filters .date-range-btn { height: 40px; }
.archive-extra-filters .archive-search .search-input { width: 190px; }
.archive-extra-filters .filter-select { max-width: 142px; }
.archive-extra-filters .date-range-btn {
  min-width: 128px;
  justify-content: space-between;
  gap: 8px;
  white-space: nowrap;
}
.archive-filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.archive-filter-actions .btn-outline-amfe,
.archive-filter-actions .btn-primary-amfe {
  height: 40px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
/* Steps up with .ana-tab at the same breakpoint, so the two controls stay
   visually the same size across the admin area. Same 128px as .ana-tab. */
@media (min-width: 1260px) {
  .archive-type-chip { width: 128px; gap: 3px; padding: 7px 6px; font-size: 13px; }
  .archive-type-chip i { font-size: 16px; }
}

/* With the admin sidebar visible, medium laptops do not have enough usable
   content width for seven tabs and every filter on one line. Stack the two
   groups before either one can overflow. */
@media (max-width: 1750px) and (min-width: 768px) {
  .archive-toolbar { align-items: stretch; flex-direction: column; }
  .archive-extra-filters { justify-content: flex-start; }
  .archive-extra-filters .archive-search { flex: 1; }
  .archive-extra-filters .archive-search .search-input { width: 100%; }
}

/* Laptop layout: use the full card width for all eight archive choices
   (All plus the seven archive categories).
   This starts above the compact/Inspect range, whose swipeable sizing stays
   unchanged. The clamp values gently scale the controls across laptops. */
@media (min-width: 768px) and (max-width: 1750px) {
  .archive-type-filter {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    width: 100%;
    overflow: visible;
  }
  .archive-type-chip {
    width: 100%;
    min-width: 0;
    min-height: clamp(3rem, 3.5vw, 3.5rem);
    gap: clamp(1px, .15vw, 2px);
    padding: clamp(.28rem, .4vw, .4rem) .3rem;
    font-size: clamp(10.5px, .85vw, 13px);
  }
  .archive-type-chip i { font-size: clamp(13px, 1vw, 16px); }
}

/* ── Phones: swipeable category strip ───────────────────────────────
   Keeping every category on-screen made the labels collide. Each chip
   now keeps a readable width and the strip scrolls horizontally. */
@media (max-width: 767px) {
  .archive-toolbar { align-items: stretch; flex-direction: column; }
  .archive-type-filter {
    display: flex;
    width: 100%;
    overflow-x: auto;
  }
  .archive-type-chip {
    flex: 0 0 96px;
    width: 96px;
    min-width: 96px;
    min-height: 54px;
    padding: 6px 8px;
    font-size: 10.5px;
    white-space: nowrap;
    text-align: center;
  }
  .archive-type-chip i { font-size: 14px; }
  .archive-extra-filters { flex-wrap: wrap; justify-content: flex-start; }
  .archive-extra-filters .archive-search { flex: 1 0 100%; }
  .archive-extra-filters .archive-search .search-input { width: 100%; height: 44px; }
  .archive-extra-filters .filter-select { flex: 1 1 135px; max-width: none; height: 44px; }
  .archive-extra-filters .date-range-btn { flex: 1 1 100%; width: 100%; height: 44px; }
  .archive-filter-actions { flex: 1 1 100%; justify-content: flex-end; }
  .archive-filter-actions .btn-outline-amfe,
  .archive-filter-actions .btn-primary-amfe { height: 44px; }
}

@media (max-width: 420px) {
  .archive-extra-filters .filter-select,
  .archive-extra-filters .date-range-btn { flex: 1 1 100%; width: 100%; }
  .archive-filter-actions { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); }
  .archive-filter-actions .btn-outline-amfe,
  .archive-filter-actions .btn-primary-amfe {
    width: 100%;
    padding-right: 10px;
    padding-left: 10px;
    justify-content: center;
  }
}

/* ===== ARCHIVE TABLE → MOBILE CARDS (≤ 640px) =====
   Five columns (Type · Item · Details · Archived · actions) cannot fit a
   phone, so .table-responsive was scrolling sideways and clipping the
   Archived date. Same card treatment as .si-table, with Item promoted to
   the card heading. */
@media (max-width: 640px) {
  .archive-results-card {
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  .archive-table,
  .archive-table tbody { display: block; }
  .archive-table tbody { display: grid; gap: 14px; }
  .archive-table thead { display: none; }
  .table-responsive:has(.archive-table) { overflow-x: visible; }

  .archive-table tbody tr {
    display: block;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 5px 18px rgba(24, 49, 38, .07);
  }
  .archive-table tbody tr:last-child { border-bottom: 1px solid var(--border); }
  /* Mobile browsers keep :hover after a tap — don't strand a tinted card. */
  .archive-table tbody tr:hover { background: #fff; }

  .archive-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: none;
    border-right: none;
    font-size: 13px;
    min-width: 0;
  }
  .archive-table tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    flex-shrink: 0;
    min-width: 72px;
  }

  /* Item — card heading, full width, no label. */
  .archive-table tbody td.archive-td-item {
    display: block;
    font-size: 15px;
    font-weight: 700;
    padding-bottom: 10px;
    margin-bottom: 2px;
    border-bottom: 1.5px solid var(--border);
  }
  .archive-table tbody td.archive-td-item::before { display: none; }
  /* `.amfe-table tbody tr:last-child td` (0,2,3) outranks the rule above
     (0,2,2) and would strip the heading rule from the last card — the only
     card on a single-row table. Re-declare one level deeper. */
  .archive-table tbody tr:last-child td.archive-td-item {
    border-bottom: 1.5px solid var(--border);
  }

  /* The Archived cell carries an inline white-space:nowrap for the desktop
     table; inline styles beat stylesheet rules, so unwrapping it here needs
     !important or the long "date by name" string forces a sideways scroll. */
  .archive-table tbody td[data-label="Archived"] {
    white-space: normal !important;
    text-align: right;
    overflow-wrap: anywhere;
  }
  /* An unbroken id/reference in Details must not widen the card either. */
  .archive-table tbody td[data-label="Details"] {
    display: block;
    padding-block: 14px;
    text-align: left;
    overflow-wrap: anywhere;
  }
  .archive-table tbody td[data-label="Details"]::before {
    display: block;
    margin-bottom: 9px;
  }
  .archive-table tbody td[data-label="Type"] > *,
  .archive-table tbody td[data-label="Details"]:not(.archive-td-item),
  .archive-table tbody td[data-label="Archived"] {
    min-width: 0;
    max-width: 72%;
  }
  .archive-table tbody td[data-label="Details"] {
    width: 100%;
    max-width: 100%;
  }

  /* Match the phone card design: two full-width actions stacked vertically. */
  .archive-table tbody td.archive-actions-cell {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 10px !important;
    align-items: center;
    width: 100%;
    margin-top: .35rem;
    padding-top: .75rem;
    border-top: 1px solid var(--border);
  }
  .archive-table tbody td.archive-actions-cell::before { display: none; }
  .archive-table tbody td.archive-actions-cell .btn-outline-amfe {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: 2.65rem;
  }
  .archive-table tbody td.archive-actions-cell .row-chevron-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    width: 100%;
    min-height: 2.65rem;
    padding: .4rem .75rem;
    border: 1px solid #dc2626;
    border-radius: 999px;
    background: #fff;
    color: #dc2626 !important;
    font-size: .82rem;
    font-weight: 600;
  }
  .archive-table tbody td.archive-actions-cell .archive-delete-label { display: inline; }
  .archive-table tbody td.archive-actions-cell .row-chevron-btn:hover,
  .archive-table tbody td.archive-actions-cell .row-chevron-btn:focus-visible {
    background: #fff1f1;
    color: #dc2626 !important;
  }

  /* Empty-state row (colSpan placeholder, no data-label). */
  .archive-table tbody td[colspan] { display: block; text-align: center; }
  .archive-table tbody td[colspan]::before { display: none; }
}

@media (max-width: 380px) {
  .archive-table tbody tr { padding: 12px; }
  .archive-table tbody td { gap: 8px; }
  .archive-table tbody td::before { min-width: 64px; }
  .archive-table tbody td.archive-actions-cell {
    gap: 8px !important;
  }
}

/* Recorded Dried Batches keeps its compact four-column comparison on small
   screens. Reserve a stable Actions column and give both actions matching
   pill dimensions, as in the desktop table. */
@media (max-width: 767.98px) {
  body.admin-shell .recorded-dried-batches-card {
    overflow: hidden;
    border-radius: 1rem;
  }
  body.admin-shell .recorded-dried-batches-header {
    gap: .75rem;
    padding: 1rem 1rem .75rem !important;
  }
  body.admin-shell .recorded-dried-batches-header .history-title {
    min-width: 0;
    font-size: clamp(1rem, 4.7vw, 1.3rem);
    line-height: 1.25;
  }
  body.admin-shell .recorded-dried-batches-header .btn-outline-amfe {
    flex: 0 0 auto;
    min-height: 2.65rem;
    padding: .55rem 1rem;
    border-radius: 999px;
  }
  body.admin-shell .recorded-dried-batches-filters {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: .65rem !important;
    padding: .25rem 1rem 1rem !important;
  }
  body.admin-shell .recorded-dried-batches-filters .filter-select {
    width: 100%;
    min-width: 0;
    min-height: 3rem;
    padding: .65rem 2.25rem .65rem .85rem;
    border-radius: .7rem;
    font-size: .95rem;
  }
  body.admin-shell .recorded-dried-batches-card > .table-responsive {
    width: 100%;
    overflow-x: hidden;
  }
  body.admin-shell .recorded-dried-batches-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }
  body.admin-shell .recorded-dried-batches-table th,
  body.admin-shell .recorded-dried-batches-table td {
    min-width: 0;
    padding: clamp(.55rem, 2.4vw, .8rem) clamp(.25rem, 1.5vw, .55rem);
    font-size: clamp(.66rem, 2.8vw, .82rem);
    line-height: 1.35;
    overflow-wrap: anywhere;
  }
  body.admin-shell .recorded-dried-batches-table th:nth-child(1) { width: 17%; }
  body.admin-shell .recorded-dried-batches-table th:nth-child(2) { width: 20%; }
  body.admin-shell .recorded-dried-batches-table th:nth-child(3) { width: 25%; }
  body.admin-shell .recorded-dried-batches-table th:nth-child(4) { width: 38%; }
  body.admin-shell .recorded-dried-batches-table .month-group-row td {
    padding: .55rem .7rem;
    font-size: clamp(.72rem, 3vw, .9rem);
  }
  body.admin-shell .recorded-dried-batches-table td.prod-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: clamp(.25rem, 1.2vw, .45rem);
  }
  body.admin-shell .recorded-dried-batches-table td.prod-actions .btn-primary-amfe,
  body.admin-shell .recorded-dried-batches-table td.prod-actions .btn-outline-amfe,
  body.admin-shell .recorded-dried-batches-table td.prod-actions .btn-archive-amfe {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
    min-height: clamp(2.2rem, 9vw, 2.6rem);
    padding: .35rem .6rem;
    border-radius: 999px;
    font-size: clamp(.65rem, 2.7vw, .78rem);
    white-space: nowrap;
  }
}

/* ===== RECORDED DRIED BATCHES — ENHANCED STYLING ===== */
.recorded-dried-batches-card {
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(24, 49, 38, 0.05);
  border-radius: 12px;
  overflow: hidden;
}
.batch-header-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #fef3c7;
  color: #b45309;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}
.recorded-dried-batches-header .history-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-dark, #183126);
}
.recorded-dried-batches-filters-bar {
  background: #fafbfa;
  border-top: 1px solid #f0f2f1;
  border-bottom: 1px solid #e5ebe7;
}
.batch-filter-bar {
  display: inline-flex;
  align-items: stretch;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(24, 49, 38, 0.04);
}
.batch-filter-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
}
.batch-filter-divider {
  width: 1px;
  background: var(--border);
  flex-shrink: 0;
}
.batch-filter-icon {
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.batch-filter-select {
  border: none !important;
  background: transparent !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: var(--text-dark) !important;
  padding: 2px 20px 2px 0 !important;
  cursor: pointer;
  outline: none !important;
  box-shadow: none !important;
}
.btn-batch-clear-filter {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  transition: all .15s ease;
}
.btn-batch-clear-filter:hover {
  background: #f1f3f2;
  color: #e05252;
}
.batch-count-indicator {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: #f4f6f5;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.recorded-dried-batches-table .month-group-row td {
  background: #f4f8f5 !important;
  border-top: 1px solid #dce8e0 !important;
  border-bottom: 1px solid #dce8e0 !important;
  padding: 9px 16px !important;
}
.month-group-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #183126;
}
.month-group-accent {
  width: 3px;
  height: 13px;
  border-radius: 2px;
  background: #2d6a4f;
  display: inline-block;
  margin-right: 4px;
}
.recorded-dried-batches-table tbody tr.batch-data-row {
  transition: background-color .15s ease;
}
.recorded-dried-batches-table tbody tr.batch-data-row:hover {
  background-color: #f9fbf9;
}
.batch-date-icon {
  font-size: 13px;
  opacity: 0.7;
}
.batch-output-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  padding: 3px 8px;
  border-radius: 6px;
  background: #f0f7f3;
  color: #1b4d35;
}
.batch-output-pill strong {
  font-size: 14px;
  font-weight: 700;
  color: #183126;
}
.batch-output-unit {
  font-size: 11px;
  font-weight: 600;
  color: #2d6a4f;
}
.batch-notes-cell {
  font-size: 13px;
  max-width: 280px;
}
.batch-empty-state {
  border-radius: 0 0 12px 12px;
}

/* ===== SALES & INVENTORY — PERIOD FILTER BAR ===== */
/* This toolbar sits below the page heading and scopes every card/list below. */
.si-summary-row { margin-bottom: 24px; }
.si-period-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 24px; }
.si-breakdown { margin-bottom: 24px; }
.si-period-toolbar-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.si-filter-bar {
  display: inline-flex;
  align-items: stretch;
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(24, 49, 38, 0.06);
}
.si-filter-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
}
.si-filter-field--view { min-width: 172px; }
@media (max-width: 991.98px) {
  .si-period-toolbar { flex-direction: column; align-items: stretch; gap: 6px; }
  .si-period-toolbar-main { align-items: stretch; }
  .si-filter-bar { align-self: stretch; width: 100%; }
  /* min-width:0 — flex items default to min-width:auto, which refuses to
     shrink below the native <input type="month">'s own intrinsic width.
     That pinned this field wide enough to push the bar past the edge of
     small phones (body hides x-overflow, so it was invisibly clipped). */
  .si-filter-field { flex: 1; min-width: 0; }
}
@media (max-width: 650px) {
  .si-period-toolbar-main { flex-direction: column; gap: 6px; }
  .si-filter-bar { flex-direction: column; }
  .si-filter-divider { display: none; }
  .si-filter-field:not(:first-child) { border-top: 1px solid var(--border); }
  .si-filter-input, .si-filter-select { flex: 1; min-width: 0; }
}
.si-filter-divider { width: 1px; background: var(--border); flex-shrink: 0; }
.si-filter-icon { font-size: 14px; color: var(--text-muted); flex-shrink: 0; }
.si-filter-select,
.si-filter-input {
  border: none;
  background: transparent;
  outline: none;
  padding: 0;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-dark);
  cursor: pointer;
}

/* Give the period control more presence on laptop screens without changing
   the compact phone/Inspect layout. */
@media (min-width: 1024px) and (max-width: 1750px) {
  .si-filter-field {
    min-height: 3.35rem;
    gap: .65rem;
    padding: .75rem 1rem;
  }
  .si-filter-field--view { min-width: 13rem; }
  .si-filter-select,
  .si-filter-input { font-size: 1rem; }
  .si-filter-icon,
  .si-filter-input > i { font-size: 1.05rem; }
}
.si-filter-select {
  -webkit-appearance: none; appearance: none;
  padding-right: 20px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236c757d' stroke-width='1.6' d='M1 1.5 6 6.5l5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right center;
}

/* The all-sales / all-expenses modals deliberately ignore the page's period
   filter, so they say so under the title — otherwise their total reads as a
   contradiction of the period total on the page behind them. */
.si-modal-scope-note {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.si-breakdown-modal-toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin: 10px 0 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f7f9f8;
}
.si-breakdown-filter-group { min-width: 0; }
.si-breakdown-filter-group .amfe-label { display: block; margin: 0 0 6px; font-size: 12px; }
.si-breakdown-filter-group .si-select { width: 100%; min-height: 42px; background-color: #fff; }
.si-breakdown-table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
}
.si-breakdown-table-wrap .si-table { margin-bottom: 0; }
@media (max-width: 576px) {
  .si-breakdown-modal-toolbar { grid-template-columns: 1fr; padding: 12px; }
  .si-breakdown-table-wrap { border: 0; border-radius: 0; }
}

/* ============================================================
   MOBILE / TABLET: ONE GAP UNDER THE FIXED TOP BAR
   On phones and tablets role-shell.css pulls .page-title out of
   flow into the fixed green top bar, so the pages that open on a
   bare .page-title — Members, Resource Allocation, Analytics,
   Settings, Activity Log, Archive — had their first card land
   right against the bar with only the shell's flat 10px between
   them. Pages that open on an in-flow header instead
   (.payroll-header, .prod-header, .rep-topbar, .si-page-header)
   sat at that same 10px, so nothing on the admin side had room.

   The shell's padding-top is what separates the two, so this
   restates it 10px larger to land on the 20px every admin page
   uses on desktop. Restated rather than composed because
   .main-content IS the <main> element here — unlike the farmer
   and entrepreneur shells, which nest a <main> inside
   #main-content and can take the extra padding on the inner box.

   `main.main-content` (0,0,1,1) out-specifies the plain
   `.main-content` (0,0,1,0) in role-shell.css and responsive.css;
   both of those declare !important, so this must too. `screen`
   keeps it away from the Reports print sheet.
   ============================================================ */
@media screen and (max-width: 991px) {
  main.main-content {
    padding-top: calc(80px + env(safe-area-inset-top)) !important;
  }
}

/* Short landscape runs a 48px bar instead of 60px (responsive.css), so it
   needs its own figure — without this the rule above would leave 32px
   there. Same specificity, declared later, so it wins where it matches. */
@media screen and (max-width: 991px) and (orientation: landscape) and (max-height: 500px) {
  main.main-content {
    padding-top: calc(68px + env(safe-area-inset-top)) !important;
  }
}

/* Headers that empty out on phones ────────────────────────────────────────
   Four admin pages open on an in-flow header wrapper instead of a bare
   .page-title. On phones both of the things those wrappers hold go away:
   .page-title is pulled into the fixed top bar (role-shell.css) and the
   "Add" button collapses into the floating .mobile-add-fab. What is left
   is an empty box still spending its bottom margin — Bootstrap's `mb-4`
   (24px) on Products and Sales & Inventory, 12px on Production — which
   stacked on the gap above and pushed those pages well below the rest.

   Reports is the same shape without the button: .rep-topbar holds only the
   title, so it is empty across the whole mobile range, not just phones.

   Scoped through .main-content because that class is the Admin shell alone
   — Farmer/Production shares .prod-header and keeps its own margin. */
@media screen and (max-width: 991px) {
  .main-content .rep-topbar { margin-bottom: 0; }
}

/* 576.98px, not 991px: above this the Add button(s) are still in the header
   row (.si-add-btn goes display:none only at the FAB breakpoint), so the
   wrapper is a real row there and has to keep its margin. `mb-4` is a
   Bootstrap utility and so carries !important — this must too. */
@media screen and (max-width: 576.98px) {
  .main-content .si-page-header,
  .main-content .prod-header {
    margin-bottom: 0 !important;
  }
}

/* Keep the announcement action beside the desktop message and bell buttons.
   The tablet header retains its in-flow button; phones use the existing FAB. */
.ann-tablet-add { display: none; }
@media (max-width: 767.98px) {
  .ann-topbar-add { display: none; }
}

/* Branded confirmation dialog used for archive, restore, and permanent delete. */
.action-confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(15, 23, 42, .58);
  backdrop-filter: blur(2px);
  animation: action-confirm-fade .16s ease-out;
}
.action-confirm-modal {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  padding: clamp(20px, 5vw, 28px);
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .25);
  text-align: center;
  animation: action-confirm-rise .18s ease-out;
}
.action-confirm-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 18px;
  border-radius: 14px;
  font-size: 1.3rem;
}
.action-confirm-icon--danger { color: #b42318; background: #fee4e2; }
.action-confirm-icon--warning { color: #855e06; background: #ffedb7; }
.action-confirm-icon--success { color: #176b47; background: #e7f5ed; }
.action-confirm-copy h2 {
  margin: 0 0 8px;
  color: #17251f;
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
}
.action-confirm-copy p {
  margin: 0;
  color: #667085;
  line-height: 1.55;
  text-align: center;
  overflow-wrap: anywhere;
}
/* Spacious, centered logout confirmation with a clear warning hierarchy. */
.action-confirm-modal--logout {
  position: relative;
  width: min(100%, 430px);
  padding: 34px 32px 30px;
  border-color: #dbe3ef;
  border-radius: 20px;
  text-align: center;
}
.action-confirm-modal--logout .action-confirm-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 20px;
  border-radius: 17px;
  color: #b42318;
  background: #fee4e2;
  font-size: 1.55rem;
}
.action-confirm-modal--logout .action-confirm-copy h2 {
  margin-bottom: 10px;
  color: #0b294d;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1.2;
}
.action-confirm-modal--logout .action-confirm-copy p {
  color: #718096;
  font-size: .98rem;
  font-weight: 400;
  line-height: 1.6;
}
.action-confirm-modal--logout .action-confirm-actions {
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}
.action-confirm-modal--logout .action-confirm-cancel,
.action-confirm-modal--logout .action-confirm-submit {
  min-width: 124px;
  min-height: 46px;
  border: 0;
  border-radius: 11px;
  font-size: .92rem;
  font-weight: 750;
}
.action-confirm-modal--logout .action-confirm-cancel {
  color: #0b294d;
  background: #f0f4f8;
}
.action-confirm-modal--logout .action-confirm-cancel:hover { background: #e5ebf2; }
.action-confirm-modal--logout .action-confirm-submit--danger {
  color: #fff;
  background: #c72a20;
  box-shadow: 0 10px 24px rgba(180, 35, 24, .2);
}
.action-confirm-modal--logout .action-confirm-submit--danger:hover { background: #a9221a; }
.action-confirm-close {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid #dbe3ef;
  border-radius: 10px;
  color: #526174;
  background: #f8fafc;
  cursor: pointer;
  font-size: 1rem;
}
.action-confirm-close:hover { color: #0b294d; background: #eef3f8; }
.action-confirm-close:focus-visible { outline: 3px solid rgba(30, 77, 58, .25); outline-offset: 2px; }
.action-confirm-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 26px;
}
.action-confirm-cancel,
.action-confirm-submit {
  min-height: 42px;
  padding: 9px 18px;
  border-radius: 10px;
  font-weight: 650;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
.action-confirm-cancel {
  border: 1px solid #d0d5dd;
  color: #344054;
  background: #fff;
}
.action-confirm-cancel:hover { background: #f8faf9; }
.action-confirm-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  color: #fff;
}
.action-confirm-submit--danger { background: #b42318; }
.action-confirm-submit--danger:hover { background: #912018; }
.action-confirm-submit--warning { background: #1e4d3a; }
.action-confirm-submit--warning:hover { background: #163c2d; }
.action-confirm-submit--success { background: #1e4d3a; }
.action-confirm-submit--success:hover { background: #163c2d; }
.action-confirm-cancel:focus-visible,
.action-confirm-submit:focus-visible { outline: 3px solid rgba(30, 77, 58, .25); outline-offset: 2px; }
.action-confirm-cancel:disabled,
.action-confirm-submit:disabled { cursor: not-allowed; opacity: .65; }
@keyframes action-confirm-fade { from { opacity: 0; } }
@keyframes action-confirm-rise { from { opacity: 0; transform: translateY(8px) scale(.985); } }
@media (max-width: 480px) {
  .action-confirm-modal { padding: 22px; border-radius: 16px; }
  .action-confirm-actions { flex-direction: column-reverse; }
  .action-confirm-cancel, .action-confirm-submit { width: 100%; }
  .action-confirm-modal--logout { width: min(100%, 18.5rem); padding: 42px 16px 18px; border-radius: 16px; }
  .action-confirm-modal--logout .action-confirm-icon { width: 46px; height: 46px; margin-bottom: 14px; border-radius: 13px; font-size: 1.25rem; }
  .action-confirm-modal--logout .action-confirm-copy h2 { margin-bottom: 7px; font-size: 1.25rem; }
  .action-confirm-modal--logout .action-confirm-copy p { font-size: .86rem; line-height: 1.45; }
  .action-confirm-modal--logout .action-confirm-actions { gap: 8px; margin-top: 18px; }
  .action-confirm-modal--logout .action-confirm-cancel,
  .action-confirm-modal--logout .action-confirm-submit { width: 100%; min-height: 40px; padding-block: 7px; font-size: .85rem; }
  .action-confirm-modal--logout .action-confirm-close { top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 8px; font-size: .85rem; }
}
@media (max-width: 480px) and (orientation: landscape), (max-height: 430px) {
  .action-confirm-modal--logout { padding-top: 20px; }
  .action-confirm-modal--logout .action-confirm-icon { margin-bottom: 10px; }
  .action-confirm-modal--logout .action-confirm-actions { flex-direction: row; margin-top: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .action-confirm-backdrop, .action-confirm-modal { animation: none; }
}

/* ============================================================
   ADMIN NAVIGATION SHELL
   One responsive sidebar shared by every /admin page.
   ============================================================ */
body.admin-shell {
  --sidebar-bg: #1f4d3a;
  --sidebar-width: 15rem;
  --sidebar-active: #a8d5b5;
}
body.admin-shell.sidebar-collapsed { --sidebar-width: 4rem; }
body.admin-shell.admin-drawer-open { overflow: hidden; }

body.admin-shell .admin-sidebar {
  width: var(--sidebar-width);
  height: 100dvh;
  min-height: 0;
  padding: 0;
  color: rgba(255,255,255,.9);
  background: var(--sidebar-bg);
  border: 0;
  box-shadow: none;
  overflow: visible;
  transition: width .25s ease, transform .25s ease;
}
body.admin-shell .admin-sidebar:hover { box-shadow: none; }
body.admin-shell .admin-sidebar .sidebar-brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex: 0 0 auto;
  min-height: 6.2rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid #fff;
}
.admin-avatar,
.admin-mobile-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  color: var(--sidebar-bg);
  background: #dceee2;
  font-size: 1.5rem;
}
body.admin-shell .admin-sidebar .brand-copy { min-width: 0; }
body.admin-shell .admin-sidebar .brand-name {
  color: #fff;
  font-family: 'DM Serif Display', serif;
  font-size: 1.55rem;
  line-height: 1;
  letter-spacing: .01em;
}
body.admin-shell .admin-sidebar .brand-sub { margin-top: .3rem; color: rgba(255,255,255,.65); font-size: .72rem; }
.sidebar-collapse-toggle {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: .5rem;
  color: rgba(255,255,255,.82);
  background: rgba(255,255,255,.08);
  cursor: pointer;
}
.sidebar-collapse-toggle:hover { background: rgba(255,255,255,.16); }

body.admin-shell .admin-sidebar .sidebar-nav {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  padding: .75rem 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.3) transparent;
}
body.admin-shell .admin-sidebar .sidebar-nav > .nav {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0 .6rem;
}
body.admin-shell .admin-sidebar .sidebar-nav::-webkit-scrollbar { width: .3rem; }
body.admin-shell .admin-sidebar .sidebar-nav::-webkit-scrollbar-thumb { border-radius: 1rem; background: rgba(255,255,255,.3); }
body.admin-shell .admin-sidebar .nav-item { width: 100%; min-width: 0; margin-bottom: .25rem; }
body.admin-shell .admin-sidebar .nav-link,
body.admin-shell .admin-sidebar .nav-group-toggle,
body.admin-shell .admin-sidebar .footer-icon-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: .7rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  padding: .65rem .75rem;
  border: 0;
  border-radius: .75rem;
  color: rgba(255,255,255,.76);
  background: transparent;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: color .15s ease, background-color .15s ease;
}
body.admin-shell .admin-sidebar .nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
body.admin-shell .admin-sidebar .nav-link > i:first-child { width: 1.5rem; color: inherit; font-size: 1.2rem; text-align: center; }
body.admin-shell .admin-sidebar .nav-link:hover,
body.admin-shell .admin-sidebar .nav-group-toggle:hover,
body.admin-shell .admin-sidebar .footer-icon-link:hover { color: #fff; background: rgba(255,255,255,.08); }
body.admin-shell .admin-sidebar .nav-link.active {
  color: var(--sidebar-bg) !important;
  background: var(--sidebar-active);
  font-weight: 600;
}
body.admin-shell .admin-sidebar .nav-link.active i { color: var(--sidebar-bg) !important; }
body.admin-shell .admin-sidebar .nav-group-toggle.active-group:not(:hover) { color: #fff; }
body.admin-shell .admin-sidebar .group-chevron {
  flex: 0 0 auto;
  width: auto !important;
  margin-left: auto;
  color: #fff !important;
  opacity: 1;
  font-size: .8rem !important;
  transition: transform .2s ease;
}
.nav-group.open .group-chevron { transform: rotate(180deg); }
.nav-submenu { max-height: 0; overflow: hidden; opacity: 0; transition: max-height .22s ease, opacity .15s ease; }
.nav-group.open .nav-submenu { max-height: 30rem; opacity: 1; }
/* Keep expanded group items aligned with their parent row at every viewport.
   Tablet and mobile drawers already use this alignment; matching it here
   prevents the laptop sidebar from shifting submenu icons and labels inward. */
body.admin-shell .admin-sidebar .nav-sub-link { min-height: 2.55rem; padding-left: .75rem; font-size: .82rem; }
body.admin-shell .admin-sidebar .nav-sub-link > i:first-child { font-size: 1rem; }

body.admin-shell .admin-sidebar .sidebar-footer {
  position: relative;
  flex: 0 0 auto;
  padding: .65rem .75rem max(.75rem, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,.15);
}
body.admin-shell .admin-sidebar .lang-switch-sidebar { margin-bottom: .4rem; background: rgba(255,255,255,.82); }
body.admin-shell .admin-sidebar .lang-switch-opt.active { background: var(--sidebar-bg); }
body.admin-shell .admin-sidebar .logout-link { justify-content: flex-start; }
body.admin-shell .admin-sidebar .logout-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.collapsed-language { display: none; position: relative; }
.language-popup {
  position: fixed;
  left: 4.4rem;
  bottom: 4.25rem;
  z-index: 1080;
  display: flex;
  gap: .25rem;
  padding: .35rem;
  border: 1px solid var(--border);
  border-radius: .7rem;
  background: #fff;
  box-shadow: var(--shadow-lg);
}
.language-popup button { min-height: 2.5rem; padding: .4rem .8rem; border: 0; border-radius: .5rem; background: transparent; color: var(--primary); }
.language-popup button.active { color: #fff; background: var(--sidebar-bg); }

body.admin-shell .admin-main {
  width: calc(100% - var(--sidebar-width));
  max-width: none;
  margin-left: var(--sidebar-width);
  padding-inline: clamp(1rem, 2vw, 2rem);
  transition: margin-left .25s ease, width .25s ease;
}
.admin-mobile-bar { display: none; }
.admin-nav-flyout {
  position: fixed;
  left: 4.35rem;
  z-index: 1070;
  width: 13.5rem;
  max-height: min(25rem, calc(100dvh - 1rem));
  padding: .5rem;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: .75rem;
  color: #fff;
  background: var(--sidebar-bg);
  box-shadow: 0 .75rem 2rem rgba(0,0,0,.24);
}
.admin-nav-flyout-title { padding: .45rem .65rem .6rem; color: rgba(255,255,255,.62); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.admin-nav-flyout .nav-link { display: flex; align-items: center; gap: .65rem; min-height: 2.75rem; padding: .6rem .7rem; border-radius: .55rem; color: rgba(255,255,255,.82); text-decoration: none; }
.admin-nav-flyout .nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.admin-nav-flyout .nav-link.active { color: var(--sidebar-bg); background: var(--sidebar-active); }

body.admin-shell.sidebar-collapsed .admin-sidebar .sidebar-brand { min-height: 7.1rem; padding: .75rem .5rem; flex-direction: column; gap: .6rem; }
body.admin-shell.sidebar-collapsed .admin-sidebar .brand-copy,
body.admin-shell.sidebar-collapsed .admin-sidebar .nav-label { display: none; }
body.admin-shell.sidebar-collapsed .admin-sidebar .sidebar-collapse-toggle { position: absolute; right: -.65rem; bottom: -.65rem; border: 2px solid var(--sidebar-bg); background: var(--sidebar-active); color: var(--sidebar-bg); }
body.admin-shell.sidebar-collapsed .admin-sidebar .sidebar-nav { padding-inline: 0; scrollbar-width: none; }
body.admin-shell.sidebar-collapsed .admin-sidebar .sidebar-nav > .nav { padding-inline: .5rem; }
body.admin-shell.sidebar-collapsed .admin-sidebar .sidebar-nav::-webkit-scrollbar { display: none; }
body.admin-shell.sidebar-collapsed .admin-sidebar .nav-link { justify-content: center; gap: 0; padding-inline: .35rem; }
body.admin-shell.sidebar-collapsed .admin-sidebar .nav-link > i:first-child { font-size: 1.35rem; }
body.admin-shell.sidebar-collapsed .admin-sidebar .group-chevron { position: absolute; right: .2rem; bottom: .25rem; display: block; font-size: .52rem !important; }
body.admin-shell.sidebar-collapsed .admin-sidebar .nav-submenu { display: none; }
body.admin-shell.sidebar-collapsed .admin-sidebar .expanded-language { display: none; }
body.admin-shell.sidebar-collapsed .admin-sidebar .collapsed-language { display: block; }
body.admin-shell.sidebar-collapsed .admin-sidebar .sidebar-footer { padding-inline: .5rem; }
body.admin-shell.sidebar-collapsed .admin-sidebar .sidebar-footer .nav-link,
body.admin-shell.sidebar-collapsed .admin-sidebar .footer-icon-link { justify-content: center; padding-inline: .35rem; }
body.admin-shell.sidebar-collapsed .admin-sidebar [data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + .65rem);
  top: 50%;
  z-index: 1090;
  padding: .4rem .6rem;
  border-radius: .4rem;
  color: #fff;
  background: #16392c;
  font-size: .75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(.25rem, -50%);
  transition: opacity .15s ease, transform .15s ease;
}
body.admin-shell.sidebar-collapsed .admin-sidebar [data-tooltip]:hover::after { opacity: 1; transform: translate(0, -50%); }

body.admin-shell .table-responsive { max-width: 100%; overflow-x: auto; }
body.admin-shell img { max-width: 100%; height: auto; }
/* Override the shell's generic responsive-image height specifically for
   product cards so object-fit can scale the whole image into its frame. */
body.admin-shell .product-img-wrap img { width: 100%; height: 100%; object-fit: contain; }
body.admin-shell .dash-stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(12.5rem, 100%), 1fr)); }
body.admin-shell .dash-stats-row > .col { width: auto; }

@media (min-width: 1024px) and (max-width: 1439.98px) {
  body.admin-shell .dash-stats-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1440px) {
  body.admin-shell .dash-stats-row { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (min-width: 768px) and (max-width: 1023.98px) {
  body.admin-shell { --sidebar-width: 4rem; }
  body.admin-shell .admin-sidebar { left: 0 !important; right: auto !important; transform: none !important; z-index: 1050; }
  body.admin-shell .admin-sidebar.show { width: 15rem; }
  body.admin-shell .admin-sidebar.show .sidebar-brand { min-height: 6.2rem; padding: .75rem 1rem; flex-direction: row; }
  body.admin-shell .admin-sidebar.show .brand-copy,
  body.admin-shell .admin-sidebar.show .nav-label { display: block; }
  body.admin-shell .admin-sidebar.show .sidebar-collapse-toggle { position: static; margin-left: auto; border: 0; color: #fff; background: rgba(255,255,255,.08); }
  body.admin-shell .admin-sidebar.show .sidebar-nav { padding-inline: 0; scrollbar-width: thin; }
  body.admin-shell .admin-sidebar.show .sidebar-nav > .nav { padding-inline: .6rem; }
  body.admin-shell .admin-sidebar.show .nav-link { justify-content: flex-start; gap: .7rem; padding-inline: .75rem; }
  body.admin-shell .admin-sidebar.show .nav-submenu { display: none; }
  body.admin-shell .admin-sidebar.show .nav-group.open .nav-submenu { display: block; }
  body.admin-shell .admin-sidebar.show .group-chevron { position: static; margin-left: auto; font-size: .8rem !important; }
  body.admin-shell .admin-sidebar.show .expanded-language { display: block; }
  body.admin-shell .admin-sidebar.show .collapsed-language { display: none; }
  body.admin-shell .admin-sidebar.show .sidebar-footer { padding-inline: .75rem; }
  body.admin-shell .admin-sidebar.show .sidebar-footer .nav-link { justify-content: flex-start; padding-inline: .75rem; }
  /* A tablet rail keeps `sidebar-collapsed` on body. When the rail is
     expanded as a drawer, these equally specific rules restore the full
     navigation instead of leaving an extra-wide icon-only panel. */
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .sidebar-brand { min-height: 6.2rem; padding: .75rem 1rem; flex-direction: row; gap: .75rem; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .brand-copy,
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .nav-label { display: block; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .sidebar-collapse-toggle { position: static; margin-left: auto; border: 0; color: #fff; background: rgba(255,255,255,.08); }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .sidebar-nav { padding-inline: 0; scrollbar-width: thin; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .sidebar-nav > .nav { padding-inline: .6rem; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .nav-link { justify-content: flex-start; gap: .7rem; padding-inline: .75rem; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .nav-group.open .nav-submenu { display: block; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .group-chevron { position: static; display: inline-block; width: auto; margin-left: auto; font-size: .8rem !important; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .expanded-language { display: block; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .collapsed-language { display: none; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .sidebar-footer { padding-inline: .75rem; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .sidebar-footer .nav-link { justify-content: flex-start; padding-inline: .75rem; }
  body.admin-shell .admin-sidebar-overlay.show { display: block; opacity: 1; visibility: visible; }
  body.admin-shell .admin-main { margin-left: 4rem !important; width: calc(100% - 4rem); }
  body.admin-shell .dash-stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767.98px) {
  body.admin-shell { --sidebar-width: 0rem; }
  body.admin-shell .admin-mobile-bar {
    position: fixed;
    inset: 0 0 auto;
    z-index: 1035;
    display: flex;
    align-items: center;
    height: calc(3.75rem + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) .75rem 0;
    color: #fff;
    background: var(--sidebar-bg);
  }
  .admin-mobile-menu { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; padding: 0; border: 0; border-radius: .6rem; color: #fff; background: transparent; font-size: 1.65rem; }
  .admin-mobile-avatar { width: 2.35rem; height: 2.35rem; margin-left: .35rem; font-size: 1.3rem; }
  .admin-mobile-actions { display: flex; gap: .15rem; margin-left: auto; }
  body.admin-shell .admin-mobile-actions .notification-bell-btn,
  body.admin-shell .admin-mobile-actions .topbar-message-btn { position: relative; inset: auto; display: flex; width: 2.75rem; height: 2.75rem; color: #fff; }
  body.admin-shell .admin-desktop-actions { display: none; }
  body.admin-shell .admin-sidebar { left: 0 !important; right: auto !important; width: min(17.5rem, 85vw) !important; transform: translateX(-100%) !important; z-index: 1050; }
  body.admin-shell .admin-sidebar.show { transform: translateX(0) !important; }
  body.admin-shell .admin-sidebar .sidebar-brand { min-height: 6.2rem; padding: .75rem 1rem; flex-direction: row; }
  body.admin-shell .admin-sidebar .brand-copy,
  body.admin-shell .admin-sidebar .nav-label { display: block; }
  body.admin-shell .admin-sidebar .sidebar-collapse-toggle { display: none; }
  body.admin-shell .admin-sidebar .sidebar-nav { padding-inline: 0; scrollbar-width: thin; }
  body.admin-shell .admin-sidebar .sidebar-nav > .nav { padding-inline: .6rem; }
  body.admin-shell .admin-sidebar .nav-link { justify-content: flex-start; gap: .7rem; padding-inline: .75rem; }
  body.admin-shell .admin-sidebar .nav-submenu { display: none; }
  body.admin-shell .admin-sidebar .nav-group.open .nav-submenu { display: block; }
  body.admin-shell .admin-sidebar .group-chevron { position: static; margin-left: auto; font-size: .8rem !important; }
  body.admin-shell .admin-sidebar .expanded-language { display: block; }
  body.admin-shell .admin-sidebar .collapsed-language { display: none; }
  body.admin-shell .admin-sidebar .sidebar-footer { padding-inline: .75rem; }
  body.admin-shell .admin-sidebar .sidebar-footer .nav-link { justify-content: flex-start; padding-inline: .75rem; }
  /* The persisted desktop collapse preference must never turn the phone
     drawer into a blank icon rail. A phone always opens the complete menu. */
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .sidebar-brand { min-height: 6.2rem; padding: .75rem 1rem; flex-direction: row; gap: .75rem; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .brand-copy,
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .nav-label { display: block; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .sidebar-collapse-toggle { display: none; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .sidebar-nav { padding-inline: 0; scrollbar-width: thin; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .sidebar-nav > .nav { padding-inline: .6rem; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .nav-link { justify-content: flex-start; gap: .7rem; padding-inline: .75rem; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .nav-submenu { display: none; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .nav-group.open .nav-submenu { display: block; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .group-chevron { position: static; display: inline-block; width: auto; margin-left: auto; font-size: .8rem !important; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .expanded-language { display: block; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .collapsed-language { display: none; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .sidebar-footer { padding-inline: .75rem; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show .sidebar-footer .nav-link { justify-content: flex-start; padding-inline: .75rem; }
  body.admin-shell.sidebar-collapsed .admin-sidebar.show [data-tooltip]::after { display: none; }
  body.admin-shell .admin-sidebar-overlay.show { display: block; opacity: 1; visibility: visible; }
  body.admin-shell .admin-main {
    width: 100%;
    margin-left: 0 !important;
    padding: calc(3.75rem + env(safe-area-inset-top)) .75rem calc(1.5rem + env(safe-area-inset-bottom)) !important;
  }
  body.admin-shell .admin-main.has-mobile-fab,
  body.admin-shell .admin-main:has(.mobile-add-fab),
  body.admin-shell .admin-main:has(.ra-floating-add),
  body.admin-shell .admin-main:has(.mobile-add-menu) {
    padding-bottom: calc(72px + env(safe-area-inset-bottom)) !important;
  }
  body.admin-shell .admin-main .page-title {
    position: static !important;
    height: auto;
    margin: 0 0 1rem;
    padding: 0 !important;
    color: var(--text-dark) !important;
    background: transparent;
    font-size: clamp(1.65rem, 7vw, 1.9rem) !important;
    line-height: 1.2;
  }
  body.admin-shell .dash-stats-row { grid-template-columns: 1fr; }
}

@media (hover: none) {
  body.admin-shell.sidebar-collapsed .admin-sidebar [data-tooltip]::after { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  body.admin-shell .admin-sidebar,
  body.admin-shell .admin-main,
  body.admin-shell .nav-submenu,
  body.admin-shell .group-chevron { scroll-behavior: auto; transition: none; }
}

/* ============================================================
   ADMIN PAGE RESPONSIVENESS
   Final admin-scoped overrides prevent shared Farmer/role-shell rules
   from reshaping Admin headers and controls on phones and tablets.
   ============================================================ */
body.admin-shell .admin-main,
body.admin-shell .admin-main > *,
body.admin-shell .admin-main .row > * { min-width: 0; }
body.admin-shell .admin-main .amfe-card { max-width: 100%; }

@media (min-width: 768px) and (max-width: 1023.98px) {
  body.admin-shell .admin-main {
    min-width: 0;
    overflow-x: clip;
    padding-inline: clamp(.85rem, 2vw, 1.25rem) !important;
    padding-block: 0 5rem !important;
  }
  body.admin-shell .admin-main > * { min-width: 0; max-width: 100%; }
  body.admin-shell .admin-main .page-title {
    position: static;
    inset: auto;
    width: auto;
    height: auto;
    margin: 0 0 1.25rem;
    padding: 0 5.5rem 0 0;
    overflow: visible;
    color: var(--text-dark);
    background: transparent;
    font-size: clamp(1.75rem, 3.5vw, 2.05rem);
    line-height: 1.2;
    white-space: normal;
  }
  body.admin-shell .admin-main .prod-header,
  body.admin-shell .admin-main .payroll-header {
    display: flex;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    text-align: left;
  }
  body.admin-shell .admin-main .prod-header .page-title,
  body.admin-shell .admin-main .payroll-header .page-title {
    margin-right: auto;
    padding-right: 14rem;
    text-align: left;
  }
  body.admin-shell .admin-desktop-actions {
    position: absolute;
    inset: 1rem 1.25rem auto auto;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: .4rem;
    min-height: 0;
    margin: 0;
  }
  body.admin-shell .admin-desktop-actions > .btn-add-product {
    min-height: 2.5rem;
    padding: .55rem 1rem;
    font-size: .82rem;
  }
  body.admin-shell .admin-desktop-actions > .btn-add-product,
  body.admin-shell .admin-desktop-actions > .si-topbar-add {
    order: -1;
  }
  body.admin-shell .admin-desktop-actions .notification-bell-btn,
  body.admin-shell .admin-desktop-actions .topbar-message-btn {
    position: relative;
    inset: auto;
    width: 2.5rem;
    height: 2.5rem;
    border: 1.5px solid var(--border, #d8dfd9);
    border-radius: .6rem;
    color: var(--text-dark, #1e4d3a);
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
  }
  body.admin-shell .admin-desktop-actions .notification-bell-btn i,
  body.admin-shell .admin-desktop-actions .topbar-message-btn i { font-size: 1.2rem; }
  body.admin-shell .admin-desktop-actions .notification-bell-btn .notification-badge {
    top: 1px;
    right: 1px;
    min-width: 12px;
    height: 12px;
    padding-inline: 2px;
    border-width: 1px;
    font-size: 7px;
  }
  body.admin-shell .admin-desktop-actions .topbar-message-btn.active,
  body.admin-shell .admin-desktop-actions .topbar-message-btn.active:hover {
    border-color: var(--primary, #1e4d3a);
    color: #fff;
    background: var(--primary, #1e4d3a);
  }

  /* A phone using the browser's “Desktop site” option normally reports a
     viewport close to 980 CSS pixels. Keep the real desktop inquiry
     arrangement at that width, but let both panes shrink safely beside the
     icon rail instead of stacking them into the phone layout. */
  body.admin-shell .messages-layout {
    flex-direction: row;
    height: calc(100dvh - 8rem);
    min-height: 28rem;
    gap: .75rem;
  }
  body.admin-shell .inbox-panel {
    flex: 0 1 17rem;
    width: min(17rem, 34%);
    min-width: 13rem;
    height: auto;
  }
  body.admin-shell .chat-panel { min-width: 0; min-height: 0; }
  body.admin-shell .chat-header { padding: .75rem 1rem 0; }
  body.admin-shell .chat-messages { padding: .85rem 1rem; }
  body.admin-shell .chat-footer { padding: .7rem .85rem; }
  body.admin-shell .chat-footer textarea { min-width: 0; }
  body.admin-shell .members-filter-row { align-items: stretch; flex-direction: column; }
  body.admin-shell .members-filter-selects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; }
  body.admin-shell .members-filter-selects .filter-select { width: 100%; min-width: 0; }
  body.admin-shell .members-filter-selects .dropdown { grid-column: 3; grid-row: 1; }
  body.admin-shell .members-filter-selects .btn-link-reset { grid-column: 1 / -1; grid-row: 2; justify-self: start; }
  body.admin-shell .payroll-type-selector {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: .5rem;
    padding: .65rem;
  }
  body.admin-shell .payroll-type-tabs {
    display: grid;
    flex: 1 1 auto;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .35rem;
    min-width: 0;
  }
  body.admin-shell .payroll-type-tab {
    width: 100%;
    min-height: 2.5rem;
    gap: .25rem;
    padding: .25rem .4rem;
    font-size: clamp(.66rem, 1.45vw, .78rem);
    white-space: nowrap;
  }
  body.admin-shell .payroll-type-tab-icon {
    flex: 0 0 1.65rem;
    width: 1.65rem;
    height: 1.65rem;
  }
  body.admin-shell .payroll-type-filters {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: .45rem !important;
    width: auto;
    margin-left: auto;
  }
  body.admin-shell .payroll-type-filters .amfe-input,
  body.admin-shell .payroll-type-filters input[type="month"] {
    width: auto;
    min-width: 110px;
    min-height: 2.5rem;
    padding-block: .45rem;
    font-size: .78rem;
  }
  body.admin-shell .payroll-cards {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: .75rem !important;
  }
  body.admin-shell .payroll-cards > [class*="col-"] {
    width: auto !important;
    max-width: none !important;
    padding: 0 !important;
  }
  body.admin-shell .si-summary-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 1fr;
    gap: 1rem;
  }
  body.admin-shell .si-summary-row > .col {
    width: auto;
    max-width: none;
    padding: 0;
  }
  body.admin-shell .si-summary-row .si-stat { min-height: 7.25rem; }
  body.admin-shell .si-records-row > [class*="col-"] { width: 100%; }
  body.admin-shell .ra-title-with-filters > div { max-width: 100%; }
  body.admin-shell .archive-type-filter {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    align-self: stretch;
    width: 100%;
    max-width: 100%;
    overflow: visible;
  }
  body.admin-shell .archive-type-chip {
    width: 100%;
    min-width: 0;
    min-height: clamp(2.8rem, 4.5vw, 3.25rem);
    padding-inline: .2rem;
    font-size: clamp(.62rem, 1.2vw, .78rem);
  }
  body.admin-shell .archive-type-chip i { font-size: clamp(.78rem, 1.5vw, .95rem); }

  /* Browsers using “Desktop site” on a phone report a tablet-like viewport.
     Keep all Activity Log controls on the same compact row at that width. */
  body.admin-shell .activity-filter-bar {
    display: grid !important;
    grid-template-columns:
      minmax(6.75rem, .72fr)
      minmax(8.5rem, 1fr)
      minmax(13rem, 1.55fr)
      max-content;
    align-items: end !important;
    gap: .45rem;
    width: 100%;
  }
  body.admin-shell .activity-filter-bar > * { min-width: 0; }
  body.admin-shell .activity-filter-bar .date-range-btn,
  body.admin-shell .activity-filter-bar .filter-select,
  body.admin-shell .activity-filter-bar .search-input {
    width: 100%;
    min-width: 0;
    height: 2.5rem;
    padding-right: 1.7rem;
    padding-left: .65rem;
    font-size: .75rem;
  }
  body.admin-shell .activity-filter-bar .activity-filter-actions {
    gap: .4rem;
    min-width: max-content;
  }
  body.admin-shell .activity-filter-bar .activity-filter-actions .btn-outline-amfe,
  body.admin-shell .activity-filter-bar .activity-filter-actions .btn-primary-amfe {
    height: 2.5rem;
    min-width: 0;
    padding-inline: .65rem;
    font-size: .72rem;
  }
  body.admin-shell .si-period-toolbar,
  body.admin-shell .si-period-toolbar-main {
    width: auto;
    align-items: flex-start;
  }
  body.admin-shell .si-filter-bar {
    align-self: flex-start;
    width: auto;
  }
}

@media (max-width: 767.98px) {
  body.admin-shell .admin-main { overflow-x: clip; }

  /* All Admin titles stay in normal document flow beneath the mobile bar.
     This overrides Farmer's global `.prod-header { justify-content:end }`
     and older shell assumptions that titles live inside the top bar. */
  body.admin-shell .admin-main .prod-header,
  body.admin-shell .admin-main .si-page-header {
    display: flex;
    width: 100%;
    min-height: 0;
    margin: 0 0 1rem !important;
    padding: 0 !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    text-align: left;
  }
  body.admin-shell .admin-main .page-title,
  body.admin-shell .admin-main .prod-header .page-title,
  body.admin-shell .admin-main .si-page-header .page-title,
  body.admin-shell .admin-main .ra-page-title {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0 0 1rem !important;
    padding: 0 !important;
    color: var(--text-dark) !important;
    font-size: clamp(1.65rem, 7vw, 1.9rem) !important;
    line-height: 1.15;
    text-align: left;
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
  }
  body.admin-shell .admin-main .prod-header .page-title,
  body.admin-shell .admin-main .si-page-header .page-title,
  body.admin-shell .admin-main .payroll-header .page-title { margin-bottom: 0 !important; }

  /* Shared mobile content rhythm and overflow protection. */
  body.admin-shell .admin-main .row {
    max-width: 100%;
    margin-right: 0;
    margin-left: 0;
  }
  body.admin-shell .admin-main .row > [class*="col-"] { padding-inline: 0; }
  body.admin-shell .admin-main .row.g-3,
  body.admin-shell .admin-main .row.g-4 { row-gap: .85rem; }
  body.admin-shell .admin-main .amfe-card { padding: clamp(.85rem, 4vw, 1rem); }
  body.admin-shell .admin-main .table-responsive { width: 100%; max-width: 100%; }
  body.admin-shell .admin-main input,
  body.admin-shell .admin-main select,
  body.admin-shell .admin-main textarea,
  body.admin-shell .admin-main button { max-width: 100%; }

  /* Members: search on top, filters below without truncated labels. */
  body.admin-shell .members-filter-row { gap: .75rem; }
  body.admin-shell .members-filter-row .search-wrap,
  body.admin-shell .members-filter-row .search-input { width: 100%; }
  body.admin-shell .members-filter-selects {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    gap: .5rem;
    width: 100%;
  }
  body.admin-shell .members-filter-selects .filter-select { width: 100%; min-width: 0; min-height: 2.75rem; }
  body.admin-shell .members-filter-selects .dropdown { grid-column: 3; grid-row: 1; width: auto; min-width: 0; }
  body.admin-shell .members-download-btn { width: 100%; justify-content: center; }
  body.admin-shell .members-filter-selects .btn-link-reset { grid-column: 1 / -1; grid-row: 2; justify-self: start; min-height: 2.75rem; }
  body.admin-shell #membersTable tbody td { min-width: 0; gap: .75rem; }
  body.admin-shell #membersTable tbody td > * { min-width: 0; max-width: 65%; overflow-wrap: anywhere; text-align: right; }
  body.admin-shell #membersTable tbody td[data-label="Name"] > * { max-width: 100%; text-align: left; }
  body.admin-shell #membersTable tbody td.members-actions > * { max-width: none; }

  /* Production: compact search/tabs and readable record cards. */
  body.admin-shell .prod-search-tabs-row { width: 100%; padding: .75rem; gap: .65rem; }
  body.admin-shell .prod-search-tabs-row .search-wrap,
  body.admin-shell .prod-search-tabs-row .search-input { width: 100%; }
  body.admin-shell .prod-search-tabs-row .amfe-tabs { gap: .4rem; }
  body.admin-shell .prod-search-tabs-row .amfe-tab { min-height: 2.75rem; padding: .65rem .5rem; white-space: normal; line-height: 1.2; }
  body.admin-shell #freshTable tbody tr:not(.month-group-row) td,
  body.admin-shell #driedTable tbody tr:not(.month-group-row) td,
  body.admin-shell #byMemberTable tbody tr:not(.month-group-row) td,
  body.admin-shell #memberFreshTable tbody tr:not(.month-group-row) td,
  body.admin-shell #memberDriedTable tbody tr:not(.month-group-row) td { min-width: 0; gap: .75rem; }

  /* Sales & Inventory: preserve a useful two-card summary at phone size,
     then stack all record panels and keep their tools within the card. */
  body.admin-shell .si-summary-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  body.admin-shell .si-summary-row > .col { width: auto; padding: 0; }
  body.admin-shell .si-stat { min-height: 10.5rem; padding: .85rem .55rem; }
  body.admin-shell .si-stat-icon { width: 2.75rem; height: 2.75rem; }
  body.admin-shell .si-stat-label { font-size: .78rem; overflow-wrap: anywhere; }
  body.admin-shell .si-stat-value { font-size: clamp(1.05rem, 5.5vw, 1.35rem); overflow-wrap: anywhere; }
  body.admin-shell .si-stat-foot { font-size: .72rem; }
  body.admin-shell .si-period-toolbar,
  body.admin-shell .si-period-toolbar-main,
  body.admin-shell .si-filter-bar { width: 100%; }
  body.admin-shell .si-filter-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }
  body.admin-shell .si-filter-divider { display: none; }
  body.admin-shell .si-filter-field {
    width: auto;
    min-width: 0;
    min-height: 2.75rem;
    padding: .65rem .8rem;
  }
  body.admin-shell .si-filter-field--view { min-width: 0; }
  body.admin-shell .si-filter-field:not(:first-child) {
    border-top: 0;
    border-left: 1px solid var(--border);
  }
  body.admin-shell .si-filter-input,
  body.admin-shell .si-filter-select { width: 100%; min-width: 0; }
  body.admin-shell .si-records-row { display: block; }
  body.admin-shell .si-records-row > [class*="col-"] { width: 100%; margin-bottom: 1rem; }
  body.admin-shell .si-panel-head { align-items: stretch; flex-direction: column; gap: .75rem; }
  body.admin-shell .si-panel-tools { display: grid; grid-template-columns: 1fr; width: 100%; }
  body.admin-shell .si-panel-tools .si-select,
  body.admin-shell .si-panel-tools .si-ghost-btn { width: 100%; }

  /* Resource Allocation: headings and their year/month controls stack
     cleanly; complex allocation rows never widen the page. */
  body.admin-shell .ra-card-title { font-size: clamp(1rem, 4.8vw, 1.15rem); line-height: 1.3; }
  body.admin-shell .ra-title-with-filters { align-items: stretch; flex-direction: column; }
  body.admin-shell .ra-title-with-filters > span,
  body.admin-shell .ra-title-with-filters > div { width: 100%; }
  body.admin-shell .ra-title-with-filters > div { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.admin-shell .ra-title-with-filters .filter-select { width: 100%; min-width: 0; }
  body.admin-shell .ra-two-col,
  body.admin-shell .ra-two-col-equal,
  body.admin-shell .ra-right-col { width: 100%; min-width: 0; }
  body.admin-shell .ra-resource-item,
  body.admin-shell .ra-row-summary,
  body.admin-shell .ra-packaging-inputs { max-width: 100%; }
  body.admin-shell .ra-available-stock-field { align-items: stretch; flex-direction: column; }
  body.admin-shell .ra-btn-view-breakdown { width: 100%; }

  /* Payroll: comprehensive mobile responsiveness down to 320px */
  body.admin-shell .admin-main .payroll-header {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    margin: 0 0 1.25rem !important;
    padding: 0 !important;
    gap: 0.75rem !important;
  }
  body.admin-shell .admin-main .payroll-header > div:first-child {
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }
  body.admin-shell .admin-main .payroll-header .page-title {
    display: inline-block !important;
    width: auto !important;
    max-width: 100% !important;
    margin: 0 !important;
  }
  body.admin-shell .admin-main .payroll-header > div:last-child {
    flex: 0 0 auto !important;
  }

  body.admin-shell .payroll-cards {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: .75rem !important;
  }
  @media (min-width: 576px) and (max-width: 767.98px) {
    body.admin-shell .payroll-cards {
      grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
  }
  body.admin-shell .payroll-cards > [class*="col-"] {
    width: auto !important;
    max-width: none !important;
    padding: 0 !important;
  }
  body.admin-shell .payroll-cards .amfe-card {
    width: 100% !important;
    padding: 14px 16px !important;
  }

  body.admin-shell .payroll-type-selector {
    width: 100% !important;
    padding: .75rem !important;
    display: flex !important;
    flex-direction: column !important;
    gap: .75rem !important;
    align-items: stretch !important;
  }
  body.admin-shell .payroll-type-selector [role="tablist"] {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: .35rem !important;
    width: 100% !important;
  }
  body.admin-shell .payroll-type-selector [role="tab"] {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 2.5rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    padding: .35rem .25rem !important;
    font-size: clamp(.68rem, 2.7vw, .8rem) !important;
    white-space: nowrap !important;
  }
  body.admin-shell .payroll-type-tab-icon {
    flex: 0 0 22px !important;
    width: 22px !important;
    height: 22px !important;
    font-size: .75rem !important;
  }
  body.admin-shell .payroll-type-tab > span:last-child {
    flex: 1 !important;
    min-width: 0 !important;
    padding-right: 0 !important;
    text-align: center !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  body.admin-shell .payroll-type-filters {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: .5rem !important;
    width: 100% !important;
    margin-left: 0 !important;
  }
  body.admin-shell .payroll-type-filters select.amfe-input {
    grid-column: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 40px !important;
  }
  body.admin-shell .payroll-type-filters .responsive-month-trigger {
    grid-column: 2 !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 40px !important;
    justify-content: space-between !important;
  }
  body.admin-shell .payroll-type-filters .btn-finalize-payroll {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    height: 40px !important;
    justify-content: center !important;
  }
  body.admin-shell .payroll-type-filters > div:has(.badge),
  body.admin-shell .payroll-type-filters > div:has(button) {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: .5rem !important;
  }
  body.admin-shell .payroll-type-filters > div:has(.badge) .badge,
  body.admin-shell .payroll-type-filters > div:has(.badge) button,
  body.admin-shell .payroll-type-filters > div:has(button) .badge,
  body.admin-shell .payroll-type-filters > div:has(button) button {
    width: 100% !important;
    justify-content: center !important;
    text-align: center !important;
    min-height: 40px !important;
  }

  /* Equation card on mobile: clean receipt/ledger layout */
  body.admin-shell [data-testid="payroll-equation"] {
    padding: 12px 14px !important;
  }
  body.admin-shell [data-testid="payroll-equation"] .d-flex {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
  }
  body.admin-shell [data-testid="payroll-equation"] .d-flex > div {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    text-align: left !important;
    padding: 8px 12px !important;
    background: #ffffff !important;
    border-radius: 8px !important;
    border: 1px solid var(--border) !important;
  }
  body.admin-shell [data-testid="payroll-equation"] .d-flex > div > div:first-child {
    font-size: 11px !important;
    margin-bottom: 0 !important;
  }
  body.admin-shell [data-testid="payroll-equation"] .d-flex > div > div:last-child {
    font-size: 15px !important;
  }
  body.admin-shell [data-testid="payroll-equation"] .d-flex > span {
    display: none !important;
  }

  /* Farmer Breakdown Header on mobile */
  body.admin-shell .payroll-breakdown-header {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    padding: 12px 14px !important;
  }
  body.admin-shell .payroll-breakdown-header > div:last-child {
    width: 100% !important;
    justify-content: space-between !important;
  }
  body.admin-shell .payroll-pending-badge {
    flex: 1 1 auto !important;
    text-align: center !important;
  }

  /* Modals on mobile */
  body.admin-shell .modal-box.modal-box-lg {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 18px 18px 0 0 !important;
    padding: clamp(14px, 4vw, 22px) !important;
  }
  body.admin-shell .rate-settings-modal-box {
    padding: clamp(14px, 4vw, 20px) !important;
    border-radius: 18px 18px 0 0 !important;
  }
  body.admin-shell .rate-modal-tabs {
    width: 100% !important;
    display: flex !important;
  }
  body.admin-shell .rate-modal-tabs button {
    flex: 1 1 0 !important;
    justify-content: center !important;
    padding: 6px 8px !important;
    font-size: 11.5px !important;
    white-space: nowrap !important;
  }
  body.admin-shell .rate-history-toolbar {
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 10px 12px !important;
    gap: 8px !important;
  }
  body.admin-shell .rate-history-filters {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    width: 100% !important;
  }
  body.admin-shell .rate-history-filters .rate-filter-field {
    min-width: 0 !important;
    width: 100% !important;
  }
  body.admin-shell .rate-history-filters .rate-search-wrap {
    grid-column: 1 / -1 !important;
    max-width: 100% !important;
    min-width: 0 !important;
    width: 100% !important;
  }
  body.admin-shell .rate-history-filters .rate-filter-reset-btn {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    justify-content: center !important;
  }
  body.admin-shell .rate-history-count-badge {
    width: 100% !important;
    text-align: center !important;
  }

  /* Floating create actions stay reachable without covering the final row. */
  body.admin-shell .mobile-add-fab,
  body.admin-shell .ra-floating-add { right: max(.75rem, env(safe-area-inset-right)); bottom: calc(.75rem + env(safe-area-inset-bottom)); }
}

@media (max-width: 374.98px) {
  body.admin-shell .admin-main { padding-inline: .75rem !important; }
  body.admin-shell .members-filter-selects { grid-template-columns: repeat(2, minmax(0, 1fr)) auto; gap: .3rem; }
  body.admin-shell .members-filter-selects .filter-select { padding-inline: .45rem 1.25rem; font-size: .7rem; background-position: right .4rem center; }
  body.admin-shell .members-download-btn { padding-inline: .5rem; font-size: .7rem; }
  body.admin-shell .prod-search-tabs-row .amfe-tabs { grid-template-columns: 1fr; }
  body.admin-shell .prod-search-tabs-row .amfe-tab:last-child { grid-column: auto; }
  body.admin-shell .si-summary-row { gap: .55rem; }
  body.admin-shell .si-stat { min-height: 9.5rem; }
  body.admin-shell .ra-title-with-filters > div { grid-template-columns: 1fr; }
  body.admin-shell .payroll-type-filters { grid-template-columns: 1fr !important; }
  body.admin-shell .payroll-type-filters select.amfe-input { grid-column: auto !important; }
  body.admin-shell .payroll-type-filters .responsive-month-trigger { grid-column: auto !important; }
  body.admin-shell .payroll-type-filters > div:has(.badge),
  body.admin-shell .payroll-type-filters > div:has(button) { grid-template-columns: 1fr !important; }
}

/* Keep the same mobile page rhythm behind every Admin sidebar link:
   mobile bar -> breathing room -> title -> breathing room -> content. */
@media (max-width: 767.98px) {
  body.admin-shell .admin-main {
    padding-top: calc(5rem + env(safe-area-inset-top)) !important;
  }

  body.admin-shell .admin-main.has-mobile-fab,
  body.admin-shell .admin-main:has(.mobile-add-fab),
  body.admin-shell .admin-main:has(.ra-floating-add),
  body.admin-shell .admin-main:has(.mobile-add-menu),
  .main-content.has-mobile-fab,
  .main-content:has(.mobile-add-fab),
  .main-content:has(.ra-floating-add),
  .main-content:has(.mobile-add-menu),
  #main-content.has-mobile-fab,
  #main-content:has(.mobile-add-fab),
  #main-content:has(.ra-floating-add),
  #main-content:has(.mobile-add-menu) {
    padding-bottom: calc(72px + env(safe-area-inset-bottom)) !important;
  }

  body.admin-shell .admin-main > .page-title,
  body.admin-shell .admin-main > .ra-page-title,
  body.admin-shell .admin-main > .admin-analytics-heading,
  body.admin-shell .admin-main .admin-analytics-heading {
    margin-bottom: 1.25rem !important;
    text-align: left !important;
    justify-content: flex-start !important;
  }

  body.admin-shell .admin-main > .prod-header,
  body.admin-shell .admin-main > .si-page-header,
  body.admin-shell .admin-main > .payroll-header,
  body.admin-shell .admin-main > .rep-topbar,
  body.admin-shell .admin-main > .announcement-page-header {
    margin-bottom: 1.25rem !important;
  }

  body.admin-shell .admin-main > .prod-header .page-title,
  body.admin-shell .admin-main > .si-page-header .page-title,
  body.admin-shell .admin-main > .payroll-header .page-title,
  body.admin-shell .admin-main > .rep-topbar .page-title,
  body.admin-shell .admin-main > .announcement-page-header .page-title,
  body.admin-shell .admin-main > .admin-analytics-heading .page-title,
  body.admin-shell .admin-main .admin-analytics-heading .page-title {
    margin-bottom: 0 !important;
    text-align: left !important;
  }
}
.admin-settings-avatar {
    width: 120px;
    height: 120px;
    flex: 0 0 120px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #dceee2;
    border: 3px solid var(--primary);
    color: var(--primary);
    font-size: 58px;
}

.admin-settings-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.admin-avatar-row {
    min-height: 144px;
    display: grid !important;
    grid-template-columns: 120px minmax(0, 1fr);
    align-items: center !important;
    gap: 16px !important;
}

.admin-avatar-controls {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.admin-avatar-controls .btn-outline-amfe,
.admin-avatar-controls .btn-primary-amfe,
.admin-avatar-controls .btn-danger-amfe {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
}

.admin-avatar-controls .btn-outline-amfe i,
.admin-avatar-controls .btn-primary-amfe i,
.admin-avatar-controls .btn-danger-amfe i {
    font-size: 14px;
}

.admin-avatar-controls .settings-hint {
    margin-top: 8px !important;
    font-size: 12px;
}

@media (max-width: 991.98px) {
    .admin-avatar-row {
        grid-template-columns: clamp(120px, 25vw, 170px) minmax(0, 1fr);
        column-gap: clamp(12px, 3vw, 24px) !important;
    }

    .admin-settings-avatar {
        width: clamp(120px, 25vw, 170px);
        height: clamp(120px, 25vw, 170px);
        flex-basis: clamp(120px, 25vw, 170px);
        font-size: clamp(58px, 12vw, 78px);
    }

    .admin-avatar-controls {
        flex: 1 1 auto;
        min-width: 0;
        align-self: center;
    }

    .admin-avatar-controls > .d-flex {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr);
    }

    .admin-avatar-controls .btn-outline-amfe,
    .admin-avatar-controls .btn-primary-amfe,
    .admin-avatar-controls .btn-danger-amfe {
        width: 100%;
        min-width: 0;
        min-height: 52px;
        padding-inline: clamp(10px, 3vw, 24px);
        font-size: clamp(13px, 2.4vw, 16px);
        font-weight: 600;
        white-space: nowrap;
    }

    .admin-avatar-controls .btn-outline-amfe i,
    .admin-avatar-controls .btn-primary-amfe i,
    .admin-avatar-controls .btn-danger-amfe i {
        font-size: clamp(15px, 2.8vw, 19px);
    }

    .admin-avatar-controls .settings-hint {
        margin-top: 14px !important;
        font-size: clamp(11px, 2.1vw, 14px);
        line-height: 1.3;
        white-space: nowrap;
    }
}

/* ===== RATE HISTORY: MOBILE RESPONSIVE CARD VIEW (≤ 768px) ===== */
@media (max-width: 767.98px) {
  .rate-history-container {
    border: none !important;
    max-height: none !important;
    overflow-y: visible !important;
  }
  .rate-history-table,
  .rate-history-table tbody {
    display: block !important;
    width: 100% !important;
  }
  .rate-history-table thead {
    display: none !important;
  }
  .rate-history-table tbody tr {
    display: block !important;
    background: #fff;
    border: 1px solid var(--border, #e5e7eb) !important;
    border-radius: 10px;
    padding: 12px 14px !important;
    margin-bottom: 12px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  }
  .rate-history-table tbody td {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 7px 0 !important;
    border-bottom: 1px solid #f3f4f6 !important;
    font-size: 13px !important;
    white-space: normal !important;
  }
  .rate-history-table tbody td:last-child {
    border-bottom: none !important;
  }
  .rate-history-table tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    flex-shrink: 0;
    margin-right: 12px;
  }
  .rate-history-table tbody td[data-label="Effective From"],
  .rate-history-table tbody td:first-child {
    border-bottom: 1.5px solid var(--border, #e5e7eb) !important;
    padding-bottom: 9px !important;
    margin-bottom: 4px;
  }
}
