/* =========================================================================
   Luv Health design system
   Tokens → primitives → components → layouts → utilities
   ========================================================================= */

/* ---------- Tokens ---------- */
:root {
  /* Brand */
  --red-500: #E1262F;
  --red-600: #C51C26;
  --red-700: #A50F18;
  --red-900: #6F0710;
  --red-050: #FFF4F5;
  --red-100: #FFE3E5;
  --red-200: #FFC9CD;

  /* Neutrals */
  --ink: #171717;
  --ink-2: #3F3F3F;
  --ink-3: #666666;
  --ink-4: #8A8A8A;
  --line: #EAEAEA;
  --line-2: #F2F2F2;
  --surface: #FFFFFF;
  --canvas: #FAFAFA;
  --canvas-warm: #FBF9F8;

  /* Semantic */
  --green-500: #1F8A5B;
  --green-050: #EDF8F2;
  --amber-500: #B26A00;
  --amber-050: #FFF6E8;
  --blue-500: #2563A8;
  --blue-050: #EEF4FB;

  /* Type */
  --font-display: "Plus Jakarta Sans", "Inter", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  --step--1: clamp(0.78rem, 0.76rem + 0.1vw, 0.83rem);
  --step-0:  clamp(0.94rem, 0.92rem + 0.12vw, 1rem);
  --step-1:  clamp(1.08rem, 1.02rem + 0.3vw, 1.22rem);
  --step-2:  clamp(1.3rem, 1.18rem + 0.6vw, 1.6rem);
  --step-3:  clamp(1.6rem, 1.36rem + 1.1vw, 2.15rem);
  --step-4:  clamp(2rem, 1.5rem + 2.3vw, 3.2rem);
  --step-5:  clamp(2.4rem, 1.6rem + 3.6vw, 4.2rem);

  /* Space */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px;
  --sp-9: 56px; --sp-10: 72px; --sp-11: 96px;

  /* Radius */
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-xl: 24px; --r-2xl: 32px; --r-pill: 999px;

  /* Elevation */
  --sh-1: 0 1px 2px rgba(23,23,23,.05), 0 1px 3px rgba(23,23,23,.04);
  --sh-2: 0 2px 4px rgba(23,23,23,.04), 0 8px 20px -6px rgba(23,23,23,.08);
  --sh-3: 0 4px 8px rgba(23,23,23,.04), 0 18px 40px -12px rgba(23,23,23,.14);
  --sh-red: 0 6px 18px -6px rgba(225,38,47,.45);

  --header-h: 68px;
  --mobile-nav-h: 68px;
  --sidebar-w: 268px;
  --content-max: 1180px;

  --ease: cubic-bezier(.2,.7,.3,1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  margin: 0 0 var(--sp-3);
  line-height: 1.12;
  letter-spacing: -0.022em;
  font-weight: 700;
  color: var(--ink);
}
h1 { font-size: var(--step-4); letter-spacing: -0.032em; }
h2 { font-size: var(--step-3); letter-spacing: -0.028em; }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); font-weight: 650; }
p  { margin: 0 0 var(--sp-4); color: var(--ink-2); }
a  { color: var(--red-600); text-decoration: none; }
a:hover { color: var(--red-700); }
small { font-size: var(--step--1); }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-7) 0; }

img, svg, video { max-width: 100%; height: auto; display: block; }
.luv-icon { flex: none; display: inline-block; vertical-align: middle; }

:focus-visible {
  outline: 3px solid var(--red-500);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 999;
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 0 0 12px 0;
}
.skip-link:focus { left: 0; color: #fff; }

.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;
}

/* ---------- Layout primitives ---------- */
.wrap { width: 100%; max-width: var(--content-max); margin-inline: auto; padding-inline: var(--sp-5); }
.wrap--narrow { max-width: 760px; }
.wrap--wide { max-width: 1360px; }
.stack > * + * { margin-top: var(--sp-4); }
.stack-lg > * + * { margin-top: var(--sp-7); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.grid { display: grid; gap: var(--sp-5); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.section { padding-block: var(--sp-10); }
.section--tight { padding-block: var(--sp-8); }
.section--alt { background: var(--surface); }
.section--warm { background: var(--red-050); }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--red-500);
  --btn-fg: #fff;
  --btn-bd: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  font-family: var(--font-display);
  font-weight: 650; font-size: var(--step-0); line-height: 1;
  padding: 14px 22px; border-radius: var(--r-pill);
  background: var(--btn-bg); color: var(--btn-fg);
  border: 1.5px solid var(--btn-bd);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease),
              background-color .18s var(--ease), color .18s var(--ease);
  box-shadow: var(--sh-red);
  min-height: 48px;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -8px rgba(225,38,47,.55); color: var(--btn-fg); }
