/* ============================================================
   FFC PLATFORM — app.css
   Design System · Layout · Components · Utilities
   ============================================================ */

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

/* ── 1. CSS Variables ──────────────────────────────────────── */
:root {
  --ffc-primary:        #dd2b24;
  --ffc-primary-dark:   #b81e18;
  --ffc-primary-deeper: #612211;
  --ffc-primary-light:  #fdf0ef;
  --ffc-primary-muted:  #e8726d;
  --ffc-accent:         #f4a340;
  --ffc-accent-light:   #fef3e2;
  --ffc-success:        #1a9e4a;
  --ffc-success-light:  #e8f7ee;
  --ffc-info:           #0284c7;
  --ffc-info-light:     #e0f2fe;
  --ffc-neutral-dark:   #1a1a2e;
  --ffc-neutral-mid:    #64748b;
  --ffc-neutral-light:  #f1f5f9;
  --ffc-white:          #ffffff;
  --ffc-border:         #e2e8f0;
  --ffc-sidebar-w:      250px;
  --ffc-topbar-h:       64px;
  --ffc-radius:         10px;
  --ffc-radius-sm:      6px;
  --ffc-shadow:         0 1px 8px rgba(0,0,0,0.07);
  --ffc-shadow-md:      0 4px 20px rgba(0,0,0,0.10);
  --ffc-transition:     all 0.2s ease;
}

/* ── 2. Base Reset & Typography ────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', 'Plus Jakarta Sans', sans-serif;
  background-color: var(--ffc-neutral-light);
  color: var(--ffc-neutral-dark);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3,h4,h5,h6 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ffc-neutral-dark);
}

a { color: var(--ffc-primary); text-decoration: none; transition: var(--ffc-transition); }
a:hover { color: var(--ffc-primary-dark); }

/* ── 3. Layout ─────────────────────────────────────────────── */
.ffc-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Topbar */
.ffc-topbar {
  position: fixed;
  top: 0;
  left: var(--ffc-sidebar-w);
  right: 0;
  height: var(--ffc-topbar-h);
  background: var(--ffc-white);
  border-bottom: 1px solid var(--ffc-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 1020;
  gap: 16px;
  transition: left 0.3s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.ffc-topbar .topbar-left { display: flex; align-items: center; gap: 12px; flex: 1; }
.ffc-topbar .topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-brand {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--ffc-primary);
  letter-spacing: -0.5px;
}
.topbar-brand span { color: var(--ffc-primary-deeper); }

.sidebar-toggle-btn {
  background: none;
  border: none;
  color: var(--ffc-neutral-mid);
  font-size: 1.1rem;
  padding: 6px 8px;
  border-radius: var(--ffc-radius-sm);
  cursor: pointer;
  transition: var(--ffc-transition);
}
.sidebar-toggle-btn:hover {
  background: var(--ffc-neutral-light);
  color: var(--ffc-primary);
}

.branch-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--ffc-primary-light);
  color: var(--ffc-primary-deeper);
  border: 1px solid rgba(221,43,36,0.2);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.branch-pill i { font-size: 0.65rem; color: var(--ffc-primary); }

.topbar-search {
  position: relative;
  max-width: 280px;
}
.topbar-search input {
  background: var(--ffc-neutral-light);
  border: 1px solid var(--ffc-border);
  border-radius: 8px;
  padding: 7px 14px 7px 36px;
  font-size: 0.82rem;
  width: 100%;
  transition: var(--ffc-transition);
  color: var(--ffc-neutral-dark);
}
.topbar-search input:focus {
  outline: none;
  border-color: var(--ffc-primary-muted);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(221,43,36,0.08);
}
.topbar-search i {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ffc-neutral-mid);
  font-size: 0.8rem;
}

/* User Avatar Dropdown */
.user-avatar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: var(--ffc-transition);
}
.user-avatar-btn:hover { background: var(--ffc-neutral-light); }

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ffc-primary), var(--ffc-primary-deeper));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  font-family: 'Plus Jakarta Sans', sans-serif;
  flex-shrink: 0;
}

.user-info-text .user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ffc-neutral-dark);
  line-height: 1.2;
  display: block;
}
.user-info-text .user-role {
  font-size: 0.7rem;
  color: var(--ffc-neutral-mid);
  display: block;
}

