:root {
  --green: #075e54;
  --green-2: #128c7e;
  --background: #f4f7f6;
  --line: #dce5e1;
  --text: #1f2925;
  --muted: #69756f;
  --danger: #a93333;
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
}

.topbar {
  min-height: 64px;
  padding: 0 28px;
  background: var(--green);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 17px;
  flex-wrap: wrap;
}

.topbar nav > a {
  text-decoration: none;
}

.brand {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
  text-decoration: none;
}

.container {
  max-width: 1500px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

h1,
h2,
h3 {
  margin-top: 0;
}

.page-heading h1 {
  margin-bottom: 5px;
}

.page-heading p {
  margin: 0;
  color: var(--muted);
}

.button {
  display: inline-block;
  border: 0;
  border-radius: 8px;
  padding: 11px 15px;
  background: var(--green-2);
  color: white;
  cursor: pointer;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.button.small {
  padding: 8px 11px;
  background: white;
  color: var(--green);
}

.button.secondary {
  background: #e3ebe7;
  color: #33423b;
}

.button.whatsapp {
  background: #25d366;
  color: #063a19;
}

.button.email {
  background: #1a73e8;
}

.full-button {
  width: 100%;
  margin-top: 10px;
}

.magic-button {
  background: var(--green);
}

.panel {
  padding: 20px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.kpis article {
  padding: 18px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.kpis span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

.kpis strong {
  color: var(--green);
  font-size: 28px;
}

.grid-two,
.project-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.lead-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid #edf1ef;
  text-decoration: none;
}

.lead-row:last-child {
  border-bottom: 0;
}

.lead-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 5px 8px;
  background: #e5eeea;
  font-size: 11px;
  font-weight: 800;
}

.badge.danger {
  background: #ffdede;
  color: #8a2828;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 220px 220px auto;
  gap: 10px;
  margin-bottom: 16px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd6d1;
  border-radius: 8px;
  padding: 10px;
  background: white;
  font: inherit;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  color: #53605a;
  font-size: 13px;
  font-weight: 700;
}

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

.form-grid .full {
  grid-column: 1 / -1;
}

.actions,
.action-grid {
  display: flex;
  gap: 10px;
}

.actions {
  justify-content: flex-end;
}

.action-grid {
  margin-top: 10px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 250px);
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: white;
  color: var(--muted);
  font-size: 12px;
}

.lead-table-row {
  cursor: pointer;
}

.lead-table-row:hover,
.lead-table-row.active {
  background: #eaf3ef;
}

.crm-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
  gap: 18px;
  align-items: start;
}

.lead-table-panel {
  min-width: 0;
}

.atendimento-sidebar {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
}

.sidebar-empty {
  padding: 30px 10px;
  color: var(--muted);
  text-align: center;
}

.hidden {
  display: none !important;
}

.sidebar-top {
  display: flex;
  justify-content: space-between;
  gap: 15px;
}

.sidebar-top h2 {
  margin-bottom: 4px;
}

.sidebar-top p {
  margin: 0;
  color: var(--muted);
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: #e3ebe7;
  cursor: pointer;
  font-size: 20px;
}

