/* FieldTrack App CSS
   CSS Variables + Component Library
   ================================================== */

:root {
  --ft-primary:        #0F766E;
  --ft-primary-light:  #14B8A6;
  --ft-primary-dark:   #0D6560;
  --ft-dark:           #16323A;
  --ft-dark-hover:     #1e424c;
  --ft-muted:          #5B7078;
  --ft-border:         #D5DFDD;
  --ft-bg:             #F3F7F7;
  --ft-white:          #FFFFFF;
  --ft-success:        #16A34A;
  --ft-danger:         #DC2626;
  --ft-warning:        #D97706;
  --ft-info:           #2563EB;
  --ft-orange:         #EA580C;
  --ft-sidebar-width:  260px;
  --ft-header-height:  60px;
  --ft-shadow-sm:      0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --ft-shadow:         0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
  --ft-shadow-lg:      0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --ft-radius:         0.5rem;
  --ft-radius-sm:      0.25rem;
  --ft-radius-lg:      0.75rem;
  --ft-transition:     0.2s ease;
}

/* ============================================================
   RESET / BASE
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: #1e2d31;
  background-color: var(--ft-bg);
  -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; height: auto; }

/* ============================================================
   LAYOUT — BODY / SIDEBAR / MAIN
   ============================================================ */

.ft-body {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.ft-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--ft-sidebar-width);
  height: 100vh;
  height: 100dvh;
  bottom: 0;
  background-color: var(--ft-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1040;
  transition: transform var(--ft-transition);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}
.ft-sidebar::-webkit-scrollbar { width: 4px; }
.ft-sidebar::-webkit-scrollbar-track { background: transparent; }
.ft-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* ---- Sidebar Brand ---- */
.ft-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.1rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  text-decoration: none;
  flex-shrink: 0;
}
.ft-sidebar-brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--ft-primary-light), var(--ft-primary));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(15,118,110,0.4);
}
.ft-sidebar-brand-icon svg { width: 20px; height: 20px; color: #fff; }
.ft-sidebar-brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}
.ft-sidebar-brand-tagline {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.45);
  display: block;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  margin-top: 1px;
}

/* ---- Sidebar User Block ---- */
.ft-sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.ft-sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
}
.ft-sidebar-user-initials {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ft-primary-light), var(--ft-primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}
.ft-sidebar-user-name {
  font-size: 0.825rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ft-sidebar-user-role {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.45);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---- Sidebar Navigation ---- */
.ft-sidebar-nav {
  flex: 1;
  padding: 0.5rem 0 1rem;
  list-style: none;
  margin: 0;
}

.ft-nav-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  padding: 1rem 1.25rem 0.3rem;
  display: block;
}

.ft-nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 1.25rem;
  color: rgba(255,255,255,0.78);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  list-style: none;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background var(--ft-transition), color var(--ft-transition);
}
.ft-nav-item i,
.ft-nav-item svg {
  width: 18px;
  flex-shrink: 0;
  font-size: 1rem;
  opacity: 0.8;
  transition: opacity var(--ft-transition);
}
.ft-nav-item:hover,
.ft-nav-item:focus {
  background: rgba(255,255,255,0.08);
  color: #fff;
  text-decoration: none;
}
.ft-nav-item:hover i,
.ft-nav-item:hover svg { opacity: 1; }
.ft-nav-item.active {
  background: rgba(15,118,110,0.75);
  color: #fff;
  border-left-color: var(--ft-primary-light);
  font-weight: 600;
}
.ft-nav-item.active i,
.ft-nav-item.active svg { opacity: 1; }
.ft-nav-item.text-danger { color: #F87171 !important; }
.ft-nav-item.text-danger:hover { background: rgba(248,113,113,0.12); color: #FCA5A5 !important; }

.ft-nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 1.25rem;
  color: rgba(255,255,255,0.72);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 0;
  transition: background var(--ft-transition), color var(--ft-transition);
  border-left: 3px solid transparent;
  cursor: pointer;
}
.ft-nav-link svg,
.ft-nav-link i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.75;
  font-size: 1rem;
  transition: opacity var(--ft-transition);
}
.ft-nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
  text-decoration: none;
}
.ft-nav-link:hover svg,
.ft-nav-link:hover i { opacity: 1; }

.ft-nav-link.active {
  background: rgba(15,118,110,0.75);
  color: #fff;
  border-left-color: var(--ft-primary-light);
  font-weight: 600;
}
.ft-nav-link.active svg,
.ft-nav-link.active i { opacity: 1; }

.ft-nav-badge {
  margin-left: auto;
  background: var(--ft-danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.12rem 0.45rem;
  border-radius: 20px;
  line-height: 1.4;
}

/* Sidebar footer */
.ft-sidebar-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.07);
  font-size: 0.72rem;
  color: rgba(255,255,255,0.3);
  flex-shrink: 0;
}

/* ---- Sidebar overlay (mobile) ---- */
.ft-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1035;
  backdrop-filter: blur(2px);
}
.ft-sidebar-overlay.show { display: block; }

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

/* ============================================================
   HEADER
   ============================================================ */

.ft-header {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: var(--ft-white);
  height: var(--ft-header-height);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  box-shadow: 0 1px 0 var(--ft-border), 0 2px 8px rgba(0,0,0,0.04);
}

.ft-header-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--ft-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--ft-radius-sm);
  transition: background var(--ft-transition), color var(--ft-transition);
  line-height: 1;
}
.ft-header-toggle:hover { background: var(--ft-bg); color: var(--ft-dark); }
.ft-header-toggle svg, .ft-header-toggle i { width: 22px; height: 22px; font-size: 1.2rem; }

.ft-header-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ft-dark);
  margin: 0;
  flex: 1;
}

.ft-header-search {
  position: relative;
  max-width: 280px;
  flex: 1;
}
.ft-header-search input {
  width: 100%;
  padding: 0.4rem 0.85rem 0.4rem 2.25rem;
  border: 1px solid var(--ft-border);
  border-radius: 20px;
  font-size: 0.85rem;
  background: var(--ft-bg);
  color: var(--ft-dark);
  outline: none;
  transition: border-color var(--ft-transition), box-shadow var(--ft-transition);
}
.ft-header-search input:focus {
  border-color: var(--ft-primary);
  box-shadow: 0 0 0 3px rgba(15,118,110,0.12);
}
.ft-header-search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ft-muted);
  width: 15px;
  height: 15px;
  pointer-events: none;
}

.ft-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.ft-header-icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ft-muted);
  transition: background var(--ft-transition), color var(--ft-transition);
}
.ft-header-icon-btn:hover { background: var(--ft-bg); color: var(--ft-dark); }
.ft-header-icon-btn svg, .ft-header-icon-btn i { width: 20px; height: 20px; font-size: 1.1rem; }

.ft-notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 9px;
  height: 9px;
  background: var(--ft-danger);
  border-radius: 50%;
  border: 2px solid var(--ft-white);
}

