/* ==========================================================================
   Helthio Design System
   Colours, type and logo usage per "Helthio - Brand & Identity Guidelines"
   Palette: Blue - Teal - Soft Surface - Navy - White
   ========================================================================== */

@font-face {
  font-family: 'Neue Montreal';
  src: url('../assets/fonts/NeueMontreal-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: 'Neue Montreal';
  src: url('../assets/fonts/NeueMontreal-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
}
@font-face {
  font-family: 'Neue Montreal';
  src: url('../assets/fonts/NeueMontreal-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
}

:root {
  /* --- Brand palette (exact values from the guidelines) --- */
  --brand-blue: #3E55A5;        /* Primary System Blue  - trust, system authority */
  --brand-teal: #17A999;        /* Secondary System Teal - transitions & actions */
  --brand-surface: #E1F2FC;     /* Background Soft Surface - soft UI backgrounds */
  --brand-navy: #202A37;        /* Deep System Navy - hierarchy & depth */
  --brand-white: #FFFFFF;       /* Pure White - clarity, breathing space */

  /* --- Derived working tones (shades of the palette only) --- */
  --primary-blue: var(--brand-blue);
  --primary-blue-dark: #2E4079;
  --primary-blue-deep: #232F5C;
  --primary-blue-light: var(--brand-surface);
  --primary-teal: var(--brand-teal);
  --primary-teal-dark: #0F6F65;
  --teal-light: #E2F5F2;

  --bg-color: var(--brand-white);
  --app-backdrop: #DCE7F1;
  --surface-gray: #F4F8FC;
  --card-bg: var(--brand-white);

  --text-dark: var(--brand-navy);
  --text-muted: #5C6675;
  --text-light: #8D97A5;
  --border-color: #E8EFF6;
  --border-strong: #BFCEDD;

  --font-family: 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-primary: 'Neue Montreal', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --shadow-sm: 0 2px 8px rgba(32, 42, 55, 0.05);
  --shadow-md: 0 8px 24px rgba(32, 42, 55, 0.10);
  --shadow-blue: 0 10px 25px rgba(31, 122, 140, 0.25);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--app-backdrop); /* Outer screen backdrop */
  color: var(--text-dark);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
}

.mobile-container {
  width: 100%;
  max-width: 440px;
  background-color: var(--bg-color);
  min-height: 100vh;
  position: relative;
  box-shadow: 0 0 40px rgba(0,0,0,0.15);
  overflow-x: hidden;
  padding-bottom: 90px; /* Safe area for bottom nav */
}

/* Typography & Headers */
h1, h2, h3, h4 {
  font-family: var(--font-primary);
  color: var(--text-dark);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.text-muted { color: var(--text-muted); }
.text-blue { color: var(--primary-blue); }
.text-teal { color: var(--primary-teal-dark); } /* darker teal for legible small text */

/* Modern Buttons (Fitts's Law compliant - min height 48px) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
  border-radius: 24px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
  font-size: 15px;
  text-decoration: none;
  min-height: 48px;
  gap: 8px;
  /* justify-content centres the label as a whole, but once it wraps onto a
     second line each line aligns to `start` again - which left-aligned the
     narrow buttons ("Live status", "Add to calendar"). Wrapping is fine here;
     wrapping ragged-left is not. */
  text-align: center;
  line-height: 1.3;
}

.btn-primary {
  background-color: var(--primary-blue);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background-color: var(--primary-blue-dark);
  transform: translateY(-1px);
}

.btn-white {
  background-color: var(--brand-white);
  color: var(--primary-blue);
  font-weight: 600;
}

.btn-translucent {
  background-color: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

.btn-outline {
  /* Also used without .btn (icon-only back buttons, small text buttons), so it
     carries its own centring rather than relying on .btn for it. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: transparent;
  border: 1.5px solid var(--border-color);
  color: var(--text-dark);
}

/* Input Fields (Combined Location + Search from Reference) */
.search-bar-container {
  display: flex;
  align-items: center;
  background-color: var(--surface-gray);
  border: 1.5px solid var(--border-color);
  border-radius: 28px;
  padding: 6px 16px;
  margin-bottom: 24px;
  height: 52px;
}

.search-location {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 12px;
  border-right: 1px solid var(--border-strong);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
}

/* The bar is the field, so the focus ring belongs on the bar - the <input>
   inside it has no border of its own to highlight. */
.search-bar-container:focus-within {
  border-color: var(--primary-blue);
  background-color: var(--brand-white);
}

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  color: var(--text-dark);
  min-width: 0;   /* lets the input shrink instead of pushing the buttons out */
}

/* WebKit draws its own grey cancel cross on type="search". It sits at a
   different size and colour to ours, so two clear affordances appeared. */
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }

/* Leading magnifier - the thing that makes a box read as a search box. */
.search-leading { color: var(--text-light); flex-shrink: 0; }

/* ==========================================================================
   Search suggestions
   The browser's own autocomplete offers words the patient typed before, in a
   black box that belongs to no design system. This replaces it with results
   from the app - a doctor, a record, a section - so the first tap goes
   somewhere useful instead of just completing a word.
   ========================================================================== */
.search-wrap { position: relative; margin-bottom: 24px; }
.search-wrap .search-bar-container { margin-bottom: 0; }

.search-suggest {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 60;
  background: var(--card-bg);
  border: 1.5px solid var(--border-color);
  border-radius: 20px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  max-height: 340px;
  overflow-y: auto;
  animation: suggestIn 0.14s ease-out;
}

@keyframes suggestIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.suggest-group {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-light);
  padding: 12px 16px 6px;
}

.suggest-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  font-family: inherit;
  text-align: left;
  text-decoration: none;
  color: var(--text-dark);
  cursor: pointer;
}

