/* ============================================================
   MAMAQAY · App shell styles
   Layered on top of styles.css
   ============================================================ */

body.app-body {
  background: var(--c-paper);
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ----- App top bar (mobile only) ----- */
.app-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--c-line);
  background: var(--c-paper);
  gap: .75rem;
}
.app-top__brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  line-height: 0;
}
.app-top__brand img {
  height: 34px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  display: block;
}
.app-top__menu {
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--c-paper-2);
}
.demo-badge {
  font-family: var(--f-mono);
  font-size: var(--s-1);
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: .25rem .55rem;
  background: var(--c-clay);
  color: var(--c-white);
  border-radius: var(--r-full);
}
@media (min-width: 900px) {
  .app-top { display: none; }
  .app { grid-template-columns: 280px 1fr; grid-template-rows: 1fr; }
}

/* ----- Sidebar ----- */
.app-side {
  background: var(--c-ink);
  color: var(--c-paper);
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: fixed;
  inset: 0;
  z-index: 70;
  width: min(80%, 320px);
  transform: translateX(-100%);
  transition: transform var(--t-base) var(--ease);
}
.app-side.open { transform: translateX(0); }
@media (min-width: 900px) {
  .app-side {
    position: static;
    width: auto;
    transform: none;
  }
}
.app-side__brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(247, 243, 235, .12);
}
.app-side__brand img {
  height: 44px;
  width: auto;
  max-width: 180px;
  object-fit: contain;
  display: block;
  /* Invert the logo on dark sidebar so the dark teal text becomes legible */
  filter: brightness(0) invert(1);
}
.app-side__brand span {
  font-family: var(--f-display);
  font-size: var(--s-5);
}
.app-side__nav { display: grid; gap: .25rem; }
.nav-link {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .85rem 1rem;
  border-radius: var(--r-md);
  font-size: var(--s-3);
  color: rgba(247, 243, 235, .75);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  cursor: pointer;
}
.nav-link:hover { background: rgba(247, 243, 235, .08); color: var(--c-paper); }
.nav-link.active {
  background: var(--c-clay);
  color: var(--c-white);
}
.nav-link svg { width: 20px; height: 20px; flex-shrink: 0; }
.app-side__footer {
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(247, 243, 235, .12);
  font-size: var(--s-1);
  color: rgba(247, 243, 235, .55);
  line-height: 1.5;
}
.app-side__back-link {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: var(--s-2);
  color: rgba(247, 243, 235, .65);
  margin-bottom: .5rem;
}
.app-side__back-link:hover { color: var(--c-clay); }

/* Mobile backdrop */
.app-side-backdrop {
  position: fixed;
  inset: 0;
  z-index: 65;
  background: rgba(12, 17, 22, .5);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base) var(--ease);
}
.app-side-backdrop.open { opacity: 1; pointer-events: auto; }
@media (min-width: 900px) { .app-side-backdrop { display: none; } }

/* ----- Main content ----- */
.app-main {
  overflow-y: auto;
  background: var(--c-paper);
}
.app-main::-webkit-scrollbar { width: 6px; }
.app-main::-webkit-scrollbar-thumb { background: var(--c-line-2); border-radius: 3px; }

.app-content {
  max-width: 1100px;
  margin-inline: auto;
  padding: clamp(1.25rem, 3vw, 2.5rem);
}

.app-page__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}
.app-page__title {
  font-family: var(--f-display);
  font-size: var(--s-7);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -.015em;
}
.app-page__subtitle {
  color: var(--c-mute);
  font-size: var(--s-3);
  margin-top: .5rem;
  max-width: 60ch;
}
.app-page__actions { display: flex; gap: .65rem; flex-wrap: wrap; }

/* ----- KPI grid ----- */
.kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi {
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  display: grid;
  gap: .5rem;
  position: relative;
  overflow: hidden;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi__label {
  font-size: var(--s-1);
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--c-mute);
  font-family: var(--f-mono);
}
.kpi__num {
  font-family: var(--f-display);
  font-size: clamp(2rem, 1.5rem + 1.5vw, 3rem);
  line-height: 1;
  letter-spacing: -.02em;
  color: var(--c-ink);
}
.kpi--high .kpi__num { color: var(--c-high); }
.kpi--medium .kpi__num { color: var(--c-medium); }
.kpi__hint { font-size: var(--s-1); color: var(--c-mute); }

