/* ==========================================================================
   A91 — Health App · Dark Premium tokens
   Mobile-first, designed for inside-iPhone-frame use
   ========================================================================== */

:root {
  /* Surfaces */
  --bg-0: #07100B;
  --bg-1: #0C1611;
  --bg-2: #131C16;
  --card: rgba(255, 255, 255, 0.04);
  --card-strong: rgba(255, 255, 255, 0.06);
  --card-solid: #161C18;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.10);
  --hairline: rgba(255, 255, 255, 0.04);

  /* Brand */
  --green-deep: #1F2E22;
  --green-mid:  #3C5A3A;
  --green:      #5C8A4F;
  --green-glow: #8FBF6B;
  --green-neon: #A8E27E;
  --gold:       #C9A24A;
  --gold-soft:  #E0BE74;

  /* Vitals */
  --vital-heart: #E84A5F;
  --vital-o2:    #5BB4E8;
  --vital-temp:  #E8B85A;
  --vital-sleep: #9476E8;
  --vital-steps: #7FD16B;

  /* Text */
  --fg-0: #F2F1EC;
  --fg-1: #C4C6BD;
  --fg-2: #8A8F86;
  --fg-3: #5A5F58;

  /* Effects */
  --shadow-card: 0 1px 0 rgba(255,255,255,0.04) inset, 0 8px 24px rgba(0,0,0,0.3);
  --shadow-hero: 0 24px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(143, 191, 107, 0.08) inset;
  --shadow-glow-green: 0 0 40px rgba(143, 191, 107, 0.25);

  /* Radii */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
}

/* ----- Base ----- */
* { box-sizing: border-box; }

.a91 {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-feature-settings: 'cv02', 'cv03', 'cv11', 'ss01';
  background: var(--bg-0);
  color: var(--fg-0);
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  font-weight: 400;
  letter-spacing: -0.005em;
}
.a91 h1, .a91 h2, .a91 h3, .a91 h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.a91 p { margin: 0; line-height: 1.45; }
.a91 button { font-family: inherit; cursor: pointer; border: 0; padding: 0; background: none; color: inherit; }
.a91 input { font-family: inherit; }

/* ----- Backgrounds ----- */
.a91-bg-mesh {
  position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(92, 138, 79, 0.30), transparent 60%),
    radial-gradient(ellipse 60% 50% at 85% 35%, rgba(201, 162, 74, 0.10), transparent 70%),
    radial-gradient(ellipse 70% 50% at 10% 80%, rgba(92, 138, 79, 0.18), transparent 70%),
    linear-gradient(180deg, #06100A 0%, #0A1410 100%);
}
.a91-grain {
  position: absolute; inset: 0; pointer-events: none; z-index: 1;
  opacity: 0.4; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.07 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ----- Typography helpers ----- */
.a91-eyebrow {
  font-size: 10px; font-weight: 600; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--fg-2);
}
.a91-num {
  font-feature-settings: 'tnum' 1, 'lnum' 1;
  font-variant-numeric: tabular-nums;
}
.a91-display {
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 200;
  letter-spacing: -0.04em;
  line-height: 0.9;
}

/* ----- Cards ----- */
.a91-card {
  background: var(--card);
  backdrop-filter: blur(20px) saturate(120%);
  -webkit-backdrop-filter: blur(20px) saturate(120%);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
}
.a91-card-flat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px;
}

/* ----- Pills, chips ----- */
.a91-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: var(--card-strong);
  color: var(--fg-1);
  border: 1px solid var(--border);
}
.a91-chip.is-live::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--green-neon);
  box-shadow: 0 0 8px var(--green-neon);
  animation: a91-pulse 2s ease-in-out infinite;
}
.a91-chip.is-warn::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--vital-temp);
}

@keyframes a91-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ----- Buttons ----- */
.a91-btn {
  height: 52px; padding: 0 22px; border-radius: 999px;
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.a91-btn:active { transform: scale(0.98); }
.a91-btn-primary {
  background: linear-gradient(180deg, #A4D77F 0%, #6FA855 100%);
  color: #0A1410;
  box-shadow:
    0 8px 24px rgba(143, 191, 107, 0.35),
    0 0 0 1px rgba(168, 226, 126, 0.5) inset,
    0 1px 0 rgba(255, 255, 255, 0.4) inset;
}
.a91-btn-ghost {
  background: var(--card-strong);
  color: var(--fg-0);
  border: 1px solid var(--border-strong);
}

/* ----- Forms ----- */
.a91-field {
  display: block;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  transition: border-color 0.2s, background 0.2s;
}
.a91-field:focus-within {
  border-color: var(--green-glow);
  background: rgba(143, 191, 107, 0.06);
}
.a91-field-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--fg-2);
  margin-bottom: 4px;
}
.a91-field input {
  width: 100%; border: 0; outline: 0;
  background: transparent; color: var(--fg-0);
  font-size: 15px; font-weight: 500;
  letter-spacing: -0.01em;
}
.a91-field input::placeholder { color: var(--fg-3); }