.sidebar-contact {
  margin: 14px 0;
  padding: 12px;
  border-radius: 9px;
  background: var(--green);
  color: white;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.detail-grid,
.quick-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.detail-grid > div {
  min-height: 70px;
  padding: 11px;
  border: 1px solid #e4ebe7;
  border-radius: 9px;
  background: #f6f9f7;
}

.detail-grid span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.sidebar-section {
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid #e2e8e5;
}

.sidebar-section h3 {
  margin-bottom: 12px;
}

.qr-box {
  margin-top: 15px;
  text-align: center;
}

.qr-box img {
  width: 190px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.qr-box small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  padding-left: 10px;
  border-left: 3px solid var(--green-2);
}

.history-item strong,
.history-item small {
  display: block;
}

.history-item small {
  margin-top: 3px;
  color: var(--muted);
}

.sidebar-message,
.kanban-message {
  position: sticky;
  bottom: 0;
  margin-top: 12px;
  border-radius: 8px;
  padding: 10px;
  background: #e8f4ed;
  color: #275d3c;
  font-size: 12px;
  text-align: center;
}

.sidebar-message:empty,
.kanban-message:empty {
  display: none;
}

.project-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.project-tab {
  padding: 8px 11px;
  border-radius: 999px;
  background: #e6eeea;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.project-tab.active {
  background: var(--green);
  color: white;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(8, minmax(250px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.kanban-column {
  min-height: 430px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #edf3f0;
}

.kanban-column.drag-over {
  outline: 2px solid var(--green-2);
}

.kanban-header {
  display: flex;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
}

.kanban-cards {
  display: grid;
  gap: 10px;
  min-height: 370px;
  padding: 10px;
}

.kanban-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  cursor: grab;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.kanban-card.dragging {
  opacity: 0.5;
}

.kanban-card small {
  display: block;
  margin: 5px 0;
  color: var(--muted);
}

.flash {
  margin-bottom: 15px;
  padding: 12px;
  border-radius: 8px;
}

.flash.success {
  background: #dff4e7;
  color: #225e38;
}

.flash.error {
  background: #ffe1e1;
  color: #872b2b;
}

.empty {
  color: var(--muted);
}

.import-summary {
  margin-top: 18px;
}

@media (max-width: 1050px) {
  .crm-workspace {
    grid-template-columns: 1fr;
  }

  .atendimento-sidebar {
    position: static;
    max-height: none;
  }
}

@media (max-width: 780px) {
  .topbar {
    padding: 14px 18px;
    align-items: flex-start;
  }

  .kpis,
  .grid-two,
  .project-grid,
  .form-grid,
  .detail-grid,
  .quick-edit-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .form-grid .full {
    grid-column: auto;
  }

  .page-heading {
    align-items: flex-start;
  }
}


.theme-toggle {
  width: 38px;
  height: 34px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 8px;
  background: rgba(255,255,255,.12);
  color: white;
  cursor: pointer;
  font-size: 16px;
}

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

.kanban-modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  box-shadow: 0 24px 70px rgba(0,0,0,.25);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.modal-header h2 {
  margin-bottom: 4px;
}

.modal-header p {
  margin: 0;
  color: var(--muted);
}

.modal-contact {
  margin: 14px 0;
  padding: 12px;
  border-radius: 9px;
  background: var(--green);
  color: white;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

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

.modal-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 12px;
}

.modal-section {
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.modal-section h3 {
  margin-bottom: 12px;
}

html.dark {
  --green: #0f766e;
  --green-2: #14b8a6;
  --background: #111827;
  --line: #334155;
  --text: #e5e7eb;
  --muted: #94a3b8;
  color-scheme: dark;
}

html.dark .panel,
html.dark .kpis article,
html.dark .kanban-modal,
html.dark .kanban-card,
html.dark input,
html.dark select,
html.dark textarea,
html.dark th {
  background: #1f2937;
  color: var(--text);
}

html.dark .detail-grid > div,
html.dark .card,
html.dark .kanban-column,
html.dark .project-tab,
html.dark .button.secondary,
html.dark .icon-button {
  background: #263244;
  color: var(--text);
}

html.dark .lead-table-row:hover,
html.dark .lead-table-row.active {
  background: #243b3a;
}

html.dark .badge {
  background: #334155;
  color: #e5e7eb;
}

html.dark .topbar {
  background: #0b4f49;
}

html.dark .modal-backdrop {
  background: rgba(0,0,0,.68);
}

@media (max-width: 650px) {
  .compact-grid,
  .modal-actions {
    grid-template-columns: 1fr;
  }
}

.error-page{max-width:620px;margin:70px auto;text-align:center}.error-code{color:var(--green);font-size:72px;font-weight:900;line-height:1;margin-bottom:14px}.error-page p{color:var(--muted);margin-bottom:22px}


.inline-form {
  display: inline;
  margin: 0;
}

.nav-link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: white;
  cursor: pointer;
  font: inherit;
}

.current-user {
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  font-size: 12px;
  font-weight: 700;
}

.login-shell {
  min-height: calc(100vh - 170px);
  display: grid;
  place-items: center;
}

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

.login-brand {
  margin-bottom: 22px;
  color: var(--green);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .4px;
  text-transform: uppercase;
}

.login-card p {
  margin-top: -8px;
  margin-bottom: 20px;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
}

.remember-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
}

.remember-row input {
  width: auto;
}

.technical-value {
  font-size: 18px !important;
  text-transform: capitalize;
}

.technical-list {
  margin: 0;
}

.technical-list > div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.technical-list dt {
  color: var(--muted);
}

.technical-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.technical-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.backup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.backup-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.technical-log-panel {
  margin-top: 18px;
}

.technical-logs {
  max-height: 420px;
  overflow: auto;
  padding: 14px;
  border-radius: 9px;
  background: #111827;
  color: #d1fae5;
  white-space: pre-wrap;
  word-break: break-word;
}


.current-user {
  text-decoration: none;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 9px;
}

.checkbox-label input {
  width: auto;
}

.panel-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.technical-users-panel {
  margin-top: 18px;
}

.technical-user-table {
  max-height: none;
  margin-top: 12px;
}


.admin-menu {
  position: relative;
}

.admin-menu-panel {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 100;
  min-width: 220px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--text);
  box-shadow: 0 16px 38px rgba(0, 0, 0, .18);
}

.admin-menu-panel a {
  display: block;
  padding: 10px 11px;
  border-radius: 7px;
  text-decoration: none;
}

.admin-menu-panel a:hover {
  background: #edf3f0;
}

html.dark .admin-menu-panel {
  background: #1f2937;
}

html.dark .admin-menu-panel a:hover {
  background: #263244;
}

.export-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.export-filter-grid .full {
  grid-column: 1 / -1;
}

.export-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.export-summary-card {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.export-summary-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 5px;
}

.export-summary-card strong {
  color: var(--green);
  font-size: 30px;
}

.export-download-actions {
  display: flex;
  gap: 10px;
}

@media (max-width: 900px) {
  .export-filter-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 650px) {
  .export-filter-grid {
    grid-template-columns: 1fr;
  }

  .export-summary-card {
    align-items: stretch;
    flex-direction: column;
  }

  .export-download-actions {
    flex-direction: column;
  }
}


/* V6.0.2 — refinamentos de fluidez */
html {
  background: var(--background);
  scroll-behavior: smooth;
}

body,
.panel,
.kpis article,
.kanban-card,
.kanban-column,
.atendimento-sidebar,
.admin-menu-panel,
input,
select,
textarea,
.button,
.project-tab,
.badge {
  transition:
    background-color .18s ease,
    color .18s ease,
    border-color .18s ease,
    box-shadow .18s ease,
    opacity .18s ease,
    transform .18s ease;
}

body {
  min-height: 100vh;
}

main.container {
  animation: pageFadeIn .18s ease both;
}

@keyframes pageFadeIn {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.button:hover,
.project-tab:hover,
.icon-button:hover,
.theme-toggle:hover {
  transform: translateY(-1px);
}

.button:active,
.project-tab:active,
.icon-button:active,
.theme-toggle:active {
  transform: translateY(0);
}

.lead-table-row {
  transition:
    background-color .14s ease,
    box-shadow .14s ease;
}

.lead-table-row.active {
  box-shadow: inset 3px 0 0 var(--green-2);
}

.atendimento-sidebar {
  animation: sidebarFadeIn .16s ease both;
}

@keyframes sidebarFadeIn {
  from {
    opacity: .75;
    transform: translateX(5px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.sidebar-content.loading {
  opacity: .55;
  pointer-events: none;
}

.sidebar-loading {
  display: grid;
  gap: 10px;
}

.sidebar-loading::before,
.sidebar-loading::after {
  content: "";
  display: block;
  height: 14px;
  border-radius: 999px;
  background:
    linear-gradient(
      90deg,
      rgba(128, 128, 128, .12) 25%,
      rgba(128, 128, 128, .22) 50%,
      rgba(128, 128, 128, .12) 75%
    );
  background-size: 200% 100%;
  animation: loadingShimmer 1.1s infinite linear;
}

.sidebar-loading::after {
  width: 65%;
}

@keyframes loadingShimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, .08);
}

.modal-backdrop {
  animation: modalBackdropIn .15s ease both;
}

.kanban-modal {
  animation: modalPanelIn .18s ease both;
}

@keyframes modalBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalPanelIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

html.dark,
html.dark body {
  background: var(--background);
  color: var(--text);
}

html.dark .topbar,
html.dark .sidebar-contact,
html.dark .modal-contact {
  color: white;
}

html.dark input::placeholder,
html.dark textarea::placeholder {
  color: #7f8da3;
}

@media (max-width: 1050px) {
  .table-wrap {
    max-height: none;
  }

  .atendimento-sidebar {
    position: static;
  }
}

@media (max-width: 780px) {
  .topbar {
    gap: 14px;
    flex-direction: column;
  }

  .topbar nav {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
    flex-wrap: nowrap;
  }

  .topbar nav > * {
    flex: 0 0 auto;
  }

  .container {
    padding: 20px 12px 44px;
  }

  .panel {
    padding: 15px;
  }

  th,
  td {
    padding: 10px 8px;
  }
}

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


html.navigating main.container {
  opacity: .78;
}


/* V6.0.3 — proteção total contra flash claro */
:root {
  background-color: #f4f7f6;
}

html.dark {
  background-color: #111827;
}

html,
body,
main,
.container {
  background-color: var(--background);
}

html.navigating,
html.navigating body {
  background-color: var(--background);
}

html.navigating main.container {
  opacity: 1;
}

@media (prefers-color-scheme: dark) {
  html:not(.light) {
    background-color: #111827;
  }
}


.brand small {
  margin-left: 5px;
  font-size: 10px;
  opacity: .7;
  vertical-align: middle;
}

.app-footer {
  padding: 18px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}