.btn:active { transform: translateY(0); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; box-shadow: none; }

.btn--secondary { --btn-bg: #fff; --btn-fg: var(--ink); --btn-bd: var(--line); box-shadow: var(--sh-1); }
.btn--secondary:hover { --btn-bd: #D8D8D8; box-shadow: var(--sh-2); }
.btn--ghost { --btn-bg: transparent; --btn-fg: var(--ink-2); --btn-bd: transparent; box-shadow: none; }
.btn--ghost:hover { --btn-bg: var(--line-2); box-shadow: none; }
.btn--danger { --btn-bg: var(--red-700); }
.btn--quiet { --btn-bg: var(--red-050); --btn-fg: var(--red-700); box-shadow: none; }
.btn--quiet:hover { --btn-bg: var(--red-100); box-shadow: none; }
.btn--sm { padding: 9px 16px; font-size: var(--step--1); min-height: 38px; }
.btn--lg { padding: 17px 30px; font-size: var(--step-1); min-height: 56px; }
.btn--block { width: 100%; }

.btn.is-loading { pointer-events: none; position: relative; color: transparent !important; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn--secondary.is-loading::after { border-color: rgba(23,23,23,.2); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  box-shadow: var(--sh-1);
}
.card--flat { box-shadow: none; }
.card--pad-lg { padding: var(--sp-7); }
.card--tight { padding: var(--sp-5); }
.card--link { display: block; color: inherit; transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease); }
.card--link:hover { transform: translateY(-2px); box-shadow: var(--sh-3); border-color: #E0E0E0; color: inherit; }
.card--accent { border-left: 4px solid var(--red-500); }
.card__title { font-family: var(--font-display); font-weight: 680; font-size: var(--step-1); margin: 0; letter-spacing: -0.02em; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }

.eyebrow {
  font-family: var(--font-display); font-size: .72rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--red-600); margin: 0 0 var(--sp-3);
}
.lede { font-size: var(--step-1); color: var(--ink-3); line-height: 1.55; }
.muted { color: var(--ink-3); }
.tiny { font-size: var(--step--1); color: var(--ink-3); }

/* ---------- Badges & pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-display); font-size: .74rem; font-weight: 650; letter-spacing: .01em;
  padding: 5px 11px; border-radius: var(--r-pill);
  background: var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.badge--brand   { background: var(--red-050); color: var(--red-700); }
.badge--success { background: var(--green-050); color: var(--green-500); }
.badge--warning { background: var(--amber-050); color: var(--amber-500); }
.badge--danger  { background: var(--red-100); color: var(--red-900); }
.badge--info    { background: var(--blue-050); color: var(--blue-500); }
.badge--neutral { background: var(--line-2); color: var(--ink-3); }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.pill-group { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 15px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  font-size: var(--step--1); font-weight: 600; cursor: pointer;
  transition: all .16s var(--ease); min-height: 40px;
}
.pill:hover { border-color: var(--red-200); color: var(--red-700); }
.pill.is-active { background: var(--red-500); border-color: var(--red-500); color: #fff; box-shadow: var(--sh-red); }

/* ---------- Avatars ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: linear-gradient(140deg, var(--red-500), var(--red-700));
  color: #fff; font-family: var(--font-display); font-weight: 700; font-size: .95rem;
  letter-spacing: .01em; overflow: hidden;
}
.avatar--sm { width: 34px; height: 34px; font-size: .78rem; }
.avatar--lg { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar--neutral { background: linear-gradient(140deg, #55565A, #2E2F33); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Forms ---------- */
.field { margin-bottom: var(--sp-5); }
.field > label, .label {
  display: block; font-family: var(--font-display); font-weight: 640;
  font-size: var(--step--1); color: var(--ink); margin-bottom: 7px; letter-spacing: -0.005em;
}
.field__hint { font-size: var(--step--1); color: var(--ink-3); margin-top: 6px; }
.field__error { font-size: var(--step--1); color: var(--red-700); margin-top: 6px; font-weight: 600; display: flex; gap: 6px; align-items: flex-start; }

input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=number], input[type=date], input[type=time], input[type=url],
input[type=search], select, textarea {
  width: 100%; font-family: var(--font-body); font-size: var(--step-0);
  color: var(--ink); background: #fff;
  padding: 13px 15px; border: 1.5px solid var(--line); border-radius: var(--r-md);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background-color .16s var(--ease);
  min-height: 50px; appearance: none;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px;
}
input:hover, select:hover, textarea:hover { border-color: #D6D6D6; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--red-500); box-shadow: 0 0 0 4px var(--red-050);
}
input::placeholder, textarea::placeholder { color: var(--ink-4); }
input[aria-invalid="true"], .has-error input, .has-error select, .has-error textarea {
  border-color: var(--red-600); background: var(--red-050);
}
input[type=checkbox], input[type=radio] {
  width: 20px; height: 20px; accent-color: var(--red-500); margin: 0; flex: none; cursor: pointer;
}

/* ---------- Search ---------- */
.search-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  width: min(100%, 390px);
  min-height: 50px;
  padding: 6px 6px 6px 15px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 7px 22px rgba(23, 23, 23, .045);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background-color .16s var(--ease);
}

