/*
 * Salepipe: estilos do sistema. Plano completo em docs/plano-visual.md.
 * Mobile first: o CSS base é o do celular; 768px (tablet) e 1024px (barra lateral fixa) acrescentam.
 * Seções: fonte, tokens, base, layout, componentes, formulários, tabelas, telas.
 */

/* ---------- Fonte ---------- */

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/manrope-latin-wght.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/manrope-latin-ext-wght.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F,
    U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Tokens ---------- */

:root {
  --navy-900: #0f1f3d;
  --navy-800: #1b2d50;
  --navy-700: #2b3c5c;
  --navy-500: #5a6a86;
  --navy-200: #d6dfeb;
  --baby-300: #a8d1f2;
  --baby-100: #e8f3fc;
  --white: #ffffff;

  --danger: #b42318;
  --danger-bg: #fdecea;
  --warn: #8a5300;
  --warn-bg: #fff3dc;
  --ok: #1d6b45;
  --ok-bg: #e5f4ec;

  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --r-control: 6px;
  --r-panel: 10px;
  --control-h: 44px;
  --field-font: 16px;
  --sidebar-w: 248px;
  --topbar-h: 56px;

  --shadow-overlay: 0 16px 40px rgba(15, 31, 61, 0.22);
  --scrim: rgba(15, 31, 61, 0.48);
  --focus-ring: 0 0 0 1px var(--navy-900), 0 0 0 4px var(--baby-300);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

@media (min-width: 1024px) {
  :root {
    --control-h: 40px;
    --field-font: 15px;
  }
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 24px;
  color: var(--navy-700);
  background: var(--white);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3 {
  color: var(--navy-900);
  font-weight: 700;
}

h1 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 32px;
  letter-spacing: -0.01em;
}

h2 {
  margin: 32px 0 12px;
  font-size: 18px;
  line-height: 26px;
}

h3 {
  margin: 24px 0 8px;
  font-size: 15px;
  line-height: 22px;
}

p {
  margin: 0 0 12px;
  max-width: 68ch;
}

a {
  color: var(--navy-900);
  font-weight: 600;
  text-decoration-line: underline;
  text-decoration-color: var(--baby-300);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: var(--navy-900);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--r-control);
}

strong {
  font-weight: 700;
  color: var(--navy-900);
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.muted {
  color: var(--navy-500);
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -64px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--white);
  border-radius: var(--r-control);
}

.skip-link:focus {
  top: 8px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Layout: barra do celular, barra lateral, conteúdo ---------- */

.mobilebar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) max(16px, var(--safe-right)) 0 max(6px, var(--safe-left));
  background: var(--navy-900);
  color: var(--white);
}

.brand {
  color: var(--white);
  font-size: 19px;
  line-height: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.mobilebar-stock {
  margin-left: auto;
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.78);
}

.mobilebar-stock strong {
  color: var(--white);
}

.btn-icon.on-dark {
  color: var(--white);
  border-color: transparent;
  background: transparent;
}

.btn-icon.on-dark:hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn-icon.on-dark .icon {
  width: 22px;
  height: 22px;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  width: min(288px, 86vw);
  padding-top: var(--safe-top);
  padding-left: var(--safe-left);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--navy-900);
  color: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-overlay);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform 0.2s ease, visibility 0s linear 0.2s;
}

.nav-open .sidebar {
  transform: none;
  visibility: visible;
  transition: transform 0.2s ease;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.nav-open .scrim {
  opacity: 1;
  pointer-events: auto;
}

.nav-open {
  overflow: hidden;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 8px 8px 8px 24px;
}

.sidebar-head .brand {
  font-size: 22px;
  line-height: 28px;
}

.nav {
  flex: 1;
  padding: 8px 12px 24px;
}

.nav-group + .nav-group {
  margin-top: 20px;
}

.nav-group-title {
  margin: 0;
  padding: 0 12px 6px;
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.52);
}

.nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--control-h);
  padding: 0 12px;
  border-radius: var(--r-control);
  color: rgba(255, 255, 255, 0.74);
  font-weight: 600;
  text-decoration: none;
}

.nav a + a {
  margin-top: 2px;
}

.nav a:hover {
  color: var(--white);
  background: rgba(255, 255, 255, 0.06);
}

.nav a[aria-current="page"] {
  color: var(--white);
  background: rgba(168, 209, 242, 0.16);
}

.nav a[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--baby-300);
}

.nav a[aria-current="page"] .icon {
  color: var(--baby-300);
}

.nav a:focus-visible,
.sidebar-foot :focus-visible {
  box-shadow: 0 0 0 3px var(--baby-300);
}

.sidebar-foot {
  padding: 0 24px calc(16px + var(--safe-bottom));
}

.stock-panel {
  padding: 16px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.stock-panel p {
  margin: 0;
}

.stock-label {
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.52);
}

.stock-days {
  margin-top: 4px;
  color: var(--white);
  font-size: 14px;
  font-weight: 600;
}

.stock-number {
  font-size: 32px;
  line-height: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-right: 4px;
}

.stock-pool {
  font-size: 13px;
  line-height: 18px;
}

.stock-pool a {
  color: rgba(255, 255, 255, 0.86);
  text-decoration-color: rgba(168, 209, 242, 0.5);
}

.stock-problem {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  margin: 8px 0 6px;
  padding: 6px 10px;
  border-radius: var(--r-control);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
}

.stock-problem .icon {
  width: 16px;
  height: 16px;
  margin-top: 1px;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 16px;
}

.user-row p {
  margin: 0;
}

.user-name {
  color: var(--white);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
}

.user-role {
  font-size: 13px;
  line-height: 18px;
}

.user-row button {
  color: rgba(255, 255, 255, 0.8);
  background: transparent;
  border-color: rgba(255, 255, 255, 0.2);
}

.user-row button:hover {
  color: var(--white);
  background: rgba(255, 255, 255, 0.08);
}

.admin-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--control-h);
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.52);
  font-size: 13px;
  text-decoration: none;
}

.admin-link .icon {
  width: 16px;
  height: 16px;
}

.admin-link:hover {
  color: var(--white);
}

.content {
  min-width: 0;
}

.main {
  max-width: 1280px;
  padding: 20px max(16px, var(--safe-right)) calc(48px + var(--safe-bottom)) max(16px, var(--safe-left));
}

@media (min-width: 768px) {
  .main {
    padding: 28px 32px 56px;
  }
}

@media (min-width: 1024px) {
  .mobilebar,
  .scrim,
  .sidebar-close {
    display: none;
  }

  .sidebar {
    width: var(--sidebar-w);
    box-shadow: none;
    transform: none;
    visibility: visible;
    transition: none;
  }

  .nav-open {
    overflow: auto;
  }

  .content {
    margin-left: var(--sidebar-w);
  }

  .main {
    padding: 32px 40px 64px;
  }
}

/* ---------- Sino de notificações ---------- */

.sidebar-head-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.bell {
  position: relative;
}

.mobilebar .bell {
  margin-left: auto;
}

.mobilebar-stock + .bell {
  margin-left: 8px;
}

.bell-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--control-h);
  height: var(--control-h);
  border-radius: var(--r-control);
  color: var(--white);
  cursor: pointer;
  list-style: none;
}

/* O triângulo padrão do <details> não serve aqui: o ícone é o próprio sino. */
.bell-trigger::-webkit-details-marker {
  display: none;
}

.bell-trigger:hover {
  background: rgba(255, 255, 255, 0.12);
}

.bell-trigger:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.bell[open] .bell-trigger {
  background: rgba(255, 255, 255, 0.16);
}

/* A bolinha existe sempre, para o HTMX ter onde trocar; some quando não há nada. */
.bell-count {
  position: absolute;
  top: 3px;
  right: 1px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border: 2px solid var(--navy-900);
  border-radius: 999px;
  background: var(--danger);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
}

.bell-count[hidden] {
  display: none;
}

/* Fixo, e não absoluto: a barra lateral rola e cortaria um painel preso a ela. */
.bell-panel {
  position: fixed;
  z-index: 60;
  width: min(340px, calc(100vw - 24px));
  max-height: min(70vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--r-panel);
  background: var(--white);
  color: var(--navy-900);
  box-shadow: var(--shadow-overlay);
}