/* One highlight class for both hover and keyboard, so arrowing down and
   moving the mouse cannot light up two rows at once. */
.suggest-item:hover,
.suggest-item.is-active { background: var(--surface-gray); }

/* Every child here is a <span>, so styling them by element used to beat
   .suggest-ico on specificity and flatten the tile back to display:block -
   which is why the icon would not centre. Each part has its own class. */
.suggest-ico {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 12px;
  background: var(--st-bg, var(--st-info-bg));
  color: var(--st-c, var(--st-info));
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;   /* no text baseline to push the glyph off centre */
}

.suggest-ico svg { display: block; }

.suggest-text { flex: 1; min-width: 0; }

.suggest-item strong { display: block; font-size: 14px; font-weight: 700; }
.suggest-sub { display: block; font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* The matched run of characters, so it is obvious why a row is here. */
.suggest-item mark { background: none; color: var(--primary-blue); font-weight: 800; }

.suggest-empty { padding: 22px 16px; text-align: center; }
.suggest-empty p { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

/* Horizontal Categories / Pills */
.categories-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;   /* momentum scrolling on iOS */
  scroll-snap-type: x proximity;
  scroll-padding-left: 20px;
  /* Bleed past the 20px page gutter so the strip scrolls edge to edge and the
     last pill is clipped by the screen, not by the container padding. */
  margin: 0 -20px 24px -20px;
  padding: 0 20px 8px 20px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  cursor: grab;
}

.categories-scroll.is-dragging {
  cursor: grabbing;
  scroll-snap-type: none;   /* snapping fights the drag */
  user-select: none;
}
.categories-scroll::-webkit-scrollbar { display: none; }

.category-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background-color: var(--surface-gray);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 44px;
  flex: 0 0 auto;              /* never shrink - let the strip overflow and scroll */
  scroll-snap-align: start;
}

.category-pill:hover, .category-pill.active {
  background-color: var(--primary-blue-light);
  border-color: var(--primary-blue);
  color: var(--primary-blue);
}

.category-pill:not(.active) svg {
  color: var(--primary-blue);
}

.category-pill.active svg {
  color: inherit;   /* active pills set their own colour; icon follows it */
}

/* Cards & Containers */
.card {
  background-color: var(--card-bg);
  border-radius: 24px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
}

.hero-card {
  background: var(--primary-blue);
  color: white;
  border-radius: 28px;
  padding: 20px;
  box-shadow: var(--shadow-blue);
  margin-bottom: 24px;
  border: none;
}

/* Bottom Navigation (Clean iOS style) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  width: 100%;
  max-width: 440px;
  background-color: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  display: flex;
  padding: 12px 4px 20px 4px;
  border-top: 1px solid var(--border-color);
  z-index: 1000;
}

/* Equal-width columns, not space-around. The five labels differ in width
   ("Home" against "Appointments"), so distributing the leftover space would
   put a different gap either side of each one. Giving every item the same
   column and centring inside it makes the spacing uniform. */
