:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --green: #16a34a;
  --red: #dc2626;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 8px 30px rgba(15, 23, 42, .06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, #eef2ff, transparent 40%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: white;
  border-radius: 24px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand.grande {
  margin-bottom: 26px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  font-weight: 800;
  font-size: 20px;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 20px;
  overflow: hidden;
}

.tab {
  flex: 1;
  border: 0;
  padding: 11px;
  background: white;
}

.tab.ativo {
  color: white;
  background: var(--primary);
}

label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin: 13px 0 6px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: white;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: #eef0f4;
  color: var(--text);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.full {
  width: 100%;
  margin-top: 18px;
}

.erro {
  color: var(--red);
  font-size: 13px;
  margin-top: 10px;
}

header {
  min-height: 70px;
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions select {
  min-width: 180px;
}

nav {
  display: flex;
  overflow-x: auto;
  gap: 4px;
  padding: 0 24px;
  background: white;
  border-bottom: 1px solid var(--border);
}

.nav-item {
  border-radius: 0;
  background: transparent;
  padding: 14px 16px;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.nav-item.ativo {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 50px;
}

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}

.page-title h1 {
  margin: 0;
  font-size: 26px;
}

.page-title p {
  margin: 5px 0 0;
  color: var(--muted);
}

.page-title input {
  width: auto;
}

.section-label {
  color: #475569;
  font-size: 14px;
  margin: 18px 0 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.metric {
  background: white;
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid #f0f1f4;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 25px;
}

.metric.entrada strong {
  color: var(--green);
}

.metric.saida strong {
  color: var(--red);
}

.metric.resultado strong {
  color: var(--primary);
}

.chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-top: 18px;
}

.panel {
  background: white;
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid #f0f1f4;
}

.panel h3 {
  margin: 0 0 12px;
}

.table-wrap {
  overflow-x: auto;
  background: white;
  border-radius: 18px;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

th {
  color: var(--muted);
  background: #fafafa;
  font-weight: 600;
}

.valor-positivo {
  color: var(--green);
  font-weight: 700;
}

.valor-negativo {
  color: var(--red);
  font-weight: 700;
}

.link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.receipt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.receipt {
  background: white;
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.receipt strong {
  display: block;
  margin-bottom: 6px;
}

.receipt small {
  display: block;
  color: var(--muted);
  margin-bottom: 12px;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.inline {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline input,
.inline select {
  margin: 0;
}

.inline input[type=color] {
  max-width: 55px;
}

.access-code {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: .12em;
  color: var(--primary);
}

.muted {
  color: var(--muted);
}

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding: 11px 0;
}

.item-row:first-child {
  margin-top: 12px;
}

.item-main strong,
.item-main small {
  display: block;
}

.item-main small {
  color: var(--muted);
  margin-top: 3px;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .48);
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal.aberto {
  display: flex;
}

.modal-box {
  width: min(430px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: white;
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 25px 80px rgba(0,0,0,.2);
}

.modal-box h2 {
  margin-top: 0;
}

.modal-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #111827;
  color: white;
  padding: 12px 16px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: .2s;
  z-index: 300;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.danger {
  color: var(--red);
}

@media (max-width: 800px) {

  header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions select {
    flex: 1;
    min-width: 0;
  }

  nav {
    padding: 0 12px;
  }

  main {
    width: min(100% - 20px, 1180px);
    margin-top: 15px;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .config-grid {
    grid-template-columns: 1fr;
  }

  .page-title {
    align-items: stretch;
    flex-direction: column;
  }

  .page-title input,
  .page-title button {
    width: 100%;
  }

  .inline {
    flex-wrap: wrap;
  }

  .inline > * {
    flex: 1 1 140px;
  }

  .metric strong {
    font-size: 23px;
  }
}

.status-dia {
  margin: 12px 0 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #ffffff;
  color: var(--muted);
  border: 1px solid var(--border);
}

.status-dia.positivo {
  color: var(--green);
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.status-dia.negativo {
  color: var(--red);
  background: #fef2f2;
  border-color: #fecaca;
}

.empty-state {
  min-height: 260px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.historico-panel,
.hoje-panel {
  margin-top: 18px;
}

.sem-sombra {
  box-shadow: none;
}

.historico-table {
  min-width: 640px;
}

.resultado-chip {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
}

.resultado-chip.positivo {
  background: #dcfce7;
  color: #166534;
}

.resultado-chip.negativo {
  background: #fee2e2;
  color: #991b1b;
}

.resultado-chip.zero {
  background: #f1f5f9;
  color: #475569;
}

.movimento {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.movimento:first-child {
  border-top: 0;
}

.movimento-info strong,
.movimento-info small {
  display: block;
}

.movimento-info small {
  color: var(--muted);
  margin-top: 3px;
}

.movimento-valor {
  font-weight: 800;
}

.movimento-valor.entrada {
  color: var(--green);
}

.movimento-valor.saida {
  color: var(--red);
}

.filtros-lista {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filtros-lista input {
  width: auto;
  min-width: 160px;
}

.filtros-lista input:first-child {
  flex: 1;
  min-width: 240px;
}

.filtro-label {
  margin: 0;
}

.filtro-label input {
  display: block;
  margin-top: 5px;
}

.relatorio-bloco {
  margin-top: 18px;
}

.relatorio-cabecalho {
  margin-bottom: 18px;
}

.relatorio-cabecalho h2 {
  margin-bottom: 4px;
}

.relatorio-cabecalho p {
  margin-top: 0;
  color: var(--muted);
}

.acoes-tabela {
  display: flex;
  gap: 5px;
}

.btn-small {
  padding: 6px 9px;
  font-size: 12px;
}

@media print {

  body {
    background: white;
  }

  header,
  nav,
  .no-print,
  #btn-imprimir-relatorio,
  .toast {
    display: none !important;
  }

  main {
    width: 100%;
    margin: 0;
  }

  .page {
    display: none !important;
  }

  #page-relatorio {
    display: block !important;
  }

  .panel,
  .metric,
  .table-wrap {
    box-shadow: none;
  }

  .cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

.status-dia {
  margin: 12px 0 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #ffffff;
  color: var(--muted);
  border: 1px solid var(--border);
}

.status-dia.positivo {
  color: var(--green);
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.status-dia.negativo {
  color: var(--red);
  background: #fef2f2;
  border-color: #fecaca;
}

.empty-state {
  min-height: 260px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.historico-panel,
.hoje-panel {
  margin-top: 18px;
}

.sem-sombra {
  box-shadow: none;
}

.historico-table {
  min-width: 640px;
}

.resultado-chip {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
}

.resultado-chip.positivo {
  background: #dcfce7;
  color: #166534;
}

.resultado-chip.negativo {
  background: #fee2e2;
  color: #991b1b;
}

.resultado-chip.zero {
  background: #f1f5f9;
  color: #475569;
}

.movimento {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.movimento:first-child {
  border-top: 0;
}

.movimento-info strong,
.movimento-info small {
  display: block;
}

.movimento-info small {
  color: var(--muted);
  margin-top: 3px;
}

.movimento-valor {
  font-weight: 800;
}

.movimento-valor.entrada {
  color: var(--green);
}

.movimento-valor.saida {
  color: var(--red);
}

header {
  position: static !important;
  top: auto !important;
}

nav {
  position: sticky;
  top: 0;
  z-index: 30;
}

header,
nav {
  position: static !important;
  top: auto !important;
}
