.dashboard-insight-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0;
}

.dashboard-insight-metrics article {
  min-height: 126px;
  border: 1px solid var(--pc-card-border);
}

.dashboard-insight-metrics span,
.dashboard-insight-metrics small,
.panel-note,
.status-grid small { color: var(--pc-text-muted); }

.dashboard-insight-metrics strong { font-size: clamp(1.5rem, 2.4vw, 2.15rem); }

.form-error {
  min-height: 1.3em;
  margin: 0;
  color: var(--pc-danger);
  font-size: .9rem;
  font-weight: 700;
}

.form-error:empty { min-height: 0; }

[aria-invalid="true"] { border-color: var(--pc-danger) !important; }

.sidebar a[aria-current="page"] { box-shadow: inset 3px 0 0 currentColor; }

.lead-whatsapp-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  height: 38px;
  padding: 8px 12px;
  border: 1px solid #13a86b;
  border-radius: 11px;
  color: #fff;
  background: #16a86d;
  font-size: .86rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 7px 16px rgba(22, 168, 109, .2);
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}

.lead-whatsapp-button:hover {
  color: #fff;
  background: #0d8f5b;
  transform: translateY(-1px);
  box-shadow: 0 9px 20px rgba(13, 143, 91, .28);
}

.lead-whatsapp-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex: 0 0 auto;
}

.lead-whatsapp-unavailable {
  color: var(--pc-text-muted);
  font-size: .82rem;
  font-weight: 700;
}

/* Os cartões usam apenas a barra inferior; os antigos quadrados decorativos foram removidos. */
.metrics article::before {
  display: none !important;
  content: none !important;
}

.notification-center {
  position: relative;
  flex: 0 0 auto;
}

.notification-bell {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  min-height: 46px;
  padding: 0;
  border: 1px solid var(--pc-card-border);
  border-radius: 15px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(31, 55, 90, .1);
}

.notification-bell svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 2px solid var(--panel);
  border-radius: 999px;
  color: #fff;
  background: var(--pc-danger);
  font-size: 10px;
  font-weight: 900;
  line-height: 16px;
}

.notification-panel {
  position: absolute;
  z-index: 100;
  top: calc(100% + 10px);
  right: 0;
  width: min(390px, calc(100vw - 28px));
  max-height: min(560px, calc(100vh - 110px));
  overflow: hidden;
  border: 1px solid var(--pc-card-border);
  border-radius: 18px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(15, 23, 42, .2);
}

.notification-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--pc-card-border);
}

.notification-panel header div {
  display: grid;
  gap: 2px;
}

.notification-panel header small,
.notification-item time {
  color: var(--pc-text-muted);
}

button.notification-clear {
  width: auto;
  min-height: 32px;
  padding: 6px 9px;
  color: var(--pc-text-muted);
  background: transparent;
  box-shadow: none;
  font-size: .76rem;
}

.notification-list {
  max-height: 470px;
  overflow-y: auto;
}

.notification-item {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid color-mix(in srgb, var(--pc-card-border) 74%, transparent);
}

.notification-item > span {
  width: 9px;
  height: 9px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.notification-item.error > span { background: var(--pc-danger); }
.notification-item p { margin: 0 0 5px; font-size: .86rem; font-weight: 700; line-height: 1.4; }
.notification-item time { font-size: .7rem; }
.notification-empty { padding: 34px 20px; color: var(--pc-text-muted); text-align: center; font-size: .86rem; }

.form-validation-summary {
  display: none;
  grid-column: 1 / -1;
  margin: 0;
  color: var(--pc-danger);
  font-size: .9rem;
  font-weight: 800;
}

.form-validation-summary:not(:empty) { display: block; }

label:has(> [aria-invalid="true"]),
label:has(.input-action-row [aria-invalid="true"]) {
  color: var(--pc-danger) !important;
}

.field-error-message {
  display: block;
  margin-top: 5px;
  color: var(--pc-danger);
  font-size: .76rem;
  font-weight: 800;
  line-height: 1.25;
}

.table-wrap th .table-sort-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  width: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  color: inherit !important;
  background: transparent !important;
  box-shadow: none !important;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}

