/* =========================================================
   Sistema de Gestão — identidade visual
   Paleta: ledger/contábil, inspirada em livros-caixa e planilhas
   ========================================================= */

:root {
  --indigo-950: #101B33;
  --indigo-900: #1B2A4A;
  --indigo-700: #2C4270;
  --paper: #F7F8FA;
  --paper-line: #E3E7ED;
  --ink: #23293A;
  --ink-soft: #616B82;
  --gold: #D9A441;
  --gold-dark: #B9862C;
  --green: #3E8E5A;
  --red: #C1443B;
  --radius: 10px;
  --font-display: "Space Grotesk", "Inter", sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
}

a { color: inherit; }

/* ---------- Layout de login: split-screen ---------- */

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}

@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { min-height: 220px; }
}

.auth-brand {
  background: #fff;
  color: var(--ink);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 44px;
}

/* Signature element: linhas de "livro-razão" no fundo, remetendo a lançamentos/planilha */
.auth-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(27, 42, 74, 0.045) 0px,
    rgba(27, 42, 74, 0.045) 1px,
    transparent 1px,
    transparent 48px
  );
  pointer-events: none;
}

.auth-brand::after {
  content: "";
  position: absolute;
  top: -120px;
  right: -120px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(217,164,65,0.14), transparent 70%);
}

.auth-logo {
  display: block;
  max-width: 380px;
  width: 70%;
  height: auto;
  margin: 0 auto 28px;
  z-index: 1;
  position: relative;
}

.auth-brand h1 {
  font-family: var(--font-display);
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.15;
  margin: 0;
  z-index: 1;
  text-align: center;
  max-width: 420px;
  color: var(--indigo-900);
}

.auth-brand .ledger-row {
  z-index: 1;
  display: flex;
  gap: 18px;
  font-size: 13px;
  color: var(--ink-soft);
  border-top: 1px solid var(--paper-line);
  padding-top: 16px;
  margin-top: 40px;
}

.auth-brand .ledger-row strong {
  display: block;
  color: var(--indigo-900);
  font-family: var(--font-display);
  font-size: 20px;
}

.auth-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: var(--indigo-950);
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-card .kicker {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 6px;
}

.auth-card h2 {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 0 0 28px;
  color: #fff;
}

.auth-card label {
  color: rgba(255,255,255,0.85);
}

.auth-card .btn-primary {
  background: var(--gold);
  color: var(--indigo-950);
}

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


label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  margin-top: 18px;
  color: var(--ink);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: var(--font-body);
  background: #fff;
  color: var(--ink);
}

input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.btn-primary {
  width: 100%;
  margin-top: 26px;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--indigo-900);
  color: #fff;
  font-family: var(--font-display);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s ease;
}

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

.btn-secondary {
  width: 100%;
  margin-top: 10px;
  padding: 11px 16px;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  cursor: pointer;
}

.form-msg {
  margin-top: 16px;
  font-size: 13.5px;
  padding: 10px 12px;
  border-radius: var(--radius);
  display: none;
}

.form-msg.error { display: block; background: #FCEBEA; color: var(--red); }
.form-msg.success { display: block; background: #E8F3EC; color: var(--green); }

/* ---------- Painel interno (pós-login) ---------- */

.app-shell { min-height: 100vh; }

.app-topbar {
  background: var(--indigo-950);
  color: #fff;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-topbar .brand {
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: 0.02em;
}

.topbar-brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-logo {
  height: 32px;
  width: auto;
  background: #fff;
  border-radius: 5px;
  padding: 3px 6px;
}

.app-topbar .empresa-tag {
  font-size: 12.5px;
  color: var(--gold);
  border: 1px solid rgba(217,164,65,0.4);
  border-radius: 999px;
  padding: 4px 12px;
  margin-left: 12px;
}

.app-topbar .logout-link {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font-body);
}

.status-card {
  background: #fff;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  padding: 28px;
}

.status-card h1 {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 0 0 6px;
}

.status-card p { color: var(--ink-soft); margin: 0 0 18px; }

.table-wrap {
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  overflow-x: auto;
  margin-top: 24px;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--paper-line); }
th { background: var(--paper); font-family: var(--font-display); font-weight: 500; color: var(--ink-soft); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.ativo { background: #E8F3EC; color: var(--green); }
.badge.inativo { background: #FCEBEA; color: var(--red); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }

/* ---------- Layout com menu lateral ---------- */
.app-body {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - 57px);
}

.app-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--paper-line);
  min-height: calc(100vh - 57px);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-left: 3px solid transparent;
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink-soft);
  padding: 12px 22px;
  cursor: pointer;
}