.sidebar .bell-panel {
  top: calc(var(--safe-top) + 64px);
  left: max(12px, var(--safe-left));
}

/* O texto vem de serviço externo e pode ter endereço comprido: quebra em vez de vazar. */
.bell-item-text {
  overflow-wrap: anywhere;
}

.mobilebar .bell-panel {
  top: calc(var(--safe-top) + var(--topbar-h) + 4px);
  right: max(12px, var(--safe-right));
}

.bell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--navy-200);
}

.bell-title {
  margin: 0;
  font-size: 15px;
  line-height: 20px;
  font-weight: 700;
}

.bell-readall {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--navy-500);
  font-size: 13px;
  line-height: 18px;
  text-decoration: underline;
  cursor: pointer;
}

.bell-readall:hover {
  color: var(--navy-900);
}

.bell-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.bell-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) var(--control-h);
  gap: 0 10px;
  align-items: start;
  padding: 12px 8px 12px 14px;
}

.bell-item + .bell-item {
  border-top: 1px solid var(--navy-200);
}

.bell-item > .icon {
  margin-top: 2px;
}

.bell-item-problem > .icon {
  color: var(--danger);
}

.bell-item-done > .icon {
  color: var(--ok);
}

.bell-item-title {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  font-weight: 700;
}

.bell-item-text {
  margin: 2px 0 0;
  font-size: 14px;
  line-height: 20px;
}

.bell-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 18px;
}

.bell-read {
  min-height: var(--control-h);
  border: 0;
  background: none;
  color: var(--navy-500);
  cursor: pointer;
}

.bell-read:hover {
  background: var(--baby-100);
  color: var(--navy-900);
}

.bell-empty {
  padding: 22px 16px;
  text-align: center;
}

.bell-empty p {
  margin: 0;
}

.bell-empty p + p {
  margin-top: 4px;
  font-size: 13px;
}

.bell-more {
  margin: 0;
  padding: 10px 14px;
  border-top: 1px solid var(--navy-200);
  font-size: 13px;
  color: var(--navy-500);
}

@media (min-width: 1024px) {
  /* Barra lateral fixa: o painel desce do sino, e não do canto da tela. */
  .sidebar .bell-panel {
    left: 196px;
  }
}

/* ---------- Componentes ---------- */

/* Botões. Padrão = secundário; .button e .btn-primary = principal. */
button,
.btn,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control-h);
  padding: 0 16px;
  border: 1px solid var(--navy-200);
  border-radius: var(--r-control);
  background: var(--white);
  color: var(--navy-900);
  font: inherit;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:hover,
.btn:hover {
  background: var(--baby-100);
  border-color: var(--baby-300);
}

.button,
.btn-primary,
.stacked-form button[type="submit"]:not(.link, .btn-quiet, .btn-danger) {
  background: var(--navy-900);
  border-color: var(--navy-900);
  color: var(--white);
}

.button:hover,
.btn-primary:hover,
.stacked-form button[type="submit"]:not(.link, .btn-quiet, .btn-danger):hover {
  background: var(--navy-800);
  border-color: var(--navy-800);
}

button:disabled,
button:disabled:hover,
.stacked-form button[type="submit"]:disabled,
.stacked-form button[type="submit"]:disabled:hover {
  background: var(--baby-100);
  border-color: var(--baby-100);
  color: var(--navy-500);
  cursor: not-allowed;
}

/* Discreto: sem borda, usado em "editar", "subir", "tornar principal". */
button.link,
.btn-quiet,
.btn-danger {
  min-height: 32px;
  padding: 0 8px;
  border-color: transparent;
  background: transparent;
  color: var(--navy-700);
}

button.link:hover,
.btn-quiet:hover,
.btn-danger:hover {
  border-color: transparent;
  background: var(--baby-100);
}

button.link.danger,
.btn-danger {
  color: var(--danger);
}

button.link.danger:hover,
.btn-danger:hover {
  background: var(--danger-bg);
}

.btn-danger-solid,
.btn-danger-solid:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--white);
}

.btn-icon {
  width: var(--control-h);
  padding: 0;
}

.btn-block {
  width: 100%;
}

/* Etiqueta de situação (pílula). */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--baby-100);
  color: var(--navy-900);
  font-size: 13px;
  line-height: 20px;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: 1px;
}

.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-outline {
  background: var(--white);
  box-shadow: inset 0 0 0 1px var(--navy-200);
}

/* Mensagens do sistema. */
.messages {
  display: grid;
  gap: 8px;
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}

.messages:not(:has(.message)) {
  display: none;
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: none;
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: var(--r-control);
  background: var(--baby-100);
  color: var(--navy-900);
  font-weight: 500;
}

.messages .message {
  margin: 0;
}

.message > .icon {
  margin-top: 3px;
}

.message > span {
  flex: 1;
}

.message.success {
  background: var(--ok-bg);
  color: var(--ok);
}

.message.error {
  background: var(--danger-bg);
  color: var(--danger);
}

.message.warning {
  background: var(--warn-bg);
  color: var(--warn);
}

.message-close {
  width: 36px;
  min-height: 36px;
  margin: -6px -6px -6px 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

.message-close:hover {
  background: rgba(15, 31, 61, 0.06);
  border-color: transparent;
}

/* Janela de confirmação. */
dialog.confirm {
  width: min(440px, calc(100vw - 32px));
  padding: 24px;
  border: 0;
  border-radius: var(--r-panel);
  color: var(--navy-700);
  box-shadow: var(--shadow-overlay);
}

dialog.confirm[open] {
  animation: dialog-in 0.16s ease-out;
}

dialog.confirm::backdrop {
  background: var(--scrim);
}

dialog.confirm h2 {
  margin: 0 0 8px;
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap-reverse;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

@media (max-width: 767px) {
  .confirm-actions button {
    flex: 1 1 auto;
  }
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Cabeçalho da página. */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
  margin-bottom: 24px;
}

.page-header h1,
.page-header h2 {
  margin: 0;
}

.card > .page-header:first-child {
  align-items: center;
}

/* Paginação. */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.page-status {
  padding: 0 8px;
  color: var(--navy-500);
  font-size: 14px;
}

/* Controle segmentado (atalhos de período). */
.subnav,
.segmented {
  display: flex;
  gap: 2px;
  width: max-content;
  max-width: 100%;
  margin: 0 0 16px;
  padding: 3px;
  overflow-x: auto;
  border: 1px solid var(--navy-200);
  border-radius: var(--r-control);
}

.subnav > a,
.subnav > strong,
.segmented > a,
.segmented > strong {
  display: inline-flex;
  align-items: center;
  min-height: calc(var(--control-h) - 8px);
  padding: 0 12px;
  border-radius: 4px;
  color: var(--navy-700);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.subnav > a:hover,
.segmented > a:hover {
  background: var(--baby-100);
}

.subnav > strong,
.segmented > strong {
  background: var(--navy-900);
  color: var(--white);
}

/* Recolhido (<details>). */
.disclosure > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--control-h);
  color: var(--navy-900);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.disclosure > summary::-webkit-details-marker {
  display: none;
}

/* Tela vazia. */
.empty {
  padding: 32px 0;
  color: var(--navy-500);
}

.empty .icon {
  width: 24px;
  height: 24px;
  margin-bottom: 8px;
}

.empty p {
  color: var(--navy-700);
}

/* ---------- Formulários ---------- */

input:not([type="checkbox"], [type="radio"], [type="file"], [type="hidden"]),
select,
textarea {
  min-height: var(--control-h);
  width: auto;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--navy-200);
  border-radius: var(--r-control);
  background-color: var(--white);
  color: var(--navy-900);
  font: inherit;
  font-size: var(--field-font);
  line-height: 22px;
}

select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235A6A86' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

select[multiple] {
  padding-right: 12px;
  background-image: none;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input[type="number"] {
  max-width: 200px;
}

input::placeholder,
textarea::placeholder {
  color: var(--navy-500);
  opacity: 1;
}

input:not([type="checkbox"], [type="radio"], [type="file"]):hover,
select:hover,
textarea:hover {
  border-color: var(--navy-500);
}

input:not([type="checkbox"], [type="radio"], [type="file"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--navy-900);
  box-shadow: 0 0 0 3px var(--baby-300);
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--navy-900);
  vertical-align: -3px;
  cursor: pointer;
}

input[type="file"] {
  max-width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--navy-700);
}