/* ----- Welcome block ----- */
.welcome {
  background: linear-gradient(135deg, var(--c-clay), var(--c-clay-dark));
  color: var(--c-white);
  padding: 2rem;
  border-radius: var(--r-xl);
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}
.welcome::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(60% 80% at 100% 0%, rgba(255, 255, 255, .15), transparent 60%);
}
.welcome__inner { position: relative; z-index: 1; max-width: 60ch; }
.welcome h2 {
  font-family: var(--f-display);
  font-size: var(--s-6);
  font-weight: 400;
  line-height: 1.1;
  margin-bottom: .65rem;
}
.welcome p { opacity: .9; font-size: var(--s-3); line-height: 1.55; }

/* ----- Cards (patient list etc) ----- */
.card {
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: 1.5rem;
}
.card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.card__title {
  font-family: var(--f-display);
  font-size: var(--s-5);
  font-weight: 400;
}

/* ----- Patient table / cards ----- */
.patient-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: center;
}
.patient-search {
  flex: 1 1 280px;
  position: relative;
}
.patient-search input {
  padding-left: 2.75rem;
}
.patient-search svg {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-mute);
  pointer-events: none;
}
.filter-pills {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
}
.pill {
  padding: .5rem 1rem;
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--r-full);
  font-size: var(--s-2);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.pill:hover { border-color: var(--c-ink); }
.pill.active {
  background: var(--c-ink);
  color: var(--c-paper);
  border-color: var(--c-ink);
}

.patient-list {
  display: grid;
  gap: .75rem;
}
.patient-row {
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.patient-row:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--c-ink);
}
.patient-row__main { display: grid; gap: .25rem; }
.patient-row__name {
  font-family: var(--f-display);
  font-size: var(--s-5);
  font-weight: 400;
  line-height: 1.1;
}
.patient-row__meta {
  font-size: var(--s-2);
  color: var(--c-mute);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.patient-row__meta span { display: inline-flex; align-items: center; gap: .35rem; }
.patient-row__side {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Risk badge */
.risk-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .85rem;
  border-radius: var(--r-full);
  font-size: var(--s-1);
  font-family: var(--f-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 500;
}
.risk-badge::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.risk-badge--low { background: var(--c-low-soft); color: var(--c-low); }
.risk-badge--medium { background: var(--c-medium-soft); color: #7a6320; }
.risk-badge--high { background: var(--c-high-soft); color: var(--c-high-dark, var(--c-clay-dark)); }
.risk-badge--none { background: var(--c-paper-2); color: var(--c-mute); }

/* ----- Empty state ----- */
.empty {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--c-white);
  border: 1px dashed var(--c-line-2);
  border-radius: var(--r-lg);
}
.empty__icon {
  width: 56px; height: 56px;
  margin: 0 auto 1rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--c-paper-2);
  color: var(--c-clay);
}
.empty h3 {
  font-family: var(--f-display);
  font-size: var(--s-5);
  font-weight: 400;
  margin-bottom: .35rem;
}
.empty p {
  color: var(--c-mute);
  margin-bottom: 1.5rem;
  max-width: 40ch;
  margin-inline: auto;
}

/* ----- Patient form ----- */
.form-section {
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.form-section h3 {
  font-family: var(--f-mono);
  font-size: var(--s-1);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--c-clay);
  margin-bottom: 1rem;
}
.form-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: 1fr;
}
@media (min-width: 600px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .span-2 { grid-column: 1 / -1; }
}
.checkbox {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .85rem;
  background: var(--c-paper);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.checkbox:hover { border-color: var(--c-ink); }
.checkbox input { margin-top: .2rem; accent-color: var(--c-clay); }
.checkbox span {
  font-size: var(--s-2);
  line-height: 1.4;
}
.form-actions {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* ----- Patient detail ----- */
.patient-header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 2rem;
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  margin-bottom: 1.5rem;
}
@media (min-width: 700px) {
  .patient-header { grid-template-columns: 1fr auto; align-items: start; }
}
.patient-header h2 {
  font-family: var(--f-display);
  font-size: var(--s-6);
  font-weight: 400;
  line-height: 1.1;
  margin-bottom: .5rem;
}
.patient-header .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  color: var(--c-mute);
  font-size: var(--s-2);
}
.patient-header .meta span { display: inline-flex; align-items: center; gap: .35rem; }

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--c-line);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}
.tab {
  padding: .85rem 1.25rem;
  background: transparent;
  font-size: var(--s-2);
  color: var(--c-mute);
  border-bottom: 2px solid transparent;
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  white-space: nowrap;
  cursor: pointer;
}
.tab:hover { color: var(--c-ink); }
.tab.active {
  color: var(--c-ink);
  border-color: var(--c-clay);
  font-weight: 500;
}

