/* ============================================================
   نظام التفتيش الصحي — Design System
   Teal / medical palette · Cairo · Mobile-first · RTL
   ============================================================ */

:root {
  /* Brand — teal / medical */
  --primary-50:  #E8F6F6;
  --primary-100: #C9ECEC;
  --primary-200: #9BDADB;
  --primary-300: #5FC2C4;
  --primary-400: #2BA6AA;
  --primary-500: #128B91;
  --primary-600: #0E7C86;   /* main */
  --primary-700: #0B626B;
  --primary-800: #0A4F57;
  --primary-900: #093E45;

  --accent-400: #2DD4BF;
  --accent-500: #14B8A6;

  /* Semantic */
  --danger:     #DC2626;
  --danger-600: #C81E1E;
  --danger-bg:  #FEF1F1;
  --danger-bd:  #F8D4D4;

  --warning:     #C2700A;
  --warning-600: #B45309;
  --warning-bg:  #FEF6E7;
  --warning-bd:  #F6E0B8;

  --success:     #0E9F6E;
  --success-600: #057A55;
  --success-bg:  #E7F8F0;
  --success-bd:  #BCEBD6;

  --info-bg:     #EAF1FB;
  --info:        #2563EB;

  /* Neutral ink (cool, slight teal) */
  --ink:    #0C2A2D;
  --ink-2:  #3B5054;
  --ink-3:  #6B8084;
  --ink-4:  #9CADB0;

  /* Surfaces */
  --bg:      #F4F7F8;
  --bg-2:    #EEF3F4;
  --surface: #FFFFFF;
  --surface-2: #F8FAFB;

  /* Borders */
  --border:   #E6ECED;
  --border-2: #DCE4E5;
  --border-strong: #CBD6D8;

  /* Radii */
  --r-xs: 8px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 22px;
  --r-2xl: 28px;
  --r-full: 999px;

  /* Shadows — very light */
  /* Shadows — soft, layered (Linear/Stripe-grade) */
  --sh-xs: 0 1px 1.5px rgba(12,42,45,.05);
  --sh-sm: 0 1px 2px rgba(12,42,45,.04), 0 2px 5px rgba(12,42,45,.035);
  --sh-md: 0 1px 2px rgba(12,42,45,.04), 0 4px 10px rgba(12,42,45,.045), 0 12px 26px rgba(12,42,45,.05);
  --sh-lg: 0 2px 6px rgba(12,42,45,.05), 0 10px 24px rgba(12,42,45,.08), 0 26px 52px rgba(12,42,45,.10);
  --sh-primary: 0 3px 8px rgba(14,124,134,.22), 0 10px 22px rgba(14,124,134,.20);
  --sh-focus: 0 0 0 4px rgba(20,139,145,.18);

  /* Spacing scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;

  /* Type */
  --font: 'Cairo', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

.hi-app {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
  height: 100%;
  font-feature-settings: 'ss01';
}

.hi-app *::-webkit-scrollbar { width: 0; height: 0; }

/* ---------- App shell (inside phone) ---------- */
.app-shell {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}
.app-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.app-scroll::-webkit-scrollbar { width: 0; }

/* page enter animation */
@keyframes pageIn {
  from { transform: translateY(10px); }
  to   { transform: translateY(0); }
}
.page { animation: pageIn .34s cubic-bezier(.22,.61,.36,1) both; }

@keyframes riseIn {
  from { transform: translateY(12px); }
  to   { transform: translateY(0); }
}
.rise { animation: riseIn .5s cubic-bezier(.22,.61,.36,1) both; }

/* ---------- Top header ---------- */
.app-header {
  flex-shrink: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.app-header.flush { padding-bottom: 14px; }
.hdr-row { display: flex; align-items: center; gap: 12px; }
.hdr-brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(150deg, var(--primary-500), var(--primary-700));
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--sh-primary);
}
.brand-text { min-width: 0; }
.brand-text h1 { margin: 0; font-size: 14.5px; font-weight: 800; letter-spacing: -.2px; line-height: 1.25; color: var(--ink); }
.brand-text p { margin: 1px 0 0; font-size: 11px; font-weight: 600; color: var(--ink-3); }

.hdr-icon-btn {
  width: 40px; height: 40px; border-radius: var(--r-full);
  border: 1px solid var(--border); background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  position: relative; flex-shrink: 0; cursor: pointer;
  transition: background .15s, transform .1s;
}
.hdr-icon-btn:active { transform: scale(.92); background: var(--bg-2); }
.hdr-dot {
  position: absolute; top: 7px; inset-inline-end: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); border: 2px solid var(--surface);
}

