/* Design system da OFFICE — tokens copiados do Orquestra, sem reinterpretar
   cores, raios, sombras ou curvas de easing. */
:root {
  --bg: #f9fafc;
  --bg-strong: #e7edf7;
  --panel: #ffffff;
  --panel-alt: #f3f6fb;
  --sidebar-bg: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #1581ff;
  --accent-soft: #e1efff;
  --accent-dark: #0a4fa6;
  --border: #d9e2ef;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  --radius: 18px;
  --radius-lg: 24px;
  --radius-xl: 30px;
  --btn-radius: 10px;
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-shadow: 0 20px 50px rgba(15, 23, 42, 0.16);

  --ease-apple: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-apple-soft: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-1: 140ms;
  --dur-2: 220ms;
  --dur-3: 360ms;
  --shadow-float: 0 18px 45px rgba(15, 23, 42, 0.18);

  /* Situações do Simples, derivadas das variantes de .tag */
  --ok-bg: rgba(16, 185, 129, 0.16);
  --ok-fg: #047857;
  --no-bg: rgba(220, 38, 38, 0.14);
  --no-fg: #b91c1c;
  --wait-bg: rgba(234, 179, 8, 0.22);
  --wait-fg: #a16207;
}

* {
  box-sizing: border-box;
  transition-duration: var(--dur-2);
  transition-timing-function: var(--ease-apple);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

html { color-scheme: light; }
body {
  margin: 0;
  font-family: "Archivo", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5 {
  font-family: "Sora", "Segoe UI", sans-serif;
  letter-spacing: -0.02em;
  color: var(--text);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.icone { display: inline-block; width: 20px; height: 20px; flex-shrink: 0; vertical-align: middle; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.2em; font-size: 11px; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.page-shell { min-height: 100vh; width: min(1240px, calc(100% - 48px)); margin: 0 auto; }

/* ---- Panels / topbar (vidro da casa) ---- */
.panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border);
  transition: transform var(--dur-2) var(--ease-apple), box-shadow var(--dur-2) var(--ease-apple);
}
.panel-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-float); }

.topbar {
  margin-top: 24px;
  padding: 18px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border);
}
.brand { display: flex; align-items: center; }
.brand img { display: block; width: 250px; height: auto; }
.topbar-meta { text-align: right; }
.topbar-meta p { margin: 0 0 4px; }
.topbar-meta strong { font-family: "Sora", sans-serif; font-size: 15px; font-weight: 600; }

/* ---- Hero ---- */
main { padding: 52px 0 40px; }
.hero { margin-bottom: 34px; }
.hero .eyebrow { margin: 0 0 14px; }
h1 { margin: 0; font-size: clamp(34px, 4.4vw, 52px); line-height: 1.05; font-weight: 700; }
h1 em { color: var(--accent); font-style: normal; font-weight: 600; }
.hero-copy { max-width: 560px; margin: 18px 0 0; color: var(--muted); font-size: 15px; line-height: 1.7; }

