:root {
  --bg: #f3f7fc;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --surface-border: rgba(15, 23, 42, 0.08);
  --shadow: 0 24px 60px rgba(38, 65, 114, 0.12);
  --text: #15233d;
  --muted: #64748b;
  --title: #0b172a;
  --primary: #2563eb;
  --primary-soft: rgba(37, 99, 235, 0.12);
  --secondary: #8b5cf6;
  --accent: #10b981;
  --accent-soft: rgba(16, 185, 129, 0.14);
  --warning-soft: rgba(245, 158, 11, 0.16);
  --danger-soft: rgba(239, 68, 68, 0.14);
  --radius-2xl: 32px;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --sidebar-width: 320px;
  --max-width: 1440px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 28%),
    radial-gradient(circle at 85% 12%, rgba(139, 92, 246, 0.08), transparent 24%),
    linear-gradient(180deg, #f7fafe 0%, #eef4fb 100%);
}

a { color: inherit; }

.bg-mesh {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at center, black 50%, transparent 96%);
}

.glow {
  position: fixed;
  border-radius: 999px;
  filter: blur(48px);
  pointer-events: none;
  opacity: 0.6;
}
.glow-a {
  width: 320px;
  height: 320px;
  top: -90px;
  left: -70px;
  background: rgba(37, 99, 235, 0.18);
}
.glow-b {
  width: 380px;
  height: 380px;
  top: 120px;
  right: -110px;
  background: rgba(139, 92, 246, 0.16);
}

.dashboard-shell {
  position: relative;
  z-index: 1;
  width: min(var(--max-width), calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 42px;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 18px;
}

.sidebar-shell {
  position: sticky;
  top: 18px;
  align-self: start;
  height: calc(100vh - 36px);
}

.sidebar-panel {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
  gap: 16px;
  padding: 18px;
  border-radius: 32px;
  border: 1px solid var(--surface-border);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  overflow: auto;
}

.workspace-shell {
  min-width: 0;
}

.workspace-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  margin-bottom: 18px;
  border-radius: 26px;
  border: 1px solid var(--surface-border);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 30px rgba(38, 65, 114, 0.08);
}

.brand-badge {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: white;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 18px 34px rgba(37, 99, 235, 0.24);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sidebar-brand h1,
.workspace-topbar h2,
.tile h2,
.tile h3,
.section-header h2,
.input-header h3,
.quick-entry-head h3 {
  margin: 0;
  color: var(--title);
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

.sidebar-brand h1 {
  font-size: 1.22rem;
}

.eyebrow,
.section-mini {
  margin: 0;
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--primary);
}

.sidebar-nav {
  display: grid;
  gap: 8px;
}

.sidebar-link,
.nav-link {
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
}

.sidebar-link {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.58);
  border: 1px solid rgba(15, 23, 42, 0.05);
}

.topbar-actions,
.chip-cloud,
.hero-actions,
.hero-kpis,
.tile-topline,
.tile-head,
.signal-row,
.quick-entry-actions,
.history-head,
.badges,
.chip-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-actions,
.tile-topline,
.tile-head,
.history-head {
  justify-content: space-between;
  align-items: flex-start;
}

.sidebar-card,
.tile {
  border-radius: var(--radius-2xl);
  border: 1px solid var(--surface-border);
  background: var(--surface);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.sidebar-card {
  padding: 18px;
}

.sidebar-target-core {
  margin: 14px 0 16px;
  padding: 20px;
  border-radius: 24px;
  background:
    radial-gradient(circle at center, rgba(37, 99, 235, 0.16), rgba(255,255,255,0.72) 56%, rgba(255,255,255,0.96) 76%),
    linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0.98));
  border: 1px solid rgba(37, 99, 235, 0.12);
  text-align: center;
}

.sidebar-target-core span,
.sidebar-target-core p,
.hero-text,
.section-copy,
.support-copy,
.history-item p,
.recommendation-card p,
.care-plan p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.sidebar-target-core strong {
  display: block;
  margin: 10px 0 8px;
  font-size: 2rem;
  color: var(--title);
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

.status-chip,
.plan-chip,
.user-pill,
.quick-food-chip,
.badge {
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255,255,255,0.82);
}

.status-chip {
  padding: 8px 12px;
  color: var(--accent);
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.18);
  font-size: 0.8rem;
  font-weight: 700;
}

.user-pill,
.plan-chip,
.quick-food-chip {
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.user-pill:hover,
.quick-food-chip:hover,
.button:hover { transform: translateY(-1px); }

.user-pill.active,
.plan-chip,
.quick-food-chip.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(139, 92, 246, 0.12));
  border-color: rgba(37, 99, 235, 0.24);
  color: var(--primary);
}

.button {
  border: none;
  border-radius: 999px;
  padding: 14px 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.button.primary {
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.2);
}