input[type="file"]::file-selector-button {
  min-height: var(--control-h);
  margin-right: 12px;
  padding: 0 16px;
  border: 1px solid var(--navy-200);
  border-radius: var(--r-control);
  background: var(--white);
  color: var(--navy-900);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* Campo do modelo único (templates/django/forms/field.html). */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 480px;
  margin-bottom: 16px;
}

.field input:not([type="checkbox"], [type="radio"], [type="file"]),
.field select,
.field textarea {
  width: 100%;
}

.field input[type="number"],
.field input[type="date"] {
  max-width: 200px;
}

.field-label,
.stacked-form label {
  color: var(--navy-900);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
}

.field fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field legend {
  margin-bottom: 4px;
  padding: 0;
}

.field fieldset label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--control-h);
  color: var(--navy-700);
  font-weight: 500;
}

.field-check {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  min-height: var(--control-h);
}

.field-check label {
  color: var(--navy-700);
  font-weight: 500;
}

.field-check .helptext,
.field-check .errorlist {
  flex-basis: 100%;
}

.helptext,
.stacked-form .helptext {
  display: block;
  color: var(--navy-500);
  font-size: 13px;
  line-height: 18px;
  font-weight: 500;
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--danger);
}

.errorlist {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--danger);
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
}

.errorlist.nonfield {
  max-width: 68ch;
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: var(--r-control);
  background: var(--danger-bg);
  font-size: 14px;
  line-height: 20px;
}

.stacked-form {
  max-width: 560px;
}

.stacked-form > div:not(.field) {
  margin-bottom: 16px;
}

.stacked-form > div:not(.field) > label {
  display: block;
  margin-bottom: 6px;
}

.stacked-form > div:not(.field) input:not([type="checkbox"], [type="radio"]),
.stacked-form > div:not(.field) select {
  width: 100%;
  max-width: 480px;
}

.stacked-form > div > div > label,
.stacked-form label:has(> input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--control-h);
  color: var(--navy-700);
  font-weight: 500;
}

/* Formulários em linha e filtros. */
.filters,
.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin: 12px 0 16px;
}

.filters label,
.inline-form label {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  color: var(--navy-900);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
}

.filters label:has(> input[type="checkbox"]),
.inline-form label:has(> input[type="checkbox"]) {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-height: var(--control-h);
  color: var(--navy-700);
  font-weight: 500;
}

.filters input[type="search"] {
  width: 320px;
}

@media (max-width: 767px) {
  .filters,
  .inline-form {
    align-items: stretch;
  }

  .filters > *,
  .inline-form > * {
    flex: 1 1 100%;
  }

  .filters input:not([type="checkbox"], [type="radio"]),
  .filters select,
  .inline-form input:not([type="checkbox"], [type="radio"]),
  .inline-form select,
  .inline-form textarea {
    width: 100%;
  }
}

/* ---------- Tabelas ---------- */

.table-wrap {
  margin: 0 0 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap table {
  min-width: 640px;
}

/* A rolagem horizontal recorta o que passa da borda. Com um menu "···" aberto, a
   tabela deixa de recortar, senão o menu fica escondido atrás de uma barra de rolagem. */
.table-wrap:has(details.menu[open]) {
  overflow: visible;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--navy-200);
  text-align: left;
  vertical-align: middle;
}

th {
  padding-top: 8px;
  padding-bottom: 8px;
  color: var(--navy-500);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: bottom;
}

td a {
  text-decoration-color: transparent;
}

td a:hover {
  text-decoration-color: var(--navy-900);
}

@media (hover: hover) {
  tbody tr:hover {
    background: var(--baby-100);
  }
}

/* Coluna de ações: o <td> continua célula de tabela (antes era flex e desalinhava a linha). */
td.actions {
  white-space: nowrap;
}

td .inline-form,
td form {
  margin: 0;
}

td .inline-form {
  align-items: center;
  gap: 8px;
}

td.actions form {
  display: inline-flex;
  vertical-align: middle;
}

.actions:not(td) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.actions form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ---------- Estruturas herdadas das telas (ajustadas bloco a bloco) ---------- */

.card {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--navy-200);
}

.card > h2:first-child {
  margin-top: 0;
}

.card.activity {
  padding: 16px;
  border: 1px solid var(--navy-200);
  border-radius: var(--r-panel);
}

@media (min-width: 768px) {
  .card.activity {
    padding: 20px 24px;
  }
}

.activity h3 {
  margin: 0 0 4px;
}

.activity-forms {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px 24px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--navy-200);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 40px;
}

@media (min-width: 1024px) {
  .grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }
}

.fields {
  display: grid;
  grid-template-columns: minmax(96px, max-content) minmax(0, 1fr);
  gap: 8px 16px;
  margin: 0 0 16px;
}

.fields dt {
  color: var(--navy-500);
  font-size: 14px;
  font-weight: 500;
}

.fields dd {
  margin: 0;
  color: var(--navy-900);
  overflow-wrap: anywhere;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 0;
}

.contact {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--navy-200);
}

.note {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--navy-200);
}

.samples div {
  color: var(--navy-500);
  font-size: 13px;
  line-height: 18px;
}

.points {
  margin: 4px 0 12px;
  padding-left: 20px;
}

/* ---------- Telas ---------- */

/* Login: metade navy com o nome, metade branca com o formulário. No celular, faixa navy no topo. */
.login-page {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

.login-brand {
  display: flex;
  align-items: flex-end;
  min-height: calc(120px + var(--safe-top));
  padding: calc(24px + var(--safe-top)) 24px 24px;
  background: var(--navy-900);
}

.wordmark {
  color: var(--white);
  font-size: 36px;
  line-height: 40px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.login-panel {
  display: flex;
  justify-content: center;
  padding: 40px 24px calc(40px + var(--safe-bottom));
}

.login-form {
  width: 100%;
  max-width: 360px;
}

.login-form h1 {
  margin-bottom: 24px;
}

.login-form .field {
  max-width: none;
}

.login-form button {
  margin-top: 8px;
}

@media (min-width: 1024px) {
  .login-page {
    grid-template-rows: none;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  }

  .login-brand {
    align-items: flex-end;
    padding: 64px;
  }

  .wordmark {
    font-size: 64px;
    line-height: 64px;
  }

  .login-panel {
    align-items: center;
    padding: 64px;
  }
}

/* ---------- Minha Rotina ---------- */

.page-subtitle {
  margin: 0;
  color: var(--navy-500);
}

.routine-section {
  margin-top: 32px;
}

.routine-section h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}

.section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--baby-100);
  color: var(--navy-900);
  font-size: 13px;
  font-weight: 700;
}

.routine-overdue .section-count {
  background: var(--danger-bg);
  color: var(--danger);
}

.routine-list {
  display: grid;
  gap: 12px;
}

/* Estados da rotina, só com CSS: seção sem card some, e as duas vazias viram "rotina concluída". */
.routine-list:has(.activity) + .routine-empty {
  display: none;
}

.routine-overdue:not(:has(.activity)) {
  display: none;
}

.routine-done {
  display: none;
}

.routine:not(:has(.activity)) .routine-done {
  display: block;
}

.routine:not(:has(.activity)) .routine-today {
  display: none;
}

.activity {
  display: grid;
  gap: 12px;
  margin: 0;
}

.activity-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
}

.channel-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--baby-100);
  color: var(--navy-900);
}

.activity-title {
  flex: 1 1 220px;
  min-width: 0;
}

.activity h3 {
  margin: 0;
}

.activity h3 a {
  text-decoration-color: transparent;
}

.activity h3 a:hover {
  text-decoration-color: var(--navy-900);
}

.activity-step {
  margin: 2px 0 0;
  color: var(--navy-500);
  font-size: 13px;
  line-height: 18px;
}

