@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Geist+Mono:wght@400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Identidade (herdada do IGECE, adaptada p/ finanças da família) ── */
  --navy:          #0D1E35;
  --navy-mid:      #122743;
  --navy-light:    #1A3352;

  --green-cta:     #2ECC52;
  --green-cta-dark:#25A843;
  --green-cta-light:#E8FAF0;
  --green-cta-dim: rgba(46,204,82,0.12);

  /* Status semânticos */
  --blue:          #2B7FE8;
  --blue-light:    #EBF3FD;
  --blue-border:   #A0C4F0;

  --purple:        #6B5CE7;
  --purple-light:  #F0EEFF;

  --amber:         #C47D0A;
  --violet:        #6B5CE7;
  --amber-light:   #FEF6E4;
  --amber-border:  #F0C060;

  --red:           #D63030;
  --red-light:     #FDEAEA;
  --red-border:    #EDAAAA;

  --success:       #1A9E3F;
  --success-light: #E6F7EB;
  --success-border:#82CFA0;

  /* Neutros */
  --white:         #FFFFFF;
  --bg:            #F2F5F9;
  --bg-card:       #FFFFFF;
  --bg-hover:      #F5F7FB;

  --gray-50:       #F8FAFB;
  --gray-100:      #EEF2F6;
  --gray-200:      #D8E0EA;
  --gray-300:      #C2CDDA;
  --gray-400:      #94A3B8;
  --gray-500:      #64748B;
  --gray-600:      #4B5A70;
  --gray-700:      #334155;
  --gray-900:      #0F172A;

  --border:        rgba(0,0,0,0.07);
  --border-mid:    rgba(0,0,0,0.12);
  --border-strong: rgba(0,0,0,0.20);

  --font:          'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono:     'Geist Mono', 'SF Mono', ui-monospace, monospace;

  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     14px;
  --radius-xl:     18px;

  --shadow-xs:     0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:     0 1px 4px rgba(0,0,0,0.07), 0 0 0 1px rgba(0,0,0,0.04);
  --shadow:        0 2px 8px rgba(0,0,0,0.09), 0 0 0 1px rgba(0,0,0,0.04);
  --shadow-md:     0 4px 20px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.05);
}

html, body { height: 100%; max-width: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray-900);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, video, canvas, table { max-width: 100%; }
a { color: inherit; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ── NAVBAR (desktop) ──────────────────────────────────── */
.navbar {
  background: var(--navy);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}
.nav-left { display: flex; align-items: center; gap: 10px; }
.nav-logo {
  font-size: 17px; font-weight: 800; color: #fff; letter-spacing: -0.3px;
  display: flex; align-items: center; gap: 8px;
}
.nav-logo .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green-cta); box-shadow: 0 0 0 3px rgba(46,204,82,.25); }
.nav-center { display: flex; align-items: center; gap: 2px; flex: 1; justify-content: center; flex-wrap: wrap; }
.nav-link {
  padding: 6px 13px; border-radius: var(--radius-sm); font-size: 13px;
  font-weight: 600; color: rgba(255,255,255,.72); text-decoration: none;
  transition: all .15s; white-space: nowrap;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { background: var(--green-cta); color: #fff; }
.nav-right { display: flex; align-items: center; gap: 10px; }
.user-chip {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1);
  padding: 5px 10px 5px 6px; border-radius: 30px; transition: background .15s;
}
.user-chip:hover { background: rgba(255,255,255,.13); }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--green-cta);
  color: #fff; font-size: 12px; font-weight: 700; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.user-name { color: #fff; font-size: 12px; font-weight: 600; }
