/* RBF Hub — design system v0.3 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font: "DM Sans", system-ui, -apple-system, sans-serif;

  --bg: #f0f4f8;
  --bg-dark: #0f172a;
  --bg-dark-2: #1e293b;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #dbeafe;
  --primary-glow: rgba(37, 99, 235, 0.35);

  --accent: #8b5cf6;
  --success: #059669;
  --success-soft: #d1fae5;
  --error: #dc2626;
  --error-soft: #fee2e2;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.12);

  --sidebar-w: 260px;
  --touch-min: 48px;
  --nav-h: 68px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  width: 100%;
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 100%;
  min-height: 100dvh;
}

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

.muted { color: var(--muted); font-size: 0.875rem; }

/* ─── Brand mark ─── */
.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px var(--primary-glow);
}

.brand-mark-sm {
  width: 40px;
  height: 40px;
  border-radius: 12px;
}

.brand-letter {
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

.brand-mark-sm .brand-letter { font-size: 1.15rem; }

/* ─── Login ─── */
.login-shell {
  display: grid;
  min-height: 100dvh;
  width: 100%;
}

.login-hero {
  display: none;
  position: relative;
  background: var(--bg-dark);
  overflow: hidden;
  padding: 48px;
}

.login-hero-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 80%, rgba(37, 99, 235, 0.45) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 80% 20%, rgba(139, 92, 246, 0.35) 0%, transparent 50%),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(37, 99, 235, 0.15) 0%, transparent 70%);
}

.login-hero-content {
  position: relative;
  z-index: 1;
  max-width: 420px;
  margin-top: auto;
  margin-bottom: auto;
}

.hero-title {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 700;
  color: #fff;
  line-height: 1.15;
  margin: 28px 0 16px;
  letter-spacing: -0.02em;
}

.hero-sub {
  color: #94a3b8;
  font-size: 1.05rem;
  margin-bottom: 32px;
  line-height: 1.6;
}

.hero-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hero-features li {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #cbd5e1;
  font-size: 0.95rem;
}

.feat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  flex-shrink: 0;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  padding-top: calc(24px + var(--safe-top));
  min-height: 100dvh;
  width: 100%;
  background:
    radial-gradient(ellipse 100% 80% at 50% -20%, rgba(37, 99, 235, 0.08) 0%, transparent 60%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}

.login-brand-mobile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.login-brand-mobile h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

.login-intro { margin-bottom: 28px; }

.login-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.login-form { display: flex; flex-direction: column; gap: 18px; }

.field { display: block; }

.field-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface-2);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  min-height: var(--touch-min);
}

.field input::placeholder { color: #94a3b8; }

.field input:hover { border-color: var(--border-strong); }

.field input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 14px 24px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: var(--touch-min);
  box-shadow: 0 4px 14px var(--primary-glow);
  transition: transform var(--transition), box-shadow var(--transition), filter var(--transition);
}

.btn-primary:hover {
  filter: brightness(1.05);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-primary:active { transform: scale(0.98); }

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-block { width: 100%; }

.btn-large { padding: 16px 24px; font-size: 1.05rem; }

.btn-arrow { transition: transform var(--transition); }
.btn-primary:hover .btn-arrow { transform: translateX(3px); }

.btn-ghost {
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 16px;
  cursor: pointer;
  min-height: 40px;
  transition: background var(--transition), border-color var(--transition);
}

.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.error-banner {
  padding: 12px 14px;
  background: var(--error-soft);
  color: var(--error);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.75rem;
}

/* Desktop login split */
@media (min-width: 900px) {
  .login-shell {
    grid-template-columns: 1fr 1fr;
  }

  .login-hero { display: flex; align-items: center; }

  .login-brand-mobile { display: none; }

  .login-panel {
    padding: 48px;
  }

  .login-card {
    max-width: 420px;
    padding: 40px 36px;
  }
}

/* ─── App shell ─── */
.app-shell {
  display: flex;
  min-height: 100dvh;
  width: 100%;
}

.sidebar {
  display: none;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
}

.app-header {
  padding: 20px 20px 12px;
  padding-top: calc(20px + var(--safe-top));
}

.header-eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 4px;
}

.app-header h1,
#page-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.header-date {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
  text-transform: capitalize;
}

.panels {
  flex: 1;
  padding: 0 16px 24px;
}

.panel[hidden] { display: none !important; }

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.panel-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-card-head h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.panel-desc { margin-bottom: 16px; font-size: 0.9rem; }

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  white-space: nowrap;
}

