:root {
  --fm-primary: #163C2C;
  --fm-primary-dark: #0E2A1F;
  --fm-primary-soft: #E7EEE6;
  --fm-primary-rgb: 22, 60, 44;
  --fm-accent: #2E7D52;
  --fm-accent-dark: #1F5C3B;
  --fm-accent-rgb: 46, 125, 82;
  --fm-bg: #FAF6EF;
  --fm-surface: #ffffff;
  --fm-text: #1E2420;
  --fm-muted: #6E7568;
  --fm-border: #E7E0D2;
  --fm-danger: #A8402F;
  --fm-radius: 18px;
  --fm-radius-sm: 10px;
  --font-serif: 'Fraunces', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  background: var(--fm-bg);
  color: var(--fm-text);
  font-family: var(--font-sans);
}

a { text-decoration: none; }

h1, h2, h3, .fm-serif { font-family: var(--font-serif); }

/* ---------- Top utility bar ---------- */
.fm-topbar {
  background: var(--fm-primary-dark);
  color: #fff;
  font-size: .8rem;
  letter-spacing: .01em;
}
.fm-topbar a { color: rgba(255,255,255,.72); }
.fm-topbar a:hover { color: #fff; }

/* ---------- Main header ---------- */
.fm-header {
  background: var(--fm-surface);
  border-bottom: 1px solid var(--fm-border);
  position: sticky;
  top: 0;
  z-index: 1030;
}
.fm-logo {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.6rem;
  color: var(--fm-primary);
  display: flex;
  align-items: center;
  gap: .45rem;
  letter-spacing: -.01em;
}
.fm-logo .bi { font-size: 1.25rem; }
.fm-logo span.accent { color: var(--fm-accent); }
.fm-logo-img {
  height: 44px;
  width: auto;
  display: block;
}
@media (max-width: 767.98px) {
  .fm-logo-img { height: 36px; }
}

.fm-search-form { max-width: 560px; }
.fm-search-form input {
  border-radius: 999px 0 0 999px;
  border: 1px solid var(--fm-border);
  font-family: var(--font-sans);
}
.fm-search-form input:focus { border-color: var(--fm-primary); box-shadow: none; }
.fm-search-form button {
  border-radius: 0 999px 999px 0;
  background: var(--fm-primary);
  border-color: var(--fm-primary);
}
.fm-search-form button:hover { background: var(--fm-primary-dark); border-color: var(--fm-primary-dark); }

.fm-header-icon {
  color: var(--fm-text);
  position: relative;
}
.fm-header-icon .badge-count {
  position: absolute;
  top: -6px;
  right: -10px;
  background: var(--fm-accent);
  color: #fff;
  border-radius: 999px;
  font-size: .65rem;
  padding: 1px 6px;
}

/* ---------- Mega menu nav ---------- */
.fm-nav {
  background: var(--fm-primary);
}
.fm-nav .nav-link {
  color: rgba(255,255,255,.92) !important;
  font-weight: 500;
  font-size: .9rem;
  padding: .7rem 1rem !important;
}
.fm-nav .nav-item:hover > .nav-link,
.fm-nav .nav-link.active {
  background: var(--fm-primary-dark);
  color: #fff !important;
}
.fm-nav-alltrigger {
  background: var(--fm-accent) !important;
  color: #fff !important;
  font-weight: 600 !important;
}
.fm-nav-alltrigger:hover { background: var(--fm-accent-dark) !important; }
.fm-mega {
  border: none;
  border-radius: 0 0 var(--fm-radius-sm) var(--fm-radius-sm);
  box-shadow: 0 16px 34px rgba(14,42,31,.16);
  padding: 1.4rem 1.5rem;
  width: 640px;
  max-width: 90vw;
}
.fm-mega a { color: var(--fm-text); display: block; padding: .2rem 0; font-size: .87rem; }
.fm-mega a:hover { color: var(--fm-primary); }
.fm-mega h6 { color: var(--fm-primary); font-weight: 600; font-family: var(--font-serif); font-size: 1rem; margin-bottom: .4rem; white-space: nowrap; }
.fm-mega .col-6,
.fm-mega .col-md-3 { margin-bottom: 1rem; }
.fm-mega-all { width: 760px; }
.fm-mega-all-link {
  display: flex !important; align-items: center; gap: .55rem;
  padding: .5rem .6rem !important; border-radius: 8px;
}
.fm-mega-all-link .bi { color: var(--fm-accent); font-size: 1rem; }
.fm-mega-all-link:hover { background: var(--fm-primary-soft); }

/* ---------- Category sidebar (all-categories browser) ---------- */
.fm-cat-sidebar {
  background: var(--fm-surface);
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius-sm);
  overflow: visible;
  position: sticky;
  top: 90px;
}
.fm-cat-sidebar-list { list-style: none; margin: 0; padding: .5rem 0; }
.fm-cat-sidebar-item { position: relative; }
.fm-cat-sidebar-item > a {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem 1rem; color: var(--fm-text); font-size: .87rem; font-weight: 500;
  border-left: 3px solid transparent;
}
.fm-cat-sidebar-icon {
  width: 26px; text-align: center; color: var(--fm-accent); font-size: 1rem; flex-shrink: 0;
}
.fm-cat-sidebar-name { flex: 1; }
.fm-cat-sidebar-caret { font-size: .7rem; color: var(--fm-muted); }
.fm-cat-sidebar-item:hover > a,
.fm-cat-sidebar-item > a:focus {
  background: var(--fm-primary-soft);
  border-left-color: var(--fm-accent);
  color: var(--fm-primary);
}
.fm-cat-sidebar-item:hover > a .fm-cat-sidebar-icon,
.fm-cat-sidebar-item:hover > a .fm-cat-sidebar-caret { color: var(--fm-primary); }