.activity-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.activity-contact,
.activity-warn {
  margin: 0;
}

.activity-warn {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.contact-btn {
  justify-content: flex-start;
  max-width: 100%;
  overflow: hidden;
}

.contact-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 767px) {
  .contact-btn {
    flex: 1 1 calc(50% - 8px);
  }
}

.result-form {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--navy-200);
}

.result-choice {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.result-choice legend {
  margin-bottom: 8px;
  padding: 0;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: var(--control-h);
  padding: 0 14px;
  border: 1px solid var(--navy-200);
  border-radius: 999px;
  color: var(--navy-700);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.pill input[type="radio"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.pill:hover {
  background: var(--baby-100);
}

.pill:has(input:checked) {
  background: var(--navy-900);
  border-color: var(--navy-900);
  color: var(--white);
}

.pill:has(input:focus-visible) {
  box-shadow: var(--focus-ring);
}

/* A dica do comportamento aparece conforme a pílula escolhida, sem JavaScript. */
.behavior-hint {
  display: none;
  margin: 8px 0 0;
  color: var(--navy-500);
  font-size: 13px;
  line-height: 18px;
}

.result-choice:has(input[data-behavior="advance"]:checked) .hint-advance,
.result-choice:has(input[data-behavior="repeat"]:checked) .hint-repeat,
.result-choice:has(input[data-behavior="close"]:checked) .hint-close {
  display: block;
}

.result-form .field {
  max-width: none;
  margin: 0;
}

.activity-done {
  justify-self: start;
}

@media (max-width: 767px) {
  .activity-done {
    width: 100%;
  }
}

.postpone-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 4px 0 8px;
}

.postpone-hint {
  flex-basis: 100%;
}

.activity.htmx-swapping {
  opacity: 0;
  transform: scale(0.99);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* O atributo hidden precisa vencer o display dos componentes. */
[hidden] {
  display: none !important;
}

/* "terça-feira, 15 de setembro": mês em minúscula, só a primeira letra da frase em maiúscula. */
.page-subtitle::first-letter {
  text-transform: uppercase;
}

/* ---------- Listas com filtro, marcação e ação em lote ---------- */

.search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.search-field .icon {
  position: absolute;
  left: 12px;
  color: var(--navy-500);
  pointer-events: none;
}

.search-field input[type="search"] {
  width: 320px;
  max-width: 100%;
  padding-left: 38px;
}

/* A barra de lote só aparece quando há algo marcado. Sem JavaScript, o CSS resolve. */
.bulk-bar {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--r-control);
  background: var(--baby-100);
}

.list-with-bulk:has(input[name="ids"]:checked) .bulk-bar {
  display: flex;
}

.bulk-bar [data-selection-count] {
  margin-right: 4px;
}

.cell-name .sub {
  display: block;
  color: var(--navy-500);
  font-size: 13px;
  line-height: 18px;
}

.cell-name a {
  text-decoration-color: transparent;
}

.cell-name a:hover {
  text-decoration-color: var(--navy-900);
}

.cell-check {
  width: 36px;
}

.cell-num {
  text-align: right;
}

/* No celular a tabela vira lista: nome e situação na primeira linha, o resto abaixo. */
@media (max-width: 767px) {
  .table-wrap:has(.stack-table) {
    overflow-x: visible;
  }

  .stack-table,
  .stack-table tbody,
  .stack-table tr,
  .stack-table td {
    display: block;
  }

  .table-wrap .stack-table {
    min-width: 0;
  }

  .stack-table thead {
    display: none;
  }

  .stack-table tr {
    position: relative;
    padding: 12px 0 12px 32px;
    border-bottom: 1px solid var(--navy-200);
  }

  .stack-table td {
    padding: 2px 0;
    border: 0;
    color: var(--navy-500);
    font-size: 13px;
    line-height: 20px;
  }

  .stack-table td:empty {
    display: none;
  }

  .stack-table td[data-label]::before {
    content: attr(data-label) " ";
    color: var(--navy-500);
  }

  .stack-table td.cell-name {
    color: var(--navy-900);
    font-size: 15px;
    line-height: 22px;
  }

  .stack-table td.cell-check {
    position: absolute;
    left: 0;
    top: 12px;
    padding: 0;
  }

  .stack-table td.cell-status {
    padding: 4px 0 2px;
  }

  .stack-table td.cell-num {
    text-align: left;
  }
}

.empty .actions {
  margin-top: 12px;
}

/* ---------- Card da empresa ---------- */

.back-link {
  margin: 0 0 8px;
}

.back-link a {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--navy-500);
  font-size: 14px;
  text-decoration-color: transparent;
}

.back-link a:hover {
  color: var(--navy-900);
  text-decoration-color: var(--navy-900);
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  max-width: none;
  margin: 8px 0 0;
  color: var(--navy-500);
  font-size: 14px;
}

.detail-grid {
  display: flex;
  flex-direction: column;
}

.detail-section {
  padding-top: 24px;
  margin-top: 24px;
  border-top: 1px solid var(--navy-200);
}

.detail-section > h2:first-child,
.detail-section > .page-header:first-child {
  margin-top: 0;
}

.detail-section > .page-header {
  align-items: center;
  margin-bottom: 12px;
}

/* No celular a ordem segue o uso: primeiro os contatos, depois a prospecção. */
@media (max-width: 1023px) {
  .detail-main,
  .detail-side {
    display: contents;
  }

  .sec-phones {
    order: 1;
  }

  .sec-emails {
    order: 2;
  }

  .sec-contacts {
    order: 3;
  }

  .sec-prospect {
    order: 4;
  }

  .sec-notes {
    order: 5;
  }

  .sec-registry {
    order: 6;
  }

  .sec-address {
    order: 7;
  }

  .sec-social {
    order: 8;
  }
}

@media (min-width: 1024px) {
  .detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 0 40px;
    align-items: start;
  }
}

/* Telefones, emails e redes: uma linha por item, com menu de ações. */
.point-list {
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

.point {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--navy-500);
}

.point + .point {
  border-top: 1px solid var(--navy-200);
}

.point .icon {
  flex: none;
  color: var(--navy-500);
}

.point-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--navy-900);
  text-decoration-color: transparent;
}

.point-value:hover {
  text-decoration-color: var(--navy-900);
}

.point-extra {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: var(--r-control);
  color: var(--navy-700);
}

.point-extra:hover {
  background: var(--baby-100);
}

.point-primary {
  display: inline-flex;
  color: var(--warn);
}

.point-primary .icon {
  color: var(--warn);
  fill: var(--warn-bg);
}

/* Menu "..." em <details>: abre no toque, sem depender do mouse. */
.menu {
  position: relative;
  flex: none;
}

.menu > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-height: 36px;
  border-radius: var(--r-control);
  color: var(--navy-700);
  list-style: none;
  cursor: pointer;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu > summary:hover,
.menu[open] > summary {
  background: var(--baby-100);
}

.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  display: grid;
  gap: 2px;
  min-width: 232px;
  padding: 8px;
  border: 1px solid var(--navy-200);
  border-radius: var(--r-panel);
  background: var(--white);
  box-shadow: var(--shadow-overlay);
}

.menu-title {
  margin: 0 0 4px;
  padding: 0 8px;
  color: var(--navy-900);
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* O menu costuma estar na coluna de ações, que não quebra linha: aqui dentro o texto volta a quebrar. */
.menu-panel {
  white-space: normal;
}

.menu-panel button,
.menu-panel .btn {
  justify-content: flex-start;
  width: 100%;
}

.menu-form {
  display: grid;
  gap: 6px;
  padding: 6px 0;
  margin: 4px 0;
  border-top: 1px solid var(--navy-200);
  border-bottom: 1px solid var(--navy-200);
}

.menu-form select {
  width: 100%;
}

/* Formulário de adicionar, recolhido até alguém precisar. */
.disclosure > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--control-h);
  color: var(--navy-900);
  font-size: 14px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.disclosure > summary::-webkit-details-marker {
  display: none;
}

.disclosure > summary:hover {
  color: var(--navy-700);
}