.nav-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  color: var(--text-muted);
  text-decoration: none;
  /* 10px, not 11: "Appointments" is the longest label and at 11px it filled
     its column to within a pixel, which wraps on a 360px phone and makes that
     one item taller than the other four. Same size for all five. */
  font-size: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-align: center;
  gap: 5px;
  transition: color 0.2s;
  /* Last resort on a very narrow screen: clip, never wrap, so the row keeps
     its height and the five items stay aligned. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Active is carried by colour alone. A heavier weight or a scaled icon would
   make one item sit differently from the other four. */
.nav-item.active {
  color: var(--primary-blue);
}

.nav-item svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  transition: transform 0.2s;
}

/* No scale on the active icon either - every icon stays the same size, so the
   five items sit on one baseline and none of them nudges its label. */

/* Helpers & Psychology Components */
.progress-bar-container {
  background-color: rgba(255, 255, 255, 0.2);
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin: 12px 0;
}

.progress-bar-fill {
  background-color: #34D399; /* Vibrant green completion pulse */
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease-in-out;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  /* Badges are short labels. Keep them on one line and stop a long sibling in a
     flex row from squeezing them until the text wraps and goes ragged-left. */
  white-space: nowrap;
  flex-shrink: 0;
  text-align: center;
}

.badge-teal { background-color: var(--teal-light); color: var(--primary-teal-dark); }
.badge-blue { background-color: var(--primary-blue-light); color: var(--primary-blue); }

/* ==========================================================================
   Iconography
   Guidelines: icons are functional system components, not decorative visuals.
   Consistent stroke weight, geometric precision, rounded minimal corners,
   grid-aligned structure, no gradients or fills unless status-based.
   Every icon inherits colour from its container via currentColor.
   ========================================================================== */
.icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;         /* one stroke weight across the whole icon system */
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-lg { width: 28px; height: 28px; }
.icon-sm { width: 18px; height: 18px; }

/* For icons sitting inline with a run of text */
.icon-inline {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
}

/* Sticky page header title.
   Every screen lays the header out as: back button | title | badge-or-action.
   The title takes the free space between the two controls and centres its text,
   so it reads centred on every screen - including hospitals.html, where the
   title is long enough to wrap onto two lines.

   A grid with equal 1fr gutters would centre it on the exact screen midpoint,
   but the widest right-hand action (115px) would then force a matching 115px
   gutter on the left and squeeze 8 of the 12 titles into wrapping. Centring
   within the available space keeps them on one line, which reads better. */
.header-title {
  flex: 1;
  min-width: 0;          /* allow the title to wrap rather than push the badge out */
  text-align: center;
  padding: 0 10px;
}

.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; gap: 8px; }

/* ✨ Helthio Clinical AI Assistant Styles & Micro-Animations */
@keyframes aiPulse {
  0% { box-shadow: 0 0 0 0 rgba(31, 122, 140, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(31, 122, 140, 0); }
  100% { box-shadow: 0 0 0 0 rgba(31, 122, 140, 0); }
}

@keyframes aiShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.ai-banner {
  background: var(--primary-blue);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  padding: 20px;
  color: white;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-blue);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.ai-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 35px rgba(31, 122, 140, 0.35);
}

.ai-badge {
  background: var(--primary-teal);
  color: white;
  padding: 5px 12px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 3px 10px rgba(23, 169, 153, 0.3);
}

.ai-btn-small {
  background: var(--primary-blue);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 18px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(31, 122, 140, 0.25);
  transition: all 0.2s;
}

.ai-btn-small:hover {
  transform: scale(1.03);
  opacity: 0.95;
}