.sidebar-link .sidebar-ico {
  color: var(--gold);
  font-size: 12px;
}

.sidebar-link:hover { background: var(--paper); color: var(--ink); }

.sidebar-link.active {
  color: var(--indigo-900);
  font-weight: 600;
  background: var(--paper);
  border-left-color: var(--gold);
}

.app-main {
  flex: 1;
  min-width: 0;
  max-width: 960px;
  margin: 0;
  padding: 40px 32px;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

@media (max-width: 780px) {
  .app-body { flex-direction: column; }
  .app-sidebar {
    width: 100%;
    min-height: auto;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--paper-line);
    padding: 8px 12px;
  }
  .sidebar-link {
    width: auto;
    white-space: nowrap;
    border-left: none;
    border-bottom: 3px solid transparent;
    padding: 10px 14px;
  }
  .sidebar-link.active { border-bottom-color: var(--gold); }
  .app-main { padding: 24px 18px; max-width: 100%; }
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header-row h1 { margin: 0; }

.row-actions button {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--indigo-700);
  font-weight: 600;
  margin-right: 10px;
  padding: 0;
}

.row-actions button.excluir { color: var(--red); }

/* ---------- Modal ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16, 27, 51, 0.55);
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal-overlay.open { display: flex; }

.modal-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-box h2 {
  font-family: var(--font-display);
  font-size: 20px;
  margin: 0 0 20px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.modal-actions .btn-secondary,
.modal-actions .btn-primary { margin-top: 0; }

.modal-box-lg { max-width: 720px; }

select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: var(--font-body);
  background: #fff;
  color: var(--ink);
}

.opcao-tipo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 500;
  margin: 0;
  cursor: pointer;
}
.opcao-tipo input { width: auto; margin: 0; }

.pdv-fiscal-header {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--paper-line);
  font-size: 12.5px;
  color: var(--ink-soft);
}
.pdv-fiscal-header strong { color: var(--indigo-900); font-family: var(--font-display); font-size: 13.5px; }

.lista-itens-kit {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
}
.lista-itens-kit li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 13px;
  font-size: 14px;
  border-bottom: 1px solid var(--paper-line);
}
.lista-itens-kit li:last-child { border-bottom: none; }
.lista-itens-kit button {
  border: none;
  background: none;
  color: var(--red);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.total-pedido {
  text-align: right;
  font-size: 17px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--paper-line);
}
.total-pedido strong { color: var(--indigo-900); font-family: var(--font-display); }

.tabela-parcelas-preview td input {
  padding: 7px 9px;
  font-size: 13.5px;
}

/* ---------- Área de impressão (pedidos/orçamentos em PDF) ---------- */
#areaImpressao { display: none; }

@media print {
  body * { visibility: hidden; }
  #areaImpressao, #areaImpressao * { visibility: visible; }
  #areaImpressao { display: block; position: absolute; top: 0; left: 0; width: 100%; padding: 24px; }
}

/* ---------- DAV — Documento Auxiliar de Venda (formato de cupom) ---------- */
.dav-receipt {
  max-width: 300px;
  margin: 0 auto;
  font-family: "Courier New", monospace;
  font-size: 12px;
  color: #000;
  line-height: 1.5;
}

.dav-header { text-align: center; margin-bottom: 6px; }

.dav-logo {
  display: block;
  max-width: 110px;
  height: auto;
  margin: 0 auto 8px;
}

.dav-titulo {
  text-align: center;
  font-weight: bold;
  margin: 6px 0 2px;
  font-size: 12.5px;
}

.dav-aviso {
  text-align: center;
  font-size: 10.5px;
  margin-bottom: 6px;
}

.dav-linha-dupla {
  border-top: 1px dashed #000;
  margin: 8px 0;
}

.dav-tabela { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 6px; }
.dav-tabela th { text-align: left; border-bottom: 1px dashed #000; padding-bottom: 3px; }
.dav-tabela td { padding: 2px 0; vertical-align: top; }
.dav-num { text-align: right; white-space: nowrap; }

.dav-total { font-weight: bold; font-size: 14px; margin: 6px 0 2px; }

.dav-rodape { text-align: center; font-size: 10.5px; margin-top: 10px; }

.dav-frase {
  margin-top: 8px;
  font-weight: bold;
  font-size: 11.5px;
}

/* ---------- PDV ---------- */
.pdv-resultados {
  display: none;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  margin-top: -12px;
  margin-bottom: 16px;
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
}
.pdv-resultados.open { display: block; }

.pdv-resultado-item {
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--paper-line);
}
.pdv-resultado-item:last-child { border-bottom: none; }
.pdv-resultado-item:hover { background: var(--paper); }
.pdv-resultado-item[data-id] { cursor: pointer; }