.add-form {
  max-width: 100%;
  padding: 12px;
  margin-bottom: 8px;
  border-radius: var(--r-panel);
  background: var(--baby-100);
}

.add-form .field {
  max-width: 100%;
  margin-bottom: 12px;
}

/* Histórico de atividades da empresa: lista compacta, não tabela larga. */
.activity-log,
.plain-list {
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

.plain-list li {
  padding: 4px 0;
  color: var(--navy-700);
}

.activity-log li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
}

.activity-log li + li {
  border-top: 1px solid var(--navy-200);
}

.log-date {
  flex: none;
  width: 56px;
  color: var(--navy-500);
  font-size: 13px;
  line-height: 22px;
}

.log-icon {
  display: flex;
  flex: none;
  padding-top: 2px;
  color: var(--navy-500);
}

.log-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.log-title {
  color: var(--navy-900);
  font-weight: 600;
}

.log-meta,
.log-notes {
  color: var(--navy-500);
  font-size: 13px;
  line-height: 18px;
}

.log-notes {
  color: var(--navy-700);
}

.contact {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--navy-200);
}

.contact:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.contact-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.contact-head h3 {
  margin: 0;
}

.note-form {
  display: grid;
  gap: 8px;
  justify-items: start;
  max-width: 560px;
  margin-bottom: 16px;
}

.note-form textarea {
  width: 100%;
}

.note {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--navy-200);
}

.note p {
  margin: 0;
}

.note-meta {
  margin-top: 2px;
  color: var(--navy-500);
  font-size: 13px;
}

/* ---------- Formulários de cadastro ---------- */

.record-form {
  max-width: 720px;
}

.record-form.narrow {
  max-width: 560px;
}

.context-line {
  margin-bottom: 24px;
  color: var(--navy-500);
}

.form-group {
  min-width: 0;
  margin: 0 0 8px;
  padding: 0 0 8px;
  border: 0;
  border-bottom: 1px solid var(--navy-200);
}

.form-group:last-of-type {
  border-bottom: 0;
}

.form-group > legend {
  padding: 0;
  margin-bottom: 12px;
  color: var(--navy-900);
  font-size: 18px;
  line-height: 26px;
  font-weight: 700;
}

.field-xs {
  max-width: 110px;
}

.field-sm {
  max-width: 170px;
}

.field-md {
  max-width: 260px;
}

/* Campo de dias: a caixa é estreita, mas o rótulo e a explicação usam a linha toda. */
.field-days {
  max-width: 420px;
}

.field.field-days input {
  max-width: 110px;
}

.address-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 16px;
}

.address-grid > span {
  display: block;
  min-width: 0;
}

.address-grid .field {
  max-width: 100%;
}

@media (min-width: 768px) {
  .address-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .col-street {
    grid-column: span 4;
  }

  .col-number {
    grid-column: span 2;
  }

  .col-complement {
    grid-column: span 3;
  }

  .col-district {
    grid-column: span 3;
  }

  .col-city {
    grid-column: span 3;
  }

  .col-state {
    grid-column: span 1;
  }

  .col-postal {
    grid-column: span 2;
  }
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
}

/* No celular o salvar fica sempre ao alcance do polegar. */
@media (max-width: 767px) {
  .form-actions {
    position: sticky;
    bottom: 0;
    margin-top: 16px;
    padding: 12px 0 calc(12px + var(--safe-bottom));
    border-top: 1px solid var(--navy-200);
    background: var(--white);
  }

  .form-actions .btn-primary {
    flex: 1 1 100%;
  }

  .form-actions .btn {
    flex: 1 1 100%;
  }
}

.record-form {
  margin-top: 24px;
}

/* Ajustes de celular vistos na verificação: o telefone não pode ser cortado, e a
   situação da empresa vem logo depois do nome na lista. */
@media (max-width: 767px) {
  .contact-btn {
    flex: 1 1 100%;
  }

  .contact-btn span:first-of-type {
    flex: none;
  }

  .stack-table tr {
    display: flex;
    flex-direction: column;
  }

  .stack-table td.cell-name {
    order: 1;
  }

  .stack-table td.cell-status {
    order: 2;
  }

  .stack-table td.cell-cnpj {
    order: 3;
  }

  .stack-table td.cell-phone {
    order: 4;
  }

  .stack-table td.cell-num {
    order: 5;
  }
}

/* ---------- Pool e Métricas ---------- */

.number-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 32px;
  margin: 24px 0 8px;
}

@media (min-width: 768px) {
  .number-strip {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
}

.number-item {
  display: grid;
  gap: 2px;
}

.number {
  color: var(--navy-900);
  font-size: 32px;
  line-height: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.number-label {
  color: var(--navy-500);
  font-size: 13px;
  line-height: 18px;
}

.pool-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 8px;
}

@media (min-width: 1024px) {
  .pool-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 0 40px;
    align-items: start;
  }
}

@media (max-width: 1023px) {
  /* No celular quem decide vem primeiro: distribuir antes da lista. */
  .pool-side {
    order: -1;
  }
}

.bulk-assign {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--navy-700);
  font-size: 14px;
  font-weight: 600;
}

.seller-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.seller-list li {
  display: grid;
  gap: 2px;
  padding: 8px 0;
}

.seller-list li + li {
  border-top: 1px solid var(--navy-200);
}

.seller-name {
  color: var(--navy-900);
  font-weight: 600;
}

.seller-load {
  color: var(--navy-500);
  font-size: 13px;
  line-height: 18px;
}

/* Funil: barras proporcionais, porque as etapas se comparam entre si. */
.funnel-block {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--navy-200);
}

.funnel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
}

.funnel-head h2 {
  margin: 0;
}

.headline-rate {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
}

.rate-number {
  color: var(--navy-900);
  font-size: 32px;
  line-height: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.rate-label {
  color: var(--navy-500);
  font-size: 13px;
}

.funnel {
  margin: 16px 0 8px;
  padding: 0;
  list-style: none;
}

.funnel li {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px 16px;
  padding: 6px 0;
}

@media (min-width: 768px) {
  .funnel li {
    grid-template-columns: 200px minmax(0, 1fr) 180px;
    align-items: center;
    gap: 16px;
  }
}

.funnel-label {
  color: var(--navy-700);
  font-size: 14px;
}

.funnel-track {
  display: block;
  height: 12px;
  border-radius: 999px;
  background: var(--baby-100);
}

.funnel-fill {
  display: block;
  width: var(--w, 0%);
  height: 100%;
  border-radius: 999px;
  background: var(--baby-300);
}

.funnel-value {
  color: var(--navy-900);
  font-size: 15px;
  font-weight: 700;
}

.funnel-note {
  color: var(--navy-500);
  font-size: 13px;
  font-weight: 500;
}

/* O recuo da lista no celular só existe quando a linha tem checkbox. */
@media (max-width: 767px) {
  .stack-table tr {
    padding-left: 0;
  }

  .stack-table tr:has(.cell-check) {
    padding-left: 32px;
  }
}

/* ---------- Cadências, resultados, importação e configurações ---------- */

.new-block {
  margin: 16px 0;
}

.behavior-legend {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  max-width: 68ch;
}

.behavior-legend li {
  padding: 4px 0;
  color: var(--navy-700);
  font-size: 14px;
}

.badge-dark {
  background: var(--navy-900);
  color: var(--white);
}

.channel-icons {
  display: inline-flex;
  gap: 8px;
  color: var(--navy-500);
}

.row-inactive .cell-name a,
.row-inactive td {
  color: var(--navy-500);
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-bottom: 16px;
}

.checkbox-row .field {
  margin: 0;
}

/* "Repetir em quantos dias" só aparece quando o comportamento é Repete. */
.only-repeat {
  display: none;
}

.behavior-dependent:has(option[value="repeat"]:checked) .only-repeat {
  display: block;
}

/* Passos da cadência: numerados, porque é de fato uma sequência. */
.step-list {
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  counter-reset: none;
}

.step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
}

.step + .step {
  border-top: 1px solid var(--navy-200);
}

.step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--navy-900);
  color: var(--white);
  font-size: 13px;
  font-weight: 700;
}