.ai-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(32, 42, 55, 0.7);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.ai-modal-card {
  background: var(--card-bg);
  border: 2px solid var(--primary-blue);
  border-radius: 28px;
  padding: 26px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-insight-box {
  background: var(--teal-light);
  border-left: 4px solid var(--primary-teal);
  padding: 14px 16px;
  border-radius: 0 16px 16px 0;
  color: var(--primary-teal-dark);
  font-size: 13px;
  line-height: 1.45;
  margin-top: 16px;
}


/* ==========================================================================
   Status & notification colours
   Patient app doc 10.3 / 13.1 - the five meanings a colour is allowed to
   carry. Nothing in the app may invent a sixth. Every value below is either a
   palette colour or a tint of one, except the alert red and the amber
   "action needed" tone, which the doc requires and the palette has no
   equivalent for. They are used only for status, never for decoration.
   ========================================================================== */
:root {
  --st-info: var(--brand-blue);          /* normal update - nothing to do */
  --st-info-bg: var(--brand-surface);
  --st-action: #B27400;                  /* action required from the patient */
  --st-action-bg: #FDF3DC;
  --st-done: var(--primary-teal-dark);   /* confirmed / completed */
  --st-done-bg: var(--teal-light);
  --st-critical: #C1272D;                /* emergency / critical */
  --st-critical-bg: #FBEAEA;
  --st-intl: #5C4B9E;                    /* insurance / international case */
  --st-intl-bg: #EEEAF8;
}

/* Set the status pair on any container, then let children read it. */
.st-info     { --st-c: var(--st-info);     --st-bg: var(--st-info-bg); }
.st-action   { --st-c: var(--st-action);   --st-bg: var(--st-action-bg); }
.st-done     { --st-c: var(--st-done);     --st-bg: var(--st-done-bg); }
.st-critical { --st-c: var(--st-critical); --st-bg: var(--st-critical-bg); }
.st-intl     { --st-c: var(--st-intl);     --st-bg: var(--st-intl-bg); }

.badge-st { background-color: var(--st-bg, var(--st-info-bg)); color: var(--st-c, var(--st-info)); }

/* ==========================================================================
   Page shell
   Every screen is: sticky header, scrolling body, bottom nav.
   ========================================================================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.page-header .header-title {
  font-size: 17px;
  font-weight: 700;
}

.icon-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 19px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1.5px solid var(--border-color);
  color: var(--text-dark);
  cursor: pointer;
  /* Used as an <a> for back and close controls on several screens. */
  text-decoration: none;
}

.icon-btn:hover { background: var(--surface-gray); }

.content-body {
  padding: 20px;
  padding-bottom: 100px;
}

/* Small caps label between blocks of cards */
.section-label {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 26px 0 12px;
}

.section-label:first-child { margin-top: 0; }

/* ==========================================================================
   Live card - home dashboard
   Doc 6: the cards at the top of home, sorted by urgency rather than by
   section. Each carries a title, a status, a time and one clear action (13.3).
   ========================================================================== */
.live-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card-bg);
  border: 1.5px solid var(--border-color);
  border-left: 4px solid var(--st-c, var(--st-info));
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-family: inherit;
  /* The card is a <button> on some screens and an <a> on others. Without this
     the <a> version underlined its whole body - title, description and all. */
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
}

.live-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.live-card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.live-card-icon {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--st-bg, var(--st-info-bg));
  color: var(--st-c, var(--st-info));
}

.live-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 3px;
  color: var(--text-dark);
}

.live-card p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

.live-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--st-c, var(--st-info));
}

/* ==========================================================================
   Quick actions grid - home dashboard middle layer (doc 6)
   ========================================================================== */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 14px 6px;
  min-height: 92px;
  border-radius: 18px;
  background: var(--surface-gray);
  border: 1px solid var(--border-color);
  color: var(--text-dark);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-action:hover {
  background: var(--primary-blue-light);
  border-color: var(--primary-blue);
  color: var(--primary-blue);
}

.quick-action svg { color: var(--primary-teal-dark); }
.quick-action:hover svg { color: inherit; }

/* ==========================================================================
   Timeline
   Doc 13.3: history is always a vertical timeline with date and time on every
   step. Used by referral status, admission, orders and lab tracking.
   ========================================================================== */
.timeline {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0 0 0 30px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 6px;
  bottom: 10px;
  width: 2px;
  background: var(--border-color);
}

.tl-step {
  position: relative;
  padding: 0 0 20px 0;
}

.tl-step::before {
  content: "";
  position: absolute;
  left: -30px;
  top: 3px;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--brand-white);
  border: 2px solid var(--border-strong);
  box-sizing: border-box;
}

/* A finished step is filled teal - care has moved through here */
.tl-step.is-done::before {
  background: var(--primary-teal);
  border-color: var(--primary-teal);
  box-shadow: 0 0 0 3px var(--teal-light);
}

/* The step happening right now */
.tl-step.is-current::before {
  background: var(--primary-blue);
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 4px var(--primary-blue-light);
}

.tl-step h4 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 2px;
  color: var(--text-dark);
}

.tl-step.is-pending h4 { color: var(--text-light); font-weight: 600; }

.tl-time { font-size: 12px; color: var(--text-muted); font-weight: 600; }

.tl-note { font-size: 13px; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }

