/* ═══════════════════════════════════════════════════════════════
   HealthLens AI — Account + Analytics Dashboard
   Extends main.css tokens (--bg-*, --sky, --text-*, --radius-*, etc.)
   Self-contained, theme-aware, responsive, accessible.
═══════════════════════════════════════════════════════════════ */

/* ─── Layout shell ──────────────────────────────────────────── */
.account-main {
  position: relative;
  z-index: 1;
  max-width: 1140px;
  margin: 0 auto;
  padding: 104px 1.5rem 5rem;
}

.hl-hidden { display: none !important; }

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

/* ─── Initial loading view ──────────────────────────────────── */
.hl-loading {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  color: var(--text-secondary);
}

/* ─── Spinner ───────────────────────────────────────────────── */
.spinner {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--sky);
  animation: hl-spin 0.9s linear infinite;
}
.spinner.spinner-sm { width: 18px; height: 18px; border-width: 2px; }
@keyframes hl-spin { to { transform: rotate(360deg); } }

.inline-thinking {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--sky);
  font-size: 0.9rem;
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}

/* ─── AUTH (sign up / log in) ───────────────────────────────── */
.auth-shell {
  min-height: 66vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 0;
}

.auth-card {
  width: 100%;
  max-width: 460px;
  padding: 2.25rem 2rem 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
}

.auth-head { text-align: center; margin-bottom: 1.6rem; }
.auth-head h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
}
.auth-head p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.55;
}

.auth-tabs {
  display: flex;
  gap: 0.4rem;
  padding: 0.32rem;
  background: rgba(5, 9, 28, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.4rem;
}
.auth-tab {
  flex: 1;
  padding: 0.62rem 0.5rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
}
.auth-tab[aria-selected="true"] {
  background: linear-gradient(135deg, var(--blue) 0%, var(--navy) 100%);
  color: #fff;
  box-shadow: 0 4px 18px rgba(26, 86, 219, 0.32);
}
.auth-tab:focus-visible { outline: 2px solid var(--border-glow); outline-offset: 2px; }

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

.auth-alt {
  margin-top: 1.2rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--sky);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--indigo-bright); }
.link-btn:focus-visible { outline: 2px solid var(--border-glow); outline-offset: 2px; border-radius: 3px; }

/* ─── Forms / fields ────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 0.34rem; margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
.field > label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}
.field .hint { font-size: 0.72rem; color: var(--text-muted); }
.field .req { color: var(--sky); }

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.72rem 0.85rem;
  background: rgba(5, 9, 28, 0.55);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.92rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
}
.field textarea { resize: vertical; min-height: 74px; line-height: 1.55; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--border-glow);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
}
.field input::placeholder,
.field textarea::placeholder { color: var(--text-muted); }
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%237e99b8' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 12px;
  padding-right: 2.2rem;
  cursor: pointer;
}
.field select option { background: #0b1230; color: var(--text-primary); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0 1rem;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem;
  margin-top: 1.1rem;
}

/* ─── Status / inline messages ──────────────────────────────── */
.form-msg {
  min-height: 1.1em;
  font-size: 0.84rem;
  line-height: 1.5;
  margin-top: 0.2rem;
}
.form-msg:empty { min-height: 0; }
.form-msg.is-error { color: var(--red); }
.form-msg.is-ok { color: var(--green); }
.form-msg.is-info { color: var(--sky); }

/* ─── Dashboard sections ────────────────────────────────────── */
.dash-section { margin-bottom: 2.6rem; }
.dash-section > .card { padding: 1.6rem 1.5rem; }

.dash-sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  margin-bottom: 1.1rem;
}
.dash-sec-head .section-label { margin-bottom: 0.35rem; }
.dash-sec-head h2 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.dash-sec-head .sec-sub {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-top: 0.25rem;
}
.head-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

/* ─── Greeting / hero ───────────────────────────────────────── */
.dash-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.2rem;
  padding: 1.8rem 1.7rem;
  margin-bottom: 1.8rem;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(56, 189, 248, 0.10), transparent 60%),
    var(--bg-card);
  border: 1px solid var(--border);
}
.dash-hero h1 { font-size: clamp(1.5rem, 3.4vw, 2.05rem); font-weight: 800; }
.dash-hero .greet-sub { color: var(--text-secondary); font-size: 0.95rem; margin-top: 0.4rem; }

.summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.1rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.8rem;
  border-radius: 999px;
  background: rgba(5, 9, 28, 0.5);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.chip b { color: var(--text-primary); font-weight: 700; }
.chip .chip-key { color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.66rem; }

