/* ============================================================
   FieldCRM — Mobile-First CSS
   Design rule: 99% mobile/tablet. Phone screen = default.
   No horizontal scroll anywhere. Vertical scroll only.
   Base font 14px. Touch targets min 44px.
   ============================================================ */

:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #eff6ff;
  --success:       #16a34a;
  --success-light: #f0fdf4;
  --warning:       #d97706;
  --warning-light: #fffbeb;
  --danger:        #dc2626;
  --danger-light:  #fef2f2;
  --info:          #0891b2;
  --info-light:    #ecfeff;
  --purple:        #7c3aed;
  --purple-light:  #f5f3ff;
  --secondary:     #64748b;
  --bg:            #f1f5f9;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --text:          #0f172a;
  --text-muted:    #64748b;
  --sidebar-w:     260px;
  --navbar-h:      52px;
  --bottom-nav-h:  58px;
  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 1px 3px rgba(0,0,0,.08);
  --shadow-md:     0 4px 12px rgba(0,0,0,.12);
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 17px; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 17px !important;          /* override Bootstrap 5 body font-size */
  --bs-body-font-size: 16px;           /* override Bootstrap CSS variable */
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
* { max-width: 100%; }
img, video, iframe { max-width: 100%; height: auto; }
a { color: var(--primary); text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ── Navbar ───────────────────────────────────────────────── */
.app-navbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--navbar-h);
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center;
  padding: 0 .75rem;
  z-index: 1030;
  gap: .5rem;
  box-shadow: var(--shadow-md);
}
.navbar-brand {
  font-weight: 700; font-size: 1rem;
  color: #fff; letter-spacing: -.2px;
  white-space: nowrap;
}
.navbar-spacer { flex: 1; }
.navbar-icon-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: rgba(255,255,255,.15);
  border-radius: 8px; cursor: pointer; color: #fff;
  font-size: 1.1rem; flex-shrink: 0;
}
.sidebar-toggle {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: rgba(255,255,255,.15);
  border-radius: 6px; cursor: pointer; color: #fff;
  font-size: 1.2rem; flex-shrink: 0;
}
.navbar-icon-btn:hover, .sidebar-toggle:hover { background: rgba(255,255,255,.25); }

/* dropdown avatar */
.app-navbar .dropdown button {
  border: none; background: transparent; padding: 0; cursor: pointer;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.app-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 1050;
  overflow-y: auto;
  padding-top: var(--navbar-h);
  transition: transform .25s ease;
  transform: translateX(-100%);
}
.app-sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 1040;
}
.sidebar-overlay.show { display: block; }
.sidebar-staff {
  display: flex; align-items: center; gap: .75rem;
  padding: 1rem .9rem; border-bottom: 1px solid var(--border);
}
.sidebar-staff-name { font-weight: 600; font-size: 1.1rem; line-height: 1.2; }
.sidebar-staff-role { font-size: 0.912rem; color: var(--text-muted); }
.sidebar-section-label {
  font-size: 0.838rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-muted);
  padding: .75rem .9rem .2rem;
}
.sidebar-nav { list-style: none; padding: 0 .5rem; }
.sidebar-nav li a {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .7rem; border-radius: var(--radius-sm);
  color: var(--text); font-size: 1.1rem; font-weight: 500;
  transition: background .12s;
}
.sidebar-nav li a i { font-size: 1rem; width: 1.2rem; text-align: center; color: var(--secondary); }
.sidebar-nav li a:hover { background: var(--bg); text-decoration: none; }
.sidebar-nav li a.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.sidebar-nav li a.active i { color: var(--primary); }
.sidebar-nav li a.text-danger { color: var(--danger); }

/* ── Layout ───────────────────────────────────────────────── */
.app-main {
  padding-top: var(--navbar-h);
  padding-bottom: calc(var(--bottom-nav-h) + .5rem);
  min-height: 100vh;
  overflow-x: hidden;
}
.page-header {
  display: flex; align-items: center; gap: .6rem;
  padding: .75rem .9rem .5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: var(--navbar-h); z-index: 100;
}
.page-title {
  font-size: 1rem; font-weight: 700; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin: 0;
}
.page-content { padding: .75rem .75rem 1rem; }