.avatar {
  width: 40px; height: 40px; border-radius: var(--r-full); flex-shrink: 0;
  background: linear-gradient(140deg, var(--accent-400), var(--primary-600));
  color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: var(--sh-xs);
}

/* search field */
.search {
  display: flex; align-items: center; gap: 9px;
  height: 44px; padding: 0 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-full); color: var(--ink-3);
  cursor: text; transition: border-color .15s, background .15s;
}
.search:focus-within { border-color: var(--primary-300); background: #fff; }
.search input {
  border: 0; outline: 0; background: transparent; flex: 1;
  font-family: var(--font); font-size: 14px; font-weight: 600; color: var(--ink);
}
.search input::placeholder { color: var(--ink-4); font-weight: 600; }

/* role pill */
.role-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: var(--r-full);
  background: var(--primary-50); color: var(--primary-700);
  font-size: 11.5px; font-weight: 700;
}

/* ---------- Section / titles ---------- */
.sec-title { font-size: 16px; font-weight: 800; color: var(--ink); letter-spacing: -.2px; margin: 0; }
.sec-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; }
.sec-link { font-size: 12.5px; font-weight: 700; color: var(--primary-600); cursor: pointer; display: inline-flex; align-items: center; gap: 3px; }
.page-pad { padding: 18px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-sm);
}
.card-pad { padding: 16px; }

/* ---------- Stat cards (tinted, hierarchical) ---------- */
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px; box-shadow: 0 1px 2px rgba(12,42,45,.04), 0 4px 14px rgba(12,42,45,.05);
  display: flex; flex-direction: column; gap: 12px; position: relative; overflow: hidden;
  transition: transform .16s cubic-bezier(.22,.61,.36,1), box-shadow .22s;
}
/* subtle top sheen for depth */
.stat::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,.5), transparent);
  pointer-events: none;
}
.stat > * { position: relative; }
.stat.t-teal   { background: var(--primary-50);  border-color: var(--primary-100); }
.stat.t-red    { background: var(--danger-bg);   border-color: var(--danger-bd); }
.stat.t-amber  { background: var(--warning-bg);  border-color: var(--warning-bd); }
.stat.t-green  { background: var(--success-bg);  border-color: var(--success-bd); }
.stat.t-violet { background: #F4F1FC;            border-color: #E6DEFA; }

.stat--hero { padding: 18px; gap: 13px; }
.stat--compact { padding: 13px 13px 14px; gap: 9px; }

.stat-head { display: flex; align-items: center; justify-content: space-between; }
.stat-ico {
  width: 38px; height: 38px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  box-shadow: var(--sh-xs);
}
.stat-ico-sm { width: 32px; height: 32px; border-radius: 9px; box-shadow: var(--sh-xs); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-val { font-size: 28px; font-weight: 800; line-height: 1; letter-spacing: -.6px; color: var(--ink); }
.stat-val-lg { font-size: 36px; font-weight: 800; line-height: .95; letter-spacing: -1.2px; color: var(--ink); }
.stat-val-sm { font-size: 23px; font-weight: 800; line-height: 1; letter-spacing: -.6px; color: var(--ink); }
.stat-lbl { font-size: 12px; font-weight: 600; color: var(--ink-3); }
.stat-lbl-sm { font-size: 11.5px; font-weight: 600; color: var(--ink-3); line-height: 1.3; }

/* trend pill — semantic */
.trend-pill {
  display: inline-flex; align-items: center; gap: 3px;
  height: 23px; padding: 0 8px; border-radius: var(--r-full);
  font-size: 12px; font-weight: 800; letter-spacing: -.2px; flex-shrink: 0;
}
.trend-pill.up   { background: rgba(14,159,110,.13); color: var(--success-600); }
.trend-pill.down { background: rgba(220,38,38,.11);  color: var(--danger); }
.trend-mini { display: inline-flex; align-items: center; gap: 2px; font-size: 11px; font-weight: 800; }
.trend-mini.up { color: var(--success-600); } .trend-mini.down { color: var(--danger); }
/* classic inline trend (legacy dashboard) */
.stat-trend { font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; gap: 3px; }
.trend-up { color: var(--success-600); }
.trend-down { color: var(--danger); }

/* sparkline */
.spark { display: flex; align-items: flex-end; gap: 4px; height: 36px; margin-top: 2px; }
.spark i {
  flex: 1; border-radius: 3px 3px 1.5px 1.5px; min-height: 5px;
  background: linear-gradient(180deg, var(--primary-300), var(--primary-600));
  transition: height .6s cubic-bezier(.22,.61,.36,1);
}
.spark i.last { background: linear-gradient(180deg, var(--primary-500), var(--primary-700)); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px; border-radius: var(--r-full);
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-danger  { background: var(--danger-bg);  color: var(--danger-600); }
.b-warning { background: var(--warning-bg); color: var(--warning-600); }
.b-success { background: var(--success-bg); color: var(--success-600); }
.b-primary { background: var(--primary-50); color: var(--primary-700); }
.b-neutral { background: var(--bg-2); color: var(--ink-2); }
.b-info    { background: var(--info-bg); color: var(--info); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 18px; border-radius: var(--r-md);
  font-family: var(--font); font-size: 15px; font-weight: 700;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: transform .12s, background .15s, box-shadow .15s; user-select: none;
}
.btn:active { transform: scale(.97); }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary-600); color: #fff; box-shadow: var(--sh-primary); }
.btn-primary:active { background: var(--primary-700); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--border-2); }
.btn-soft { background: var(--primary-50); color: var(--primary-700); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { height: 40px; font-size: 13.5px; padding: 0 14px; }
.btn-icon-only { width: 48px; padding: 0; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field-lbl { font-size: 13px; font-weight: 700; color: var(--ink-2); display: flex; align-items: center; gap: 5px; }
.field-lbl .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; min-height: 50px; padding: 0 14px;
  font-family: var(--font); font-size: 15px; font-weight: 600; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--border-2);
  border-radius: var(--r-md); outline: none;
  transition: border-color .15s, box-shadow .15s; appearance: none;
}
.textarea { min-height: 96px; padding: 12px 14px; resize: none; line-height: 1.6; }
.input::placeholder, .textarea::placeholder { color: var(--ink-4); font-weight: 600; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary-400); box-shadow: 0 0 0 4px rgba(20,139,145,.12); }
.select-wrap { position: relative; }
.select-wrap .chev { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--ink-3); }
.select { padding-inline-start: 38px; cursor: pointer; }
.field-hint { font-size: 11.5px; font-weight: 600; color: var(--ink-4); }

