/* ============================================================
   NutriApp — Liquid Glass / iOS styling
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Manrope:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Acentos compartidos */
  --accent-1: #00c48a;          /* verde menta (un poco más oscuro para tema claro) */
  --accent-2: #0090d4;          /* azul cian */
  --accent-3: #ff4d8d;          /* magenta */
  --accent-warn: #ff9500;
  --accent-red:  #ff3b30;

  --radius-sm: 14px;
  --radius:    22px;
  --radius-lg: 32px;

  --safe-top: env(safe-area-inset-top, 0);
  --safe-bot: env(safe-area-inset-bottom, 0);

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body:    'Manrope', system-ui, sans-serif;
}

/* ---------- TEMA CLARO (por defecto) ---------- */
:root, [data-theme="light"] {
  --bg-0: #f3f5fb;
  --bg-1: #ffffff;
  --bg-2: #eef1f8;

  --text-1: #0b1020;
  --text-2: rgba(11, 16, 32, 0.72);
  --text-3: rgba(11, 16, 32, 0.52);
  --text-4: rgba(11, 16, 32, 0.32);

  --glass-bg:        rgba(255, 255, 255, 0.65);
  --glass-bg-strong: rgba(255, 255, 255, 0.82);
  --glass-border:    rgba(11, 16, 32, 0.08);
  --glass-shadow:    0 8px 32px rgba(11, 16, 32, 0.08),
                     inset 0 1px 0 rgba(255, 255, 255, 0.6);

  --bg-grad-1: rgba(0, 196, 138, 0.14);
  --bg-grad-2: rgba(0, 144, 212, 0.12);
  --bg-grad-3: rgba(255, 77, 141, 0.08);
  --dot-color: rgba(11, 16, 32, 0.05);
  --noise-opacity: 0.04;
  --tabbar-bg: rgba(255, 255, 255, 0.78);
  --input-bg: rgba(11, 16, 32, 0.04);
  --input-border: rgba(11, 16, 32, 0.1);
}

/* ---------- TEMA OSCURO ---------- */
[data-theme="dark"] {
  --bg-0: #060812;
  --bg-1: #0a0e1a;
  --bg-2: #11162a;

  --accent-1: #00e1a0;
  --accent-2: #00a0e1;

  --text-1: #f5f7ff;
  --text-2: rgba(245, 247, 255, 0.72);
  --text-3: rgba(245, 247, 255, 0.5);
  --text-4: rgba(245, 247, 255, 0.3);

  --glass-bg:        rgba(255, 255, 255, 0.06);
  --glass-bg-strong: rgba(255, 255, 255, 0.09);
  --glass-border:    rgba(255, 255, 255, 0.12);
  --glass-shadow:    0 8px 32px rgba(0, 0, 0, 0.4),
                     inset 0 1px 0 rgba(255, 255, 255, 0.12);

  --bg-grad-1: rgba(0,225,160,0.18);
  --bg-grad-2: rgba(0,160,225,0.16);
  --bg-grad-3: rgba(255,77,141,0.10);
  --dot-color: rgba(255,255,255,0.04);
  --noise-opacity: 0.07;
  --tabbar-bg: rgba(10, 14, 26, 0.7);
  --input-bg: rgba(255, 255, 255, 0.05);
  --input-border: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: var(--font-body);
  color: var(--text-1);
  background: var(--bg-0);
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}

button, input, select, textarea {
  font-family: inherit; color: inherit;
  border: 0; background: transparent; outline: none;
}

button { cursor: pointer; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ============================================================
   FONDO ATMOSFÉRICO — gradientes en movimiento
   ============================================================ */
.app-shell {
  position: relative;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(120% 80% at 15% 0%,  var(--bg-grad-1), transparent 55%),
    radial-gradient(100% 70% at 90% 20%, var(--bg-grad-2), transparent 60%),
    radial-gradient(140% 90% at 50% 100%, var(--bg-grad-3), transparent 60%),
    var(--bg-0);
}

.app-shell::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    radial-gradient(circle at 1px 1px, var(--dot-color) 1px, transparent 0);
  background-size: 24px 24px;
  pointer-events: none;
  z-index: 0;
}

.app-shell::after {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence 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.06 0'/></filter><rect width='200' height='200' filter='url(%23n)'/></svg>");
  opacity: var(--noise-opacity); mix-blend-mode: overlay;
  z-index: 0;
}

/* ============================================================
   LIQUID GLASS — clase base
   ============================================================ */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(30px) saturate(160%);
  -webkit-backdrop-filter: blur(30px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
  position: relative;
  overflow: hidden;
}