/* ----- Progress / meter ----- */
.a91-bar {
  height: 6px; border-radius: 999px;
  background: rgba(255,255,255,0.06); overflow: hidden;
}
.a91-bar > i {
  display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--green) 0%, var(--green-glow) 100%);
  transition: width 0.6s cubic-bezier(0.2, 0.7, 0.3, 1);
}

/* ----- Devices ----- */
.a91-device {
  position: relative;
  border-radius: var(--r-md);
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  overflow: hidden;
}
.a91-device.is-off {
  opacity: 0.7;
}
.a91-device-pill {
  position: absolute; top: 10px; right: 10px;
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 8px; border-radius: 999px;
  font-size: 9px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(168, 226, 126, 0.14);
  color: var(--green-neon);
  border: 1px solid rgba(168, 226, 126, 0.25);
}
.a91-device-pill.is-off {
  background: rgba(232, 184, 90, 0.12);
  color: var(--gold-soft);
  border-color: rgba(232, 184, 90, 0.25);
}

/* ----- Tab bar ----- */
.a91-tabbar {
  position: sticky; bottom: 0; left: 0; right: 0;
  margin: 20px -16px -16px;
  padding: 12px 8px calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-around;
  background: linear-gradient(180deg, rgba(7, 16, 11, 0) 0%, rgba(7, 16, 11, 0.95) 35%);
  z-index: 5;
}
.a91-tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 6px; border-radius: 12px;
  color: var(--fg-3);
  font-size: 9px; font-weight: 600; letter-spacing: 0.02em;
  transition: color 0.2s;
  border: 0; background: transparent; cursor: pointer;
  flex: 1; min-width: 0;
}
.a91-tab.is-active { color: var(--green-neon); }
.a91-tab svg { width: 20px; height: 20px; }

/* ----- Humanoid glow ----- */
.a91-humanoid {
  filter: drop-shadow(0 0 24px rgba(143, 191, 107, 0.35));
}
.a91-humanoid.is-past {
  filter: drop-shadow(0 0 14px rgba(201, 162, 74, 0.18)) saturate(0.5) brightness(0.7);
}

/* ----- Avatar ----- */
.a91-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green-mid), var(--green-deep));
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
  position: relative;
}
.a91-avatar.ring::after {
  content: '';
  position: absolute; inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--green-neon);
  box-shadow: 0 0 10px rgba(168, 226, 126, 0.4);
}

/* ----- Sheets (bottom drawers) — theme-aware ----- */
.a91-sheet {
  background: linear-gradient(180deg, #131C16 0%, #0B130D 100%);
  border-top: 1px solid var(--border-strong);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -20px 60px rgba(0,0,0,0.7);
  color: var(--fg-0);
}
.a91-sheet-handle {
  width: 40px; height: 4px; border-radius: 999px;
  background: rgba(255,255,255,0.18);
  margin: 0 auto 14px;
}
.a91-theme-light .a91-sheet-backdrop {
  background: rgba(20, 30, 18, 0.35) !important;
}
.a91-theme-light .a91-sheet {
  background: linear-gradient(180deg, #FFFFFF 0%, #F7F2E8 100%);
  border-top: 1px solid rgba(20, 30, 18, 0.10);
  box-shadow: 0 -20px 60px rgba(20, 30, 18, 0.2);
}
.a91-theme-light .a91-sheet-handle {
  background: rgba(20, 30, 18, 0.18);
}

/* ----- Chart tooltip ----- */
.a91-chart-wrap { position: relative; }
.a91-chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--card-solid);
  color: var(--fg-0);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 11px; font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  transform: translate(-50%, calc(-100% - 10px));
  z-index: 5;
  display: flex; flex-direction: column; gap: 1px; align-items: center;
}
.a91-chart-tooltip::after {
  content: '';
  position: absolute; left: 50%; bottom: -4px;
  width: 8px; height: 8px;
  background: var(--card-solid);
  border-right: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
  transform: translateX(-50%) rotate(45deg);
}
.a91-chart-tooltip .lbl {
  font-size: 9px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--fg-3); text-transform: uppercase;
}
.a91-chart-tooltip .val {
  font-feature-settings: 'tnum' 1, 'lnum' 1;
}
.a91-theme-light .a91-chart-tooltip {
  box-shadow: 0 6px 18px rgba(20, 30, 18, 0.18);
}