.table-wrap th .table-sort-button:hover {
  color: inherit !important;
  background: transparent !important;
  box-shadow: none !important;
  transform: none !important;
}

.table-wrap th .table-sort-button span {
  color: var(--pc-text-muted);
  font-size: .95rem;
  line-height: 1;
}

.table-wrap th .table-sort-button.active,
.table-wrap th .table-sort-button.active span { color: inherit !important; }

.period-filter-form {
  grid-template-columns: minmax(150px, 220px) minmax(150px, 220px) auto auto auto;
}

.period-filter-form button {
  width: auto;
  min-height: 42px;
  grid-column: auto;
  white-space: nowrap;
}

.lead-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  min-width: 285px;
}

/* Em tablets e notebooks menores, prioriza os dados de contato e as ações. */
@media (max-width: 1440px) {
  .leads-table-wrap .lead-table-optional {
    display: none;
  }

  .leads-table-wrap table {
    table-layout: fixed;
  }

  .leads-table-wrap th:nth-child(2),
  .leads-table-wrap td:nth-child(2) { width: 135px; }

  .leads-table-wrap th:nth-child(3),
  .leads-table-wrap td:nth-child(3) { width: 145px; }

  .leads-table-wrap th:nth-child(6),
  .leads-table-wrap td:nth-child(6) { width: 175px; }

  .leads-table-wrap th:nth-child(7),
  .leads-table-wrap td:nth-child(7) { width: 290px; }

  .leads-table-wrap td:not(.actions) {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .leads-table-wrap td.actions {
    min-width: 285px;
  }
}

@media (max-width: 1180px) {
  .leads-table-wrap th:nth-child(2),
  .leads-table-wrap td:nth-child(2) { width: 120px; }

  .leads-table-wrap th:nth-child(3),
  .leads-table-wrap td:nth-child(3) { width: 130px; }

  .leads-table-wrap th:nth-child(6),
  .leads-table-wrap td:nth-child(6) { width: 150px; }

  .leads-table-wrap th:nth-child(7),
  .leads-table-wrap td:nth-child(7) { width: 205px; }

  .leads-table-wrap td.actions {
    min-width: 195px;
  }

  .leads-table-wrap .lead-row-actions {
    min-width: 0;
    gap: 6px;
  }

  .leads-table-wrap .lead-whatsapp-button {
    width: 38px;
    min-width: 38px;
    padding-inline: 8px;
  }

  .leads-table-wrap .lead-whatsapp-button span {
    display: none;
  }
}

.lead-contact-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  height: 38px;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--pc-card-border);
  border-radius: 11px;
  color: var(--pc-text-muted);
  background: var(--surface, #fff);
  cursor: pointer;
  white-space: nowrap;
}

.lead-contact-check:has(input:checked) {
  border-color: #15803d;
  color: #087a45;
  background: #ecfdf3;
}

.lead-contact-check input {
  width: 18px;
  min-width: 18px;
  min-height: 18px !important;
  height: 18px;
  margin: 0;
  padding: 0 !important;
  border-radius: 5px;
  box-shadow: none !important;
  accent-color: #15803d;
}

.lead-contact-check span { font-size: .78rem; font-weight: 800; }

.lead-delete-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 38px;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  margin: 0;
  padding: 0;
  border: 1px solid #ef4444;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #c81e1e);
  box-shadow: 0 7px 16px rgba(220, 38, 38, .22);
  font-size: 1.45rem;
  font-weight: 500;
  line-height: 1;
}