.glass::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 50%;
  background: linear-gradient(to bottom,
    var(--glass-highlight, rgba(255,255,255,0.08)), transparent);
  pointer-events: none;
  border-radius: inherit;
}

.glass-strong {
  background: var(--glass-bg-strong);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
}

/* ============================================================
   LAYOUT GENERAL
   ============================================================ */
.app-shell {
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}

.app-main {
  flex: 1;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 16px 120px;
  position: relative;
  z-index: 1;
}

/* En tablet/desktop se ensancha ligeramente, mantiene estética mobile */
@media (min-width: 768px) {
  .app-main { max-width: 560px; padding-top: 24px; }
}

/* ============================================================
   TOP BAR — saludo + avatar
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px 24px;
}
.topbar .hello {
  font-family: var(--font-display);
  font-size: 26px;
  
  line-height: 1;
  color: var(--text-1);
  font-weight: 400;
}
.topbar .date {
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 6px;
}
.topbar .avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
  color: var(--bg-0);
  box-shadow: 0 4px 16px rgba(0,225,160,0.3),
              inset 0 1px 0 rgba(255,255,255,0.4);
}

/* ============================================================
   RING — anillo de calorías estilo iOS Activity
   ============================================================ */
.kcal-card {
  padding: 24px;
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 18px;
  align-items: center;
}
.kcal-ring { position: relative; width: 130px; height: 130px; }
.kcal-ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.kcal-ring .track  { fill: none; stroke: var(--input-border); stroke-width: 14; }
.kcal-ring .fill   {
  fill: none;
  stroke: url(#kcalGrad);
  stroke-width: 14;
  stroke-linecap: round;
  transition: stroke-dasharray 700ms cubic-bezier(.2,.9,.2,1);
  filter: drop-shadow(0 0 8px rgba(0,225,160,0.5));
}
.kcal-ring .inside {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  text-align: center;
}
.kcal-ring .num {
  font-family: var(--font-display);
  font-size: 38px; 
  font-weight: 400; line-height: 1;
}
.kcal-ring .label {
  font-size: 10px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-3);
  margin-top: 4px;
}

.kcal-info h2 {
  font-family: var(--font-display);
  
  font-weight: 400;
  font-size: 20px;
  margin-bottom: 4px;
}
.kcal-info .remaining {
  font-size: 13px; color: var(--text-2);
  margin-bottom: 14px;
}
.kcal-info .remaining b { color: var(--accent-1); font-weight: 600; }
.kcal-info.warning .remaining b { color: var(--accent-warn); }
.kcal-info.over .remaining b    { color: var(--accent-red); }

/* ============================================================
   MACROS — barras horizontales
   ============================================================ */
