:root {
  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --text: #0F172A;
  --text-muted: #64748B;
  --border: #E2E8F0;

  --accent: #10B981;
  --accent-dark: #059669;
  --accent-soft: #D1FAE5;

  --danger: #EF4444;
  --danger-soft: #FEE2E2;

  --warning: #F59E0B;
  --warning-soft: #FEF3C7;

  --info: #3B82F6;
  --info-soft: #DBEAFE;

  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100vh;
  padding-bottom: 84px;
}

a { color: var(--accent-dark); text-decoration: none; }

.screen {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

.top-bar {
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 5;
}

.top-bar h1 {
  font-size: 1.15rem;
  margin: 0;
  color: var(--text);
}

/* ---------- Cabecalho de saudacao (tela inicial) ---------- */
.greeting-wrap {
  padding: 18px 16px 4px;
}
.greeting-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.greeting-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}
.greeting-date {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.bell-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  cursor: pointer;
  flex-shrink: 0;
}
.bell-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg);
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
}

.card-row {
  display: flex;
  gap: 10px;
}
.card-row .card { flex: 1; }

.metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}
.metric-value {
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 4px;
  color: var(--text);
}
.metric-value.positive { color: var(--accent-dark); }
.metric-value.negative { color: var(--danger); }

/* card de metrica com icone colorido + tendencia, estilo do mockup */
.metric-card-v2 {
  background: var(--surface);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow-card);
  flex: 1;
  min-width: 0;
}
.icon-badge {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-bottom: 8px;
}
.icon-badge.accent { background: var(--accent-soft); color: var(--accent-dark); }
.icon-badge.danger { background: var(--danger-soft); color: var(--danger); }
.icon-badge.warning { background: var(--warning-soft); color: #B45309; }
.icon-badge.info { background: var(--info-soft); color: var(--info); }

.trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  margin-top: 6px;
}
.trend-up { color: var(--accent-dark); }
.trend-down { color: var(--danger); }
.trend-muted { color: var(--text-muted); font-weight: 500; }

/* ---------- Acoes rapidas (tela inicial) ---------- */
.quick-actions {
  display: flex;
  justify-content: space-around;
  padding: 4px 8px 14px;
}
.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.72rem;
  cursor: pointer;
}
.quick-action-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: var(--shadow-card);
}

h2 { font-size: 1.05rem; margin: 0 0 10px; color: var(--text); }
h3 { font-size: 0.92rem; margin: 0 0 8px; color: var(--text-muted); font-weight: 600; }

.form-field {
  margin-bottom: 14px;
}
.form-field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}
.form-field textarea { resize: vertical; min-height: 60px; }
.form-row { display: flex; gap: 10px; }
.form-row .form-field { flex: 1; }

.btn {
  display: inline-block;
  padding: 14px 18px;
  border-radius: 14px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  width: 100%;
}
.btn-primary { background: var(--info); color: #fff; }
.btn-primary:active { background: #2563EB; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-small { width: auto; padding: 8px 14px; font-size: 0.85rem; }

/* ---------- Listas de lancamento ---------- */
.date-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 16px 0 8px;
}
.date-group-label:first-child { margin-top: 0; }

.list-item {
  background: var(--surface);
  border-radius: 16px;
  padding: 13px 14px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-card);
}
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; color: var(--text); }
.list-item-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.list-item-value { font-weight: 700; white-space: nowrap; }
.list-item-value.receita { color: var(--accent-dark); }
.list-item-value.despesa { color: var(--danger); }

.pending-tag {
  display: inline-block;
  font-size: 0.62rem;
  background: var(--warning-soft);
  color: #B45309;
  border-radius: 6px;
  padding: 2px 6px;
  margin-left: 6px;
  vertical-align: middle;
  font-weight: 700;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 30px 10px;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 10;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 2px;
  color: var(--text-muted);
  font-size: 0.65rem;
  border-radius: 10px;
  position: relative;
}
.nav-item.active { color: var(--accent-dark); }
.nav-item .nav-icon { font-size: 1.25rem; }

#nav-pending-badge {
  position: absolute;
  top: 2px;
  right: 18%;
  background: var(--warning);
  color: #451a03;
  border-radius: 999px;
  font-size: 0.6rem;
  min-width: 16px;
  height: 16px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}
#nav-pending-badge.show { display: flex; }

.fab {
  position: fixed;
  right: 20px;
  bottom: 88px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--info);
  color: #fff;
  font-size: 1.8rem;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
  z-index: 9;
  cursor: pointer;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

#connectivity-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--warning);
  color: #451a03;
  font-size: 0.78rem;
  padding: 8px 16px;
  text-align: center;
  transform: translateY(-100%);
  transition: transform 0.2s;
  z-index: 40;
}
#connectivity-banner.show { transform: translateY(0); }

.chart-wrap {
  position: relative;
  height: 220px;
}

.sparkline-wrap {
  position: relative;
  height: 56px;
  margin-top: 4px;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
}
.tab-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 10px 0;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
}

/* ---------- Anel de progresso circular (Meta) ---------- */
.progress-ring-wrap {
  position: relative;
  width: 96px;
  height: 96px;
  flex-shrink: 0;
}
.progress-ring-wrap svg { transform: rotate(-90deg); }
.progress-ring-track { fill: none; stroke: var(--surface-2); stroke-width: 10; }
.progress-ring-fill { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 0.4s; }
.progress-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.error-text { color: var(--danger); font-size: 0.85rem; margin-top: 6px; }
.link-muted { color: var(--text-muted); font-size: 0.85rem; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: flex-end;
  z-index: 30;
}
.modal-sheet {
  background: var(--bg);
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh;
  overflow-y: auto;
}

.notif-panel {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  padding: 6px;
  margin: 0 16px 12px;
}
.notif-item {
  padding: 10px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
}
.notif-item + .notif-item { border-top: 1px solid var(--border); }
.notif-item-title { font-weight: 600; color: var(--text); }
.notif-item-sub { color: var(--text-muted); font-size: 0.78rem; margin-top: 2px; }

.vehicle-photo {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 14px;
  object-fit: cover;
  background: var(--surface-2);
  display: block;
  margin-bottom: 10px;
}
.vehicle-photo-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 14px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.photo-input-label {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--info);
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-box { width: 100%; max-width: 380px; }
.login-title { text-align: center; margin-bottom: 4px; font-size: 1.6rem; color: var(--text); }
.login-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: 0.9rem; }

.lang-switcher { justify-content: center; }
.lang-btn { font-size: 0.8rem; padding: 6px 12px; }