/* ---- Notification Dropdown ---- */
.ft-notif-dropdown {
  width: 320px;
  max-height: 480px;
  overflow-y: auto;
  padding: 0;
}
.ft-notif-dropdown .dropdown-header {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ft-dark);
  padding: 0.75rem 1rem 0.5rem;
  border-bottom: 1px solid var(--ft-border);
}
.ft-notif-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--ft-border);
  cursor: pointer;
  transition: background var(--ft-transition);
}
.ft-notif-item:hover { background: var(--ft-bg); }
.ft-notif-item.unread { background: rgba(15,118,110,0.06); }
.ft-notif-item.unread:hover { background: rgba(15,118,110,0.1); }
.ft-notif-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.9rem;
}
.ft-notif-text {
  flex: 1;
  min-width: 0;
}
.ft-notif-text p { margin: 0; font-size: 0.825rem; line-height: 1.4; color: #2c3e42; }
.ft-notif-text .ft-notif-time { font-size: 0.72rem; color: var(--ft-muted); margin-top: 2px; }
.ft-notif-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ft-primary); flex-shrink: 0; margin-top: 5px; }

/* Header Avatar */
.ft-header-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--ft-border);
  cursor: pointer;
}
.ft-header-avatar-initials {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ft-primary-light), var(--ft-primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  border: 2px solid rgba(15,118,110,0.3);
}

/* ============================================================
   CONTENT AREA
   ============================================================ */

.ft-content {
  padding: 1.5rem;
  flex: 1;
}

/* ---- Page Header ---- */
.ft-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.ft-page-header-left {}
.ft-page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ft-dark);
  margin: 0 0 0.15rem;
  letter-spacing: -0.01em;
}
.ft-page-subtitle {
  font-size: 0.83rem;
  color: var(--ft-muted);
  margin: 0;
}
.ft-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--ft-muted);
  margin-bottom: 0.25rem;
  list-style: none;
  padding: 0;
}
.ft-breadcrumb-item + .ft-breadcrumb-item::before { content: '/'; margin-right: 0.35rem; opacity: 0.5; }
.ft-breadcrumb a { color: var(--ft-primary); }

/* ============================================================
   CARDS
   ============================================================ */

.ft-card {
  background: var(--ft-white);
  border-radius: var(--ft-radius-lg);
  box-shadow: var(--ft-shadow-sm);
  border: 1px solid var(--ft-border);
  overflow: hidden;
}
.ft-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: #f8fafa;
  border-bottom: 1px solid var(--ft-border);
}
.ft-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ft-dark);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.ft-card-body { padding: 1.25rem; }
.ft-card-footer {
  padding: 0.85rem 1.25rem;
  background: #f8fafa;
  border-top: 1px solid var(--ft-border);
  font-size: 0.82rem;
  color: var(--ft-muted);
}

/* ============================================================
   STAT CARDS
   ============================================================ */

.ft-stat-card {
  background: var(--ft-white);
  border-radius: var(--ft-radius-lg);
  box-shadow: var(--ft-shadow-sm);
  border: 1px solid var(--ft-border);
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: box-shadow var(--ft-transition), transform var(--ft-transition);
}
.ft-stat-card:hover { box-shadow: var(--ft-shadow); transform: translateY(-1px); }

.ft-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.15rem;
}
.ft-stat-icon svg { width: 22px; height: 22px; }
.ft-stat-icon.primary { background: rgba(15,118,110,0.12); color: var(--ft-primary); }
.ft-stat-icon.success { background: rgba(22,163,74,0.12); color: var(--ft-success); }
.ft-stat-icon.danger  { background: rgba(220,38,38,0.12);  color: var(--ft-danger); }
.ft-stat-icon.warning { background: rgba(217,119,6,0.12);  color: var(--ft-warning); }
.ft-stat-icon.info    { background: rgba(37,99,235,0.12);  color: var(--ft-info); }
.ft-stat-icon.orange  { background: rgba(234,88,12,0.12);  color: var(--ft-orange); }

.ft-stat-body { flex: 1; min-width: 0; }
.ft-stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--ft-dark);
  line-height: 1;
  letter-spacing: -0.02em;
}
.ft-stat-label {
  font-size: 0.78rem;
  color: var(--ft-muted);
  margin-top: 0.15rem;
  font-weight: 500;
}
.ft-stat-change {
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.2rem;
}
.ft-stat-change.up { color: var(--ft-success); }
.ft-stat-change.down { color: var(--ft-danger); }

/* ============================================================
   DAY CARD (Dashboard Featured)
   ============================================================ */

.ft-day-card {
  background: linear-gradient(135deg, var(--ft-primary) 0%, var(--ft-dark) 100%);
  color: #fff;
  border-radius: var(--ft-radius-lg);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 25px rgba(15,118,110,0.35);
}
.ft-day-card::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
}
.ft-day-card::after {
  content: '';
  position: absolute;
  bottom: -30px;
  right: 30px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
}
.ft-day-card-date { font-size: 0.78rem; opacity: 0.75; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; }
.ft-day-card-title { font-size: 1.5rem; font-weight: 800; margin: 0.25rem 0 0.5rem; letter-spacing: -0.02em; }
.ft-day-card-subtitle { font-size: 0.85rem; opacity: 0.75; }
.ft-day-card-stats { display: flex; gap: 1.5rem; margin-top: 1.25rem; }
.ft-day-card-stat-val { font-size: 1.4rem; font-weight: 800; }
.ft-day-card-stat-lbl { font-size: 0.7rem; opacity: 0.6; text-transform: uppercase; letter-spacing: 0.05em; }

/* ============================================================
   STATUS DOT / PRESENCE
   ============================================================ */

.ft-status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ft-muted);
  flex-shrink: 0;
}
.ft-status-dot.active {
  background: var(--ft-success);
  animation: ft-pulse 2s infinite;
}
.ft-status-dot.inactive { background: #ccc; }
.ft-status-dot.busy     { background: var(--ft-danger); }

@keyframes ft-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(22,163,74,0.5); }
  70%  { box-shadow: 0 0 0 6px rgba(22,163,74,0); }
  100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); }
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */

.ft-progress {
  height: 8px;
  background: var(--ft-border);
  border-radius: 20px;
  overflow: hidden;
}
.ft-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--ft-primary-light), var(--ft-primary));
  border-radius: 20px;
  transition: width 0.6s ease;
}
.ft-progress-bar.success { background: linear-gradient(90deg, #4ade80, var(--ft-success)); }
.ft-progress-bar.danger  { background: linear-gradient(90deg, #f87171, var(--ft-danger)); }
.ft-progress-bar.warning { background: linear-gradient(90deg, #fcd34d, var(--ft-warning)); }

/* ============================================================
   BUTTONS
   ============================================================ */

.ft-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--ft-radius);
  border: 1.5px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--ft-transition);
  white-space: nowrap;
  line-height: 1.4;
}
.ft-btn svg { width: 16px; height: 16px; }
.ft-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.ft-btn-primary {
  background: var(--ft-primary);
  color: #fff;
  border-color: var(--ft-primary);
}
.ft-btn-primary:hover:not(:disabled) {
  background: var(--ft-primary-dark);
  border-color: var(--ft-primary-dark);
  color: #fff;
  text-decoration: none;
}

.ft-btn-secondary {
  background: var(--ft-white);
  color: var(--ft-dark);
  border-color: var(--ft-border);
}
.ft-btn-secondary:hover:not(:disabled) { background: var(--ft-bg); text-decoration: none; }

.ft-btn-danger {
  background: var(--ft-danger);
  color: #fff;
  border-color: var(--ft-danger);
}
.ft-btn-danger:hover:not(:disabled) { background: #b91c1c; border-color: #b91c1c; text-decoration: none; color: #fff; }

.ft-btn-success {
  background: var(--ft-success);
  color: #fff;
  border-color: var(--ft-success);
}
.ft-btn-success:hover:not(:disabled) { background: #15803d; border-color: #15803d; color: #fff; text-decoration: none; }

.ft-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--ft-radius);
  border: 1.5px solid var(--ft-primary);
  color: var(--ft-primary);
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--ft-transition);
}
.ft-quick-btn:hover {
  background: var(--ft-primary);
  color: #fff;
  text-decoration: none;
}
.ft-quick-btn svg { width: 15px; height: 15px; }

.ft-btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.ft-btn-lg { padding: 0.65rem 1.4rem; font-size: 1rem; }

/* ============================================================
   BADGES / STATUS
   ============================================================ */

.ft-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 20px;
  letter-spacing: 0.02em;
  text-transform: capitalize;
}

/* Status variants */
.ft-status-badge             { composes: ft-badge; }
.ft-status-planned           { background: rgba(37,99,235,0.12);   color: #1d4ed8; }
.ft-status-done              { background: rgba(22,163,74,0.12);   color: #15803d; }
.ft-status-missed            { background: rgba(220,38,38,0.12);   color: #b91c1c; }
.ft-status-rescheduled       { background: rgba(234,88,12,0.12);   color: #c2410c; }
.ft-status-in_progress,
.ft-status-in-progress       { background: rgba(217,119,6,0.12);   color: #b45309; }
.ft-status-pending           { background: rgba(91,112,120,0.12);  color: var(--ft-muted); }
.ft-status-approved          { background: rgba(22,163,74,0.12);   color: #15803d; }
.ft-status-rejected          { background: rgba(220,38,38,0.12);   color: #b91c1c; }
.ft-status-cancelled         { background: rgba(91,112,120,0.12);  color: var(--ft-muted); }
.ft-status-confirmed         { background: rgba(15,118,110,0.12);  color: var(--ft-primary); }

/* Priority variants */
.ft-priority { composes: ft-badge; }
.ft-priority-low      { background: rgba(37,99,235,0.1);   color: #1d4ed8; }
.ft-priority-medium   { background: rgba(217,119,6,0.1);   color: #b45309; }
.ft-priority-high     { background: rgba(234,88,12,0.1);   color: #c2410c; }
.ft-priority-urgent   { background: rgba(220,38,38,0.12);  color: #b91c1c; }

/* ============================================================
   AVATARS
   ============================================================ */

.ft-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--ft-border);
  display: inline-block;
  flex-shrink: 0;
}
.ft-avatar-sm { width: 28px; height: 28px; }
.ft-avatar-lg { width: 52px; height: 52px; }
.ft-avatar-xl { width: 72px; height: 72px; }

.ft-avatar-initials {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ft-primary-light), var(--ft-primary));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
.ft-avatar-initials.sm { width: 28px; height: 28px; font-size: 0.65rem; }
.ft-avatar-initials.lg { width: 52px; height: 52px; font-size: 1rem; }
.ft-avatar-initials.xl { width: 72px; height: 72px; font-size: 1.3rem; }

.ft-avatar-group { display: flex; }
.ft-avatar-group .ft-avatar,
.ft-avatar-group .ft-avatar-initials {
  margin-left: -8px;
  border: 2px solid var(--ft-white);
}
.ft-avatar-group .ft-avatar:first-child,
.ft-avatar-group .ft-avatar-initials:first-child { margin-left: 0; }

/* ============================================================
   TABLE
   ============================================================ */

.ft-table-wrapper { overflow-x: auto; }

.ft-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.ft-table thead {
  background: #f4f8f8;
  border-bottom: 2px solid var(--ft-border);
}
.ft-table thead th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ft-muted);
  white-space: nowrap;
}
.ft-table tbody tr {
  border-bottom: 1px solid var(--ft-border);
  transition: background var(--ft-transition);
}
.ft-table tbody tr:last-child { border-bottom: none; }
.ft-table tbody tr:hover { background: #f8fcfc; }
.ft-table td {
  padding: 0.8rem 1rem;
  vertical-align: middle;
  color: #2c3e42;
}
.ft-table td.muted { color: var(--ft-muted); font-size: 0.82rem; }

/* ============================================================
   FORMS
   ============================================================ */

.ft-form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ft-dark);
  margin-bottom: 0.35rem;
}
.ft-form-label .req { color: var(--ft-danger); margin-left: 2px; }

.ft-form-control {
  display: block;
  width: 100%;
  padding: 0.5rem 0.85rem;
  font-size: 0.9rem;
  border: 1.5px solid var(--ft-border);
  border-radius: var(--ft-radius);
  background: var(--ft-white);
  color: var(--ft-dark);
  outline: none;
  transition: border-color var(--ft-transition), box-shadow var(--ft-transition);
  font-family: inherit;
  line-height: 1.5;
}
.ft-form-control::placeholder { color: #a0b0b4; }
.ft-form-control:focus {
  border-color: var(--ft-primary);
  box-shadow: 0 0 0 3px rgba(15,118,110,0.12);
}
.ft-form-control:disabled,
.ft-form-control[readonly] { background: #f3f7f7; color: var(--ft-muted); cursor: not-allowed; }
.ft-form-control.error { border-color: var(--ft-danger); }

select.ft-form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235B7078' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2.25rem; }

.ft-form-hint { font-size: 0.75rem; color: var(--ft-muted); margin-top: 0.3rem; }
.ft-form-error { font-size: 0.75rem; color: var(--ft-danger); margin-top: 0.3rem; }

.ft-form-group { margin-bottom: 1rem; }

/* ============================================================
   ALERTS
   ============================================================ */

.ft-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.9rem 1rem;
  border-radius: var(--ft-radius);
  border-left: 4px solid transparent;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.ft-alert-icon { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }
.ft-alert-close { margin-left: auto; background: none; border: none; cursor: pointer; opacity: 0.5; padding: 0; font-size: 1rem; line-height: 1; }
.ft-alert-close:hover { opacity: 1; }

.ft-alert-success { background: rgba(22,163,74,0.08);  border-color: var(--ft-success); color: #14532d; }
.ft-alert-danger  { background: rgba(220,38,38,0.08);  border-color: var(--ft-danger);  color: #7f1d1d; }
.ft-alert-warning { background: rgba(217,119,6,0.08);  border-color: var(--ft-warning); color: #78350f; }
.ft-alert-info    { background: rgba(37,99,235,0.08);  border-color: var(--ft-info);    color: #1e3a5f; }

/* ============================================================
   EMPTY STATE
   ============================================================ */

.ft-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--ft-muted);
}
.ft-empty-state-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--ft-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  color: #a0b0b4;
  font-size: 1.5rem;
}
.ft-empty-state-icon svg { width: 28px; height: 28px; }
.ft-empty-state-title { font-size: 0.95rem; font-weight: 600; color: #4a6068; margin-bottom: 0.35rem; }
.ft-empty-state-text  { font-size: 0.83rem; max-width: 280px; line-height: 1.5; }

/* ============================================================
   AUTH PAGES
   ============================================================ */

.ft-auth-body {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--ft-primary) 0%, var(--ft-dark) 60%, #0a2228 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  position: relative;
}
.ft-auth-body::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top left, rgba(20,184,166,0.2) 0%, transparent 60%),
              radial-gradient(ellipse at bottom right, rgba(15,118,110,0.3) 0%, transparent 60%);
}

.ft-auth-card {
  background: var(--ft-white);
  border-radius: 1.25rem;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
}

.ft-auth-logo-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--ft-primary-light), var(--ft-primary));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  box-shadow: 0 8px 20px rgba(15,118,110,0.4);
  color: #fff;
  font-size: 1.75rem;
}
.ft-auth-logo-icon svg { width: 32px; height: 32px; }

.ft-auth-title {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--ft-dark);
  margin-bottom: 0.3rem;
  letter-spacing: -0.02em;
}
.ft-auth-subtitle {
  text-align: center;
  font-size: 0.85rem;
  color: var(--ft-muted);
  margin-bottom: 1.75rem;
}
.ft-auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.78rem;
  color: var(--ft-muted);
}
.ft-auth-body-bg-text {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.2);
  font-size: 0.75rem;
  z-index: 1;
  white-space: nowrap;
}

/* ============================================================
   PLAN ITEM
   ============================================================ */

.ft-plan-item {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--ft-border);
}
.ft-plan-item:last-child { border-bottom: none; }
.ft-plan-item-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}
.ft-plan-item-body { flex: 1; min-width: 0; }
.ft-plan-item-title { font-size: 0.875rem; font-weight: 600; color: var(--ft-dark); margin-bottom: 0.15rem; }
.ft-plan-item-meta  { font-size: 0.78rem; color: var(--ft-muted); display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.ft-plan-item-actions { display: flex; align-items: center; gap: 0.35rem; flex-shrink: 0; }

/* ============================================================
   MOBILE BOTTOM NAV
   ============================================================ */

.ft-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--ft-white);
  border-top: 1px solid var(--ft-border);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
  z-index: 1030;
  align-items: center;
  justify-content: space-around;
  padding: 0 0.5rem;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.ft-bottom-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  color: var(--ft-muted);
  font-size: 0.65rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.35rem 0.5rem;
  border-radius: var(--ft-radius-sm);
  transition: color var(--ft-transition);
  cursor: pointer;
  background: none;
  border: none;
  min-width: 48px;
}
.ft-bottom-item svg, .ft-bottom-item i { width: 22px; height: 22px; font-size: 1.15rem; margin-bottom: 1px; }
.ft-bottom-item.active, .ft-bottom-item:hover { color: var(--ft-primary); text-decoration: none; }