.nudge {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.1rem;
  margin-top: 1.2rem;
  border-radius: var(--radius);
  background: rgba(245, 158, 11, 0.10);
  border: 1px solid rgba(245, 158, 11, 0.32);
  color: var(--text-primary);
  font-size: 0.88rem;
}
.nudge .nudge-ico { font-size: 1.15rem; }
.nudge .btn { margin-left: auto; }

/* ─── Stat tiles ────────────────────────────────────────────── */
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.4rem;
}
.stat-tile {
  padding: 1.1rem 1.15rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.stat-tile .stat-key {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 700;
}
.stat-tile .stat-value {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 800;
  margin-top: 0.35rem;
  line-height: 1.1;
}
.stat-tile .stat-value .stat-unit { font-size: 0.85rem; color: var(--text-secondary); font-weight: 600; margin-left: 0.2rem; }
.stat-tile .stat-delta {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.stat-delta .arrow-up { color: var(--sky); }
.stat-delta .arrow-down { color: var(--indigo-bright); }
.stat-delta.is-muted { color: var(--text-muted); }

/* ─── Charts ────────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.1rem;
}
.chart-card {
  padding: 1.15rem 1.2rem 1rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.chart-card .chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.55rem;
}
.chart-card .chart-title { font-size: 0.92rem; font-weight: 700; color: var(--text-primary); }
.chart-card .chart-latest { font-size: 0.82rem; color: var(--text-secondary); font-weight: 600; }
.chart-canvas-wrap { position: relative; width: 100%; }
.chart-card canvas { display: block; width: 100%; height: 150px; }
.chart-caption { margin-top: 0.5rem; font-size: 0.74rem; color: var(--text-muted); line-height: 1.5; }

/* ─── Scan history ──────────────────────────────────────────── */
.scan-table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.scan-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  min-width: 640px;
}
.scan-table th, .scan-table td {
  text-align: left;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.scan-table thead th {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
}
.scan-table tbody tr:hover { background: rgba(56, 189, 248, 0.05); }
.scan-table td .muted { color: var(--text-muted); }
.tag-source {
  display: inline-block;
  padding: 0.14rem 0.55rem;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tag-source.src-deepscan { background: rgba(56, 189, 248, 0.14); color: var(--sky); border: 1px solid rgba(56, 189, 248, 0.3); }
.tag-source.src-manual { background: rgba(126, 153, 184, 0.14); color: var(--text-secondary); border: 1px solid var(--border); }

/* ─── Empty states ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-secondary);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty-state .empty-ico { font-size: 2rem; margin-bottom: 0.6rem; opacity: 0.85; }
.empty-state p { font-size: 0.9rem; max-width: 420px; margin: 0 auto 1rem; line-height: 1.6; }

.subpanel {
  margin-top: 1.2rem;
  padding: 1.3rem 1.3rem;
  border-radius: var(--radius);
  background: rgba(5, 9, 28, 0.4);
  border: 1px solid var(--border);
}
.subpanel > h3 { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; }

/* ─── AI Coach ──────────────────────────────────────────────── */
.coach-card { position: relative; }
.coach-summary {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-primary);
  margin-bottom: 1.1rem;
}
.coach-bullets { list-style: none; display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.2rem; }
.coach-bullets li {
  position: relative;
  padding-left: 1.6rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.55;
}
.coach-bullets li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.5em;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--sky);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
}
.coach-flags { display: flex; flex-direction: column; gap: 0.6rem; }
.flag {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  line-height: 1.5;
  border: 1px solid transparent;
}
.flag .flag-ico { flex: none; font-size: 1rem; line-height: 1.4; }
.flag-info { background: rgba(56, 189, 248, 0.10); border-color: rgba(56, 189, 248, 0.3); color: var(--text-primary); }
.flag-watch { background: rgba(245, 158, 11, 0.10); border-color: rgba(245, 158, 11, 0.34); color: var(--text-primary); }
.flag-seek-care { background: rgba(239, 68, 68, 0.10); border-color: rgba(239, 68, 68, 0.38); color: var(--text-primary); }
.flag-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.66rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  margin-right: 0.35rem;
}
.flag-info .flag-label { background: rgba(56, 189, 248, 0.2); color: var(--sky); }
.flag-watch .flag-label { background: rgba(245, 158, 11, 0.2); color: var(--gold); }
.flag-seek-care .flag-label { background: rgba(239, 68, 68, 0.2); color: var(--red); }

/* ─── Disclaimer ────────────────────────────────────────────── */
.disclaimer {
  margin-top: 1.2rem;
  padding: 0.7rem 0.9rem;
  border-left: 3px solid var(--border-glow);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: rgba(5, 9, 28, 0.4);
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.55;
}

