/* =========================================================
   Coliseu Fiscal — Design System
   Paleta: Azul corporativo, branco, cinza
   ========================================================= */

:root {
  --blue-900: #0b1f3a;
  --blue-800: #10294f;
  --blue-700: #163a6b;
  --blue-600: #1d4f8f;
  --blue-500: #2563eb;
  --blue-400: #4f86e8;
  --blue-100: #e8f0fe;
  --gray-900: #1a1d24;
  --gray-700: #4b5563;
  --gray-500: #6b7280;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50: #f8fafc;
  --white: #ffffff;
  --green-600: #16a34a;
  --green-100: #dcfce7;
  --red-600: #dc2626;
  --red-100: #fee2e2;
  --amber-600: #d97706;
  --amber-100: #fef3c7;
  --radius: 14px;
  --shadow-sm: 0 1px 2px 0 rgb(16 41 79 / 0.06);
  --shadow-md: 0 4px 16px -2px rgb(16 41 79 / 0.12);
  --shadow-lg: 0 12px 32px -6px rgb(16 41 79 / 0.18);
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

/* ---------- Layout shell ---------- */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar ---------- */
.topbar {
  background: linear-gradient(120deg, var(--blue-900) 0%, var(--blue-700) 100%);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-md);
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #ffd166;
  border: 1px solid rgba(255,255,255,0.18);
}
.brand-text h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.brand-text span {
  display: block;
  font-size: 11px;
  color: #b9c9e8;
  font-weight: 500;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.nav-links {
  display: flex;
  gap: 6px;
  align-items: center;
}
.nav-links a {
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: #d5e1f7;
  transition: 0.15s;
  display: flex;
  align-items: center;
  gap: 7px;
}
.nav-links a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-links a.active { background: var(--white); color: var(--blue-800); }

/* ---------- Page wrapper ---------- */
.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 28px 80px;
  width: 100%;
  flex: 1;
}

.page-header { margin-bottom: 28px; }
.page-header h2 {
  font-size: 28px;
  font-weight: 800;
  color: var(--blue-900);
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-header p {
  color: var(--gray-500);
  font-size: 15px;
  margin: 0;
  max-width: 760px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}
.card + .card { margin-top: 22px; }
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--blue-900);
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.card-title i { color: var(--blue-500); }

/* ---------- Stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.stat-icon.blue { background: var(--blue-100); color: var(--blue-600); }
.stat-icon.green { background: var(--green-100); color: var(--green-600); }
.stat-icon.red { background: var(--red-100); color: var(--red-600); }
.stat-icon.amber { background: var(--amber-100); color: var(--amber-600); }
.stat-value { font-size: 22px; font-weight: 800; color: var(--gray-900); line-height: 1.1; }
.stat-label { font-size: 12.5px; color: var(--gray-500); font-weight: 600; margin-top: 2px; }

/* ---------- Forms ---------- */
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.input, .select {
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--gray-900);
  background: var(--white);
  transition: 0.15s;
  outline: none;
  width: 100%;
}
.input:focus, .select:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.input-icon-wrap { position: relative; }
.input-icon-wrap .input { padding-left: 40px; }
.input-icon-wrap i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-500);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 11px 20px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--blue-600); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--blue-700); }
.btn-outline { background: var(--white); color: var(--blue-700); border: 1.5px solid var(--gray-300); }
.btn-outline:hover { border-color: var(--blue-500); color: var(--blue-600); }
.btn-ghost { background: transparent; color: var(--gray-700); }
.btn-ghost:hover { background: var(--gray-100); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge-green { background: var(--green-100); color: #15803d; }
.badge-red { background: var(--red-100); color: #b91c1c; }
.badge-amber { background: var(--amber-100); color: #a15c07; }
.badge-blue { background: var(--blue-100); color: var(--blue-700); }
.badge-gray { background: var(--gray-100); color: var(--gray-700); }

/* ---------- Result panel (NCM lookup) ---------- */
.result-panel {
  display: none;
  margin-top: 22px;
}
.result-panel.show { display: block; }
.result-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 14px;
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: 18px;
  margin-bottom: 18px;
}
.result-ncm {
  font-size: 26px;
  font-weight: 800;
  color: var(--blue-900);
  letter-spacing: 0.5px;
}
.result-desc { color: var(--gray-700); font-size: 14.5px; margin-top: 4px; max-width: 640px; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}
.info-box {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 14px 16px;
}
.info-box .k {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--gray-500);
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}
.info-box .v { font-size: 16px; font-weight: 700; color: var(--gray-900); }
.legal-box {
  margin-top: 16px;
  background: var(--blue-100);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--blue-800);
  line-height: 1.55;
  display: flex;
  gap: 10px;
}
.legal-box i { margin-top: 2px; }
.legal-box a { color: var(--blue-700); font-weight: 700; text-decoration: underline; }

/* ---------- Section titles inside result panel ---------- */
.section-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--gray-500);
  margin: 26px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: 8px;
}
.section-title i { color: var(--blue-500); }