/* Sidebar */
.ffc-sidebar {
  width: var(--ffc-sidebar-w);
  min-height: 100vh;
  max-height: 100vh;
  background: var(--ffc-primary-deeper);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1030;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.ffc-sidebar::-webkit-scrollbar { width: 4px; }
.ffc-sidebar::-webkit-scrollbar-track { background: transparent; }
.ffc-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.sidebar-brand {
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sidebar-brand-logo {
  width: 38px;
  height: 38px;
  background: var(--ffc-primary);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  font-family: 'Plus Jakarta Sans', sans-serif;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(221,43,36,0.4);
}

.sidebar-brand-text .brand-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  color: #fff;
  letter-spacing: -0.3px;
  line-height: 1.2;
  display: block;
}
.sidebar-brand-text .brand-sub {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.45);
  display: block;
  font-weight: 400;
}

.sidebar-nav { 
  padding: 10px 0; 
  flex: 1; 
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar { 
  width: 4px; 
}
.sidebar-nav::-webkit-scrollbar-track { 
  background: transparent; 
}
.sidebar-nav::-webkit-scrollbar-thumb { 
  background: rgba(255,255,255,0.1); 
  border-radius: 2px; 
}

.sidebar-section-label {
  color: rgba(255,255,255,0.3);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 14px 20px 5px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,0.65);
  font-size: 0.825rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: var(--ffc-transition);
  text-decoration: none;
  position: relative;
}
.sidebar-link i {
  font-size: 0.9rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.07);
  border-left-color: rgba(221,43,36,0.5);
}
.sidebar-link.active {
  color: #fff;
  background: rgba(221,43,36,0.18);
  border-left-color: var(--ffc-primary);
  font-weight: 600;
}
.sidebar-link.active i { color: var(--ffc-primary-muted); }

