/*
 * MIAS-H v0.1 — clinical interface system
 * Warm Caribbean palette, accessible contrast, no gradients.
 */

:root {
  color-scheme: light;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --ivory-25: #fffefa;
  --ivory-50: #fcfaf4;
  --ivory-100: #f6f2e8;
  --ivory-200: #ebe4d6;
  --sand-300: #d5c7b0;
  --ink-950: #102b30;
  --ink-800: #25434a;
  --ink-700: #3d575d;
  --ink-600: #587077;
  --ink-500: #75878b;

  --petrol-950: #04303a;
  --petrol-900: #063c48;
  --petrol-800: #0a4e5b;
  --petrol-700: #116170;
  --petrol-500: #2b7e8b;
  --petrol-100: #dbecee;
  --petrol-50: #edf6f6;
  --jade-800: #176552;
  --jade-700: #207965;
  --jade-600: #2d8a74;
  --jade-500: #3a9f87;
  --jade-400: #65bba4;
  --jade-100: #dcefe8;
  --jade-50: #edf7f3;
  --coral-700: #b84935;
  --coral-600: #d85e45;
  --coral-500: #e8755c;
  --coral-400: #ef947f;
  --coral-300: #f3aa98;
  --coral-100: #f9dfd8;
  --coral-50: #fff1ed;
  --amber-700: #8b5b00;
  --amber-500: #d89a20;
  --amber-100: #f8e8bb;
  --amber-50: #fff8e7;
  --red-700: #9f2f2f;
  --red-600: #bf3f3f;
  --red-100: #f7dada;
  --red-50: #fff0ef;
  --blue-700: #2a5d8d;
  --blue-100: #dce9f5;
  --blue-50: #f0f6fb;

  --background: var(--ivory-50);
  --surface: var(--ivory-25);
  --surface-raised: #ffffff;
  --surface-subtle: var(--ivory-100);
  --text: var(--ink-950);
  --text-muted: var(--ink-600);
  --text-faint: var(--ink-500);
  --border: #ded8cc;
  --border-strong: #c8beaf;
  --brand: var(--petrol-800);
  --brand-hover: var(--petrol-900);
  --brand-soft: var(--petrol-50);
  --accent: var(--coral-600);
  --accent-soft: var(--coral-50);
  --success: var(--jade-700);
  --warning: var(--amber-700);
  --danger: var(--red-700);
  --info: var(--blue-700);

  --sidebar-width: 17.5rem;
  --topbar-height: 4.75rem;
  --content-max: 96rem;
  --radius-xs: 0.375rem;
  --radius-sm: 0.625rem;
  --radius-md: 0.875rem;
  --radius-lg: 1.25rem;
  --radius-xl: 1.75rem;
  --shadow-sm: 0 1px 2px rgb(16 43 48 / 0.06), 0 4px 14px rgb(16 43 48 / 0.04);
  --shadow-md: 0 10px 30px rgb(16 43 48 / 0.10), 0 2px 8px rgb(16 43 48 / 0.05);
  --shadow-lg: 0 22px 60px rgb(16 43 48 / 0.16), 0 6px 18px rgb(16 43 48 / 0.08);
  --focus-ring: 0 0 0 3px rgb(17 97 112 / 0.25);
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --duration-fast: 140ms;
  --duration-normal: 220ms;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 20rem;
  min-height: 100%;
  scroll-behavior: smooth;
  text-size-adjust: 100%;
}

body {
  min-width: 20rem;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: var(--background);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  display: none;
}

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  margin: 0;
  color: inherit;
  font: inherit;
}

button,
[role="button"] {
  touch-action: manipulation;
}

a {
  color: var(--petrol-700);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

a:hover {
  color: var(--petrol-900);
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
dl {
  margin-block-start: 0;
}

h1,
h2,
h3,
h4 {
  color: var(--ink-950);
  font-weight: 720;
  letter-spacing: -0.025em;
  line-height: 1.18;
}

h1 {
  margin-block-end: 0.6rem;
  font-size: clamp(1.65rem, 2.5vw, 2.35rem);
}

h2 {
  margin-block-end: 0.55rem;
  font-size: clamp(1.25rem, 2vw, 1.6rem);
}

h3 {
  margin-block-end: 0.45rem;
  font-size: 1.075rem;
}

p:last-child,
ul:last-child,
ol:last-child {
  margin-block-end: 0;
}

::selection {
  background: var(--petrol-100);
  color: var(--petrol-900);
}

:focus-visible {
  outline: 3px solid rgb(17 97 112 / 0.38);
  outline-offset: 2px;
}

[hidden],
.is-hidden {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  z-index: 9999;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.9rem;
  transform: translateY(-160%);
  border-radius: var(--radius-sm);
  background: var(--petrol-900);
  color: white;
  box-shadow: var(--shadow-md);
  font-weight: 700;
  text-decoration: none;
  transition: transform var(--duration-fast) var(--ease-standard);
}

.skip-link:focus {
  transform: translateY(0);
}

/* App structure */
.app,
.app-shell {
  min-height: 100vh;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: fixed;
  z-index: 40;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-width);
  min-height: 100vh;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid rgb(255 255 255 / 0.12);
  background: var(--petrol-900);
  color: rgb(255 255 255 / 0.82);
  scrollbar-color: rgb(255 255 255 / 0.22) transparent;
}

.sidebar-brand,
.brand {
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  color: white;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2.45rem;
  height: 2.45rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 0.18);
  border-radius: 0.8rem;
  background: var(--coral-500);
  color: white;
  font-size: 0.9rem;
  font-weight: 850;
  letter-spacing: -0.04em;
}

.brand-copy {
  min-width: 0;
}

.brand-name {
  display: block;
  overflow: hidden;
  color: white;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-subtitle {
  display: block;
  margin-top: 0.18rem;
  overflow: hidden;
  color: rgb(255 255 255 / 0.62);
  font-size: 0.72rem;
  letter-spacing: 0.035em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.sidebar-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1.25rem;
  padding: 0.65rem 0.8rem 1.25rem;
}

.nav-section {
  display: grid;
  gap: 0.28rem;
}

.nav-section-title {
  margin: 0.75rem 0.75rem 0.35rem;
  color: rgb(255 255 255 / 0.5);
  font-size: 0.68rem;
  font-weight: 760;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.nav-link {
  position: relative;
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  gap: 0.72rem;
  padding: 0.65rem 0.8rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgb(255 255 255 / 0.76);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 610;
  text-align: left;
  text-decoration: none;
  transition:
    background-color var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard),
    transform var(--duration-fast) var(--ease-standard);
}

.nav-link:hover {
  background: rgb(255 255 255 / 0.08);
  color: white;
}

.nav-link:active {
  transform: translateY(1px);
}

.nav-link[aria-current="page"],
.nav-link.is-active,
.nav-link[data-state="active"] {
  background: rgb(255 255 255 / 0.14);
  color: white;
}

.nav-link[aria-current="page"]::before,
.nav-link.is-active::before,
.nav-link[data-state="active"]::before {
  position: absolute;
  inset: 0.58rem auto 0.58rem -0.8rem;
  width: 0.24rem;
  border-radius: 0 0.25rem 0.25rem 0;
  background: var(--coral-500);
  content: "";
}

.nav-icon,
.icon {
  display: inline-grid;
  width: 1.25rem;
  height: 1.25rem;
  flex: 0 0 auto;
  place-items: center;
}

.nav-icon svg,
.icon svg {
  width: 100%;
  height: 100%;
}

.nav-badge {
  min-width: 1.3rem;
  margin-left: auto;
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
  background: var(--coral-500);
  color: white;
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  text-align: center;
}

.sidebar-footer {
  margin: auto 0.85rem 0.85rem;
  padding: 0.9rem;
  border: 1px solid rgb(255 255 255 / 0.11);
  border-radius: var(--radius-md);
  background: rgb(255 255 255 / 0.055);
  color: rgb(255 255 255 / 0.72);
  font-size: 0.78rem;
}

.sidebar-footer strong {
  display: block;
  margin-bottom: 0.2rem;
  color: white;
}

.app-main,
.main {
  min-width: 0;
  grid-column: 2;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem clamp(1rem, 3vw, 2.25rem);
  border-bottom: 1px solid rgb(200 190 175 / 0.72);
  background: rgb(252 250 244 / 0.94);
  box-shadow: 0 5px 20px rgb(16 43 48 / 0.035);
  backdrop-filter: blur(14px);
}

.topbar-start,
.topbar-end,
.header-actions,
.card-actions,
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.topbar-start {
  min-width: 0;
}

.topbar-title {
  min-width: 0;
}

.topbar-title strong {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 0.96rem;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-title small {
  display: block;
  margin-top: 0.05rem;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-toggle {
  display: none;
}

.search {
  position: relative;
  display: flex;
  width: min(23rem, 32vw);
  align-items: center;
}

.search .icon {
  position: absolute;
  left: 0.8rem;
  z-index: 1;
  width: 1rem;
  height: 1rem;
  color: var(--text-faint);
  pointer-events: none;
}

.search input,
.search-input {
  width: 100%;
  min-height: 2.6rem;
  padding: 0.58rem 0.9rem 0.58rem 2.35rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text);
  transition:
    border-color var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard);
}

.search input::placeholder {
  color: var(--text-faint);
}

.search input:focus {
  border-color: var(--petrol-700);
  box-shadow: var(--focus-ring);
  outline: none;
}

.profile-chip {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.6rem;
  padding: 0.25rem 0.35rem 0.25rem 0.25rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.profile-chip:hover {
  background: var(--surface-subtle);
}

.avatar {
  display: inline-grid;
  width: 2.25rem;
  height: 2.25rem;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border: 2px solid var(--surface-raised);
  border-radius: 50%;
  background: var(--jade-100);
  box-shadow: 0 0 0 1px var(--border);
  color: var(--jade-800);
  font-size: 0.78rem;
  font-weight: 800;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar.avatar-sm {
  width: 1.8rem;
  height: 1.8rem;
  font-size: 0.68rem;
}

.avatar.avatar-lg {
  width: 3.6rem;
  height: 3.6rem;
  font-size: 1rem;
}

.profile-copy {
  display: grid;
  max-width: 10rem;
  text-align: left;
}

.profile-copy strong,
.profile-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-copy strong {
  font-size: 0.8rem;
}

.profile-copy span {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.main-content,
.page {
  width: min(100%, var(--content-max));
  margin: 0 auto;
  padding: clamp(1.1rem, 2.8vw, 2.25rem);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-kicker,
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.45rem;
  color: var(--jade-800);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-description,
.muted {
  color: var(--text-muted);
}

.page-description {
  max-width: 52rem;
  margin: 0;
}

.divider {
  height: 1px;
  margin: 1.25rem 0;
  border: 0;
  background: var(--border);
}

/* Reusable surfaces and grids */
.card,
.panel,
.widget {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

.card {
  padding: clamp(1rem, 2vw, 1.35rem);
}

.card.is-interactive,
button.card,
a.card {
  color: inherit;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transition:
    border-color var(--duration-normal) var(--ease-standard),
    box-shadow var(--duration-normal) var(--ease-standard),
    transform var(--duration-normal) var(--ease-standard);
}

.card.is-interactive:hover,
button.card:hover,
a.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-header,
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.card-title,
.panel-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 760;
  letter-spacing: -0.015em;
}

.card-subtitle,
.panel-subtitle {
  margin: 0.22rem 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.card-body {
  min-width: 0;
}

.card-footer,
.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1rem -1.35rem -1.35rem;
  padding: 0.85rem 1.35rem;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--ivory-50);
}

.dashboard-grid,
.grid {
  display: grid;
  gap: 1rem;
}

.dashboard-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4,
.metrics-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-9 { grid-column: span 9; }
.span-12 { grid-column: 1 / -1; }

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Metrics */
.metric-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  padding: 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

.metric-card::after {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0.22rem;
  background: var(--petrol-700);
  content: "";
}

.metric-card[data-tone="jade"]::after,
.metric-card[data-state="success"]::after {
  background: var(--jade-600);
}

.metric-card[data-tone="coral"]::after,
.metric-card[data-risk="high"]::after,
.metric-card[data-risk="critical"]::after {
  background: var(--coral-600);
}

.metric-card[data-tone="amber"]::after,
.metric-card[data-risk="moderate"]::after {
  background: var(--amber-500);
}

.metric-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 690;
}

.metric-value {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: clamp(1.45rem, 3vw, 2rem);
  font-variant-numeric: tabular-nums;
  font-weight: 790;
  letter-spacing: -0.04em;
  line-height: 1;
}

.metric-unit {
  margin-left: 0.22rem;
  color: var(--text-muted);
  font-size: 0.72em;
  font-weight: 650;
  letter-spacing: 0;
}

.metric-detail {
  display: flex;
  align-items: center;
  gap: 0.38rem;
  margin-top: 0.65rem;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.trend {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-weight: 760;
}

.trend[data-trend="up"],
.trend.is-positive {
  color: var(--jade-800);
}

.trend[data-trend="down"],
.trend.is-negative {
  color: var(--red-700);
}

.trend[data-trend="neutral"] {
  color: var(--text-muted);
}

/* Buttons */
.btn,
.button {
  display: inline-flex;
  min-height: 2.65rem;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.62rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: white;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 750;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
  transition:
    background-color var(--duration-fast) var(--ease-standard),
    border-color var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard),
    transform var(--duration-fast) var(--ease-standard);
}

.btn:hover,
.button:hover {
  background: var(--brand-hover);
  color: white;
}

.btn:active,
.button:active {
  transform: translateY(1px);
}

.btn:focus-visible,
.button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn-secondary,
.btn[data-variant="secondary"] {
  border-color: var(--border-strong);
  background: var(--surface-raised);
  color: var(--petrol-800);
}

.btn-secondary:hover,
.btn[data-variant="secondary"]:hover {
  border-color: var(--petrol-700);
  background: var(--petrol-50);
  color: var(--petrol-900);
}

.btn-ghost,
.btn[data-variant="ghost"] {
  background: transparent;
  color: var(--petrol-800);
}

.btn-ghost:hover,
.btn[data-variant="ghost"]:hover {
  background: var(--petrol-50);
  color: var(--petrol-900);
}

.btn-accent,
.btn[data-variant="accent"] {
  background: var(--coral-600);
}

.btn-accent:hover,
.btn[data-variant="accent"]:hover {
  background: var(--coral-700);
}

.btn-danger,
.btn[data-variant="danger"] {
  background: var(--red-600);
}

.btn-danger:hover,
.btn[data-variant="danger"]:hover {
  background: var(--red-700);
}

.btn-sm {
  min-height: 2.15rem;
  padding: 0.45rem 0.72rem;
  font-size: 0.75rem;
}

.btn-lg {
  min-height: 3.15rem;
  padding: 0.8rem 1.25rem;
  font-size: 0.92rem;
}

.btn-block {
  width: 100%;
}

.btn:disabled,
.button:disabled,
.btn[aria-disabled="true"],
.button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.48;
  pointer-events: none;
}

.icon-btn {
  display: inline-grid;
  width: 2.55rem;
  height: 2.55rem;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--ink-700);
  cursor: pointer;
  transition:
    border-color var(--duration-fast) var(--ease-standard),
    background-color var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard);
}