.lead-delete-button:hover {
  border-color: #f87171;
  background: linear-gradient(135deg, #f05252, #b91c1c);
  box-shadow: 0 9px 20px rgba(220, 38, 38, .3);
}

:root[data-theme="dark"] .lead-contact-check:has(input:checked) {
  color: #86efac;
  background: #123c2a;
}

:root[data-theme="dark"] .lead-contact-check {
  border-color: #3b526f;
  color: #d3deec;
  background: #17263d;
}

:root[data-theme="dark"] .lead-contact-check input[type="checkbox"] {
  border-color: #71829a;
  background: #0c1728;
}

.toast {
  display: none !important;
}

/* Menu lateral compacto no desktop. Ao passar o mouse ele abre sobre o
   conteúdo; quando fixado, a grade reserva a largura completa. */
@media (min-width: 921px) {
  .app-shell {
    --sidebar-compact-width: 82px;
    --sidebar-open-width: 236px;
    grid-template-columns: var(--sidebar-compact-width) minmax(0, 1fr) !important;
    transition: grid-template-columns .22s ease;
  }

  .app-shell.sidebar-pinned {
    grid-template-columns: var(--sidebar-open-width) minmax(0, 1fr) !important;
  }

  .sidebar {
    z-index: 30;
    width: var(--sidebar-compact-width);
    padding-inline: 12px !important;
    overflow: visible;
    transition: width .22s ease, padding .22s ease, box-shadow .22s ease;
  }

  .sidebar:hover,
  .sidebar:has(nav a:focus-visible),
  .sidebar:has(.sidebar-logout:focus-visible),
  .sidebar-pinned .sidebar {
    width: var(--sidebar-open-width);
    padding-inline: 16px !important;
    box-shadow: 18px 0 38px rgba(2, 13, 29, .2);
  }

  .sidebar-pinned .sidebar { box-shadow: none; }

  .sidebar-head {
    position: relative;
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    align-items: center;
    column-gap: 12px;
    min-width: 0;
    padding-inline: 4px !important;
  }

  .sidebar nav {
    width: 100%;
    margin-top: 50px;
  }

  .sidebar-logo {
    width: 46px;
    min-width: 46px;
    height: 46px;
    transition: width .22s ease, height .22s ease;
  }

  .sidebar-head > div,
  .sidebar nav > a > span:not(.nav-icon):not(.nav-caret),
  .sidebar-logout > span {
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    white-space: nowrap;
    transform: translateX(-5px);
    transition: max-width .22s ease, opacity .14s ease, transform .22s ease;
  }

  .sidebar:hover .sidebar-head > div,
  .sidebar:has(nav a:focus-visible) .sidebar-head > div,
  .sidebar:has(.sidebar-logout:focus-visible) .sidebar-head > div,
  .sidebar-pinned .sidebar-head > div,
  .sidebar:hover nav > a > span:not(.nav-icon):not(.nav-caret),
  .sidebar:has(nav a:focus-visible) nav > a > span:not(.nav-icon):not(.nav-caret),
  .sidebar:has(.sidebar-logout:focus-visible) nav > a > span:not(.nav-icon):not(.nav-caret),
  .sidebar-pinned .sidebar nav > a > span:not(.nav-icon):not(.nav-caret),
  .sidebar:hover .sidebar-logout > span,
  .sidebar:has(nav a:focus-visible) .sidebar-logout > span,
  .sidebar:has(.sidebar-logout:focus-visible) .sidebar-logout > span,
  .sidebar-pinned .sidebar-logout > span {
    max-width: 180px;
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
  }

  .sidebar nav > a,
  .sidebar-logout {
    justify-content: center;
    gap: 0;
  }

  .sidebar nav > a {
    justify-self: center;
    width: 50px;
    min-width: 50px;
    height: 50px;
    min-height: 50px;
    padding: 6px;
    border-radius: 16px;
    overflow: hidden;
    transition: width .22s ease, color .18s ease, background .18s ease, border-radius .22s ease, transform .18s ease;
  }

  .sidebar nav > a[aria-current="page"] {
    box-shadow: 0 10px 24px rgba(0, 111, 218, .28);
  }

  .sidebar nav > a.active::after { display: none; }

  .sidebar:hover nav > a,
  .sidebar:has(nav a:focus-visible) nav > a,
  .sidebar:has(.sidebar-logout:focus-visible) nav > a,
  .sidebar-pinned .sidebar nav > a,
  .sidebar:hover .sidebar-logout,
  .sidebar:has(nav a:focus-visible) .sidebar-logout,
  .sidebar:has(.sidebar-logout:focus-visible) .sidebar-logout,
  .sidebar-pinned .sidebar-logout {
    justify-content: flex-start;
    gap: 10px;
  }

  .sidebar:hover nav > a,
  .sidebar:has(nav a:focus-visible) nav > a,
  .sidebar:has(.sidebar-logout:focus-visible) nav > a,
  .sidebar-pinned .sidebar nav > a {
    justify-self: stretch;
    width: 100%;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 16px;
  }

  .sidebar .nav-icon {
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
  }

  .sidebar-collapse-btn {
    position: absolute;
    top: 62px;
    right: -29px;
    display: inline-grid;
    width: 34px;
    min-width: 34px;
    height: 30px;
    min-height: 30px;
    margin: 0;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(125, 211, 252, .2);
    border-radius: 10px;
    color: #8bdfff;
    background: rgba(11, 53, 80, .78);
    box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
    transition: color .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
  }

  .sidebar:hover .sidebar-collapse-btn,
  .sidebar-pinned .sidebar-collapse-btn {
    right: -33px;
  }

  .sidebar-collapse-btn:hover,
  .sidebar-collapse-btn:focus-visible {
    color: #e0f7ff;
    border-color: rgba(125, 211, 252, .58);
    background: #0e4a6e;
    box-shadow: 0 8px 20px rgba(2, 18, 35, .28), 0 0 0 3px rgba(56, 189, 248, .12);
    transform: translateY(-1px);
  }

  .sidebar-collapse-btn svg,
  .sidebar-logout-icon {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .sidebar-collapse-btn svg {
    transition: transform .22s ease;
  }

  .sidebar-pinned .sidebar-collapse-btn svg { transform: scaleX(-1); }

  .sidebar-logout {
    display: inline-flex;
    align-items: center;
    justify-self: center;
    width: 48px;
    min-width: 48px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 14px;
    overflow: hidden;
    transition: width .22s ease, border-radius .22s ease, background .18s ease;
  }

  .sidebar:hover .sidebar-logout,
  .sidebar:has(nav a:focus-visible) .sidebar-logout,
  .sidebar:has(.sidebar-logout:focus-visible) .sidebar-logout,
  .sidebar-pinned .sidebar-logout {
    justify-self: stretch;
    width: 100%;
    padding-inline: 12px;
  }

  .sidebar-logout-icon {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    margin: 0;
  }
}

@media (max-width: 920px) {
  .sidebar-collapse-btn { display: none !important; }
  .sidebar-logout-icon { display: none; }
}

@media (max-width: 920px) {
  .topbar-actions {
    grid-template-columns: 42px 42px minmax(0, 1fr) !important;
  }

  .notification-bell {
    width: 42px;
    height: 42px;
    min-height: 42px;
    border-radius: 12px;
  }

  .notification-panel {
    position: fixed;
    top: 72px;
    right: 12px;
    left: 12px;
    width: auto;
  }

  .period-filter-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .period-filter-form label { grid-column: auto; }
  .period-filter-form button { width: 100%; }
  .lead-row-actions { min-width: 0; flex-wrap: wrap; }
}

@media (max-width: 520px) {
  .period-filter-form { grid-template-columns: 1fr; }
  .period-filter-form label { grid-column: auto; }
  .lead-row-actions { width: 100%; }
  .lead-row-actions .lead-whatsapp-button,
  .lead-contact-check { flex: 1 1 100%; justify-content: center; }
}

@media (forced-colors: active) {
  .health-badge, .badge, button, input, select, textarea { border: 1px solid ButtonText; }
}