/* Visit list */
.visit-list { display: grid; gap: .75rem; }
.visit-item {
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  padding: 1.25rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: start;
}
.visit-item__date {
  font-family: var(--f-mono);
  font-size: var(--s-1);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--c-mute);
  margin-bottom: .35rem;
}
.visit-item__week {
  font-family: var(--f-display);
  font-size: var(--s-4);
  font-weight: 400;
}
.visit-vitals {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: .5rem;
}
.vital {
  font-size: var(--s-2);
  color: var(--c-ink-2);
}
.vital strong { font-family: var(--f-mono); color: var(--c-ink); }
.vital--alert strong { color: var(--c-high); }

/* Risk result panel */
.risk-result {
  border-radius: var(--r-lg);
  padding: 2rem;
  margin-top: 1.5rem;
  display: grid;
  gap: 1.5rem;
}
.risk-result--low { background: var(--c-low-soft); border-left: 4px solid var(--c-low); }
.risk-result--medium { background: var(--c-medium-soft); border-left: 4px solid var(--c-medium); }
.risk-result--high { background: var(--c-high-soft); border-left: 4px solid var(--c-high); }
.risk-result__head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.risk-result__title {
  font-family: var(--f-display);
  font-size: var(--s-6);
  font-weight: 400;
  line-height: 1;
}
.risk-result__score {
  font-family: var(--f-mono);
  font-size: var(--s-2);
  color: var(--c-mute);
}
.risk-result__body { font-size: var(--s-3); line-height: 1.55; color: var(--c-ink-2); }

.alerts-list { display: grid; gap: .5rem; margin-top: .5rem; }
.alert-row {
  background: var(--c-white);
  padding: .85rem 1rem;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: var(--s-2);
  line-height: 1.4;
}
.alert-row .sev {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.alert-row .sev--critical { background: var(--c-high); }
.alert-row .sev--high { background: var(--c-high); }
.alert-row .sev--medium { background: var(--c-medium); }
.alert-row .sev--low { background: var(--c-low); }

.evac-card {
  background: var(--c-white);
  padding: 1.25rem;
  border-radius: var(--r-md);
  display: grid;
  gap: .65rem;
}
.evac-card h4 {
  font-family: var(--f-display);
  font-size: var(--s-4);
  font-weight: 400;
}
.evac-card .meta {
  font-size: var(--s-2);
  color: var(--c-mute);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ----- Education cards ----- */
.edu-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 700px) { .edu-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .edu-grid { grid-template-columns: repeat(3, 1fr); } }

.edu-card {
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  display: grid;
  gap: 1rem;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  position: relative;
  overflow: hidden;
}
.edu-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--c-clay);
}
.edu-card__category {
  font-family: var(--f-mono);
  font-size: var(--s-1);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--c-clay);
}
.edu-card h3 {
  font-family: var(--f-display);
  font-size: var(--s-5);
  font-weight: 400;
  line-height: 1.15;
}
.edu-card p {
  color: var(--c-mute);
  font-size: var(--s-2);
  line-height: 1.5;
}
.edu-card__foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--s-1);
  color: var(--c-mute);
  font-family: var(--f-mono);
}