/* segmented yes/no etc */
.segmented { display: flex; gap: 6px; background: var(--bg-2); padding: 4px; border-radius: var(--r-md); }
.segmented button {
  flex: 1; height: 42px; border: 0; background: transparent; cursor: pointer;
  font-family: var(--font); font-size: 14px; font-weight: 700; color: var(--ink-2);
  border-radius: 10px; transition: all .18s; display: flex; align-items: center; justify-content: center; gap: 6px;
}
.segmented button.on { background: var(--surface); color: var(--primary-700); box-shadow: var(--sh-xs); }
.segmented button.on.yes { color: var(--success-600); }
.segmented button.on.no { color: var(--danger-600); }

/* rating chips (ممتاز/جيد/ضعيف) */
.chips { display: flex; gap: 8px; }
.chip {
  flex: 1; height: 44px; border-radius: var(--r-md); cursor: pointer;
  border: 1.5px solid var(--border-2); background: var(--surface);
  font-family: var(--font); font-size: 13.5px; font-weight: 700; color: var(--ink-2);
  display: flex; align-items: center; justify-content: center; transition: all .16s;
}
.chip.on { border-color: var(--primary-500); background: var(--primary-50); color: var(--primary-700); }

/* ---------- Bottom navigation ---------- */
.bottom-nav {
  flex-shrink: 0; position: relative; z-index: 30;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border-top: 1px solid var(--border);
  padding: 8px 10px 26px;
  display: flex; align-items: flex-end; justify-content: space-around;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: 0; cursor: pointer; padding: 6px 0;
  color: var(--ink-4); font-family: var(--font); font-size: 10.5px; font-weight: 700;
  transition: color .15s; min-height: 48px; justify-content: center;
}
.nav-item.on { color: var(--primary-600); }
.nav-item .ico { transition: transform .2s; }
.nav-item.on .ico { transform: translateY(-1px); }
.nav-fab {
  width: 58px; height: 58px; border-radius: 20px; margin-top: -26px; flex-shrink: 0;
  background: linear-gradient(150deg, var(--primary-500), var(--primary-700));
  color: #fff; border: 4px solid var(--surface); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--sh-primary); transition: transform .14s;
}
.nav-fab:active { transform: scale(.92); }
.nav-fab-wrap { flex: 1; display: flex; justify-content: center; }