.search-bar:hover { border-color: #D6D6D6; }

.search-bar:focus-within {
  border-color: var(--red-500);
  box-shadow: 0 0 0 4px var(--red-050), 0 9px 24px rgba(111, 7, 16, .08);
}

.search-bar--wide { width: min(100%, 680px); }
.search-bar--field { width: min(100%, 360px); box-shadow: none; }

.search-bar__icon {
  display: inline-grid;
  place-items: center;
  color: var(--ink-4);
  pointer-events: none;
}

.search-bar input[type=search] {
  min-width: 0;
  min-height: 36px;
  padding: 6px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: .86rem;
}

.search-bar input[type=search]:hover,
.search-bar input[type=search]:focus {
  border: 0;
  outline: none;
  box-shadow: none;
}

.search-bar input[type=search]::-webkit-search-cancel-button { display: none; }

.search-bar__clear {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: var(--ink-4);
  text-decoration: none;
  transition: color .16s var(--ease), background-color .16s var(--ease);
}

.search-bar__clear:hover {
  color: var(--red-700);
  background: var(--red-050);
}

.search-bar__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 15px;
  border: 0;
  border-radius: 11px;
  background: var(--red-500);
  color: #fff;
  font-family: var(--font-display);
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 5px 14px -6px rgba(225, 38, 47, .7);
  transition: background-color .16s var(--ease), transform .16s var(--ease), box-shadow .16s var(--ease);
}

.search-bar__submit:hover {
  background: var(--red-600);
  box-shadow: var(--sh-red);
  transform: translateY(-1px);
}

.search-bar__submit:focus-visible,
.search-bar__clear:focus-visible {
  outline: 3px solid var(--red-200);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .search-bar,
  .search-bar--wide,
  .search-bar--field { width: 100%; }

  .search-bar { padding-left: 13px; }
  .search-bar__submit { padding-inline: 12px; }
}

.check {
  display: flex; gap: var(--sp-3); align-items: flex-start; padding: 14px 16px;
  border: 1.5px solid var(--line); border-radius: var(--r-md); background: #fff;
  cursor: pointer; transition: all .16s var(--ease);
}
.check:hover { border-color: var(--red-200); background: var(--red-050); }
.check input { margin-top: 2px; }
.check__body { flex: 1; }
.check__title { font-weight: 620; font-family: var(--font-display); font-size: var(--step-0); }
.check__hint { font-size: var(--step--1); color: var(--ink-3); }
.check.is-selected { border-color: var(--red-500); background: var(--red-050); box-shadow: 0 0 0 3px var(--red-050); }

fieldset { border: 0; padding: 0; margin: 0 0 var(--sp-6); }
legend { padding: 0; font-family: var(--font-display); font-weight: 680; font-size: var(--step-1); margin-bottom: var(--sp-2); }