/* Sidebar collapse sub-nav */
.sidebar-collapse-btn {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  justify-content: space-between;
}
.sidebar-collapse-btn .chevron {
  font-size: 0.65rem;
  transition: transform 0.25s ease;
  color: rgba(255,255,255,0.35);
  margin-left: auto;
}
.sidebar-collapse-btn[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.sidebar-subnav {
  background: rgba(0,0,0,0.15);
  border-left: none;
}
.sidebar-subnav .sidebar-link {
  padding-left: 48px;
  font-size: 0.795rem;
  color: rgba(255,255,255,0.5);
}
.sidebar-subnav .sidebar-link:hover { color: rgba(255,255,255,0.85); }
.sidebar-subnav .sidebar-link.active { color: #fff; background: rgba(221,43,36,0.12); }

.sidebar-divider {
  border: none;
  border-top: 1px solid rgba(255,255,255,0.07);
  margin: 8px 20px;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.sidebar-footer .sidebar-link {
  border-radius: 6px;
  border-left: 3px solid transparent;
  padding: 8px 12px;
}

/* Content Area */
.ffc-content {
  margin-left: var(--ffc-sidebar-w);
  padding-top: var(--ffc-topbar-h);
  min-height: 100vh;
  flex: 1;
  transition: margin-left 0.3s ease;
  overflow-x: hidden;
}

.content-inner {
  padding: 28px 28px 48px;
  max-width: 100%;
  overflow-x: hidden;
}

/* Sidebar collapsed state */
body.sidebar-collapsed .ffc-sidebar { transform: translateX(calc(-1 * var(--ffc-sidebar-w))); }
body.sidebar-collapsed .ffc-topbar { left: 0; }
body.sidebar-collapsed .ffc-content { margin-left: 0; }

/* ── 4. Page Header ────────────────────────────────────────── */
.page-header {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: nowrap !important;
  width: 100%;
}
.page-header-left {
  flex: 1 1 auto !important;
  min-width: 0;
  overflow: hidden;
}
.page-header-left .page-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0 0 3px;
  color: var(--ffc-neutral-dark);
  font-family: 'Plus Jakarta Sans', sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-header-left .breadcrumb {
  margin: 0;
  padding: 0;
  background: none;
  font-size: 0.77rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-header-left .breadcrumb-item a { color: var(--ffc-neutral-mid); }
.page-header-left .breadcrumb-item.active { color: var(--ffc-primary); font-weight: 500; }
.page-header-left .breadcrumb-item + .breadcrumb-item::before { color: var(--ffc-neutral-mid); }
.page-header-right { 
  display: flex !important; 
  gap: 8px; 
  align-items: center; 
  flex-wrap: nowrap !important;
  flex: 0 0 auto !important;
  max-width: fit-content;
  min-width: fit-content;
}

/* Responsive Page Header */
@media (max-width: 992px) {
  .page-header {
    gap: 12px;
  }
  .page-header-right {
    gap: 6px;
  }
}

@media (max-width: 768px) {
  .page-header {
    gap: 10px;
  }
  .page-header-left .page-title {
    font-size: 1.1rem;
  }
  .page-header-left .breadcrumb {
    font-size: 0.7rem;
  }
  .page-header-right {
    gap: 4px;
  }
  .page-header-right .btn {
    padding: 5px 8px;
    font-size: 0.7rem;
  }
  .page-header-right .branch-filter-bar {
    padding: 6px 10px;
    font-size: 0.7rem;
  }
}

@media (max-width: 576px) {
  .page-header {
    gap: 8px;
  }
  .page-header-left .page-title {
    font-size: 1rem;
  }
  .page-header-left .breadcrumb {
    font-size: 0.65rem;
  }
  .page-header-right {
    gap: 4px;
  }
  .page-header-right .btn {
    padding: 4px 6px;
    font-size: 0.65rem;
  }
  .page-header-right .branch-filter-bar {
    padding: 4px 8px;
    font-size: 0.65rem;
  }
}

/* ── 5. Cards ──────────────────────────────────────────────── */
.ffc-card {
  background: var(--ffc-white);
  border-radius: var(--ffc-radius);
  box-shadow: var(--ffc-shadow);
  border: 1px solid var(--ffc-border);
  overflow: hidden;
}

.ffc-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--ffc-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ffc-card-header .card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ffc-neutral-dark);
  margin: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ffc-card-header .card-title i { color: var(--ffc-primary); font-size: 0.85rem; }

.ffc-card-body { padding: 20px; }

/* Stat Cards */
.stat-card {
  background: var(--ffc-white);
  border-radius: var(--ffc-radius);
  padding: 20px;
  box-shadow: var(--ffc-shadow);
  border: 1px solid var(--ffc-border);
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
  transition: var(--ffc-transition);
}
.stat-card:hover {
  box-shadow: var(--ffc-shadow-md);
  transform: translateY(-1px);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  background: var(--ffc-primary);
}
.stat-card.accent::before  { background: var(--ffc-accent); }
.stat-card.success::before { background: var(--ffc-success); }
.stat-card.info::before    { background: var(--ffc-info); }

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  background: var(--ffc-primary-light);
  color: var(--ffc-primary);
}
.stat-card.accent .stat-icon  { background: var(--ffc-accent-light); color: var(--ffc-accent); }
.stat-card.success .stat-icon { background: var(--ffc-success-light); color: var(--ffc-success); }
.stat-card.info .stat-icon    { background: var(--ffc-info-light); color: var(--ffc-info); }

.stat-body .stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ffc-neutral-mid);
  display: block;
  margin-bottom: 3px;
}
.stat-body .stat-value {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--ffc-neutral-dark);
  line-height: 1.1;
  font-family: 'Plus Jakarta Sans', sans-serif;
  display: block;
}
.stat-body .stat-meta {
  font-size: 0.75rem;
  color: var(--ffc-neutral-mid);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-meta .up   { color: var(--ffc-success); }
.stat-meta .down { color: var(--ffc-primary); }

/* Responsive Stat Cards */
@media (max-width: 1024px) {
  .stat-card {
    padding: 16px 14px;
    gap: 12px;
  }
  .stat-icon {
    width: 44px;
    height: 44px;
    font-size: 1rem;
  }
  .stat-body .stat-value {
    font-size: 1.35rem;
  }
}

@media (max-width: 768px) {
  .stat-card {
    padding: 14px 12px;
    gap: 10px;
  }
  .stat-icon {
    width: 38px;
    height: 38px;
    font-size: 0.9rem;
  }
  .stat-body .stat-label {
    font-size: 0.68rem;
  }
  .stat-body .stat-value {
    font-size: 1.2rem;
  }
  .stat-body .stat-meta {
    font-size: 0.7rem;
  }
}

@media (max-width: 576px) {
  .stat-card {
    padding: 12px 10px;
    gap: 8px;
  }
  .stat-icon {
    width: 34px;
    height: 34px;
    font-size: 0.85rem;
  }
  .stat-body .stat-label {
    font-size: 0.65rem;
  }
  .stat-body .stat-value {
    font-size: 1rem;
  }
  .stat-body .stat-meta {
    font-size: 0.68rem;
  }
}

/* ── 6. Buttons ────────────────────────────────────────────── */
.btn {
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  border-radius: var(--ffc-radius-sm);
  transition: var(--ffc-transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.825rem;
  padding: 8px 16px;
  border: 1.5px solid transparent;
}

.btn-ffc-primary {
  background: var(--ffc-primary);
  border-color: var(--ffc-primary);
  color: #fff;
}
.btn-ffc-primary:hover {
  background: var(--ffc-primary-dark);
  border-color: var(--ffc-primary-dark);
  color: #fff;
  box-shadow: 0 4px 12px rgba(221,43,36,0.3);
}

.btn-ffc-outline {
  background: transparent;
  border-color: var(--ffc-primary);
  color: var(--ffc-primary);
}
.btn-ffc-outline:hover {
  background: var(--ffc-primary-light);
  color: var(--ffc-primary-dark);
}

.btn-ffc-ghost {
  background: var(--ffc-neutral-light);
  border-color: var(--ffc-border);
  color: var(--ffc-neutral-dark);
}
.btn-ffc-ghost:hover {
  background: var(--ffc-border);
  color: var(--ffc-neutral-dark);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.765rem;
  gap: 4px;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--ffc-radius-sm);
  font-size: 0.82rem;
  border: 1.5px solid transparent;
}
.btn-icon.btn-ffc-ghost { border-color: var(--ffc-border); }
.btn-icon.btn-edit  { background: var(--ffc-info-light); color: var(--ffc-info); border-color: rgba(2,132,199,0.2); }
.btn-icon.btn-edit:hover { background: var(--ffc-info); color: #fff; }
.btn-icon.btn-delete { background: var(--ffc-primary-light); color: var(--ffc-primary); border-color: rgba(221,43,36,0.2); }
.btn-icon.btn-delete:hover { background: var(--ffc-primary); color: #fff; }
.btn-icon.btn-view  { background: var(--ffc-success-light); color: var(--ffc-success); border-color: rgba(26,158,74,0.2); }
.btn-icon.btn-view:hover { background: var(--ffc-success); color: #fff; }

/* ── 7. Forms ──────────────────────────────────────────────── */
.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ffc-neutral-dark);
  margin-bottom: 5px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.form-control, .form-select {
  font-size: 0.845rem;
  border: 1.5px solid var(--ffc-border);
  border-radius: var(--ffc-radius-sm);
  color: var(--ffc-neutral-dark);
  padding: 9px 13px;
  transition: var(--ffc-transition);
  background: var(--ffc-white);
}
.form-control:focus, .form-select:focus {
  border-color: var(--ffc-primary-muted);
  box-shadow: 0 0 0 3px rgba(221,43,36,0.1);
  outline: none;
}
.form-control::placeholder { color: var(--ffc-neutral-mid); font-size: 0.82rem; }

.form-control.is-invalid { border-color: var(--ffc-primary); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(221,43,36,0.1); }

.input-group .input-group-text {
  background: var(--ffc-neutral-light);
  border: 1.5px solid var(--ffc-border);
  color: var(--ffc-neutral-mid);
  font-size: 0.82rem;
  padding: 9px 12px;
}
.input-group .form-control { border-left: none; }
.input-group .input-group-text:first-child { border-right: none; }

.form-check-input:checked {
  background-color: var(--ffc-primary);
  border-color: var(--ffc-primary);
}
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(221,43,36,0.1); }

.form-text { font-size: 0.75rem; color: var(--ffc-neutral-mid); }

/* Toggle Switch */
.form-switch .form-check-input { width: 2.5em; height: 1.3em; cursor: pointer; }

/* ── 8. Tables ─────────────────────────────────────────────── */
.ffc-table-wrap {
  border-radius: var(--ffc-radius);
  overflow: hidden;
  background: var(--ffc-white);
  box-shadow: var(--ffc-shadow);
  border: 1px solid var(--ffc-border);
}

.ffc-table {
  margin: 0;
  font-size: 0.83rem;
  width: 100%;
  table-layout: auto;
}
.ffc-table thead th {
  background: var(--ffc-primary-deeper);
  color: rgba(255,255,255,0.95);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 16px;
  border: none;
  white-space: nowrap;
  font-family: 'Plus Jakarta Sans', sans-serif;
  position: relative;
  vertical-align: middle;
}
.ffc-table thead th:first-child { border-radius: 0 0 0 0; }
.ffc-table thead th:last-child { border-radius: 0 0 0 0; }
.ffc-table thead th.sortable { 
  cursor: pointer; 
  user-select: none; 
  transition: background 0.15s ease;
}
.ffc-table thead th.sortable:hover { 
  background: var(--ffc-primary-dark); 
}
.ffc-table thead th.sortable:active {
  background: var(--ffc-primary);
}

/* Sort icons container */
.ffc-table thead th .sort-icon { 
  margin-left: 8px; 
  opacity: 0.4; 
  font-size: 0.7rem; 
  transition: all 0.2s ease;
  display: inline-block;
}

/* Sorting states */
.ffc-table thead th.sortable:hover .sort-icon {
  opacity: 0.7;
}

.ffc-table thead th.sort-asc .sort-icon,
.ffc-table thead th.sort-desc .sort-icon { 
  opacity: 1; 
  color: var(--ffc-accent);
  transform: scale(1.1);
}

.ffc-table thead th.sort-asc .sort-icon {
  transform: rotate(0deg);
}

.ffc-table thead th.sort-desc .sort-icon {
  transform: rotate(180deg);
}

/* Active sort column highlight */
.ffc-table thead th.sort-asc,
.ffc-table thead th.sort-desc {
  background: var(--ffc-primary-dark);
  box-shadow: inset 0 2px 0 0 var(--ffc-accent);
}

.ffc-table tbody tr {
  border-bottom: 1px solid var(--ffc-border);
  transition: background 0.15s ease, transform 0.1s ease;
}
.ffc-table tbody tr:nth-child(even) {
  background: rgba(241,245,249,0.4);
}
.ffc-table tbody tr:last-child { 
  border-bottom: none; 
}
.ffc-table tbody tr:hover { 
  background: var(--ffc-primary-light); 
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  z-index: 1;
  position: relative;
}
.ffc-table tbody tr:active {
  transform: translateY(0);
  transition: transform 0.05s ease;
}
.ffc-table tbody td {
  padding: 14px 16px;
  color: var(--ffc-neutral-dark);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.83rem;
  line-height: 1.4;
}

/* Column width constraints for better alignment */
.ffc-table th:first-child,
.ffc-table td:first-child {
  width: 50px;
  text-align: center;
}

.ffc-table th.text-center,
.ffc-table td.text-center {
  text-align: center;
}

.ffc-table th.actions-col,
.ffc-table td.actions-col {
  width: 120px;
  min-width: 120px;
}

/* Status and badge alignment */
.ffc-table td .badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Number columns alignment */
.ffc-table td.numeric,
.ffc-table th.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Sticky table header for large datasets */
.ffc-table-wrap .table-responsive {
  max-height: calc(100vh - 300px);
  overflow-y: auto;
}

.ffc-table-wrap .ffc-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

/* Ensure sticky header stays above row hover effects */
.ffc-table tbody tr:hover {
  z-index: 1;
}

/* Compact table variant for dense data */
.ffc-table.table-compact tbody td {
  padding: 10px 12px;
  font-size: 0.78rem;
}
.ffc-table.table-compact thead th {
  padding: 10px 12px;
  font-size: 0.68rem;
}

/* Bordered table variant */
.ffc-table.table-bordered {
  border-collapse: separate;
  border-spacing: 0;
}
.ffc-table.table-bordered th,
.ffc-table.table-bordered td {
  border: 1px solid var(--ffc-border);
}
.ffc-table.table-bordered th {
  border-bottom-width: 2px;
}
.ffc-table tbody tr.row-low-stock { 
  background: #fffbf0; 
}
.ffc-table tbody tr.row-low-stock:hover { 
  background: #fff5df; 
}
.ffc-table tbody tr.row-inactive { 
  opacity: 0.6; 
  background: var(--ffc-neutral-light);
}
.ffc-table tbody tr.row-inactive:hover {
  background: #e2e8f0;
}

/* Table responsive wrapper - Bootstrap style */
.table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Table responsive breakpoints */
@media (max-width: 575.98px) {
  .table-responsive {
    border-radius: var(--ffc-radius);
    border: 1px solid var(--ffc-border);
  }
}

/* Table header section */
.table-header {
  padding: 16px 18px 0;
  border-bottom: none;
}

.table-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ffc-neutral-dark);
  margin: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

/* Table toolbar - Search left, filters right layout */
.table-toolbar {
  padding: 14px 18px;
  border-bottom: 1px solid var(--ffc-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: linear-gradient(to bottom, #fff, var(--ffc-neutral-light));
}

/* Left section: Fixed width search */
.table-toolbar .toolbar-left {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}

.table-toolbar .toolbar-left .search-wrap {
  position: relative;
  width: 280px;
  max-width: 100%;
}

.table-toolbar .toolbar-left .search-wrap i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ffc-neutral-mid);
  font-size: 0.8rem;
}

.table-toolbar .toolbar-left .search-wrap input {
  padding-left: 34px;
  font-size: 0.82rem;
  height: 38px;
  border-radius: var(--ffc-radius-sm);
  border: 1.5px solid var(--ffc-border);
  transition: all 0.2s ease;
  width: 100%;
}

.table-toolbar .toolbar-left .search-wrap input:focus {
  border-color: var(--ffc-primary-muted);
  box-shadow: 0 0 0 3px rgba(221,43,36,0.08);
}

/* Right section: Filters */
.table-toolbar .toolbar-right {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.table-toolbar .filter-select {
  height: 38px;
  font-size: 0.82rem;
  min-width: 140px;
  max-width: 180px;
  border-radius: var(--ffc-radius-sm);
  border: 1.5px solid var(--ffc-border);
  background: var(--ffc-white);
  cursor: pointer;
  transition: all 0.2s ease;
  flex: 0 0 auto;
}

.table-toolbar .filter-select:hover {
  border-color: var(--ffc-primary-muted);
}

.table-toolbar .filter-select:focus {
  border-color: var(--ffc-primary-muted);
  box-shadow: 0 0 0 3px rgba(221,43,36,0.08);
}

.table-toolbar .results-count {
  font-size: 0.8rem;
  color: var(--ffc-neutral-mid);
  font-weight: 500;
  white-space: nowrap;
  padding-left: 8px;
}

/* Legacy support - remove conflicting rules */
.table-toolbar .search-wrap:not(.toolbar-left .search-wrap) { display: none; }
.table-toolbar .table-actions-right { display: none; }

/* Table footer / pagination */
.table-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--ffc-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to top, #fff, var(--ffc-neutral-light));
  flex-wrap: wrap;
  gap: 12px;
}
.table-footer .table-count { 
  font-size: 0.8rem; 
  color: var(--ffc-neutral-mid); 
  font-weight: 500;
}
.pagination { margin: 0; }
.page-link {
  font-size: 0.8rem;
  color: var(--ffc-neutral-dark);
  border-color: var(--ffc-border);
  padding: 6px 12px;
  border-radius: var(--ffc-radius-sm);
  transition: all 0.2s ease;
}
.page-link:hover { 
  color: var(--ffc-primary); 
  background: var(--ffc-primary-light); 
  border-color: var(--ffc-border); 
}
.page-item.active .page-link {
  background: var(--ffc-primary);
  border-color: var(--ffc-primary);
  color: #fff;
  font-weight: 600;
}
.page-item.disabled .page-link {
  color: var(--ffc-neutral-mid);
  background: var(--ffc-neutral-light);
}
.page-item:first-child .page-link,
.page-item:last-child .page-link {
  padding: 6px 10px;
}

/* ── 9. Badges & Pills ─────────────────────────────────────── */
.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.badge-active  { background: var(--ffc-success-light); color: var(--ffc-success); }
.badge-inactive { background: var(--ffc-neutral-light); color: var(--ffc-neutral-mid); border: 1px solid var(--ffc-border); }
.badge-danger   { background: var(--ffc-primary-light); color: var(--ffc-primary); }
.badge-low-stock { background: var(--ffc-accent-light); color: #c27a10; }
.badge-manual  { background: var(--ffc-info-light); color: var(--ffc-info); }
.badge-auto    { background: var(--ffc-success-light); color: var(--ffc-success); }
.badge-cash    { background: var(--ffc-success-light); color: var(--ffc-success); }
.badge-bank    { background: var(--ffc-info-light); color: var(--ffc-info); }
.badge-card    { background: #f3e8ff; color: #7c3aed; }

/* Role badges */
.role-super_admin { background: var(--ffc-primary-light); color: var(--ffc-primary); }
.role-developer   { background: #e0f2fe; color: #0369a1; }
.role-branch_manager { background: #ede9fe; color: #5b21b6; }
.role-finance     { background: var(--ffc-success-light); color: var(--ffc-success); }
.role-sales       { background: var(--ffc-accent-light); color: #c27a10; }

/* ── 10. Modals ────────────────────────────────────────────── */
.modal-content {
  border: none;
  border-radius: var(--ffc-radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}
.modal-header {
  background: var(--ffc-white);
  border-bottom: 1px solid var(--ffc-border);
  padding: 18px 24px;
  border-radius: var(--ffc-radius) var(--ffc-radius) 0 0;
}
.modal-header .modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ffc-neutral-dark);
  font-family: 'Plus Jakarta Sans', sans-serif;
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-header .modal-title i { color: var(--ffc-primary); }
.modal-header .btn-close { opacity: 0.5; }
.modal-header .btn-close:hover { opacity: 1; }

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--ffc-border);
  background: var(--ffc-neutral-light);
  border-radius: 0 0 var(--ffc-radius) var(--ffc-radius);
  gap: 8px;
}

/* ── 11. Toasts ────────────────────────────────────────────── */
.toast-container-ffc {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 9999;
  min-width: 320px;
}
.ffc-toast {
  background: var(--ffc-white);
  border-radius: var(--ffc-radius-sm);
  box-shadow: var(--ffc-shadow-md);
  border: 1px solid var(--ffc-border);
  overflow: hidden;
}
.ffc-toast .toast-progress {
  height: 3px;
  background: var(--ffc-primary);
  animation: toastProgress 4s linear forwards;
}
.ffc-toast.toast-success .toast-progress { background: var(--ffc-success); }
.ffc-toast.toast-warning .toast-progress { background: var(--ffc-accent); }
.ffc-toast.toast-error   .toast-progress { background: var(--ffc-primary); }

@keyframes toastProgress {
  from { width: 100%; }
  to   { width: 0%; }
}

.ffc-toast .toast-header {
  border-bottom: none;
  padding: 10px 14px 6px;
}
.ffc-toast .toast-body {
  padding: 4px 14px 12px;
  font-size: 0.82rem;
  color: var(--ffc-neutral-dark);
}

/* ── 12. Alerts ────────────────────────────────────────────── */
.ffc-alert {
  border-radius: var(--ffc-radius-sm);
  padding: 12px 16px;
  font-size: 0.82rem;
  border: 1.5px solid;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.ffc-alert i { margin-top: 1px; flex-shrink: 0; }
.ffc-alert-info    { background: var(--ffc-info-light); border-color: rgba(2,132,199,0.25); color: #075985; }
.ffc-alert-success { background: var(--ffc-success-light); border-color: rgba(26,158,74,0.25); color: #145e2d; }
.ffc-alert-warning { background: var(--ffc-accent-light); border-color: rgba(244,163,64,0.35); color: #92540a; }
.ffc-alert-danger  { background: var(--ffc-primary-light); border-color: rgba(221,43,36,0.25); color: var(--ffc-primary-darker, #8b1a16); }

/* ── 13. Charts ────────────────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
}
.chart-period-tabs {
  display: flex;
  gap: 4px;
  background: var(--ffc-neutral-light);
  padding: 3px;
  border-radius: 7px;
}
.chart-period-tab {
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 5px;
  border: none;
  background: none;
  color: var(--ffc-neutral-mid);
  cursor: pointer;
  transition: var(--ffc-transition);
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.chart-period-tab.active {
  background: var(--ffc-white);
  color: var(--ffc-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* ── 14. Auth Pages ────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  background: var(--ffc-white);
}
.auth-panel-left {
  flex: 0 0 42%;
  background: linear-gradient(160deg, var(--ffc-primary-deeper) 0%, #3d1208 60%, #1a0804 100%);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-panel-left::before {
  content: '';
  position: absolute;
  top: -30%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(221,43,36,0.25) 0%, transparent 70%);
  border-radius: 50%;
}
.auth-panel-left::after {
  content: '';
  position: absolute;
  bottom: -20%;
  left: -10%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(244,163,64,0.12) 0%, transparent 70%);
  border-radius: 50%;
}

.auth-panel-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: #fff;
}
.auth-form-box {
  width: 100%;
  max-width: 400px;
}

.auth-logo-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 8px 16px;
  border-radius: 8px;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.auth-logo-badge span {
  width: 28px;
  height: 28px;
  background: var(--ffc-primary);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

.auth-tagline {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.25;
  margin: 0;
}
.auth-tagline em {
  font-style: normal;
  color: var(--ffc-primary-muted);
}

.auth-feat-list { list-style: none; padding: 0; margin: 0; }
.auth-feat-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
  margin-bottom: 10px;
}
.auth-feat-list li i { color: var(--ffc-primary-muted); font-size: 0.8rem; }

/* ── 15. Empty States ──────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-state-icon {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--ffc-neutral-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 1.8rem;
  color: var(--ffc-neutral-mid);
}
.empty-state h6 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ffc-neutral-dark);
  margin-bottom: 6px;
}
.empty-state p { font-size: 0.82rem; color: var(--ffc-neutral-mid); margin: 0; }

/* ── 16. Dropdowns ─────────────────────────────────────────── */
.dropdown-menu {
  border: 1px solid var(--ffc-border);
  border-radius: var(--ffc-radius-sm);
  box-shadow: var(--ffc-shadow-md);
  padding: 6px;
  font-size: 0.82rem;
}
.dropdown-item {
  border-radius: 5px;
  padding: 7px 12px;
  color: var(--ffc-neutral-dark);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}
.dropdown-item:hover {
  background: var(--ffc-primary-light);
  color: var(--ffc-primary);
}
.dropdown-item i { width: 14px; text-align: center; color: var(--ffc-neutral-mid); font-size: 0.78rem; }
.dropdown-item:hover i { color: var(--ffc-primary); }
.dropdown-divider { border-color: var(--ffc-border); margin: 4px 0; }
.dropdown-item.text-danger:hover { background: var(--ffc-primary-light); color: var(--ffc-primary); }

/* ── 17. Misc Utilities ────────────────────────────────────── */
.text-ffc-primary { color: var(--ffc-primary) !important; }
.text-ffc-muted   { color: var(--ffc-neutral-mid) !important; }
.bg-ffc-light     { background: var(--ffc-primary-light) !important; }

/* ── Custom Scrollbars (Except Sidebar) ────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--ffc-neutral-light);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb {
  background: var(--ffc-neutral-mid);
  border-radius: 3px;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ffc-primary-deeper);
}

::-webkit-scrollbar-corner {
  background: var(--ffc-primary-deeper);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--ffc-neutral-mid) var(--ffc-neutral-light);
}

/* IE/Edge scrollbar */
* {
  -ms-overflow-style: -ms-autohiding-scrollbar;
}

/* Sidebar scrollbar override (keep original) */
.ffc-sidebar::-webkit-scrollbar { 
  width: 4px; 
}
.ffc-sidebar::-webkit-scrollbar-track { 
  background: transparent; 
}
.ffc-sidebar::-webkit-scrollbar-thumb { 
  background: rgba(255,255,255,0.1); 
  border-radius: 2px; 
}
.ffc-sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}

.sidebar-nav::-webkit-scrollbar { 
  width: 4px; 
}
.sidebar-nav::-webkit-scrollbar-track { 
  background: transparent; 
}
.sidebar-nav::-webkit-scrollbar-thumb { 
  background: rgba(255,255,255,0.1); 
  border-radius: 2px; 
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}

.divider {
  border: none;
  border-top: 1px solid var(--ffc-border);
  margin: 20px 0;
}

.skeleton {
  background: linear-gradient(90deg, var(--ffc-neutral-light) 25%, #e9eef3 50%, var(--ffc-neutral-light) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 4px;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── 18. Responsive ────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .ffc-topbar { left: 0; }
  .ffc-content { margin-left: 0; }
  .ffc-sidebar {
    transform: translateX(calc(-1 * var(--ffc-sidebar-w)));
    z-index: 1050;
  }
  .ffc-sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1040;
  }
  .sidebar-overlay.show { display: block; }
  body.sidebar-collapsed .ffc-sidebar { transform: translateX(0); }
  body.sidebar-collapsed .ffc-topbar  { left: 0; }
  body.sidebar-collapsed .ffc-content { margin-left: 0; }
}

@media (max-width: 767.98px) {
  .content-inner { padding: 20px 16px 40px; }
  .auth-panel-left { display: none; }
  .auth-panel-right { padding: 28px 20px; }
  .stat-card { padding: 14px; }
  .stat-icon { width: 42px; height: 42px; font-size: 1rem; }
  .stat-body .stat-value { font-size: 1.25rem; }
  .topbar-search { display: none; }
  .user-info-text { display: none; }
  
  /* Better table handling on mobile */
  .ffc-table thead th {
    padding: 10px 12px;
    font-size: 0.68rem;
  }
  .ffc-table tbody td {
    padding: 10px 12px;
    font-size: 0.78rem;
  }
  
  /* Ensure sidebar footer stays visible */
  .ffc-sidebar {
    display: flex;
    flex-direction: column;
    max-height: 100vh;
  }
  .toast-container-ffc { right: 12px; left: 12px; min-width: unset; top: 70px; }
}

/* Responsive toolbar adjustments */
@media (max-width: 991.98px) {
  .table-toolbar .toolbar-left .search-wrap {
    width: 240px;
  }
}

@media (max-width: 767.98px) {
  .table-toolbar {
    gap: 12px;
  }
  
  .table-toolbar .toolbar-left {
    flex: 1 1 100%;
  }
  
  .table-toolbar .toolbar-left .search-wrap {
    width: 100%;
    max-width: none;
  }
  
  .table-toolbar .toolbar-right {
    flex: 1 1 100%;
    justify-content: flex-start;
    gap: 8px;
  }
  
  .table-toolbar .filter-select {
    flex: 1 1 auto;
    min-width: 120px;
    max-width: none;
  }
  
  .table-toolbar .results-count {
    flex: 1 1 100%;
    text-align: right;
    padding-left: 0;
    padding-top: 4px;
  }
}

@media (max-width: 575.98px) {
  .table-toolbar {
    padding: 12px 14px;
  }
  
  .table-toolbar .toolbar-right {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  .table-toolbar .filter-select {
    width: 100%;
    max-width: none;
  }
  
  .table-toolbar .results-count {
    text-align: left;
    border-top: 1px solid var(--ffc-border);
    padding-top: 8px;
    margin-top: 4px;
  }
}

/* ── 19. Print ─────────────────────────────────────────────── */
@media print {
  .ffc-sidebar, .ffc-topbar, .no-print { display: none !important; }
  .ffc-content { margin-left: 0; padding-top: 0; }
  .content-inner { padding: 0; }
}