#pdvCarrinho input[type="number"] { width: 70px; padding: 6px 8px; }

/* ---------- PDV — layout estilo caixa ---------- */
.pdv-shell {
  background: var(--indigo-950);
  border-radius: var(--radius);
  overflow: hidden;
}

.pdv-topbar {
  background: var(--indigo-900);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
}

.pdv-status { color: var(--green); font-weight: 600; }
.pdv-operador { color: rgba(255,255,255,0.7); }

.pdv-cliente-bar {
  background: rgba(255,255,255,0.04);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.pdv-cliente-bar strong { color: var(--gold); font-weight: 600; }
.pdv-cliente-bar button {
  border: 1px solid rgba(255,255,255,0.25);
  background: transparent;
  color: #fff;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
}
.pdv-cliente-bar button:hover { background: rgba(255,255,255,0.08); }
.pdv-cliente-bar button small { opacity: 0.6; margin-left: 4px; }

.pdv-select-inline {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 13px;
}
.pdv-select-inline option { color: #000; }

.pdv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: rgba(255,255,255,0.08);
}

.pdv-entrada, .pdv-carrinho-painel {
  background: #fff;
  padding: 24px;
}

.pdv-entrada label { margin-top: 0; }

.pdv-codigo-row {
  display: grid;
  grid-template-columns: 1fr 90px;
  gap: 10px;
}

#pdvCodigo {
  font-size: 16px;
  font-family: var(--font-body);
  padding: 13px 15px;
}

#pdvQtdRapida { padding: 13px 10px; text-align: center; }

.pdv-btn-buscar-produto {
  width: 100%;
  margin-top: 12px;
  padding: 12px 16px;
}

.pdv-logo-area {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 0 16px;
  opacity: 0.8;
}
.pdv-logo-area img { max-width: 140px; height: auto; }

.pdv-totalbar {
  background: var(--indigo-900);
  color: #fff;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
}
.pdv-totalbar-valor { font-size: 17px; }
.pdv-totalbar strong { font-family: var(--font-display); }
.pdv-totalbar .pdv-totalbar-valor strong { font-size: 26px; color: var(--gold); margin-left: 6px; }

.pdv-bottombar {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr;
  gap: 1px;
  background: rgba(255,255,255,0.08);
}

.pdv-bottombar button {
  border: none;
  background: var(--indigo-900);
  color: #fff;
  padding: 16px 10px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.6;
}
.pdv-bottombar button:hover { background: var(--indigo-700); }
.pdv-bottombar button small { font-weight: 400; opacity: 0.7; }

.pdv-bottombar button.pdv-finalizar {
  background: var(--green);
  font-size: 16px;
}
.pdv-bottombar button.pdv-finalizar:hover { background: #337a4d; }

/* ---------- Listas de busca (modal de produto/cliente) ---------- */
.pdv-busca-lista {
  margin-top: 12px;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
}

.pdv-busca-item {
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--paper-line);
  font-size: 14px;
}
.pdv-busca-item:last-child { border-bottom: none; }
.pdv-busca-item:hover { background: var(--paper); }
.pdv-busca-item span { color: var(--ink-soft); font-size: 13px; white-space: nowrap; }

.busca-global-grupo {
  padding: 8px 16px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  background: var(--paper);
}

@media (max-width: 780px) {
  .pdv-grid { grid-template-columns: 1fr; }
  .pdv-bottombar { grid-template-columns: 1fr; }
  .pdv-cliente-bar { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* ---------- Dashboard ---------- */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}
@media (max-width: 780px) { .dash-grid { grid-template-columns: 1fr 1fr; } }

.dash-card {
  background: #fff;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  padding: 20px;
  border-left: 4px solid var(--indigo-900);
}

.dash-label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.dash-valor {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--indigo-900);
}

.dash-recebido { border-left-color: var(--green); }
.dash-atrasado { border-left-color: var(--red); }
.dash-faturado { border-left-color: var(--gold); }
.dash-pagar { border-left-color: var(--indigo-700); }

.dash-ico {
  display: block;
  font-size: 22px;
  margin-bottom: 6px;
}

.dash-chart-wrap {
  max-width: 420px;
  margin: 10px auto 0;
}
