* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --azul: #15803d; --azul-esc: #166534; --verde: #16a34a;
  --vermelho: #dc2626; --laranja: #ea580c; --cinza: #64748b;
  --fundo: #f1f5f9; --card: #fff; --borda: #e2e8f0; --texto: #0f172a;
}
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fundo); color: var(--texto); }
.hidden { display: none !important; }

/* AUTH */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background-color: #15803d; background-image: linear-gradient(135deg, #15803d, #166534);
  background-size: cover; background-position: center center; background-repeat: no-repeat; background-attachment: scroll; }
.auth-card { background: #fff; padding: 32px; border-radius: 16px; width: 100%; max-width: 380px; box-shadow: 0 20px 40px rgba(0,0,0,.2); }
.logo { font-size: 28px; font-weight: 800; text-align: center; }
.sub { text-align: center; color: var(--cinza); margin: 6px 0 20px; font-size: 14px; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab { flex: 1; padding: 10px; border: none; background: var(--fundo); border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--cinza); }
.tab.active { background: var(--azul); color: #fff; }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--borda); border-radius: 8px; margin-bottom: 12px; font-size: 14px; font-family: inherit; }
.btn { width: 100%; padding: 12px; background: var(--azul); color: #fff; border: none; border-radius: 8px; font-weight: 700; cursor: pointer; font-size: 15px; }
.btn:hover { background: var(--azul-esc); }
.btn.sm { width: auto; padding: 7px 14px; font-size: 13px; }
.btn.danger { background: var(--vermelho); }
.link { background: none; border: none; color: var(--azul); cursor: pointer; font-weight: 600; }
.msg { margin-top: 10px; font-size: 13px; text-align: center; min-height: 18px; }
.msg.err { color: var(--vermelho); } .msg.ok { color: var(--verde); }

/* APP */
header { background: #fff; border-bottom: 1px solid var(--borda); display: flex; align-items: center; gap: 16px; padding: 0 20px; height: 60px; position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 18px; }
nav { display: flex; gap: 4px; flex: 1; }
.navbtn { padding: 8px 14px; border: none; background: none; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--cinza); }
.navbtn.active { background: var(--fundo); color: var(--azul); }
.user { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--cinza); }
main { max-width: 980px; margin: 0 auto; padding: 24px 20px 60px; }
h1 { font-size: 24px; margin-bottom: 16px; } h2 { font-size: 17px; margin: 22px 0 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat { background: var(--card); border: 1px solid var(--borda); border-radius: 12px; padding: 16px; }
.stat .n { font-size: 28px; font-weight: 800; } .stat .l { color: var(--cinza); font-size: 13px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.item { background: var(--card); border: 1px solid var(--borda); border-radius: 12px; padding: 16px; }
.item h3 { font-size: 16px; margin-bottom: 4px; }
.item .meta { color: var(--cinza); font-size: 13px; line-height: 1.6; }
.item .acts { margin-top: 12px; display: flex; gap: 8px; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.red { background: #fee2e2; color: var(--vermelho); }
.badge.orange { background: #ffedd5; color: var(--laranja); }
.badge.green { background: #dcfce7; color: var(--verde); }
.empty { color: var(--cinza); padding: 24px; text-align: center; background: var(--card); border: 1px dashed var(--borda); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; border: 1px solid var(--borda); }
th, td { padding: 11px 12px; text-align: left; font-size: 14px; border-bottom: 1px solid var(--borda); }
th { background: var(--fundo); color: var(--cinza); font-size: 12px; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal-box { background: #fff; border-radius: 14px; padding: 24px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--cinza); }
.animal-foto { width: 100%; height: 140px; object-fit: cover; border-radius: 10px; margin-bottom: 10px; border: 1px solid var(--borda); }
.item .meta a { color: var(--azul); text-decoration: none; font-weight: 600; }
.brand-logo { display: block; margin: 0 auto 12px; max-width: 280px; max-height: 110px; width: auto; height: auto; object-fit: contain; }
.brand-logo-sm { height: 36px; width: auto; max-width: 170px; object-fit: contain; vertical-align: middle; margin-right: 8px; }
.ferradura { vertical-align: middle; margin: 0 2px; }
#alert-banner { background: #fee2e2; color: #991b1b; padding: 10px 20px; display: flex; align-items: center; justify-content: center; gap: 14px; font-weight: 600; flex-wrap: wrap; border-bottom: 1px solid #fecaca; }

/* ===== Instalar app + versao ===== */
.install-cta { display: block; width: 100%; margin-top: 14px; padding: 12px; border: 2px dashed var(--azul); background: #f0fdf4; color: var(--azul-esc); border-radius: 10px; font-weight: 700; text-align: center; cursor: pointer; font-size: 14px; }
.install-cta:hover { background: #dcfce7; }
.app-version { text-align: center; color: var(--cinza); font-size: 12px; margin-top: 14px; }
.ov { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100; }
.ov-box { background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; }
.os-card { border: 1px solid var(--borda); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.os-card h3 { display: flex; align-items: center; gap: 8px; font-size: 16px; margin-bottom: 8px; }
.os-card ol { margin: 0 0 0 18px; font-size: 14px; line-height: 1.8; color: var(--texto); }

/* ===== Aviso de nova versao ===== */
#update-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 200; background: var(--azul-esc); color: #fff; padding: 12px 16px; display: flex; align-items: center; justify-content: center; gap: 14px; font-weight: 700; font-size: 15px; box-shadow: 0 2px 12px rgba(0,0,0,.3); flex-wrap: wrap; }
#update-banner button { background: #fff; color: var(--azul-esc); border: none; border-radius: 8px; padding: 8px 18px; font-weight: 800; cursor: pointer; font-size: 14px; }

/* ===== Menu lateral (base desktop) ===== */
.hamburger { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--azul); padding: 4px 8px; line-height: 1; }
#sidemenu { display: contents; }
.menu-head { display: none; }
#nav-overlay { display: none; }

/* ===== Responsivo (celular) — menu lateral deslizante ===== */
@media (max-width: 760px) {
  header { height: 56px; flex-direction: row; align-items: center; gap: 10px; padding: 8px 12px; flex-wrap: nowrap; z-index: 80; }
  .hamburger { display: inline-flex; align-items: center; }
  .brand { flex: 1; text-align: left; font-size: 17px; }

  #sidemenu {
    display: flex; flex-direction: column; align-items: stretch; gap: 6px;
    position: fixed; top: 0; left: 0; height: 100%; width: 264px; max-width: 82%;
    background: #fff; transform: translateX(-100%); transition: transform .25s ease;
    z-index: 70; box-shadow: 2px 0 18px rgba(0,0,0,.28);
    padding: 18px 12px; overflow-y: auto;
  }
  #sidemenu.open { transform: translateX(0); }

  .menu-head { display: flex; align-items: center; gap: 10px; padding: 2px 8px 12px; border-bottom: 1px solid var(--borda); margin-bottom: 4px; }
  .menu-logo { width: 42px; height: 42px; border-radius: 9px; object-fit: cover; flex: 0 0 auto; border: 1px solid var(--borda); }
  .menu-user-top { font-weight: 800; color: var(--texto); font-size: 15px; line-height: 1.25; }

  nav { display: flex; flex-direction: column; align-items: stretch; gap: 4px; flex: none; overflow: visible; border: none; padding: 0; }
  .navbtn { width: 100%; text-align: left; padding: 12px 14px; font-size: 15px; }

  .user { display: flex; flex-direction: column; align-items: stretch; width: 100%; gap: 2px; font-size: 14px; border-top: 1px solid var(--borda); margin-top: 8px; padding-top: 8px; }
  .user #user-name { display: none; }
  .user .link { text-align: left; padding: 10px 14px; white-space: nowrap; }

  #nav-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 65; }
  #nav-overlay.open { display: block; }

  #alert-banner { padding: 10px 12px; gap: 8px; font-size: 14px; }
  main { padding: 16px 14px 60px; }
  h1 { font-size: 21px; }
  .modal-box, .ov-box { padding: 18px; }
}