/* Education reader modal-style */
.edu-reader { max-width: 720px; }
.edu-reader h2 {
  font-family: var(--f-display);
  font-size: var(--s-6);
  font-weight: 400;
  line-height: 1.1;
  margin-bottom: .5rem;
}
.edu-reader .meta {
  font-size: var(--s-1);
  color: var(--c-mute);
  font-family: var(--f-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}
.edu-reader section {
  margin-bottom: 1.5rem;
}
.edu-reader h4 {
  font-family: var(--f-display);
  font-size: var(--s-4);
  font-weight: 400;
  margin-bottom: .35rem;
}
.edu-reader p { color: var(--c-ink-2); line-height: 1.65; }
.edu-reader .source {
  font-size: var(--s-1);
  color: var(--c-mute);
  border-top: 1px solid var(--c-line);
  padding-top: 1rem;
  margin-top: 1.5rem;
}

/* ----- Map ----- */
#map {
  height: 60vh;
  min-height: 400px;
  border-radius: var(--r-lg);
  border: 1px solid var(--c-line);
  overflow: hidden;
  background: var(--c-paper-2);
}
.map-list {
  display: grid;
  gap: .75rem;
  margin-top: 1.5rem;
}
.center-row {
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  padding: 1.25rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
}
.center-row__main { display: grid; gap: .35rem; }
.center-row__name {
  font-family: var(--f-display);
  font-size: var(--s-4);
  font-weight: 400;
}
.center-row__meta {
  font-size: var(--s-2);
  color: var(--c-mute);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.center-level {
  font-family: var(--f-mono);
  font-size: var(--s-1);
  padding: .25rem .55rem;
  background: var(--c-paper-2);
  border-radius: var(--r-sm);
  letter-spacing: .08em;
}

/* ----- Settings ----- */
.settings-grid { display: grid; gap: 1rem; }
.setting-block {
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: 1.5rem;
}
.setting-block h3 {
  font-family: var(--f-display);
  font-size: var(--s-5);
  font-weight: 400;
  margin-bottom: .5rem;
}
.setting-block p {
  color: var(--c-mute);
  font-size: var(--s-2);
  margin-bottom: 1rem;
  line-height: 1.55;
}
.setting-actions {
  display: flex;
  gap: .65rem;
  flex-wrap: wrap;
}

/* Sync state indicator */
.sync-state {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-family: var(--f-mono);
  font-size: var(--s-1);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--c-mute);
}
.sync-state .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--c-low);
  box-shadow: 0 0 0 0 currentColor;
  animation: pulse-sm 2s infinite;
}
.sync-state.offline .dot { background: var(--c-medium); }
@keyframes pulse-sm {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

/* Quick action cards */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
  margin-bottom: 2rem;
}
@media (min-width: 700px) { .quick-actions { grid-template-columns: repeat(4, 1fr); } }
.qa-card {
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  display: grid;
  gap: .75rem;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  text-align: left;
}
.qa-card:hover {
  transform: translateY(-2px);
  border-color: var(--c-clay);
  box-shadow: var(--shadow-md);
}
.qa-card__icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--c-paper-2);
  display: grid;
  place-items: center;
  color: var(--c-clay);
}
.qa-card span {
  font-family: var(--f-display);
  font-size: var(--s-4);
  font-weight: 400;
}

/* Trends / charts */
.trend-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}
@media (min-width: 700px) { .trend-grid { grid-template-columns: repeat(2, 1fr); } }
.trend-card {
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: 1.25rem;
}
.trend-card h4 {
  font-family: var(--f-mono);
  font-size: var(--s-1);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--c-mute);
  margin-bottom: 1rem;
}
.trend-svg { width: 100%; height: 120px; }
.trend-svg .line { fill: none; stroke: var(--c-clay); stroke-width: 2; }
.trend-svg .area { fill: var(--c-clay); opacity: .12; }
.trend-svg .grid line { stroke: var(--c-line); stroke-width: 1; }
.trend-svg .axis text { font-family: var(--f-mono); font-size: 10px; fill: var(--c-mute); }
.trend-svg .dot { fill: var(--c-clay); }

/* Location mini-map in form */
.loc-block {
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.loc-block h3 {
  font-family: var(--f-mono);
  font-size: var(--s-1);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--c-clay);
  margin-bottom: .5rem;
}
.loc-block p { font-size: var(--s-2); color: var(--c-mute); margin-bottom: 1rem; }
#loc-map {
  width: 100%;
  height: 240px;
  border-radius: var(--r-md);
  background: var(--c-paper-2);
  border: 1px solid var(--c-line);
  overflow: hidden;
  margin-bottom: .75rem;
}
.loc-coords {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-family: var(--f-mono);
  font-size: var(--s-1);
  color: var(--c-mute);
  letter-spacing: .04em;
}
.loc-coords strong { color: var(--c-ink); }