.step-icon {
  display: flex;
  flex: none;
  padding-top: 3px;
  color: var(--navy-500);
}

.step-body {
  display: grid;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.step-title {
  color: var(--navy-900);
  font-weight: 600;
}

.step-when {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--navy-500);
  font-size: 13px;
  line-height: 18px;
}

.step-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.step-actions .btn-icon {
  border-color: transparent;
}

.btn-icon.is-disabled {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--control-h);
  min-height: var(--control-h);
  color: var(--navy-200);
  cursor: not-allowed;
}

/* Etapas da importação: sequência numerada, o único lugar que precisa disso. */
.stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}

.stepper li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--navy-500);
  font-size: 14px;
}

.stepper .step-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--navy-200);
  font-size: 13px;
  font-weight: 700;
}

.stepper .is-current {
  color: var(--navy-900);
  font-weight: 600;
}

.stepper .is-current .step-mark {
  background: var(--navy-900);
  border-color: var(--navy-900);
  color: var(--white);
}

.stepper .is-done .step-mark {
  background: var(--baby-100);
  border-color: var(--baby-100);
  color: var(--navy-900);
}

.dropzone {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 32px 16px;
  margin-bottom: 8px;
  border: 2px dashed var(--navy-200);
  border-radius: var(--r-panel);
  text-align: center;
  cursor: pointer;
}

.dropzone:hover {
  border-color: var(--baby-300);
  background: var(--baby-100);
}

.dropzone .icon {
  width: 24px;
  height: 24px;
  color: var(--navy-500);
}

.dropzone-title {
  color: var(--navy-900);
  font-weight: 600;
}

.dropzone input[type="file"] {
  margin-top: 8px;
}

.number-item.is-danger .number {
  color: var(--danger);
}

.number-item.is-warn .number {
  color: var(--warn);
}

.preview-lines {
  max-height: 420px;
  overflow: auto;
}

.job-count {
  font-size: 13px;
}

.new-line {
  align-items: flex-end;
  margin-top: 16px;
}

.capacity-row {
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  min-height: 56px;
}

.capacity-person {
  display: grid;
  gap: 0;
  min-width: 0;
}

.capacity-person .muted {
  font-size: 13px;
  line-height: 18px;
}

.capacity-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.capacity-field input {
  width: 96px;
  text-align: right;
}

/* Ações do passo: mesma posição em todas as linhas no computador, e abaixo do título no celular. */
.step-actions {
  width: 176px;
  justify-content: flex-end;
}

@media (max-width: 767px) {
  .step {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
    gap: 4px 10px;
  }

  .step-body {
    grid-column: 3;
  }

  .step-actions {
    grid-column: 1 / 4;
    width: auto;
    justify-content: flex-start;
  }
}

.dropzone input[type="file"] {
  display: block;
  width: 100%;
}

/* Ordem das células na lista do celular: nome e situação primeiro, número e menu por último.
   O padrão vale para qualquer tabela empilhada, não só as que têm classe em toda célula. */
@media (max-width: 767px) {
  .stack-table td {
    order: 3;
  }

  .stack-table td.cell-name {
    order: 1;
  }

  .stack-table td.cell-status {
    order: 2;
  }

  .stack-table td.cell-num {
    order: 4;
  }

  .stack-table td.cell-menu {
    order: 5;
    padding-top: 4px;
  }
}

/* ---------- Ajuda ---------- */

.topic-list {
  display: grid;
  gap: 8px;
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}

@media (min-width: 768px) {
  .topic-list {
    grid-template-columns: 1fr 1fr;
  }
}

.topic {
  display: flex;
  gap: 12px;
  height: 100%;
  padding: 14px 16px;
  border: 1px solid var(--navy-200);
  border-radius: var(--r-panel);
  color: var(--navy-500);
  font-weight: 400;
  text-decoration: none;
}

.topic:hover {
  border-color: var(--navy-900);
  background: var(--baby-100);
}

.topic .icon {
  flex: none;
  margin-top: 3px;
  color: var(--navy-500);
}

.topic-title {
  display: block;
  color: var(--navy-900);
  font-weight: 700;
}

.guide ol,
.guide ul {
  max-width: 68ch;
  margin: 0 0 16px;
  padding-left: 20px;
}

.guide li {
  margin-bottom: 6px;
}

.guide li::marker {
  color: var(--navy-500);
  font-weight: 700;
}

/* O porquê de uma regra que surpreende, separado do passo a passo. */
.guide-why {
  max-width: 68ch;
  margin: 0 0 16px;
  padding: 12px 16px;
  border-left: 3px solid var(--baby-300);
  border-radius: 0 var(--r-panel) var(--r-panel) 0;
  background: var(--baby-100);
}

.guide-why p:last-child {
  margin-bottom: 0;
}

.guide .fields {
  max-width: 68ch;
}

.guide-next {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--navy-200);
}

.guide-next a {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

/* ---------- Regiões ---------- */

/* Três caminhos para acrescentar cidade, lado a lado no computador e empilhados
   no celular. Largura igual porque nenhum é o principal: a escolha é do usuário. */
.rule-heading {
  margin: 28px 0 12px;
  font-size: 18px;
  line-height: 24px;
}

.rule-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 8px;
}

@media (min-width: 900px) {
  .rule-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.rule-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
}

.rule-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 16px;
  line-height: 22px;
}

.rule-card .field {
  margin: 0;
}

/* O botão fica colado no fim do card para que os três alinhem mesmo com
   quantidade diferente de campos. */
.rule-card > button {
  margin-top: auto;
}

.rule-hint,
.rule-note {
  margin: -4px 0 0;
  color: var(--navy-500);
  font-size: 13px;
  line-height: 18px;
}

.rule-note {
  margin: 0;
  padding-top: 4px;
  border-top: 1px solid var(--navy-200);
}

/* Resultado da busca por nome: some quando não há o que mostrar, e não reserva
   espaço vazio embaixo do campo. */
.search-results {
  display: grid;
  gap: 2px;
  margin: 0;
  max-height: 280px;
  overflow-y: auto;
}

.search-results li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--navy-200);
}

.search-results li:last-child {
  border-bottom: 0;
}

.search-name {
  min-width: 0;
  font-size: 14px;
  line-height: 20px;
}

.search-name .muted {
  display: block;
  font-size: 13px;
}

.search-empty {
  margin: 0;
  color: var(--navy-500);
  font-size: 14px;
}

.rule-card .search-field input[type="search"] {
  width: 100%;
}

/* Histórico da lista: uma linha por regra aplicada, sem virar tabela. */
.rule-log {
  display: grid;
  gap: 10px;
  margin: 8px 0 0;
}

.rule-log li {
  display: grid;
  gap: 2px;
}

.rule-log-label {
  font-weight: 600;
}

.rule-log .muted {
  font-size: 13px;
  line-height: 18px;
}

/* No celular a coluna "Entrou por" sai para a tabela caber inteira: sem ela, o
   botão de tirar a cidade fica na tela, em vez de atrás de rolagem lateral. */
@media (max-width: 767px) {
  .table-wrap .region-table {
    min-width: 0;
  }

  .region-table .cell-origin {
    display: none;
  }

  .region-table th,
  .region-table td {
    padding: 12px 8px 12px 0;
  }
}

.region-log {
  margin-top: 24px;
  padding-top: 8px;
  border-top: 1px solid var(--navy-200);
}

/* ---------- Integrações ---------- */

/* Um serviço por linha: ícone, nome e para que serve, situação embaixo, botão à direita. */
.service-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--navy-200);
}

.service {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 4px 16px;
  padding: 20px 0;
  border-bottom: 1px solid var(--navy-200);
}

.service-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-panel);
  background: var(--baby-100);
  color: var(--navy-900);
}

.service-name {
  margin: 0;
  font-size: 15px;
  line-height: 22px;
}

.service-name a {
  color: inherit;
  text-decoration-color: transparent;
}

.service-name a:hover {
  text-decoration-color: currentColor;
}

.service-purpose {
  margin: 2px 0 0;
  color: var(--navy-700);
}

.service-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  margin: 10px 0 0;
  color: var(--navy-500);
  font-size: 13px;
  line-height: 18px;
}

