@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
  --bg: #f5f2ee;
  --surface: #ffffff;
  --card: #faf9f7;
  --border: #e8e3dc;
  --dark: #1a1612;
  --dark2: #2d2820;
  --muted: #9c9186;
  --navy: #1e2a3a;
  --navy-2: #2a3a50;
  --accent: #e8440a;
  --accent-strong: #c43a08;
  --accent-light: #fef0e8;
  --green: #2a6e4e;
  --green-light: #e8f5ee;
  --blue: #1e4d8c;
  --blue-light: #e8eef8;
  --bad: #c0392b;
  --purple: #6b21a8;
  --purple-light: #f3e8ff;
  --red-light: #fee2e2;
  --amber: #a8710f;
  --amber-light: #fbf0dc;
  --teal: #0f766e;
  --teal-light: #ccfbf1;
  --gray-light: #f0ede8;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 2px 20px rgba(26,22,18,.08);
  --shadow-lg: 0 8px 40px rgba(26,22,18,.14);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'DM Sans', -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--dark);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-light); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 20px; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- AUTH ---------- */
#auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.auth-card {
  background: var(--surface); border: 1px solid var(--border); padding: 40px;
  border-radius: var(--radius-lg); width: 380px; box-shadow: var(--shadow-lg); text-align: center;
}
.auth-logo { width: 150px; margin: 0 auto 20px; display: block; }
.auth-card h1 { font-family: 'DM Serif Display', serif; font-weight: 400; font-size: 26px; margin: 0 0 8px; color: var(--dark); }
.auth-card h1 .accent-word { color: var(--accent); font-style: italic; }
.auth-card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 22px; line-height: 1.5; text-align: left; }
.auth-tabs { display: flex; gap: 4px; margin-bottom: 20px; background: var(--card); padding: 4px; border-radius: 10px; border: 1px solid var(--border); }
.auth-tabs button {
  flex: 1; padding: 8px; border: none; background: transparent; color: var(--muted);
  border-radius: 7px; cursor: pointer; font-size: 13.5px; font-weight: 600; font-family: inherit; transition: all .15s ease;
}
.auth-tabs button.active { background: var(--navy); color: #fff; }
#login-form, #signup-form { text-align: left; }
#login-form label, #signup-form label { font-size: 12px; color: var(--muted); display: block; margin: 14px 0 6px; font-weight: 600; }
#login-form input, #signup-form input {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 9px;
  background: var(--card); color: var(--dark); font-size: 14px; font-family: inherit;
}
#login-form input:focus, #signup-form input:focus { outline: none; border-color: var(--accent); }
.error-msg { color: var(--bad); font-size: 13px; margin-top: 10px; min-height: 16px; }
.success-msg { color: var(--green); font-size: 13px; margin-top: 10px; min-height: 16px; line-height: 1.4; }

