:root {
  --petrol: #0e3a46;
  --petrol-2: #0a2b35;
  --mint: #2fbfa3;
  --mint-soft: #e3f5f0;
  --paper: #f5f8f7;
  --white: #ffffff;
  --ink: #16323a;
  --muted: #6b8189;
  --line: #dde8e6;
  --red: #d95757;
  --red-soft: #fbecec;
  --radius: 12px;
  --font-display: 'Sora', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0; font-family: var(--font-body); color: var(--ink);
  background: var(--paper); font-size: 15px;
}
h1 { font-family: var(--font-display); font-size: 1.5rem; margin: 0; }
h2 { font-family: var(--font-display); font-size: .95rem; margin: 0 0 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(160deg, var(--petrol) 0%, var(--petrol-2) 100%);
}
.login-card {
  background: var(--white); border-radius: 20px; padding: 44px 40px;
  width: min(360px, 90vw); text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.login-tooth { color: var(--mint); margin-bottom: 6px; }
.login-card h1 { font-size: 1.6rem; }
.login-sub { color: var(--muted); margin: 6px 0 26px; }
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  text-decoration: none; color: var(--ink); font-weight: 600;
  transition: background .15s;
}
.btn-google:hover { background: var(--mint-soft); }
.login-erro { color: var(--red); background: var(--red-soft); padding: 10px; border-radius: 8px; margin-top: 18px; font-size: .88rem; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--petrol); color: #cfe3e0; padding: 22px 14px;
  display: flex; flex-direction: column; gap: 24px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--mint); font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; padding: 0 8px; }