.service-action {
  grid-column: 2;
  justify-self: start;
  margin-top: 8px;
}

@media (min-width: 768px) {
  .service {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: start;
  }

  .service-action {
    grid-column: 3;
    grid-row: 1;
    margin-top: 0;
  }
}

.usage-alert {
  color: var(--warn);
  font-weight: 700;
}

.calls-summary {
  min-width: 220px;
  color: var(--navy-700);
}

/* No celular a tabela vira lista sem a coluna da caixa de marcar. */
@media (max-width: 767px) {
  .stack-table.calls-table tr,
  .stack-table.usage-table tr {
    padding-left: 0;
  }

  .stack-table.usage-table td.cell-num {
    text-align: left;
  }

  .stack-table.calls-table td.calls-summary {
    min-width: 0;
    color: var(--navy-700);
  }
}

/* Tela do serviço: no celular, configurar, testar e depois o histórico. */
@media (max-width: 1023px) {
  .provider-grid .sec-config {
    order: 1;
  }

  .provider-grid .sec-test {
    order: 2;
  }

  .provider-grid .sec-calls {
    order: 3;
  }
}

.provider-form {
  max-width: 520px;
}

.sec-test .muted {
  margin: 0 0 12px;
}

/* Detalhe da chamada. */
.call-summary {
  margin: 16px 0 8px;
  color: var(--navy-900);
  font-size: 18px;
  line-height: 26px;
  font-weight: 600;
}

.call-facts {
  max-width: 560px;
}

.call-fact-label {
  flex: none;
  width: 140px;
  color: var(--navy-500);
  font-size: 14px;
}

.raw-response {
  max-height: 560px;
  margin: 12px 0 0;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--navy-200);
  border-radius: var(--r-panel);
  background: var(--baby-100);
  color: var(--navy-900);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 20px;
  white-space: pre;
  tab-size: 2;
}

.raw-response:focus-visible {
  box-shadow: var(--focus-ring);
  outline: none;
}

/* Ajustes da verificação visual das Integrações (rodada 1). */
.integrations-section {
  margin-top: 32px;
}

.integrations-section > .page-header {
  align-items: center;
  margin-bottom: 12px;
}

.integrations-section > .page-header h2,
.integrations-section > h2 {
  margin-top: 0;
}

.provider-form input[type="number"] {
  width: 160px;
}

.call-facts .point-value {
  padding: 8px 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 767px) {
  .stack-table.usage-table tr {
    flex-direction: row;
    flex-wrap: wrap;
    column-gap: 16px;
  }

  .stack-table.usage-table td.cell-name {
    flex: 1 1 100%;
  }
}

/* Rodada 2: data e CNPJ não quebram no meio. */
.calls-when {
  white-space: nowrap;
}

.calls-request {
  min-width: 200px;
}

/* Formulário curto de teste: botão logo abaixo do campo, sem a barra fixa do celular. */
.test-actions {
  margin-top: 12px;
}

@media (max-width: 767px) {
  .stack-table.calls-table td.calls-request {
    min-width: 0;
  }
}

/* ---------- Gerar listas e ICPs ---------- */

.menu-note {
  margin: 4px 0 0;
  padding: 8px;
  border-top: 1px solid var(--navy-200);
  color: var(--navy-500);
  font-size: 13px;
  line-height: 18px;
}

.icp-form,
.job-form {
  max-width: 640px;
}

.form-section-title {
  margin: 16px 0 0;
  padding-top: 24px;
  border-top: 1px solid var(--navy-200);
  font-size: 18px;
  line-height: 24px;
}

.icp-form > .muted,
.job-form .muted {
  max-width: 640px;
  margin: 0 0 8px;
  font-size: 14px;
}

.keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: none;
  margin: 0 0 8px;
}

/* A prévia é a conta que decide o gasto: ela é o destaque da tela, em tipo grande. */
.job-preview {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--navy-200);
}

.job-preview h2 {
  margin-top: 0;
}

.preview-math {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  max-width: none;
  margin: 8px 0 8px;
  color: var(--navy-700);
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.preview-op {
  color: var(--navy-500);
  font-weight: 400;
}

.preview-total {
  color: var(--navy-900);
  font-size: 32px;
  line-height: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.preview-form {
  max-width: 640px;
  margin-top: 16px;
}

.preview-form .field-check {
  margin-bottom: 16px;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preview-actions form {
  margin: 0;
}

.cell-order {
  width: 80px;
}

.job-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  margin: 4px 0 0;
}

.job-facts div {
  display: flex;
  gap: 6px;
}

.job-facts dt {
  color: var(--navy-500);
}

.job-facts dd {
  margin: 0;
  color: var(--navy-900);
  font-weight: 600;
}

/* Seis abas não cabem no celular: quebram em linhas em vez de rolar escondidas. */
.job-lists .segmented {
  flex-wrap: wrap;
}

@media (max-width: 767px) {
  .job-lists .segmented {
    width: auto;
  }

  /* Na prévia do celular a ordem já é a da lista: o número só alongaria cada linha. */
  .stack-table td.cell-order {
    display: none;
  }
}

/* Andamento: situação e ações numa linha, depois a barra e o funil. */
.job-live {
  margin-top: 16px;
}

.job-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
}

.job-state .status-line {
  margin: 0;
}

.job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.job-live > .message {
  margin: 16px 0 0;
}

.job-progress {
  margin-top: 24px;
}

.job-progress-text {
  margin: 0 0 8px;
  color: var(--navy-700);
  font-variant-numeric: tabular-nums;
}

.job-progress-text strong {
  color: var(--navy-900);
  font-size: 24px;
  line-height: 32px;
}

.job-progress .funnel-track {
  max-width: 720px;
}

.job-progress-parts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  max-width: none;
  margin: 8px 0 0;
  color: var(--navy-500);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.job-progress-parts a {
  color: var(--navy-700);
}

.job-progress-parts .job-part-warn {
  color: var(--warn);
}

.job-funnel {
  margin-top: 24px;
}

.job-funnel a.funnel-label {
  color: var(--navy-700);
}

.job-funnel a.funnel-value {
  font-variant-numeric: tabular-nums;
}

.job-funnel a:hover {
  color: var(--navy-900);
}

.job-lists .segmented {
  margin-bottom: 16px;
}

.search-problem {
  max-width: 360px;
  color: var(--navy-500);
  font-size: 13px;
  line-height: 18px;
}

.record-note {
  max-width: 68ch;
  margin: 12px 0 0;
}

.hit-list .sub {
  display: block;
  color: var(--navy-500);
  font-size: 13px;
  line-height: 18px;
}

.fields dd .badge {
  margin-right: 4px;
}

/* ---------- Leitura do site (etapa 7) ---------- */

/* Segundo funil do job, abaixo do de resultados: mesma régua visual, título menor. */
.job-sites {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--navy-200);
}

.job-sites-title {
  margin: 0;
  color: var(--navy-700);
  font-size: 15px;
  line-height: 22px;
  font-weight: 700;
}

.job-sites .job-funnel {
  margin-top: 8px;
}

.job-sites .job-progress-parts {
  margin-top: 4px;
}

/* Filtro dentro de uma aba: menor que as abas, para a hierarquia ficar clara. */
.segmented.segmented-sm {
  flex-wrap: wrap;
  padding: 2px;
}