.macros { display: grid; gap: 8px; }
.macro {
  display: grid;
  grid-template-columns: 50px 1fr 50px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.macro .name { color: var(--text-3); letter-spacing: 0.06em; text-transform: uppercase; }
.macro .val  { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }
.macro .bar {
  height: 6px;
  background: var(--input-bg);
  border-radius: 99px;
  overflow: hidden;
}
.macro .bar > span {
  display: block; height: 100%;
  border-radius: 99px;
  transition: width 600ms cubic-bezier(.2,.9,.2,1);
}
.macro.protein .bar > span { background: linear-gradient(90deg,#00e1a0,#3affd2); }
.macro.carbs   .bar > span { background: linear-gradient(90deg,#00a0e1,#5ad6ff); }
.macro.fat     .bar > span { background: linear-gradient(90deg,#ff4d8d,#ff9ec1); }

/* ============================================================
   FASTING CARD — ayuno
   ============================================================ */
.fasting-card {
  padding: 22px;
  margin-bottom: 14px;
}
.fasting-card .head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.fasting-card .head h3 {
  font-family: var(--font-display);
  
  font-weight: 400;
  font-size: 22px;
}
.fasting-card .status-pill {
  font-size: 10px; padding: 6px 10px;
  border-radius: 99px;
  letter-spacing: 0.1em; text-transform: uppercase;
  background: rgba(0,225,160,0.18);
  color: var(--accent-1);
  border: 1px solid rgba(0,225,160,0.3);
}
.fasting-card .status-pill.idle {
  background: var(--input-bg);
  color: var(--text-3);
  border-color: var(--input-border);
}
.fasting-progress {
  position: relative;
  height: 12px;
  background: var(--input-bg);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 14px;
}
.fasting-progress > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
  border-radius: 99px;
  transition: width 600ms cubic-bezier(.2,.9,.2,1);
  box-shadow: 0 0 12px rgba(0,225,160,0.4);
}
.fasting-times {
  display: flex; justify-content: space-between;
  font-size: 13px;
}
.fasting-times .t-block .lbl {
  font-size: 10px; color: var(--text-3);
  letter-spacing: 0.1em; text-transform: uppercase;
}
.fasting-times .t-block .val {
  font-family: var(--font-display);
  
  font-size: 18px;
  margin-top: 2px;
}
.fasting-cta {
  margin-top: 16px;
  display: flex; gap: 8px;
  align-items: stretch;
}
.fasting-cta .btn-block { flex: 1 1 auto; }
.fasting-cta .btn-icon { flex: 0 0 44px; }

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px;
  border-radius: 99px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
  transition: transform 150ms, opacity 200ms;
  white-space: nowrap;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: #04111a;
  box-shadow: 0 6px 20px rgba(0,225,160,0.25),
              inset 0 1px 0 rgba(255,255,255,0.4);
}
.btn-secondary {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  color: var(--text-1);
}
.btn-danger {
  background: rgba(255,85,96,0.15);
  border: 1px solid rgba(255,85,96,0.3);
  color: var(--accent-red);
}
.btn-block { width: 100%; }
.btn-icon {
  width: 44px; height: 44px; padding: 0;
  border-radius: 14px;
  flex-shrink: 0;
}

/* ============================================================
   SECCIÓN DE COMIDAS DEL DÍA
   ============================================================ */
.section-head {
  display: flex; align-items: end; justify-content: space-between;
  padding: 22px 6px 14px;
}
.section-head h2 {
  font-family: var(--font-display);
  
  font-weight: 400;
  font-size: 26px;
  line-height: 1;
}
.section-head .count {
  font-size: 11px; color: var(--text-3);
  letter-spacing: 0.1em; text-transform: uppercase;
}

.meal-group { margin-bottom: 12px; }
.meal-group-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px 8px;
  font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}
.meal-group-head .kcal-sum { color: var(--text-2); font-weight: 600; }

.meal-card {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: transform 200ms;
}
.meal-card:active { transform: scale(0.98); }
.meal-card .ico {
  width: 48px; height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg,
    rgba(0,225,160,0.2), rgba(0,160,225,0.2));
  display: grid; place-items: center;
  font-size: 22px;
  border: 1px solid var(--input-border);
}
.meal-card .meta .name {
  font-weight: 600; font-size: 15px;
  margin-bottom: 2px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
  overflow: hidden;
}
.meal-card .meta .sub {
  font-size: 12px; color: var(--text-3);
}
.meal-card .kcal {
  font-family: var(--font-display);
  
  font-size: 20px;
  color: var(--text-1);
}
.meal-card .kcal small {
  font-family: var(--font-body);
  font-style: normal;
  font-size: 10px; color: var(--text-3);
  display: block; text-align: right;
  letter-spacing: 0.06em;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
}
.empty-state .big {
  font-family: var(--font-display);
  
  font-size: 24px;
  color: var(--text-2);
  margin-bottom: 6px;
}

/* ============================================================
   TAB BAR FLOTANTE
   ============================================================ */
.tabbar {
  position: fixed;
  bottom: calc(16px + var(--safe-bot));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 460px;
  z-index: 100;

  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 8px;
  border-radius: 99px;

  background: var(--tabbar-bg);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}
.tabbar button {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px; padding: 8px;
  border-radius: 99px;
  font-size: 9px; letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  transition: color 200ms, background 200ms;
}
.tabbar button.active {
  color: var(--text-1);
  background: var(--input-bg);
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar .fab {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  color: var(--bg-0);
  margin: -16px 0;
  padding: 0;
  width: 56px; height: 56px;
  border-radius: 50%;
  justify-self: center;
  align-self: center;
  box-shadow: 0 8px 24px rgba(0,225,160,0.4),
              inset 0 1px 0 rgba(255,255,255,0.4);
}
.tabbar .fab svg { width: 26px; height: 26px; }

/* ============================================================
   VISTAS / PÁGINAS
   ============================================================ */
.view { display: none; animation: fadeIn 300ms ease-out; }
.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   MODAL / SHEET (estilo iOS)
   ============================================================ */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: none;
  opacity: 0;
  transition: opacity 300ms;
}
.sheet-backdrop.open { display: block; opacity: 1; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 210;
  max-width: 520px;
  margin: 0 auto;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border-top: 1px solid var(--glass-border);
  border-radius: 28px 28px 0 0;
  padding: 8px 20px calc(28px + var(--safe-bot));
  transform: translateY(100%);
  transition: transform 350ms cubic-bezier(.2,.9,.2,1);
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: 0 -10px 60px rgba(0,0,0,0.15);
  color: var(--text-1);
}
.sheet.open { transform: translateY(0); }
.sheet .handle {
  width: 38px; height: 5px;
  background: var(--text-4);
  border-radius: 99px;
  margin: 8px auto 18px;
}
.sheet h2 {
  font-family: var(--font-display);
  
  font-weight: 400;
  font-size: 28px;
  margin-bottom: 18px;
}

/* ============================================================
   FORMS
   ============================================================ */
.field {
  display: block;
  margin-bottom: 14px;
  min-width: 0; /* permite que el grid/flex shrinkee */
}
.field label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
  padding-left: 4px;
}
.field input, .field select, .field textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  font-size: 16px;
  color: var(--text-1);
  font-family: inherit;
  transition: border-color 200ms, background 200ms;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent-1);
  background: var(--bg-1);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.field-row > .field { min-width: 0; }

/* Segmented control (estilo iOS) */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--input-bg);
  border-radius: 12px;
  padding: 4px;
  border: 1px solid var(--input-border);
  margin-bottom: 14px;
}
.segmented button {
  padding: 9px 4px;
  font-size: 12px; font-weight: 600;
  color: var(--text-3);
  border-radius: 9px;
  transition: all 200ms;
  font-family: inherit;
  min-width: 0;
}
.segmented button.active {
  background: var(--bg-1);
  color: var(--text-1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* ============================================================
   AUTH SCREEN
   ============================================================ */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
  max-width: 420px;
  margin: 0 auto;
  position: relative; z-index: 1;
}
.auth-screen .logo {
  text-align: center;
  margin-bottom: 32px;
}
.auth-screen .logo h1 {
  font-family: var(--font-display);
  
  font-weight: 400;
  font-size: 56px;
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 0.9;
}
.auth-screen .logo p {
  color: var(--text-3);
  margin-top: 4px;
  font-size: 13px;
  letter-spacing: 0.04em;
}
.auth-card { padding: 28px 24px; }
.auth-switch {
  text-align: center;
  margin-top: 18px;
  font-size: 13px;
  color: var(--text-3);
}
.auth-switch button {
  color: var(--accent-1);
  font-weight: 600;
  font-size: inherit;
}

/* ============================================================
   CAPTURE: cámara
   ============================================================ */
.capture-modal {
  position: fixed; inset: 0;
  z-index: 300;
  background: black;
  display: none;
  flex-direction: column;
}
.capture-modal.open { display: flex; }

.capture-modal video {
  flex: 1;
  width: 100%; height: 100%;
  object-fit: cover;
}

.capture-overlay {
  position: absolute; inset: 0;
  pointer-events: none;
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: calc(20px + var(--safe-top)) 20px calc(20px + var(--safe-bot));
}
.capture-top {
  display: flex; justify-content: space-between; align-items: center;
  pointer-events: auto;
}
.capture-top .close-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(20px);
  color: white; display: grid; place-items: center;
}
.capture-mode {
  display: flex; gap: 4px; padding: 4px;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(20px);
  border-radius: 99px;
}
.capture-mode button {
  padding: 8px 14px; font-size: 12px; font-weight: 600;
  border-radius: 99px;
  color: rgba(255,255,255,0.6);
}
.capture-mode button.active {
  background: white; color: black;
}