.icon-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-subtle);
  color: var(--petrol-900);
}

/* Badges, states and clinical risk */
.badge,
.chip,
.status {
  display: inline-flex;
  min-height: 1.6rem;
  align-items: center;
  gap: 0.32rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--ivory-50);
  color: var(--ink-700);
  font-size: 0.68rem;
  font-weight: 760;
  line-height: 1.1;
  white-space: nowrap;
}

.status-dot {
  width: 0.45rem;
  height: 0.45rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

[data-state="success"],
[data-status="active"],
[data-status="complete"],
.badge-success {
  border-color: #b8dbcf;
  background: var(--jade-50);
  color: var(--jade-800);
}

[data-state="warning"],
[data-status="pending"],
.badge-warning {
  border-color: #ead49b;
  background: var(--amber-50);
  color: var(--amber-700);
}

[data-state="error"],
[data-status="blocked"],
.badge-danger {
  border-color: #edbdbc;
  background: var(--red-50);
  color: var(--red-700);
}

[data-state="info"],
.badge-info {
  border-color: #bfd6e8;
  background: var(--blue-50);
  color: var(--blue-700);
}

[data-risk="low"],
.risk-low {
  --risk-color: var(--jade-800);
  --risk-border: #b8dbcf;
  --risk-bg: var(--jade-50);
}

[data-risk="moderate"],
[data-risk="medium"],
.risk-moderate {
  --risk-color: var(--amber-700);
  --risk-border: #ead49b;
  --risk-bg: var(--amber-50);
}

[data-risk="high"],
.risk-high {
  --risk-color: var(--coral-700);
  --risk-border: #edb7aa;
  --risk-bg: var(--coral-50);
}

[data-risk="critical"],
.risk-critical {
  --risk-color: var(--red-700);
  --risk-border: #e9a8a8;
  --risk-bg: var(--red-50);
}

.badge[data-risk],
.status[data-risk],
.risk-badge {
  border-color: var(--risk-border);
  background: var(--risk-bg);
  color: var(--risk-color);
}

.risk-card[data-risk],
.alert[data-risk] {
  border-color: var(--risk-border);
  background: var(--risk-bg);
}

.risk-card[data-risk] .risk-icon,
.risk-card[data-risk] .risk-label,
.alert[data-risk] .alert-icon {
  color: var(--risk-color);
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--ink-800);
  font-size: 0.82rem;
}

.alert-icon {
  display: grid;
  width: 1.55rem;
  height: 1.55rem;
  flex: 0 0 auto;
  place-items: center;
}

.alert strong {
  display: block;
  margin-bottom: 0.16rem;
  color: var(--text);
}

/* Clinical patient summaries */
.patient-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.patient-header-copy {
  min-width: 0;
}

.patient-name {
  overflow: hidden;
  margin: 0;
  font-size: 1rem;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.patient-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin-top: 0.2rem;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.risk-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.risk-item {
  min-width: 0;
  padding: 0.7rem;
  border: 1px solid var(--risk-border, var(--border));
  border-radius: var(--radius-sm);
  background: var(--risk-bg, var(--ivory-50));
}

.risk-item-label {
  display: block;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.risk-item-value {
  display: block;
  margin-top: 0.25rem;
  color: var(--risk-color, var(--text));
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

/* Chart presentation */
.chart-card {
  min-height: 22rem;
}

.chart-wrap,
.chart {
  position: relative;
  min-width: 0;
  min-height: 15rem;
}

.chart svg,
.chart canvas {
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-grid line,
.grid-line {
  stroke: var(--border);
  stroke-dasharray: 3 5;
}

.chart-axis text,
.axis-label {
  fill: var(--text-muted);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.68rem;
}

.chart-line {
  fill: none;
  stroke: var(--petrol-700);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
}

.chart-line[data-series="target"] {
  stroke: var(--jade-600);
}

.chart-line[data-series="risk"] {
  stroke: var(--coral-600);
}

.chart-area {
  fill: rgb(17 97 112 / 0.1);
}

.chart-point {
  fill: var(--surface-raised);
  stroke: var(--petrol-700);
  stroke-width: 2;
}

.chart-bars {
  display: grid;
  min-height: 13rem;
  grid-auto-flow: column;
  grid-auto-columns: minmax(1.5rem, 1fr);
  align-items: end;
  gap: clamp(0.3rem, 1.2vw, 0.75rem);
  padding: 0.75rem 0.25rem 1.7rem;
  border-bottom: 1px solid var(--border);
}

.chart-bar {
  position: relative;
  min-height: 0.35rem;
  border-radius: 0.38rem 0.38rem 0.12rem 0.12rem;
  background: var(--petrol-700);
}

.chart-bar[data-series="secondary"] {
  background: var(--jade-600);
}

.chart-bar[data-risk="high"],
.chart-bar[data-risk="critical"] {
  background: var(--coral-600);
}

.chart-bar-label {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 50%;
  max-width: 4rem;
  transform: translateX(-50%);
  color: var(--text-muted);
  font-size: 0.62rem;
  text-align: center;
  white-space: nowrap;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 0.85rem;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
}

.legend-swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 0.2rem;
  background: var(--petrol-700);
}

.legend-swatch[data-series="secondary"] { background: var(--jade-600); }
.legend-swatch[data-series="risk"] { background: var(--coral-600); }

.progress,
.meter {
  position: relative;
  width: 100%;
  height: 0.55rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--ivory-200);
}

.progress-bar,
.meter-fill {
  width: var(--progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--petrol-700);
  transition: width 500ms var(--ease-standard);
}

.progress-bar[data-state="success"],
.meter-fill[data-state="success"] {
  background: var(--jade-600);
}

.progress-bar[data-risk="high"],
.progress-bar[data-risk="critical"],
.meter-fill[data-risk="high"],
.meter-fill[data-risk="critical"] {
  background: var(--coral-600);
}

.donut {
  --value: 0;
  --donut-color: var(--petrol-700);
  position: relative;
  display: grid;
  width: 7.25rem;
  aspect-ratio: 1;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  border: 0.65rem solid var(--ivory-200);
  background: var(--surface-raised);
  box-shadow: inset 0 0 0 2px var(--donut-color);
}

.donut::after {
  position: absolute;
  width: 72%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: transparent;
  content: "";
}

.donut-value {
  z-index: 1;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  font-weight: 820;
}

/* Tables */
.table-wrap,
.table-scroll {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  scrollbar-color: var(--sand-300) transparent;
}

.data-table,
table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  color: var(--ink-800);
  font-size: 0.8rem;
}

caption {
  padding: 0.8rem 1rem;
  color: var(--text-muted);
  font-weight: 650;
  text-align: left;
}

th,
td {
  padding: 0.78rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  position: relative;
  background: var(--ivory-50);
  color: var(--ink-700);
  font-size: 0.68rem;
  font-weight: 790;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr {
  transition: background-color var(--duration-fast) var(--ease-standard);
}

tbody tr:hover {
  background: var(--petrol-50);
}

tbody tr[data-state="selected"] {
  background: var(--jade-50);
  box-shadow: inset 3px 0 var(--jade-600);
}

td[data-label="Paciente"],
.cell-primary {
  color: var(--text);
  font-weight: 690;
}

.cell-number {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.cell-actions {
  width: 1%;
  text-align: right;
  white-space: nowrap;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}

/* Forms */
.form,
.form-grid {
  display: grid;
  gap: 1rem;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-field,
.field {
  display: grid;
  min-width: 0;
  gap: 0.38rem;
}

.form-field.full,
.field.full {
  grid-column: 1 / -1;
}

.form-label,
.field-label,
label {
  color: var(--ink-800);
  font-size: 0.78rem;
  font-weight: 700;
}

.required {
  color: var(--red-700);
}

.form-control,
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
select,
textarea {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.65rem 0.78rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text);
  line-height: 1.35;
  transition:
    border-color var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard),
    background-color var(--duration-fast) var(--ease-standard);
}

textarea {
  min-height: 7.5rem;
  resize: vertical;
}

select {
  appearance: none;
  padding-right: 2.4rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%233d575d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
}

.form-control::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

.form-control:hover,
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):hover,
select:hover,
textarea:hover {
  border-color: var(--ink-500);
}

.form-control:focus,
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):focus,
select:focus,
textarea:focus {
  border-color: var(--petrol-700);
  box-shadow: var(--focus-ring);
  outline: none;
}

.form-control:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  background: var(--surface-subtle);
  color: var(--text-faint);
  cursor: not-allowed;
  opacity: 0.78;
}

.form-field[data-state="error"] .form-control,
.field[data-state="error"] .form-control,
.form-control[aria-invalid="true"],
input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--red-600);
  background: var(--red-50);
}

.form-field[data-state="success"] .form-control,
.field[data-state="success"] .form-control {
  border-color: var(--jade-600);
}

.field-hint,
.form-hint {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.field-error,
.form-error {
  color: var(--red-700);
  font-size: 0.7rem;
  font-weight: 650;
}

.check-row,
.radio-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  color: var(--ink-800);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 570;
}

input[type="checkbox"],
input[type="radio"] {
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
  margin-top: 0.12rem;
  accent-color: var(--petrol-700);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--petrol-700);
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 650;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  width: 2.65rem;
  height: 1.5rem;
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--ivory-200);
  transition:
    background-color var(--duration-fast) var(--ease-standard),
    border-color var(--duration-fast) var(--ease-standard);
}

.switch-track::after {
  position: absolute;
  top: 0.18rem;
  left: 0.2rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgb(16 43 48 / 0.22);
  content: "";
  transition: transform var(--duration-fast) var(--ease-standard);
}

.switch input:checked + .switch-track {
  border-color: var(--petrol-700);
  background: var(--petrol-700);
}

.switch input:checked + .switch-track::after {
  transform: translateX(1.14rem);
}

.switch input:focus-visible + .switch-track {
  box-shadow: var(--focus-ring);
}

.segmented {
  display: inline-flex;
  max-width: 100%;
  padding: 0.22rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
}

.segmented button,
.segment {
  min-height: 2.1rem;
  padding: 0.4rem 0.72rem;
  border: 0;
  border-radius: 0.45rem;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 720;
  white-space: nowrap;
}

.segmented button[aria-selected="true"],
.segment[data-state="active"] {
  background: white;
  color: var(--petrol-900);
  box-shadow: 0 1px 4px rgb(16 43 48 / 0.12);
}

/* Timeline and intervention feed */
.timeline {
  position: relative;
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 1.7rem minmax(0, 1fr);
  gap: 0.7rem;
  padding-bottom: 1rem;
}

.timeline-item:not(:last-child)::before {
  position: absolute;
  top: 1.45rem;
  bottom: -0.1rem;
  left: 0.8rem;
  width: 1px;
  background: var(--border);
  content: "";
}

.timeline-marker {
  position: relative;
  z-index: 1;
  display: grid;
  width: 1.7rem;
  height: 1.7rem;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface-raised);
  color: var(--petrol-700);
}

.timeline-item[data-state="complete"] .timeline-marker {
  border-color: var(--jade-600);
  background: var(--jade-600);
  color: white;
}

.timeline-item[data-state="active"] .timeline-marker {
  border-color: var(--coral-600);
  box-shadow: 0 0 0 4px var(--coral-100);
  color: var(--coral-700);
}

.timeline-content {
  min-width: 0;
  padding-top: 0.16rem;
}

.timeline-title {
  margin: 0;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 720;
}

.timeline-meta {
  margin-top: 0.2rem;
  color: var(--text-muted);
  font-size: 0.7rem;
}

.activity-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.activity-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.75rem;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-copy {
  min-width: 0;
  font-size: 0.8rem;
}

.activity-copy strong {
  display: block;
  color: var(--text);
}

.activity-time {
  color: var(--text-faint);
  font-size: 0.68rem;
  white-space: nowrap;
}

/* Agent and audit components */
.agent-card {
  position: relative;
  overflow: hidden;
}

.agent-card[data-state="active"] {
  border-color: #b8dbcf;
  box-shadow: inset 0 0 0 1px var(--jade-100), var(--shadow-sm);
}

.agent-card[data-state="paused"] {
  background: var(--ivory-50);
}

.agent-card[data-state="blocked"] {
  border-color: #edbdbc;
}

.agent-state {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 720;
}

.pulse-dot {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 50%;
  background: var(--jade-600);
  box-shadow: 0 0 0 0 rgb(45 138 116 / 0.28);
  animation: status-pulse 2s ease-out infinite;
}

@keyframes status-pulse {
  70%, 100% { box-shadow: 0 0 0 7px rgb(45 138 116 / 0); }
}

.audit-log {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #102b30;
  color: #dcefe8;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.audit-row {
  display: grid;
  grid-template-columns: 8rem minmax(7rem, 0.8fr) minmax(12rem, 2fr) minmax(7rem, 1fr);
  gap: 0.7rem;
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid rgb(255 255 255 / 0.08);
}

.audit-row:last-child {
  border-bottom: 0;
}

.audit-row:hover {
  background: rgb(255 255 255 / 0.045);
}

.audit-hash {
  overflow: hidden;
  color: #8fd1bd;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Patient mobile experience mockup */
.phone-stage {
  display: grid;
  min-height: 39rem;
  place-items: center;
  padding: 2rem;
  border-radius: var(--radius-lg);
  background: var(--petrol-50);
}

.phone-mockup,
.phone-frame {
  position: relative;
  width: min(100%, 22rem);
  padding: 0.62rem;
  border: 2px solid #173b42;
  border-radius: 2.25rem;
  background: #173b42;
  box-shadow: 0 25px 55px rgb(16 43 48 / 0.22);
}

.phone-mockup::before,
.phone-frame::before {
  position: absolute;
  z-index: 3;
  top: 0.92rem;
  left: 50%;
  width: 5rem;
  height: 1.1rem;
  transform: translateX(-50%);
  border-radius: 999px;
  background: #173b42;
  content: "";
}

.phone-screen {
  position: relative;
  min-height: 42rem;
  overflow: hidden;
  border-radius: 1.72rem;
  background: var(--ivory-50);
}

.phone-statusbar {
  display: flex;
  height: 2.2rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1.2rem 0;
  color: var(--ink-800);
  font-size: 0.62rem;
  font-weight: 760;
}

.phone-header {
  padding: 1rem 1.1rem 0.75rem;
}

.phone-content {
  display: grid;
  gap: 0.8rem;
  padding: 0.8rem 1rem 5rem;
}

.phone-card {
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: 0 5px 14px rgb(16 43 48 / 0.05);
}

.meal-photo {
  position: relative;
  display: grid;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--ivory-200);
  color: var(--text-muted);
}