.ft-bottom-checkin {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ft-primary-light), var(--ft-primary));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(15,118,110,0.45);
  margin-top: -20px;
  cursor: pointer;
  border: 3px solid var(--ft-white);
  transition: transform var(--ft-transition), box-shadow var(--ft-transition);
  flex-shrink: 0;
}
.ft-bottom-checkin:hover { transform: scale(1.05); box-shadow: 0 6px 18px rgba(15,118,110,0.5); }
.ft-bottom-checkin svg { width: 22px; height: 22px; }

/* ============================================================
   MISC / UTILITY COMPONENTS
   ============================================================ */

/* Teal link */
.ft-link { color: var(--ft-primary); text-decoration: none; font-weight: 500; }
.ft-link:hover { text-decoration: underline; color: var(--ft-primary-dark); }

/* Divider */
.ft-divider { border: none; border-top: 1px solid var(--ft-border); margin: 1.25rem 0; }

/* Info row (label + value) */
.ft-info-row { display: flex; gap: 0.5rem; margin-bottom: 0.65rem; font-size: 0.875rem; }
.ft-info-row-label { color: var(--ft-muted); min-width: 130px; font-weight: 500; }
.ft-info-row-value { color: var(--ft-dark); font-weight: 500; }

/* GPS / Map placeholder */
.ft-map-placeholder {
  height: 180px;
  border-radius: var(--ft-radius);
  background: linear-gradient(135deg, #e8f4f3, #d5dfdd);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ft-muted);
  font-size: 0.85rem;
  gap: 0.5rem;
  border: 1px solid var(--ft-border);
}

/* Photo grid */
.ft-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 0.5rem; }
.ft-photo-thumb {
  aspect-ratio: 1;
  border-radius: var(--ft-radius-sm);
  object-fit: cover;
  width: 100%;
  border: 1px solid var(--ft-border);
  cursor: pointer;
  transition: opacity var(--ft-transition);
}
.ft-photo-thumb:hover { opacity: 0.85; }

/* Timeline */
.ft-timeline { position: relative; padding-left: 1.5rem; }
.ft-timeline::before { content: ''; position: absolute; left: 6px; top: 0; bottom: 0; width: 2px; background: var(--ft-border); }
.ft-timeline-item { position: relative; margin-bottom: 1.25rem; }
.ft-timeline-dot { position: absolute; left: -1.5rem; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--ft-white); border: 2px solid var(--ft-primary); }
.ft-timeline-dot.filled { background: var(--ft-primary); }
.ft-timeline-content { font-size: 0.85rem; }
.ft-timeline-title { font-weight: 600; color: var(--ft-dark); margin-bottom: 0.15rem; }
.ft-timeline-meta { font-size: 0.78rem; color: var(--ft-muted); }

