:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --dark: #0f172a;
  --text: #111827;
  --muted: #64748b;
  --border: #cbd5e1;
  --blue: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #ca8a04;
  --shadow: 0 4px 14px #0001;
}

* {
  box-sizing: border-box;
}

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

header {
  background: var(--dark);
  color: white;
  padding: 18px 28px;
}

header h1 {
  margin: 0 0 4px;
}

main {
  padding: 24px;
  max-width: 1400px;
  margin: auto;
}

.card {
  background: var(--card);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

label {
  font-size: 13px;
  font-weight: bold;
  display: block;
  margin-top: 10px;
}

input,
select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

button {
  padding: 12px 18px;
  border: 0;
  border-radius: 10px;
  font-weight: bold;
  cursor: pointer;
  font-size: 14px;
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

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

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

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

.btn-light {
  background: #e2e8f0;
  color: var(--text);
}

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

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

.hidden {
  display: none !important;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 70vh;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid #cbd5e1;
  padding: 9px;
  text-align: left;
  white-space: nowrap;
}

th {
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 10;
}

tbody tr:nth-child(odd) {
  background: #ffffff;
}

tbody tr:nth-child(even) {
  background: #e5e7eb;
}

tbody tr:hover {
  background: #dbeafe;
}

tbody tr.selected {
  background: #1e3a8a !important;
  color: #ffffff;
}

tbody tr.selected td {
  color: #ffffff;
}

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

.badge-emitido {
  background: #dcfce7;
  color: #166534;
}

.badge-rejeitado {
  background: #fee2e2;
  color: #991b1b;
}

.badge-processando {
  background: #fef9c3;
  color: #854d0e;
}

.badge-default {
  background: #e2e8f0;
  color: #334155;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: #0008;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow: auto;
  z-index: 1000;
}

.modal {
  background: white;
  width: min(1100px, 100%);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 60px #0005;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
}

.suggestions {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 4px;
  max-height: 180px;
  overflow: auto;
}

.suggestions div {
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid #e5e7eb;
}

.suggestions div:hover {
  background: #e0f2fe;
}

.selected-city {
  font-size: 13px;
  color: #166534;
  margin-top: 4px;
  font-weight: bold;
}

.result-ok {
  font-size: 28px;
  color: var(--green);
  font-weight: bold;
}

.result-error {
  font-size: 20px;
  color: var(--red);
  font-weight: bold;
}

pre {
  background: #020617;
  color: #d1fae5;
  padding: 14px;
  border-radius: 10px;
  overflow: auto;
  max-height: 260px;
}

h3 {
  margin-top: 16px;
  margin-bottom: 6px;
  font-size: 14px;
  color: #1e293b;
}

.input-error {
  border-color: #dc2626 !important;
  background: #fff1f2;
}

.col-actions,
td.row-actions {
  position: sticky;
  left: 0;
  z-index: 15;
  background: inherit;
}

th.col-actions {
  z-index: 20;
  background: #f8fafc;
}

td.row-actions {
  min-width: 70px;
  text-align: center;
}

.btn-menu {
  background: #e2e8f0;
  color: #111827;
  padding: 6px 10px;
  border-radius: 8px;
  min-width: 36px;
}

.btn-menu:hover {
  background: #cbd5e1;
}

.floating-menu {
  position: fixed;
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 12px 30px #0004;
  min-width: 160px;
  z-index: 5000;
  overflow: hidden;
}

.floating-menu button {
  display: block;
  width: 100%;
  background: white;
  color: #111827;
  border-radius: 0;
  padding: 10px 12px;
  text-align: left;
}

.floating-menu button:hover {
  background: #f1f5f9;
}