.btn {
  background: var(--accent); color: #fff; border: none; padding: 10px 18px;
  border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600; font-family: inherit;
  transition: background .15s ease, transform .05s ease;
}
.btn:hover { background: var(--accent-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: var(--gray-light); color: var(--muted); cursor: default; }
.btn:disabled:hover { background: var(--gray-light); }
.btn.secondary { background: transparent; color: var(--dark); border: 1.5px solid var(--border); font-weight: 600; }
.btn.secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn.secondary:disabled { background: var(--gray-light); color: var(--muted); border-color: var(--border); cursor: default; }
.btn.secondary:disabled:hover { border-color: var(--border); color: var(--muted); }
.btn.full { width: 100%; margin-top: 18px; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger:hover { background: #a5301f; }
.btn.danger:disabled { background: var(--gray-light); color: var(--muted); cursor: default; }
.btn-sm { padding: 6px 13px; font-size: 12.5px; border-radius: 8px; }
.btn-xs { padding: 3px 9px; font-size: 11px; border-radius: 6px; }
.icon-btn {
  background: transparent; border: 1.5px solid var(--border); color: var(--dark); border-radius: 8px;
  padding: 5px 12px; cursor: pointer; font-size: 12.5px; font-weight: 600; transition: all .15s ease; font-family: inherit;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn-danger:hover { border-color: var(--bad); color: var(--bad); }

/* ---------- APP SHELL ---------- */
#app-shell { display: flex; min-height: 100vh; }
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }
.sidebar-close-btn { display: none; }
.sidebar {
  width: 240px; background: var(--navy); color: #fff; padding: 0 14px 18px;
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-logo { padding: 22px 8px 18px; border-bottom: 1px solid rgba(255,255,255,.07); margin-bottom: 14px; }
.structa-logo { display: flex; align-items: baseline; gap: 6px; line-height: 1; }
.structa-word { font-weight: 700; font-size: 19px; letter-spacing: 1.5px; color: #fff; text-transform: uppercase; }
.structa-habits { font-weight: 700; font-size: 19px; letter-spacing: 1.5px; color: var(--accent); text-transform: uppercase; }
.structa-sub { font-size: 9px; font-weight: 600; letter-spacing: 2.5px; text-transform: uppercase; color: rgba(255,255,255,.3); margin-top: 6px; }
.sidebar .who { font-size: 13px; opacity: 0.95; padding: 0 8px; font-weight: 600; color: #fff; }
.tier-badge {
  display: inline-block; background: rgba(232,68,10,.18); color: #ff8552; font-size: 10.5px;
  font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; padding: 3px 9px;
  border-radius: 20px; margin: 8px 8px 18px; width: fit-content;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav button {
  text-align: left; background: none; border: none; color: rgba(255,255,255,.5); padding: 10px 10px;
  border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 500; font-family: inherit; transition: all .15s ease;
  display: flex; align-items: center; gap: 10px;
}
.sidebar nav button::before { font-size: 15px; opacity: 0.9; }
.sidebar nav button[data-tab="hoy"]::before { content: "☀️"; }
.sidebar nav button[data-tab="resumen"]::before { content: "📊"; }
.sidebar nav button[data-tab="metas"]::before { content: "🎯"; }
.sidebar nav button[data-tab="habitos"]::before { content: "🔁"; }
.sidebar nav button[data-tab="pendientes"]::before { content: "📝"; }
.sidebar nav button[data-tab="plan"]::before { content: "💳"; }
.sidebar nav button[data-tab="admin"]::before { content: "🛠️"; }
.sidebar nav button:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav button.active { background: rgba(232,68,10,.2); color: #fff; }
.sidebar nav button.active .nav-icon { color: var(--accent); }
.sidebar .logout { margin-top: 12px; background: transparent; color: rgba(255,255,255,.6); border: 1.5px solid rgba(255,255,255,.15); }
.sidebar .logout:hover { border-color: var(--accent); color: #fff; }

.main { flex: 1; padding: 36px 44px; max-width: 1160px; }
.main h1 { font-family: 'DM Serif Display', serif; font-weight: 400; margin: 0 0 4px; font-size: 32px; line-height: 1.1; color: var(--dark); }
.subtitle { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h3 { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }

/* ---------- HOY ---------- */
.hoy-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.streak-pill {
  display: flex; align-items: center; gap: 6px; background: var(--accent-light); color: var(--accent-strong);
  font-weight: 700; padding: 8px 16px; border-radius: 20px; font-size: 15px; white-space: nowrap;
}
.streak-fire { font-size: 17px; }
.streak-pill-sm { padding: 5px 12px; font-size: 12.5px; }
.streak-pill-sm .streak-fire { font-size: 13px; }
.hoy-bubbles-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 18px 0 6px; }
.hoy-bubble {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px 14px; box-shadow: var(--shadow); cursor: pointer; font-family: inherit;
  transition: border-color .15s ease, transform .1s ease;
}
.hoy-bubble:hover, .hoy-bubble:focus-visible { border-color: var(--accent); transform: translateY(-2px); outline: none; }
.hoy-bubble-icon { display: inline-flex; margin-bottom: 2px; }
.hoy-bubble-icon svg { width: 27px; height: 27px; }
.hoy-bubble-label { font-size: 11px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); }
.hoy-bubble-pct { font-family: 'DM Serif Display', serif; font-size: 30px; color: var(--dark); line-height: 1.1; }
.hoy-bubble-date { font-size: 12px; color: var(--muted); }
.hoy-bubble-streak {
  margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--accent-strong);
  background: var(--accent-light); padding: 3px 10px; border-radius: 20px;
}
.hoy-bubble-grace { margin-top: 4px; font-size: 11.5px; font-weight: 700; color: var(--green); background: var(--green-light); padding: 3px 10px; border-radius: 20px; }
.hoy-bubble-countdown { margin-top: 4px; font-size: 11.5px; font-weight: 700; color: var(--accent-strong); background: var(--accent-light); padding: 3px 10px; border-radius: 20px; }
.hoy-bubble-hint { margin-top: 4px; font-size: 11px; color: var(--muted); }
.hoy-bubble-action {
  margin-top: 8px; background: var(--accent); color: #fff; border: none; padding: 7px 16px;
  border-radius: 20px; font-size: 12.5px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.hoy-bubble-action:hover { background: var(--accent-strong); }
/* Burbuja "cerrada" (Diario, ya cerrado hoy) — deja de verse como si
   invitara a cerrar de nuevo; la racha se mantiene igual de visible, el
   resto del look se calma un poco (Daniel: que se note que ya quedó hecho). */
.hoy-bubble-closed { border-color: var(--green); background: var(--green-light); }
/* Bloqueada = cerrada y sin "Corregir" pedido todavía: tocar la burbuja no
   debe sentirse como que va a pasar algo (Daniel: "que no se pueda tocar
   cualquier parte de la burbuja e ingresar"). Quita el hover de "voy a poder
   entrar" y el cursor vuelve a default; el botón "Corregir" sigue con
   cursor:pointer propio, así se nota que ESE sí hace algo. */
.hoy-bubble-blocked { cursor: default; }
.hoy-bubble-blocked:hover, .hoy-bubble-blocked:focus-visible { border-color: var(--green); transform: none; }
.hoy-bubble-action-locked { background: var(--green); display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.hoy-bubble-action-locked:hover { background: #1f5a3f; }
.hoy-bubble-action-correct { text-decoration: underline; opacity: .85; }

.hoy-detail-back {
  background: none; border: none; color: var(--accent); font-size: 13.5px; font-family: inherit;
  cursor: pointer; padding: 4px 0; margin-bottom: 10px; font-weight: 700;
}
.hoy-detail-back:hover { color: var(--accent-strong); text-decoration: underline; }
.hoy-detail-card .card-head h3 {
  display: flex; align-items: center; gap: 8px; text-transform: none; font-size: 18px; letter-spacing: normal;
  color: var(--dark); font-family: 'DM Serif Display', serif; font-weight: 400;
}
.hoy-detail-card .card-head h3 .hoy-bubble-icon svg { width: 22px; height: 22px; }
.hoy-habito-extras { display: flex; align-items: center; gap: 8px; width: 100%; margin-left: 40px; margin-top: 2px; }
.habito-fire-badge { font-size: 12px; font-weight: 700; color: var(--accent-strong); background: var(--accent-light); padding: 2px 9px; border-radius: 20px; }
.habito-lock-badge { font-size: 12px; font-weight: 700; color: var(--green); background: var(--green-light); padding: 2px 9px; border-radius: 20px; }
.habito-early-close-btn {
  font-size: 12px; font-weight: 700; color: var(--green); background: var(--green-light); border: none;
  padding: 3px 10px; border-radius: 20px; cursor: pointer; font-family: inherit;
}
.habito-early-close-btn:hover { background: var(--green); color: #fff; }
.hoy-backfill-link-wrap { text-align: center; margin: 4px 0 14px; }
.hoy-backfill-link {
  background: none; border: none; color: var(--muted); font-size: 12.5px; font-family: inherit;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px; padding: 4px;
}
.hoy-backfill-link:hover { color: var(--accent); }
.backfill-type-toggle { display: flex; gap: 8px; margin-top: 4px; }
.backfill-type-btn {
  flex: 1; padding: 9px 12px; border-radius: 9px; border: 1.5px solid var(--border); background: var(--card);
  color: var(--dark); font-family: inherit; font-size: 13px; cursor: pointer; font-weight: 600;
}
.backfill-type-btn.active { border-color: var(--accent); background: var(--accent-light); color: var(--accent-strong); }
.backfill-habits-list { margin-top: 14px; max-height: 320px; overflow-y: auto; }
.hoy-habito-row {
  display: flex; align-items: flex-start; flex-wrap: wrap; gap: 14px;
  padding: 10px 10px; border-radius: 10px; transition: background .15s ease; margin-bottom: 3px;
}
.hoy-habito-row-done { background: var(--accent-light); }
/* Gesto de deslizar (prototipo, solo diario/hoy): la fila queda con padding
   0 y overflow oculto; el fondo verde vive debajo y solo se revela mientras
   .hoy-swipe-content (que sí lleva el padding y fondo real) se desliza a la
   derecha con el arrastre. Deslizar completa binarios o congela el valor
   actual en cuantitativos — el check/stepper de siempre sigue funcionando. */
.hoy-habito-row-swipeable { position: relative; overflow: hidden; padding: 0; touch-action: pan-y; }
.hoy-swipe-bg {
  position: absolute; inset: 0; display: flex; align-items: center; padding-left: 18px;
  font-size: 13px; font-weight: 700; color: #fff; background: var(--green); border-radius: 10px;
  opacity: 0; transition: opacity .15s ease; z-index: 0;
}
.hoy-swipe-bg-visible { opacity: 1; }
.hoy-swipe-content {
  position: relative; z-index: 1; display: flex; align-items: flex-start; flex-wrap: wrap; gap: 14px;
  width: 100%; box-sizing: border-box; padding: 10px 10px; background: var(--card); border-radius: 10px;
  cursor: grab;
}
.hoy-habito-row-swipeable.hoy-habito-row-done .hoy-swipe-content { background: var(--accent-light); }
/* 3 secciones (Pendientes / No necesarios / Completados) dentro de una misma
   lista de hábitos — Daniel pidió que lo cumplido baje al final y lo que no
   toca hoy quede en medio, sin competir visualmente con lo pendiente real. */
.hoy-section + .hoy-section { margin-top: 14px; }
.hoy-section-title {
  font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  color: var(--dark); margin: 0 0 6px 4px; padding-bottom: 5px; border-bottom: 2px solid var(--border);
  display: flex; align-items: center; gap: 6px;
}
.hoy-section-count {
  font-size: 11px; font-weight: 700; color: var(--muted); background: var(--border);
  border-radius: 20px; padding: 1px 7px;
}
.hoy-habito-row-summary { align-items: center; gap: 10px; }
.hoy-habito-summary-check {
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700;
  flex-shrink: 0;
}
.hoy-correct-btn, .hoy-edit-done-btn {
  font-size: 12px; font-weight: 700; color: var(--muted); background: transparent;
  border: 1px solid var(--border); padding: 3px 10px; border-radius: 20px; cursor: pointer; font-family: inherit;
}
.hoy-correct-btn:hover, .hoy-edit-done-btn:hover { border-color: var(--accent); color: var(--accent-strong); }
/* El <label> ahora envuelve SOLO el control (checkbox/stepper) — tocar el
   nombre o la descripción del hábito ya no marca nada por accidente. */
.hoy-check { display: flex; align-items: center; cursor: pointer; font-size: 14px; flex-shrink: 0; padding-top: 2px; }
.hoy-check input[type=checkbox] {
  appearance: none; -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--card); cursor: pointer; flex-shrink: 0;
  position: relative; transition: all .15s ease;
}
.hoy-check input[type=checkbox]:hover { border-color: var(--accent); }
.hoy-check input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
.hoy-check input[type=checkbox]:checked::after {
  content: '✓'; color: #fff; font-size: 14px; font-weight: 700; line-height: 1;
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
}
.hoy-habito-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 140px; }
.hoy-habito-name { font-size: 14px; }
.hoy-habito-desc { font-size: 12px; color: var(--muted); line-height: 1.35; }
.hoy-stepper { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.hoy-stepper-btn {
  width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--border); background: var(--card);
  color: var(--accent); font-size: 16px; font-weight: 700; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.hoy-stepper-btn:hover { border-color: var(--accent); background: var(--accent-light); }
.hoy-stepper-target { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.hoy-value-input {
  width: 52px; padding: 5px 2px; border: 1.5px solid var(--border); border-radius: 7px; text-align: center;
  background: var(--card); color: var(--dark); font-family: inherit; -moz-appearance: textfield;
}
.hoy-value-input::-webkit-outer-spin-button, .hoy-value-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stat-pill { background: var(--accent-light); color: var(--accent); font-weight: 700; padding: 5px 12px; border-radius: 20px; font-size: 13px; }
.mood-row { display: flex; gap: 10px; justify-content: space-between; }
/* Cada opción ahora es emoji + palabra debajo (Daniel: "para ser más
   explícitos") — el círculo con el emoji se queda igual, la etiqueta vive
   fuera de él para no forzar el círculo a estirarse. */
.mood-option {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  background: transparent; border: none; cursor: pointer; padding: 2px; font-family: inherit;
}
.mood-option-emoji {
  font-size: 24px; width: 44px; height: 44px; box-sizing: border-box; display: flex;
  align-items: center; justify-content: center; background: var(--card);
  border: 2px solid transparent; border-radius: 50%; line-height: 1; transition: all .15s ease;
}
.mood-option:hover .mood-option-emoji { background: var(--border); }
.mood-option.selected .mood-option-emoji { border-color: var(--accent); background: var(--accent-light); }
.mood-option-label { font-size: 10.5px; font-weight: 600; color: var(--muted); text-align: center; }
.mood-option.selected .mood-option-label { color: var(--accent-strong); }
.agenda-add-row, .pendiente-add-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.agenda-add-row input { flex: 1; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 9px; background: var(--card); color: var(--dark); font-family: inherit; }
.pendiente-add-row input, .pendiente-add-row select { padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 9px; background: var(--card); color: var(--dark); font-family: inherit; }
.pendiente-add-row input[type=text] { flex: 1; min-width: 140px; }
.cierre-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  padding: 16px 22px; border-radius: var(--radius-lg); margin-top: 10px; color: #fff;
}
.cierre-bar span { font-size: 14px; color: rgba(255,255,255,.85); }
.cierre-bar strong { color: #fff; }

/* ---------- RESUMEN ---------- */
.resumen-period-bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  margin-bottom: 18px;
}
.resumen-period-tabs { display: flex; gap: 6px; background: var(--card); border: 1.5px solid var(--border); border-radius: 11px; padding: 4px; }
.resumen-period-tab {
  padding: 8px 16px; border-radius: 8px; border: none; background: none; color: var(--muted);
  font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.resumen-period-tab:hover { color: var(--dark); }
.resumen-period-tab.active { background: var(--accent); color: #fff; }
.resumen-period-nav { display: flex; align-items: center; gap: 10px; }
.resumen-period-nav-label { font-size: 14px; font-weight: 600; color: var(--dark); min-width: 160px; text-align: center; }
.resumen-period-nav-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1.5px solid var(--border); background: var(--card);
  color: var(--dark); font-size: 16px; cursor: pointer; line-height: 1;
}
.resumen-period-nav-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.resumen-period-nav-btn:disabled { opacity: .35; cursor: default; }
.resumen-consolidado-card { text-align: center; padding: 26px 20px; margin-bottom: 22px; }
.resumen-consolidado-label { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.resumen-consolidado-value { font-family: 'DM Serif Display', serif; font-size: 48px; font-weight: 400; color: var(--accent-strong); line-height: 1.1; }
.resumen-consolidado-card .muted { font-size: 12.5px; margin-top: 6px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px,1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { border-left: 3px solid var(--accent); position: relative; overflow: hidden; }
.stat-card .stat-icon { position: absolute; right: 12px; top: 12px; font-size: 26px; opacity: .14; }
.stat-grid .stat-card:nth-child(3n+2) { border-left-color: var(--green); }
.stat-grid .stat-card:nth-child(3n+3) { border-left-color: var(--blue); }
.stat-card .stat-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; font-weight: 500; }
.stat-card .stat-value { font-family: 'DM Serif Display', serif; font-size: 28px; font-weight: 400; color: var(--dark); }
.stat-card .stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.mini-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.mini-row:last-child { border-bottom: none; }

/* Hábitos de Resumen agrupados por periodicidad, en filas lineales con barra
   (reemplaza el grid de tarjetas — Daniel: "muchos números... se siente
   saturado"). Colores por desempeño real, no por posición. Ancho completo,
   NO grid multi-columna (eso fue lo que producía columnas angostas con
   nombres cortados en la primera prueba en vivo). */
.resumen-habits-groups { margin-bottom: 8px; }
.resumen-periodicity-group { margin-bottom: 10px; }
.resumen-periodicity-header {
  display: flex; align-items: center; gap: 8px; width: 100%; margin-bottom: 8px;
  background: none; border: none; padding: 4px 0; cursor: pointer; font-family: inherit; text-align: left;
}
.resumen-periodicity-icon { font-size: 15px; }
.resumen-periodicity-title { font-size: 13px; font-weight: 600; color: var(--dark2); }
.resumen-periodicity-avg { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.resumen-periodicity-chevron { font-size: 15px; color: var(--muted); transition: transform .15s ease; }
.resumen-periodicity-group.open .resumen-periodicity-chevron { transform: rotate(90deg); }
.resumen-periodicity-body {
  display: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2px 16px;
}
.resumen-periodicity-group.open .resumen-periodicity-body { display: block; margin-bottom: 20px; }
.resumen-habit-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.resumen-habit-row:last-child { border-bottom: none; }
.resumen-habit-name { font-size: 13px; color: var(--dark2); width: 42%; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resumen-habit-bar-track { flex: 1; height: 6px; background: var(--gray-light); border-radius: 4px; overflow: hidden; }
.resumen-habit-bar-fill { height: 100%; border-radius: 4px; }
.resumen-habit-pct { font-size: 12.5px; font-weight: 600; width: 38px; text-align: right; flex-shrink: 0; }
.resumen-tier-good { background: var(--green); }
.resumen-tier-mid { background: var(--amber); }
.resumen-tier-low { background: var(--bad); }
.resumen-tier-text-good { color: var(--green); }
.resumen-tier-text-mid { color: var(--amber); }
.resumen-tier-text-low { color: var(--bad); }

/* Metas "en curso" en burbuja dentro de Resumen — visibles con su categoría,
   no solo un número (Daniel: "que se vea lo que quiero cumplir"). */
.resumen-goal-bubbles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 10px; margin-bottom: 14px; }
.resumen-goal-bubble { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.resumen-goal-bubble-cat { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.resumen-goal-bubble-title { font-size: 13px; font-weight: 500; color: var(--dark2); line-height: 1.35; }
.resumen-goal-bubble-countdown { font-size: 11px; color: var(--accent-strong); margin-top: 6px; }

/* ---------- TABLES / LISTS ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 10px 8px; color: var(--muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 2px solid var(--border); }
td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--border); }
tr:hover td { background: var(--card); }
.filters { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.filters select {
  padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 9px; background: var(--surface);
  color: var(--dark); font-size: 13px; font-family: inherit; cursor: pointer;
}
.filters select:focus { outline: none; border-color: var(--accent); }
.spacer { flex: 1; }

/* bubble/chip filters */
.chip-row { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 7px 14px; border-radius: 100px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--muted);
  font-size: 12.5px; font-weight: 600; cursor: pointer; transition: all .15s ease; font-family: inherit;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }

.badge { background: var(--accent-light); color: var(--accent); padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-gray { background: var(--gray-light); color: var(--muted); }
.badge-orange { background: var(--accent-light); color: var(--accent); }
.badge-green { background: var(--green-light); color: var(--green); }
.badge-red { background: var(--red-light); color: var(--bad); }
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-teal { background: var(--teal-light); color: var(--teal); }
.tag { background: var(--card); border: 1px solid var(--border); color: var(--muted); padding: 3px 9px; border-radius: 6px; font-size: 11px; margin-left: 6px; }
.habit-row { padding: 14px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 5px; }
.habit-row:last-child { border-bottom: none; }
.habit-row-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* empty state */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .empty-icon { font-size: 40px; margin-bottom: 10px; opacity: .5; }
.empty p { font-size: 13.5px; margin: 0; }

/* ---------- MODALS ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(26,22,18,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 28px; width: 480px; max-width: 92vw; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal.modal-wide { width: 640px; }
.modal h3 { font-family: 'DM Serif Display', serif; font-weight: 400; margin-top: 0; font-size: 22px; color: var(--dark); }
.modal label { font-size: 12px; color: var(--muted); display: block; margin: 12px 0 6px; font-weight: 600; }
.modal input, .modal select, .modal textarea {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 9px;
  font-family: inherit; background: var(--card); color: var(--dark); font-size: 14px;
}
.modal input:focus, .modal select:focus, .modal textarea:focus { outline: none; border-color: var(--accent); }
.modal textarea { min-height: 64px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.form-section { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.form-section-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 4px;
}
.advanced-details { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.advanced-details summary {
  cursor: pointer; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); list-style: none;
}
.advanced-details summary::-webkit-details-marker { display: none; }
.advanced-details summary::before { content: '▸ '; }
.advanced-details[open] summary::before { content: '▾ '; }
.advanced-details[open] summary { margin-bottom: 8px; }

/* Frase-resumen en vivo del formulario de hábitos — Daniel: que la persona
   entienda qué le van a preguntar y cuándo cumple sin tener que traducir
   selects con jerga interna. */
.habit-preview-box {
  margin-top: 18px; padding: 12px 14px; border-radius: 12px;
  background: var(--accent-light); border: 1px solid var(--accent);
}
.habit-preview-label {
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--accent-strong); margin: 0 0 4px;
}
.habit-preview-text { font-size: 13.5px; color: var(--dark); margin: 0; line-height: 1.4; }

/* ---------- MI PLAN ---------- */
.sub-current {
  background: linear-gradient(135deg, var(--navy), var(--navy-2)); border-radius: var(--radius-lg);
  padding: 22px 26px; color: #fff; margin-bottom: 20px;
}
.sub-plan-label { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: rgba(255,255,255,.4); margin-bottom: 6px; }
.sub-plan-name { font-family: 'DM Serif Display', serif; font-size: 26px; margin-bottom: 4px; }
.sub-plan-meta { font-size: 13px; color: rgba(255,255,255,.55); }
.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; max-width: 980px; }
.plan-card { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius-lg); padding: 22px; position: relative; }
.plan-card.featured { border-color: var(--accent); background: #fffaf7; }
.plan-badge {
  position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; padding: 4px 14px; border-radius: 100px;
}
.plan-name { font-family: 'DM Serif Display', serif; font-size: 20px; margin-bottom: 6px; }
.plan-price { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.plan-price strong { font-size: 24px; color: var(--dark); font-family: 'DM Serif Display', serif; }
.plan-feature { font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.plan-feature:last-of-type { border-bottom: none; }
.plan-feature.muted { color: var(--muted); }

/* ---------- ADJUNTOS (link + imagen) ---------- */
.attachment-preview { margin-top: 10px; display: flex; align-items: center; gap: 10px; }
.attachment-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 9px; border: 1.5px solid var(--border); }
.attachment-preview .remove-attachment { font-size: 12px; color: var(--bad); background: none; border: none; cursor: pointer; font-weight: 600; font-family: inherit; }

/* ---------- METAS: agrupación por temporalidad + tarjetas ---------- */
.goals-group { margin-bottom: 26px; }
.goals-group-title {
  font-family: 'DM Serif Display', serif; font-size: 19px; font-weight: 400; color: var(--dark);
  margin: 0 0 14px; padding-bottom: 8px; border-bottom: 2px solid var(--accent); display: inline-block;
}
.goals-cards { display: flex; flex-direction: column; gap: 10px; }
.goal-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow); }
.goal-card-title { font-size: 15.5px; font-weight: 600; color: var(--dark); margin: 0 0 10px; padding-right: 36px; }
.goal-card-number { position: absolute; top: 16px; right: 18px; color: var(--muted); font-weight: 600; font-size: 12px; }
.goal-card-badges { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 8px; }
.goal-card-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.goal-card-meta-group { display: flex; flex-direction: column; gap: 3px; }
.goal-card-meta { font-size: 12px; color: var(--muted); }
.goal-card-countdown { font-size: 12.5px; color: var(--accent); font-weight: 700; }
.goal-card-done { font-size: 12.5px; color: var(--green); font-weight: 700; }
.goal-card-desc { font-size: 13px; color: var(--muted); margin: 0 0 10px; line-height: 1.4; }
.goal-card-foot-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 55%; }
.goal-card-actions { display: flex; gap: 6px; align-items: center; }
.goal-card-update { font-size: 12px; color: var(--muted); font-style: italic; text-align: right; line-height: 1.35; }

/* ---------- SELECTOR DE DÍAS (hábitos) ---------- */
.day-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.day-btn {
  flex: 1; min-width: 42px; padding: 8px 4px; border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--dark); font-size: 12.5px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: background .1s ease, border-color .1s ease;
}
.day-btn:hover { border-color: var(--accent); }
.day-btn.selected { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- HÁBITOS: mismo lenguaje visual que Metas ---------- */
.habits-cards { display: flex; flex-direction: column; gap: 10px; }
.habit-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow); }
.habit-card-inactive { opacity: .6; }
.habit-card-title { font-size: 15.5px; font-weight: 600; color: var(--dark); margin: 0 0 10px; padding-right: 36px; }
.habit-card-number { position: absolute; top: 16px; right: 18px; color: var(--muted); font-weight: 600; font-size: 12px; }
.habit-card-badges { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 8px; }
.habit-card-desc { font-size: 13px; color: var(--muted); margin: 0 0 10px; line-height: 1.4; }
.habit-card-achievement {
  font-size: 11.5px; color: var(--accent); font-style: italic; margin: -4px 0 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.habit-card-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.habit-card-actions { display: flex; gap: 6px; align-items: center; }
.habit-card-meta-group { display: flex; flex-direction: column; gap: 3px; }
.habit-card-meta { font-size: 12px; color: var(--muted); }

/* ---------- PENDIENTES / HITOS: mismo lenguaje visual que Metas/Hábitos ---------- */
.pend-cards { display: flex; flex-direction: column; gap: 10px; }
.pend-card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 18px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px; }
.pend-card.pend-card-done { opacity: .6; }
.pend-card-check { flex-shrink: 0; }
.pend-card-check input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
.pend-card-body { flex: 1; min-width: 0; }
.pend-card-title { font-size: 15px; font-weight: 600; color: var(--dark); margin: 0 0 6px; }
.pend-card-title.pend-title-done { text-decoration: line-through; color: var(--muted); }
.pend-card-badges { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 4px; }
.pend-card-meta { font-size: 12px; color: var(--muted); }
.pend-card-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* ---------- SELECT PERSONALIZADO (reemplaza el look nativo del navegador) ---------- */
.xselect { position: relative; }
.filters .xselect { min-width: 190px; }

.search-box {
  display: flex; align-items: center; gap: 7px; padding: 8px 12px;
  border: 1.5px solid var(--border); border-radius: 9px; background: var(--surface); min-width: 200px;
}
.search-box .search-icon { font-size: 13px; opacity: .6; }
.search-box input {
  border: none; outline: none; background: transparent; font-family: inherit; font-size: 13px;
  color: var(--dark); width: 100%;
}

.load-more-wrap { display: flex; justify-content: center; margin-top: 18px; }
.xselect select { display: none; }
.xselect-trigger {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border); border-radius: 9px; background: var(--card);
  color: var(--dark); font-size: 14px; font-family: inherit; cursor: pointer; text-align: left;
}
.xselect-trigger:hover { border-color: var(--accent); }
.xselect-disabled .xselect-trigger { cursor: default; opacity: .6; background: var(--gray-light); }
.xselect-disabled .xselect-trigger:hover { border-color: var(--border); }
.xselect.open .xselect-trigger { border-color: var(--accent); }
.xselect-trigger .xselect-icon { font-size: 16px; line-height: 1; flex-shrink: 0; }
.xselect-trigger .xselect-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.xselect-trigger .xselect-label { flex: 1; font-weight: 600; }
.xselect-trigger .xselect-chevron { color: var(--muted); font-size: 11px; transition: transform .15s ease; }
.xselect.open .xselect-trigger .xselect-chevron { transform: rotate(180deg); }
.xselect-panel {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 40;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; max-height: 300px; overflow-y: auto;
}
.xselect-option {
  display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; border-radius: 8px;
  cursor: pointer; transition: background .1s ease;
}
.xselect-option:hover { background: var(--card); }
.xselect-option.selected { background: var(--accent-light); }
.xselect-option .xselect-icon { font-size: 17px; line-height: 1.3; flex-shrink: 0; }
.xselect-option .xselect-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.xselect-option-text { display: flex; flex-direction: column; gap: 1px; }
.xselect-option-label { font-size: 13.5px; font-weight: 600; color: var(--dark); }
.xselect-option-desc { font-size: 11.5px; color: var(--muted); line-height: 1.3; }

@media (max-width: 720px) {
  .plan-grid { grid-template-columns: 1fr; }
  #app-shell { flex-direction: column; }
  .hoy-grid { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .main { padding: 18px 16px 32px; }

  /* Barra superior fija con botón de menú, reemplaza el sidebar apilado */
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 45;
    background: var(--navy); color: #fff;
    padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  }
  .mobile-topbar-logo { display: flex; align-items: baseline; gap: 5px; line-height: 1; }
  .mobile-topbar-logo .structa-word { font-size: 15px; letter-spacing: 1px; }
  .mobile-topbar-logo .structa-habits { font-size: 15px; letter-spacing: 1px; }
  .mobile-menu-btn {
    background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15); color: #fff;
    width: 38px; height: 38px; border-radius: 9px; font-size: 17px; cursor: pointer; line-height: 1;
  }

  /* Sidebar se convierte en panel deslizable (drawer) */
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100%; width: 82vw; max-width: 300px;
    z-index: 60; transform: translateX(-100%); transition: transform .22s ease;
    overflow-y: auto; padding-top: env(safe-area-inset-top);
    box-shadow: var(--shadow-lg);
  }
  #app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-close-btn {
    display: block; align-self: flex-end; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15);
    color: #fff; width: 34px; height: 34px; border-radius: 8px; font-size: 15px; cursor: pointer; margin: 14px 14px 0 0;
  }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(26,22,18,.5); z-index: 55;
    opacity: 0; pointer-events: none; transition: opacity .22s ease;
  }
  #app-shell.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

  /* Objetivos táctiles más cómodos */
  .icon-btn.btn-xs { padding: 8px 14px; font-size: 12.5px; }
  .day-btn { min-width: 44px; padding: 11px 4px; }
  .mood-option-emoji { width: 40px; height: 40px; }
  .hoy-check input[type=checkbox] { width: 21px; height: 21px; }
  .hoy-bubbles-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .hoy-bubble { padding: 16px 8px; }
  .hoy-bubble-pct { font-size: 24px; }
  .hoy-habito-extras { margin-left: 0; }

  /* Modales: menos padding y sin recortarse */
  .modal { padding: 20px; }
  .modal-actions { padding-bottom: env(safe-area-inset-bottom); }

  /* Tarjetas de meta/hábito: pie en columna para que los botones no queden apretados */
  .goal-card-foot, .habit-card-foot { flex-direction: column; align-items: stretch; }
  .goal-card-foot-right { max-width: 100%; align-items: flex-start; }
  .goal-card-actions, .habit-card-actions { justify-content: flex-end; }

  /* Tarjetas de pendientes/hitos: apilar en vez de apretar checkbox+texto+botones en una fila */
  .pend-card { flex-wrap: wrap; }
  .pend-card-body { flex-basis: 100%; order: 1; }
  .pend-card-actions { order: 2; margin-left: auto; }
}