.fm-cat-flyout {
  display: none;
  position: absolute; left: 100%; top: 0;
  width: 460px; max-width: 70vw;
  background: var(--fm-surface);
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius-sm);
  box-shadow: 0 16px 34px rgba(14,42,31,.16);
  padding: 1.25rem 1.4rem;
  z-index: 1040;
}
.fm-cat-sidebar-item.has-flyout:hover .fm-cat-flyout { display: block; }
.fm-cat-flyout-link {
  display: block; color: var(--fm-text); font-size: .87rem; padding: .3rem 0;
}
.fm-cat-flyout-link:hover { color: var(--fm-primary); }
.fm-cat-flyout-all {
  display: inline-block; margin-top: .75rem; padding-top: .75rem;
  border-top: 1px solid var(--fm-border);
  font-size: .82rem; font-weight: 600; color: var(--fm-accent-dark);
}
@media (max-width: 991px) {
  .fm-cat-sidebar { position: static; margin-bottom: 2rem; }
  .fm-cat-flyout { position: static; width: 100%; max-width: 100%; box-shadow: none; border-top: none; display: block !important; margin-top: .25rem; padding: 0 1rem .75rem 2.4rem; }
  .fm-cat-sidebar-item.has-flyout .fm-cat-flyout { display: none; }
  .fm-cat-sidebar-item.has-flyout:hover .fm-cat-flyout,
  .fm-cat-sidebar-item.has-flyout:focus-within .fm-cat-flyout { display: block !important; }
}

/* ---------- Hero / banners ---------- */
.fm-hero {
  border-radius: var(--fm-radius);
  overflow: hidden;
  background: linear-gradient(135deg, var(--fm-primary), var(--fm-primary-dark));
  color: #fff;
  min-height: 220px;
}
.fm-hero h1 { font-weight: 600; letter-spacing: -.01em; }
.fm-hero-carousel { border-radius: var(--fm-radius); overflow: hidden; }
.fm-hero-carousel .carousel-item { overflow: hidden; }
.fm-hero-img {
  height: 340px;
  object-fit: cover;
  object-position: center;
  transform: scale(1.12);
  transform-origin: center;
}
@media (max-width: 768px) { .fm-hero-img { height: 220px; } }

/* ---------- Trust strip (under hero) ---------- */
.fm-trust-strip {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  padding: 1.1rem 0;
  margin-bottom: 2.75rem;
  border-bottom: 1px solid var(--fm-border);
}
.fm-trust-item {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: 0 1.25rem;
}
.fm-trust-item + .fm-trust-item { border-left: 1px solid var(--fm-border); }
.fm-trust-item .bi { font-size: 1.3rem; color: var(--fm-accent); }
.fm-trust-item .fm-trust-label { font-weight: 600; font-size: .92rem; color: var(--fm-text); display: block; }
.fm-trust-item .fm-trust-sub { font-size: .8rem; color: var(--fm-muted); }
@media (max-width: 768px) {
  .fm-trust-strip { flex-wrap: wrap; gap: 1rem; }
  .fm-trust-item { flex: 1 1 100%; border-left: none !important; padding: 0; }
}