/* Custom Leaflet marker for risk-coded patient pins */
.leaflet-marker-patient {
  width: 28px; height: 28px;
  border-radius: 50% 50% 50% 0;
  background: var(--c-clay);
  border: 2px solid #fff;
  transform: rotate(-45deg);
  box-shadow: 0 4px 10px rgba(0,0,0,.25);
  display: grid;
  place-items: center;
  position: relative;
}
.leaflet-marker-patient.low { background: var(--c-low); }
.leaflet-marker-patient.medium { background: var(--c-medium); }
.leaflet-marker-patient.high { background: var(--c-high); }
.leaflet-marker-patient::after {
  content: "";
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #fff;
  transform: rotate(45deg);
}
.leaflet-popup-content { margin: 12px 14px; font-family: var(--f-body); }
.leaflet-popup-content strong { font-family: var(--f-display); font-size: var(--s-4); font-weight: 400; }

/* Map page actions row */
.map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  margin-bottom: 1rem;
}
.map-actions .filter-pills { margin-right: auto; }

/* Status pill at app top */
.app-status-pill {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .65rem;
  border-radius: var(--r-full);
  background: var(--c-paper-2);
  font-size: var(--s-1);
  font-family: var(--f-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--c-ink-2);
}
.app-status-pill .d {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--c-low);
}
.app-status-pill.off .d { background: var(--c-medium); }

/* App page reveal */
.app-page {
  animation: page-in .4s var(--ease);
}
@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Emergency FAB + sheet
   ============================================================ */
.emerg-fab {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 95;
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .9rem 1.25rem .9rem 1rem;
  background: #d62828;
  color: #fff;
  border-radius: var(--r-full);
  box-shadow: 0 10px 25px rgba(214, 40, 40, .35), 0 0 0 1px rgba(255,255,255,.12) inset;
  font-weight: 600;
  font-size: var(--s-2);
  letter-spacing: .01em;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  animation: emerg-pulse 2.4s ease-in-out infinite;
}
.emerg-fab:hover {
  background: #b91c1c;
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 14px 32px rgba(214, 40, 40, .45);
}
.emerg-fab .pulse {
  position: relative;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #fff;
}
.emerg-fab .pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #fff;
  opacity: .6;
  animation: ping 1.6s cubic-bezier(0, 0, .2, 1) infinite;
}
@keyframes ping {
  75%, 100% { transform: scale(2.4); opacity: 0; }
}
@keyframes emerg-pulse {
  0%, 100% { box-shadow: 0 10px 25px rgba(214, 40, 40, .35), 0 0 0 0 rgba(214,40,40,.55); }
  50% { box-shadow: 0 10px 25px rgba(214, 40, 40, .35), 0 0 0 14px rgba(214,40,40,0); }
}