/* ── Bottom Nav ───────────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-around;
  z-index: 1020;
  padding: 0 .25rem;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; gap: 2px; color: var(--text-muted);
  font-size: 0.775rem; font-weight: 500;
  padding: .3rem 0;
  border: none; background: transparent; cursor: pointer; text-decoration: none;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item i { font-size: 1.2rem; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item:hover { color: var(--primary); text-decoration: none; }
.bottom-nav-fab {
  flex-shrink: 0;
}
.bottom-nav-fab a {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 1.4rem; box-shadow: 0 3px 10px rgba(37,99,235,.4);
  text-decoration: none; margin-bottom: 8px;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; gap: .5rem;
  padding: .65rem .9rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.card-title { font-weight: 600; font-size: 1.125rem; }
.card-body { padding: .9rem; }

/* ── Stat Grid — 2 columns on mobile, stays 2 on small phones ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .65rem .75rem;
  display: flex; align-items: center; gap: .6rem;
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0;
  /* Link styles reset - entire card is clickable */
  color: var(--text);
  text-decoration: none;
  -webkit-tap-highlight-color: rgba(37,99,235,.1);
  transition: background .12s, box-shadow .12s;
}
.stat-card:hover {
  background: var(--primary-light);
  box-shadow: 0 2px 8px rgba(37,99,235,.15);
  text-decoration: none;
  color: var(--text);
}
a.stat-card { display: flex; }
.stat-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.stat-icon.blue   { background: var(--primary-light);  color: var(--primary); }
.stat-icon.green  { background: var(--success-light);  color: var(--success); }
.stat-icon.yellow { background: var(--warning-light);  color: var(--warning); }
.stat-icon.red    { background: var(--danger-light);   color: var(--danger); }
.stat-icon.cyan   { background: var(--info-light);     color: var(--info); }
.stat-icon.purple { background: var(--purple-light);   color: var(--purple); }
.stat-value { font-size: 1.3rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: 0.85rem; color: var(--text-muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center;
  gap: .3rem; padding: .45rem .85rem; border-radius: var(--radius-sm);
  font-size: 1.062rem; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; white-space: nowrap;
  transition: all .15s; text-decoration: none; min-height: 36px; }
.btn:hover { text-decoration: none; }
.btn-sm { padding: .3rem .6rem; font-size: 0.975rem; min-height: 30px; }
.btn-primary    { background: var(--primary);  color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-success    { background: var(--success);  color: #fff; border-color: var(--success); }
.btn-warning    { background: var(--warning);  color: #fff; border-color: var(--warning); }
.btn-danger     { background: var(--danger);   color: #fff; border-color: var(--danger); }
.btn-outline-primary   { background: transparent; color: var(--primary);   border-color: var(--primary); }
.btn-outline-secondary { background: transparent; color: var(--secondary); border-color: var(--border); }
.btn-outline-success   { background: transparent; color: var(--success);   border-color: var(--success); }
.btn-outline-danger    { background: transparent; color: var(--danger);    border-color: var(--danger); }
.btn-outline-info      { background: transparent; color: var(--info);      border-color: var(--info); }
.btn-outline-primary:hover   { background: var(--primary-light); }
.btn-outline-secondary:hover { background: var(--bg); }
.btn-outline-success:hover   { background: var(--success-light); }
.btn-outline-danger:hover    { background: var(--danger-light); }
.btn-icon-sm { width: 30px; height: 30px; min-height: 30px; padding: 0; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.w-100 { width: 100%; }
.flex-1 { flex: 1; }

/* ── Forms ────────────────────────────────────────────────── */
.form-label { display: block; font-size: 1rem; font-weight: 600; margin-bottom: .3rem; color: var(--text); }
.form-control, .form-select {
  display: block; width: 100%; min-width: 0;
  padding: .5rem .7rem; font-size: 1.1rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color .15s;
  -webkit-appearance: none;
}
.form-control:focus, .form-select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-control-sm, .form-select-sm { padding: .3rem .55rem; font-size: 1rem; }
textarea.form-control { resize: vertical; min-height: 80px; }
.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); flex: 1; min-width: 0; }
.input-group-text {
  display: flex; align-items: center; padding: .5rem .7rem;
  background: var(--bg); border: 1.5px solid var(--border);
  border-right: none; border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  font-size: 1.1rem; color: var(--secondary); white-space: nowrap;
}
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: .2em .5em; font-size: 0.85rem; font-weight: 600;
  border-radius: 4px; white-space: nowrap; line-height: 1;
}
.badge-secondary { background: #e2e8f0; color: var(--secondary); }
.badge-primary   { background: var(--primary-light); color: var(--primary); }
.badge-success   { background: var(--success-light); color: var(--success); }
.badge-warning   { background: var(--warning-light); color: var(--warning); }
.badge-danger    { background: var(--danger-light);  color: var(--danger); }
.badge-info      { background: var(--info-light);    color: var(--info); }
.status-active   { background: #dcfce7; color: #166534; }
.status-prospect { background: #fef9c3; color: #854d0e; }
.status-customer { background: #dbeafe; color: #1e40af; }
.status-inactive { background: #f1f5f9; color: var(--secondary); }
.priority-low    { background: #f1f5f9; color: var(--secondary); }
.priority-medium { background: var(--info-light);    color: var(--info); }
.priority-high   { background: var(--warning-light); color: var(--warning); }
.priority-urgent { background: var(--danger-light);  color: var(--danger); }

/* ── Avatars ──────────────────────────────────────────────── */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.025rem; font-weight: 700; color: #fff;
  flex-shrink: 0; user-select: none;
}
.avatar-sm { width: 28px; height: 28px; font-size: 0.875rem; }
.avatar-lg { width: 48px; height: 48px; font-size: 1rem; }
.avatar-blue   { background: var(--primary); }
.avatar-green  { background: var(--success); }
.avatar-yellow { background: var(--warning); }
.avatar-red    { background: var(--danger); }
.avatar-purple { background: var(--purple); }
.avatar-cyan   { background: var(--info); }

/* ── Contact Cards ────────────────────────────────────────── */
.contact-card {
  display: flex; align-items: center; gap: .65rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .65rem .75rem;
  margin-bottom: .4rem; box-shadow: var(--shadow);
  overflow: hidden;
}
.contact-info { flex: 1; min-width: 0; }
.contact-name { font-weight: 600; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-company { font-size: 0.912rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem .5rem; margin-top: .2rem; }
.contact-meta span { font-size: 0.875rem; color: var(--text-muted); display: flex; align-items: center; gap: .2rem; }
.contact-actions { display: flex; gap: .3rem; flex-shrink: 0; }
.contact-actions a, .contact-actions button {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; font-size: 1.125rem;
}

/* ── Search Bar ───────────────────────────────────────────── */
.search-bar { position: relative; }
.search-bar i { position: absolute; left: .65rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 1.125rem; pointer-events: none; }
.search-bar .form-control { padding-left: 2rem; }

/* ── Tables — NO horizontal scroll ───────────────────────── */
.table-responsive { width: 100%; overflow-x: hidden; }
table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;   /* forces columns to fit */
}
table th, table td {
  padding: .45rem .5rem;
  font-size: 0.975rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: break-word;
}
table th {
  font-weight: 700; font-size: 0.875rem;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); background: var(--bg);
}
table td { white-space: normal; word-break: break-word; }
table tr:hover td { background: var(--primary-light); }
table .badge { font-size: 0.787rem; }

/* ── Tabs ─────────────────────────────────────────────────── */
.nav-tabs {
  display: flex; border-bottom: 2px solid var(--border);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  gap: 0; white-space: nowrap; flex-wrap: nowrap;
  -ms-overflow-style: none; scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tabs .nav-link {
  padding: .5rem .75rem; font-size: 1.025rem; font-weight: 500;
  color: var(--text-muted); border: none; border-bottom: 2px solid transparent;
  background: transparent; cursor: pointer; white-space: nowrap;
  margin-bottom: -2px; flex-shrink: 0;
}
.nav-tabs .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-content .tab-pane { display: none; }
.tab-content .tab-pane.show.active { display: block; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert { padding: .6rem .8rem; border-radius: var(--radius-sm); border: 1px solid transparent; font-size: 1.037rem; margin-bottom: .75rem; }
.alert-success { background: var(--success-light); border-color: #bbf7d0; color: #166534; }
.alert-danger  { background: var(--danger-light);  border-color: #fecaca; color: #991b1b; }
.alert-warning { background: var(--warning-light); border-color: #fde68a; color: #92400e; }
.alert-info    { background: var(--info-light);    border-color: #a5f3fc; color: #155e75; }

/* ── Empty States ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 2rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2.2rem; display: block; margin-bottom: .5rem; opacity: .4; }
.empty-state p { font-size: 1.062rem; margin: 0; }

/* ── Activity / Notifications ─────────────────────────────── */
.activity-item { display: flex; gap: .6rem; padding: .6rem 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1.062rem; flex-shrink: 0; }
.activity-icon.blue { background: var(--primary-light); color: var(--primary); }
.activity-content { flex: 1; min-width: 0; }
.activity-text { font-size: 1rem; line-height: 1.4; }
.activity-time { font-size: 0.875rem; color: var(--text-muted); margin-top: 1px; }
.notif-item { display: flex; gap: .65rem; padding: .65rem .9rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item.unread { background: var(--primary-light); }
.notif-text { flex: 1; min-width: 0; }
.notif-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: .35rem; }

/* ── Filter Pills ─────────────────────────────────────────── */
.filter-pills { display: flex; gap: .35rem; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; -ms-overflow-style: none; scrollbar-width: none; }
.filter-pills::-webkit-scrollbar { display: none; }
.filter-pill { flex-shrink: 0; padding: .3rem .7rem; border-radius: 20px; font-size: 0.975rem; font-weight: 500; border: 1.5px solid var(--border); background: var(--surface); color: var(--text-muted); cursor: pointer; white-space: nowrap; text-decoration: none; }
.filter-pill.active, .filter-pill:hover { background: var(--primary); border-color: var(--primary); color: #fff; text-decoration: none; }

/* ── Task Items ───────────────────────────────────────────── */
.task-item { display: flex; align-items: flex-start; gap: .6rem; padding: .65rem .75rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .4rem; }
.task-item.overdue { border-left: 3px solid var(--danger); }
.task-item.completed { opacity: .6; }
.task-title { font-size: 1.1rem; font-weight: 500; }
.task-title.done { text-decoration: line-through; color: var(--text-muted); }
.task-meta { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .25rem; }
.task-actions { flex-shrink: 0; }

/* ── Reminder Items ───────────────────────────────────────── */
.reminder-item { display: flex; gap: .6rem; align-items: flex-start; padding: .65rem .75rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .4rem; }
.reminder-item.overdue { border-left: 3px solid var(--danger); }
.reminder-item.today   { border-left: 3px solid var(--warning); }
.reminder-item.completed { opacity: .6; }

/* ── Visit Cards ──────────────────────────────────────────── */
.visit-card { display: flex; align-items: center; gap: .65rem; padding: .65rem .75rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .4rem; }
.visit-date-badge { text-align: center; background: var(--primary); color: #fff; border-radius: 8px; padding: .35rem .5rem; min-width: 42px; flex-shrink: 0; }
.vd-day { font-size: 1.1rem; font-weight: 800; line-height: 1; }
.vd-mon { font-size: 0.787rem; font-weight: 600; text-transform: uppercase; }

/* ── Note Items ───────────────────────────────────────────── */
.note-item { background: #fffef5; border: 1px solid #fde68a; border-radius: var(--radius); padding: .65rem .75rem; margin-bottom: .4rem; }
.note-content { font-size: 1.062rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.note-meta { display: flex; align-items: center; justify-content: space-between; margin-top: .35rem; font-size: 0.875rem; color: var(--text-muted); }

/* ── Geo / Map ────────────────────────────────────────────── */
.geo-info { display: flex; align-items: center; gap: .5rem; padding: .5rem .65rem; background: var(--bg); border-radius: var(--radius-sm); font-size: 1.025rem; }
.map-preview { width: 100%; height: 180px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.map-preview iframe { width: 100%; height: 100%; border: none; display: block; }

/* ── Camera/Photo Grid ────────────────────────────────────── */
.camera-preview { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; }
.camera-preview video { width: 100%; max-height: 220px; object-fit: cover; display: block; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.photo-grid-item { position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--bg); }
.photo-grid-item img { width: 100%; height: 100%; object-fit: cover; }

/* ── Doc Cards ────────────────────────────────────────────── */
.doc-card { display: flex; align-items: center; gap: .6rem; padding: .6rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .4rem; }
.doc-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.doc-icon.pdf   { background: var(--danger-light); color: var(--danger); }
.doc-icon.doc   { background: var(--primary-light); color: var(--primary); }
.doc-icon.xls   { background: var(--success-light); color: var(--success); }
.doc-icon.img   { background: var(--purple-light); color: var(--purple); }
.doc-icon.other { background: var(--bg); color: var(--secondary); }
.doc-name { font-size: 1.037rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { font-size: 0.875rem; color: var(--text-muted); }

/* ── Settings ─────────────────────────────────────────────── */
.settings-group { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.settings-row { display: flex; align-items: center; gap: .75rem; padding: .65rem .85rem; border-bottom: 1px solid var(--border); }
.settings-row:last-child { border-bottom: none; }
.settings-row-label { font-size: 0.938rem; font-weight: 600; color: var(--text-muted); width: 80px; flex-shrink: 0; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-content { border-radius: var(--radius); border: none; box-shadow: var(--shadow-md); }
.modal-header { padding: .75rem 1rem; }
.modal-body { padding: .9rem 1rem; }
.modal-footer { padding: .65rem 1rem; }
.modal-title { font-size: 1.188rem; font-weight: 700; }

/* ── Toast ────────────────────────────────────────────────── */
.toast-container { z-index: 9999; max-width: calc(100vw - 1rem); }
.toast { font-size: 1.037rem; border-radius: var(--radius-sm); min-width: 200px; max-width: min(340px, calc(100vw - 1.5rem)); }

/* ── Utilities ────────────────────────────────────────────── */
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.fs-xs  { font-size: 0.875rem; }
.fs-sm  { font-size: 1.025rem; }
.text-muted { color: var(--text-muted) !important; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-primary { color: var(--primary) !important; }
.text-warning { color: var(--warning) !important; }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.text-nowrap { white-space: nowrap; }
.overflow-hidden { overflow: hidden; }
.d-none { display: none !important; }
.d-flex { display: flex; }
.d-block { display: block; }
.d-inline { display: inline; }
.gap-1 { gap: .3rem; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.align-items-center { align-items: center; }
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.mt-4 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: .75rem; }
.mb-4 { margin-bottom: 1rem; }
.ms-1 { margin-left: .25rem; }
.ms-2 { margin-left: .5rem; }
.ms-auto { margin-left: auto; }
.me-1 { margin-right: .25rem; }
.me-2 { margin-right: .5rem; }
.p-0 { padding: 0; }
.p-2 { padding: .5rem; }
.px-3 { padding-left: .75rem; padding-right: .75rem; }
.py-2 { padding-top: .5rem; padding-bottom: .5rem; }
.py-3 { padding-top: .75rem; padding-bottom: .75rem; }
.text-center { text-align: center; }
.text-end { text-align: right; }
.border-0 { border: none !important; }
.border-bottom { border-bottom: 1px solid var(--border) !important; }
.border-top { border-top: 1px solid var(--border) !important; }
.rounded { border-radius: var(--radius-sm) !important; }
.bg-transparent { background: transparent !important; }
.w-100 { width: 100%; }
.mw-100 { max-width: 100%; }
.position-relative { position: relative; }
.position-fixed { position: fixed; }
.cursor-pointer { cursor: pointer; }
.text-decoration-none { text-decoration: none !important; }

/* ── Bootstrap Grid (minimal subset) ─────────────────────── */
.container-fluid { width: 100%; padding: 0 .75rem; }
.row { display: flex; flex-wrap: wrap; margin: 0 -.375rem; }
.row > * { padding: 0 .375rem; }
.col-4  { width: 33.333%; }
.col-6  { width: 50%; }
.col-12 { width: 100%; }
.g-2 > * { padding: .25rem; }
.g-3 > * { padding: .375rem; }

/* ── Tablet (≥576px) ──────────────────────────────────────── */
@media (min-width: 576px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .photo-grid { grid-template-columns: repeat(4, 1fr); }
  .col-sm-6 { width: 50%; }
}

/* ── Navbar logo: mobile=show, desktop=hide (sidebar has it) ─ */
.navbar-logo { display: flex; }
@media (min-width: 768px) {
  .navbar-logo { display: none; }
}

/* ── Desktop (≥768px) ─────────────────────────────────────── */
@media (min-width: 768px) {
  html, body { font-size: 16px !important; --bs-body-font-size: 16px; }
  .app-sidebar { transform: translateX(0); position: fixed; padding-top: 0; }
  .sidebar-logo { height: var(--navbar-h); }  /* logo row same height as navbar */
  .sidebar-toggle { display: none; }
  .sidebar-overlay { display: none !important; }
  .app-main { margin-left: var(--sidebar-w); padding-bottom: 1.5rem; }
  .bottom-nav { display: none; }
  .page-content { padding: 1rem 1.25rem 1.5rem; }
  .page-header { padding: .9rem 1.25rem .6rem; top: 0; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); gap: .75rem; }
  .photo-grid { grid-template-columns: repeat(5, 1fr); }
}

@media (min-width: 1200px) {
  .stat-grid { grid-template-columns: repeat(6, 1fr); }
}

/* ── Report tables — allow smaller text to fit ────────────── */
.report-table th, .report-table td {
  font-size: 0.9rem; padding: .35rem .4rem;
}

/* ── Dropdown (Bootstrap compat) ─────────────────────────── */
.dropdown-menu {
  min-width: 160px; font-size: 1.062rem;
  border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); padding: .35rem 0;
}
.dropdown-item { padding: .45rem .9rem; font-size: 1.062rem; }
.dropdown-header { font-size: 0.938rem; font-weight: 600; padding: .3rem .9rem; color: var(--text-muted); }
.dropdown-divider { border-top: 1px solid var(--border); margin: .25rem 0; }

/* ── Bootstrap modal size fix on mobile ──────────────────── */
@media (max-width: 575px) {
  .modal-dialog { margin: .5rem; }
  .modal-dialog-centered { align-items: flex-end; min-height: calc(100% - 1rem); }
  .modal-content { border-radius: var(--radius) var(--radius) 0 0; }
}

/* ── Empty space fix: page-header is NOT sticky inside main ── */
.app-main { padding-top: var(--navbar-h); }
.page-header { position: static; }   /* remove sticky - was causing double gap */

/* ── Header icon buttons (contacts page) ─────────────────── */
.hdr-icon-btn {
  width:34px;height:34px;display:flex;align-items:center;justify-content:center;
  border-radius:8px;font-size:1rem;color:var(--secondary);
  background:var(--bg);border:1px solid var(--border);text-decoration:none;
  flex-shrink:0;
}
.hdr-icon-btn:hover,.hdr-icon-active{background:var(--primary-light);color:var(--primary);border-color:var(--primary);}
.hdr-icon-primary{background:var(--primary);color:#fff;border-color:var(--primary);}
.hdr-icon-primary:hover{background:var(--primary-dark);color:#fff;}

/* ── Filter active bar ────────────────────────────────────── */
.filter-active-bar{
  background:var(--primary-light);color:var(--primary);
  font-size: 0.938rem;font-weight:600;padding:.3rem .6rem;
  border-radius:var(--radius-sm);border:1px solid #bfdbfe;
}

/* ── Contact list row (no card, just a slim row) ─────────── */
.clist-row {
  display:flex;align-items:center;gap:.55rem;
  padding:.55rem .4rem;
  border-bottom:1px solid var(--border);
  background:var(--surface);
}
.clist-row:first-of-type{border-radius:var(--radius) var(--radius) 0 0;}
.clist-row:last-of-type{border-radius:0 0 var(--radius) var(--radius);border-bottom:none;}
.clist-row:hover{background:var(--primary-light);}

/* ── Contact action buttons (icon-only, tight) ───────────── */
.cact-btn {
  width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;
  border-radius:6px;font-size: 1.025rem;border:1px solid var(--border);
  background:var(--bg);color:var(--secondary);cursor:pointer;
  text-decoration:none;flex-shrink:0;transition:all .12s;
  padding:0;
}
.cact-btn:hover{text-decoration:none;}
.cact-green{color:var(--success);border-color:var(--success);background:var(--success-light);}
.cact-blue {color:var(--primary);border-color:var(--primary);background:var(--primary-light);}
.cact-red  {color:var(--danger); border-color:var(--danger); background:var(--danger-light);}

/* ── Workspace tabs (custom, no Bootstrap tab JS needed) ─── */
.ws-tab {
  display:inline-block;padding:.5rem .7rem;font-size: 1rem;font-weight:500;
  color:var(--text-muted);text-decoration:none;white-space:nowrap;
  border-bottom:2px solid transparent;cursor:pointer;
}
.ws-tab.active{color:var(--primary);border-bottom-color:var(--primary);font-weight:600;}
.ws-tab:hover{color:var(--primary);text-decoration:none;}
.ws-cnt{
  display:inline-flex;align-items:center;justify-content:center;
  min-width:16px;height:16px;border-radius:8px;
  background:var(--border);color:var(--secondary);
  font-size: 0.775rem;font-weight:700;padding:0 3px;vertical-align:middle;
}
.ws-pane{width:100%;}

/* ── Workspace info table ─────────────────────────────────── */
.ws-info-table{border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;}
.ws-info-row{display:flex;align-items:flex-start;gap:.5rem;padding:.45rem .65rem;border-bottom:1px solid var(--border);font-size: 1rem;}
.ws-info-row:last-child{border-bottom:none;}
.ws-info-row>span:first-child{width:56px;flex-shrink:0;color:var(--text-muted);font-size: 0.9rem;font-weight:600;padding-top:1px;}
.ws-info-row>span:last-child{flex:1;min-width:0;word-break:break-word;}

/* ── Workspace note ───────────────────────────────────────── */
.ws-note{background:#fffef5;border:1px solid #fde68a;border-radius:var(--radius-sm);padding:.55rem .65rem;margin-bottom:.4rem;}

/* ── Workspace task ───────────────────────────────────────── */
.ws-task{display:flex;align-items:center;gap:.5rem;padding:.55rem .65rem;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-sm);margin-bottom:.35rem;}
.ws-overdue{border-left:3px solid var(--danger);}
.ws-done{opacity:.6;}

/* ── Workspace reminder ───────────────────────────────────── */
.ws-reminder{display:flex;align-items:flex-start;gap:.5rem;padding:.55rem .65rem;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-sm);margin-bottom:.35rem;}

/* ── Workspace visit ──────────────────────────────────────── */
.ws-visit{display:flex;align-items:center;gap:.55rem;padding:.55rem .65rem;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-sm);margin-bottom:.35rem;}

/* ── Global mobile-only rules ─────────────────────────────── */
@media (max-width:575px){
  html{font-size:16px;}
  body{font-size:16px !important;}
  .page-content{padding:.5rem .5rem 1rem;}
  .page-header{padding:.5rem .6rem;}
  .card-body{padding:.65rem;}
  .modal-body{padding:.75rem;}
  .stat-value{font-size:1.2rem;}
  .stat-label{font-size: 0.812rem;}
}





/* ── Header icon buttons ──────────────────────────────────── */
.ic-btn {
  width:28px;height:28px;display:flex;align-items:center;justify-content:center;
  border-radius:6px;font-size: 1.062rem;text-decoration:none;
  border:1px solid var(--border);background:var(--bg);color:var(--secondary);flex-shrink:0;
}
.ic-btn:hover,.ic-btn-on{background:var(--primary-light);color:var(--primary);border-color:var(--primary);text-decoration:none;}
.ic-btn-primary{background:var(--primary);color:#fff;border-color:var(--primary);}
.ic-btn-primary:hover{background:var(--primary-dark);color:#fff;text-decoration:none;}

/* ── Contact row icon buttons (.ci) ──────────────────────── */
/* 22px, no bg, just colored icon — enterprise/minimal style */
.ci {
  width:22px;height:22px;display:inline-flex;align-items:center;justify-content:center;
  font-size: 0.975rem;text-decoration:none;border:none;background:transparent;
  cursor:pointer;border-radius:4px;flex-shrink:0;opacity:.75;
  transition:opacity .1s,background .1s;padding:0;
}
.ci:hover{opacity:1;background:var(--bg);text-decoration:none;}

/* ── Workspace action bar ─────────────────────────────────── */
.ws-action-btn{
  flex:1;display:flex;flex-direction:column;align-items:center;
  padding:.4rem .1rem;font-size: 0.775rem;font-weight:600;
  color:var(--text-muted);text-decoration:none;gap:2px;
  border-left:1px solid var(--border);
}
.ws-action-btn:first-child{border-left:none;}
.ws-action-btn i{font-size: 1.125rem;}
.ws-action-btn:hover{background:var(--bg);text-decoration:none;}