.meal-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.confidence {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.confidence-value {
  color: var(--jade-800);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.phone-nav {
  position: absolute;
  z-index: 2;
  inset: auto 0 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  min-height: 4.5rem;
  border-top: 1px solid var(--border);
  background: rgb(255 254 250 / 0.96);
  backdrop-filter: blur(10px);
}

.phone-nav-item {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.18rem;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  font-size: 0.58rem;
  font-weight: 680;
}

.phone-nav-item[data-state="active"],
.phone-nav-item[aria-current="page"] {
  color: var(--petrol-800);
}

/* Dialogs, drawers and overlays */
.overlay,
.modal-backdrop,
.drawer-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  background: rgb(8 31 36 / 0.58);
  backdrop-filter: blur(3px);
  animation: fade-in var(--duration-normal) var(--ease-standard);
}

.modal,
[role="dialog"].modal {
  position: fixed;
  z-index: 90;
  top: 50%;
  left: 50%;
  width: min(calc(100% - 2rem), 38rem);
  max-height: min(44rem, calc(100vh - 2rem));
  overflow: auto;
  transform: translate(-50%, -50%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  animation: modal-in var(--duration-normal) var(--ease-standard);
}

.modal-lg {
  width: min(calc(100% - 2rem), 60rem);
}

.modal-header,
.modal-body,
.modal-footer {
  padding: 1.15rem 1.35rem;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-size: 1.15rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  border-top: 1px solid var(--border);
  background: var(--ivory-50);
}

.drawer {
  position: fixed;
  z-index: 90;
  top: 0;
  right: 0;
  width: min(92vw, 30rem);
  height: 100vh;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  animation: drawer-in var(--duration-normal) var(--ease-standard);
}

@keyframes fade-in {
  from { opacity: 0; }
}

@keyframes modal-in {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 0.65rem)) scale(0.985); }
}

@keyframes drawer-in {
  from { transform: translateX(100%); }
}

/* Toasts */
.toast-region,
.toasts {
  position: fixed;
  z-index: 110;
  top: 1rem;
  right: 1rem;
  display: grid;
  width: min(calc(100vw - 2rem), 24rem);
  gap: 0.65rem;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 0.65rem;
  padding: 0.85rem;
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--petrol-700);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
  color: var(--ink-800);
  pointer-events: auto;
  animation: toast-in var(--duration-normal) var(--ease-standard);
}

.toast[data-state="success"] { border-left-color: var(--jade-600); }
.toast[data-state="warning"] { border-left-color: var(--amber-500); }
.toast[data-state="error"] { border-left-color: var(--red-600); }

.toast-title {
  margin: 0;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 760;
}

.toast-message {
  margin: 0.12rem 0 0;
  color: var(--text-muted);
  font-size: 0.72rem;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(0.8rem); }
}

/* Empty, error, loading and skeleton states */
.state-view,
.empty-state,
.error-state,
.loading-state {
  display: grid;
  min-height: 15rem;
  place-items: center;
  align-content: center;
  padding: 2rem;
  color: var(--text-muted);
  text-align: center;
}

.state-icon,
.empty-icon {
  display: grid;
  width: 3.25rem;
  height: 3.25rem;
  margin-bottom: 0.85rem;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface-subtle);
  color: var(--petrol-700);
}

.error-state .state-icon,
.state-view[data-state="error"] .state-icon {
  border-color: #edbdbc;
  background: var(--red-50);
  color: var(--red-700);
}

.state-title,
.empty-title {
  max-width: 28rem;
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 760;
}

.state-description,
.empty-description {
  max-width: 28rem;
  margin: 0.35rem 0 1rem;
  font-size: 0.78rem;
}

.spinner {
  width: 2rem;
  height: 2rem;
  margin-bottom: 0.85rem;
  border: 3px solid var(--petrol-100);
  border-top-color: var(--petrol-700);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(1turn); }
}

.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xs);
  background: var(--ivory-200);
  color: transparent !important;
  pointer-events: none;
}

.skeleton::after {
  position: absolute;
  inset: 0;
  background: rgb(255 255 255 / 0.38);
  content: "";
  animation: skeleton-pulse 1.25s ease-in-out infinite alternate;
}

@keyframes skeleton-pulse {
  from { opacity: 0.18; }
  to { opacity: 0.72; }
}

[aria-busy="true"],
[data-state="loading"] {
  cursor: progress;
}

/* Tooltips and dropdown menus */
.tooltip {
  position: absolute;
  z-index: 100;
  max-width: 18rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-xs);
  background: var(--ink-950);
  color: white;
  box-shadow: var(--shadow-md);
  font-size: 0.68rem;
  line-height: 1.35;
}

.dropdown,
.popover,
[role="menu"].menu {
  position: absolute;
  z-index: 70;
  min-width: 13rem;
  padding: 0.38rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
}

.menu-item,
[role="menuitem"] {
  display: flex;
  width: 100%;
  min-height: 2.35rem;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.65rem;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink-800);
  cursor: pointer;
  font-size: 0.78rem;
  text-align: left;
  text-decoration: none;
}

.menu-item:hover,
[role="menuitem"]:hover {
  background: var(--petrol-50);
  color: var(--petrol-900);
}

.menu-separator {
  height: 1px;
  margin: 0.35rem -0.38rem;
  background: var(--border);
}

/* MIAS-H application components */
.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.brand > div:last-child {
  display: grid;
  min-width: 0;
}

.brand > div:last-child strong {
  color: white;
  font-size: 1.1rem;
  font-weight: 830;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.brand > div:last-child span {
  margin-top: 0.16rem;
  color: rgb(255 255 255 / 0.58);
  font-size: 0.68rem;
  font-weight: 620;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.environment-chip {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 0.42rem;
  margin: 0.1rem 1.25rem 1.1rem;
  padding: 0.32rem 0.58rem;
  border: 1px solid rgb(255 255 255 / 0.13);
  border-radius: 999px;
  background: rgb(255 255 255 / 0.06);
  color: rgb(255 255 255 / 0.68);
  font-size: 0.65rem;
  font-weight: 720;
  letter-spacing: 0.02em;
}

.live-dot {
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #65c3a5;
  box-shadow: 0 0 0 3px rgb(101 195 165 / 0.14);
}

.nav-list {
  display: grid;
  gap: 0.3rem;
  padding: 0 0.8rem;
}

.nav-item {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 2.8rem;
  align-items: center;
  gap: 0.72rem;
  padding: 0.65rem 0.8rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgb(255 255 255 / 0.7);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 640;
  text-align: left;
  transition:
    background-color var(--duration-fast) var(--ease-standard),
    color var(--duration-fast) var(--ease-standard),
    transform var(--duration-fast) var(--ease-standard);
}

.nav-item:hover {
  background: rgb(255 255 255 / 0.075);
  color: white;
}

.nav-item:active {
  transform: translateY(1px);
}

.nav-item.is-active,
.nav-item[aria-current="page"] {
  background: rgb(255 255 255 / 0.14);
  color: white;
}

.nav-item.is-active::before,
.nav-item[aria-current="page"]::before {
  position: absolute;
  inset: 0.55rem auto 0.55rem -0.8rem;
  width: 0.25rem;
  border-radius: 0 0.25rem 0.25rem 0;
  background: var(--coral-500);
  content: "";
}

.nav-item .icon {
  width: 1.12rem;
  height: 1.12rem;
}

.nav-tag,
.nav-count {
  margin-left: auto;
  border-radius: 999px;
  font-size: 0.59rem;
  font-weight: 840;
  letter-spacing: 0.04em;
  line-height: 1;
}

.nav-tag {
  padding: 0.25rem 0.4rem;
  border: 1px solid rgb(255 255 255 / 0.17);
  color: #f2c3b8;
}

.nav-count {
  display: grid;
  min-width: 1.35rem;
  height: 1.35rem;
  place-items: center;
  background: var(--coral-500);
  color: white;
}

.sidebar-spacer {
  min-height: 1.25rem;
  flex: 1;
}

.sidebar-status {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  margin: 0 0.85rem 0.75rem;
  padding: 0.8rem;
  border: 1px solid rgb(255 255 255 / 0.11);
  border-radius: var(--radius-md);
  background: rgb(255 255 255 / 0.055);
}

.status-icon {
  display: grid;
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 0.65rem;
  background: var(--jade-100);
  color: var(--jade-800);
}

.sidebar-status .status-icon {
  background: rgb(101 195 165 / 0.14);
  color: #8ed8c1;
}

.status-icon .icon {
  width: 1.05rem;
  height: 1.05rem;
}

.sidebar-status strong,
.sidebar-status span {
  display: block;
}

.sidebar-status strong {
  color: white;
  font-size: 0.72rem;
}

.sidebar-status span {
  margin-top: 0.12rem;
  color: rgb(255 255 255 / 0.55);
  font-size: 0.63rem;
}

.sidebar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 0 1rem 1.1rem;
  color: rgb(255 255 255 / 0.44);
  font-size: 0.61rem;
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--petrol-700);
  cursor: pointer;
  font-size: 0.73rem;
  font-weight: 760;
  text-align: left;
  text-decoration: none;
}

.text-button:hover {
  color: var(--petrol-900);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.text-button .icon {
  width: 0.9rem;
  height: 0.9rem;
}

.sidebar-meta .text-button {
  color: rgb(255 255 255 / 0.68);
  font-size: 0.61rem;
}

.main-shell {
  min-width: 0;
  grid-column: 2;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.topbar-title {
  display: grid;
}

.topbar-title > span {
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 650;
}

.topbar-title > strong {
  color: var(--text);
  font-size: 0.95rem;
}

.icon-button {
  position: relative;
  display: inline-grid;
  width: 2.55rem;
  height: 2.55rem;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--ink-700);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--border-strong);
  background: var(--surface-subtle);
  color: var(--petrol-900);
}

.icon-button .icon {
  width: 1.1rem;
  height: 1.1rem;
}

.mobile-menu {
  display: none;
}

.notification-count {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  display: grid;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.3rem;
  place-items: center;
  border: 2px solid var(--surface-raised);
  border-radius: 999px;
  background: var(--coral-600);
  color: white;
  font-size: 0.66rem;
  font-weight: 850;
  line-height: 1;
}

.notification-count[hidden] {
  display: none;
}

.notification-popover {
  position: absolute;
  z-index: 80;
  top: calc(100% - 0.45rem);
  right: clamp(4.5rem, 16vw, 15.5rem);
  width: min(23rem, calc(100vw - 2rem));
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
}

.notification-popover[hidden] {
  display: none;
}

.notification-popover-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.2rem 0.25rem 0.7rem;
  border-bottom: 1px solid var(--border);
}

.notification-popover-header span {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.notification-list {
  display: grid;
  gap: 0.5rem;
  padding-top: 0.65rem;
}

.notification-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--amber-100);
  border-radius: var(--radius-md);
  background: var(--amber-50);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.notification-item:hover,
.notification-item:focus-visible {
  border-color: var(--amber-500);
  outline: none;
}

.notification-item-mark {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 50%;
  background: var(--amber-100);
  color: var(--amber-700);
  font-weight: 900;
}

.notification-item-copy {
  display: grid;
  gap: 0.15rem;
}

.notification-item-copy strong {
  font-size: 0.82rem;
}

.notification-item-copy small,
.notification-empty {
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.notification-item > .icon {
  width: 0.9rem;
  height: 0.9rem;
  color: var(--amber-700);
}

.notification-empty {
  padding: 1rem 0.5rem;
  text-align: center;
}

.profile-chip > div:last-child {
  display: grid;
  min-width: 0;
}

.profile-chip strong,
.profile-chip small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-chip strong {
  font-size: 0.75rem;
}

.profile-chip small {
  color: var(--text-muted);
  font-size: 0.63rem;
}

.workspace {
  width: min(100%, var(--content-max));
  margin: 0 auto;
  padding: clamp(1.1rem, 2.8vw, 2.25rem);
}

.view {
  min-width: 0;
}

.view:not(.is-active) {
  display: none;
}

.page-header p {
  max-width: 50rem;
  margin: 0;
  color: var(--text-muted);
}

.status-pill {
  display: inline-flex;
  min-height: 1.65rem;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.58rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--ivory-50);
  color: var(--ink-700);
  font-size: 0.65rem;
  font-weight: 790;
  line-height: 1.1;
  white-space: nowrap;
}

.status-safe {
  border-color: #b8dbcf;
  background: var(--jade-50);
  color: var(--jade-800);
}

.status-info {
  border-color: #bfd6e8;
  background: var(--blue-50);
  color: var(--blue-700);
}

.status-warning,
.status-experimental {
  border-color: #ead49b;
  background: var(--amber-50);
  color: var(--amber-700);
}

.status-danger {
  border-color: #edbdbc;
  background: var(--red-50);
  color: var(--red-700);
}

.safety-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid #b8dbcf;
  border-radius: var(--radius-md);
  background: var(--jade-50);
  color: var(--ink-800);
}

.safety-banner > .icon {
  width: 1.35rem;
  height: 1.35rem;
  color: var(--jade-800);
}

.safety-banner strong,
.safety-banner span:not(.status-pill) {
  display: block;
}

.safety-banner strong {
  color: var(--jade-800);
  font-size: 0.78rem;
}

.safety-banner span:not(.status-pill) {
  margin-top: 0.1rem;
  color: var(--text-muted);
  font-size: 0.7rem;
}

.safety-banner.experimental {
  border-color: #ead49b;
  background: var(--amber-50);
}

.safety-banner.experimental > .icon,
.safety-banner.experimental strong {
  color: var(--amber-700);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 1rem 0;
}

.metric-grid.compact-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-top {
  display: flex;
  min-height: 1.65rem;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 690;
}

.metric-card small {
  display: block;
  margin-top: 0.6rem;
  color: var(--text-muted);
  font-size: 0.67rem;
  line-height: 1.4;
}

.metric-icon {
  display: grid;
  width: 1.65rem;
  height: 1.65rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 0.52rem;
  background: var(--petrol-50);
  color: var(--petrol-700);
}

.metric-icon.coral { background: var(--coral-50); color: var(--coral-700); }
.metric-icon.amber { background: var(--amber-50); color: var(--amber-700); }
.metric-icon.jade { background: var(--jade-50); color: var(--jade-800); }
.metric-icon .icon { width: 0.9rem; height: 0.9rem; }

.trend-up {
  color: var(--jade-800);
}

.progress-track {
  width: 100%;
  height: 0.42rem;
  margin-top: 0.7rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--ivory-200);
}

.progress-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--jade-600);
}

.content-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.content-grid.grid-main {
  grid-template-columns: minmax(0, 2fr) minmax(18rem, 0.9fr);
}

