:root {
  /* Cores oficiais ACJOGOS-AL */
  --navy: #233871;
  --navy-2: #1a2b5a;
  --navy-tint: #eef1f8;
  --red: #d42127;
  --red-2: #b91c22;
  --red-tint: #fdecec;
  --sky: #33b0e6;
  --sky-2: #1e93c9;
  --sky-tint: #e9f6fd;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1f2733;
  --muted: #6b7280;
  --border: #e5e8ef;

  --green: #157347;      /* escurecido p/ passar contraste AA em badge */
  --green-tint: #e7f6ee;
  --amber: #8a5a10;      /* escurecido p/ passar contraste AA em badge */
  --amber-tint: #fbf3e0;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 14px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body { max-width: 100%; overflow-x: hidden; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: #1770a0; }

/* Conteúdo visível só para leitores de tela. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Foco de teclado visível e consistente com a marca. */
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.btn:focus-visible, .nav-item:focus-visible,
.icon-btn:focus-visible, .modal-close:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

/* ---------- LOGIN ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 50% -10%, var(--navy-tint) 0%, var(--bg) 60%);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--navy);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 36px 34px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.login-logo { width: 150px; height: auto; margin: 0 auto 6px; display: block; }
.login-sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }

/* Esconde o h1 textual do login — o logo já traz a marca */
.login-card h1 { display: none; }

input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  padding: 11px 12px;
  font-size: 14px;
  width: 100%;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px var(--navy-tint);
}

/* ---------- BOTÕES ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); border-color: #d3d8e2; }
.btn-danger { background: var(--surface); border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-tint); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- LAYOUT ---------- */
.layout { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand img { width: 118px; height: auto; }
.brand-text { display: none; } /* o logo já contém o nome */

.sidebar nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  color: var(--muted);
  text-align: left;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 11px;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active {
  background: var(--navy-tint);
  color: var(--navy);
  border-left-color: var(--navy);
  border-radius: 0 8px 8px 0;
}

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

.content { padding: 28px 32px; overflow-x: hidden; }

.view-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}
.view-head h1 { margin: 0; font-size: 23px; color: var(--navy); font-weight: 700; }
.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.head-actions input[type=search], .head-actions select { width: auto; min-width: 200px; }

/* ---------- CARDS ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--navy);
}
.card .card-label { color: var(--muted); font-size: 13px; margin-bottom: 8px; font-weight: 500; }
.card .card-value { font-size: 25px; font-weight: 700; color: var(--navy); }
.card .card-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.card.accent-green { border-top-color: var(--green); }
.card.accent-green .card-value { color: var(--green); }
.card.accent-amber { border-top-color: var(--amber); }
.card.accent-amber .card-value { color: var(--amber); }
.card.accent-red { border-top-color: var(--red); }
.card.accent-red .card-value { color: var(--red); }
.card.accent-cyan { border-top-color: var(--sky); }
.card.accent-cyan .card-value { color: var(--sky-2); }

/* ---------- PANEL / TABELAS ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 15px; color: var(--navy); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 16px; font-size: 14px; }
th {
  color: var(--muted); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border); background: #fafbfc;
}
td { border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 640px; }

.muted { color: var(--muted); }
.empty { padding: 44px; text-align: center; color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- BADGES ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}
.badge svg { width: 13px; height: 13px; }
.badge-muted { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.badge-pago { background: var(--green-tint); color: var(--green); }
.badge-pendente { background: var(--amber-tint); color: var(--amber); }
.badge-vencido { background: var(--red-tint); color: var(--red); }
.badge-cancelado, .badge-estornado, .badge-outro { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.badge-on { background: var(--green-tint); color: var(--green); }
.badge-off { background: var(--red-tint); color: var(--red); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 5px 9px;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
  line-height: 1.4;
}
.icon-btn:hover { border-color: var(--navy); background: var(--navy-tint); }
.icon-btn svg { width: 15px; height: 15px; display: block; }

/* ---------- MODAL ---------- */
.modal-overlay[hidden] { display: none; }
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 39, 51, .45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(16, 24, 40, .2);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 17px; color: var(--navy); }
.modal-close { background: none; border: none; color: var(--muted); font-size: 24px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background: #fafbfc; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid label, .form-full { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.form-full { grid-column: 1 / -1; }

/* ---------- PIX ---------- */
.pix-box { text-align: center; }
.pix-box img { width: 232px; height: 232px; border: 1px solid var(--border); border-radius: 12px; padding: 8px; background: #fff; }
.pix-copy { display: flex; gap: 8px; margin-top: 16px; }
.pix-copy input { font-size: 12px; font-family: ui-monospace, monospace; }

.erro-msg { color: var(--red); font-size: 13px; margin: 4px 0 0; }
.info-line { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

/* ---------- TOASTS ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--navy);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--shadow);
  max-width: 340px;
  color: var(--text);
  animation: slideIn .2s ease;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- RESPONSIVO ---------- */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 12px; justify-content: space-between; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; justify-content: center; }
  .nav-item { border-left: none; border-radius: 8px; }
  .nav-item.active { border-radius: 8px; }
  .sidebar-footer { margin: 0; flex-direction: row; align-items: center; }
  .content { padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }

  /* Alvos de toque maiores (WCAG 2.5.5 / conforto no dedo). */
  .icon-btn {
    min-width: 40px; min-height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0;
  }
  .icon-btn svg { width: 18px; height: 18px; }
  .row-actions { gap: 8px; }
  .modal-close { padding: 4px 10px; font-size: 28px; }
  .btn-sm { padding: 9px 14px; font-size: 13px; }
  th, td { padding: 10px 12px; }

  /* Ações do cabeçalho ocupam a largura toda. */
  .head-actions { width: 100%; }
  .head-actions input[type=search],
  .head-actions select { width: 100%; min-width: 0; flex: 1 1 100%; }
  .head-actions .btn { flex: 1 1 auto; justify-content: center; }
}

@media (max-width: 480px) {
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
  .pix-copy { flex-direction: column; }
  .pix-copy .btn { width: 100%; justify-content: center; }
}