.form-grid { display: grid; gap: 0 var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ---------- Alerts ---------- */
.alert {
  display: flex; gap: var(--sp-3); align-items: flex-start;
  padding: 15px 18px; border-radius: var(--r-lg);
  background: var(--blue-050); color: var(--blue-500);
  border: 1px solid rgba(37,99,168,.16); font-size: var(--step-0);
}
.alert strong { display: block; font-family: var(--font-display); }
.alert p { color: inherit; margin: 0; }
.alert--success { background: var(--green-050); color: var(--green-500); border-color: rgba(31,138,91,.18); }
.alert--warning { background: var(--amber-050); color: var(--amber-500); border-color: rgba(178,106,0,.2); }
.alert--danger  { background: var(--red-050); color: var(--red-900); border-color: var(--red-200); }
.alert__body { flex: 1; min-width: 0; }

/* Emergency screen — deliberately unmissable */
.emergency {
  background: linear-gradient(160deg, var(--red-700), var(--red-900));
  color: #fff; border-radius: var(--r-2xl); padding: var(--sp-8);
  box-shadow: 0 24px 60px -20px rgba(111,7,16,.6);
}
.emergency h1, .emergency h2 { color: #fff; }
.emergency p { color: rgba(255,255,255,.9); }
.emergency .btn { --btn-bg: #fff; --btn-fg: var(--red-900); box-shadow: none; }
.emergency .btn--outline { --btn-bg: transparent; --btn-fg: #fff; --btn-bd: rgba(255,255,255,.5); }

/* ---------- Toasts ---------- */
.toast-stack {
  position: fixed; z-index: 200; bottom: calc(var(--mobile-nav-h) + 16px); left: 50%;
  transform: translateX(-50%); width: min(440px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: var(--sp-2); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; gap: var(--sp-3); align-items: flex-start;
  background: var(--ink); color: #fff; padding: 14px 16px; border-radius: var(--r-lg);
  box-shadow: var(--sh-3); font-size: var(--step-0);
  animation: toast-in .32s var(--ease);
}
.toast--success { background: #0F6B45; }
.toast--error { background: var(--red-700); }
.toast--warning { background: #8C5400; }
.toast button { background: none; border: 0; color: inherit; opacity: .7; cursor: pointer; padding: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (min-width: 900px) { .toast-stack { bottom: 24px; left: auto; right: 24px; transform: none; } }

/* ---------- Empty & skeleton states ---------- */
.empty {
  text-align: center; padding: var(--sp-9) var(--sp-5);
  border: 1.5px dashed var(--line); border-radius: var(--r-xl); background: #fff;
}
.empty__icon {
  width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center;
  margin: 0 auto var(--sp-4); background: var(--red-050); color: var(--red-500);
}
.empty h3 { margin-bottom: var(--sp-2); font-size: var(--step-1); }
.empty p { max-width: 40ch; margin-inline: auto; color: var(--ink-3); font-size: var(--step-0); }

.skeleton {
  background: linear-gradient(90deg, #F1F1F1 25%, #F8F8F8 37%, #F1F1F1 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite;
  border-radius: var(--r-sm);
}
.skeleton--line { height: 12px; margin-bottom: 10px; }
.skeleton--title { height: 20px; width: 55%; margin-bottom: 16px; }
.skeleton--card { height: 120px; border-radius: var(--r-xl); }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-lg); }
table.data { width: 100%; border-collapse: collapse; font-size: var(--step--1); min-width: 560px; }
table.data th {
  text-align: left; font-family: var(--font-display); font-weight: 650; color: var(--ink-3);
  font-size: .74rem; letter-spacing: .06em; text-transform: uppercase;
  padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tbody tr:hover { background: var(--canvas); }
table.data tbody tr:last-child td { border-bottom: 0; }

/* ---------- Stat cards ---------- */
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: var(--sp-5); box-shadow: var(--sh-1);
}
.stat__label { font-size: var(--step--1); color: var(--ink-3); font-weight: 600; margin-bottom: 6px; }
.stat__value { font-family: var(--font-display); font-size: var(--step-3); font-weight: 730; letter-spacing: -0.03em; line-height: 1; }
.stat__meta { font-size: var(--step--1); color: var(--ink-3); margin-top: 8px; display: flex; align-items: center; gap: 5px; }
.stat--brand { background: linear-gradient(150deg, var(--red-600), var(--red-900)); border: 0; color: #fff; box-shadow: var(--sh-red); }
.stat--brand .stat__label, .stat--brand .stat__meta { color: rgba(255,255,255,.82); }
.trend-up { color: var(--green-500); font-weight: 650; }
.trend-down { color: var(--red-600); font-weight: 650; }

/* ---------- Progress ---------- */
.progress { height: 8px; background: var(--line-2); border-radius: var(--r-pill); overflow: hidden; }
.progress__bar { height: 100%; background: linear-gradient(90deg, var(--red-500), var(--red-700)); border-radius: var(--r-pill); transition: width .5s var(--ease); }

.steps { display: flex; gap: 6px; margin-bottom: var(--sp-3); }
.steps__dot { flex: 1; height: 5px; border-radius: var(--r-pill); background: var(--line); }
.steps__dot.is-done { background: var(--red-500); }
.steps__dot.is-current { background: var(--red-200); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--line); overflow-x: auto; margin-bottom: var(--sp-6); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 12px 16px; font-family: var(--font-display); font-weight: 620; font-size: var(--step--1);
  color: var(--ink-3); border-bottom: 2.5px solid transparent; white-space: nowrap; margin-bottom: -1px;
  transition: color .16s var(--ease), border-color .16s var(--ease);
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--red-600); border-bottom-color: var(--red-500); }
.tab__count { display: inline-block; margin-left: 6px; background: var(--line-2); border-radius: var(--r-pill); padding: 1px 7px; font-size: .7rem; }
.tab.is-active .tab__count { background: var(--red-050); color: var(--red-700); }

/* ---------- Modal / drawer ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(23,23,23,.45); z-index: 150;
  display: grid; place-items: center; padding: var(--sp-4);
  animation: fade-in .2s var(--ease); backdrop-filter: blur(3px);
}
.modal {
  background: #fff; border-radius: var(--r-2xl); width: min(560px, 100%);
  max-height: 88vh; overflow-y: auto; box-shadow: var(--sh-3);
  padding: var(--sp-7); animation: modal-in .28s var(--ease);
}
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }
@media (max-width: 640px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { border-radius: var(--r-2xl) var(--r-2xl) 0 0; max-height: 92vh; }
  @keyframes modal-in { from { transform: translateY(100%); } }
}

/* ---------- Message bubbles ---------- */
.thread { display: flex; flex-direction: column; gap: var(--sp-5); }
.bubble-row { display: flex; gap: var(--sp-3); align-items: flex-end; }
.bubble-row--own { flex-direction: row-reverse; }
.bubble {
  max-width: min(560px, 82%); padding: 14px 18px; border-radius: var(--r-lg);
  background: #fff; border: 1px solid var(--line); box-shadow: var(--sh-1);
  font-size: var(--step-0); line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.bubble--own { background: var(--red-500); color: #fff; border-color: var(--red-500); border-bottom-right-radius: 6px; }
.bubble--own a { color: #fff; text-decoration: underline; }
.bubble--care { border-bottom-left-radius: 6px; }
.bubble--assistant { background: var(--canvas-warm); border-color: var(--red-100); }
.bubble--system { background: transparent; border: 1px dashed var(--line); color: var(--ink-3); font-size: var(--step--1); box-shadow: none; max-width: 100%; text-align: center; }
.bubble--note { background: #FFFCF2; border-color: #F0E2BD; }
.bubble__meta { font-size: .72rem; color: var(--ink-4); margin-top: 6px; display: flex; gap: 8px; align-items: center; }
.bubble--own .bubble__meta { color: rgba(255,255,255,.75); justify-content: flex-end; }

/* ---------- Appointment card ---------- */
.appt {
  display: flex; gap: var(--sp-4); align-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: var(--sp-5); box-shadow: var(--sh-1);
}
.appt__date {
  flex: none; width: 66px; text-align: center; padding: 10px 0;
  background: var(--red-050); border-radius: var(--r-lg); color: var(--red-700);
}
.appt__month { font-size: .68rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.appt__day { font-family: var(--font-display); font-size: 1.6rem; font-weight: 730; line-height: 1.05; }
.appt__body { flex: 1; min-width: 0; }
.appt__title { font-family: var(--font-display); font-weight: 680; font-size: var(--step-1); letter-spacing: -0.02em; }

.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: var(--sp-3); }
.slot {
  border: 1.5px solid var(--line); background: #fff; border-radius: var(--r-md);
  padding: 14px 8px; text-align: center; font-family: var(--font-display);
  font-weight: 650; font-size: var(--step-0); color: var(--ink); cursor: pointer;
  transition: all .16s var(--ease); min-height: 52px;
}
.slot:hover { border-color: var(--red-500); color: var(--red-600); transform: translateY(-1px); box-shadow: var(--sh-2); }
.slot.is-selected { background: var(--red-500); border-color: var(--red-500); color: #fff; }

/* ---------- Charts ---------- */
.chart-card { background: #fff; border: 1px solid var(--line); border-radius: var(--r-xl); padding: var(--sp-6); box-shadow: var(--sh-1); }
.chart-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.chart-holder { position: relative; width: 100%; min-height: 220px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--sp-4); margin-top: var(--sp-4); font-size: var(--step--1); color: var(--ink-3); }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Utilities ---------- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.flex-1 { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mt-0 { margin-top: 0 !important; } .mb-0 { margin-bottom: 0 !important; }
/* Full 8pt scale — every step exists so a class in a template always applies. */
.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); } .mt-5 { margin-top: var(--sp-5); } .mt-6 { margin-top: var(--sp-6); } .mt-7 { margin-top: var(--sp-7); } .mt-8 { margin-top: var(--sp-8); } .mt-9 { margin-top: var(--sp-9); } .mt-10 { margin-top: var(--sp-10); } .mt-11 { margin-top: var(--sp-11); }
.mb-1 { margin-bottom: var(--sp-1); } .mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); } .mb-4 { margin-bottom: var(--sp-4); } .mb-5 { margin-bottom: var(--sp-5); } .mb-6 { margin-bottom: var(--sp-6); } .mb-7 { margin-bottom: var(--sp-7); } .mb-8 { margin-bottom: var(--sp-8); } .mb-9 { margin-bottom: var(--sp-9); } .mb-10 { margin-bottom: var(--sp-10); } .mb-11 { margin-bottom: var(--sp-11); }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); } .gap-5 { gap: var(--sp-5); } .gap-6 { gap: var(--sp-6); } .gap-7 { gap: var(--sp-7); } .gap-8 { gap: var(--sp-8); }
.hide { display: none !important; }

/* Type-scale and measure helpers, so templates never inline a size. */
.h-xl { font-size: var(--step-2) !important; }
.h-md { font-size: var(--step-1) !important; }
.h-sm { font-size: var(--step-0) !important; }
.fw-normal { font-weight: 500; }
.m-0 { margin: 0 !important; }
.measure-56 { max-width: 46rem; }
.measure-58 { max-width: 48rem; }
.measure-820 { max-width: 820px; }
.measure-22 { max-width: 18rem; }
.min-w-0 { min-width: 0; }
.flex-start { align-items: flex-start; }
.flex-baseline { align-items: baseline; }
.row--center { justify-content: center; }
.grid-halves { display: grid; gap: var(--sp-8); grid-template-columns: 1fr 1fr; align-items: start; }
@media (max-width: 760px) { .grid-halves { grid-template-columns: 1fr; } }
.tone-ok { background: var(--green-050); color: var(--green-500); }
.page-pad { padding-block: var(--sp-8) var(--sp-10); }

/* Repeating app patterns, lifted out of the templates. */
.rowline { padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.rowline--roomy { padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.rowline--last { border-bottom: 0; }
.rowline--soft { padding: 9px 0; border-bottom: 1px solid rgba(0,0,0,.05); }
.pad-y { padding: 8px 0; }
.display-num {
  font-family: var(--font-display); font-weight: 700; font-size: var(--step-1);
  letter-spacing: -.02em;
}
.empty--inline { padding: 32px 16px; border: 0; }
.select--inline { min-height: 38px; font-size: var(--step--1); width: auto; }
.clickable { cursor: pointer; }
.break-all { word-break: break-all; }
.chip-file {
  padding: 8px 10px; border-radius: 10px; background: rgba(0,0,0,.06);
  font-size: var(--step--1);
}
.tile-glass {
  width: 46px; height: 46px; border-radius: 14px; display: grid;
  place-items: center; background: rgba(255,255,255,.16);
}
.tone-warn { background: var(--amber-050); color: var(--amber-500); }
.stack-gap + .stack-gap { margin-top: 12px; }
.divider { border-top: 1px solid var(--line); margin-block: var(--sp-5); }
.list-plain { list-style: none; padding: 0; margin: 0; }
.link-quiet { color: var(--ink-2); font-weight: 600; }
.link-quiet:hover { color: var(--red-600); }

@media (max-width: 700px) { .hide-sm { display: none !important; } }
@media (min-width: 701px) { .only-sm { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

@media print {
  .site-header, .app-nav, .mobile-nav, .app-sidebar, .btn, .toast-stack { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; }
}