/* Tooltip helper */
[data-ft-tooltip] { position: relative; cursor: help; }
[data-ft-tooltip]::after {
  content: attr(data-ft-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ft-dark);
  color: #fff;
  font-size: 0.72rem;
  padding: 0.3rem 0.65rem;
  border-radius: var(--ft-radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 9999;
}
[data-ft-tooltip]:hover::after { opacity: 1; }

/* Skeleton loader */
.ft-skeleton {
  background: linear-gradient(90deg, #e8f0ef 25%, #f3f7f7 50%, #e8f0ef 75%);
  background-size: 200% 100%;
  animation: ft-skeleton-shine 1.5s infinite;
  border-radius: var(--ft-radius-sm);
  height: 1em;
  display: block;
}
@keyframes ft-skeleton-shine {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Loading spinner */
.ft-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(15,118,110,0.2);
  border-top-color: var(--ft-primary);
  border-radius: 50%;
  animation: ft-spin 0.7s linear infinite;
}
.ft-spinner-sm { width: 14px; height: 14px; border-width: 2px; }
.ft-spinner-lg { width: 30px; height: 30px; border-width: 3px; }
@keyframes ft-spin { to { transform: rotate(360deg); } }

/* Modal backdrop extra */
.ft-modal-loading { display: flex; align-items: center; justify-content: center; min-height: 120px; }

/* ============================================================
   RESPONSIVE — BREAKPOINT 992px
   ============================================================ */

@media (max-width: 992px) {

  /* Sidebar collapses off-screen */
  .ft-sidebar {
    transform: translateX(calc(-1 * var(--ft-sidebar-width)));
    box-shadow: none;
    z-index: 1045;
  }
  .ft-sidebar.show {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.25);
  }

  /* Overlay shows behind sidebar */
  .ft-sidebar-overlay { display: block; visibility: hidden; opacity: 0; transition: opacity var(--ft-transition), visibility var(--ft-transition); }
  .ft-sidebar-overlay.show { visibility: visible; opacity: 1; }

  /* Close button inside sidebar on mobile */
  .ft-sidebar-close-btn { display: flex !important; }

  /* Main takes full width */
  .ft-main { margin-left: 0; }

  /* Show hamburger in header */
  .ft-header-toggle { display: flex; }

  /* Hide search on mobile, show icon only */
  .ft-header-search { display: none; }

  /* Bottom nav visible */
  .ft-bottom-nav { display: flex; }

  /* Add padding to content so bottom nav doesn't obscure */
  .ft-content { padding-bottom: calc(6rem + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 576px) {
  /* keep room for the fixed bottom nav (was being overridden to 1rem) */
  .ft-content { padding: 1rem 1rem calc(6rem + env(safe-area-inset-bottom, 0px)); }
  .ft-page-header { flex-direction: column; align-items: stretch; }
  .ft-stat-card { padding: 0.85rem 1rem; }
  .ft-stat-value { font-size: 1.3rem; }
  .ft-day-card { padding: 1.1rem; }
  .ft-auth-card { padding: 2rem 1.25rem; }
  .ft-table thead th { padding: 0.6rem 0.75rem; }
  .ft-table td { padding: 0.65rem 0.75rem; }
}

/* ============================================================
   PRINT
   ============================================================ */

@media print {
  .ft-sidebar,
  .ft-header,
  .ft-bottom-nav,
  .ft-sidebar-overlay { display: none !important; }
  .ft-main { margin-left: 0 !important; }
  .ft-content { padding: 0 !important; }
  .ft-card { box-shadow: none !important; border: 1px solid #ddd !important; }
}


/* ============================================================
   MOBILE FRIENDLY FIXES  (bottom nav, visit report, forms)
   ============================================================ */

/* Centre "Check In" button: bigger circle so icon + label both fit */
.ft-bottom-checkin {
  width: 60px;
  height: 60px;
  min-width: 60px;
  padding: 0;
  gap: 1px;
  margin-top: -26px;
  flex-direction: column;
  justify-content: center;
  color: #fff !important;
}
.ft-bottom-checkin i,
.ft-bottom-checkin svg { width: auto; height: auto; font-size: 1.25rem; margin: 0; line-height: 1; }
.ft-bottom-checkin span {
  font-size: 0.58rem;
  line-height: 1;
  white-space: nowrap;
  letter-spacing: 0;
}

/* Visit report action buttons */
.ft-report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: space-between;
  align-items: center;
}
.ft-report-actions-right { display: flex; gap: 0.5rem; }

@media (max-width: 576px) {

  /* Action bar: full-width stacked buttons -> Submit, Check Out, Save Draft */
  .ft-report-actions,
  .ft-report-actions-right {
    flex-direction: column-reverse;
    align-items: stretch;
    width: 100%;
  }
  .ft-report-actions .btn {
    width: 100%;
    min-height: 48px;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Less wasted padding inside cards */
  .ft-content .card-body.p-4 { padding: 1rem !important; }
  .ft-content .card-header { padding: 0.75rem 1rem !important; }

  /* Photo drop zone: touch-first */
  #dropZone { padding: 1.25rem 0.75rem !important; }
  #dropZone .btn { min-height: 46px; padding: 0.55rem 1.1rem; font-size: 0.95rem; }
  #dropZone .d-flex { flex-wrap: wrap; }

  /* Selfie buttons: full width */
  #selfieCameraWrap,
  #selfieGalleryWrap,
  #selfieCameraWrap .btn { width: 100%; }
  #selfieCameraWrap .btn,
  #selfieGalleryWrap { min-height: 48px; display: flex; align-items: center; justify-content: center; }

  /* Bigger tap targets + no iOS zoom on focus for form fields */
  .ft-content .form-control,
  .ft-content .form-select { min-height: 46px; font-size: 16px; }
  .ft-content textarea.form-control { min-height: 120px; }

  /* Webcam / generic modals go full width on phones */
  .modal-dialog { margin: 0.5rem; }
}


/* ============================================================
   MOBILE: RESPONSIVE LIST PAGES
   (tables -> cards, collapsible filters, date placeholders)
   ============================================================ */

/* Filter toggle button is hidden on desktop */
.ft-filter-toggle { display: none; }

@media (max-width: 767.98px) {

  /* ---------- Collapsible filters ---------- */
  .ft-filter-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 46px;
    padding: 0.5rem 0.9rem;
    background: #F0FDFA;
    color: var(--ft-primary);
    border: 1px solid rgba(15,118,110,0.25);
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
  }
  .ft-filter-count {
    display: inline-block;
    min-width: 20px;
    padding: 0 6px;
    margin-left: 6px;
    border-radius: 20px;
    background: var(--ft-primary);
    color: #fff;
    font-size: 0.72rem;
    line-height: 20px;
    text-align: center;
  }
  .ft-filter-chevron { transition: transform .2s; }
  .ft-filter-toggle.open .ft-filter-chevron { transform: rotate(180deg); }

  .ft-filter-form { display: none !important; margin-top: 0.75rem; }
  .ft-filter-form.ft-open { display: flex !important; }
  /* two fields per row, text/search + buttons full width */
  .ft-filter-form > * { width: 50%; flex: 0 0 auto; }
  .ft-filter-form > .ft-col-full { width: 100%; }
  .ft-filter-form .form-label { font-size: 0.78rem; margin-bottom: 0.2rem; }
  .ft-filter-form .btn { min-height: 46px; font-size: 1rem; display: flex; align-items: center; justify-content: center; }
  .ft-filter-form .d-flex.gap-2 .btn { flex: 1 1 0; }
  .ft-filter-form .btn.w-100 { width: 100% !important; }

  /* ---------- Date inputs ---------- */
  input[type="date"].form-control,
  input[type="date"].form-select {
    position: relative;
    padding-right: 2.4rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5M1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 18px;
  }
  input[type="date"].ft-date-empty:not(:focus)::before {
    content: attr(data-ph);
    color: #94a3b8;
    display: block;
    width: 100%;
  }
  input[type="date"].ft-date-empty:not(:focus)::-webkit-datetime-edit { display: none; }

  /* ---------- Tables -> cards ---------- */
  .ft-card-flat {
    background: transparent !important;
    box-shadow: none !important;
    border: 0 !important;
  }
  .ft-card-flat > .card-body { padding: 0 !important; background: transparent; }
  .ft-stack-wrap { overflow: visible !important; }

  .ft-stack,
  .ft-stack tbody,
  .ft-stack tfoot,
  .ft-stack tr,
  .ft-stack td { display: block; width: 100%; }
  .ft-stack thead { display: none; }

  .ft-stack tbody tr {
    background: #fff;
    border: 1px solid var(--ft-border);
    border-radius: 14px;
    box-shadow: 0 1px 4px rgba(15,23,42,0.06);
    margin-bottom: 0.8rem;
    padding: 0.35rem 0;
    overflow: hidden;
  }
  .ft-stack td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 1rem !important;
    border: 0 !important;
    text-align: right !important;
    max-width: none !important;
    min-height: 38px;
    background: transparent !important;
    word-break: break-word;
  }
  .ft-stack td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    max-width: 42%;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ft-muted);
    text-align: left;
  }
  .ft-stack td[data-label=""]::before { display: none; }
  .ft-stack td:empty { display: none; }

  /* first cell = card title */
  .ft-stack td.ft-cell-primary {
    justify-content: flex-start;
    text-align: left !important;
    font-size: 1.02rem;
    padding-top: 0.7rem !important;
    padding-bottom: 0.7rem !important;
    border-bottom: 1px solid var(--ft-border) !important;
    margin-bottom: 0.2rem;
    background: #F8FAFC !important;
  }
  .ft-stack td.ft-cell-primary::before { display: none; }

  /* actions row = big tap targets at the bottom of the card */
  .ft-stack td.ft-cell-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.3rem;
    padding-top: 0.7rem !important;
    border-top: 1px solid var(--ft-border) !important;
  }
  .ft-stack td.ft-cell-actions::before { display: none; }
  .ft-stack td.ft-cell-actions .btn,
  .ft-stack td.ft-cell-actions a.btn { min-width: 42px; min-height: 42px; display: inline-flex; align-items: center; justify-content: center; }
  .ft-stack td.ft-cell-actions form { display: inline-flex; margin: 0; }
  .ft-stack td.ft-cell-actions .d-flex,
  .ft-stack td.ft-cell-actions .btn-group { flex-wrap: wrap; gap: 0.5rem; }

  /* empty-state row (colspan) */
  .ft-stack tr.ft-row-wide td { justify-content: center; text-align: center !important; padding: 2rem 1rem !important; }
  .ft-stack tr.ft-row-wide td::before { display: none; }

  /* table footer (page totals) */
  .ft-stack tfoot tr {
    background: #F0FDFA;
    border-radius: 12px;
    padding: 0.3rem 0;
    margin-bottom: 0.8rem;
  }

  /* pagination footer */
  .ft-card-flat > .card-footer {
    background: #fff !important;
    border: 1px solid var(--ft-border) !important;
    border-radius: 14px;
    flex-direction: column;
    gap: 0.6rem;
    text-align: center;
    padding: 0.75rem !important;
  }
  .pagination { flex-wrap: wrap; justify-content: center; gap: 2px; }
  .page-link { min-width: 40px; min-height: 40px; display: flex; align-items: center; justify-content: center; }

  /* summary stat cards side by side */
  .ft-content .row > .col-6 > .card.text-center { padding: 0.75rem 0.25rem !important; }

  /* page header: title + action button stay on one row */
  .ft-content .ft-page-header { flex-direction: row; align-items: center; flex-wrap: wrap; }
}


