:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --primary: #0582CA;
  --primary-dark: #003554;
  --danger: #b42318;
  --warn: #b54708;
  --ok: #067647;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
}

a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 230px;
  background: var(--primary-dark);
  color: white;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
}

.brand {
  margin-bottom: 22px;
}

.brand img {
  display: block;
  max-width: 178px;
  max-height: 72px;
  object-fit: contain;
}

.sidebar nav {
  display: grid;
  gap: 7px;
}

.sidebar a {
  color: white;
  border-radius: 6px;
  padding: 10px 12px;
}

.sidebar a:hover {
  background: rgba(255, 255, 255, .12);
}

.sidebar-credit {
  margin-top: auto;
  padding: 16px 8px 2px;
  color: rgba(255, 255, 255, .72);
  font-size: 12px;
  line-height: 1.4;
}

.main {
  margin-left: 230px;
  padding: 24px;
}

.login-main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.topbar span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.panel,
.login-card,
.cards article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.panel {
  padding: 18px;
  margin-bottom: 18px;
  overflow-x: auto;
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
}

h1,
h2 {
  margin: 0 0 14px;
}

h2 {
  font-size: 18px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.cards article {
  padding: 18px;
}

.cards span,
.login-card p {
  color: var(--muted);
}

.cards strong {
  display: block;
  font-size: 30px;
  margin-top: 8px;
}

.form,
.grid-form,
.inline-form {
  display: grid;
  gap: 12px;
}

.grid-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-form.compact {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.inline-form {
  grid-template-columns: 1fr auto;
  margin-bottom: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

input,
select,
button,
.button {
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 9px 11px;
  font: inherit;
}

input,
select {
  width: 100%;
  background: white;
  color: var(--text);
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  font-weight: 800;
  cursor: pointer;
}

button.secondary,
.button.secondary {
  background: white;
  color: var(--primary);
}

button.icon {
  min-height: 34px;
  padding: 6px 8px;
  background: white;
  color: var(--danger);
  border-color: #f3c2bd;
}

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

.check input {
  width: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
}

.table-tools,
.detail-header,
.actions,
.row-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.detail-header span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.simple-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  list-style: none;
}

.simple-list li {
  background: #e7f4fc;
  border-radius: 999px;
  padding: 7px 10px;
}

.flash {
  border-radius: 6px;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: #ecfdf3;
  color: var(--ok);
  border: 1px solid #abefc6;
}

.flash.error {
  background: #fef3f2;
  border-color: #fecdca;
  color: var(--danger);
}

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

.status.enviado,
.status.finalizada {
  background: #dcfae6;
  color: var(--ok);
}

.status.erro {
  background: #fee4e2;
  color: var(--danger);
}

.status.aberta,
.status.relatorio_emitido,
.status.aguardando_conferencia,
.status.pendente,
.status.processando {
  background: #fef0c7;
  color: var(--warn);
}

.error-cell {
  max-width: 360px;
  word-break: break-word;
  color: #475467;
  font-size: 13px;
}

.hint {
  color: var(--muted);
  margin: 6px 0 0;
}

.error-text {
  color: var(--danger);
  font-weight: 800;
}

.narrow {
  max-width: 520px;
}

.tiny {
  grid-template-columns: 110px auto;
  margin: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(16, 24, 40, .55);
  padding: 20px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(560px, 100%);
  background: white;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(16, 24, 40, .25);
}

.modal h2 {
  font-size: 28px;
}

.modal p {
  font-size: 18px;
  line-height: 1.4;
}

.print-report {
  background: white;
  color: #111;
  padding: 24px;
}

.store-report {
  page-break-after: always;
  margin-bottom: 38px;
}

.store-report h2 {
  border-bottom: 2px solid #111;
  padding-bottom: 8px;
}

.store-report h3 {
  margin: 18px 0 8px;
}

.signature {
  margin-top: 42px;
  page-break-inside: avoid;
}

.signature-line {
  border-bottom: 1px solid #111;
  height: 48px;
  width: 70%;
}

@media print {
  body {
    background: white;
    font-size: 12px;
  }

  .sidebar,
  .topbar,
  .no-print,
  .flash {
    display: none !important;
  }

  .main {
    margin: 0;
    padding: 0;
  }

  .print-report {
    padding: 0;
  }

  table {
    page-break-inside: auto;
  }

  tr {
    page-break-inside: avoid;
  }
}

@media (max-width: 860px) {
  .sidebar {
    position: static;
    width: auto;
  }

  .main {
    margin-left: 0;
    padding: 16px;
  }

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