:root {
  /* Marca Akirede (vermelho). Nomes mantidos por compatibilidade. */
  --azul: #E8322D;        /* vermelho Akirede (primario) */
  --azul-claro: #C42820;  /* vermelho escuro (hover/ativo) */
  --verde: #16a34a;
  --amarelo: #d97706;
  --vermelho: #dc2626;
  --cinza: #6b7280;
  --bg: #f3f4f6;
  --card: #ffffff;
  --borda: #e5e7eb;
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: #111827;
  line-height: 1.5;
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--azul), var(--azul-claro));
  padding: 1rem;
}
.login-card {
  background: var(--card);
  width: 100%;
  max-width: 380px;
  border-radius: 14px;
  padding: 2rem;
  box-shadow: 0 20px 40px rgba(0,0,0,.25);
}
.login-logo { display: flex; align-items: center; justify-content: center; gap: .5rem; color: var(--azul); margin-bottom: .5rem; }
.login-logo svg { width: 34px; height: 45px; }
.login-logo strong { font-size: 1.9rem; font-weight: 800; letter-spacing: -.01em; }
.login-card h1 { color: #374151; font-size: 1.1rem; font-weight: 600; margin-bottom: .1rem; text-align: center; }
.login-card .sub { color: var(--cinza); font-size: .88rem; margin-bottom: 1.5rem; text-align: center; }

/* ---------- Layout app ---------- */
.topbar {
  background: var(--azul);
  color: #fff;
  padding: .9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .brand { font-weight: 700; font-size: 1.15rem; }
.topbar .right { display: flex; align-items: center; gap: 1rem; font-size: .9rem; }
.badge-mock {
  background: var(--amarelo); color: #fff; padding: .2rem .6rem;
  border-radius: 999px; font-size: .75rem; font-weight: 600;
}
.badge-live { background: var(--verde); }

.container { max-width: 1100px; margin: 1.5rem auto; padding: 0 1.5rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat {
  background: var(--card); border: 1px solid var(--borda); border-radius: 12px; padding: 1.1rem 1.2rem;
}
.stat .label { color: var(--cinza); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 1.6rem; font-weight: 700; color: var(--azul); margin-top: .3rem; }

.panel {
  background: var(--card); border: 1px solid var(--borda); border-radius: 12px;
  padding: 1.3rem; margin-bottom: 1.5rem;
}
.panel h2 { font-size: 1.1rem; color: var(--azul); margin-bottom: 1rem; }

/* ---------- Form ---------- */
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 1rem; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .35rem; color: #374151; }
input, select, textarea {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--borda); border-radius: 8px;
  font-size: .95rem; font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul-claro); border-color: var(--azul-claro); }
.metodos { display: flex; gap: 1rem; flex-wrap: wrap; }
.metodos label { display: flex; align-items: center; gap: .4rem; font-weight: 500; }
.metodos input { width: auto; }

.btn {
  background: var(--azul); color: #fff; border: none; border-radius: 8px;
  padding: .65rem 1.2rem; font-size: .95rem; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--azul-claro); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn-ghost { background: transparent; color: var(--azul); border: 1px solid var(--borda); }
.btn-danger { background: var(--vermelho); }

/* ---------- Tabela ---------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--borda); }
th { color: var(--cinza); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.status { padding: .18rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.st-pendente { background: #fef3c7; color: #92400e; }
.st-pago { background: #dcfce7; color: #166534; }
.st-cancelado { background: #f3f4f6; color: #374151; }
.st-erro { background: #fee2e2; color: #991b1b; }
.st-expirado { background: #f3f4f6; color: #6b7280; }

.msg { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.msg-erro { background: #fee2e2; color: #991b1b; }
.msg-ok { background: #dcfce7; color: #166534; }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.link-cell { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--cinza); font-size: .82rem; }

/* ---------- Filtros ---------- */
.filtros {
  display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end;
  margin-bottom: 1.2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--borda);
}
.filtros > div { flex: 1 1 140px; min-width: 120px; }
.filtros label { font-size: .78rem; }
.filtros-acoes { display: flex; gap: .5rem; flex: 0 0 auto; }
.filtros-acoes .btn { white-space: nowrap; }