/* ============================================================
   HEADER: MENU TOGGLE + HEADER BUTTONS
   (markup uses .ft-menu-toggle, old CSS only styled .ft-header-toggle)
   ============================================================ */
.ft-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #E6F4F1;
  color: var(--ft-primary);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--ft-transition), transform .1s ease;
}
.ft-menu-toggle i { font-size: 1.7rem; line-height: 1; }
.ft-menu-toggle:hover { background: #D3ECE7; }
.ft-menu-toggle:active { transform: scale(0.94); background: #C2E4DD; }
.ft-menu-toggle:focus-visible { outline: 2px solid var(--ft-primary-light); outline-offset: 2px; }

.ft-header-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ft-hbtn {
  height: 42px;
  min-width: 42px;
  border-radius: 12px !important;
  background: #F1F5F5 !important;
  border: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ft-hbtn:hover, .ft-hbtn:active { background: #E2ECEB !important; }
.ft-hbtn .bi-bell { font-size: 1.15rem; }
.ft-hbtn .badge { font-size: 0.65rem; }

@media (max-width: 992px) {
  :root { --ft-sidebar-width: min(285px, 86vw); }

  .ft-header { padding: 0 0.75rem; gap: 0.6rem; }
  .ft-header-title { font-size: 1rem; font-weight: 700; color: var(--ft-dark); pointer-events: auto; flex: 1 1 auto; }
  .ft-header-actions { margin-left: 0 !important; flex-shrink: 0; gap: 0.4rem; }
  .ft-header-actions .dropdown.me-2 { margin-right: 0 !important; }
  .ft-hbtn-user { padding-left: 0.4rem !important; padding-right: 0.55rem !important; }
  .ft-hbtn-user .bi-chevron-down { font-size: 0.7rem; }

  /* Drawer: bigger tap targets + softer overlay */
  .ft-nav-item { padding: 0.85rem 1.25rem; font-size: 0.95rem; }
  .ft-nav-item i { font-size: 1.1rem; }
  .ft-sidebar-overlay { background: rgba(15,23,42,0.5); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); z-index: 1044; }
  .ft-sidebar { padding-bottom: env(safe-area-inset-bottom, 0px); }
  .dropdown-menu { font-size: 1rem; }
  .dropdown-item { padding: 0.65rem 1rem; }
}

/* ============================================================
   TODAY'S PLAN / TASKS LIST (dashboard)
   ============================================================ */
.ft-tp-count {
  display: inline-block;
  min-width: 22px;
  padding: 0 7px;
  border-radius: 20px;
  background: #E6F4F1;
  color: var(--ft-primary);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
}
.ft-tp-list { display: flex; flex-direction: column; }
.ft-tp-item {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--ft-border);
  color: inherit;
  text-decoration: none !important;
  background: #fff;
}
.ft-tp-item:last-child { border-bottom: 0; }
a.ft-tp-item:active { background: #F5FAF9; }

.ft-tp-time {
  flex: 0 0 56px;
  width: 56px;
  min-height: 52px;
  border-radius: 12px;
  background: #E6F4F1;
  color: var(--ft-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  text-align: center;
}
.ft-tp-time i { font-size: 1.3rem; }
.ft-tp-time-main { font-size: 1rem; font-weight: 800; letter-spacing: -0.02em; }
.ft-tp-time-ampm { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em; opacity: 0.85; }
.ft-tp-done .ft-tp-time,
.ft-tp-visited .ft-tp-time { background: #DCFCE7; color: #15803d; }
.ft-tp-missed .ft-tp-time  { background: #FEE2E2; color: #b91c1c; }

.ft-tp-body { flex: 1 1 0; min-width: 0; }
.ft-tp-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.3;
  color: var(--ft-dark);
  text-decoration: none !important;
  word-break: break-word;
}
.ft-tp-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.7rem;
  margin-top: 0.3rem;
  font-size: 0.82rem;
  color: var(--ft-muted);
}
.ft-tp-meta i { margin-right: 4px; color: var(--ft-primary); }
.ft-tp-purpose {
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--ft-muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ft-tp-badge {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(91,112,120,0.12);
  color: var(--ft-muted);
}
.ft-tp-badge-planned { background: rgba(37,99,235,0.12);  color: #1d4ed8; }
.ft-tp-badge-visited,
.ft-tp-badge-done    { background: rgba(22,163,74,0.12);  color: #15803d; }
.ft-tp-badge-missed  { background: rgba(220,38,38,0.12);  color: #b91c1c; }
.ft-tp-badge-rescheduled { background: rgba(234,88,12,0.12); color: #c2410c; }
.ft-tp-prio { align-self: center; font-size: 0.72rem; padding: 0.35rem 0.6rem; border-radius: 20px; }

/* actions: full-width buttons under the info on phones */
.ft-tp-actions { flex: 1 1 100%; display: flex; gap: 0.5rem; }
.ft-tp-actions .btn {
  flex: 1 1 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
}
.ft-tp-btn-primary { background: var(--ft-primary); border: 1px solid var(--ft-primary); color: #fff !important; }
.ft-tp-btn-primary:hover, .ft-tp-btn-primary:active { background: var(--ft-primary-dark); color: #fff; }
.ft-tp-btn-ghost { background: #fff; border: 1px solid var(--ft-border); color: var(--ft-dark) !important; }
.ft-tp-btn-ghost:hover, .ft-tp-btn-ghost:active { background: #F3F7F7; }

@media (min-width: 576px) {
  .ft-tp-item { flex-wrap: nowrap; align-items: center; padding: 0.9rem 1.25rem; }
  .ft-tp-actions { flex: 0 0 auto; }
  .ft-tp-actions .btn { flex: 0 0 auto; min-height: 38px; padding: 0.35rem 0.9rem; font-size: 0.875rem; }
}

/* ============================================================
   FIX: DASHBOARD STAT TILES — equal size, centred, aligned
   (previously .ft-stat-card was a flex row, so each card's
   content shrink-wrapped to the left and looked misaligned)
   ============================================================ */
.ft-stat-card.card {
  display: block;
  height: 100%;
  padding: 0;
}
.ft-stat-card > .card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 132px;
  padding: 1rem 0.5rem;
  gap: 0.45rem;
  text-align: center;
}
.ft-stat-card .ft-stat-icon {
  width: 46px;
  height: 46px;
  margin: 0;
  font-size: 1.25rem;
}
.ft-stat-card .ft-stat-value { font-size: 1.75rem; line-height: 1; }
.ft-stat-card .ft-stat-label {
  margin: 0;
  line-height: 1.25;
  text-align: center;
  min-height: 2.5em;            /* keeps 1-line and 2-line labels aligned */
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.ft-bg-teal-subtle { background: rgba(15,118,110,0.12); }
@media (max-width: 576px) {
  .ft-stat-card > .card-body { min-height: 120px; padding: 0.85rem 0.4rem; }
  .ft-stat-card .ft-stat-icon { width: 42px; height: 42px; font-size: 1.15rem; }
  .ft-stat-card .ft-stat-value { font-size: 1.55rem; }
  .ft-stat-card .ft-stat-label { font-size: 0.8rem; min-height: 0; }
}

/* ============================================================
   FIX: TODAY'S PLAN — checked-in / visited states
   ============================================================ */
.ft-tp-checked_in .ft-tp-time { background: #DBEAFE; color: #1d4ed8; }
.ft-tp-checked_in { background: #F5F9FF; box-shadow: inset 3px 0 0 #2563eb; }
.ft-tp-badge-checked_in { background: rgba(37,99,235,0.14); color: #1d4ed8; }
.ft-tp-badge-checked_in i { margin-right: 3px; animation: ft-pulse 1.6s ease-in-out infinite; }
.ft-tp-badge i { color: inherit; margin-right: 3px; }
.ft-tp-btn-active { background: #2563eb; border: 1px solid #2563eb; color: #fff !important; }
.ft-tp-btn-active:hover, .ft-tp-btn-active:active { background: #1d4ed8; color: #fff; }
@keyframes ft-pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ============================================================
   VISIT DETAIL (.vd-*) — mobile-first, responsive
   ============================================================ */
.vd { max-width: 1100px; margin: 0 auto; }
.vd .row { --bs-gutter-y: 1rem; }
.vd-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.vd-back {
  flex: 0 0 44px; width: 44px; height: 44px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; border: 1px solid var(--ft-border); color: var(--ft-dark);
  font-size: 1.2rem; text-decoration: none;
}
.vd-back:active { background: #F3F7F7; }
.vd-header-text { min-width: 0; }
.vd-eyebrow { font-size: 0.72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ft-primary); }
.vd-title { margin: 0; font-size: 1.2rem; font-weight: 800; line-height: 1.25; color: var(--ft-dark); word-break: break-word; }

.vd-card {
  background: #fff; border: 1px solid var(--ft-border); border-radius: 14px;
  box-shadow: var(--ft-shadow-sm); padding: 1rem; margin-bottom: 1rem;
}
.vd-card-warn { border-color: #F59E0B; background: #FFFBEB; }
.vd-card-title {
  display: flex; align-items: center; gap: 0.5rem;
  margin: 0 0 0.85rem; font-size: 0.95rem; font-weight: 700; color: var(--ft-primary);
}
.vd-count { background: var(--ft-primary); color: #fff; border-radius: 20px; padding: 0 8px; font-size: 0.72rem; line-height: 20px; }

/* pills */
.vd-badges { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.vd-pill {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.3rem 0.7rem; border-radius: 20px; font-size: 0.8rem; font-weight: 700; line-height: 1.2;
}
.vd-pill-primary   { background: rgba(37,99,235,.12);  color: #1d4ed8; }
.vd-pill-secondary { background: rgba(91,112,120,.14); color: var(--ft-muted); }
.vd-pill-info      { background: rgba(8,145,178,.13);  color: #0e7490; }
.vd-pill-warning   { background: rgba(217,119,6,.15);  color: #b45309; }
.vd-pill-success   { background: rgba(22,163,74,.14);  color: #15803d; }
.vd-pill-danger    { background: rgba(220,38,38,.13);  color: #b91c1c; }

/* hero */
.vd-hero { background: linear-gradient(135deg, #F0FDFA, #fff 70%); }
.vd-facts { list-style: none; margin: 0.85rem 0 0; padding: 0; display: grid; gap: 0.5rem; }
.vd-facts li { display: flex; align-items: flex-start; gap: 0.6rem; font-size: 0.9rem; color: var(--ft-dark); }
.vd-facts i { color: var(--ft-primary); margin-top: 2px; }

/* active visit */
.vd-active { border-color: #93C5FD; background: #F5F9FF; }
.vd-active-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.75rem; }
.vd-live { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 700; color: #1d4ed8; font-size: 0.9rem; }
.vd-live-dot { width: 9px; height: 9px; border-radius: 50%; background: #2563eb; animation: ft-pulse 1.6s ease-in-out infinite; }
.vd-timer { font-weight: 800; font-size: 1rem; color: var(--ft-dark); background: #fff; border: 1px solid #BFDBFE; border-radius: 20px; padding: 0.15rem 0.7rem; }
.vd-checklist { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0.5rem; }
.vd-checklist li {
  display: flex; align-items: center; gap: 0.6rem; padding: 0.65rem 0.8rem;
  background: #fff; border: 1px solid var(--ft-border); border-radius: 10px; font-size: 0.92rem; font-weight: 600;
}
.vd-checklist li em { margin-left: auto; font-style: normal; font-size: 0.82rem; font-weight: 600; }
.vd-checklist li.ok i, .vd-checklist li.ok em { color: #15803d; }
.vd-checklist li.todo i, .vd-checklist li.todo em { color: #b45309; }

.vd-actions { display: grid; grid-template-columns: 1fr; gap: 0.6rem; }
.vd-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 48px; padding: 0.55rem 1rem; border-radius: 12px; font-weight: 700; font-size: 0.98rem;
  border: 1px solid transparent; text-decoration: none !important; cursor: pointer; width: 100%;
}
.vd-btn-primary { background: var(--ft-primary); color: #fff !important; }
.vd-btn-primary:active { background: var(--ft-primary-dark); }
.vd-btn-danger { background: #DC2626; color: #fff !important; }
.vd-btn-danger-outline { background: #fff; color: #DC2626 !important; border-color: #FCA5A5; }
.vd-btn:disabled { opacity: .7; }
.vd-hint { margin: 0.75rem 0 0; font-size: 0.82rem; color: var(--ft-muted); display: flex; gap: 0.4rem; align-items: center; }

.vd-notice { display: flex; gap: 0.75rem; background: #FFFBEB; border-color: #FCD34D; }
.vd-notice > i { color: #d97706; font-size: 1.25rem; margin-top: 2px; }
.vd-notice p { margin: 0.2rem 0 0.75rem; font-size: 0.9rem; color: var(--ft-dark); }

/* timing tiles */
.vd-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.vd-tile {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.15rem;
  padding: 0.7rem 0.3rem; background: #F8FBFA; border: 1px solid var(--ft-border); border-radius: 12px; min-width: 0;
}
.vd-tile-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ft-muted); }
.vd-tile strong { font-size: 0.98rem; color: var(--ft-dark); line-height: 1.25; }
.vd-tile small { font-size: 0.72rem; color: var(--ft-muted); }
.vd-tile-accent strong { color: var(--ft-primary); }
.vd-muted { color: var(--ft-muted) !important; font-style: italic; font-weight: 600; }

/* label/value lists: stacked on phones, side-by-side on larger screens */
.vd-list { margin: 0; }
.vd-row { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.7rem 0; border-bottom: 1px solid #EDF2F1; }
.vd-row:last-child { border-bottom: 0; padding-bottom: 0; }
.vd-row:first-child { padding-top: 0; }
.vd-row dt { font-size: 0.74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ft-muted); }
.vd-row dd { margin: 0; font-size: 0.95rem; color: var(--ft-dark); word-break: break-word; }
.vd-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; display: block; }
.vd-link { display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 0.35rem; color: var(--ft-primary); font-weight: 600; font-size: 0.88rem; text-decoration: none; }
.vd-warn { background: #FEF3C7; border-radius: 10px; padding: 0.65rem 0.8rem; margin-bottom: 0.85rem; font-size: 0.88rem; color: #92400E; }

/* photos */
.vd-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
.vd-photo { position: relative; padding: 0; border: 0; border-radius: 10px; overflow: hidden; aspect-ratio: 1; background: #E5ECEB; cursor: zoom-in; }
.vd-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vd-photo span { position: absolute; left: 4px; bottom: 4px; max-width: calc(100% - 8px); background: rgba(0,0,0,.65); color: #fff; font-size: 0.65rem; padding: 1px 6px; border-radius: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* institution / executive */
.vd-inst { display: flex; align-items: center; gap: 0.75rem; text-decoration: none !important; color: var(--ft-dark); min-height: 48px; }
.vd-inst strong { display: block; font-size: 0.95rem; line-height: 1.3; }
.vd-inst small { color: var(--ft-muted); font-size: 0.82rem; }
.vd-avatar { flex: 0 0 42px; height: 42px; border-radius: 12px; background: #E6F4F1; color: var(--ft-primary); display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; }
.vd-avatar-round { border-radius: 50%; background: var(--ft-primary); color: #fff; font-weight: 700; }
.vd-small { font-size: 0.85rem; color: var(--ft-muted); margin: 0.6rem 0 0; }
.vd-quote { margin: 0.7rem 0 0; padding: 0.6rem 0.8rem; background: #F8FAFC; border-left: 3px solid var(--ft-primary); border-radius: 0 8px 8px 0; font-size: 0.88rem; }
.vd-empty { display: flex; align-items: center; gap: 0.6rem; color: var(--ft-muted); font-size: 0.9rem; margin-bottom: 0.75rem; }
.vd-empty i { font-size: 1.25rem; opacity: .6; }

/* tablet / desktop */
@media (min-width: 576px) {
  .vd-title { font-size: 1.45rem; }
  .vd-card { padding: 1.25rem; }
  .vd-actions { grid-template-columns: 1fr 1fr; }
  .vd-btn { width: auto; }
  .vd-actions .vd-btn { width: 100%; }
  .vd-tile strong { font-size: 1.1rem; }
  .vd-row { flex-direction: row; gap: 1rem; }
  .vd-row dt { flex: 0 0 130px; padding-top: 2px; }
  .vd-row dd { flex: 1; }
  .vd-photos { grid-template-columns: repeat(4, 1fr); gap: 0.6rem; }
  .vd-facts { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; }
}
@media (min-width: 992px) {
  .vd-photos { grid-template-columns: repeat(4, 1fr); }
}