.emerg-sheet {
  position: fixed;
  inset: 0;
  z-index: 160;
  background: rgba(12,17,22,.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: grid;
  place-items: end center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base) var(--ease);
}
.emerg-sheet.open { opacity: 1; pointer-events: auto; }
.emerg-sheet__inner {
  background: #fff;
  width: min(560px, 100%);
  max-height: 90vh;
  margin: auto auto 0;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 1.5rem 1.5rem 2rem;
  transform: translateY(40px);
  transition: transform var(--t-base) var(--ease);
  overflow-y: auto;
  border-top: 6px solid #d62828;
}
@media (min-width: 700px) {
  .emerg-sheet { place-items: center; padding: 2rem; }
  .emerg-sheet__inner {
    margin: 0;
    border-radius: var(--r-xl);
    border-top: 0;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
  }
}
.emerg-sheet.open .emerg-sheet__inner { transform: translateY(0); }
.emerg-sheet__head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 1.25rem;
  gap: 1rem;
}
.emerg-sheet__title {
  font-family: var(--f-display);
  font-size: var(--s-6);
  font-weight: 400;
  line-height: 1.05;
  color: #b91c1c;
}
.emerg-sheet__sub {
  font-size: var(--s-2);
  color: var(--c-mute);
  margin-top: .35rem;
}
.emerg-sheet__close {
  width: 36px; height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fee2e2;
  color: #b91c1c;
  flex-shrink: 0;
}
.emerg-section {
  margin-top: 1.25rem;
}
.emerg-section h4 {
  font-family: var(--f-mono);
  font-size: var(--s-1);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #b91c1c;
  margin-bottom: .65rem;
  font-weight: 500;
}
.emerg-list { display: grid; gap: .5rem; }
.emerg-call {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .85rem 1rem;
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: var(--r-md);
  text-decoration: none;
  color: inherit;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.emerg-call:hover {
  background: #fee2e2;
  transform: translateX(2px);
}
.emerg-call .icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  color: #d62828;
  flex-shrink: 0;
  border: 1px solid #fecaca;
}
.emerg-call--critical .icon {
  background: #d62828;
  color: #fff;
  border-color: #d62828;
}
.emerg-call__main { flex: 1; min-width: 0; }
.emerg-call__name {
  font-family: var(--f-display);
  font-size: var(--s-4);
  font-weight: 400;
  line-height: 1.15;
}
.emerg-call__tag {
  font-size: var(--s-1);
  color: var(--c-mute);
  font-family: var(--f-mono);
  letter-spacing: .04em;
  margin-top: .15rem;
}
.emerg-call__num {
  font-family: var(--f-mono);
  font-weight: 600;
  color: #d62828;
  white-space: nowrap;
}
.emerg-protocols {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--c-line);
}
.emerg-protocol {
  background: #f8f8f6;
  padding: 1rem;
  border-radius: var(--r-md);
  margin-bottom: .5rem;
}
.emerg-protocol h5 {
  font-family: var(--f-display);
  font-size: var(--s-4);
  font-weight: 400;
  margin-bottom: .25rem;
}
.emerg-protocol p {
  font-size: var(--s-2);
  color: var(--c-ink-2);
  line-height: 1.5;
}

/* ============================================================
   Photo gallery on patient profile
   ============================================================ */
.photo-section {
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  margin-top: 1rem;
}
.photo-section h3 {
  font-family: var(--f-display);
  font-size: var(--s-5);
  font-weight: 400;
  margin-bottom: .25rem;
}
.photo-section p {
  font-size: var(--s-2);
  color: var(--c-mute);
  margin-bottom: 1rem;
}
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: .65rem;
  margin-top: 1rem;
}
.photo-tile {
  position: relative;
  aspect-ratio: 1/1;
  background: var(--c-paper-2);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease);
}
.photo-tile:hover { transform: scale(1.02); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile__date {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: .35rem .5rem;
  background: linear-gradient(to top, rgba(0,0,0,.65), transparent);
  color: #fff;
  font-size: 10px;
  font-family: var(--f-mono);
  letter-spacing: .04em;
}
.photo-tile__del {
  position: absolute;
  top: .35rem; right: .35rem;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  color: #fff;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}
.photo-tile:hover .photo-tile__del { opacity: 1; }
.photo-add {
  aspect-ratio: 1/1;
  border: 2px dashed var(--c-line-2);
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  color: var(--c-mute);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.photo-add:hover {
  border-color: var(--c-clay);
  color: var(--c-clay);
  background: var(--c-clay-soft);
}
.photo-add input { display: none; }
.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(12,17,22,.92);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base) var(--ease);
}
.photo-lightbox.open { opacity: 1; pointer-events: auto; }
.photo-lightbox img { max-width: 92vw; max-height: 92vh; border-radius: var(--r-md); }
.photo-lightbox__close {
  position: absolute;
  top: 1rem; right: 1rem;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  color: #fff;
  display: grid;
  place-items: center;
}

/* Risk chip with extra severity ring */
.risk-result__head .risk-badge {
  box-shadow: 0 0 0 4px var(--c-paper);
}

/* Dashboard emergency hint card */
.emerg-hint {
  background: linear-gradient(135deg, #d62828, #991b1b);
  color: #fff;
  padding: 1.25rem;
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  position: relative;
  overflow: hidden;
}
.emerg-hint:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(214,40,40,.35);
}
.emerg-hint::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(80% 80% at 100% 0%, rgba(255,255,255,.18), transparent 60%);
}
.emerg-hint__icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.emerg-hint__main { position: relative; z-index: 1; }
.emerg-hint__title {
  font-family: var(--f-display);
  font-size: var(--s-5);
  font-weight: 400;
  line-height: 1.1;
}
.emerg-hint__sub {
  font-size: var(--s-2);
  opacity: .85;
  margin-top: .15rem;
}
