:root {
  --teal: #14b8a6;
  --teal-d: #0f766e;
  --blue: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #f59e0b;
  --ink: #0f172a;
  --muted: #64748b;
  --bg: #f1f5f9;
  --card: #ffffff;
  --line: #e2e8f0;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(15, 23, 42, .06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: inherit; text-decoration: none; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; background: linear-gradient(180deg, var(--teal-d), #134e4a);
  color: #fff; padding: 22px 16px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; }
.brand img { width: 44px; height: 44px; border-radius: 12px; background: #fff; padding: 4px; }
.brand strong { display: block; font-size: 15px; }
.brand span { font-size: 11px; opacity: .8; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar nav a { padding: 11px 14px; border-radius: 10px; font-size: 14.5px; opacity: .85; transition: .15s; }
.sidebar nav a:hover { background: rgba(255,255,255,.1); opacity: 1; }
.sidebar nav a.on { background: rgba(255,255,255,.18); opacity: 1; font-weight: 600; }
.sidebar .user { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid rgba(255,255,255,.15); padding-top: 14px; font-size: 13px; }
.sidebar .user a { background: rgba(255,255,255,.15); padding: 6px 12px; border-radius: 8px; }

.sidebar-admin { background: linear-gradient(180deg, #1e293b, #0f172a); }
.sidebar-admin .brand img { background: #fff; }

.content { flex: 1; padding: 30px 38px; max-width: 1200px; }

/* ---------- Headings ---------- */
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { font-size: 24px; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.card .label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.card .valor { font-size: 27px; font-weight: 700; margin-top: 8px; }
.card .hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.pos { color: var(--green); } .neg { color: var(--red); }
.card.accent-prev { border-top: 4px solid var(--blue); }
.card.accent-real { border-top: 4px solid var(--teal); }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } .sidebar { display: none; } .content { padding: 18px; } }

.panel { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); border: 1px solid var(--line); margin-bottom: 18px; }
.panel h2 { font-size: 16px; margin-bottom: 14px; }

/* ---------- Bars / categorias ---------- */
.catbar { margin-bottom: 12px; }
.catbar .top { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 5px; }
.catbar .track { background: var(--bg); height: 9px; border-radius: 99px; overflow: hidden; }
.catbar .fill { height: 100%; border-radius: 99px; }

/* ---------- Dicas ---------- */
.dica { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 10px; line-height: 1.45; }
.dica.alerta { background: #fef2f2; color: #991b1b; }
.dica.ok { background: #f0fdf4; color: #166534; }
.dica.info { background: #eff6ff; color: #1e40af; }

/* ---------- Tabela ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; font-size: 14px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; }
.tag.prev { background: #dbeafe; color: #1e40af; }
.tag.real { background: #ccfbf1; color: #0f766e; }
.dot { width: 9px; height: 9px; border-radius: 99px; display: inline-block; margin-right: 6px; }

/* ---------- Forms ---------- */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; align-items: end; }
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); border-color: transparent; }
input[type="radio"], input[type="checkbox"] { width: auto; }
.btn { background: var(--teal-d); color: #fff; border: none; padding: 11px 18px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; transition: .15s; }
.btn:hover { background: var(--teal); }
.btn.blue { background: var(--blue); } .btn.blue:hover { background: #1d4ed8; }
.btn.ghost { background: var(--bg); color: var(--ink); }
.btn.sm { padding: 6px 12px; font-size: 12.5px; }
.btn.danger { background: #fee2e2; color: #991b1b; }
.btn-link { color: var(--muted); background: none; border: none; cursor: pointer; font-size: 13px; }

/* ---------- WhatsApp box ---------- */
.wa-box { background: linear-gradient(135deg, #ecfdf5, #eff6ff); border: 1px solid var(--line); }
.wa-box textarea { min-height: 52px; resize: vertical; }
.wa-box .hint { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
#btn-mic.gravando { animation: pulse 1s infinite; background: var(--red); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.5); } 50% { box-shadow: 0 0 0 10px rgba(220,38,38,0); } }

/* ---------- Seg toggle (período) ---------- */
.seg-toggle { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg-toggle a { padding: 8px 14px; font-size: 13px; color: var(--muted); }
.seg-toggle a.on { background: var(--teal-d); color: #fff; font-weight: 600; }

/* ---------- Month nav ---------- */
.monthnav { display: flex; align-items: center; gap: 10px; }
.monthnav a { background: var(--card); border: 1px solid var(--line); padding: 8px 12px; border-radius: 10px; font-size: 13px; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; }
.flash.ok { background: #f0fdf4; color: #166534; }
.flash.erro { background: #fef2f2; color: #991b1b; }
.flash.info { background: #eff6ff; color: #1e40af; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(135deg, var(--teal), var(--blue)); }
.auth-card { background: #fff; border-radius: 22px; padding: 38px; width: 100%; max-width: 410px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.auth-card .logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; text-align: center; }
.auth-card .logo img { width: 64px; height: 64px; border-radius: 16px; }
.auth-card h1 { font-size: 21px; } .auth-card .slogan { color: var(--muted); font-size: 13.5px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn { width: 100%; margin-top: 6px; }
.auth-card .alt { text-align: center; margin-top: 16px; font-size: 13.5px; color: var(--muted); }
.auth-card .alt a { color: var(--teal-d); font-weight: 600; }

/* ---------- PWA install ---------- */
.pwa-install { position: fixed; right: 18px; bottom: 18px; z-index: 50; background: var(--blue);
  color: #fff; border: none; padding: 12px 18px; border-radius: 99px; font-size: 14px; font-weight: 600;
  cursor: pointer; box-shadow: 0 8px 24px rgba(37,99,235,.4); }
.pwa-install:hover { background: #1d4ed8; }
.ios-tip { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 50; background: #0f172a;
  color: #fff; padding: 14px 16px; border-radius: 14px; font-size: 13.5px; line-height: 1.5;
  box-shadow: 0 10px 30px rgba(0,0,0,.3); }

/* ---------- Trilha de educação ---------- */
.licao-card { display: block; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: #fff; transition: border-color .15s, transform .15s; }
.licao-card:hover { transform: translateY(-2px); }
.licao-card.ok { background: #f0fdf4; }
.licao-card .lc-top { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.licao-card p { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.45; }
.licao-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 6px; }

/* ---------- Perfil ---------- */
.q { margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.q p { font-weight: 600; margin-bottom: 10px; }
.q label { display: flex; gap: 9px; align-items: center; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 7px; cursor: pointer; color: var(--ink); font-size: 14px; }
.q label:hover { border-color: var(--teal); }
.perfil-res { text-align: center; padding: 26px; }
.perfil-res .badge { display: inline-block; padding: 6px 16px; border-radius: 99px; color: #fff; font-weight: 700; margin-bottom: 12px; }
.aloc { display: flex; gap: 14px; justify-content: center; margin: 18px 0; }
.aloc .seg { flex: 1; max-width: 200px; padding: 16px; border-radius: 14px; background: var(--bg); }
.aloc .seg .pct { font-size: 30px; font-weight: 800; }
.passos { text-align: left; max-width: 480px; margin: 0 auto; }
.passos li { margin-bottom: 8px; font-size: 14px; }
.disclaimer { font-size: 12px; color: var(--muted); margin-top: 18px; font-style: italic; }

/* botão pequeno (excluir categoria) */
.btn-mini{background:#fee2e2;color:#b91c1c;border:1px solid #fecaca;border-radius:7px;padding:5px 9px;font-size:13px;cursor:pointer;}
.btn-mini:hover{background:#fecaca;}

/* ---------- Celular: barra no topo + menu deslizante (☰) ---------- */
.mobile-bar, .menu-fundo { display: none; }
@media (max-width: 900px) {
  .app { display: block; }
  .mobile-bar { display: flex; position: sticky; top: 0; z-index: 40; align-items: center; justify-content: space-between;
    gap: 10px; padding: 10px 14px; background: linear-gradient(90deg, var(--teal-d), #134e4a); color: #fff; }
  .mobile-bar.admin { background: linear-gradient(90deg, #1e293b, #0f172a); }
  .mobile-bar .mb-brand { display: flex; gap: 8px; align-items: center; font-weight: 700; font-size: 15px; }
  .mobile-bar img { width: 32px; height: 32px; border-radius: 8px; background: #fff; padding: 3px; }
  .mobile-bar .mb-acoes { display: flex; gap: 8px; align-items: center; }
  .mobile-bar .mb-acoes a, .mobile-bar button { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 10px;
    font-size: 20px; min-width: 44px; height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0 8px; }
  .mb-badge { background: #dc2626; color: #fff; border-radius: 99px; padding: 0 6px; font-size: 11px; font-weight: 700; margin-left: 2px; }
  .sidebar { display: flex !important; position: fixed; left: 0; top: 0; bottom: 0; height: 100vh; z-index: 60;
    width: 82%; max-width: 300px; transform: translateX(-105%); transition: transform .2s; overflow-y: auto; }
  body.menu-aberto .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  body.menu-aberto .menu-fundo { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; }
  body.menu-aberto { overflow: hidden; }
  .content { padding: 14px; max-width: 100%; }
  .panel { padding: 16px; }
  table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  td.desc { white-space: normal; min-width: 160px; }
  .form-row { grid-template-columns: 1fr 1fr; }
  .page-head h1 { font-size: 20px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px; }
  .card .valor { font-size: 20px; }
  .monthnav { width: 100%; justify-content: space-between; }
  input, select, textarea { font-size: 16px; }  /* evita o zoom automático do iPhone */
}
@media (max-width: 430px) {
  .form-row, .cards { grid-template-columns: 1fr; }
}
.grid-2 > *, .cards > * { min-width: 0; }   /* deixa as colunas encolherem no celular */