/* ---------- Category tiles ---------- */
.fm-category-row { margin-bottom: 3rem; }
.fm-category-tile {
  text-align: center;
  display: block;
}
.fm-category-tile .icon-circle {
  width: 68px; height: 68px; border-radius: 50%;
  background: var(--fm-primary-soft);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto .65rem;
  font-size: 1.5rem; color: var(--fm-primary);
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.fm-category-tile:hover .icon-circle {
  background: var(--fm-primary);
  color: #fff;
  transform: translateY(-3px);
}
.fm-category-tile .fm-cat-label {
  font-size: .86rem; font-weight: 500; color: var(--fm-text);
}

/* ---------- Product card ---------- */
.fm-product-card {
  background: var(--fm-surface);
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius-sm);
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: box-shadow .18s ease, border-color .18s ease;
}
.fm-product-card:hover {
  box-shadow: 0 14px 30px rgba(var(--fm-primary-rgb), .12);
  border-color: transparent;
}
.fm-product-card .fm-badges {
  position: absolute; top: .6rem; left: .6rem; z-index: 2;
  display: flex; flex-direction: column; gap: .3rem;
}
.fm-badge {
  font-size: .66rem; font-weight: 600; padding: .22rem .55rem; border-radius: 999px;
  letter-spacing: .01em;
}
.fm-badge.hit { background: #fff; color: var(--fm-accent-dark); border: 1px solid var(--fm-accent); }
.fm-badge.new { background: #fff; color: var(--fm-primary); border: 1px solid var(--fm-primary); }
.fm-badge.sale { background: var(--fm-danger); color: #fff; }

.fm-wishlist-btn {
  position: absolute; top: .5rem; right: .5rem; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%;
  background: #fff; border: 1px solid var(--fm-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--fm-muted); font-size: .9rem;
}
.fm-wishlist-btn.active { color: var(--fm-danger); border-color: var(--fm-danger); }

.fm-product-card .fm-product-img {
  padding: 1.1rem; text-align: center; background: var(--fm-primary-soft);
  border-radius: var(--fm-radius-sm) var(--fm-radius-sm) 0 0;
}
.fm-product-card .fm-product-img img { max-height: 130px; object-fit: contain; }
.fm-product-card .fm-product-body { padding: .9rem 1rem 1rem; display: flex; flex-direction: column; flex: 1; }
.fm-product-card .fm-product-name {
  font-size: .88rem; font-weight: 500; color: var(--fm-text);
  min-height: 2.6em; margin-bottom: .5rem;
}
.fm-price { font-weight: 700; color: var(--fm-primary); font-size: 1.05rem; font-family: var(--font-sans); }
.fm-price-old { color: var(--fm-muted); text-decoration: line-through; font-size: .8rem; margin-left: .4rem; }

.fm-add-btn {
  background: var(--fm-accent);
  border: none; color: #fff; border-radius: 999px;
  font-size: .82rem; font-weight: 600; padding: .4rem .9rem;
}
.fm-add-btn:hover { background: var(--fm-accent-dark); color: #fff; }
.fm-add-btn:disabled { background: var(--fm-border); color: var(--fm-muted); }

.fm-qty-stepper {
  display: flex; align-items: center; border: 1px solid var(--fm-border); border-radius: 999px; overflow: hidden;
}
.fm-qty-stepper button {
  background: #fff; border: none; width: 30px; height: 30px; color: var(--fm-primary); font-weight: 700;
}
.fm-qty-stepper input {
  width: 42px; border: none; text-align: center; font-size: .85rem; -moz-appearance: textfield;
}

/* ---------- Section headers ---------- */
.fm-section-title {
  display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 1.4rem;
  padding-left: .9rem; border-left: 3px solid var(--fm-accent);
}
.fm-section-title h2 { font-size: 1.5rem; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.fm-section-title a { color: var(--fm-muted); font-weight: 500; font-size: .85rem; }
.fm-section-title a:hover { color: var(--fm-primary); }

/* ---------- Sidebar (category page) ---------- */
.fm-sidebar { background: var(--fm-surface); border: 1px solid var(--fm-border); border-radius: var(--fm-radius-sm); padding: 1.2rem; }
.fm-sidebar .list-group-item { border: none; padding: .45rem 0; background: transparent; }
.fm-sidebar .list-group-item.active { color: var(--fm-primary); font-weight: 700; background: transparent; }

/* ---------- Footer ---------- */
.fm-footer { background: var(--fm-primary-dark); color: #C9D6CC; }
.fm-footer h6 { color: #fff; font-weight: 600; font-family: var(--font-serif); font-size: 1.1rem; }
.fm-footer a { color: #C9D6CC; }
.fm-footer a:hover { color: #fff; }

/* ---------- Admin panel ---------- */
.admin-sidebar {
  background: var(--fm-primary-dark); min-height: 100vh; color: #C9D6CC;
}
.admin-sidebar a.nav-link { color: #C9D6CC; border-radius: 8px; margin-bottom: 2px; }
.admin-sidebar a.nav-link.active, .admin-sidebar a.nav-link:hover { background: var(--fm-primary); color: #fff; }
.admin-stat-card {
  background: var(--fm-surface); border-radius: var(--fm-radius-sm); padding: 1.2rem; border: 1px solid var(--fm-border);
}
.badge-status-pending { background:#f0ad4e; }
.badge-status-processing { background:#0dcaf0; color:#0b3; }
.badge-status-shipped { background:#6f42c1; }
.badge-status-delivered { background:var(--fm-primary); }
.badge-status-cancelled { background:var(--fm-danger); }

.form-label { font-weight: 600; font-size: .88rem; }
.btn-primary { background: var(--fm-primary); border-color: var(--fm-primary); }
.btn-primary:hover { background: var(--fm-primary-dark); border-color: var(--fm-primary-dark); }
.btn-outline-primary { color: var(--fm-primary); border-color: var(--fm-primary); }
.btn-outline-primary:hover { background: var(--fm-primary); border-color: var(--fm-primary); }
.text-primary { color: var(--fm-primary) !important; }

/* ---------- POS / Register ---------- */
.pos-scan-bar { position: relative; }
.pos-scan-icon {
  position: absolute; left: 1rem; top: 50%; transform: translateY(-50%);
  color: var(--fm-muted); font-size: 1.2rem; pointer-events: none;
}
.pos-scan-input { padding-left: 2.75rem; border: 2px solid var(--fm-primary); }
.pos-scan-input:focus { border-color: var(--fm-primary); box-shadow: 0 0 0 .2rem rgba(var(--fm-primary-rgb), .15); }

.pos-search-results {
  background: var(--fm-surface); border: 1px solid var(--fm-border); border-radius: var(--fm-radius-sm);
  max-height: 320px; overflow-y: auto; box-shadow: 0 10px 24px rgba(14,42,31,.1);
}
.pos-result-item {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  padding: .65rem 1rem; border: none; border-bottom: 1px solid var(--fm-border); background: none; text-align: left;
}
.pos-result-item:last-child { border-bottom: none; }
.pos-result-item:hover { background: var(--fm-primary-soft); }
.pos-result-empty { padding: 1rem; color: var(--fm-muted); font-size: .88rem; }

.pos-cart-card {
  background: var(--fm-surface); border: 1px solid var(--fm-border); border-radius: var(--fm-radius-sm);
  overflow: hidden;
}

.pos-qty-stepper {
  display: flex; align-items: center; border: 1px solid var(--fm-border); border-radius: 999px; overflow: hidden; width: fit-content;
}
.pos-qty-stepper button {
  background: #fff; border: none; width: 28px; height: 28px; color: var(--fm-primary); font-weight: 700;
}
.pos-qty-stepper input {
  width: 52px; border: none; text-align: center; font-size: .85rem;
}

.pos-summary-card {
  background: var(--fm-surface); border: 1px solid var(--fm-border); border-radius: var(--fm-radius-sm);
  padding: 1.25rem; position: sticky; top: 1rem;
}
.pos-total-row { border-bottom: 1px solid var(--fm-border); }
.pos-total-amount { font-family: var(--font-serif); font-size: 1.9rem; font-weight: 600; color: var(--fm-primary); }

.pos-shift-bar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .75rem;
  background: var(--fm-primary-soft); border: 1px solid var(--fm-border); border-radius: var(--fm-radius-sm);
  padding: .75rem 1rem; font-size: .88rem;
}

.pos-quickpick { background: var(--fm-surface); border: 1px solid var(--fm-border); border-radius: var(--fm-radius-sm); padding: 1rem; }
.pos-quickpick-label { font-weight: 600; font-size: .82rem; color: var(--fm-muted); margin-bottom: .6rem; }
.pos-quickpick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .5rem; }
.pos-quickpick-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: .2rem;
  background: var(--fm-bg); border: 1px solid var(--fm-border); border-radius: 10px; padding: .6rem .7rem; text-align: left;
}
.pos-quickpick-tile:hover { border-color: var(--fm-primary); background: var(--fm-primary-soft); }
.pos-quickpick-name { font-size: .82rem; font-weight: 600; color: var(--fm-text); }
.pos-quickpick-price { font-size: .78rem; color: var(--fm-accent); font-weight: 600; }

.pos-held-panel {
  background: var(--fm-surface); border: 1px solid var(--fm-border); border-radius: var(--fm-radius-sm);
  max-height: 280px; overflow-y: auto;
}
.pos-held-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .7rem 1rem; border-bottom: 1px solid var(--fm-border);
}
.pos-held-row:last-child { border-bottom: none; }