.btn-logout {
  background: none; border: none; color: rgba(255,255,255,.6); cursor: pointer;
  font-size: 12px; font-weight: 600; font-family: var(--font); padding: 6px 8px;
  border-radius: var(--radius-sm); transition: all .15s;
}
.btn-logout:hover { color: #fff; background: rgba(255,255,255,.08); }

/* ── LAYOUT ────────────────────────────────────────────── */
.wrap { max-width: 1200px; margin: 0 auto; padding: 34px 28px 48px; }
.page-head { margin-bottom: 26px; }
.page-title { font-size: 24px; font-weight: 800; color: var(--navy); letter-spacing: -0.6px; }
.page-sub { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

/* ── CARDS ─────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h3 { font-size: 14px; font-weight: 700; color: var(--navy); letter-spacing: -0.2px; }
.card-head .sub { font-size: 12px; color: var(--gray-500); font-weight: 500; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
/* duas colunas que colapsam no mobile (evita overflow lateral) */
.split   { display: grid; gap: 16px; grid-template-columns: 1.4fr 1fr; }
.split-b { display: grid; gap: 16px; grid-template-columns: 1.3fr 1fr; }

/* ── STAT CARD ─────────────────────────────────────────── */
.stat {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.stat .stat-label { font-size: 11px; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: .06em; }
.stat .stat-value { font-size: 26px; font-weight: 800; color: var(--navy); letter-spacing: -0.8px; margin-top: 6px; font-family: var(--font-mono); }
.stat .stat-foot { font-size: 12px; color: var(--gray-500); margin-top: 4px; font-weight: 600; }
.stat .stat-accent { position: absolute; top: 0; left: 0; width: 4px; height: 100%; }
.stat.pos .stat-value { color: var(--success); }
.stat.neg .stat-value { color: var(--red); }

/* ── PROGRESS ──────────────────────────────────────────── */
.progress-track { height: 8px; background: var(--gray-100); border-radius: 30px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 30px; background: var(--green-cta); transition: width .6s cubic-bezier(.2,.8,.2,1); }

/* ── BADGES ────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px;
  font-weight: 700; padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}
.badge.green  { background: var(--green-cta-light); color: var(--green-cta-dark); }
.badge.blue   { background: var(--blue-light); color: var(--blue); }
.badge.amber  { background: var(--amber-light); color: var(--amber); }
.badge.red    { background: var(--red-light); color: var(--red); }
.badge.purple { background: var(--purple-light); color: var(--purple); }
.badge.gray   { background: var(--gray-100); color: var(--gray-600); }

/* ── BUTTONS ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: none; border-radius: var(--radius-sm); padding: 9px 16px; font-size: 13px;
  font-weight: 700; cursor: pointer; font-family: var(--font); transition: all .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-mid); }
.btn-green { background: var(--green-cta); color: #fff; }
.btn-green:hover { background: var(--green-cta-dark); }
.btn-ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--border-mid); }
.btn-ghost:hover { border-color: var(--navy); background: var(--bg); }
.btn-danger { background: var(--red-light); color: var(--red); }
.btn-danger:hover { background: #f9d5d5; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-icon {
  width: 34px; height: 34px; padding: 0; border-radius: var(--radius-sm);
  background: var(--gray-100); color: var(--gray-600); display: inline-flex;
  align-items: center; justify-content: center; cursor: pointer; border: none; transition: all .15s;
}
.btn-icon:hover { background: var(--gray-200); color: var(--navy); }

/* ── FIELDS ────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 700; color: var(--gray-700); }
.field input, .field select, .field textarea {
  font-family: var(--font); font-size: 14px; color: var(--gray-900);
  border: 1.5px solid var(--border-mid); border-radius: var(--radius-sm);
  padding: 10px 12px; background: #fff; transition: border-color .15s, box-shadow .15s; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--green-cta); box-shadow: 0 0 0 3px var(--green-cta-dim);
}

/* ── TABLE ─────────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 11px; font-weight: 700; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: .05em; padding: 10px 14px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--bg-hover); }
.tbl .num { font-family: var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }

/* ── LIST ROW ──────────────────────────────────────────── */
.row-item {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}
.row-item:last-child { border-bottom: none; }
.row-dot { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.row-main { flex: 1; min-width: 0; }
.row-main strong { display: block; font-size: 13px; font-weight: 700; color: var(--navy); }
.row-main span { font-size: 12px; color: var(--gray-500); }
.row-val { font-family: var(--font-mono); font-weight: 700; font-size: 14px; text-align: right; white-space: nowrap; }

/* ── MODAL ─────────────────────────────────────────────── */
.modal-back {
  position: fixed; inset: 0; background: rgba(13,30,53,.5); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.modal-back.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius-xl); box-shadow: var(--shadow-md);
  width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
}
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 16px; font-weight: 800; color: var(--navy); }
.modal-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.modal-x { background: none; border: none; cursor: pointer; color: var(--gray-400); font-size: 22px; line-height: 1; }
.modal-x:hover { color: var(--navy); }

/* ── EMPTY ─────────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 20px; color: var(--gray-400); }
.empty .emoji { font-size: 34px; margin-bottom: 10px; }
.empty p { font-size: 14px; font-weight: 600; color: var(--gray-500); }
.empty small { font-size: 12px; color: var(--gray-400); }

/* ── TOAST ─────────────────────────────────────────────── */
.toast-zone { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 30px;
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow-md);
  animation: toast-in .25s ease; display: flex; align-items: center; gap: 8px;
}
.toast.ok { background: var(--green-cta-dark); }
.toast.err { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ── SPINNER ───────────────────────────────────────────── */
.spinner { width: 22px; height: 22px; border: 3px solid var(--gray-200); border-top-color: var(--green-cta); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 60vh; color: var(--gray-400); font-weight: 600; font-size: 13px; }

/* ── MOBILE NAV (bottom) — só aparece em telas pequenas ── */
.mob-nav { display: none; }

@media (max-width: 760px) {
  .navbar { display: none; }
  .wrap { padding: 20px 16px 96px; }
  .grid-2, .grid-3, .grid-4, .split, .split-b { grid-template-columns: 1fr; }
  .page-title { font-size: 20px; }
  .page-head { margin-bottom: 20px; }

  .mob-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 64px;
    background: #fff; border-top: 1px solid var(--border-mid); z-index: 500;
    box-shadow: 0 -2px 12px rgba(0,0,0,.06); padding-bottom: env(safe-area-inset-bottom);
  }
  .mob-link {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; text-decoration: none; color: var(--gray-400); font-size: 10px; font-weight: 700;
  }
  .mob-link svg { width: 22px; height: 22px; }
  .mob-link.active { color: var(--green-cta-dark); }
  .mob-link.fab {
    flex: 0 0 auto; width: 56px; height: 56px; margin-top: -18px; border-radius: 50%;
    background: var(--green-cta); color: #fff; box-shadow: 0 6px 16px rgba(46,204,82,.45);
  }
  .mob-link.fab svg { width: 26px; height: 26px; }
  .mob-link.fab span { display: none; }
}

@media (min-width: 761px) {
  .desktop-hide { display: none !important; }
}
@media (max-width: 760px) {
  .mobile-hide { display: none !important; }
}

/* botão-ícone redondo (editar/ação em cards) */
.icon-btn {
  width: 32px; height: 32px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px; border: 1.5px solid var(--border-mid);
  background: #fff; color: var(--gray-500); cursor: pointer;
  transition: all .15s;
}
.icon-btn:hover { color: var(--navy); border-color: var(--navy); background: var(--gray-50, #f8fafc); }

/* ============================================================
   v8 — polimento mobile + componentes compartilhados
   ============================================================ */

/* segmented control "Salvar como" (usado no lançar) */
.lc-status { display: flex; gap: 8px; margin-bottom: 4px; }
.lc-status button {
  flex: 1; border: 1.5px solid var(--border-mid); background: #fff; border-radius: 12px;
  padding: 11px 6px; font: inherit; font-size: 13px; font-weight: 700; color: var(--gray-600);
  cursor: pointer; transition: all .15s;
}
.lc-status button.on { border-color: var(--green-cta); background: var(--green-cta-light); color: var(--green-cta-dark); }
.lc-status button:active { transform: scale(.98); }

/* selects com chevron próprio (mais bonitos no mobile) */
.field select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 34px;
}

@media (max-width: 760px) {
  /* respiro geral e tipografia */
  .wrap { padding: 16px 14px 96px; }
  .page-sub { font-size: 12.5px; }

  /* stat cards mais compactos e legíveis em coluna */
  .stat { padding: 15px 16px; border-radius: var(--radius); }
  .stat .stat-value { font-size: 22px; }
  .grid, .grid-3, .grid-2 { gap: 12px; }

  /* navegação de mês não estoura em telas estreitas */
  .comp-nav .lbl { min-width: 0; flex: 1; font-size: 14px; }
  .comp-nav { flex: 1; justify-content: space-between; min-width: 180px; }

  /* cards e linhas com toque mais confortável */
  .card-head { padding: 14px 16px; }
  .row-item { padding: 13px 14px; gap: 11px; }
  .btn { padding: 10px 15px; }

  /* MODAIS viram "bottom sheet" — sobem de baixo, ocupam a largura */
  .modal-back { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100%; width: 100%; max-height: 92dvh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: sheet-up .28s cubic-bezier(.2,.8,.2,1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-head { padding: 16px 18px; position: sticky; top: 0; background: #fff; z-index: 2; }
  /* alça do bottom sheet */
  .modal-head::before {
    content: ''; position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4px; border-radius: 4px; background: var(--gray-200);
  }
  .modal-body { padding: 18px; gap: 13px; }
  .modal-foot {
    padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
    position: sticky; bottom: 0; background: #fff; flex-wrap: wrap;
  }
  .modal-foot .btn { flex: 1; min-width: 90px; justify-content: center; }
  .modal-foot .btn[style*="margin-right:auto"] { flex-basis: 100%; }

  /* toque mínimo de 16px em inputs evita zoom automático do iOS */
  .field input, .field select, .field textarea { font-size: 16px; padding: 12px 13px; }
  .field select { font-size: 16px; }
}
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