.brand span { color: #fff; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-btn {
  background: none; border: 0; color: #cfe3e0; text-align: left;
  padding: 11px 14px; border-radius: 9px; font: inherit; font-weight: 500; cursor: pointer;
}
.nav-btn:hover { background: rgba(255,255,255,.07); }
.nav-btn.active { background: var(--mint); color: var(--petrol-2); font-weight: 600; }
.userbox { display: flex; gap: 10px; align-items: center; padding: 0 8px; font-size: .85rem; }
.userbox img { width: 34px; height: 34px; border-radius: 50%; background: #234; }
.userbox strong { display: block; color: #fff; font-size: .83rem; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link { background: none; border: 0; color: var(--mint); cursor: pointer; padding: 0; font-size: .8rem; }

.content { padding: 28px 32px; max-width: 1100px; }
.tab { display: none; }
.tab.active { display: block; }
.tab-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.row { display: flex; gap: 10px; align-items: center; }

/* ---------- Componentes ---------- */
.painel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.resumo { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card span { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.card strong { display: block; font-family: var(--font-display); font-size: 1.45rem; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card.ok strong { color: #1a9c7f; }
.card.bad strong { color: var(--red); }

.input {
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px;
  font: inherit; background: var(--white); color: var(--ink); min-width: 0;
}
.input:focus { outline: 2px solid var(--mint); outline-offset: 1px; border-color: var(--mint); }
.btn {
  background: var(--mint); color: var(--petrol-2); border: 0; border-radius: 9px;
  padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn:hover { filter: brightness(.95); }
.btn.ghost { background: var(--white); border: 1px solid var(--line); color: var(--ink); }
.btn.mini { padding: 5px 10px; font-size: .8rem; }
.btn.danger { background: var(--red-soft); color: var(--red); }

.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.form-grid .span2 { grid-column: span 2; }
.form-grid .btn { grid-column: span 1; }

.tabela { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabela th { text-align: left; color: var(--muted); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tabela td { padding: 10px; border-bottom: 1px solid var(--line); }
.tabela tr:last-child td { border-bottom: 0; }
.tabela .num, .tabela td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .75rem; font-weight: 600; }
.tag.entrada { background: var(--mint-soft); color: #14806a; }
.tag.saida { background: var(--red-soft); color: var(--red); }
.vazio, .hint { color: var(--muted); font-size: .9rem; margin: 8px 4px; }
code { background: var(--paper); padding: 1px 6px; border-radius: 5px; }

/* Gráfico de barras (CSS puro) */
.barras { display: flex; gap: 18px; align-items: flex-end; height: 180px; padding-top: 10px; }
.barra-grupo { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.barra-par { display: flex; gap: 4px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.barra { width: 26px; border-radius: 5px 5px 0 0; min-height: 2px; transition: height .4s ease; }
.barra.e { background: var(--mint); }
.barra.s { background: var(--red); opacity: .75; }
.barra-label { font-size: .75rem; color: var(--muted); }

.catlist { display: flex; flex-direction: column; gap: 10px; }
.catrow { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: .88rem; }
.catbar { grid-column: 1 / -1; height: 6px; border-radius: 4px; background: var(--paper); overflow: hidden; }
.catbar i { display: block; height: 100%; background: var(--mint); }
.catbar.s i { background: var(--red); opacity: .7; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--petrol); color: #fff; padding: 12px 22px; border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25); font-size: .9rem; z-index: 50;
}
.toast.erro { background: var(--red); }

/* ---------- Modal ficha ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(10, 43, 53, .55);
  display: grid; place-items: center; z-index: 60; padding: 16px;
}
.modal-bg[hidden] { display: none; }
.modal {
  background: var(--paper); border-radius: 16px; padding: 22px;
  width: min(720px, 100%); max-height: 90vh; overflow-y: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h2 { font-size: 1.2rem; color: var(--ink); text-transform: none; letter-spacing: 0; margin: 0; }
.ficha-dados {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; font-size: .9rem;
}
.ficha-dados .full { grid-column: 1 / -1; }
.ficha-dados span { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; display: block; }
.modal-tabela { max-height: 300px; overflow-y: auto; }
@media (max-width: 560px) { .ficha-dados { grid-template-columns: 1fr; } }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  html, body { overflow-x: hidden; max-width: 100vw; }
  .input, .btn { font-size: 16px; } /* evita zoom automático no iOS */

  .layout { grid-template-columns: 100%; }
  /* Impede que conteúdo interno (tabelas) alargue a página */
  .content { min-width: 0; width: 100%; max-width: 100%; padding: 16px 14px; }
  .tab { min-width: 0; }

  /* Sidebar vira barra superior fixa */
  .sidebar {
    position: sticky; top: 0; height: auto; z-index: 40;
    flex-direction: column; gap: 8px; padding: 10px 14px;
  }
  .sidebar .brand { justify-content: flex-start; padding-right: 48px; }
  .sidebar nav {
    flex: 0 0 auto; flex-direction: row; align-items: center;
    overflow-x: auto; width: 100%;
    -webkit-overflow-scrolling: touch; scrollbar-width: none; gap: 6px;
  }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .nav-btn { flex: 0 0 auto; white-space: nowrap; padding: 9px 14px; }
  .userbox { position: absolute; top: 10px; right: 14px; }
  .userbox img { width: 32px; height: 32px; cursor: pointer; }
  .userbox div { display: none; } /* no celular, sair = tocar na foto */
  .userbox div { display: none; }

  .tab-head { flex-direction: column; align-items: stretch; }
  .tab-head .input, .tab-head .btn { width: 100%; }
  .tab-head .row { flex-direction: column; align-items: stretch; }

  .resumo { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 12px 14px; min-width: 0; }
  .card strong { font-size: 1.1rem; }

  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .btn { grid-column: 1 / -1; }
  .cols { grid-template-columns: 1fr; }

  /* Tabelas: rolagem horizontal SÓ dentro do painel */
  .painel { overflow-x: auto; padding: 14px; max-width: 100%; }
  .tabela { min-width: 600px; }
}

@media (max-width: 480px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: auto; }
  .barras { gap: 8px; }
  .barra { width: 16px; }
}

@media (prefers-reduced-motion: reduce) { .barra { transition: none; } }