/* ==========================================================================
   List rows - settings, consent, menus
   ========================================================================== */
.list-group {
  background: var(--card-bg);
  border: 1.5px solid var(--border-color);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 18px;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 15px 16px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-color);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-dark);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  min-height: 56px;
}

.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface-gray); }

.list-row-icon {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-blue-light);
  color: var(--primary-blue);
}

.list-row-main { flex: 1; min-width: 0; }
.list-row-main strong { display: block; font-size: 14px; font-weight: 700; }
.list-row-main span { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.list-row-end { font-size: 13px; font-weight: 700; color: var(--text-muted); flex-shrink: 0; }

/* ==========================================================================
   Toggle switch
   ========================================================================== */
.toggle { position: relative; display: inline-block; width: 46px; height: 28px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: 14px;
  transition: background 0.2s;
  cursor: pointer;
}

.toggle-track::before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 3px;
  top: 3px;
  background: var(--brand-white);
  border-radius: 11px;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(32, 42, 55, 0.3);
}

/* Primary System Blue, not teal: a switch being on is a setting the patient
   chose, not a task they completed. Teal stays reserved for done/confirmed. */
.toggle input:checked + .toggle-track { background: var(--primary-blue); }
.toggle input:checked + .toggle-track::before { transform: translateX(18px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--primary-blue); outline-offset: 2px; }

/* ==========================================================================
   Segmented control
   ========================================================================== */
.segmented {
  display: flex;
  gap: 4px;
  background: var(--surface-gray);
  border: 1px solid var(--border-color);
  border-radius: 22px;
  padding: 4px;
  margin-bottom: 20px;
}

.segmented button {
  flex: 1;
  padding: 9px 8px;
  border: none;
  background: none;
  border-radius: 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  min-height: 40px;
  transition: all 0.2s;
}

.segmented button.active {
  background: var(--brand-white);
  color: var(--primary-blue);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Forms
   ========================================================================== */
.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 7px;
}

/* Doc 13.5: optional fields are clearly marked optional */
.field .optional { font-weight: 600; color: var(--text-light); }

.input,
select.input,
textarea.input {
  width: 100%;
  padding: 13px 16px;
  margin-bottom: 5px;
  min-height: 50px;
  border: 1.5px solid var(--border-color);
  border-radius: 16px;
  background: var(--surface-gray);
  font-family: inherit;
  font-size: 15px;
  color: var(--text-dark);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.input:focus { border-color: var(--primary-blue); background: var(--brand-white); }

textarea.input { min-height: 90px; resize: vertical; line-height: 1.5; }

.field-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; line-height: 1.4; }

/* Selectable option card - radio behaviour without radio chrome */
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1.5px solid var(--border-color);
  border-radius: 18px;
  background: var(--card-bg);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-dark);
  text-align: left;
  cursor: pointer;
  min-height: 56px;
  transition: all 0.2s;
}

.choice:hover { border-color: var(--border-strong); }

.choice.selected {
  border-color: var(--primary-blue);
  background: var(--primary-blue-light);
  color: var(--primary-blue);
}

.choice strong { display: block; font-size: 14px; font-weight: 700; }
.choice span { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.choice.selected span { color: var(--primary-blue); }

.choice-check { margin-left: auto; opacity: 0; color: var(--primary-blue); }
.choice.selected .choice-check { opacity: 1; }

/* Chip row for slots, quantities, durations.
   Scoped to [data-select] because hospitals.html already had a .chip of its
   own for the specialty filter strip - an unscoped rule here would leak
   min-height into it and leave the label sitting off-centre. */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

[data-select] .chip {
  padding: 9px 16px;
  border: 1.5px solid var(--border-color);
  border-radius: 18px;
  background: var(--card-bg);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  min-height: 40px;
  transition: all 0.2s;
}

[data-select] .chip.selected {
  border-color: var(--primary-blue);
  background: var(--primary-blue);
  color: var(--brand-white);
}

[data-select] .chip:disabled { opacity: 0.4; cursor: not-allowed; }

/* ==========================================================================
   Notices
   ========================================================================== */
.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--st-bg, var(--st-info-bg));
  border-left: 4px solid var(--st-c, var(--st-info));
  border-radius: 0 16px 16px 0;
  padding: 13px 16px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-dark);
  margin-bottom: 18px;
}

.notice svg { color: var(--st-c, var(--st-info)); flex-shrink: 0; margin-top: 1px; }
.notice strong { color: var(--st-c, var(--st-info)); }