.segmented.segmented-sm > a,
.segmented.segmented-sm > strong {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.segmented.segmented-sm > strong {
  background: var(--baby-100);
  color: var(--navy-900);
}

.nowrap {
  white-space: nowrap;
}

.cell-status .sub,
.fields dd .sub {
  display: block;
  color: var(--navy-500);
  font-size: 13px;
  line-height: 18px;
}

.site-problem {
  max-width: 320px;
  margin-top: 4px;
}

.cell-name .sub .badge {
  margin-top: 4px;
}

.record-network {
  max-width: 68ch;
  margin: 16px 0 0;
}

.site-meta {
  margin: 0 0 12px;
}

.site-reason {
  max-width: 68ch;
  margin: 0 0 16px;
  color: var(--navy-700);
}

.site-values {
  margin: 0;
}

.site-values li {
  padding: 0 0 2px;
}

.site-pages .hit-list {
  margin-top: 4px;
}

.site-pages .hit-list a {
  overflow-wrap: anywhere;
}

.site-pages[open] > summary .icon {
  transform: rotate(90deg);
}

.site-not-yet {
  color: var(--navy-500);
  font-size: 14px;
}

.site-network {
  display: inline-block;
  min-width: 80px;
  color: var(--navy-500);
  font-size: 14px;
}

.site-values li:has(.site-network) {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 8px;
}

.site-values li .site-network {
  min-width: 0;
}

/* ---------- CNPJ dos achados (etapa 8) ---------- */

.job-cnpj .job-progress-parts {
  margin: 4px 0 0;
}

.cnpj-review-call {
  max-width: 68ch;
  margin: 12px 0 0;
}

/* Maps e Receita lado a lado: quem confere lê as duas colunas na mesma altura. */
.cnpj-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0 0 16px;
  border: 1px solid var(--navy-200);
  border-radius: var(--r-panel);
}

.cnpj-side {
  padding: 16px;
}

.cnpj-side + .cnpj-side {
  border-left: 1px solid var(--navy-200);
  background: var(--baby-100);
  border-radius: 0 var(--r-panel) var(--r-panel) 0;
}

.cnpj-side h3 {
  margin: 0 0 12px;
  color: var(--navy-900);
  font-size: 15px;
  line-height: 22px;
}

.cnpj-side .fields {
  margin: 0;
}

.cnpj-review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 24px;
}

.cnpj-candidates-title {
  margin: 8px 0;
  font-size: 15px;
  line-height: 22px;
}

.cnpj-candidates li {
  padding: 10px 0;
  border-top: 1px solid var(--navy-200);
}

.cnpj-candidates .row {
  justify-content: flex-start;
  margin: 0 0 2px;
}

.cnpj-candidates .sub {
  display: block;
  max-width: 68ch;
  color: var(--navy-500);
  font-size: 13px;
  line-height: 18px;
}

.cnpj-manual {
  margin: 0 0 16px;
}

.cnpj-search-again {
  padding-top: 16px;
  border-top: 1px solid var(--navy-200);
}

@media (max-width: 767px) {
  .cnpj-compare {
    grid-template-columns: minmax(0, 1fr);
  }

  .cnpj-side + .cnpj-side {
    border-left: 0;
    border-top: 1px solid var(--navy-200);
    border-radius: 0 0 var(--r-panel) var(--r-panel);
  }

  .cnpj-review-actions > form,
  .cnpj-review-actions button {
    flex: 1 1 100%;
    width: 100%;
  }
}

/* Rótulos do funil de CNPJ são mais longos: a coluna cresce nos três funis do job, que seguem alinhados. */
@media (min-width: 768px) {
  .job-funnel li {
    grid-template-columns: 240px minmax(0, 1fr) 180px;
  }
}

/* ---------- Qualificação pela IA (etapa 9) ---------- */

.badge-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

/* Score: número em destaque. Verde quando chega ao mínimo do ICP. */
.score {
  display: inline-block;
  min-width: 36px;
  padding: 2px 8px;
  border-radius: var(--r-control);
  background: var(--baby-100);
  color: var(--navy-900);
  font-size: 15px;
  line-height: 20px;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.score-in {
  background: var(--ok-bg);
  color: var(--ok);
}

.score-lg {
  min-width: 64px;
  padding: 8px 12px;
  font-size: 30px;
  line-height: 36px;
  letter-spacing: -0.02em;
}

.cell-score {
  width: 72px;
}

.ai-table .ai-justification {
  min-width: 360px;
  max-width: 560px;
}

.ai-verdict {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin: 0 0 16px;
}

.ai-score {
  display: flex;
  gap: 10px;
  align-items: center;
  flex: none;
  margin: 0;
}

.ai-score-of {
  color: var(--navy-700);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
}

.ai-score-of .sub {
  display: block;
  color: var(--navy-500);
  font-size: 13px;
  line-height: 18px;
  font-weight: 500;
}

.ai-reason {
  max-width: 68ch;
}

.ai-reason p {
  margin: 0 0 6px;
}

.ai-confidence {
  color: var(--navy-500);
  font-size: 14px;
}

.ai-confidence strong {
  color: var(--navy-900);
}

.ai-verdict-compact {
  margin-bottom: 8px;
}

.ai-verdict-compact .ai-score {
  min-width: 160px;
}

.ai-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-actions form {
  margin: 0;
}

.site-summary {
  max-width: 68ch;
  margin: 8px 0 0;
  color: var(--navy-700);
  font-size: 14px;
  line-height: 21px;
  overflow-wrap: anywhere;
}

/* Rótulo das palavras-chave com a quantidade e o botão da IA na mesma linha. */
.keywords-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.stacked-form .keywords-head > label {
  margin: 0;
  color: var(--navy-900);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
}

.keywords-ai {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stacked-form .keywords-qty {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--navy-500);
  font-size: 13px;
  font-weight: 600;
}

.keywords-qty input {
  width: 64px;
  height: 36px;
  min-height: 36px;
  padding: 0 8px;
  font-size: 15px;
}

.keywords-suggest {
  --control-h: 36px;
  height: 36px;
  min-height: 36px;
}

.keywords-suggest .icon {
  width: 18px;
  height: 18px;
}

.keywords-suggest.htmx-request .icon {
  animation: keywords-spin 1s linear infinite;
}

@keyframes keywords-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .keywords-suggest.htmx-request .icon {
    animation: none;
  }
}

.keywords-notice {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 6px 0 0;
  color: var(--ok);
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
}

.keywords-notice .icon {
  width: 14px;
  height: 14px;
  flex: none;
}

.helptext .icon {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
}

@media (max-width: 767px) {
  .ai-verdict {
    flex-direction: column;
    gap: 12px;
  }
}

.guide-example {
  max-width: 68ch;
  margin: 0 0 16px;
  padding: 12px 16px;
  overflow-x: auto;
  border-radius: var(--r-control);
  background: var(--baby-100);
  color: var(--navy-900);
  font-family: var(--font);
  font-size: 14px;
  line-height: 22px;
  white-space: pre-wrap;
}

/* ---------- Recoleta ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.recollect-table .cell-action {
  text-align: right;
  white-space: nowrap;
}

.recollect-table .cell-since {
  white-space: nowrap;
}

.recollect-rules {
  margin-bottom: 16px;
}

@media (max-width: 1023px) {
  .recollect-grid .pool-side {
    margin-bottom: 24px;
  }

  .recollect-grid .pool-list {
    padding-top: 24px;
    border-top: 1px solid var(--navy-200);
  }
}

.recollect-table .cell-since .muted {
  display: block;
  font-size: 13px;
}

@media (max-width: 767px) {
  .recollect-table .cell-status,
  .recollect-table .cell-since {
    white-space: normal;
  }

  .recollect-table .cell-since .muted {
    display: inline;
  }
}

.inline-days {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.inline-days input[type="number"] {
  width: 96px;
}

.recollect-rules .plain-list {
  max-width: 80ch;
  margin-top: 8px;
}

.recollect-rules li {
  font-size: 14px;
  line-height: 22px;
}

.recollect-results {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--navy-200);
}

.recollect-result {
  padding: 16px 0;
  border-bottom: 1px solid var(--navy-200);
}

.recollect-result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.recollect-result-head h3 {
  margin: 0 4px 0 0;
  font-size: 15px;
  line-height: 22px;
}

.recollect-result-head .muted {
  font-size: 13px;
}

.recollect-lines {
  max-width: 80ch;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.recollect-lines li {
  position: relative;
  padding: 2px 0 2px 16px;
  color: var(--navy-700);
  font-size: 14px;
  line-height: 22px;
}

.recollect-lines li::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--baby-300);
}

.recollect-lines .line-note::before {
  background: var(--navy-200);
}

.recollect-lines .line-problem {
  color: var(--warn);
}

.recollect-lines .line-problem::before {
  background: var(--warn);
}

.recollect-call {
  margin: 6px 0 0 16px;
  font-size: 13px;
}