/* ----- Animations ----- */
@keyframes a91-fadeup {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes a91-slideup {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.a91-fadeup { animation: a91-fadeup 0.6s cubic-bezier(0.2, 0.7, 0.3, 1) both; }

@keyframes a91-glow-breath {
  0%, 100% { filter: drop-shadow(0 0 20px rgba(143, 191, 107, 0.35)); }
  50%      { filter: drop-shadow(0 0 36px rgba(143, 191, 107, 0.55)); }
}
.a91-breath { animation: a91-glow-breath 4s ease-in-out infinite; }

@keyframes a91-spin-slow {
  to { transform: rotate(360deg); }
}

@keyframes a91-pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
}

/* Sparkline path animation */
@keyframes a91-draw {
  from { stroke-dashoffset: 600; }
  to { stroke-dashoffset: 0; }
}
.a91-draw {
  stroke-dasharray: 600;
  animation: a91-draw 1.4s ease-out both;
}

/* ----- Scrollbars: hide for in-frame feel ----- */
.a91 ::-webkit-scrollbar { display: none; }
.a91 { scrollbar-width: none; }

/* ─────────────────────────────────────────────────────────────
   LIGHT THEME — vivid, colorful, alive
   ───────────────────────────────────────────────────────────── */
.a91-theme-light {
  --bg-0: #FCF8F2;
  --bg-1: #F4F0E8;
  --bg-2: #EDE7DC;
  --card: rgba(255, 255, 255, 0.85);
  --card-strong: rgba(255, 255, 255, 0.95);
  --card-solid: #FFFFFF;
  --border: rgba(20, 30, 18, 0.08);
  --border-strong: rgba(20, 30, 18, 0.14);
  --hairline: rgba(20, 30, 18, 0.05);

  --green-deep: #1F2E22;
  --green-mid:  #3C5A3A;
  --green:      #4A7C3F;
  --green-glow: #5C9A4A;
  --green-neon: #4FA53A;
  --gold:       #D49A2F;
  --gold-soft:  #B47C1A;

  --vital-heart: #E14B5F;
  --vital-o2:    #2E8FCB;
  --vital-temp:  #E0832A;
  --vital-sleep: #7256C4;
  --vital-steps: #3FA45A;

  --fg-0: #1A2218;
  --fg-1: #3A4538;
  --fg-2: #6B7568;
  --fg-3: #9CA398;

  --shadow-card: 0 1px 2px rgba(20, 30, 18, 0.04), 0 8px 24px rgba(20, 30, 18, 0.06);
  --shadow-hero: 0 24px 60px rgba(20, 30, 18, 0.12), 0 0 0 1px rgba(92, 154, 74, 0.1) inset;
  background: var(--bg-0);
}

.a91-theme-light .a91-card {
  backdrop-filter: blur(20px) saturate(130%);
  -webkit-backdrop-filter: blur(20px) saturate(130%);
  background: rgba(255, 255, 255, 0.75);
  border-color: rgba(20, 30, 18, 0.06);
}

.a91-theme-light .a91-chip {
  background: rgba(20, 30, 18, 0.06);
  color: var(--fg-1);
  border-color: rgba(20, 30, 18, 0.08);
}
.a91-theme-light .a91-chip.is-live {
  background: rgba(79, 165, 58, 0.12);
  color: var(--green);
  border-color: rgba(79, 165, 58, 0.25);
}
.a91-theme-light .a91-chip.is-live::before {
  background: var(--green-neon);
  box-shadow: 0 0 8px var(--green-neon);
}

.a91-theme-light .a91-bar {
  background: rgba(20, 30, 18, 0.06);
}

.a91-theme-light .a91-field {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(20, 30, 18, 0.1);
}
.a91-theme-light .a91-field:focus-within {
  border-color: var(--green);
  background: rgba(79, 165, 58, 0.05);
}

.a91-theme-light .a91-btn-ghost {
  background: rgba(20, 30, 18, 0.06);
  color: var(--fg-0);
  border-color: rgba(20, 30, 18, 0.1);
}

.a91-theme-light .a91-device {
  background: #FFFFFF;
  border-color: rgba(20, 30, 18, 0.08);
  box-shadow: 0 2px 8px rgba(20, 30, 18, 0.04);
}
.a91-theme-light .a91-device-pill {
  background: rgba(79, 165, 58, 0.14);
  color: var(--green);
  border-color: rgba(79, 165, 58, 0.25);
}
.a91-theme-light .a91-device-pill.is-off {
  background: rgba(224, 131, 42, 0.14);
  color: var(--vital-temp);
  border-color: rgba(224, 131, 42, 0.25);
}

/* ----- Acompanhamento / Exames ----- */
.a91-theme-light .a91-chart-tooltip::after {
  background: var(--card-solid);
}
.a91-theme-light .a91-sheet .a91-card {
  background: rgba(255,255,255,0.85);
}
/* Stethoscope tab — keep icon same size as others */
.a91-tab svg { width: 20px; height: 20px; }