.badge-soft {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* Timeline events */
.events-timeline {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.events-timeline li {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.events-timeline li:last-child { border-bottom: none; }

.event-marker {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 6px;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.event-body { flex: 1; min-width: 0; }

.event-time {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 2px;
}

.event-title {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.4;
}

.events-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Check-ins */
.checkin-chips {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.check-chip {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: var(--touch-min);
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-family: inherit;
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  transition: all var(--transition);
}

.check-chip:hover { border-color: var(--border-strong); background: var(--surface); }

.check-chip[aria-pressed="true"] {
  border-color: var(--success);
  background: var(--success-soft);
}

.check-chip-id {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}

.check-chip[aria-pressed="true"] .check-chip-id {
  background: var(--success);
  color: #fff;
}

.energia-block {
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.energia-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.energia-chips {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.energia-chip {
  min-height: 44px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.energia-chip:hover { border-color: var(--border-strong); }

.energia-chip[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.save-status {
  margin-top: 14px;
  min-height: 20px;
  font-size: 0.8125rem;
  font-weight: 500;
}

.save-status.saving { color: var(--muted); }
.save-status.saved { color: var(--success); }
.save-status.error { color: var(--error); }

/* Workout */
.workout-card-inner {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.workout-key {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  margin-bottom: 8px;
}

.workout-label {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.workout-focus {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 16px;
}

.workout-exercises {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.workout-exercises li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.workout-exercises li::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
}

.workout-done {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--success-soft);
  color: var(--success);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
}

/* Bottom nav (mobile) */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  padding: 8px 4px;
  transition: color var(--transition);
}

.nav-svg {
  width: 22px;
  height: 22px;
}

.nav-item.active { color: var(--primary); }

.nav-item.active .nav-svg { stroke: var(--primary); }

/* Desktop layout */
@media (min-width: 900px) {
  .desktop-hide { display: none; }

  .bottom-nav { display: none; }

  .app-main {
    padding-bottom: 0;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
  }

  .app-shell {
    background: var(--bg);
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-dark);
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100dvh;
  }

  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px 28px;
  }

  .sidebar-title {
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
  }

  .sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: #94a3b8;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: all var(--transition);
  }

  .sidebar-link .nav-svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  .sidebar-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
  }

  .sidebar-link.active {
    background: rgba(37, 99, 235, 0.2);
    color: #fff;
  }

  .sidebar-link.active .nav-svg { stroke: #60a5fa; }

  .sidebar-logout {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    margin-top: auto;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: #64748b;
    font-family: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition);
  }

  .sidebar-logout:hover {
    background: rgba(220, 38, 38, 0.15);
    color: #f87171;
  }

  .app-header {
    padding: 32px 32px 20px;
  }

  .panels {
    padding: 0 32px 40px;
  }

  .panel-card {
    padding: 28px 32px;
  }

  .energia-chips {
    grid-template-columns: repeat(10, 1fr);
    max-width: 480px;
  }
}

@media (min-width: 1200px) {
  .app-main { max-width: 960px; }
}

/* ─── Calendário 90d (estilo Calendario/visual/calendario-90d.html) ─── */
.cal-panel { padding: 16px !important; }

.cal-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cal-toolbar-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.cal-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-left: 4px;
  text-transform: capitalize;
}

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.cal-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cal-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.cal-dot-wake { background: #b06000; }
.cal-dot-gym { background: #137333; }
.cal-dot-work { background: #1967d2; }
.cal-dot-sleep { background: #3949ab; }
.cal-dot-custom { background: #64748b; }

.cal-hint {
  font-size: 0.75rem;
  margin-bottom: 12px;
}

.cal-loading { font-size: 0.875rem; margin-bottom: 8px; }

.cal-grid-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.cal-grid-90d {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  min-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cal-dow {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.cal-cell {
  min-height: 100px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 4px 6px 6px;
  background: var(--surface);
  vertical-align: top;
}

.cal-cell:nth-child(7n) { border-right: none; }

.cal-cell-other {
  background: var(--surface-2);
}

.cal-cell-today .cal-num {
  background: var(--primary);
  color: #fff;
}

.cal-cell-cycle {
  box-shadow: inset 0 0 0 2px var(--primary);
}

.cal-num {
  float: right;
  font-size: 0.75rem;
  line-height: 20px;
  min-width: 20px;
  text-align: center;
  border-radius: 50%;
  color: var(--text-secondary);
  font-weight: 600;
}

.cal-cell-other .cal-num { color: var(--muted); }

.cal-phase {
  font-size: 0.55rem;
  color: var(--muted);
  margin-top: 2px;
  clear: both;
  line-height: 1.2;
}

.cal-events {
  clear: both;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-ev {
  font-size: 0.65rem;
  line-height: 1.25;
  padding: 2px 4px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  border: none;
  font-family: inherit;
  text-align: left;
  width: 100%;
  transition: filter 0.15s;
}

.cal-ev:hover { filter: brightness(0.95); }

.cal-ev-gym { background: #e6f4ea; color: #137333; }
.cal-ev-work { background: #e8f0fe; color: #1967d2; }
.cal-ev-study { background: #f3e8fd; color: #7627bb; }
.cal-ev-wake { background: #fef7e0; color: #b06000; }
.cal-ev-sleep { background: #e8eaf6; color: #3949ab; }
.cal-ev-meal { background: #fff3e0; color: #e65100; }
.cal-ev-read { background: #f3e8fd; color: #7627bb; }
.cal-ev-commute { background: #e0f2f1; color: #00695c; }
.cal-ev-family { background: #fce4ec; color: #c2185b; }
.cal-ev-custom { background: #f1f5f9; color: #475569; }

.btn-icon {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.8rem;
  min-height: 36px;
}

.btn-danger {
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--error-soft);
  color: var(--error);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* Modal evento */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal.hidden { display: none !important; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}

.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px;
  box-shadow: var(--shadow-lg);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-head h2 { font-size: 1.1rem; }

.event-form .field { margin-bottom: 14px; }

.field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.event-form textarea,
.event-form select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  background: var(--surface);
}

.event-form input[type="color"] {
  width: 100%;
  height: 44px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.weekday-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.wd-chip {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.wd-chip.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

.modal-actions .btn-primary { flex: 1; }

@media (min-width: 600px) {
  .modal { align-items: center; }
  .modal-sheet {
    border-radius: var(--radius-lg);
    margin: 20px;
  }
  .cal-cell { min-height: 110px; }
}

@media (min-width: 900px) {
  .app-main:has(#panel-calendario.active) { max-width: 1100px; }
  .app-main:has(#panel-financas.active) { max-width: 1200px; }
  .cal-cell { min-height: 120px; }
  .cal-ev { font-size: 0.7rem; }
}

/* Finanças casal */
.fin-panel { padding: 0; overflow: hidden; }
.fin-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 12px;
  flex-wrap: wrap;
}
.fin-toolbar h2 { font-size: 1.25rem; margin: 0; }
.fin-meta-line { font-size: 0.8rem; margin-top: 4px; }
.fin-hint { padding: 0 20px 12px; font-size: 0.75rem; }
.fin-resumo {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 0 20px 16px;
}
.fin-holerites {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  padding: 0 20px 16px;
}
.fin-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  flex: 1;
  min-width: 140px;
}
.fin-card h3 { font-size: 0.85rem; margin-bottom: 8px; color: #1b5e20; }
.fin-nome { font-weight: 600; font-size: 0.8rem; margin-bottom: 8px; }
.fin-card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 0.75rem;
}
.fin-card dt { color: var(--muted); }
.fin-card dd { text-align: right; font-variant-numeric: tabular-nums; }
.fin-nota { margin-top: 8px; font-size: 0.7rem; color: #e65100; }
.fin-big { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 4px; }
.fin-meta { font-size: 0.7rem; color: var(--muted); margin-top: 4px; }
.fin-caixa-card { cursor: pointer; }
.fin-caixa-card:hover { border-color: #1565c0; }
.fin-legenda {
  margin: 0 20px 12px;
  padding: 8px 12px;
  background: #e8f5e9;
  border-left: 4px solid #2e7d32;
  border-radius: 4px;
  color: #1b5e20;
  font-size: 0.75rem;
}
.fin-sheet-wrap {
  padding: 0 12px 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.fin-sheet {
  border-collapse: collapse;
  background: #fff;
  min-width: 900px;
  width: 100%;
  font-size: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.fin-sheet th, .fin-sheet td {
  border: 1px solid #d0d5dd;
  padding: 6px 8px;
  text-align: right;
  white-space: nowrap;
}
.fin-sheet th:first-child, .fin-sheet td:first-child {
  text-align: left;
  min-width: 180px;
  position: sticky;
  left: 0;
  background: inherit;
  z-index: 1;
}
.fin-sheet thead th {
  background: #f3f4f6;
  font-weight: 600;
  text-align: center;
}
.fin-sec-head td {
  font-weight: 700;
  color: #fff;
  text-align: left !important;
}
.fin-sec-head td:first-child { padding-left: 14px; }
.fin-subtotal td { font-weight: 700; background: #f9fafb; }
.fin-subtotal-hint {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  margin-top: 2px;
}
.fin-subtotal-hint .pos { color: #2e7d32; }
.fin-subtotal-hint .neg { color: #c62828; }
.fin-pct td { font-style: italic; color: #555; background: #fafafa; }
.fin-saldo-row td { font-weight: 700; font-size: 14px; }
.fin-real-row td { font-weight: 600; }
.fin-real-row.pago-real td:not(:first-child) { background: #e8f5e9; color: #1b5e20; }
.fin-real-row.faltante td:not(:first-child) { background: #fff8e1; color: #e65100; }
.fin-real-row.caixa td:not(:first-child) { background: #e3f2fd; color: #1565c0; }
.fin-sheet .pos { color: #2e7d32; }
.fin-sheet .neg { color: #c62828; }
.fin-sheet .empty { color: #9aa0a6; }
.fin-sheet td.pago {
  background: #c8e6c9 !important;
  color: #1b5e20;
  font-weight: 600;
  cursor: pointer;
}
.fin-sheet td.pago-cartao {
  background: #b2dfdb !important;
  color: #00695c;
  font-weight: 600;
  cursor: pointer;
}
.fin-cell[data-toggle="pago"] { cursor: pointer; }
.fin-cell-toggle {
  box-shadow: inset 0 0 0 1px rgba(46, 125, 50, 0.25);
}
.fin-cell-toggle:hover {
  background: #f1f8e9 !important;
}
.fin-cell[data-toggle="pago"]:active { opacity: 0.85; }
.fin-toast {
  margin: 0 20px 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.fin-toast-ok { background: #e8f5e9; color: #1b5e20; border-left: 4px solid #2e7d32; }
.fin-toast-info { background: #e3f2fd; color: #0d47a1; border-left: 4px solid #1565c0; }
.fin-toast-err { background: #ffebee; color: #b71c1c; border-left: 4px solid #c62828; }
.fin-row-pago td:first-child {
  background: #e8f5e9 !important;
  color: #1b5e20;
}
.fin-label-cell { cursor: pointer; }
.fin-label-cell:hover { text-decoration: underline; }
.fin-caixa-cell { cursor: pointer; }

/* Trades / Mesa Guardião */
.trades-panel { padding: 0; }
.trades-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 12px;
}
.trades-toolbar h2 { font-size: 1.25rem; margin: 0; }
.trades-meta-line { font-size: 0.8rem; margin-top: 4px; }
.trades-banner {
  margin: 0 20px 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
}
.trades-banner-block {
  background: #ffebee;
  color: #c62828;
  border-left: 4px solid #c62828;
}
.trades-banner-wait {
  background: #fff8e1;
  color: #e65100;
  border-left: 4px solid #e65100;
}
.trades-pnl-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 20px 16px;
}
.trades-pnl-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}
.trades-pnl-label {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.trades-pnl-value {
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.trades-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 16px;
  padding: 0 20px 12px;
  font-size: 0.85rem;
}
.trades-stats strong {
  display: block;
  font-size: 1rem;
  margin-top: 2px;
}
.trades-meta { padding: 0 20px 12px; font-size: 0.8rem; }
.trades-period-tabs {
  display: flex;
  gap: 8px;
  padding: 0 20px 12px;
}
.trades-period-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}
.trades-period-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.mesa-period-label {
  margin: 0 20px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: capitalize;
}
.mesa-health {
  margin: 0 20px 16px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.mesa-health-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.mesa-health-head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mesa-health-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eceff1;
  color: #546e7a;
}
.mesa-health-badge.green { background: #e8f5e9; color: #1b5e20; }
.mesa-health-badge.yellow { background: #fff8e1; color: #f57f17; }
.mesa-health-badge.red { background: #ffebee; color: #b71c1c; }
.mesa-health-hint {
  margin: 0 0 12px;
  font-size: 0.75rem;
}
.mesa-health-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}
@media (min-width: 640px) {
  .mesa-health-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
.mesa-health-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mesa-health-item span,
.mesa-health-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.mesa-health-item strong {
  font-size: 0.9rem;
  font-weight: 700;
}
.mesa-health-item strong.pos { color: #2e7d32; }
.mesa-health-item strong.neg { color: #c62828; }
.mesa-tip {
  position: relative;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 1px solid #90a4ae;
  border-radius: 50%;
  background: #eceff1;
  color: #455a64;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  flex-shrink: 0;
}
.mesa-tip:hover,
.mesa-tip:focus,
.mesa-tip.is-open {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  outline: none;
}
.mesa-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  width: min(260px, 70vw);
  padding: 8px 10px;
  border-radius: 8px;
  background: #263238;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.35;
  text-transform: none;
  letter-spacing: 0;
  text-align: left;
  white-space: normal;
  box-shadow: 0 6px 18px rgba(0,0,0,.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
  z-index: 30;
}
.mesa-tip::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #263238;
  opacity: 0;
  pointer-events: none;
  z-index: 30;
}
.mesa-tip:hover::after,
.mesa-tip:hover::before,
.mesa-tip:focus::after,
.mesa-tip:focus::before,
.mesa-tip.is-open::after,
.mesa-tip.is-open::before {
  opacity: 1;
}
.trades-events {
  list-style: none;
  margin: 0;
  padding: 0 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.trades-event {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.trades-ev-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.trades-ev-type {
  font-weight: 600;
  font-size: 0.85rem;
}
.trades-ev-type.pos { color: #2e7d32; }
.trades-ev-type.neg { color: #c62828; }
.trades-ev-time {
  font-size: 0.75rem;
  color: var(--muted);
}
.trades-ev-body {
  font-size: 0.8rem;
  color: var(--text);
}
.trades-ev-body .pos { color: #2e7d32; font-weight: 600; }
.trades-ev-body .neg { color: #c62828; font-weight: 600; }
.trades-event-force_close_loss,
.trades-event-blocked_entry_reject,
.trades-event-neg {
  border-left: 3px solid #c62828;
}
.trades-event-pos {
  border-left: 3px solid #2e7d32;
}
/* Abertura/fechamento: cor vem do resultado (pos/neg), não do tipo */
.trades-event-trade_open:not(.trades-event-pos):not(.trades-event-neg),
.trades-event-gain_floor_close:not(.trades-event-pos):not(.trades-event-neg) {
  border-left: 3px solid #2e7d32;
}
.trades-empty {
  text-align: center;
  color: var(--muted);
  padding: 24px;
  font-size: 0.9rem;
}

@media (max-width: 899px) {
  .bottom-nav .nav-item { font-size: 0.58rem; }
  .bottom-nav .nav-svg { width: 20px; height: 20px; }
}

@media (min-width: 900px) {
  .app-main:has(#panel-trades.active) { max-width: 960px; }
}

/* Desafio trading */
.trades-view-tabs {
  display: flex;
  gap: 8px;
  padding: 0 20px 16px;
}
.trades-view-tab {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}
.trades-view-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.chal-month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 0 12px;
}
.chal-month-nav h3 {
  margin: 0;
  font-size: 1rem;
  min-width: 110px;
  text-align: center;
}
.chal-th-date, .chal-cell-date { background: #eceff1; font-weight: 600; white-space: nowrap; }
.chal-cell-editable { cursor: pointer; }
.chal-cell-editable:hover { background: #fff59d !important; }
.chal-row-future { opacity: 0.55; }
.chal-row-future .chal-cell-date { font-weight: 500; }
.fx-usd { display: inline; }
.fx-brl {
  display: block;
  font-size: 0.68em;
  font-weight: 600;
  margin-top: 2px;
  line-height: 1.2;
  opacity: 0.95;
}
.fx-brl.pos { color: #1b5e20; }
.fx-brl.neg { color: #b71c1c; }
.chal-stack-item .fx-brl.pos,
.chal-box-win .fx-brl.pos,
.chal-box-deposit .fx-brl.pos { color: #c8e6c9; }
.chal-stack-item .fx-brl.neg,
.chal-box-loss .fx-brl.neg,
.chal-box-deposit .fx-brl.neg,
.chal-red .fx-brl.neg,
.chal-amber .fx-brl.neg { color: #ffcdd2; }
.chal-stack-item .fx-brl.pos,
.chal-green .fx-brl.pos,
.chal-blue .fx-brl.pos,
.chal-purple .fx-brl.pos { color: #c8e6c9; }
.chal-table .fx-brl { font-size: 0.7em; }
.chal-plan-item strong.pos .fx-usd { color: inherit; }
.chal-plan-item strong.neg .fx-usd { color: inherit; }
.chal-row-saturday .chal-cell-date {
  font-weight: 700;
}
.chal-row-saturday.chal-row-future {
  opacity: 0.75;
}
.chal-hint { font-size: 0.8rem; margin: 0; }
.chal-plan {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
}
.chal-plan-main {
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  color: #fff;
}
.chal-plan-main span {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.9;
}
.chal-plan-main strong {
  display: block;
  font-size: 1.35rem;
  margin-top: 4px;
}
.chal-plan-hint {
  display: block;
  font-size: 0.65rem;
  opacity: 0.85;
  margin-top: 6px;
  line-height: 1.3;
}
.chal-plan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.chal-plan-item {
  background: #eceff1;
  border-radius: 6px;
  padding: 8px;
  text-align: center;
}
.chal-plan-item span {
  display: block;
  font-size: 0.65rem;
  color: #546e7a;
  margin-bottom: 2px;
}
.chal-plan-item strong { font-size: 0.85rem; color: #263238; }
.chal-plan-item strong.neg { color: #c62828; }
.chal-plan-item strong.pos { color: #2e7d32; }
.chal-plan-item .chal-plan-hint {
  margin-top: 2px;
  font-size: 0.58rem;
  opacity: 0.75;
}
.chal-plan-item.chal-muted { opacity: 0.85; }
.chal-plan-item.chal-plan-proj {
  background: #e8eaf6;
  box-shadow: inset 0 0 0 1px rgba(57, 73, 171, 0.25);
}
.chal-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 12px 24px;
}
.chal-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.chal-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.75rem;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.chal-table th, .chal-table td {
  border: 1px solid #c8c8c8;
  padding: 8px 10px;
  text-align: center;
  white-space: nowrap;
}
.chal-th-meta { background: #fff9c4; font-weight: 700; }
.chal-subhead th { background: #37474f; color: #fff; font-size: 0.7rem; }
.chal-table thead tr:first-child th { background: #455a64; color: #fff; }
.chal-cell-meta { background: #fffde7; }
.chal-status-win { background: #c8e6c9; color: #1b5e20; }
.chal-status-loss { background: #ffcdd2; color: #b71c1c; }
.chal-ops-over {
  background: #c62828 !important;
  color: #fff !important;
  font-weight: 700;
}
.chal-ops-total { font-weight: 600; background: #f5f5f5; }
.chal-empty { color: var(--muted); padding: 20px !important; }
.chal-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chal-winloss {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.chal-box {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: center;
}
.chal-box span {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  opacity: 0.9;
}
.chal-box strong {
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
}
.chal-box-win { background: #2e7d32; color: #fff; }
.chal-box-loss { background: #c62828; color: #fff; }
.chal-box-muted { background: #eceff1; color: #37474f; }
.chal-box-deposit { background: #e8f5e9; color: #1b5e20; }
.chal-box-deposit strong.pos { color: #1b5e20; }
.chal-box-note {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.62rem;
  font-weight: 500;
  opacity: 0.75;
  text-transform: none;
  letter-spacing: 0;
}
.chal-stack { display: flex; flex-direction: column; gap: 6px; }
.chal-stack-item {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: #fff;
  text-align: center;
}
.chal-stack-item span {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  opacity: 0.9;
  margin-bottom: 4px;
}
.chal-stack-item strong {
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}
.chal-purple { background: #5e35b1; }
.chal-green { background: #2e7d32; }
.chal-blue { background: #1565c0; }
.chal-red { background: #c62828; }
.chal-amber { background: #e65100; }
.chal-totals {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.chal-totals-head {
  background: #4527a0;
  color: #fff;
  padding: 10px 14px;
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.chal-totals-head strong {
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  opacity: 0.95;
}
.chal-totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  color: #fff;
  font-weight: 600;
}
.chal-totals-row.chal-blue { background: #1976d2; }
.chal-totals-row.chal-red { background: #d32f2f; }

@media (min-width: 768px) {
  .chal-layout {
    flex-direction: row;
    align-items: flex-start;
  }
  .chal-table-wrap { flex: 1.2; min-width: 0; }
  .chal-side { flex: 0.8; min-width: 220px; max-width: 280px; }
}