.capture-frame {
  width: 75%; aspect-ratio: 1;
  border: 2px solid rgba(255,255,255,0.6);
  border-radius: 32px;
  margin: 0 auto;
  position: relative;
  pointer-events: none;
}
.capture-frame::before,
.capture-frame::after {
  content: '';
  position: absolute;
  width: 32px; height: 32px;
  border-color: var(--accent-1);
  border-style: solid;
  border-width: 0;
}
.capture-frame::before {
  top: -3px; left: -3px;
  border-top-width: 4px; border-left-width: 4px;
  border-top-left-radius: 30px;
}
.capture-frame::after {
  bottom: -3px; right: -3px;
  border-bottom-width: 4px; border-right-width: 4px;
  border-bottom-right-radius: 30px;
}

.capture-bottom {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  pointer-events: auto;
}
.capture-hint {
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(20px);
  padding: 8px 14px;
  border-radius: 99px;
}
.capture-shoot {
  width: 76px; height: 76px;
  border-radius: 50%;
  background: white;
  border: 5px solid rgba(255,255,255,0.4);
  background-clip: padding-box;
  transition: transform 100ms;
}
.capture-shoot:active { transform: scale(0.92); }

/* Cuando la cámara escanea código de barras */
.scanline {
  position: absolute;
  left: 12.5%; right: 12.5%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-1), transparent);
  animation: scan 2s ease-in-out infinite;
  box-shadow: 0 0 12px var(--accent-1);
}
@keyframes scan {
  0%, 100% { top: 30%; }
  50%      { top: 60%; }
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  top: calc(20px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  z-index: 400;
  padding: 12px 20px;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(30px) saturate(160%);
  -webkit-backdrop-filter: blur(30px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  font-size: 14px;
  font-weight: 500;
  max-width: 90%;
  color: var(--text-1);
  box-shadow: var(--glass-shadow);
  transition: transform 400ms cubic-bezier(.2,.9,.2,1),
              opacity 250ms ease;
  display: flex; align-items: center; gap: 10px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.toast.success { border-color: rgba(0,225,160,0.3); }
.toast.success .ico { color: var(--accent-1); }
.toast.warn    { border-color: rgba(255,181,71,0.4); }
.toast.warn    .ico { color: var(--accent-warn); }
.toast.error   { border-color: rgba(255,85,96,0.4); }
.toast.error   .ico { color: var(--accent-red); }

/* ============================================================
   CHART semanal
   ============================================================ */
.week-chart {
  padding: 20px;
}
.week-chart h3 {
  font-family: var(--font-display);
  
  font-size: 22px;
  font-weight: 400;
  margin-bottom: 18px;
}
.week-bars {
  display: flex;
  align-items: end;
  gap: 8px;
  height: 140px;
}
.week-bars .bar-wrap {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center;
  gap: 6px;
}
.week-bars .bar {
  width: 100%;
  background: linear-gradient(180deg, var(--accent-1), var(--accent-2));
  border-radius: 8px 8px 4px 4px;
  min-height: 4px;
  position: relative;
  transition: height 600ms cubic-bezier(.2,.9,.2,1);
}
.week-bars .bar.over { background: linear-gradient(180deg, var(--accent-red), var(--accent-3)); }
.week-bars .bar-wrap .lbl {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.week-bars .bar-wrap .val {
  font-size: 9px;
  color: var(--text-4);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   PROFILE: settings list
   ============================================================ */
.settings-group {
  padding: 8px 0;
  margin-bottom: 14px;
}
.settings-group .grp-title {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 8px 20px 10px;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--glass-border);
  font-size: 14px;
  min-height: 54px;
}
.setting-row:last-child { border-bottom: none; }
.setting-row .val { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* Input inline en filas (perfil) */
.inline-input {
  width: 110px;
  text-align: right;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-1);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  transition: border-color 200ms, background 200ms;
}
.inline-input:focus {
  border-color: var(--accent-1);
  background: var(--bg-1);
}

/* Profile card */
.profile-card {
  padding: 28px;
  text-align: center;
  margin-bottom: 16px;
}
.profile-avatar {
  width: 72px;
  height: 72px;
  font-size: 24px;
  margin: 0 auto 12px;
}
.profile-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}

/* Theme segmented compacto dentro de setting-row */
.setting-row .theme-seg {
  margin-bottom: 0;
  width: auto;
  min-width: 180px;
}

/* Switch toggle estilo iOS */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 30px;
}
.switch input {
  opacity: 0; width: 0; height: 0;
}
.switch::before {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 99px;
  transition: background 200ms;
  border: 1px solid var(--input-border);
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  background: white;
  border-radius: 50%;
  transition: transform 220ms cubic-bezier(.2,.9,.2,1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.switch:has(input:checked)::before {
  background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  border-color: transparent;
}
.switch:has(input:checked)::after {
  transform: translateX(20px);
}

/* ============================================================
   UTILS
   ============================================================ */
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; }
.between { justify-content: space-between; }
.gap-12 { gap: 12px; }
.mt-12 { margin-top: 12px; }
.mt-20 { margin-top: 20px; }
.mb-14 { margin-bottom: 14px; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.tiny  { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); }
.center { text-align: center; }
.stat-big {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
  margin-top: 2px;
}
.stat-unit {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 12px;
  color: var(--text-3);
}

/* Card padding consistente */
.card-pad { padding: 20px; }
.card-pad-lg { padding: 24px; }
.card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.01em;
  margin-bottom: 14px;
}

/* Inline row dentro de cards (alternativa a .setting-row sin padding propio) */
.inline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--glass-border);
  font-size: 14px;
}
.inline-row:last-child { border-bottom: none; }
.inline-row + .btn { margin-top: 12px; }

/* Spinner */
.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--input-border);
  border-top-color: var(--accent-1);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.detecting {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 28px;
}
.detecting .big-spinner {
  width: 52px; height: 52px; border-width: 4px;
}