.content-grid.grid-equal {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.content-grid .span-2 {
  grid-column: auto;
}

.card-kicker {
  display: block;
  margin-bottom: 0.28rem;
  color: var(--jade-800);
  font-size: 0.63rem;
  font-weight: 810;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.card-header h2 {
  margin: 0;
  font-size: 1rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  color: var(--text-muted);
  font-size: 0.64rem;
}

.legend > span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.legend-dot {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 50%;
  background: var(--petrol-700);
}

.legend-dot.jade { background: var(--jade-600); }

.legend-line {
  width: 0.9rem;
  height: 2px;
  background: var(--coral-600);
}

.chart-shell {
  position: relative;
  width: 100%;
  min-height: 12rem;
  overflow: hidden;
}

.chart-shell svg {
  width: 100%;
  height: auto;
}

.grid-lines line {
  stroke: var(--border);
  stroke-width: 1;
}

.goal-line {
  stroke: var(--coral-500);
  stroke-dasharray: 6 6;
  stroke-width: 1.5;
}

.area-path {
  fill: rgb(45 138 116 / 0.09);
}

.data-path {
  fill: none;
  stroke: var(--jade-600);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.data-points circle {
  fill: var(--surface-raised);
  stroke: var(--jade-600);
  stroke-width: 2;
}

.axis-labels text {
  fill: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.62rem;
}

.insight-strip {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin-top: 0.45rem;
  padding: 0.65rem 0.75rem;
  border-left: 3px solid var(--jade-600);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--jade-50);
  color: var(--ink-700);
  font-size: 0.7rem;
}

.insight-icon {
  color: var(--jade-800);
  font-size: 0.9rem;
  font-weight: 850;
}

.capability-list {
  display: grid;
  gap: 0.25rem;
}

.capability {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.capability:last-child {
  border-bottom: 0;
}

.capability-ring {
  display: grid;
  width: 2.55rem;
  height: 2.55rem;
  place-items: center;
  border: 4px solid var(--jade-100);
  border-top-color: var(--jade-600);
  border-right-color: var(--jade-600);
  border-radius: 50%;
  background: var(--surface-raised);
  color: var(--jade-800);
}

.capability-ring span {
  font-size: 0.64rem;
  font-variant-numeric: tabular-nums;
  font-weight: 820;
}

.capability strong,
.capability small {
  display: block;
}

.capability strong {
  font-size: 0.76rem;
}

.capability small {
  margin-top: 0.1rem;
  color: var(--text-muted);
  font-size: 0.63rem;
}

.capability-state {
  color: var(--jade-800);
  font-size: 0.62rem;
  font-weight: 760;
}

.capability-state.warning {
  color: var(--amber-700);
}

.timeline-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--text);
  font-size: 0.76rem;
}

.timeline-heading time {
  color: var(--text-faint);
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
  font-weight: 560;
}

.timeline-item p {
  margin: 0.25rem 0 0.35rem;
  color: var(--text-muted);
  font-size: 0.68rem;
}

.timeline-item[data-state="abstain"] .timeline-marker {
  border-color: var(--amber-500);
  background: var(--amber-50);
}

.timeline-item[data-state="escalate"] .timeline-marker {
  border-color: var(--red-600);
  background: var(--red-50);
}

.reason-code {
  display: inline-flex;
  padding: 0.2rem 0.42rem;
  border-radius: var(--radius-xs);
  background: var(--surface-subtle);
  color: var(--ink-700);
  font-family: var(--font-mono);
  font-size: 0.57rem;
}

.gate-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0 1rem;
}

.gate-summary > div:first-child {
  display: grid;
}

.gate-summary strong {
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 820;
  letter-spacing: -0.04em;
}

.gate-summary span {
  color: var(--text-muted);
  font-size: 0.68rem;
}

.gate-summary .donut {
  width: 4.2rem;
  border-width: 0.45rem;
}

.gate-summary .donut > span,
.donut.mini > span {
  z-index: 1;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  font-weight: 820;
}

.check-list {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.check-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem;
}

.check {
  display: grid;
  width: 1.5rem;
  height: 1.5rem;
  place-items: center;
  border-radius: 50%;
  font-size: 0.67rem;
  font-weight: 820;
}

.check.pending {
  background: var(--amber-50);
  color: var(--amber-700);
}

.check.done {
  background: var(--jade-50);
  color: var(--jade-800);
}

.check .icon {
  width: 0.78rem;
  height: 0.78rem;
}

.check-list strong,
.check-list small {
  display: block;
}

.check-list strong { font-size: 0.72rem; }
.check-list small { margin-top: 0.08rem; color: var(--text-muted); font-size: 0.62rem; }

/* Patient view */
.patient-layout {
  display: grid;
  grid-template-columns: minmax(20rem, 0.82fr) minmax(0, 1.4fr);
  align-items: start;
  gap: 1rem;
}

.patient-details {
  display: grid;
  gap: 1rem;
}

.phone-mockup {
  overflow: hidden;
}

.phone-status {
  position: absolute;
  z-index: 4;
  top: 0.66rem;
  left: 0.62rem;
  display: flex;
  width: calc(100% - 1.24rem);
  height: 2.25rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.25rem 0;
  color: var(--ink-800);
  font-size: 0.57rem;
  font-weight: 780;
  pointer-events: none;
}

.phone-screen {
  padding: 2.55rem 1rem 5.2rem;
}

.patient-greeting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.patient-greeting small,
.patient-greeting strong {
  display: block;
}

.patient-greeting small {
  color: var(--text-muted);
  font-size: 0.66rem;
}

.patient-greeting strong {
  margin-top: 0.12rem;
  font-size: 1.05rem;
}

.patient-avatar {
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  place-items: center;
  border-radius: 50%;
  background: var(--coral-100);
  color: var(--coral-700);
  font-size: 0.7rem;
  font-weight: 830;
}

.day-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

.day-score span,
.day-score strong,
.day-score small {
  display: block;
}

.day-score span { color: var(--text-muted); font-size: 0.61rem; }
.day-score strong { margin-top: 0.1rem; font-size: 0.78rem; }
.day-score small { margin-top: 0.12rem; color: var(--text-muted); font-size: 0.6rem; }

.donut.mini {
  width: 3.45rem;
  border-width: 0.36rem;
}

.next-moment {
  margin-top: 0.72rem;
  padding: 0.9rem;
  border: 1px solid #b8dbcf;
  border-radius: var(--radius-md);
  background: var(--jade-50);
}

.next-moment > strong,
.next-moment > p {
  display: block;
}

.next-moment > strong {
  margin-top: 0.16rem;
  color: var(--jade-800);
  font-size: 0.82rem;
}

.next-moment > p {
  margin: 0.25rem 0 0.7rem;
  color: var(--ink-700);
  font-size: 0.66rem;
}

.phone-label {
  color: var(--text-muted);
  font-size: 0.57rem;
  font-weight: 760;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.button-full {
  width: 100%;
}

.micro-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.65rem;
  margin-top: 0.72rem;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}

.micro-icon {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 0.65rem;
  background: var(--jade-50);
}

.micro-card strong {
  display: block;
  margin-top: 0.12rem;
  font-size: 0.75rem;
}

.micro-card p {
  margin: 0.2rem 0 0.45rem;
  color: var(--text-muted);
  font-size: 0.62rem;
}

.phone-nav {
  grid-template-columns: repeat(4, 1fr);
}

.phone-nav button {
  border: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 0.61rem;
  font-weight: 690;
}

.phone-nav button.active {
  color: var(--petrol-800);
  box-shadow: inset 0 -2px 0 var(--petrol-700);
}

.patient-phone-panel {
  min-height: 26rem;
}

.patient-phone-panel[hidden] {
  display: none;
}

.phone-panel-heading {
  display: grid;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.phone-panel-heading > strong {
  color: var(--ink-900);
  font-size: 1rem;
}

.phone-panel-heading p,
.phone-info-note p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.66rem;
  line-height: 1.5;
}

.phone-log-card,
.phone-progress-score {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}

.phone-log-card > div,
.phone-progress-score > div:last-child {
  display: grid;
  gap: 0.2rem;
}

.phone-log-card strong,
.phone-progress-score strong {
  font-size: 0.76rem;
}

.phone-log-card small,
.phone-progress-score small,
.phone-milestones small {
  color: var(--text-muted);
  font-size: 0.61rem;
  line-height: 1.4;
}

.phone-log-icon {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 0.75rem;
  background: var(--petrol-100);
  color: var(--petrol-800);
  font-size: 1.15rem;
}

.phone-info-note {
  margin-top: 0.9rem;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: var(--jade-50);
}

.phone-info-note strong {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.7rem;
}

.phone-milestones {
  display: grid;
  gap: 0.55rem;
}

.phone-milestones > div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
}

.phone-milestones > div > span {
  display: grid;
  width: 1.55rem;
  height: 1.55rem;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 850;
}

.phone-milestones > div.is-complete {
  border-color: #b8dbcf;
  background: var(--jade-50);
}

.phone-milestones > div.is-complete > span {
  background: var(--jade-100);
  color: var(--jade-800);
}

.progress-screen-heading {
  margin-bottom: 0.68rem;
  padding: 0 0.1rem;
}

.progress-screen-heading .progress-eyebrow { margin: 0; color: var(--coral-600); font-size: 0.48rem; font-weight: 880; letter-spacing: 0.08em; }
.progress-screen-heading h2 { margin: 0.16rem 0 0.18rem; color: var(--petrol-950); font-size: 1.02rem; line-height: 1.15; }
.progress-screen-heading p { margin: 0; color: var(--text-muted); font-size: 0.58rem; line-height: 1.45; }

.progress-motivation-hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 0.65rem;
  padding: 0.9rem;
  border-radius: 1rem;
  background: linear-gradient(145deg, var(--petrol-900), var(--petrol-700) 62%, var(--jade-700));
  color: white;
  box-shadow: 0 10px 24px rgb(8 76 89 / 0.2);
}

.progress-motivation-hero::after {
  position: absolute;
  top: -2.2rem;
  right: -2rem;
  width: 7rem;
  height: 7rem;
  border: 1.1rem solid rgb(255 255 255 / 0.07);
  border-radius: 50%;
  content: "";
}