/* Anything a machine wrote must say so (doc 11.2) */
.ai-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--st-action);
  background: var(--st-action-bg);
  border-radius: 10px;
  padding: 4px 9px;
  margin-bottom: 8px;
}

/* ==========================================================================
   Sticky footer action - "one main action per screen" (doc 13.3)
   ========================================================================== */
.sticky-action {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 440px;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  z-index: 900;
}

.sticky-action-summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.sticky-action-summary strong { font-size: 18px; color: var(--text-dark); }

/* Pages carrying a sticky action need room for it above the nav */
.has-sticky-action { padding-bottom: 190px; }

/* ==========================================================================
   Step wizard progress
   ========================================================================== */
.steps-bar { display: flex; gap: 6px; margin-bottom: 22px; }

.steps-bar span {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border-color);
  transition: background 0.3s;
}

/* Both Primary System Blue. Finished steps are solid; the step being worked on
   is lighter, so the bar reads as settled behind you and in progress here. */
.steps-bar span.done,
.steps-bar span.active { background: var(--primary-blue); }
.steps-bar span.active { opacity: 0.5; }

/* ==========================================================================
   Floating SOS
   Doc 8.9 and 13.3: emergency access is permanent, so this is injected on
   every signed-in screen by js/app.js rather than living on one page.

   Anchoring: the button must sit against the phone frame's right edge, not the
   browser window's, on a desktop screen. Anchor it to the container's centre
   line the way .bottom-nav does, then step back in from the frame's own edge.
   min() keeps it correct when the screen is narrower than the container.
   ========================================================================== */
.floating-sos {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(calc(min(220px, 50vw) - 100% - 20px));
  background: var(--st-critical);
  color: white;
  width: 56px;
  height: 56px;
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(193, 39, 45, 0.35);
  font-family: inherit;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  z-index: 990;
  border: none;
  letter-spacing: 0.5px;
  transition: transform 0.2s;
}

/* Repeat the translate - a bare scale() here would drop it and snap the
   button back to the centre line on press. */
.floating-sos:active {
  transform: translateX(calc(min(220px, 50vw) - 100% - 20px)) scale(0.95);
}

/* Screens with no bottom navigation have no bar to clear. */
.floating-sos.no-nav { bottom: 24px; }

/* ==========================================================================
   Empty state
   ========================================================================== */
.empty-state { text-align: center; padding: 40px 24px; color: var(--text-muted); }
.empty-state svg { color: var(--border-strong); margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; margin-bottom: 6px; }
.empty-state p { font-size: 13px; line-height: 1.5; }

/* ==========================================================================
   Bottom sheet
   ========================================================================== */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(32, 42, 55, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 2000;
}

.sheet-overlay.open { display: flex; }

.sheet {
  width: 100%;
  max-width: 440px;
  background: var(--card-bg);
  border-radius: 28px 28px 0 0;
  padding: 12px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  max-height: 85vh;
  overflow-y: auto;
  animation: sheetUp 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  margin: 0 auto 16px;
}

/* ==========================================================================
   Toast - replaces the placeholder alert() calls
   ========================================================================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translate(-50%, 12px);
  width: calc(100% - 40px);
  max-width: 400px;
  background: var(--brand-navy);
  color: var(--brand-white);
  border-radius: 18px;
  padding: 14px 18px;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 3000;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   Utility
   ========================================================================== */
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.mb-0 { margin-bottom: 0; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   Avatar
   Initials by default. The app deliberately avoids remote profile images.
   -------------------------------------------------------------------------- */
.avatar {
  width: 46px;
  height: 46px;
  min-width: 46px;
  border-radius: 23px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-blue-light);
  color: var(--primary-blue);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.avatar-teal { background: var(--teal-light); color: var(--primary-teal-dark); }
.avatar-navy { background: var(--brand-navy); color: var(--brand-white); }
.avatar-sm { width: 38px; height: 38px; min-width: 38px; border-radius: 19px; font-size: 13px; }
.avatar-lg { width: 64px; height: 64px; min-width: 64px; border-radius: 32px; font-size: 21px; }

/* Key-value rows used by bills, cost breakdowns and record metadata */
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; font-size: 14px; border-bottom: 1px dashed var(--border-color); }
.kv:last-child { border-bottom: none; }
.kv dt { color: var(--text-muted); }
.kv dd { font-weight: 700; text-align: right; margin: 0; }
.kv-total { border-top: 2px solid var(--border-strong); border-bottom: none; padding-top: 12px; margin-top: 4px; font-size: 16px; }