.button.secondary {
  color: var(--title);
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.button.slim { padding: 10px 16px; }
.button.wide { width: 100%; }

.bento-grid {
  display: grid;
  gap: 18px;
}

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

.content-bento {
  margin-top: 18px;
}

.tile {
  min-width: 0;
  padding: 22px;
}

.tile-hero { grid-column: span 7; }
.tile-profile { grid-column: span 5; }
.tile-recommendation-detail { grid-column: span 12; }
.tile-nutrition { grid-column: span 8; }
.tile-body { grid-column: span 4; }
.tile-care { grid-column: span 4; }
.tile-meals { grid-column: span 8; }
.tile-metrics { grid-column: span 4; }

.tile-primary {
  background:
    linear-gradient(145deg, rgba(255,255,255,0.92), rgba(255,255,255,0.74)),
    linear-gradient(135deg, rgba(37, 99, 235, 0.06), rgba(139, 92, 246, 0.06));
}

.tile-hero h2 {
  margin-top: 12px;
  font-size: clamp(2.1rem, 4vw, 3.8rem);
  line-height: 1.04;
  max-width: 12ch;
}

.tile-hero h2 span {
  color: var(--primary);
}

.hero-text { margin-top: 16px; max-width: 720px; }
.hero-actions { margin-top: 22px; }
.hero-kpis { margin-top: 24px; }

.hero-kpi,
.metric-card,
.recommendation-meta,
.signal-card,
.input-card,
.quick-entry-card,
.upload-card,
.inline-result,
.history-item,
.care-plan,
.recommendation-card {
  border-radius: var(--radius-xl);
  border: 1px solid rgba(15, 23, 42, 0.06);
  background: var(--surface-strong);
}

.hero-kpi,
.metric-card,
.recommendation-meta,
.signal-card {
  min-width: 160px;
  padding: 16px 18px;
}

.hero-kpi span,
.metric-card span,
.recommendation-meta span,
.signal-card span {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
}

.hero-kpi strong,
.metric-card strong,
.recommendation-meta strong,
.signal-card strong {
  display: block;
  margin-top: 8px;
  color: var(--title);
  font-size: 1.08rem;
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

.summary-grid,
.recommendation-grid,
.nutrition-layout,
.form-stack,
.history-list,
.care-plan,
.upload-meta,
.quick-entry-head {
  display: grid;
  gap: 14px;
}

.summary-grid,
.recommendation-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
}

.recommendation-card,
.input-card,
.quick-entry-card,
.upload-card,
.inline-result,
.history-item,
.care-plan { padding: 18px; }

.recommendation-card { margin-top: 14px; }

.recommendation-card strong {
  font-size: 1.5rem;
  color: var(--title);
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
}

.section-header,
.input-header {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
}

.section-header h2,
.input-header h3,
.quick-entry-head h3,
.workspace-topbar h2 { font-size: 1.4rem; }

.nutrition-layout {
  margin-top: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wide-card { grid-column: 1 / -1; }

.form-row.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
}

label span {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.09);
  background: #fff;
  color: var(--title);
  padding: 14px 16px;
  font: inherit;
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(37, 99, 235, 0.28);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

textarea { min-height: 120px; resize: vertical; }

.quick-food-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-entry-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

.quick-entry-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.photo-preview {
  width: min(100%, 320px);
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  object-fit: cover;
}

.hidden { display: none; }

.history-list { margin-top: 14px; }
.history-item { display: grid; gap: 12px; }
.badge { padding: 6px 10px; font-size: 0.8rem; }
.badge.gold { background: var(--warning-soft); color: #9a6500; }
.badge.cyan { background: var(--primary-soft); color: var(--primary); }
.badge.green { background: var(--accent-soft); color: #0c7a59; }
.badge.danger { background: var(--danger-soft); color: #b42318; }
.badge.muted { background: rgba(15, 23, 42, 0.04); color: var(--muted); }

@media (max-width: 1220px) {
  .dashboard-shell {
    grid-template-columns: 1fr;
  }

  .sidebar-shell {
    position: static;
    height: auto;
  }

  .sidebar-panel {
    grid-template-rows: auto;
  }
}

@media (max-width: 980px) {
  .hero-bento,
  .content-bento {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .tile-hero,
  .tile-profile,
  .tile-recommendation-detail,
  .tile-nutrition,
  .tile-body,
  .tile-care,
  .tile-meals,
  .tile-metrics {
    grid-column: span 6;
  }

  .summary-grid,
  .recommendation-grid,
  .nutrition-layout,
  .form-row.two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .dashboard-shell {
    width: min(100% - 18px, var(--max-width));
    padding-top: 14px;
  }

  .workspace-topbar,
  .sidebar-panel,
  .tile {
    padding: 18px;
  }

  .tile-hero h2 {
    font-size: 2.15rem;
  }

  .hero-actions,
  .quick-entry-actions,
  .topbar-actions,
  .quick-entry-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .button,
  .sidebar-link {
    width: 100%;
  }
}