.progress-motivation-hero .phone-label { margin: 0; color: #bceade; }
.progress-purpose-head { position: relative; z-index: 1; display: flex; align-items: flex-start; justify-content: space-between; gap: 0.6rem; }
.progress-purpose-head > div { display: grid; gap: 0.08rem; }
.progress-purpose-mark { display: grid; width: 2.1rem; height: 2.1rem; flex: 0 0 auto; place-items: center; border: 1px solid rgb(255 255 255 / 0.18); border-radius: 0.72rem; background: rgb(255 255 255 / 0.09); color: #bceade; font-size: 0.95rem; }
.progress-motivation-hero h3 { position: relative; z-index: 1; margin: 0.08rem 0 0.3rem; max-width: 13rem; color: #fff; font-size: 1rem; line-height: 1.16; }
.progress-motivation-hero > p { position: relative; z-index: 1; margin: 0; color: rgb(255 255 255 / 0.8); font-size: 0.61rem; line-height: 1.48; }

.progress-hero-metrics {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.75rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgb(255 255 255 / 0.16);
}

.progress-hero-metrics .donut {
  --donut-color: #72d7bd;
  width: 3.3rem;
  border: 0;
  background: conic-gradient(var(--donut-color) calc(var(--value) * 1%), rgb(255 255 255 / 0.16) 0);
  box-shadow: none;
}

.progress-hero-metrics .donut::after { width: 73%; background: var(--petrol-800); }
.progress-hero-metrics .donut > span { z-index: 2; color: white; }
.progress-hero-metrics > div:last-child { display: grid; gap: 0.12rem; }
.progress-hero-metrics h4 { margin: 0; color: #fff; font-size: 0.69rem; line-height: 1.3; }
.progress-hero-metrics p { margin: 0; color: rgb(255 255 255 / 0.72); font-size: 0.54rem; line-height: 1.4; }

.progress-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.progress-kpi-row > div {
  display: grid;
  min-width: 0;
  justify-items: center;
  gap: 0.08rem;
  padding: 0.52rem 0.25rem;
  border: 1px solid var(--border);
  border-radius: 0.72rem;
  background: var(--surface-raised);
  box-shadow: 0 3px 10px rgb(16 43 48 / 0.04);
}

.progress-kpi-row span { display: grid; width: 1.45rem; height: 1.45rem; place-items: center; border-radius: 0.48rem; background: var(--jade-50); color: var(--jade-700); font-size: 0.65rem; font-weight: 850; }
.progress-kpi-row strong { margin-top: 0.05rem; color: var(--petrol-950); font-size: 0.72rem; }
.progress-kpi-row p { overflow: hidden; max-width: 100%; margin: 0; color: var(--text-muted); font-size: 0.45rem; text-align: center; text-overflow: ellipsis; white-space: nowrap; }

.progress-data-card {
  margin-bottom: 0.58rem;
  padding: 0.72rem;
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  background: var(--surface-raised);
  box-shadow: 0 5px 14px rgb(16 43 48 / 0.05);
}

.progress-data-card > header { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.65rem; }
.progress-data-card > header > div { display: grid; gap: 0.08rem; }
.progress-data-card .progress-card-kicker { margin: 0; color: var(--jade-700); font-size: 0.46rem; font-weight: 850; letter-spacing: 0.06em; }
.progress-data-card > header h3 { margin: 0; color: var(--petrol-950); font-size: 0.72rem; line-height: 1.25; }
.progress-data-card > header output { display: grid; min-width: 2.2rem; height: 2.2rem; place-items: center; border-radius: 0.68rem; background: var(--jade-50); color: var(--jade-800); font-size: 0.72rem; font-weight: 850; }

.progress-stage-chart { display: grid; gap: 0.52rem; }
.progress-stage-chart > div { display: grid; grid-template-columns: 6.6rem minmax(0, 1fr); align-items: center; gap: 0.48rem; }
.progress-stage-chart > div > div { display: grid; gap: 0.04rem; }
.progress-stage-chart h4 { margin: 0; color: var(--petrol-950); font-size: 0.58rem; line-height: 1.3; }
.progress-stage-chart p { margin: 0; color: var(--text-muted); font-size: 0.47rem; line-height: 1.35; }
.progress-stage-chart > div > span { display: block; height: 0.46rem; overflow: hidden; border-radius: 999px; background: var(--ivory-200); }
.progress-stage-chart i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--jade-600), var(--jade-400)); transition: width 480ms var(--ease-standard); }
.progress-stage-chart > div:not(.is-complete) i { background: var(--coral-400); }

.progress-week-chart { display: grid; height: 5.7rem; grid-template-columns: repeat(7, minmax(0, 1fr)); align-items: end; gap: 0.25rem; }
.progress-week-chart > div { display: grid; height: 100%; grid-template-rows: 0.8rem minmax(0, 1fr) 0.75rem; justify-items: center; gap: 0.15rem; }
.progress-week-chart > div > strong { color: var(--text-muted); font-size: 0.48rem; }
.progress-week-chart > div > span { position: relative; display: flex; width: 100%; align-items: flex-end; justify-content: center; overflow: hidden; border-radius: 0.35rem; background: var(--surface-subtle); }
.progress-week-chart i { display: block; width: 58%; min-height: 0.22rem; border-radius: 0.25rem 0.25rem 0.12rem 0.12rem; background: linear-gradient(180deg, var(--coral-400), var(--coral-600)); transition: height 480ms var(--ease-standard); }
.progress-week-chart small { color: var(--text-muted); font-size: 0.45rem; font-weight: 760; }
.progress-week-chart .is-today small { color: var(--coral-600); }
.progress-week-chart .is-today > span { box-shadow: inset 0 0 0 1px var(--coral-300); }
.progress-truth-note { margin: 0.55rem 0 0; color: var(--text-muted); font-size: 0.5rem; line-height: 1.4; }

.progress-accountability {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.55rem;
  padding: 0.76rem;
  border: 1px solid #e8c7a0;
  border-radius: 0.9rem;
  background: linear-gradient(145deg, #fff8eb, #fffdf9);
}

.progress-accountability.is-reward { border-color: #a9d8c9; background: linear-gradient(145deg, #e9f8f3, #f9fffd); }
.progress-accountability-icon { display: grid; width: 1.85rem; height: 1.85rem; place-items: center; border-radius: 0.55rem; background: #ffe6bd; color: #9a5a00; font-size: 0.85rem; }
.progress-accountability.is-reward .progress-accountability-icon { background: var(--jade-100); color: var(--jade-800); }
.progress-accountability > div { display: grid; gap: 0.12rem; }
.progress-accountability small { color: #9a5a00; font-size: 0.44rem; font-weight: 880; letter-spacing: 0.06em; }
.progress-accountability.is-reward small { color: var(--jade-700); }
.progress-accountability strong { color: var(--petrol-950); font-size: 0.68rem; }
.progress-accountability p { margin: 0; color: var(--text-muted); font-size: 0.54rem; line-height: 1.42; }
.progress-accountability button { grid-column: 2; justify-self: start; margin-top: 0.22rem; padding: 0.36rem 0.58rem; border: 0; border-radius: 0.48rem; background: var(--petrol-800); color: white; font: inherit; font-size: 0.51rem; font-weight: 780; cursor: pointer; }

.diet-phone-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}

.diet-phone-head strong {
  display: block;
  margin-top: 0.1rem;
  font-size: 1rem;
}

.diet-phone-head > div { display: grid; gap: 0.08rem; }

#diet-calendar-status {
  max-width: 14rem;
  margin-top: 0.15rem;
  color: var(--text-muted);
  font-size: 0.48rem;
  font-weight: 650;
  line-height: 1.35;
}

.diet-plan-badge {
  padding: 0.3rem 0.5rem;
  border-radius: 999px;
  background: var(--amber-50);
  color: var(--amber-700);
  font-size: 0.56rem;
  font-weight: 800;
}

.diet-day-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.2rem;
  margin-bottom: 0.65rem;
}

.diet-day-strip button {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
  padding: 0.35rem 0.1rem;
  border: 0;
  border-radius: 0.55rem;
  background: var(--surface-subtle);
  color: var(--text-muted);
  cursor: pointer;
}

.diet-day-strip button.active {
  background: var(--coral-600);
  color: white;
  box-shadow: 0 4px 10px rgb(223 99 73 / 0.24);
}

.diet-day-strip button.is-today:not(.active) {
  border-color: var(--jade-500);
  box-shadow: inset 0 0 0 1px var(--jade-500);
}

.diet-day-strip small {
  overflow: hidden;
  font-size: 0.48rem;
  text-overflow: clip;
}

.diet-day-strip strong {
  font-size: 0.62rem;
}

.diet-calorie-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}

.diet-ring {
  display: grid;
  width: 4.5rem;
  height: 4.5rem;
  place-content: center;
  border: 0.48rem solid var(--coral-100);
  border-top-color: var(--coral-600);
  border-right-color: var(--coral-600);
  border-radius: 50%;
  text-align: center;
  transform: rotate(-18deg);
}

.diet-ring > * {
  transform: rotate(18deg);
}

.diet-ring strong {
  font-size: 0.9rem;
}

.diet-ring small {
  color: var(--text-muted);
  font-size: 0.5rem;
}

.diet-macros {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.25rem;
}

.diet-macros span {
  display: grid;
  min-width: 0;
  gap: 0.1rem;
  text-align: center;
}

.diet-macros i {
  width: 0.45rem;
  height: 0.45rem;
  margin: auto;
  border-radius: 50%;
}

.macro-protein { background: var(--blue-700); }
.macro-carbs { background: var(--jade-600); }
.macro-fat { background: var(--amber-500); }
.diet-macros strong { font-size: 0.58rem; }
.diet-macros small { overflow: hidden; color: var(--text-muted); font-size: 0.45rem; text-overflow: ellipsis; }

.diet-meal-list {
  display: grid;
  gap: 0.38rem;
}

.diet-meal-list article {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
}

.diet-meal-icon {
  display: grid;
  width: 1.7rem;
  height: 1.7rem;
  place-items: center;
  border-radius: 0.5rem;
  background: var(--jade-50);
  color: var(--jade-800);
  font-size: 0.72rem;
}

.diet-meal-list article > div {
  display: grid;
  gap: 0.08rem;
}

.diet-meal-list small { color: var(--text-muted); font-size: 0.5rem; }
.diet-meal-list strong { font-size: 0.62rem; line-height: 1.35; }

.diet-meal-list .diet-meal-card {
  display: block;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
}

.diet-meal-list .diet-meal-card.is-open {
  border-color: var(--jade-400);
  box-shadow: 0 0 0 2px rgb(49 151 126 / 0.1);
}

.diet-meal-trigger {
  display: grid;
  width: 100%;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.62rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.diet-meal-trigger:hover { background: var(--jade-50); }
.diet-meal-trigger:focus-visible { outline: 2px solid var(--jade-600); outline-offset: -2px; }

.diet-meal-copy {
  display: grid;
  min-width: 0;
  gap: 0.08rem;
}

.diet-meal-copy small { color: var(--text-muted); font-size: 0.5rem; }
.diet-meal-copy strong { font-size: 0.62rem; line-height: 1.35; }
.diet-meal-copy em { color: var(--jade-700); font-size: 0.48rem; font-style: normal; font-weight: 750; }

.diet-meal-chevron {
  color: var(--jade-700);
  font-size: 1rem;
  line-height: 1;
  transition: transform var(--duration-fast) var(--ease-standard);
}

.diet-meal-card.is-open .diet-meal-chevron { transform: rotate(180deg); }

.diet-meal-options {
  padding: 0.18rem 0.62rem 0.65rem 2.88rem;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, var(--jade-50), var(--surface-raised));
}

.diet-meal-options[hidden] { display: none; }
.diet-options-label { display: block; margin: 0.52rem 0 0.4rem; color: var(--petrol-800); font-size: 0.52rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
.diet-meal-options ol { display: grid; gap: 0.38rem; margin: 0; padding: 0; list-style: none; }
.diet-meal-options li { display: grid; grid-template-columns: 1.25rem minmax(0, 1fr) auto; align-items: center; gap: 0.42rem; padding: 0.45rem; border: 1px solid rgb(8 76 89 / 0.1); border-radius: 0.55rem; background: rgb(255 255 255 / 0.88); }
.diet-meal-options li > span { display: grid; width: 1.25rem; height: 1.25rem; place-items: center; border-radius: 50%; background: var(--jade-100); color: var(--jade-800); font-size: 0.56rem; font-weight: 850; }
.diet-meal-options li p { margin: 0; color: var(--text); font-size: 0.58rem; font-weight: 680; line-height: 1.4; }
.diet-meal-options li small { color: var(--jade-700); font-size: 0.45rem; font-weight: 760; white-space: nowrap; }

@media (max-width: 30rem) {
  .diet-meal-options { padding-left: 0.62rem; }
  .diet-meal-options li { grid-template-columns: 1.25rem minmax(0, 1fr); }
  .diet-meal-options li small { grid-column: 2; }
}

.diet-day-note {
  margin-top: 0.5rem;
  padding: 0.55rem;
  border-radius: var(--radius-sm);
  background: var(--jade-50);
}

.diet-day-note strong { font-size: 0.58rem; }
.diet-day-note p { margin: 0.15rem 0 0; color: var(--text-muted); font-size: 0.52rem; line-height: 1.4; }
.diet-disclaimer { margin: 0.45rem 0 0; color: var(--amber-700); font-size: 0.5rem; line-height: 1.4; }

.diet-editor-card {
  margin: 1rem 0;
  border-left: 0.25rem solid var(--jade-600);
}

.diet-editor-toolbar,
.diet-meal-editor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.diet-meal-editor-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 64rem) {
  .diet-editor-toolbar,
  .diet-meal-editor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 36rem) {
  .diet-editor-toolbar,
  .diet-meal-editor-grid {
    grid-template-columns: 1fr;
  }
}

/* Intelligent patient companion */
.agent-welcome-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.7rem;
  margin: 0.75rem 0;
  padding: 0.82rem;
  border: 1px solid rgba(47, 143, 119, 0.25);
  border-radius: 1rem;
  background: linear-gradient(135deg, #eef9f5 0%, #f9fcfb 64%, #fff4ed 100%);
  box-shadow: 0 0.45rem 1.15rem rgba(9, 73, 86, 0.08);
}

.agent-welcome-card > div:last-child { display: grid; gap: 0.2rem; min-width: 0; }
.agent-welcome-card strong { color: var(--petrol-900); font-size: 0.9rem; line-height: 1.3; }
.agent-welcome-card p { margin: 0; color: var(--text-muted); font-size: 0.72rem; line-height: 1.4; }
.agent-welcome-card .text-button { justify-self: start; margin-top: 0.15rem; font-size: 0.72rem; }
.agent-welcome-icon,
.agent-avatar {
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(145deg, var(--petrol-700), var(--jade-500));
  box-shadow: 0 0.35rem 0.9rem rgba(8, 78, 91, 0.2);
}
.agent-welcome-icon { width: 2.2rem; height: 2.2rem; border-radius: 0.75rem; }

.agent-launcher {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 85;
  display: none;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 0.65rem;
  min-width: 10.25rem;
  padding: 0.65rem 0.85rem 0.65rem 0.65rem;
  border: 0;
  border-radius: 1rem;
  color: white;
  background: linear-gradient(135deg, #075766, #0b7b74);
  box-shadow: 0 0.8rem 2.1rem rgba(4, 58, 71, 0.3);
  cursor: pointer;
}
body[data-profile="patient"] .agent-launcher { display: grid; }
.agent-launcher > span:first-child { display: grid; width: 2.25rem; height: 2.25rem; place-items: center; border-radius: 0.72rem; background: rgba(255,255,255,0.14); font-size: 1.05rem; }
.agent-launcher > span:nth-child(2) { display: grid; text-align: left; }
.agent-launcher strong { font-size: 0.78rem; }
.agent-launcher small { color: rgba(255,255,255,0.76); font-size: 0.62rem; }
.agent-launcher b { position: absolute; top: -0.3rem; right: -0.25rem; display: grid; width: 1.25rem; height: 1.25rem; place-items: center; border-radius: 50%; background: var(--coral-500); font-size: 0.68rem; }

.agent-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 90;
  display: grid;
  grid-template-rows: auto auto auto minmax(10rem, 1fr) auto auto auto;
  width: min(25rem, calc(100vw - 1.5rem));
  height: min(44rem, calc(100vh - 2rem));
  overflow: hidden;
  border: 1px solid rgba(7, 87, 102, 0.2);
  border-radius: 1.35rem;
  background: #fbfdfc;
  box-shadow: 0 1.4rem 4rem rgba(4, 42, 51, 0.28);
  transform: translateY(1rem) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
.agent-panel.is-open { transform: none; opacity: 1; pointer-events: auto; }
.agent-panel-header { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.75rem; align-items: center; padding: 1rem; color: white; background: linear-gradient(135deg, #064f5d, #0b776f); }
.agent-avatar { width: 2.65rem; height: 2.65rem; border-radius: 0.85rem; background: rgba(255,255,255,0.14); box-shadow: none; }
.agent-panel-header small { color: rgba(255,255,255,0.72); font-size: 0.61rem; font-weight: 800; letter-spacing: 0.08em; }
.agent-panel-header h2 { margin: 0.12rem 0; color: white; font-size: 1rem; }
.agent-panel-header span { display: flex; align-items: center; gap: 0.35rem; color: rgba(255,255,255,0.78); font-size: 0.67rem; }
.agent-panel-header span i { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: #76e2bf; box-shadow: 0 0 0 0.18rem rgba(118,226,191,0.16); }
.agent-panel-header button { display: grid; width: 2rem; height: 2rem; place-items: center; border: 0; border-radius: 0.65rem; color: white; background: rgba(255,255,255,0.12); cursor: pointer; }

.agent-progress { display: grid; gap: 0.45rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); background: white; }
.agent-progress > div:first-child { display: flex; justify-content: space-between; gap: 0.75rem; font-size: 0.68rem; }
.agent-progress span { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-progress strong { color: var(--petrol-800); white-space: nowrap; }
.agent-progress .progress-track { height: 0.35rem; }
.agent-progress .progress-track span { background: linear-gradient(90deg, var(--jade-500), var(--petrol-500)); }
.agent-motivation { display: grid; gap: 0.15rem; margin: 0.7rem 0.8rem 0; padding: 0.7rem 0.8rem; border-radius: 0.85rem; color: var(--petrol-900); background: #edf8f4; }
.agent-motivation strong { font-size: 0.78rem; }
.agent-motivation span { color: var(--text-muted); font-size: 0.68rem; }

.agent-chat { display: flex; flex-direction: column; gap: 0.65rem; overflow-x: hidden; overflow-y: auto; padding: 0.85rem; scroll-behavior: smooth; }
.agent-message { display: grid; gap: 0.3rem; max-width: 88%; min-width: 0; padding: 0.7rem 0.78rem; border-radius: 0.9rem; overflow-wrap: anywhere; font-size: 0.75rem; line-height: 1.48; }
.agent-message.agent { align-self: flex-start; border-bottom-left-radius: 0.25rem; color: var(--text); background: white; box-shadow: 0 0.25rem 0.8rem rgba(9, 70, 82, 0.09); }
.agent-message.user { align-self: flex-end; border-bottom-right-radius: 0.25rem; color: white; background: var(--petrol-700); }
.agent-message small { color: inherit; opacity: 0.63; font-size: 0.61rem; }
.agent-message .agent-reason { padding-top: 0.28rem; border-top: 1px solid rgba(9, 70, 82, 0.1); color: var(--text-muted); font-size: 0.63rem; }
.agent-message.is-alert { border: 1px solid rgba(210, 91, 72, 0.28); background: #fff3f0; }
.agent-typing { display: inline-flex; gap: 0.2rem; }
.agent-typing i { width: 0.35rem; height: 0.35rem; border-radius: 50%; background: var(--petrol-400); animation: agent-pulse 1s infinite alternate; }
.agent-typing i:nth-child(2) { animation-delay: 150ms; }
.agent-typing i:nth-child(3) { animation-delay: 300ms; }
@keyframes agent-pulse { to { opacity: 0.25; transform: translateY(-0.12rem); } }

.agent-quick-actions { display: flex; gap: 0.4rem; overflow-x: auto; padding: 0 0.8rem 0.65rem; scrollbar-width: none; }
.agent-quick-actions::-webkit-scrollbar { display: none; }
.agent-quick-actions button { flex: 0 0 auto; padding: 0.48rem 0.62rem; border: 1px solid #b8d9d1; border-radius: 999px; color: var(--petrol-800); background: white; font-size: 0.65rem; font-weight: 750; cursor: pointer; }
.agent-quick-actions .icon { width: 0.8rem; height: 0.8rem; }
.agent-composer { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 0.4rem; align-items: end; padding: 0.7rem 0.8rem; border-top: 1px solid var(--border); background: white; }
.agent-composer textarea { min-height: 2.4rem; max-height: 5.5rem; resize: none; padding: 0.65rem 0.7rem; border: 1px solid var(--border); border-radius: 0.75rem; font: inherit; font-size: 0.73rem; }
.agent-tool-button, .agent-send-button { display: grid; width: 2.4rem; height: 2.4rem; place-items: center; border: 0; border-radius: 0.75rem; cursor: pointer; }
.agent-tool-button { color: var(--petrol-800); background: var(--surface-subtle); }
.agent-tool-button.is-listening { color: white; background: var(--coral-500); }
.agent-send-button { color: white; background: var(--petrol-700); }
.agent-send-button .icon { width: 1rem; height: 1rem; }
.agent-panel footer { display: flex; justify-content: space-between; gap: 0.5rem; align-items: center; padding: 0.45rem 0.8rem 0.6rem; color: var(--text-faint); background: white; font-size: 0.58rem; }
.agent-panel footer .text-button { font-size: 0.6rem; white-space: nowrap; }

.agent-supervision-card { margin: 1rem 0; border-left: 0.25rem solid var(--jade-500); }
.agent-supervision-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.65rem; }
.agent-supervision-metrics > div { display: grid; gap: 0.25rem; padding: 0.75rem; border-radius: 0.8rem; background: var(--surface-subtle); }
.agent-supervision-metrics small { color: var(--text-muted); font-size: 0.66rem; font-weight: 750; }
.agent-supervision-metrics strong { color: var(--petrol-900); font-size: 1rem; }
.agent-alert-list { display: grid; gap: 0.55rem; margin-top: 0.8rem; }
.agent-alert-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.65rem; align-items: center; padding: 0.75rem; border: 1px solid #efc8be; border-radius: 0.8rem; background: #fff8f6; }
.agent-alert-item > span { display: grid; width: 1.85rem; height: 1.85rem; place-items: center; border-radius: 0.6rem; color: #9d3f32; background: #ffe4dd; font-weight: 850; }
.agent-alert-item div { display: grid; gap: 0.15rem; }
.agent-alert-item small { color: var(--text-muted); }
.agent-alert-item button { padding: 0.4rem 0.55rem; border: 1px solid var(--border); border-radius: 0.55rem; color: var(--petrol-800); background: white; font-size: 0.65rem; font-weight: 750; cursor: pointer; }
.agent-empty-state { padding: 0.85rem; border: 1px dashed var(--border); border-radius: 0.8rem; color: var(--text-muted); text-align: center; font-size: 0.75rem; }

/* Sara · professional nutrition copilot */
.sara-workspace { margin: 1rem 0; border: 1px solid rgba(114, 86, 184, 0.18); background: linear-gradient(180deg, #fff 0%, #fcfbff 100%); }
.sara-header, .sara-identity { display: flex; align-items: center; }
.sara-header { justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.sara-identity { gap: 0.8rem; }
.sara-identity h2 { margin: 0.05rem 0; }
.sara-identity p { margin: 0; color: var(--text-muted); font-size: 0.78rem; }
.sara-avatar { display: grid; width: 3rem; height: 3rem; place-items: center; border-radius: 1rem; color: white; background: linear-gradient(145deg, #5f4aa8, #0b7b74); box-shadow: 0 0.5rem 1rem rgba(75, 57, 142, 0.2); font-size: 1rem; font-weight: 900; }
.sara-toolbar { display: grid; grid-template-columns: 1fr 0.8fr 2fr auto; gap: 0.7rem; align-items: end; }
.sara-instruction textarea { min-height: 2.75rem; }
.sara-eligibility { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.7rem; align-items: center; margin-top: 0.9rem; padding: 0.8rem; border-radius: 0.85rem; color: var(--petrol-900); background: #edf8f4; }
.sara-eligibility > span { display: grid; width: 2rem; height: 2rem; place-items: center; border-radius: 0.65rem; color: white; background: var(--jade-500); font-weight: 900; }
.sara-eligibility p { margin: 0.15rem 0 0; color: var(--text-muted); font-size: 0.72rem; }
.sara-eligibility.is-blocked { color: #8d342b; background: #fff2ef; }
.sara-eligibility.is-blocked > span { background: var(--coral-500); }
.sara-plan { margin-top: 1rem; }
.sara-plan-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.55rem; }
.sara-plan-summary > div { display: grid; gap: 0.2rem; padding: 0.7rem; border: 1px solid var(--border); border-radius: 0.75rem; background: white; }
.sara-plan-summary small { color: var(--text-muted); font-size: 0.65rem; font-weight: 750; }
.sara-plan-summary strong { color: var(--petrol-900); font-size: 0.92rem; }
.sara-plan-tabs { display: flex; gap: 0.45rem; margin: 0.9rem 0 0.65rem; }
.sara-plan-tabs button { padding: 0.48rem 0.72rem; border: 1px solid var(--border); border-radius: 0.65rem; color: var(--petrol-800); background: white; font-size: 0.72rem; font-weight: 800; cursor: pointer; }
.sara-plan-tabs button.active { color: white; border-color: var(--petrol-700); background: var(--petrol-700); }
.sara-days { display: grid; gap: 0.65rem; }
.sara-day { overflow: hidden; border: 1px solid var(--border); border-radius: 0.85rem; background: white; }
.sara-day > header { display: flex; justify-content: space-between; align-items: center; padding: 0.65rem 0.8rem; background: var(--surface-subtle); }
.sara-day > header strong { color: var(--petrol-900); }
.sara-day > header small { color: var(--text-muted); }
.sara-meals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.sara-meal { padding: 0.75rem; border-right: 1px solid var(--border); }
.sara-meal:last-child { border-right: 0; }
.sara-meal > strong { display: block; margin-bottom: 0.45rem; color: var(--petrol-800); font-size: 0.72rem; text-transform: uppercase; }
.sara-meal ol { margin: 0; padding-left: 1.15rem; color: var(--text); font-size: 0.72rem; line-height: 1.48; }
.sara-meal li + li { margin-top: 0.35rem; }
.sara-snack { padding: 0.55rem 0.8rem; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 0.7rem; }
.sara-explanation { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; margin-top: 0.8rem; }
.sara-explanation > div { padding: 0.75rem; border-radius: 0.8rem; background: var(--surface-subtle); }
.sara-explanation strong { display: block; margin-bottom: 0.35rem; color: var(--petrol-900); font-size: 0.75rem; }
.sara-explanation ul { margin: 0; padding-left: 1rem; color: var(--text-muted); font-size: 0.7rem; line-height: 1.5; }
.sara-approval-actions { display: flex; justify-content: flex-end; gap: 0.55rem; margin-top: 0.9rem; }
.sara-feedback { display: grid; grid-template-columns: 1fr 2fr 1fr auto auto; gap: 0.65rem; align-items: end; margin-top: 1rem; padding: 0.8rem; border: 1px solid #d9d0ef; border-radius: 0.85rem; background: #f8f5ff; }
.sara-feedback > div:first-child { display: grid; gap: 0.15rem; }
.sara-feedback small { color: var(--text-muted); }
.sara-score-buttons { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.sara-score-buttons button { padding: 0.4rem 0.5rem; border: 1px solid #cfc5e6; border-radius: 0.55rem; color: #514080; background: white; font-size: 0.62rem; font-weight: 800; cursor: pointer; }
.sara-score-buttons button.active { color: white; background: #6049a7; }
.sara-learning-check { display: flex; align-items: center; gap: 0.35rem; padding-bottom: 0.65rem; color: var(--text-muted); font-size: 0.7rem; white-space: nowrap; }
.sara-daily-summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.7rem; align-items: start; margin-top: 1rem; padding: 0.85rem; border-top: 1px solid var(--border); }
.sara-daily-summary h3 { margin: 0.15rem 0 0; font-size: 0.95rem; }
#sara-summary-content { grid-column: 1 / -1; }
#sara-summary-content p { margin: 0; color: var(--text-muted); }
.sara-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.55rem; }
.sara-summary-grid > div { padding: 0.65rem; border-radius: 0.7rem; background: var(--surface-subtle); }
.sara-summary-grid small, .sara-summary-grid strong { display: block; }
.sara-summary-grid small { color: var(--text-muted); font-size: 0.62rem; }
.sara-summary-grid strong { margin-top: 0.2rem; color: var(--petrol-900); font-size: 0.8rem; }
.sara-summary-history { display: grid; gap: 0.75rem; }
.sara-summary-history article { display: grid; gap: 0.65rem; padding: 0.85rem; border: 1px solid var(--border); border-radius: 0.9rem; background: rgba(255, 255, 255, 0.62); }
.sara-summary-history article > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.sara-summary-history article small { color: var(--text-muted); }
.sara-shopping-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.65rem; }
.sara-shopping-grid > div { padding: 0.8rem; border-radius: 0.8rem; background: white; border: 1px solid var(--border); }
.sara-shopping-grid strong { display: block; margin-bottom: 0.35rem; color: var(--petrol-900); }
.sara-shopping-grid p { margin: 0; color: var(--text-muted); font-size: 0.72rem; line-height: 1.5; }

.patient-fortnight-plan { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid rgba(7,87,102,0.14); }
.patient-fortnight-plan > strong { display: block; color: var(--petrol-900); font-size: 0.78rem; }
.patient-fortnight-plan > small { color: var(--text-muted); font-size: 0.65rem; }
.patient-fortnight-plan details { margin-top: 0.45rem; border: 1px solid var(--border); border-radius: 0.65rem; background: white; }
.patient-fortnight-plan summary { padding: 0.55rem; color: var(--petrol-800); font-size: 0.7rem; font-weight: 800; cursor: pointer; }
.patient-fortnight-plan ul { margin: 0; padding: 0 0.65rem 0.65rem 1.5rem; color: var(--text-muted); font-size: 0.66rem; line-height: 1.45; }

@media (max-width: 40rem) {
  .agent-launcher { right: 0.7rem; bottom: 0.7rem; min-width: 0; }
  .agent-launcher > span:nth-child(2) { display: none; }
  .agent-panel { right: 0; bottom: 0; width: 100%; height: min(92vh, 46rem); border-radius: 1.3rem 1.3rem 0 0; }
  .agent-supervision-metrics { grid-template-columns: 1fr; }
  .agent-alert-item { grid-template-columns: auto minmax(0, 1fr); }
  .agent-alert-item button { grid-column: 2; justify-self: start; }
  .sara-toolbar, .sara-plan-summary, .sara-meals, .sara-explanation, .sara-feedback, .sara-summary-grid, .sara-shopping-grid { grid-template-columns: 1fr; }
  .sara-feedback { align-items: stretch; }
  .sara-approval-actions { flex-direction: column; }
}

.signal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.signal {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.52rem;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--ivory-50);
}

.signal-icon {
  display: grid;
  width: 1.75rem;
  height: 1.75rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 0.55rem;
  background: var(--petrol-100);
  color: var(--petrol-800);
  font-weight: 820;
}

.signal small,
.signal strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.signal small { color: var(--text-muted); font-size: 0.6rem; }
.signal strong { margin-top: 0.08rem; font-size: 0.69rem; }

.meal-record {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  align-items: center;
  gap: 0.9rem;
}

.meal-visual,
.meal-dropzone {
  display: grid;
  min-height: 6.5rem;
  place-items: center;
  align-content: center;
  gap: 0.15rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--ivory-100);
  color: var(--text-muted);
  text-align: center;
}

.meal-visual > span {
  font-size: 2.2rem;
}

.meal-visual em {
  font-size: 0.56rem;
  font-style: normal;
}

.meal-copy > strong {
  font-size: 0.83rem;
}

.meal-copy > p {
  margin: 0.25rem 0 0.55rem;
  color: var(--text-muted);
  font-size: 0.69rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  padding: 0.2rem 0.42rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--ivory-50);
  color: var(--ink-700);
  font-size: 0.58rem;
  font-weight: 690;
}

.safety-explainer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.7rem;
  border-color: #b8dbcf;
  background: var(--jade-50);
}

.safety-explainer h2 {
  margin: 0;
  color: var(--jade-800);
  font-size: 0.86rem;
}

.safety-explainer p {
  margin: 0.25rem 0 0;
  color: var(--ink-700);
  font-size: 0.69rem;
}

/* Metabolic twin */
.twin-layout {
  display: grid;
  grid-template-columns: minmax(18rem, 0.78fr) minmax(0, 1.45fr);
  align-items: start;
  gap: 1rem;
}

.twin-controls {
  display: grid;
  gap: 0.95rem;
}

.twin-controls .card-header {
  margin-bottom: 0;
}

.range-control {
  display: grid;
  gap: 0.42rem;
}

.range-control > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.range-control strong {
  color: var(--ink-800);
  font-size: 0.7rem;
}

.range-control output {
  color: var(--petrol-800);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  font-weight: 810;
}

.range-control input[type="range"] {
  min-height: 1.15rem;
  cursor: pointer;
}

.field-group {
  display: grid;
  gap: 0.35rem;
}

.field-group > span,
.field-group > label,
.field-group:not(label) label {
  color: var(--ink-800);
  font-size: 0.7rem;
  font-weight: 700;
}

.prediction-head {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.75rem;
}

.prediction-head > div {
  min-width: 0;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--ivory-50);
}

.prediction-head small,
.prediction-head strong {
  display: block;
}

.prediction-head small {
  min-height: 2em;
  color: var(--text-muted);
  font-size: 0.59rem;
  line-height: 1.15;
}

.prediction-head strong {
  margin-top: 0.25rem;
  color: var(--text);
  font-size: clamp(1rem, 2.4vw, 1.35rem);
  font-variant-numeric: tabular-nums;
  font-weight: 810;
  letter-spacing: -0.03em;
}

.prediction-head strong span {
  color: var(--text-muted);
  font-size: 0.55em;
  font-weight: 650;
}

.twin-chart {
  min-height: 14rem;
  margin: 0.2rem 0 0.7rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--ivory-50);
}

.model-explanation {
  display: grid;
  gap: 0.48rem;
}

.model-explanation > div {
  display: grid;
  grid-template-columns: minmax(5rem, 0.85fr) minmax(7rem, 1fr) 2rem;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink-700);
  font-size: 0.65rem;
}

.explanation-bar {
  width: var(--bar, 0%);
  max-width: 100%;
  height: 0.44rem;
  border-radius: 999px;
  background: var(--petrol-700);
}

.explanation-bar.positive { background: var(--coral-600); }
.explanation-bar.negative { background: var(--jade-600); }
.explanation-bar.neutral { background: var(--amber-500); }

.model-explanation strong {
  font-weight: 680;
}

.model-explanation em {
  font-style: normal;
  font-variant-numeric: tabular-nums;
  font-weight: 780;
  text-align: right;
}

.fine-print {
  margin: 0.7rem 0 0;
  color: var(--text-muted);
  font-size: 0.61rem;
  line-height: 1.45;
}

/* Skill registry */
.skill-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.skill-summary > div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.1rem 0.55rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}

.summary-dot {
  width: 0.55rem;
  height: 0.55rem;
  grid-row: span 2;
  border-radius: 50%;
  background: var(--text-faint);
}

.summary-dot.active { background: var(--jade-600); }
.summary-dot.review { background: var(--amber-500); }
.summary-dot.blocked { background: var(--red-600); }

.skill-summary strong { font-size: 0.75rem; }
.skill-summary small { color: var(--text-muted); font-size: 0.61rem; }

.skill-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
}

.skill-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 14.5rem;
  flex-direction: column;
  padding: 1rem;
  overflow: hidden;
  border: 1px solid var(--risk-border, var(--border));
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

.skill-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 0.22rem;
  background: var(--risk-color, var(--petrol-700));
  content: "";
}

.skill-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.skill-glyph {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 0.65rem;
  background: var(--risk-bg, var(--petrol-50));
  color: var(--risk-color, var(--petrol-800));
  font-size: 0.68rem;
  font-weight: 830;
}

.skill-card h2 {
  margin: 0.85rem 0 0.35rem;
  font-size: 0.9rem;
}

.skill-card > p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.68rem;
}

.skill-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.8rem 0;
}

.skill-meta span {
  padding: 0.16rem 0.36rem;
  border-radius: var(--radius-xs);
  background: var(--surface-subtle);
  color: var(--ink-700);
  font-size: 0.55rem;
  font-weight: 650;
}

.skill-card > .text-button {
  margin-top: auto;
}

.execution-card {
  margin-top: 1rem;
}

.execution-flow {
  display: grid;
  grid-template-columns: minmax(7rem, 1fr) auto minmax(7rem, 1fr) auto minmax(7rem, 1fr) auto minmax(7rem, 1fr);
  align-items: center;
  gap: 0.45rem;
}

.execution-flow > div {
  display: grid;
  min-height: 5.5rem;
  align-content: center;
  justify-items: center;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--ivory-50);
  text-align: center;
}

.execution-flow > div > span {
  color: var(--coral-700);
  font-size: 0.58rem;
  font-weight: 840;
}

.execution-flow strong {
  margin-top: 0.18rem;
  font-size: 0.72rem;
}

.execution-flow small {
  margin-top: 0.12rem;
  color: var(--text-muted);
  font-size: 0.58rem;
}

.execution-flow > i {
  width: 1.2rem;
  height: 1px;
  background: var(--border-strong);
}

/* Human-in-the-loop */
.clinical-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(17rem, 0.65fr);
  align-items: start;
  gap: 1rem;
}

.hitl-queue {
  display: grid;
  gap: 0.8rem;
}

.review-card {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--risk-border, var(--border));
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

.review-side {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 0.9rem 0.65rem;
  background: var(--risk-bg, var(--ivory-50));
  color: var(--risk-color, var(--ink-700));
  text-align: center;
}

.risk-beacon {
  width: 0.7rem;
  height: 0.7rem;
  margin-bottom: 0.45rem;
  border-radius: 50%;
  background: var(--risk-color, var(--petrol-700));
  box-shadow: 0 0 0 4px var(--risk-border, var(--petrol-100));
}

.review-side small {
  font-size: 0.54rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.review-side strong {
  margin-top: 0.08rem;
  font-size: 0.8rem;
}

.review-side time {
  margin-top: 0.55rem;
  color: var(--text-muted);
  font-size: 0.58rem;
}

.review-content {
  min-width: 0;
  padding: 1rem;
}

.review-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.case-id {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.58rem;
}

.review-head h2 {
  margin: 0.2rem 0 0;
  font-size: 0.88rem;
}

.review-content > p {
  margin: 0.55rem 0;
  color: var(--text-muted);
  font-size: 0.69rem;
}

.rationale-box {
  display: grid;
  gap: 0.16rem;
  padding: 0.6rem 0.7rem;
  border-left: 3px solid var(--risk-color, var(--petrol-700));
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--risk-bg, var(--petrol-50));
}

.rationale-box strong {
  color: var(--risk-color, var(--petrol-800));
  font-size: 0.65rem;
}

.rationale-box span {
  color: var(--ink-700);
  font-size: 0.62rem;
}

.review-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.condition-data-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0.85rem 0;
}