/* ---------- Rate highlight (IBS/CBS %) ---------- */
.rate-highlight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin: 4px 0 18px;
}
.rate-card {
  border-radius: 12px;
  padding: 16px 18px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.rate-card.ibs { background: linear-gradient(135deg, var(--blue-700), var(--blue-500)); }
.rate-card.cbs { background: linear-gradient(135deg, #0f6e5c, #16a34a); }
.rate-card.efetiva { background: linear-gradient(135deg, #92400e, #d97706); }
.rate-card .rc-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; opacity: 0.9; }
.rate-card .rc-value { font-size: 26px; font-weight: 800; margin-top: 4px; }
.rate-card .rc-sub { font-size: 12px; opacity: 0.9; margin-top: 4px; }

/* ---------- Indicator grid (badges de sim/não/N-A) ---------- */
.indicator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}
.indicator-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}
.indicator-item .ind-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  flex-shrink: 0;
}
.ind-badge.yes { background: var(--green-100); color: #15803d; }
.ind-badge.no { background: var(--gray-100); color: var(--gray-500); }
.ind-badge.na { background: var(--amber-100); color: #a15c07; }

/* ---------- Document applicability chips ---------- */
.doc-chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.doc-chip {
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--gray-200);
  color: var(--gray-400);
  background: #fff;
}
.doc-chip.applicable { border-color: var(--green-600); color: #15803d; background: var(--green-100); }

/* ---------- Table / DataGrid ---------- */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--gray-200); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 900px; }
table.grid thead th {
  background: var(--blue-900);
  color: #fff;
  text-align: left;
  padding: 12px 14px;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  position: sticky;
  top: 0;
}
table.grid tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-900);
  vertical-align: top;
}
table.grid tbody tr:hover { background: var(--gray-50); }
table.grid tbody tr:last-child td { border-bottom: none; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

/* ---------- Autocomplete ---------- */
.autocomplete-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-height: 340px;
  overflow-y: auto;
  z-index: 40;
  display: none;
}
.autocomplete-list.show { display: block; }
.autocomplete-item {
  padding: 11px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--blue-100); }
.autocomplete-item .ac-ncm { font-weight: 800; color: var(--blue-800); font-size: 13.5px; }
.autocomplete-item .ac-desc { font-size: 12.5px; color: var(--gray-500); flex: 1; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2.5px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: 0.15s;
  background: var(--gray-50);
}
.dropzone.dragover { border-color: var(--blue-500); background: var(--blue-100); }
.dropzone i { font-size: 40px; color: var(--blue-400); margin-bottom: 14px; }
.dropzone h3 { margin: 0 0 6px; font-size: 16px; color: var(--gray-900); }
.dropzone p { margin: 0; font-size: 13px; color: var(--gray-500); }

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--gray-100);
  border-radius: 999px;
  padding: 6px 12px 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gray-700);
  margin: 4px 6px 0 0;
}
.file-chip button { background: none; border: none; cursor: pointer; color: var(--gray-500); font-size: 13px; }
.file-chip button:hover { color: var(--red-600); }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--gray-500); }
.empty-state i { font-size: 42px; color: var(--gray-300); margin-bottom: 14px; }
.empty-state h3 { color: var(--gray-700); margin: 0 0 6px; font-size: 16px; }
.empty-state p { margin: 0; font-size: 13.5px; }

/* ---------- Loader ---------- */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11,31,58,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(2px);
}
.loader-overlay.show { display: flex; }
.loader-box {
  background: #fff;
  border-radius: 16px;
  padding: 32px 40px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--blue-600);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-box p { margin: 0; font-weight: 700; color: var(--blue-900); font-size: 14px; }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: #fff;
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
  font-weight: 600;
  min-width: 280px;
  border-left: 4px solid var(--blue-500);
  animation: slideIn 0.25s ease;
}
.toast.error { border-left-color: var(--red-600); }
.toast.success { border-left-color: var(--green-600); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------- Filters chip row ---------- */
.chip-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 999px;
  border: 1.5px solid var(--gray-200);
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-700);
  cursor: pointer;
  transition: 0.15s;
}
.chip-filter:hover { border-color: var(--blue-400); }
.chip-filter.active { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }

/* ---------- Footer ---------- */
.footer {
  background: var(--blue-900);
  color: #a9bee0;
  text-align: center;
  padding: 22px;
  font-size: 12.5px;
}
.footer strong { color: #fff; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; flex-wrap: wrap; gap: 10px; }
.pagination .info { font-size: 13px; color: var(--gray-500); }
.pagination .controls { display: flex; gap: 6px; }
.page-btn {
  border: 1.5px solid var(--gray-200);
  background: #fff;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: var(--gray-700);
}
.page-btn:hover:not(:disabled) { border-color: var(--blue-500); color: var(--blue-600); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-btn.active { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .nav-links span.nav-label { display: none; }
  .page { padding: 20px 14px 60px; }
}
@media (max-width: 600px) {
  .topbar-inner { padding: 12px 14px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .brand-text span { display: none; }
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11,31,58,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 250;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 16px;
  max-width: 880px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
  box-shadow: var(--shadow-lg);
}
.modal-close {
  position: sticky;
  top: 0;
  float: right;
  background: var(--gray-100);
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  cursor: pointer;
  color: var(--gray-700);
  font-size: 14px;
  z-index: 10;
}
.modal-close:hover { background: var(--gray-200); }

/* ---------- Crossref box (BrasilAPI NCM confirmation) ---------- */
.crossref-box {
  display: flex;
  gap: 10px;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  margin-top: 14px;
}
.crossref-box i { margin-top: 2px; flex-shrink: 0; }
.crossref-box.crossref-ok { background: var(--green-100); color: #15803d; }
.crossref-box.crossref-warn { background: var(--amber-100); color: #a15c07; }
.crossref-meta { font-size: 12px; opacity: 0.85; margin-top: 3px; }

/* ---------- API status grid (Guias page) ---------- */
.api-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}
.api-status-card {
  border-radius: 12px;
  border: 1.5px solid var(--gray-200);
  padding: 18px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.api-status-card.ok { border-color: var(--green-600); background: linear-gradient(180deg, var(--green-100) 0%, #fff 18%); }
.api-status-card.blocked { border-color: var(--red-600); background: linear-gradient(180deg, var(--red-100) 0%, #fff 18%); }
.api-status-card.unavailable { border-color: var(--amber-600); background: linear-gradient(180deg, var(--amber-100) 0%, #fff 18%); }
.api-status-card h5 { margin: 0; font-size: 15px; font-weight: 800; color: var(--gray-900); display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.api-status-card .endpoint { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11.5px; color: var(--gray-700); background: var(--gray-100); padding: 6px 8px; border-radius: 6px; word-break: break-all; }
.api-status-card p { margin: 0; font-size: 13px; color: var(--gray-700); line-height: 1.55; }
.api-status-tag { font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; }
.api-status-tag.ok { background: var(--green-600); color: #fff; }
.api-status-tag.blocked { background: var(--red-600); color: #fff; }
.api-status-tag.unavailable { background: var(--amber-600); color: #fff; }

/* ---------- Bulk import (lote) ---------- */
.bulk-progress-wrap { margin-top: 16px; }
.bulk-progress-bar { height: 10px; border-radius: 999px; background: var(--gray-200); overflow: hidden; }
.bulk-progress-fill { height: 100%; background: linear-gradient(90deg, var(--blue-600), var(--blue-400)); transition: width 0.2s; width: 0%; }
.bulk-progress-label { font-size: 12.5px; color: var(--gray-500); margin-top: 6px; font-weight: 600; }
textarea.input {
  width: 100%; min-height: 110px; resize: vertical;
  border: 1.5px solid var(--gray-200); border-radius: 10px; padding: 11px 14px;
  font-size: 14px; font-family: inherit; outline: none;
}
textarea.input:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }

/* ---------- Utility ---------- */
.flex { display: flex; }
.gap-2 { gap: 8px; }
.items-center { align-items: center; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11.5px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.impact-positive { color: var(--red-600); font-weight: 800; }
.impact-zero { color: var(--gray-500); font-weight: 700; }