/* ==========================================================================
   hidden
   The HTML `hidden` attribute is styled by the UA as [hidden] { display: none },
   which any author rule setting `display` outranks - so a .btn, .notice or
   .quick-action carrying `hidden` stayed visible. The wizards drive their
   back buttons and conditional notices through that attribute, so this rule
   is what makes those states work at all.
   ========================================================================== */
[hidden] { display: none !important; }

/* ==========================================================================
   Sticky action vs. bottom nav
   Both are fixed to the bottom of the screen, and the nav has the higher
   z-index - so on a wizard that also shows the nav (lab booking, share
   records, add medicine, upload record) the Continue button sat completely
   behind it. Lift the bar by exactly the nav's height when a nav is present;
   leave it flush when the page has none, as onboarding does.
   ========================================================================== */
:root { --nav-height: 79px; }

body:not([data-nav="none"]) .sticky-action,
body:not([data-nav="none"]) .confirm-bar {
  bottom: var(--nav-height);
  padding-bottom: 14px;   /* the nav below already covers the safe-area inset */
}

body:not([data-nav="none"]) .has-sticky-action {
  padding-bottom: calc(190px + var(--nav-height));
}

/* ==========================================================================
   Card actions
   A card's controls should read as one decision, not a grid of equal pills.
   Three tiers: the action, the alternative to it, then a quiet strip of
   extras. The doc asks for one main action per screen (13.3); this is how a
   card keeps that true while still offering the smaller things.
   ========================================================================== */
.card-actions {
  border-top: 1px solid var(--border-color);
  margin-top: 14px;
  padding-top: 14px;
}

/* Direct children only. As a descendant selector this also matched a button
   sitting next to another inside a .row, adding a stray 8px top margin that
   knocked the pair out of alignment. */
.card-actions > .btn + .btn { margin-top: 8px; }

/* Paired side by side, each button has roughly half the width a full-width one
   would - so the default 15px/24px padding no longer fits and the label wraps.
   Step both down inside a card row. */
.card-actions .row .btn {
  font-size: 14px;
  padding: 12px 14px;
  min-height: 46px;
}

/* The extras. One bordered strip split into equal cells reads as a single
   secondary object, where three separate outlined pills read as three more
   buttons competing with the two above them. */
.action-strip {
  display: flex;
  margin-top: 12px;
  border: 1.5px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  background: var(--card-bg);
}

.action-strip > * {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 11px 6px;
  background: none;
  border: none;
  border-left: 1px solid var(--border-color);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.action-strip > *:first-child { border-left: none; }

.action-strip > *:hover {
  background: var(--surface-gray);
  color: var(--primary-blue);
}

.action-strip svg {
  color: var(--primary-blue);
  transition: color 0.2s;
}

.action-strip > *:hover svg { color: inherit; }

/* ==========================================================================
   Horizontal strip edges
   Filter and category strips hide their scrollbar, so a chip cut off at the
   screen edge looks like a layout bug rather than an invitation to scroll.
   js/hscroll.js marks which side still has content and the matching edge
   fades out, which reads as "there is more this way".
   ========================================================================== */
.categories-scroll,
.filter-scroll,
.filter-strip,
.child-strip {
  transition: -webkit-mask-image 0.2s, mask-image 0.2s;
}

.can-scroll-end:not(.can-scroll-start) {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent 100%);
  mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent 100%);
}

.can-scroll-start:not(.can-scroll-end) {
  -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 36px), transparent 100%);
  mask-image: linear-gradient(to left, #000 calc(100% - 36px), transparent 100%);
}

.can-scroll-start.can-scroll-end {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 36px, #000 calc(100% - 36px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 36px, #000 calc(100% - 36px), transparent 100%);
}

/* ==========================================================================
   Buttons paired in a row
   A two-up row gives each button about half the card, and adding a leading
   icon costs roughly 26px of that. Tighten the icon and the gap so the label
   still fits on one line; a wrapped action button reads as a layout fault.
   ========================================================================== */
.row > .btn,
.result-actions > .btn,
.card-actions .row > .btn {
  gap: 6px;
}

.row > .btn .icon-sm,
.result-actions > .btn .icon-sm,
.card-actions .row > .btn .icon-sm {
  width: 16px;
  height: 16px;
}