.condition-data-card {
  display: grid;
  align-content: start;
  gap: 0.65rem;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}

.condition-data-card.is-inactive {
  opacity: 0.52;
}

.condition-data-card.is-inactive::after {
  content: "Se habilita al seleccionar este diagnóstico";
  color: var(--text-muted);
  font-size: 0.7rem;
}

.clinical-policy {
  position: sticky;
  top: calc(var(--topbar-height) + 1rem);
}

.policy-list {
  display: grid;
  gap: 0.55rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.policy-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.48rem;
  color: var(--ink-700);
  font-size: 0.68rem;
}

.policy-list .icon {
  width: 0.92rem;
  height: 0.92rem;
  color: var(--jade-700);
}

.policy-list li.blocked {
  color: var(--text-muted);
}

.policy-list li.blocked .icon {
  color: var(--red-600);
}

/* Audit */
.audit-chain {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid #b8dbcf;
  border-radius: var(--radius-lg);
  background: var(--jade-50);
}

.chain-icon {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  border-radius: 0.8rem;
  background: var(--jade-100);
  color: var(--jade-800);
}

.chain-icon .icon {
  width: 1.25rem;
  height: 1.25rem;
}

.audit-chain h2 {
  margin: 0;
  color: var(--jade-800);
  font-size: 0.92rem;
}