/* ---------- Visit / list cards ---------- */
.list-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 14px; box-shadow: var(--sh-sm);
  cursor: pointer; transition: transform .12s, box-shadow .15s, border-color .15s;
}
.list-card:active { transform: scale(.985); box-shadow: var(--sh-md); }
.lc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.lc-title { font-size: 15px; font-weight: 800; color: var(--ink); letter-spacing: -.2px; }
.lc-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.lc-meta span { font-size: 12px; font-weight: 600; color: var(--ink-3); display: inline-flex; align-items: center; gap: 4px; }
.lc-divider { height: 1px; background: var(--border); margin: 12px -14px; }
.lc-foot { display: flex; align-items: center; justify-content: space-between; }

.type-tag {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: var(--r-sm); font-size: 11px; font-weight: 700;
}
.tt-clinic { background: var(--primary-50); color: var(--primary-700); }
.tt-lab { background: #F1EEFB; color: #6D49C9; }

/* ---------- Charts ---------- */
.bars { display: flex; align-items: flex-end; gap: 9px; height: 130px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%; max-width: 26px; border-radius: 7px 7px 4px 4px;
  background: linear-gradient(180deg, var(--primary-400), var(--primary-600));
  transition: height .6s cubic-bezier(.22,.61,.36,1);
}
.bar.muted { background: var(--primary-100); }
.bar-lbl { font-size: 10.5px; font-weight: 700; color: var(--ink-4); }

.legend { display: flex; flex-direction: column; gap: 11px; }
.legend-item { display: flex; align-items: center; gap: 9px; }
.legend-dot { width: 11px; height: 11px; border-radius: 4px; flex-shrink: 0; }
.legend-txt { font-size: 12.5px; font-weight: 600; color: var(--ink-2); flex: 1; }
.legend-val { font-size: 13px; font-weight: 800; color: var(--ink); }

/* ---------- Wizard / steps ---------- */
.steps { display: flex; align-items: center; gap: 0; padding: 4px 0 24px; }
.step-node { position: relative; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step-bullet {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; transition: all .25s;
  border: 2px solid var(--border-2); background: var(--surface); color: var(--ink-4);
}
.step-bullet.active { border-color: var(--primary-600); background: var(--primary-600); color: #fff; box-shadow: var(--sh-primary); }
.step-bullet.done { border-color: var(--primary-600); background: var(--primary-50); color: var(--primary-700); }
/* labels float centered under each bullet so they never stretch the node (even spacing) */
.step-lbl { position: absolute; top: calc(100% + 7px); left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 10px; font-weight: 700; color: var(--ink-4); }
.step-lbl.active { color: var(--primary-700); }
.step-line { flex: 1; height: 2px; background: var(--border-2); margin: 0 6px; border-radius: 2px; transition: background .3s; }
.step-line.done { background: var(--primary-500); }

/* progress bar */
.prog-track { height: 6px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.prog-fill { height: 100%; background: linear-gradient(90deg, var(--primary-500), var(--accent-500)); border-radius: 99px; transition: width .4s ease; }

/* collapsible */
.collapse {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-sm); overflow: hidden;
}
.collapse-head {
  display: flex; align-items: center; gap: 12px; padding: 15px 16px; cursor: pointer;
  width: 100%; border: 0; background: var(--surface); font-family: var(--font); text-align: start;
}
.collapse-head .c-ico { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.collapse-head .c-title { flex: 1; }
.collapse-head .c-title b { display: block; font-size: 14.5px; font-weight: 800; color: var(--ink); }
.collapse-head .c-title small { font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.collapse-chev { color: var(--ink-3); transition: transform .28s; }
.collapse.open .collapse-chev { transform: rotate(180deg); }
.collapse-body { padding: 0 16px; max-height: 0; overflow: hidden; transition: max-height .35s ease, padding .35s ease; }
.collapse.open .collapse-body { padding: 4px 16px 18px; max-height: 1400px; }

/* attachments */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--r-lg);
  padding: 22px 16px; text-align: center; background: var(--surface-2);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.cam-btn {
  width: 100%; height: 56px; border-radius: var(--r-md);
  background: var(--primary-600); color: #fff; border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--font); font-size: 15px; font-weight: 700; box-shadow: var(--sh-primary);
}
.thumb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumb {
  aspect-ratio: 1; border-radius: var(--r-md); position: relative; overflow: hidden;
  background: var(--bg-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.thumb .x { position: absolute; top: 5px; inset-inline-end: 5px; width: 22px; height: 22px; border-radius: 50%; background: rgba(12,42,45,.6); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }

/* sticky save bar */
.save-bar {
  flex-shrink: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.94); backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border); display: flex; gap: 10px;
}

/* doctor row */
.doc-row { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); }
.doc-av { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-100); color: var(--primary-700); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* flag note for violation-generating items */
.flag-note { display: flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 700; color: var(--warning-600); background: var(--warning-bg); border: 1px solid var(--warning-bd); border-radius: 9px; padding: 7px 10px; }

/* conditional reveal */
@keyframes revealDown { from { transform: translateY(-5px); } to { transform: translateY(0); } }
.conditional { animation: revealDown .3s ease both; }

/* timeline */
.tl { position: relative; padding-inline-start: 8px; }
.tl-item { position: relative; padding-inline-start: 24px; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ''; position: absolute; inset-inline-start: 4px; top: 16px; bottom: -2px; width: 2px; background: var(--border-2); }
.tl-item:last-child::before { display: none; }
.tl-dot { position: absolute; inset-inline-start: 0; top: 3px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--surface); z-index: 1; }

/* filter chips row */
.filter-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.filter-chip {
  flex-shrink: 0; height: 36px; padding: 0 14px; border-radius: var(--r-full);
  border: 1px solid var(--border-2); background: var(--surface); cursor: pointer;
  font-family: var(--font); font-size: 13px; font-weight: 700; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px; transition: all .15s;
}
.filter-chip.on { background: var(--primary-600); color: #fff; border-color: var(--primary-600); }
.filter-chip .cnt { font-size: 11px; opacity: .7; }

/* bottom sheet */
.sheet-backdrop {
  position: absolute; inset: 0; z-index: 80; background: rgba(12,42,45,.4);
  backdrop-filter: blur(2px); display: flex; align-items: flex-end;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet {
  width: 100%; background: var(--surface); border-radius: 26px 26px 0 0;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
  animation: sheetUp .3s cubic-bezier(.22,.61,.36,1); max-height: 80%; overflow-y: auto;
}
.sheet-grip { width: 40px; height: 5px; border-radius: 99px; background: var(--border-strong); margin: 0 auto 14px; }

/* empty state */
.empty { text-align: center; padding: 40px 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-ico { width: 64px; height: 64px; border-radius: 20px; background: var(--bg-2); display: flex; align-items: center; justify-content: center; color: var(--ink-4); }

/* misc utils */
.row { display: flex; align-items: center; }
.gap6 { gap: 6px; } .gap8 { gap: 8px; } .gap10 { gap: 10px; } .gap12 { gap: 12px; }
.col { display: flex; flex-direction: column; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 16px; }
.mut { color: var(--ink-3); }
.tnum { font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: var(--border); }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* ============================================================
   Premium layer — interaction states, skeletons, tooltips
   ============================================================ */

/* press feedback (touch) */
.list-card { transition: transform .15s cubic-bezier(.22,.61,.36,1), box-shadow .22s, border-color .15s; }
.stat:active { transform: scale(.99); }

/* hover (desktop / fine pointer) */
@media (hover: hover) and (pointer: fine) {
  .list-card:hover { box-shadow: var(--sh-md); border-color: var(--border-strong); transform: translateY(-2px); }
  .stat:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }
  .hdr-icon-btn:hover { background: var(--bg-2); border-color: var(--border-strong); }
  .filter-chip:hover:not(.on) { border-color: var(--border-strong); background: var(--surface-2); }
  .nav-item:hover:not(.on) { color: var(--primary-500); }
  .nav-fab:hover { filter: brightness(1.05); box-shadow: 0 8px 22px rgba(14,124,134,.4); }
  .btn-primary:hover { filter: brightness(1.05); }
  .btn-ghost:hover, .btn-soft:hover { background: var(--surface-2); }
  .chip:hover:not(.on) { border-color: var(--primary-300); }
  .collapse-head:hover { background: var(--surface-2); }
  .sec-link:hover { color: var(--primary-700); }
  .bar-col:hover .bar { filter: brightness(1.06); }
  .stat-link:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }
}

/* focus-visible rings — consistent across the system */
.btn:focus-visible, .filter-chip:focus-visible, .nav-item:focus-visible,
.list-card:focus-visible, .chip:focus-visible, .hdr-icon-btn:focus-visible,
.segmented button:focus-visible, .collapse-head:focus-visible, .stat:focus-visible {
  outline: none; box-shadow: var(--sh-focus);
}
.list-card:focus-visible { box-shadow: var(--sh-focus), var(--sh-sm); }

/* ---------- Skeleton loaders ---------- */
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.sk {
  background: linear-gradient(90deg, var(--bg-2) 25%, #E8EFF0 38%, var(--bg-2) 55%);
  background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 8px; display: block;
}
.sk-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px; box-shadow: var(--sh-sm); }
.sk-line { height: 12px; }
.sk-circle { border-radius: 50%; }

/* ---------- Chart tooltip ---------- */
.chart-wrap { position: relative; }
.chart-tip {
  position: absolute; transform: translate(50%, -100%); z-index: 6;
  background: var(--ink); color: #fff; font-size: 11.5px; font-weight: 800;
  padding: 6px 9px; border-radius: 9px; white-space: nowrap; pointer-events: none;
  box-shadow: var(--sh-md); letter-spacing: -.2px;
}
.chart-tip small { display: block; font-size: 9.5px; font-weight: 700; opacity: .65; margin-bottom: 1px; }
.chart-tip::after {
  content: ''; position: absolute; right: 50%; top: 100%; transform: translateX(50%);
  border: 5px solid transparent; border-top-color: var(--ink);
}
.bar-col { cursor: pointer; }
.bar-col .bar { transition: height .6s cubic-bezier(.22,.61,.36,1), filter .15s; }
.bar-col.sel .bar { filter: brightness(1.1); }
.bar-col.sel .bar-lbl { color: var(--primary-700); }
.donut-seg { cursor: pointer; transition: stroke-width .18s, opacity .18s; }
.donut-seg.dim { opacity: .35; }

/* ---------- Empty state illustration ---------- */
.empty { text-align: center; padding: 38px 24px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.empty-art { width: 116px; height: 96px; position: relative; margin-bottom: 2px; }

/* card link (whole stat clickable) */
.stat-link { cursor: pointer; text-align: start; font-family: var(--font); transition: transform .16s, box-shadow .22s; }

/* ---------- Google Maps location picker ---------- */
.map-pick {
  position: relative; height: 150px; border-radius: 14px; overflow: hidden;
  cursor: pointer; border: 1.5px solid var(--border-2); box-shadow: var(--sh-xs);
  transition: box-shadow .2s, border-color .15s, transform .12s;
}
.map-pick:active { transform: scale(.99); }
.map-pick:hover { border-color: var(--primary-300); box-shadow: var(--sh-sm); }
.map-canvas {
  position: absolute; inset: 0; background-color: #E7EFE8;
  background-image:
    linear-gradient(0deg, rgba(110,135,118,.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110,135,118,.16) 1px, transparent 1px),
    linear-gradient(0deg, rgba(110,135,118,.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(110,135,118,.09) 1px, transparent 1px);
  background-size: 30px 30px, 30px 30px, 90px 90px, 90px 90px;
}
.map-canvas::before { content: ''; position: absolute; left: -10%; right: -10%; top: 56%; height: 10px; background: #fff; opacity: .9; transform: rotate(-5deg); box-shadow: 0 0 0 1px rgba(110,135,118,.12); }
.map-canvas::after  { content: ''; position: absolute; top: 0; bottom: 0; left: 36%; width: 9px; background: #fff; opacity: .85; box-shadow: 0 0 0 1px rgba(110,135,118,.12); }
.map-pin { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -100%); z-index: 2; filter: drop-shadow(0 5px 6px rgba(12,42,45,.32)); }
.map-overlay { position: absolute; left: 0; right: 0; bottom: 0; padding: 11px 12px; display: flex; justify-content: center; background: linear-gradient(0deg, rgba(255,255,255,.96), rgba(255,255,255,0)); }
.map-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 800; color: var(--primary-700); background: #fff; border: 1px solid var(--border); padding: 8px 13px; border-radius: var(--r-full); box-shadow: var(--sh-sm); }
.map-tag.muted { color: var(--ink-2); }

/* ---------- Toggle switch ---------- */
.switch { width: 46px; height: 27px; border-radius: 99px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .2s; flex-shrink: 0; border: 0; padding: 0; }
.switch.on { background: var(--primary-600); }
.switch::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; transition: inset-inline-start .22s; box-shadow: var(--sh-xs); }
.switch.on::after { inset-inline-start: 22px; }