/* ---------- Dashboard ---------- */
.dash-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; }
.dash-controls { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.dash-controls > div { min-width: 110px; }
.dash-controls label { font-size: .78rem; }

.dash-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; margin-top: 1.2rem;
}
.dash-box { border: 1px solid var(--borda); border-radius: 10px; padding: 1rem; }
.dash-box:first-child { grid-column: 1 / -1; }   /* grafico de periodo ocupa a linha toda */
.dash-box h3 { font-size: .95rem; color: var(--azul); margin-bottom: .8rem; }
.chart { width: 100%; }
@media (max-width: 720px) { .dash-grid { grid-template-columns: 1fr; } }

/* barras horizontais (top clientes) */
.hbar { margin-bottom: .7rem; }
.hbar-top { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: .25rem; }
.hbar-track { background: #eef2f7; border-radius: 6px; height: 12px; overflow: hidden; }
.hbar-fill { background: var(--azul-claro); height: 100%; border-radius: 6px; }

/* legenda de status */
.legenda { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: .6rem; font-size: .82rem; }
.legenda span { display: inline-flex; align-items: center; gap: .35rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chart-empty { color: var(--cinza); font-size: .85rem; padding: 1rem 0; }

/* elementos exclusivos de admin: escondidos por padrão, revelados via body.perfil-admin */
.admin-only { display: none; }
.nav-item.admin-only { display: none; }   /* especifico para vencer .nav-item */
body.perfil-admin .admin-only { display: block; }
body.perfil-admin th.admin-only, body.perfil-admin td.admin-only { display: table-cell; }
body.perfil-admin .nav-item.admin-only { display: flex; }
body.perfil-admin .grid-form > .admin-only,
body.perfil-admin .filtros > .admin-only { display: block; }

/* elementos exclusivos do admin COMPLETO (sub-admin nao ve) */
.fulladmin-only { display: none; }
.nav-item.fulladmin-only { display: none; }   /* especifico para vencer .nav-item */
body.perfil-fulladmin .fulladmin-only { display: block; }
body.perfil-fulladmin .nav-item.fulladmin-only { display: flex; }

/* sub-admin nao pode gerar link: esconde o item e a tela */
body.perfil-subadmin [data-view="gerar"] { display: none !important; }
.badge-env { background: rgba(255,255,255,.15); padding: .15rem .5rem; border-radius: 6px; font-size: .8rem; }

/* ========== Layout com menu lateral ========== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex-shrink: 0; background: var(--azul); color: #fff;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  padding: 1.2rem 1.3rem; display: flex; align-items: center; gap: .6rem;
  border-bottom: 1px solid rgba(255,255,255,.18);
}
.sidebar-brand .logo-pin { width: 30px; height: 40px; color: #fff; flex-shrink: 0; }
.brand-text strong { display: block; font-weight: 800; font-size: 1.2rem; line-height: 1; letter-spacing: -.01em; }
.brand-text span { display: block; font-weight: 400; font-size: .78rem; opacity: .85; margin-top: .1rem; }
.logo-pin { display: inline-block; }
.sidebar-nav { padding: .8rem .6rem; display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: .5rem; padding: .65rem .8rem; border-radius: 8px;
  color: rgba(255,255,255,.85); text-decoration: none; font-size: .93rem; font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--azul-claro); color: #fff; }
.sidebar-foot { padding: 1rem; border-top: 1px solid rgba(255,255,255,.18); }
.side-user { font-size: .82rem; margin-bottom: .6rem; opacity: .9; word-break: break-word; }
.side-user strong { display: block; }
/* Botao Sair: texto branco sobre o vermelho da sidebar */
.sidebar-foot .btn {
  width: 100%; color: #fff; background: transparent; border: 1px solid rgba(255,255,255,.45);
}
.sidebar-foot .btn:hover { background: rgba(255,255,255,.15); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--borda);
  padding: 1rem 1.6rem; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 1.2rem; color: var(--azul); font-weight: 700; }
.content { padding: 1.6rem; max-width: 1150px; width: 100%; }

.view.hidden { display: none; }
.hidden { display: none !important; }
.aviso {
  margin-top: .7rem; padding: .7rem .9rem; border-radius: 8px;
  background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; font-size: .85rem;
}
.check-inline { display: flex !important; align-items: center; gap: .5rem; font-weight: 500 !important; margin-top: .5rem; }
.check-inline input { width: auto !important; }

/* responsivo: menu vira topo em telas estreitas */
@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: column; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .content { padding: 1rem; }
}