.audit-chain p {
  margin: 0.22rem 0 0;
  color: var(--ink-700);
  font-size: 0.64rem;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.search-field {
  position: relative;
  width: min(24rem, 100%);
}

.search-field > span {
  position: absolute;
  top: 50%;
  left: 0.75rem;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}

.search-field input {
  padding-left: 2.15rem !important;
}

.select-wrap {
  min-width: 11rem;
}

.data-table td strong,
.data-table td small {
  display: block;
}

.data-table td small {
  margin-top: 0.12rem;
  color: var(--text-muted);
  font-size: 0.61rem;
}

.event-id,
.hash-state {
  font-family: var(--font-mono);
  font-size: 0.64rem;
}

.hash-state {
  color: var(--jade-800);
  white-space: nowrap;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.75rem;
  color: var(--text-muted);
  font-size: 0.65rem;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pagination button {
  min-width: 2rem;
  min-height: 2rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface-raised);
  color: var(--ink-700);
  cursor: pointer;
  font-size: 0.64rem;
}

.pagination button:hover:not(:disabled),
.pagination button.active {
  border-color: var(--petrol-700);
  background: var(--petrol-50);
  color: var(--petrol-900);
}

.pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

/* Application modal composition */
.modal:has(.modal-panel) {
  position: fixed;
  z-index: 90;
  inset: 0;
  display: grid;
  width: 100%;
  max-height: none;
  place-items: center;
  overflow: auto;
  padding: 1rem;
  transform: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  animation: fade-in var(--duration-normal) var(--ease-standard);
}

.modal[aria-hidden="true"] {
  display: none;
}

.modal[aria-hidden="false"] {
  display: grid;
}

.modal > .modal-backdrop {
  z-index: -1;
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 34rem);
  max-height: calc(100vh - 2rem);
  padding: 1.35rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
  animation: panel-in var(--duration-normal) var(--ease-standard);
}

.meal-modal-panel {
  width: min(100%, 46rem);
}

.meal-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  margin: 1rem 0;
  padding: 0;
  list-style: none;
}

.meal-steps li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-faint);
  font-size: 0.7rem;
  font-weight: 760;
}

.meal-steps li::after {
  width: 100%;
  height: 1px;
  margin-left: 0.25rem;
  background: var(--border);
  content: "";
}

.meal-steps li:last-child::after {
  display: none;
}

.meal-steps li > span {
  display: grid;
  width: 1.5rem;
  height: 1.5rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-subtle);
  font-size: 0.65rem;
}

.meal-steps li.active {
  color: var(--petrol-800);
}

.meal-steps li.active > span {
  background: var(--petrol-800);
  color: white;
}

.onboarding-modal-panel {
  width: min(100%, 58rem);
  max-height: min(92vh, 58rem);
  overflow-y: auto;
}

.onboarding-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 1rem 0;
}

.onboarding-grid.three-columns {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.intake-notice {
  display: grid;
  gap: 0.25rem;
  margin: 1rem 0;
  padding: 0.85rem 1rem;
  border-left: 0.25rem solid var(--amber-500);
  background: var(--amber-50);
  color: var(--ink-800);
  font-size: 0.78rem;
  line-height: 1.5;
}

.intake-section {
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.intake-section h3 {
  margin: 0;
  color: var(--petrol-900);
  font-size: 0.95rem;
}

.choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  margin: 0.9rem 0;
  padding: 0;
  border: 0;
}

.choice-group legend {
  width: 100%;
  margin-bottom: 0.25rem;
  color: var(--ink-800);
  font-size: 0.72rem;
  font-weight: 750;
}

.choice-group label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.76rem;
}

.choice-group input {
  width: 1rem;
  height: 1rem;
}

.field-hint {
  color: var(--text-faint);
  font-size: 0.68rem;
  font-weight: 450;
  line-height: 1.4;
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-top: 0.9rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.consent-row input {
  width: 1rem;
  height: 1rem;
  margin-top: 0.12rem;
  flex: 0 0 auto;
}

.modal-panel > p {
  margin: 0.25rem 0 1rem;
  color: var(--text-muted);
  font-size: 0.76rem;
}

.modal-close {
  position: absolute;
  z-index: 2;
  top: 0.85rem;
  right: 0.85rem;
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--ink-700);
  cursor: pointer;
}

.modal-close:hover {
  background: var(--surface-subtle);
  color: var(--petrol-900);
}

.modal-close .icon {
  width: 1rem;
  height: 1rem;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(0.65rem) scale(0.985); }
}

.scanner-stage {
  display: grid;
  place-items: center;
  gap: 0.75rem;
  min-height: 13rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: var(--petrol-900);
  color: white;
}

.scanner-frame {
  position: relative;
  display: grid;
  width: min(100%, 25rem);
  aspect-ratio: 16 / 9;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 0.3);
  border-radius: var(--radius-md);
  background: rgb(255 255 255 / 0.06);
  overflow: hidden;
}

.scanner-frame > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-placeholder {
  display: grid;
  place-items: center;
  gap: 0.28rem;
  text-align: center;
}

.scanner-placeholder[hidden] {
  display: none;
}

.scanner-placeholder strong {
  font-size: 0.82rem;
}

.scanner-placeholder small {
  color: rgb(255 255 255 / 0.64);
  font-size: 0.62rem;
}

.camera-orb {
  display: grid;
  width: 3.25rem;
  height: 3.25rem;
  margin-bottom: 0.3rem;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 0.24);
  border-radius: 50%;
  background: rgb(255 255 255 / 0.1);
}

.camera-orb .icon {
  width: 1.35rem;
  height: 1.35rem;
}

.meal-photo-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
}

.button-light {
  border-color: rgb(255 255 255 / 0.35);
  background: rgb(255 255 255 / 0.12);
  color: white;
  cursor: pointer;
}

.button-light:hover {
  border-color: white;
  background: rgb(255 255 255 / 0.2);
}

.scanner-stage.is-analyzing .scanner-frame::after {
  position: absolute;
  right: 0;
  left: 0;
  height: 3px;
  background: #8ed8c1;
  box-shadow: 0 0 16px 4px rgb(142 216 193 / 0.42);
  content: "";
  animation: scan-photo 1.4s ease-in-out infinite;
}

@keyframes scan-photo {
  from { transform: translateY(-100%); }
  to { transform: translateY(100%); }
}

.scanner-frame > span {
  font-size: 4rem;
}

.scanner-frame > i,
.scanner-frame > b {
  position: absolute;
  width: 2rem;
  height: 2rem;
  border-color: #8ed8c1;
  border-style: solid;
}

.scanner-frame > i {
  top: 0.55rem;
  left: 0.55rem;
  border-width: 2px 0 0 2px;
}

.scanner-frame > b {
  right: 0.55rem;
  bottom: 0.55rem;
  border-width: 0 2px 2px 0;
}

.scanner-status {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  color: rgb(255 255 255 / 0.74);
  font-size: 0.65rem;
}

.recognition-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.75rem 0;
  padding: 0.72rem;
  border: 1px solid #b8dbcf;
  border-radius: var(--radius-sm);
  background: var(--jade-50);
}

.meal-analysis-panel {
  margin-top: 0.85rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--ivory-50);
}

.meal-analysis-panel[hidden] {
  display: none;
}

.meal-privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin-top: 0.75rem;
  padding: 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--jade-50);
  color: var(--jade-800);
  font-size: 0.67rem;
  line-height: 1.45;
}

.meal-privacy-note .icon {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

.meal-learning-consent {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin-top: 0.65rem;
  color: var(--text-muted);
  font-size: 0.66rem;
  line-height: 1.45;
}

.meal-learning-consent input {
  margin-top: 0.15rem;
  accent-color: var(--petrol-800);
}

.catalog-learning-status {
  margin-top: 0.55rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-muted);
  font-size: 0.62rem;
}

.food-catalog-card {
  margin: 1rem 0;
  border-left: 0.25rem solid var(--blue-700);
}

.catalog-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.catalog-metrics > div {
  display: grid;
  gap: 0.3rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}

.catalog-metrics small {
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 760;
}

.catalog-metrics strong {
  color: var(--petrol-900);
  font-size: 1rem;
}

@media (max-width: 48rem) {
  .catalog-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

#meal-confirm-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.recognition-result > div:first-child {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.6rem;
}

.confidence-badge {
  display: grid;
  width: 2.7rem;
  height: 2.7rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--jade-600);
  color: white;
  font-size: 0.68rem;
  font-weight: 820;
}

.recognition-result small,
.recognition-result strong {
  display: block;
}

.recognition-result small { color: var(--text-muted); font-size: 0.6rem; }
.recognition-result strong { margin-top: 0.12rem; font-size: 0.72rem; }

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.manifest-block {
  max-height: 26rem;
  overflow: auto;
  padding: 0.9rem;
  border-radius: var(--radius-md);
  background: var(--ink-950);
  color: #dcefe8;
}