/* ---- Cartões de resumo ---- */
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.summary-card { min-height: 112px; display: flex; align-items: center; gap: 16px; padding: 21px; }
.summary-icon {
  width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center;
  border-radius: 14px; color: var(--accent-dark); background: var(--accent-soft);
}
.summary-icon .icone { width: 22px; height: 22px; }
.summary-card strong, .summary-card span { display: block; }
.summary-card strong { font-family: "Sora", sans-serif; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.summary-card span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.summary-card.positive .summary-icon { color: var(--ok-fg); background: var(--ok-bg); }
.summary-card.negative .summary-icon { color: var(--no-fg); background: var(--no-bg); }
.summary-card.pending .summary-icon { color: var(--wait-fg); background: var(--wait-bg); }

/* ---- Painel de empresas ---- */
.company-panel { overflow: hidden; box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 24px 26px; border-bottom: 1px solid var(--border); }
.panel-heading h2 { margin: 0; font-size: 22px; font-weight: 600; }
.panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.controls { display: flex; gap: 10px; }
.search-field {
  display: flex; align-items: center; gap: 8px; min-width: 290px; padding: 9px 14px;
  border-radius: 14px; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.85);
  color: var(--muted);
  transition: border-color var(--dur-1) var(--ease-apple), box-shadow var(--dur-1) var(--ease-apple), transform var(--dur-1) var(--ease-apple);
}
.search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(21, 129, 255, 0.18); transform: translateY(-1px); }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14px; }
.form-select {
  border-radius: 14px; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.85);
  padding: 9px 14px; font-size: 14px; color: var(--text);
  transition: border-color var(--dur-1) var(--ease-apple), box-shadow var(--dur-1) var(--ease-apple), transform var(--dur-1) var(--ease-apple);
}
.form-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(21, 129, 255, 0.18); transform: translateY(-1px); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 13px 26px; color: var(--muted); background: var(--panel-alt);
  font-size: 10px; text-align: left; text-transform: uppercase; letter-spacing: 0.11em; font-weight: 600;
}
td { padding: 16px 26px; border-top: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tbody tr { transition: background var(--dur-1) var(--ease-apple); }
tbody tr:hover { background: rgba(21, 129, 255, 0.05); }
.company-name { max-width: 420px; font-weight: 600; }
.company-name small { display: block; margin-top: 4px; color: var(--muted); font-weight: 400; }
.cnpj-text { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.source-label { color: var(--muted); font-size: 11px; }

.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  background: var(--accent-soft); color: var(--accent-dark); white-space: nowrap;
}
.tag-dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.tag.simples { background: var(--ok-bg); color: var(--ok-fg); }
.tag.not-simples, .tag.invalid { background: var(--no-bg); color: var(--no-fg); }
.tag.pending, .tag.unknown { background: var(--wait-bg); color: var(--wait-fg); }

.pagination { min-height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 26px; border-top: 1px solid var(--border); }
.pagination p { color: var(--muted); font-size: 12px; }
.pagination div { display: flex; align-items: center; gap: 10px; }
.pagination button {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--btn-radius); color: var(--text); background: var(--panel);
  transition: transform var(--dur-1) var(--ease-apple), box-shadow var(--dur-1) var(--ease-apple), border-color var(--dur-1) var(--ease-apple), color var(--dur-1) var(--ease-apple);
}
.pagination button:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--accent); color: var(--accent); box-shadow: 0 10px 20px rgba(15, 23, 42, 0.12); }
.pagination button:disabled { color: #b8c0be; background: var(--panel-alt); cursor: not-allowed; }
.pagination span { min-width: 78px; text-align: center; color: var(--muted); font-size: 11px; }
.empty-state { padding: 56px 20px; text-align: center; color: var(--muted); }

footer { padding: 22px 0 34px; display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }
footer span:first-child { color: var(--text); font-family: "Sora", sans-serif; font-size: 13px; font-weight: 600; }

/* ---- Loading: GIF da casa, nunca spinner de CSS ---- */
.loading-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: rgba(249, 250, 252, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeUp var(--dur-2) var(--ease-apple-soft) both;
}
.loading-overlay[hidden] { display: none; }
.loading-overlay__gif { width: 180px; max-width: 100%; height: auto; margin: 0 auto 12px; display: block; }
.loading-overlay__text {
  margin: 0; text-align: center; font-family: "Sora", "Segoe UI", sans-serif; font-size: 13px;
  font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}

/* ---- Toasts ---- */
.toast-stack {
  position: fixed; top: 20px; right: 20px; z-index: 110;
  display: flex; flex-direction: column; gap: 12px;
  pointer-events: none;
}
.toast {
  pointer-events: auto; width: 330px; max-width: calc(100vw - 32px); min-height: 80px;
  border-radius: 8px; box-sizing: border-box; padding: 10px 15px;
  background-color: #ffffff; box-shadow: rgba(149, 157, 165, 0.2) 0px 8px 24px;
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 15px;
  animation: toast-in var(--dur-3) var(--ease-apple-soft) both;
}
.toast.is-leaving { animation: toast-out var(--dur-2) var(--ease-apple) both; }
.toast__wave {
  position: absolute; transform: rotate(90deg); left: -31px; top: 32px; width: 80px;
  fill: var(--toast-wave); pointer-events: none;
}
.toast__icon-container {
  width: 35px; height: 35px; display: flex; justify-content: center; align-items: center;
  background-color: var(--toast-bubble); border-radius: 50%; margin-left: 8px; flex-shrink: 0; position: relative;
}
.toast__icon { width: 17px; height: 17px; color: var(--toast-color); }
.toast__text-container { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; flex-grow: 1; min-width: 0; }
.toast__title, .toast__sub { margin: 0; cursor: default; max-width: 100%; }
.toast__title { color: var(--toast-color); font-size: 17px; font-weight: 700; line-height: 1.2; }
.toast__sub { font-size: 14px; color: #555; line-height: 1.3; }
.toast__close { width: 18px; height: 18px; color: #555; cursor: pointer; flex-shrink: 0; background: none; border: none; padding: 0; }
.toast-sucesso { --toast-wave: rgba(4, 228, 0, 0.23); --toast-bubble: rgba(4, 228, 0, 0.28); --toast-color: #269b24; }
.toast-erro { --toast-wave: rgba(220, 38, 38, 0.20); --toast-bubble: rgba(220, 38, 38, 0.16); --toast-color: #b91c1c; }
.toast-alerta { --toast-wave: rgba(234, 179, 8, 0.28); --toast-bubble: rgba(234, 179, 8, 0.26); --toast-color: #a16207; }
.toast-info { --toast-wave: rgba(21, 129, 255, 0.20); --toast-bubble: rgba(21, 129, 255, 0.16); --toast-color: var(--accent-dark); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px) scale(0.98); } to { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes toast-out { from { opacity: 1; transform: translateX(0) scale(1); } to { opacity: 0; transform: translateX(24px) scale(0.98); } }

@media (max-width: 900px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .controls { width: 100%; }
  .search-field { min-width: 0; flex: 1; }
  th, td { padding-left: 18px; padding-right: 18px; }
}
@media (max-width: 620px) {
  .page-shell { width: calc(100% - 28px); }
  .topbar { flex-direction: column; align-items: flex-start; gap: 14px; padding: 18px; }
  .topbar-meta { text-align: left; }
  .brand img { width: 190px; }
  main { padding-top: 34px; }
  .summary-grid { grid-template-columns: 1fr; }
  .controls { flex-direction: column; }
  .search-field, .filter-field, .form-select { width: 100%; }
  .panel-heading { padding: 20px 18px; }
  th:nth-child(4), td:nth-child(4) { display: none; }
  .pagination { padding: 0 16px; }
  footer { gap: 12px; flex-direction: column; }
}