/* ─── Plans ─────────────────────────────────────────────────── */
.plan-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0 1rem;
  align-items: end;
}
.plan-summary {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-primary);
  margin-bottom: 1.3rem;
  padding: 0.9rem 1.05rem;
  border-radius: var(--radius);
  background: rgba(56, 189, 248, 0.07);
  border: 1px solid rgba(56, 189, 248, 0.22);
}
.plan-block { margin-bottom: 1.8rem; }
.plan-block > h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.plan-block > h3 .blk-ico { font-size: 1.15rem; }

.diet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.9rem;
}
.diet-card {
  padding: 1rem 1.05rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.diet-card .diet-day { font-weight: 800; font-size: 0.95rem; font-family: var(--font-heading); }
.diet-card .diet-focus { font-size: 0.76rem; color: var(--sky); margin: 0.2rem 0 0.7rem; font-weight: 600; }
.diet-card .diet-meal { font-size: 0.8rem; margin-bottom: 0.5rem; color: var(--text-secondary); line-height: 1.45; }
.diet-card .diet-meal b { color: var(--text-primary); display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.diet-card .diet-kcal { color: var(--text-muted); font-size: 0.72rem; }
.diet-card .diet-total {
  margin-top: 0.7rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-secondary);
}
.diet-card .diet-total b { color: var(--gold); }

.info-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.9rem;
  margin-bottom: 0.9rem;
}
.info-cell {
  padding: 0.95rem 1.05rem;
  border-radius: var(--radius);
  background: rgba(5, 9, 28, 0.4);
  border: 1px solid var(--border);
}
.info-cell .info-k { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); font-weight: 700; }
.info-cell .info-v { font-family: var(--font-heading); font-size: 1.4rem; font-weight: 800; margin-top: 0.25rem; }
.info-cell .info-note { font-size: 0.78rem; color: var(--text-secondary); margin-top: 0.35rem; line-height: 1.5; }

.cardio-list, .routine-list { list-style: none; display: flex; flex-direction: column; gap: 0.55rem; }
.cardio-row, .routine-row {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  background: rgba(5, 9, 28, 0.35);
  border: 1px solid var(--border);
  font-size: 0.86rem;
}
.cardio-row .day, .routine-row .day {
  font-weight: 800;
  color: var(--sky);
  min-width: 2.6rem;
  font-family: var(--font-heading);
}
.cardio-row .meta { color: var(--text-muted); font-size: 0.76rem; }
.intensity {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
}
.intensity.easy { background: rgba(16, 185, 129, 0.16); color: var(--green); }
.intensity.moderate { background: rgba(245, 158, 11, 0.16); color: var(--gold); }
.intensity.hard { background: rgba(239, 68, 68, 0.16); color: var(--red); }

/* ─── Tabs (routine levels) ─────────────────────────────────── */
.level-tabs {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.3rem;
  background: rgba(5, 9, 28, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.level-tab {
  padding: 0.5rem 1.1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}
.level-tab[aria-selected="true"] {
  background: linear-gradient(135deg, var(--blue) 0%, var(--navy) 100%);
  color: #fff;
}
.level-tab:focus-visible { outline: 2px solid var(--border-glow); outline-offset: 2px; }
.level-panel[hidden] { display: none; }

.routine-day-card {
  padding: 0.9rem 1.05rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 0.7rem;
}
.routine-day-card .rd-head { display: flex; align-items: baseline; gap: 0.6rem; margin-bottom: 0.5rem; }
.routine-day-card .rd-day { font-weight: 800; color: var(--sky); font-family: var(--font-heading); }
.routine-day-card .rd-focus { font-size: 0.8rem; color: var(--text-secondary); }
.routine-day-card ul { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.routine-day-card li {
  font-size: 0.78rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: rgba(5, 9, 28, 0.45);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* ─── Tracking response ─────────────────────────────────────── */
.coach-message {
  margin-top: 1.1rem;
  padding: 0.95rem 1.1rem;
  border-radius: var(--radius);
  background: rgba(16, 185, 129, 0.09);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.55;
  display: flex;
  gap: 0.6rem;
}
.coach-message .cm-ico { flex: none; }

/* ─── Utility ───────────────────────────────────────────────── */
.hl-lead { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.6; max-width: 640px; }
.mt-1 { margin-top: 1rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.8rem; }

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 720px) {
  .account-main { padding: 92px 1.1rem 4rem; }
  .dash-hero { padding: 1.4rem 1.25rem; }
  .dash-section > .card { padding: 1.3rem 1.15rem; }
  .nudge .btn { margin-left: 0; width: 100%; justify-content: center; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; justify-content: center; }
}
@media (max-width: 460px) {
  .auth-card { padding: 1.7rem 1.3rem; }
  .stat-tile .stat-value { font-size: 1.5rem; }
}