.manifest-block code {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

.manifest-block code span {
  color: #f1ae9e;
}

.noscript {
  position: fixed;
  z-index: 200;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid #edbdbc;
  border-radius: var(--radius-md);
  background: var(--red-50);
  color: var(--red-700);
  box-shadow: var(--shadow-md);
  font-size: 0.78rem;
  font-weight: 680;
  text-align: center;
}

/* Responsive behavior */
@media (max-width: 78rem) {
  .metrics-grid,
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .span-3,
  .span-4 {
    grid-column: span 6;
  }

  .span-8,
  .span-9 {
    grid-column: span 12;
  }
}

@media (max-width: 64rem) {
  .app-shell {
    display: block;
  }

  .app-main,
  .main {
    grid-column: auto;
  }

  .sidebar {
    transform: translateX(-102%);
    box-shadow: var(--shadow-lg);
    transition: transform var(--duration-normal) var(--ease-standard);
  }

  body[data-nav-open="true"] {
    overflow: hidden;
  }

  body[data-nav-open="true"] .sidebar,
  .sidebar[data-state="open"] {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    z-index: 35;
    inset: 0;
    display: none;
    background: rgb(8 31 36 / 0.46);
  }

  body[data-nav-open="true"] .sidebar-overlay {
    display: block;
  }

  .menu-toggle {
    display: inline-grid;
  }

  .topbar {
    padding-inline: 1rem;
  }

  .search {
    width: min(20rem, 42vw);
  }

  .profile-copy {
    display: none;
  }

  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .risk-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 47.99rem) {
  :root {
    --topbar-height: 4.2rem;
  }

  body::before {
    background-image: none;
  }

  .topbar-title,
  .search {
    display: none;
  }

  .topbar-end {
    margin-left: auto;
  }

  .main-content,
  .page {
    padding: 1rem;
  }

  .page-header {
    display: grid;
    margin-bottom: 1.1rem;
  }

  .page-header .header-actions {
    width: 100%;
  }

  .page-header .header-actions .btn {
    flex: 1;
  }

  .dashboard-grid,
  .grid,
  .grid-2,
  .grid-3,
  .grid-4,
  .metrics-grid,
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .span-3,
  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8,
  .span-9,
  .span-12 {
    grid-column: 1 / -1;
  }

  .card {
    padding: 1rem;
    border-radius: var(--radius-md);
  }

  .card-footer,
  .panel-footer {
    margin: 1rem -1rem -1rem;
    padding: 0.8rem 1rem;
  }

  .toolbar {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar > * {
    width: 100%;
  }

  .risk-strip {
    grid-template-columns: minmax(0, 1fr);
  }

  .table-wrap[data-mobile="cards"],
  .table-scroll[data-mobile="cards"] {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .data-table[data-mobile="cards"] thead,
  table[data-mobile="cards"] thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .data-table[data-mobile="cards"],
  .data-table[data-mobile="cards"] tbody,
  .data-table[data-mobile="cards"] tr,
  .data-table[data-mobile="cards"] td,
  table[data-mobile="cards"],
  table[data-mobile="cards"] tbody,
  table[data-mobile="cards"] tr,
  table[data-mobile="cards"] td {
    display: block;
    width: 100%;
  }

  .data-table[data-mobile="cards"] tr,
  table[data-mobile="cards"] tr {
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-raised);
    box-shadow: var(--shadow-sm);
  }

  .data-table[data-mobile="cards"] td,
  table[data-mobile="cards"] td {
    display: grid;
    grid-template-columns: minmax(6rem, 0.42fr) minmax(0, 1fr);
    gap: 0.75rem;
    padding: 0.52rem 0;
    border-bottom: 1px solid var(--border);
    text-align: right;
  }

  .data-table[data-mobile="cards"] td::before,
  table[data-mobile="cards"] td::before {
    color: var(--text-muted);
    content: attr(data-label);
    font-size: 0.68rem;
    font-weight: 760;
    text-align: left;
    text-transform: uppercase;
  }

  .data-table[data-mobile="cards"] td:last-child,
  table[data-mobile="cards"] td:last-child {
    border-bottom: 0;
  }

  .phone-stage {
    min-height: auto;
    padding: 0.75rem;
  }

  .phone-screen {
    min-height: 38rem;
  }

  .modal {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: calc(100vh - 1rem);
    transform: none;
    border-width: 1px 0 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation-name: sheet-in;
  }

  .modal-footer {
    position: sticky;
    bottom: 0;
    flex-direction: column-reverse;
  }

  .modal-footer .btn {
    width: 100%;
  }

  @keyframes sheet-in {
    from { transform: translateY(100%); }
  }

  .toast-region,
  .toasts {
    top: auto;
    right: 0.75rem;
    bottom: 0.75rem;
    left: 0.75rem;
    width: auto;
  }

  .audit-log {
    overflow-x: auto;
  }

  .audit-row {
    min-width: 44rem;
  }
}

@media (max-width: 25rem) {
  .topbar-end .btn:not(.btn-icon) {
    display: none;
  }

  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .split {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --border: #8e8477;
    --border-strong: #61594f;
    --text-muted: #344d53;
  }

  .card,
  .panel,
  .widget,
  .metric-card {
    box-shadow: none;
  }

  :focus-visible {
    outline-width: 4px;
  }
}

@media print {
  :root {
    --background: white;
    --surface: white;
    --surface-raised: white;
  }

  body::before,
  .sidebar,
  .topbar,
  .btn,
  .button,
  .icon-btn,
  .toast-region,
  .toasts,
  .modal-backdrop,
  .overlay {
    display: none !important;
  }

  .app-shell,
  .app-main,
  .main {
    display: block;
  }

  .main-content,
  .page {
    width: 100%;
    max-width: none;
    padding: 0;
  }

  .card,
  .panel,
  .widget,
  .metric-card,
  .table-wrap {
    break-inside: avoid;
    box-shadow: none;
  }
}

/* MIAS-H application shell responsive aliases */
@media (max-width: 78rem) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid.grid-main,
  .content-grid.grid-equal,
  .patient-layout,
  .twin-layout,
  .clinical-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .content-grid .span-2 {
    grid-column: auto;
  }
}

@media (max-width: 64rem) {
  .mobile-menu {
    display: inline-grid;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  body.menu-open {
    overflow: hidden;
  }

  .main-shell {
    width: 100%;
    margin-left: 0;
  }

  .skill-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .execution-flow {
    grid-template-columns: minmax(0, 1fr);
  }

  .execution-flow > i {
    width: 1px;
    height: 1.25rem;
    margin-inline: 1.25rem;
  }
}

@media (max-width: 47.99rem) {
  .workspace {
    padding: 1rem;
  }

  .metric-grid,
  .metric-grid.compact-metrics,
  .skill-grid,
  .signal-grid,
  .field-row,
  .prediction-head {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid,
  .content-grid.grid-main,
  .content-grid.grid-equal {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar-actions .profile-chip > div,
  .topbar-actions .status-pill {
    display: none;
  }

  .page-header .header-actions .button {
    flex: 1 1 auto;
  }

  .review-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .review-side {
    grid-template-columns: auto auto 1fr auto;
    align-items: center;
  }

  .audit-chain {
    align-items: flex-start;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .audit-chain > .status-pill {
    grid-column: 1 / -1;
  }

  .table-toolbar,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .search-field,
  .select-wrap,
  .modal-actions .button {
    width: 100%;
  }
}

@media (max-width: 27rem) {
  .metric-grid,
  .metric-grid.compact-metrics,
  .skill-grid,
  .signal-grid,
  .field-row,
  .onboarding-grid,
  .onboarding-grid.three-columns,
  .prediction-head {
    grid-template-columns: minmax(0, 1fr);
  }
}

.toast-region {
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  transform: translateY(0.5rem);
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.toast-mark {
  display: grid;
  width: 1.55rem;
  height: 1.55rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--jade-100);
  color: var(--jade-800);
  font-weight: 850;
}

.toast[data-state="danger"] .toast-mark {
  background: var(--red-100);
  color: var(--red-700);
}

.review-card.is-resolved {
  transform: translateX(1rem);
  opacity: 0;
}

.uncertainty-band {
  fill: rgb(45 138 116 / 0.14);
  stroke: none;
}

.peak-point {
  fill: var(--coral-600);
  stroke: white;
  stroke-width: 3;
}

.nav-item[hidden] {
  display: none !important;
}

.profile-switcher {
  color: inherit;
  font: inherit;
  text-align: left;
}

.profile-switcher > .icon {
  width: 0.9rem;
  height: 0.9rem;
  margin-left: 0.15rem;
  color: var(--text-faint);
}

.profile-modal-panel {
  width: min(100%, 42rem);
}

.profile-options {
  display: grid;
  gap: 0.8rem;
  margin-top: 1.1rem;
}

.profile-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.9rem;
  width: 100%;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
}

.profile-option:hover,
.profile-option:focus-visible {
  transform: translateY(-2px);
  border-color: var(--petrol-500);
  box-shadow: var(--shadow-md);
  outline: none;
}

.profile-option > span:nth-child(2) {
  display: grid;
  gap: 0.18rem;
}

.profile-option strong {
  font-size: 1rem;
}

.profile-option small {
  color: var(--petrol-700);
  font-weight: 750;
}

.profile-option em {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-style: normal;
  line-height: 1.45;
}

.profile-option > .icon {
  width: 1rem;
  height: 1rem;
  color: var(--petrol-700);
}

.profile-option-avatar {
  display: grid;
  width: 3.15rem;
  height: 3.15rem;
  place-items: center;
  border-radius: 1rem;
  font-size: 0.9rem;
  font-weight: 850;
}

.profile-option-avatar.researcher {
  background: var(--petrol-100);
  color: var(--petrol-900);
}

.profile-option-avatar.patient {
  background: var(--jade-100);
  color: var(--jade-800);
}

.profile-safety {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.profile-safety .icon {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
  color: var(--petrol-700);
}

body[data-profile="patient"] .sidebar-status strong::after {
  content: " · modo paciente";
}

.intake-review-card {
  margin: 1rem 0;
  border-left: 0.25rem solid var(--amber-500);
}

.pending-review-card {
  border-color: color-mix(in srgb, var(--warning) 34%, var(--line));
  background: linear-gradient(145deg, #fffdf7, #ffffff);
}

.pending-review-list {
  display: grid;
  gap: .7rem;
}

.pending-review-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.pending-review-item > span {
  display: grid;
  gap: .18rem;
}

.pending-review-item small {
  color: var(--muted);
}

@media (max-width: 680px) {
  .pending-review-item {
    align-items: stretch;
    flex-direction: column;
  }

  .pending-review-item .button {
    width: 100%;
  }
}

.review-intro {
  margin: -0.25rem 0 1rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.intake-review-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.intake-review-summary > div {
  display: grid;
  align-content: start;
  gap: 0.35rem;
  min-height: 5.25rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}

.intake-review-summary small {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.intake-review-summary strong {
  overflow-wrap: anywhere;
  font-size: 0.88rem;
  line-height: 1.45;
}

.review-actions {
  justify-content: flex-end;
  margin-top: 1rem;
}

.patient-switcher-bar {
  display: grid;
  grid-template-columns: minmax(13rem, 1fr) minmax(16rem, 1.35fr) auto;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.patient-switcher-bar[hidden] { display: none; }
.patient-switcher-bar > div { display: grid; gap: 0.25rem; }
.patient-switcher-bar .field-group { margin: 0; }

.enrollment-card { margin-bottom: 1rem; }
.enrollment-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 10rem auto;
  align-items: end;
  gap: 1rem;
}
.enrollment-batch { grid-row: span 2; }
.enrollment-batch textarea { min-height: 8rem; resize: vertical; }
.enrollment-results { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.enrollment-results-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.enrollment-results-head > div { display: grid; gap: 0.25rem; }
.enrollment-results-head small { color: var(--text-muted); }
.enrollment-link-list { display: grid; gap: 0.65rem; margin-top: 0.85rem; }
.enrollment-link-row { display: grid; grid-template-columns: minmax(10rem, 0.7fr) minmax(0, 1.6fr); gap: 0.75rem; align-items: center; padding: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-subtle); }
.enrollment-link-row span { min-width: 0; }
.enrollment-link-row strong, .enrollment-link-row small { display: block; }
.enrollment-link-row small { color: var(--text-muted); }
.enrollment-link-row code { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--petrol-700); }
.enrollment-status-list { margin-top: 1rem; color: var(--text-muted); }
.enrollment-status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.65rem; }
.enrollment-status-item { display: grid; gap: 0.2rem; padding: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-md); }
.enrollment-status-item small { color: var(--text-muted); }

#runtime-connectivity-status.is-offline {
  color: #a94732;
}

@media (max-width: 64rem) {
  .patient-switcher-bar {
    grid-template-columns: 1fr 1fr;
  }

  .enrollment-grid { grid-template-columns: 1fr 1fr; }
  .enrollment-batch { grid-column: 1 / -1; grid-row: auto; }

  .patient-switcher-bar > .status-pill {
    justify-self: start;
  }

  .intake-review-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .condition-data-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 36rem) {
  .patient-switcher-bar {
    grid-template-columns: 1fr;
  }

  .enrollment-grid, .enrollment-link-row { grid-template-columns: 1fr; }
  .enrollment-results-head { align-items: flex-start; flex-direction: column; }

  .intake-review-summary {
    grid-template-columns: 1fr;
  }

  .profile-option {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .profile-option > .icon {
    display: none;
  }
}
/* Daily wellness and reminder layer — v0.5.1 */
.wellness-card{margin-top:14px;padding:14px;border:1px solid #d9e8e3;border-radius:18px;background:linear-gradient(145deg,#f5fbf8,#fffaf4);box-shadow:0 10px 24px rgba(2,64,75,.07)}
.wellness-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:8px}.wellness-card-head strong{display:block;color:#063f48;font-size:15px;margin-top:2px}.wellness-settings-button{width:34px;height:34px;border:0;border-radius:12px;background:#e6f4ef;color:#075460;font-size:16px;cursor:pointer}
.wellness-row{width:100%;display:grid;grid-template-columns:38px 1fr auto;align-items:center;gap:10px;padding:10px 0;border:0;border-top:1px solid #e6ece8;background:transparent;text-align:left;color:#123d43;cursor:pointer}.wellness-row span:nth-child(2){min-width:0}.wellness-row strong,.wellness-row small{display:block}.wellness-row strong{font-size:13px}.wellness-row small{margin-top:2px;color:#60757a;font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.wellness-row em{font-style:normal;color:#087060;font-size:11px;font-weight:700}.wellness-icon{display:grid;place-items:center;width:34px;height:34px;border-radius:12px;background:#e9f6f0;color:#087060;font-size:18px}.wellness-icon-meal{background:#fff1df;color:#bd681d}
.wellness-modal-card{max-width:620px}.wellness-modal-card.compact{max-width:480px}.sleep-hours-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;margin:18px 0 12px}.sleep-hours-grid button{padding:12px 6px;border:1px solid #d4dfdc;border-radius:12px;background:#fff;color:#0a5660;font-weight:750;cursor:pointer}.sleep-hours-grid button.active{border-color:#087a68;background:#e7f6f0;box-shadow:0 0 0 2px rgba(8,122,104,.12)}
.reminder-setting-block{padding:14px;margin:14px 0;border:1px solid #dfe8e5;border-radius:16px;background:#fbfdfc}.switch-row{display:flex;align-items:center;justify-content:space-between;gap:18px}.switch-row span{display:block}.switch-row strong,.switch-row small{display:block}.switch-row small{margin-top:3px;color:#66777b}.switch-row input{width:22px;height:22px;accent-color:#087a68}.reminder-times-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-top:14px}.permission-note{padding:10px 12px;border-radius:12px;background:#fff8e8;color:#765420;font-size:12px}
@media(max-width:620px){.reminder-times-grid{grid-template-columns:1fr}.wellness-modal-card{max-height:88vh;overflow:auto}.sleep-hours-grid{grid-template-columns:repeat(4,1fr)}}
