:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --line: #d9e2ec;
  --brand: #ef3b6d;
  --brand-dark: #b4234f;
  --green: #127c56;
  --amber: #a15c00;
  --red: #b42318;
  --blue: #1f6feb;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.access-denied {
  display: none !important;
}

.muted-row td {
  color: var(--muted);
  background: #f8fafc;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef3f8;
}

body.logged-in .login-screen {
  display: none;
}

body:not(.logged-in) > .sidebar,
body:not(.logged-in) > main {
  visibility: hidden;
}

.login-box {
  width: min(100%, 430px);
  display: grid;
  gap: 18px;
  padding: 30px;
  border: 1px solid #ccd7e3;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.14);
}

.login-box img {
  width: 150px;
  height: 76px;
  object-fit: contain;
  justify-self: center;
}

.login-box h1 {
  text-align: center;
  font-size: 25px;
}

.login-box p {
  margin-top: 6px;
  color: var(--muted);
  text-align: center;
  line-height: 1.45;
}

.login-box label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-weight: 700;
}

.login-box .form-error {
  min-height: 21px;
  margin: 0;
  color: var(--red);
  font-weight: 700;
  text-align: left;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  display: grid;
  grid-template-columns: 260px 1fr;
  font-size: 16px;
}

.sidebar {
  background: #17212b;
  color: #f8fafc;
  padding: 22px 16px;
  min-height: 100vh;
  height: 100vh;
  overflow-y: auto;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-logo {
  width: 72px;
  height: 44px;
  object-fit: contain;
  border-radius: 10px;
  flex: 0 0 auto;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: white;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 14px;
  line-height: 1.25;
}

.brand span,
.status-box small {
  color: #cbd5e1;
  font-size: 12px;
}

nav {
  display: grid;
  gap: 12px;
}

.nav-section {
  display: grid;
  gap: 5px;
}

.nav-label {
  color: #8fa3b8;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  padding: 0 12px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: #dbe4ee;
  text-align: left;
  padding: 13px 12px;
  border-radius: 6px;
  font-size: 15px;
  min-height: 46px;
  cursor: pointer;
}

.nav-link {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.nav-subitem {
  padding-left: 24px;
  position: relative;
}

.nav-subitem::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 6px;
  height: 1px;
  background: #8fa3b8;
}

.nav-item.active,
.nav-item:hover {
  background: #263545;
  color: #ffffff;
}

.status-box {
  margin-top: 28px;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.status-box.is-active { border-color: #16a34a; background: rgba(22, 163, 74, 0.12); }
.status-box.is-paused { border-color: #eab308; background: rgba(234, 179, 8, 0.12); }
.status-box.is-stopped { border-color: #dc2626; background: rgba(220, 38, 38, 0.12); }
.status-box.is-active .dot { background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.16); }
.status-box.is-paused .dot { background: #facc15; box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.16); }
.status-box.is-stopped .dot { background: #ef4444; box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.16); }

.nav-technical {
  opacity: 0.78;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f59e0b;
  margin-top: 4px;
  flex: 0 0 auto;
}

main {
  padding: 24px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.current-user {
  display: grid;
  gap: 1px;
  min-width: 126px;
  padding: 7px 10px;
  border-left: 3px solid #1e88e5;
  background: #ffffff;
}

.current-user strong {
  font-size: 13px;
}

.current-user span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
}

.topbar p,
.panel-head p {
  color: var(--muted);
  margin-top: 4px;
}

.primary-btn,
.secondary-btn,
.small-btn {
  border: 0;
  background: var(--brand);
  color: white;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
}

.primary-btn {
  padding: 13px 18px;
  min-height: 46px;
}

.secondary-btn {
  padding: 13px 18px;
  min-height: 46px;
  background: #1e88e5;
}

.danger-btn {
  min-height: 46px;
  padding: 13px 16px;
  border: 0;
  border-radius: 6px;
  background: #b42318;
  color: #ffffff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.danger-btn:hover {
  background: #8f1c13;
}

.paid-btn {
  min-height: 44px;
  padding: 10px 13px;
  border: 0;
  border-radius: 6px;
  background: #127c56;
  color: #ffffff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.paid-btn:hover {
  background: #0d6244;
}

.small-btn {
  padding: 10px 12px;
  min-height: 40px;
  white-space: nowrap;
}

button,
input,
select,
textarea {
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid #84c5ff;
  outline-offset: 2px;
}

.simple-help {
  position: sticky;
  top: 0;
  z-index: 5;
  margin-bottom: 16px;
  border: 1px solid #b8ddff;
  border-radius: 8px;
  background: #eff8ff;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.simple-help strong,
.simple-help span {
  display: block;
}

.simple-help strong {
  color: #1849a9;
  font-size: 17px;
  margin-bottom: 4px;
}

.simple-help span {
  color: #344054;
  line-height: 1.45;
}

.simple-help-actions {
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
}

.primary-btn:hover,
.secondary-btn:hover,
.small-btn:hover {
  background: var(--brand-dark);
}

.phone-link {
  color: #1e88e5;
  font-weight: 800;
  text-decoration: none;
}

.client-link {
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 0;
  text-align: left;
}

.client-link:hover {
  color: #1e88e5;
  text-decoration: underline;
}

.phone-link:hover {
  text-decoration: underline;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.compact-metrics .metric {
  min-height: 84px;
}

.compact-metrics .metric strong {
  font-size: 23px;
}

.mini-metrics {
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 10px;
  margin: 16px;
}

.mini-metrics .metric {
  box-shadow: none;
  min-height: 82px;
}

.mini-metrics .metric strong {
  font-size: 22px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
  min-height: 96px;
}

.metric-button {
  width: 100%;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.metric-button:hover {
  border-color: #60a5fa;
  background: #f8fbff;
}

.metric-button.active {
  border-color: #1f6feb;
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(31, 111, 235, 0.12);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.metric strong {
  font-size: 27px;
  letter-spacing: 0;
}

.metric.ok strong {
  color: var(--green);
}

.metric.warn strong {
  color: var(--amber);
}

.action-panel {
  margin-bottom: 16px;
}

.action-steps {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.action-card {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 14px;
  min-height: 112px;
  text-align: left;
  cursor: pointer;
}

.action-card:hover {
  border-color: var(--brand);
  box-shadow: 0 8px 18px rgba(239, 59, 109, 0.12);
}

.action-card strong,
.action-card span {
  display: block;
}

.action-card strong {
  font-size: 15px;
  margin-bottom: 8px;
}

.action-card span {
  color: var(--muted);
  line-height: 1.4;
}

.technical-panel {
  opacity: 0.92;
}

.grid {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  overflow: hidden;
}

.panel-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.panel-head.stacked {
  align-items: flex-end;
}

.panel-head.filter-panel-head {
  align-items: stretch;
  flex-direction: column;
}

.filter-panel-head .filters > * {
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
}

.filters {
  display: flex;
  gap: 10px;
  align-items: center;
}

input,
select,
textarea {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 12px 12px;
  font-size: 16px;
  min-height: 46px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}

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

input[type="search"] {
  min-width: 260px;
}

.list {
  padding: 8px 16px 14px;
}

.list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #edf2f7;
}

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

.list-row small {
  color: var(--muted);
}

.list-row strong {
  white-space: nowrap;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 12px 12px;
  border-bottom: 1px solid #edf2f7;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #475467;
  z-index: 1;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

tbody tr:hover {
  background: #f8fbff;
}

th::after {
  content: " ↕";
  color: #98a2b3;
  font-size: 11px;
}

th.sorted-asc::after {
  content: " ↑";
  color: #1e88e5;
}

th.sorted-desc::after {
  content: " ↓";
  color: #1e88e5;
}

td.muted,
.muted {
  color: var(--muted);
}

.money,
.num {
  white-space: nowrap;
  text-align: right;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2ff;
  color: #344054;
  white-space: nowrap;
}

.badge.erro {
  background: #fee4e2;
  color: var(--red);
}

.badge.enviado {
  background: #dcfae6;
  color: var(--green);
}

.badge.pendente {
  background: #fff4cc;
  color: var(--amber);
}

.phone-form {
  display: block;
}

.phone-form input {
  min-width: 130px;
  width: 100%;
}

.phone-input-label {
  display: grid;
  gap: 4px;
}

.phone-input-label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.phone-row-actions {
  min-width: 190px;
}

.phone-order-select {
  font-weight: 700;
}

.phone-origin-toggle {
  display: grid;
  gap: 0;
}

.phone-origin-summary {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
  min-height: auto;
}

.phone-origin-toggle select {
  margin-top: 6px;
  width: 100%;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.client-row-actions {
  min-width: 270px;
}

.report-filters {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.report-filters label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.report-filters label input {
  min-width: 150px;
}

.report-summary {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  color: #475467;
  font-weight: 700;
}

.client-detail-panel {
  margin-top: 16px;
}

.client-detail-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
}

.client-negative-alert { margin:16px; padding:14px 16px; border:1px solid #fca5a5; border-radius:8px; background:#fff1f2; color:#991b1b; font-weight:800; }
.client-negative-alert.withdrawal { background:#fff7ed; border-color:#fdba74; color:#9a3412; }
.client-timeline-panel { margin:16px; border:1px solid var(--line); border-radius:8px; background:var(--panel); }
.client-timeline-panel .panel-head { padding:14px 16px; }
.timeline-summary { display:grid; grid-template-columns:repeat(5,minmax(90px,1fr)); gap:8px; padding:0 16px 14px; }
.timeline-summary span { padding:9px; border-radius:7px; background:#f1f5f9; text-align:center; font-size:12px; color:var(--muted); }
.timeline-summary strong { display:block; color:var(--text); font-size:18px; }
.client-timeline { max-height:420px; overflow:auto; padding:0 16px 16px; }
.timeline-item { position:relative; margin-left:10px; padding:0 0 18px 24px; border-left:2px solid #dbeafe; }
.timeline-item::before { content:''; position:absolute; left:-6px; top:4px; width:10px; height:10px; border-radius:50%; background:#1f6feb; }
.timeline-item strong { display:block; }
.timeline-item small { color:var(--muted); }
.timeline-item p { margin:5px 0 0; white-space:pre-wrap; }
@media (max-width:720px){.timeline-summary{grid-template-columns:repeat(2,1fr)}.client-timeline-panel{margin:10px}.client-negative-alert{margin:10px}}

.client-detail-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #f8fafc;
  min-height: 110px;
}

.client-detail-grid span,
.client-detail-grid small {
  display: block;
  color: var(--muted);
}

.client-detail-grid span {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.client-detail-grid strong {
  display: block;
  font-size: 17px;
  line-height: 1.3;
  margin-bottom: 6px;
}

.message-box {
  padding: 0 16px 16px;
}

.message-box label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.message-box textarea {
  width: 100%;
  min-height: 150px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.message-cell {
  min-width: 190px;
  max-width: 360px;
  white-space: pre-wrap;
  line-height: 1.45;
}

.ia-suggestion-text {
  width: 100%;
  min-width: 250px;
  min-height: 118px;
  resize: vertical;
  line-height: 1.45;
  background: #ffffff;
}

.ia-suggestion-text:disabled {
  color: var(--muted);
  background: #f2f4f7;
}

.ai-status-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.ai-status-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
}

.ai-status-grid strong,
.ai-status-grid span {
  display: block;
}

.ai-status-grid strong {
  font-size: 15px;
  margin-bottom: 7px;
}

.ai-status-grid span {
  color: var(--muted);
  line-height: 1.45;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 560px;
  background: #17212b;
  color: #fff;
  padding: 16px 18px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 16px;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.menu-toggle {
  display: none;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 40;
}

.sidebar-backdrop:not([hidden]) {
  display: block;
}

@media (max-width: 980px) {
  body {
    grid-template-columns: 1fr;
  }

  .menu-toggle {
    display: inline-flex;
    align-self: flex-start;
    align-items: center;
    justify-content: center;
    width: 48px;
    min-width: 48px;
    height: 48px;
    padding: 0;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 82vw;
    max-width: 320px;
    min-height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 50;
    overflow-y: auto;
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 8px 0 24px rgba(15, 23, 42, 0.35);
  }

  nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics-grid,
  .grid.two,
  .action-steps,
  .client-detail-grid,
  .ai-status-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-head.stacked,
  .filters,
  .simple-help {
    align-items: stretch;
    flex-direction: column;
  }

  .simple-help-actions {
    flex-direction: column;
  }

  input[type="search"] {
    min-width: 0;
    width: 100%;
  }
}

/* --- Dashboard de clientes: KPIs, filtros clicaveis e graficos --- */
.client-overview {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 18px;
}

.client-overview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.client-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.client-kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px 16px;
  text-align: left;
  min-height: 44px;
}

.client-kpi span {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
}

.client-kpi strong {
  font-size: 22px;
  line-height: 1.2;
}

.client-kpi small {
  color: var(--muted);
  font-size: 12px;
}

button.client-kpi {
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

button.client-kpi:hover {
  border-color: #93c5fd;
}

button.client-kpi.active {
  background: #eff6ff;
  border-color: #2563eb;
}

button.client-kpi.active strong {
  color: #1d4ed8;
}

.client-filter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.filter-chip strong {
  font-weight: 800;
}

.filter-chip:hover {
  border-color: #94a3b8;
}

.filter-chip.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.client-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.chart-surface {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chart-surface h3 {
  margin: 0;
  font-size: 15px;
}

.chart-surface p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.chart-container {
  position: relative;
  height: 220px;
}

/* Garante alvo de toque minimo (44x44) em botoes e controles interativos */
button,
.small-btn,
.primary-btn,
.secondary-btn,
.danger-btn,
select,
input[type="search"],
input[type="text"],
input[type="date"] {
  min-height: 44px;
}

@media (max-width: 768px) {
  .simple-help {
    position: static;
  }

  #iawhatsapp .compact-metrics {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(74%, 1fr);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  #iawhatsapp .compact-metrics .metric {
    scroll-snap-align: start;
  }

  .client-kpis {
    grid-template-columns: 1fr;
    grid-auto-flow: column;
    grid-auto-columns: minmax(78%, 1fr);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .client-kpi {
    scroll-snap-align: start;
  }

  .client-filter-strip {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .filter-chip {
    scroll-snap-align: start;
  }

  .client-chart-grid {
    grid-template-columns: 1fr;
  }

  .chart-container {
    height: 200px;
  }

  /* Tabela de clientes vira lista de cards no celular */
  #clientesTable thead {
    display: none;
  }

  #clientesTable,
  #clientesTable tbody,
  #clientesTable tr,
  #clientesTable td {
    display: block;
    width: 100%;
  }

  #clientesTable tr {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: #fff;
  }

  #clientesTable td {
    border-bottom: none;
    padding: 8px 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    text-align: right;
  }

  #clientesTable td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    text-align: left;
    flex: 0 0 auto;
  }

  #clientesTable td:last-child {
    justify-content: flex-end;
  }

  #clientesTable .small-btn {
    width: 100%;
    justify-content: center;
  }

  .client-row-actions {
    width: 100%;
    min-width: 0;
  }
}

.client-row-meta {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

@media screen and (max-width: 768px) {
  .responsive-cards thead {
    display: none;
  }

  .responsive-cards,
  .responsive-cards tbody,
  .responsive-cards tr,
  .responsive-cards td {
    display: block;
    width: 100%;
  }

  .responsive-cards tr {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: #fff;
  }

  .responsive-cards td {
    min-height: 44px;
    border: 0;
    padding: 8px 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    text-align: right;
    white-space: normal;
  }

  .responsive-cards td::before {
    content: attr(data-label);
    max-width: 42%;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-align: left;
    text-transform: uppercase;
  }

  .responsive-cards td[colspan]::before {
    content: none;
  }

  .responsive-cards td[colspan] {
    display: block;
    min-height: 0;
    text-align: left;
  }

  .responsive-cards .row-actions,
  .responsive-cards form,
  .responsive-cards input,
  .responsive-cards select,
  .responsive-cards button {
    max-width: 100%;
  }

  .filters > *,
  .form-grid input,
  .form-grid select,
  .form-grid textarea,
  .form-grid button {
    width: 100%;
  }
}

.form-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.form-grid input {
  width: 100%;
  text-transform: none;
  font-weight: 400;
}

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

.checkbox-field {
  display: flex !important;
  align-items: center;
  gap: 10px;
  min-height: 46px;
}

.checkbox-field input {
  width: 22px;
  height: 22px;
  min-height: 0;
}

.span-2 {
  grid-column: span 2;
}

.table-wrap.compact {
  max-height: 420px;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.code-block {
  margin: 0;
  padding: 16px;
  background: #111827;
  color: #e5e7eb;
  overflow: auto;
  font-size: 13px;
  line-height: 1.6;
}

/* Cadastros gerais e parametros operacionais */
.parameter-header {
  display: grid;
  gap: 14px;
}

.parameter-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 8px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.parameter-tabs button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 9px 13px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #334155;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  scroll-snap-align: start;
}

.parameter-tabs button.active {
  border-color: var(--brand);
  background: #e8f2ff;
  color: #0b57a4;
}

.parameter-layout {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.dynamic-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dynamic-fields label {
  min-width: 0;
}

.dynamic-fields input,
.dynamic-fields select,
.dynamic-fields textarea {
  width: 100%;
}

.field-help {
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  text-transform: none;
}

.automation-lock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-left: 5px solid #f59e0b;
}

.automation-lock[hidden] {
  display: none;
}

.automation-lock div {
  display: grid;
  gap: 4px;
}

.automation-lock span {
  color: var(--muted);
}

.master-client-actions {
  min-width: 150px;
}

@media (max-width: 980px) {
  .parameter-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .dynamic-fields {
    grid-template-columns: 1fr;
  }

  .dynamic-fields .span-2 {
    grid-column: span 1;
  }

  .automation-lock {
    align-items: stretch;
    flex-direction: column;
  }

  .automation-lock button,
  .master-client-actions {
    width: 100%;
  }

  #masterClientForm .span-2 {
    grid-column: span 1;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 6mm;
  }

  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  html,
  body {
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }

  body {
    display: block;
    background: #ffffff;
    color: #111827;
    font-size: 7pt;
    line-height: 1.15;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .sidebar,
  .login-screen,
  .topbar-actions,
  .topbar p,
  .simple-help,
  .action-panel,
  .row-actions,
  .filters,
  .status-box,
  .toast,
  .technical-details summary,
  .primary-btn,
  .secondary-btn,
  .small-btn,
  .paid-btn,
  .nav-item,
  #clientSearch {
    display: none !important;
  }

  main {
    display: block !important;
    padding: 0 !important;
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .topbar {
    display: block;
    margin-bottom: 6px;
    border-bottom: 1px solid #d0d5dd;
    padding-bottom: 4px;
  }

  .topbar h1 {
    font-size: 12pt;
  }

  .view {
    display: none !important;
  }

  .view.active {
    display: block !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .metric,
  .client-detail-grid article,
  .sync-status-card {
    box-shadow: none !important;
    border: 1px solid #d0d5dd;
    break-inside: avoid-page;
    page-break-inside: avoid;
    border-radius: 0;
  }

  .panel {
    box-shadow: none !important;
    border: 1px solid #d0d5dd;
    border-radius: 0;
    break-inside: auto !important;
    page-break-inside: auto !important;
  }

  .metrics-grid,
  .compact-metrics,
  .mini-metrics {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 4px;
    margin-bottom: 6px;
  }

  .metric {
    min-height: 0;
    padding: 6px;
  }

  .metric span {
    font-size: 6.5pt;
    margin-bottom: 3px;
  }

  .metric strong,
  .compact-metrics .metric strong,
  .mini-metrics .metric strong {
    font-size: 9pt;
  }

  .grid,
  .grid.two {
    display: block;
    margin-top: 6px;
  }

  .panel {
    margin-bottom: 6px;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .panel-head {
    padding: 3px 5px;
    break-after: avoid-page;
    page-break-after: avoid;
  }

  .panel-head h2 {
    font-size: 8.5pt;
  }

  .panel-head p,
  .ai-status-grid,
  .message-box,
  form,
  .form-grid,
  .info-list,
  .list {
    display: none !important;
  }

  .client-detail-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 4px;
    padding: 4px;
  }

  .client-detail-grid article {
    min-height: 0;
    padding: 5px;
  }

  .client-detail-grid span,
  .client-detail-grid small {
    font-size: 6pt;
  }

  .client-detail-grid strong {
    font-size: 7.5pt;
  }

  .table-wrap,
  .table-wrap.compact {
    display: block !important;
    width: auto !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    font-size: 6.25pt;
    line-height: 1.12;
    table-layout: fixed;
    page-break-inside: auto;
    break-inside: auto;
  }

  thead {
    display: table-header-group;
  }

  tbody {
    display: table-row-group;
  }

  tfoot {
    display: table-footer-group;
  }

  th,
  td {
    border-bottom: 1px solid #d0d5dd;
    padding: 0.8mm;
    white-space: normal !important;
    word-break: break-word;
    overflow-wrap: anywhere;
    vertical-align: top;
  }

  tr {
    break-inside: avoid-page;
    page-break-inside: avoid;
  }

  th {
    position: static;
    font-size: 5.75pt;
    line-height: 1.08;
    color: #111827;
    background: #f3f4f6;
  }

  th::after {
    content: "";
  }

  th:empty,
  td:has(.row-actions) {
    display: none;
  }

  .badge {
    min-height: 0;
    padding: 1px 3px;
    border-radius: 2px;
    font-size: 5.5pt;
  }

  a,
  .phone-link,
  .client-link {
    color: #111827;
    text-decoration: none;
    display: inline !important;
  }

  .client-link {
    border: 0;
    background: transparent;
    padding: 0;
    font-weight: 800;
  }

  #dashboard .technical-panel,
  #dashboard .grid.two {
    display: none !important;
  }

  #clienteArquivosPanel {
    display: none !important;
  }
}

.info-list {
  padding: 8px 16px 14px;
  display: grid;
  gap: 10px;
}

.info-list div {
  border-bottom: 1px solid #edf2f7;
  padding: 10px 0;
}

.info-list div:last-child {
  border-bottom: 0;
}

.info-list strong,
.info-list span {
  display: block;
}

.info-list span {
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.45;
}

.sync-status-card {
  margin: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #f8fafc;
}

.sync-status-card.ok {
  background: #ecfdf3;
  border-color: #abefc6;
}

.sync-status-card.warn {
  background: #fffaeb;
  border-color: #fedf89;
}

.sync-status-card strong,
.sync-status-card span {
  display: block;
}

.sync-status-card strong {
  font-size: 18px;
  margin-bottom: 6px;
}

.sync-status-card span {
  color: var(--muted);
  line-height: 1.45;
}

.simple-list strong {
  font-size: 14px;
}

.technical-details {
  margin-top: 16px;
}

.technical-details summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
  padding: 10px 2px;
}

.compact-info {
  padding-top: 2px;
}

@media (max-width: 680px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }
}

/* Navegacao operacional por areas */
.sidebar-menu-search {
  padding: 2px 2px 10px;
}

.sidebar-menu-search input {
  width: 100%;
  height: 42px;
  padding: 0 12px 0 36px;
  border: 1px solid rgba(203, 213, 225, 0.18);
  border-radius: 10px;
  color: #f8fafc;
  background:
    linear-gradient(90deg, transparent 0 33px, rgba(203, 213, 225, 0.12) 33px 34px, transparent 34px),
    #18232f;
  font: inherit;
  font-size: 13px;
}

.sidebar-menu-search::before {
  content: "⌕";
  position: absolute;
  margin: 9px 0 0 12px;
  color: #aebdcd;
  font-size: 19px;
  pointer-events: none;
}

.sidebar-menu-search input::placeholder {
  color: #94a3b8;
}

.sidebar-menu-search input:focus {
  border-color: #60a5fa;
  outline: 2px solid rgba(96, 165, 250, 0.18);
}

.nav-group {
  display: grid;
  gap: 4px;
  padding: 3px;
  border: 1px solid transparent;
  border-radius: 11px;
}

.nav-group:has(.nav-item.active) {
  border-color: rgba(96, 165, 250, 0.24);
  background: rgba(30, 64, 175, 0.1);
}

.nav-group-toggle {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #aebdcd;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
}

.nav-group-toggle:hover,
.nav-group-toggle:focus-visible {
  background: #22303e;
  color: #ffffff;
  outline: none;
}

.nav-group-toggle[aria-expanded="true"] {
  color: #ffffff;
  background: rgba(51, 65, 85, 0.72);
}

.nav-group-symbol {
  font-size: 18px;
  line-height: 1;
  color: #dbe4ee;
}

.nav-group-items {
  display: grid;
  gap: 3px;
}

.nav-group-items .nav-item {
  width: 100%;
  padding: 11px 12px 11px 17px;
  min-height: 44px;
  font-size: 14px;
  border-radius: 8px;
  text-align: left;
}

.nav-group-items .nav-item.active {
  position: relative;
  color: #ffffff;
  background: #2563eb;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.24);
}

.nav-group-items .nav-item.active::before {
  content: "";
  position: absolute;
  inset: 10px auto 10px 6px;
  width: 3px;
  border-radius: 4px;
  background: #bfdbfe;
}

.global-search {
  flex: 1 1 390px;
  max-width: 620px;
  min-width: 280px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 8px;
}

.global-search input {
  width: 100%;
  min-width: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  flex-wrap: wrap;
}

.advanced-filters {
  padding: 12px 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.advanced-filters label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.advanced-filters select {
  width: 100%;
  min-width: 0;
}

#clientTablePanel > .panel-head.stacked {
  align-items: stretch;
  flex-direction: column;
}

#clientTablePanel > .panel-head .filters {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) repeat(3, minmax(165px, 1fr)) auto;
  width: 100%;
}

#clientesTable {
  min-width: 1280px;
}

@media (min-width: 769px) {
  #clientesTable th:nth-child(1),
  #clientesTable td:nth-child(1) {
    position: sticky;
    left: 0;
    width: 90px;
    min-width: 90px;
    background: #ffffff;
    z-index: 2;
  }

  #clientesTable th:nth-child(2),
  #clientesTable td:nth-child(2) {
    position: sticky;
    left: 90px;
    min-width: 220px;
    max-width: 270px;
    background: #ffffff;
    z-index: 2;
    box-shadow: 7px 0 9px -10px #475467;
  }

  #clientesTable th:last-child,
  #clientesTable td:last-child {
    position: sticky;
    right: 0;
    min-width: 235px;
    background: #ffffff;
    z-index: 2;
    box-shadow: -7px 0 9px -10px #475467;
  }

  #clientesTable th:nth-child(1),
  #clientesTable th:nth-child(2),
  #clientesTable th:last-child {
    background: #f8fafc;
    z-index: 4;
  }

  #clientesTable tbody tr:hover td {
    background: #f8fbff;
  }

  #clientesTable th:nth-child(3),
  #clientesTable td:nth-child(3) {
    min-width: 190px;
  }

  #clientesTable th:nth-child(4),
  #clientesTable td:nth-child(4) {
    min-width: 125px;
  }

  #clientesTable th:nth-child(5),
  #clientesTable td:nth-child(5) {
    min-width: 95px;
  }
}

.priority-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.priority-urgent {
  color: #9f1c13;
  background: #fee4e2;
}

.priority-high {
  color: #854a0e;
  background: #fff1c2;
}

.priority-review {
  color: #175cd3;
  background: #eaf2ff;
}

.priority-normal {
  color: #067647;
  background: #dcfae6;
}

.priority-locked {
  color: #475467;
  background: #eaecf0;
}

.compact-client-info {
  display: none;
}

.client-row-actions,
.agreement-row-actions {
  min-width: 0;
  align-items: flex-start;
}

.action-whatsapp {
  background: #137a4d;
}

.conversa-ver-completa {
  background: #137a4d;
}

.conversa-ver-completa:hover {
  background: #0f5f3c;
}

.action-call {
  background: #1f6feb;
}

.row-action-menu {
  min-width: 72px;
}

.row-action-menu summary {
  list-style: none;
}

.row-action-menu summary::-webkit-details-marker {
  display: none;
}

.row-more-summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  background: #475467;
  color: #ffffff;
  cursor: pointer;
}

.row-action-menu[open] .row-more-summary {
  background: #344054;
}

.row-action-menu-content {
  display: grid;
  gap: 6px;
  margin-top: 6px;
  min-width: 180px;
}

.row-action-menu-content .small-btn,
.row-action-menu-content .danger-btn,
.row-action-menu-content .paid-btn {
  width: 100%;
  min-height: 42px;
  text-align: center;
}

.client-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(15, 23, 42, 0.5);
}

.password-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(15, 23, 42, 0.5);
  display: grid;
  place-items: center;
  padding: 24px;
}

.password-modal-box {
  width: min(100%, 460px);
  margin: 0;
}

.password-modal-box .form-error {
  grid-column: span 2;
  min-height: 0;
  margin: 0;
  color: var(--red);
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(15, 23, 42, 0.5);
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
}

.modal-box {
  width: min(100%, 560px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  margin: auto;
}

.modal-box .form-error {
  grid-column: span 2;
  min-height: 0;
  margin: 0;
  color: var(--red);
  font-weight: 700;
}

.client-bill-payment-backdrop { z-index: 240; }
.bill-payment-actions { display: grid; gap: 8px; min-width: 155px; }
.bill-payment-actions summary { cursor: pointer; list-style: none; white-space: nowrap; }
.bill-payment-actions summary::-webkit-details-marker { display: none; }
.bill-payment-actions[open] summary { background: #0f766e; color: #fff; }
.bill-payment-action-list { display: grid; gap: 6px; }
.bill-payment-action-list button { width: 100%; }
.client-section-nav { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px; margin-top: 16px; border: 1px solid var(--border); border-radius: 14px; background: #f8fafc; }
.client-section-btn { border: 1px solid #cbd5e1; border-radius: 999px; background: #fff; color: #334155; padding: 9px 14px; font-weight: 750; cursor: pointer; }
.client-section-btn:hover { border-color: #14b8a6; color: #0f766e; }
.client-section-btn.is-active { border-color: #0f766e; background: #0f766e; color: #fff; box-shadow: 0 6px 16px rgba(15,118,110,.18); }
.client-section-content { margin-top: 16px; }
.client-section-empty { margin: 16px 0 0; padding: 18px; border: 1px dashed #cbd5e1; border-radius: 12px; color: var(--muted); text-align: center; }
.client-action-menu { position: relative; }
.client-action-menu > summary { list-style: none; cursor: pointer; white-space: nowrap; }
.client-action-menu > summary::-webkit-details-marker { display: none; }
.client-action-menu > summary::after { content: '⌄'; margin-left: 7px; }
.client-action-menu[open] > summary::after { content: '⌃'; }
.client-action-menu-list { position: absolute; right: 0; top: calc(100% + 8px); z-index: 8; display: grid; gap: 7px; width: 210px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: #fff; box-shadow: 0 16px 36px rgba(15,23,42,.18); }
.client-action-menu-list button { width: 100%; }
@media (max-width: 720px) { .client-action-menu { position: static; } .client-action-menu-list { left: 12px; right: 12px; width: auto; } }

.compact-filter-details{position:relative;align-self:stretch}
.compact-filter-details>summary{list-style:none;min-height:42px;display:flex;align-items:center;padding:0 16px;border:1px solid var(--border);border-radius:10px;background:#fff;color:var(--text);font-weight:700;cursor:pointer;white-space:nowrap}
.compact-filter-details>summary::-webkit-details-marker{display:none}.compact-filter-details>summary::after{content:'⌄';margin-left:10px;color:var(--muted)}.compact-filter-details[open]>summary{border-color:#14b8a6;color:#0f766e}.compact-filter-details[open]>summary::after{content:'⌃'}
.compact-filter-popover{position:absolute;right:0;top:calc(100% + 8px);z-index:30;width:min(360px,calc(100vw - 40px));padding:16px;border:1px solid var(--border);border-radius:14px;background:#fff;box-shadow:0 18px 44px rgba(15,23,42,.16);display:grid;gap:12px}
.compact-filter-popover label{display:grid;gap:6px;color:var(--muted);font-size:.78rem;font-weight:700}.compact-filter-popover select{width:100%;color:var(--text);font-size:.9rem}
.green-client-btn{background:#15803d!important;border-color:#15803d!important;color:#fff!important}.green-client-btn:hover{background:#166534!important;border-color:#166534!important}.field-assist{display:block;margin-top:5px;color:var(--muted);font-size:.75rem;font-weight:500}.field-assist.is-loading{color:#0369a1}.field-assist.is-success{color:#15803d}.field-assist.is-error{color:#b91c1c}
@media(max-width:720px){.compact-filter-details{width:100%}.compact-filter-details>summary{justify-content:center}.compact-filter-popover{position:static;width:100%;margin-top:8px;box-shadow:none}}

.col-hide {
  display: none;
}

.list-row-clickable {
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.list-row-clickable:hover,
.list-row-clickable:focus-visible {
  background-color: #f1f5f9;
  outline: none;
}

.confirm-action-backdrop { z-index: 3000; }

.conversation-actions-panel {
  display: grid;
  gap: 14px;
}

.conversation-filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.conversation-filter {
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  padding: 9px 15px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.conversation-filter:hover,
.conversation-filter.is-active {
  border-color: #0f766e;
  background: #e6fffb;
  color: #0f766e;
}

.conversation-actions-panel #conversationSearch {
  width: 100%;
}

.confirm-action-box {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 16px;
  width: min(100%, 500px);
  padding: 24px;
  overflow: visible;
}

.confirm-action-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff1ec;
  color: #b42318;
  font-size: 24px;
  font-weight: 900;
}

.confirm-action-content h2 { margin: 2px 0 8px; }

.confirm-action-content p {
  margin: 0;
  color: #475467;
  line-height: 1.55;
  white-space: pre-line;
}

.confirm-action-buttons {
  grid-column: 1 / -1;
  justify-content: flex-end;
  margin-top: 8px;
}

body.modal-open { overflow: hidden; }

.form-section-title {
  margin: 8px 0 0;
  padding: 12px 0 7px;
  border-bottom: 1px solid #d0d5dd;
  color: #123b5d;
  font-size: 15px;
}

.required-label {
  display: inline-block;
  margin-left: 5px;
  color: #b42318;
  font-size: 11px;
  font-weight: 800;
}

.master-client-actions {
  flex-wrap: wrap;
}

.master-client-actions .danger-btn {
  padding: 8px 10px;
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-top: 1px solid #e4e7ec;
  color: #475467;
  font-size: 13px;
  font-weight: 700;
}

.table-pagination > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-pagination button {
  min-height: 40px;
  padding: 8px 12px;
}

.table-pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.management-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
  align-items: end;
  width: 100%;
}

.management-filters label {
  display: grid;
  gap: 6px;
  color: #475467;
  font-size: 12px;
  font-weight: 800;
}

.cash-hero { margin-bottom: 16px; }
.cash-status-banner {
  margin: 0 16px 16px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a5f;
  font-weight: 700;
}
.cash-status-banner.closed { background: #f8fafc; border-color: var(--line); color: var(--muted); }
.cash-status-banner.open { background: #ecfdf3; border-color: #a7f3d0; color: #166534; }
.cash-filters { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
.cash-value-in { color: var(--green); font-weight: 800; }
.cash-value-out { color: #b42318; font-weight: 800; }
.cash-difference { font-weight: 800; }
.cash-difference.negative { color: #b42318; }
.cash-difference.positive { color: var(--amber); }
.receive-hero {
  margin-bottom: 16px;
  background: linear-gradient(135deg, #ffffff 0%, #f2f8f5 100%);
  border-color: #d7e9df;
}
.receive-hero .panel-head { margin-bottom: 10px; }
.receive-main-actions { flex-wrap: wrap; }
.receive-main-actions .receive-action-btn.active {
  color: #ffffff;
  border-color: #127c56;
  background: #127c56;
}
.receive-action-panel {
  margin-bottom: 16px;
  border-top: 4px solid #127c56;
}
#receiveHistoryPanel { border-top-color: #2563eb; }
#receiveHistoryPanel,
#receiveHistoryPanel .table-wrap {
  width: 100%;
  min-width: 0;
}
#receiptsHistoryTable {
  width: 100%;
  min-width: 980px;
  table-layout: auto;
}
#receiptsHistoryTable th:nth-child(2),
#receiptsHistoryTable td:nth-child(2) {
  min-width: 210px;
}
#receiptsHistoryTable th:nth-child(3),
#receiptsHistoryTable td:nth-child(3) {
  min-width: 180px;
}
#receiptsHistoryTable th:first-child,
#receiptsHistoryTable td:first-child,
#receiptsHistoryTable th:nth-child(4),
#receiptsHistoryTable td:nth-child(4),
#receiptsHistoryTable th:nth-child(5),
#receiptsHistoryTable td:nth-child(5),
#receiptsHistoryTable th:nth-child(6),
#receiptsHistoryTable td:nth-child(6) {
  white-space: nowrap;
}
.receive-action-panel[hidden] { display: none; }
#pagamentos .grid.two.payment-work-grid {
  width: 100%;
  grid-template-columns: minmax(0, 1fr);
}

.sms-hero {
  margin-bottom: 16px;
  background: linear-gradient(135deg, #ffffff 0%, #f3f7ff 100%);
  border-color: #d8e4f6;
}

.sms-hero .panel-head {
  margin-bottom: 0;
}

.sms-main-actions {
  flex-wrap: wrap;
}

.sms-main-actions .sms-action-btn.active {
  color: #ffffff;
  border-color: #2563eb;
  background: #2563eb;
}

.sms-action-panel {
  width: 100%;
  margin-top: 0;
  margin-bottom: 16px;
}

.sms-action-panel[hidden] {
  display: none;
}

#smsRegisterPanel,
#smsClientsPanel {
  border-top: 4px solid #2563eb;
}

#smsHistoryPanel {
  border-top: 4px solid #127c56;
}

#smsHistoryPanel table,
#smsClientsPanel table {
  width: 100%;
  min-width: 980px;
}

.sms-client-filters {
  flex-wrap: wrap;
}

#sms .grid.two.sms-action-panel {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.report-main-actions {
  width: 100%;
  flex-wrap: wrap;
}

.report-main-actions .report-panel-btn.active {
  color: #ffffff;
  border-color: #2563eb;
  background: #2563eb;
}

#reportFiltersPanel {
  width: 100%;
  margin-top: 4px;
  padding: 14px;
  border: 1px solid #dbe4ee;
  border-radius: 10px;
  background: #f8fafc;
}

#reportFiltersPanel[hidden],
.report-content-panel[hidden] {
  display: none;
}

.report-content-panel {
  width: 100%;
}

#reportSummaryPanel .management-metrics {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

#reportSummaryPanel .metric {
  min-width: 0;
}

#reportSummaryPanel .metric strong {
  display: block;
  max-width: 100%;
  font-size: clamp(20px, 1.65vw, 27px);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

#reportSummaryPanel .metric small {
  display: block;
  margin-top: 7px;
  line-height: 1.3;
}

#reportGeoPanel,
#reportPerformancePanel {
  margin-top: 16px;
  border-top: 4px solid #2563eb;
}

#reportGeoTable,
#reportPerformanceTable {
  width: 100%;
  min-width: 980px;
}
.receive-steps { display:grid; grid-template-columns:auto 1fr auto 1fr auto 1fr; gap:8px 12px; align-items:center; margin:0 16px 16px; padding:12px 14px; background:#f8fafc; border:1px solid var(--line); border-radius:8px; }
.receive-steps strong { color:#1f6feb; }
.receive-steps span { color:var(--muted); font-size:13px; }
.receivable-results { display:grid; gap:10px; padding:0 16px 16px; }
.receivable-card { display:grid; grid-template-columns:minmax(180px,1.5fr) minmax(110px,.7fr) minmax(100px,.6fr) auto; gap:12px; align-items:center; padding:14px; border:1px solid var(--line); border-radius:8px; background:var(--panel); }
.receivable-card small { display:block; color:var(--muted); margin-top:4px; }
.receivable-card .overdue { color:#b42318; font-weight:700; }

.agent-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:12px}.agent-card{border:1px solid var(--border);border-radius:14px;padding:14px;background:var(--surface);text-align:left;cursor:pointer;transition:.18s}.agent-card:hover,.agent-card.active{border-color:var(--primary);box-shadow:0 0 0 2px color-mix(in srgb,var(--primary) 16%,transparent)}.agent-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px}.agent-card h3{margin:0 0 6px}.agent-card p{margin:0;color:var(--muted);font-size:.9rem}.agent-card footer{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px;font-size:.78rem}.training-list{display:grid;gap:8px;max-height:360px;overflow:auto}.training-item{border:1px solid var(--border);border-radius:10px;padding:10px}.training-item strong,.training-item small{display:block}.training-item p{white-space:pre-wrap;margin:6px 0 0}.ai-test-result{margin-top:16px;padding:18px;border:1px solid var(--border);border-left:4px solid var(--primary);border-radius:10px;background:var(--surface-soft);white-space:pre-wrap;line-height:1.55}.grow{flex:1;min-width:240px}
#agentesia.view.active{display:block;position:fixed;inset:0;z-index:1200;overflow-y:auto;background:rgba(15,23,42,.72);backdrop-filter:blur(4px);padding:24px max(20px,calc((100vw - 1500px)/2));animation:modalFadeIn .18s ease}#agentesia.view.active>.panel,#agentesia.view.active>.grid{max-width:1450px;margin-left:auto;margin-right:auto}#agentesia.view.active>.metrics-grid{max-width:1450px;margin:0 auto 14px}#agentesia.view.active>.panel{box-shadow:0 18px 60px rgba(0,0,0,.25)}body:has(#agentesia.view.active){overflow:hidden}@media(max-width:720px){#agentesia.view.active{padding:10px}.agent-grid{grid-template-columns:1fr}#agentesia.view.active>.metrics-grid{grid-template-columns:repeat(2,1fr)}}

#iawhatsapp.view.active{display:block;position:fixed;inset:0;z-index:1190;overflow-y:auto;background:rgba(15,23,42,.74);backdrop-filter:blur(5px);padding:24px max(20px,calc((100vw - 1540px)/2));animation:modalFadeIn .18s ease}
#iawhatsapp.view.active>.panel,#iawhatsapp.view.active>.grid,#iawhatsapp.view.active>.metrics-grid{max-width:1490px;margin-left:auto;margin-right:auto}
#iawhatsapp.view.active>.panel{box-shadow:0 18px 60px rgba(0,0,0,.22)}
#iawhatsapp .ia-modal-header{position:sticky;top:0;z-index:4;margin-bottom:14px;border-color:rgba(20,184,166,.35);background:linear-gradient(135deg,#f8fffe 0%,#effcf9 100%)}
.ia-modal-header .panel-head{margin-bottom:0}.ia-modal-eyebrow{display:block;margin-bottom:5px;color:#0f766e;font-size:.75rem;font-weight:800;letter-spacing:.08em;text-transform:uppercase}
body:has(#iawhatsapp.view.active){overflow:hidden}
.ia-suggestions-hub{min-height:min(620px,calc(100vh - 180px));display:flex;flex-direction:column;justify-content:center}
.ia-hub-grid{display:grid;grid-template-columns:repeat(3,minmax(220px,1fr));gap:16px}
.ia-hub-button{appearance:none;border:1px solid #dbe7e5;border-radius:18px;background:#fff;padding:22px;text-align:left;color:var(--text);cursor:pointer;display:flex;flex-direction:column;gap:8px;min-height:180px;box-shadow:0 7px 24px rgba(15,23,42,.06);transition:transform .16s ease,border-color .16s ease,box-shadow .16s ease}
.ia-hub-button:hover{transform:translateY(-3px);border-color:#14b8a6;box-shadow:0 14px 34px rgba(15,118,110,.14)}
.ia-hub-button.is-priority{background:linear-gradient(145deg,#effcf9,#fff);border-color:#5eead4}.ia-hub-button strong{font-size:1.05rem}.ia-hub-button small{color:var(--muted);line-height:1.45}.ia-hub-button b{margin-top:auto;color:#0f766e}.ia-hub-icon{font-size:1.65rem;line-height:1}
#iawhatsapp [data-ia-pane]{display:none}#iawhatsapp [data-ia-pane].is-active{display:grid}#iawhatsapp section[data-ia-pane].is-active{display:block}
@media(max-width:720px){#iawhatsapp.view.active{padding:10px}#iawhatsapp.view.active>.metrics-grid{grid-template-columns:repeat(2,1fr)}#iawhatsapp .ia-modal-header{top:0}}

.wa-template-composer{padding:12px 16px;border-top:1px solid var(--border-color,#d9e1e8);background:#f8fafc;display:grid;gap:10px}
.wa-template-composer[hidden]{display:none}
.wa-template-composer label{display:grid;gap:5px;font-size:.82rem;font-weight:600}
.wa-template-composer select,.wa-template-composer input{width:100%;padding:9px 10px;border:1px solid #cbd5e1;border-radius:8px;background:#fff}
.wa-template-parameters{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.wa-template-composer .muted{margin:0;white-space:pre-wrap;max-height:100px;overflow:auto}
@media(max-width:720px){.wa-template-parameters{grid-template-columns:1fr}}
.wa-message-image-link{display:block;margin:-3px -3px 8px;overflow:hidden;border-radius:10px;background:#e2e8f0}
.wa-message-image{display:block;width:100%;max-width:360px;max-height:420px;object-fit:contain}
.wa-message-audio{display:block;width:min(330px,100%);margin:7px 0}
.conversation-history-audio{display:block;width:min(300px,100%);margin:0 0 7px}
.conversation-history-image{display:block;width:150px;max-height:130px;object-fit:cover;border-radius:8px;margin:0 0 7px}
@media(max-width:900px){.ia-hub-grid{grid-template-columns:repeat(2,minmax(180px,1fr))}}@media(max-width:560px){.ia-hub-grid{grid-template-columns:1fr}.ia-hub-button{min-height:140px}}

@media (max-width: 720px) {
  .cash-filters { grid-template-columns: 1fr 1fr; }
  .cash-filters button { grid-column: 1 / -1; }
  .cash-hero .row-actions { width: 100%; }
  .cash-hero .row-actions button { flex: 1 1 140px; }
  .receive-steps { grid-template-columns:auto 1fr; }
  .receive-main-actions,
  .receive-main-actions button { width: 100%; }
  .sms-main-actions,
  .sms-main-actions button { width: 100%; }
  .report-main-actions,
  .report-main-actions button { width: 100%; }
  #sms .grid.two.sms-action-panel { grid-template-columns: 1fr; }
  .receivable-card { grid-template-columns:1fr; }
  .receivable-card button { width:100%; }
}

.document-preview { padding:0 16px 18px; max-height:60vh; overflow:auto; }
.document-sheet { background:#fff; color:#111; border:1px solid #d1d5db; padding:28px; line-height:1.6; min-height:360px; }
.signature-lines { display:grid; grid-template-columns:1fr 1fr; gap:50px; margin-top:70px; }
.signature-lines span { border-top:1px solid #111; text-align:center; padding-top:7px; }
@media(max-width:720px){.signature-lines{grid-template-columns:1fr;gap:60px}.document-sheet{padding:18px}}

.management-metrics {
  grid-template-columns: repeat(6, minmax(150px, 1fr));
}

.management-charts .chart-container {
  height: 320px;
}

.text-danger { color: #b42318; font-weight: 800; }

.field-with-quick-add {
  display: flex;
  gap: 6px;
  align-items: center;
}

.field-with-quick-add select {
  flex: 1;
  min-width: 0;
}

.quick-add-btn {
  flex: 0 0 auto;
  width: 44px;
  min-height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.quick-add-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.quick-create-backdrop {
  position: fixed;
  inset: 0;
  z-index: 140;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
}

.quick-create-box {
  width: min(100%, 480px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  margin: auto;
}

.client-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  width: min(760px, 100vw);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #ffffff;
  border-left: 1px solid #cbd5e1;
  box-shadow: -16px 0 40px rgba(15, 23, 42, 0.2);
}

body.client-drawer-open {
  overflow: hidden;
}

.wa-chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1990;
  background: rgba(15, 23, 42, 0.56);
}

.install-app-btn {
  display: none;
}

.install-app-btn.is-visible {
  display: inline-flex;
}

.wa-chat-drawer {
  position: fixed;
  top: 16px;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  width: min(920px, calc(100vw - 32px));
  min-width: 0;
  background: #e8edf1;
  border: 1px solid #cbd5e1;
  border-radius: 18px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.32);
  overflow: hidden;
}

.wa-chat-drawer[hidden],
.wa-chat-backdrop[hidden] {
  display: none;
}

body.wa-chat-open {
  overflow: hidden;
}

.operator-cockpit {
  display: grid;
  grid-template-columns: minmax(220px, .72fr) minmax(380px, 1.5fr) minmax(250px, .88fr);
  min-height: 620px;
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid #d8e0e8;
  border-radius: 16px;
  background: #f3f6f8;
  box-shadow: var(--shadow);
}
.operator-column { min-width: 0; padding: 18px; background: #fff; }
.operator-column + .operator-column { border-left: 1px solid #d8e0e8; }
.operator-column-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.operator-column-head h3 { margin: 2px 0 0; }
.operator-kicker { color: #64748b; font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.operator-count { min-width: 30px; padding: 5px 8px; border-radius: 999px; background: #e8eef5; text-align: center; font-weight: 900; }
.operator-help { margin: -8px 0 14px; color: #64748b; font-size: 13px; }
.operator-agents-list, .operator-conversation-list, .operator-alerts-list { display: grid; gap: 10px; max-height: 540px; overflow-y: auto; }
.operator-agent-card, .operator-conversation-card, .operator-alert-card { width: 100%; padding: 12px; border: 1px solid #dbe3eb; border-radius: 12px; background: #fff; color: inherit; text-align: left; }
.operator-conversation-card { cursor: pointer; }
.operator-conversation-card:hover { border-color: #ef3b6d; background: #fff7fa; transform: translateY(-1px); }
.operator-card-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.operator-card-row small, .operator-card-meta { color: #64748b; }
.operator-card-message { margin: 8px 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.operator-agent-status { width: 9px; height: 9px; border-radius: 50%; background: #22a06b; box-shadow: 0 0 0 4px #dcfce7; }
.operator-alert-card { border-left: 4px solid #d97706; background: #fffbeb; }
.operator-alert-card.is-danger { border-left-color: #dc2626; background: #fff1f2; }
.operator-empty { padding: 18px; border: 1px dashed #cbd5e1; border-radius: 12px; color: #64748b; text-align: center; }
.operator-advanced { margin: 16px 0; }
.operator-advanced > summary { cursor: pointer; color: #475569; font-weight: 800; }
@media (max-width: 980px) {
  .operator-cockpit { grid-template-columns: 1fr; }
  .operator-column + .operator-column { border-left: 0; border-top: 1px solid #d8e0e8; }
  .operator-agents-list, .operator-conversation-list, .operator-alerts-list { max-height: 360px; }
}

.wa-chat-header {
  display: grid;
  grid-template-columns: auto 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 10px 16px;
  color: #ffffff;
  background: #123b5d;
  border-bottom: 1px solid #0b2f4d;
}

.wa-chat-back,
.wa-chat-refresh {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 6px;
  background: transparent;
  color: #ffffff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.wa-chat-back:hover,
.wa-chat-refresh:hover {
  background: rgba(255, 255, 255, 0.12);
}

.wa-chat-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ffffff;
  color: #123b5d;
  font-size: 13px;
  font-weight: 900;
}

.wa-chat-contact {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.wa-chat-contact strong,
.wa-chat-contact span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wa-chat-contact strong {
  font-size: 16px;
}

.wa-chat-contact span {
  color: #dceaf4;
  font-size: 13px;
}

.wa-chat-window-status {
  min-height: 38px;
  padding: 9px 16px;
  border-bottom: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.wa-chat-window-status.is-open {
  color: #12633f;
  background: #e8f7ef;
}

.wa-chat-window-status.is-closed {
  color: #8a341c;
  background: #fff1ec;
}

.wa-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px clamp(12px, 4vw, 52px);
}

.wa-chat-day {
  display: table;
  margin: 12px auto;
  padding: 5px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
}

.wa-message-row {
  display: flex;
  width: 100%;
  margin: 5px 0;
}

.wa-message-row.outgoing {
  justify-content: flex-end;
}

.wa-message-bubble {
  max-width: min(72%, 620px);
  padding: 9px 11px 7px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.08);
}

.wa-message-row.outgoing .wa-message-bubble {
  border-color: #b8d9c3;
  background: #dff4e5;
}

.wa-message-bubble.is-failed {
  border-color: #dc6b60;
  background: #fff0ee;
}

.wa-audio-label {
  display: block;
  margin-bottom: 5px;
  color: #12633f;
  font-size: 11px;
  font-weight: 800;
}

.wa-message-text {
  margin: 0;
  color: #17202a;
  line-height: 1.42;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.wa-message-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
  color: #64748b;
  font-size: 11px;
}

.wa-message-operator {
  margin-right: auto;
  font-weight: 700;
}

.wa-message-status {
  font-weight: 800;
}

.wa-message-status.is-read,
.wa-message-status.is-delivered {
  color: #12633f;
}

.wa-chat-empty {
  max-width: 460px;
  margin: 48px auto;
  padding: 18px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #475569;
  text-align: center;
}

.wa-chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid #cbd5e1;
  background: #ffffff;
}

.wa-chat-toolbar {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.wa-chat-toolbar .small-btn {
  min-width: 0;
  padding: 8px 10px;
  background: #f1f5f9;
  color: #334155;
}

.wa-chat-toolbar .small-btn:hover {
  background: #e2e8f0;
}

.wa-emoji-popover {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
  width: min(320px, 100%);
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
}

.wa-emoji-item {
  border: 0;
  background: transparent;
  font-size: 20px;
  min-height: 0;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
}

.wa-emoji-item:hover {
  background: #f1f5f9;
}

.wa-chat-attachment-preview {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
}

.wa-attachment-chip {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

.wa-message-document {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #123b5d;
  font-weight: 700;
  text-decoration: none;
}

.wa-chat-composer textarea {
  width: 100%;
  min-height: 48px;
  max-height: 144px;
  resize: vertical;
}

.wa-chat-composer button {
  min-width: 128px;
  min-height: 48px;
  font-weight: 800;
}

.wa-chat-send-column {
  display: grid;
  justify-items: end;
  gap: 3px;
}

.wa-chat-send-column small {
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
}

.wa-chat-composer textarea:disabled,
.wa-chat-composer button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.client-drawer > .panel {
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  border-bottom: 8px solid #edf2f7;
}

.client-drawer .client-detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.client-drawer .panel-head {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #ffffff;
}

.client-drawer #clienteArquivosPanel .panel-head,
.client-drawer #clienteBoletosPanel .panel-head {
  position: static;
}

#agreementsTable {
  min-width: 1020px;
}

.agreements-hero {
  margin-bottom: 14px;
  background: linear-gradient(135deg, #ffffff 0%, #f3f7ff 100%);
  border-color: #d8e4f6;
}

.agreements-hero .panel-head {
  margin-bottom: 0;
}

.agreement-create-panel {
  border-top: 4px solid #2563eb;
}

.agreement-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  flex-wrap: wrap;
}

.agreement-toolbar > input {
  flex: 1 1 280px;
  min-width: 220px;
}

.agreement-quick-filters {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: thin;
}

.agreement-quick-filters .filter-chip {
  flex: 0 0 auto;
}

.agreement-advanced-filters {
  width: 100%;
  padding: 12px;
  border: 1px solid #e1e7ef;
  border-radius: 10px;
  background: #f8fafc;
}

.agreement-advanced-filters[hidden],
.agreement-create-panel[hidden] {
  display: none;
}

#acordos > .grid.two {
  grid-template-columns: 1fr;
}

@media (min-width: 1181px) {
  #agreementForm {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .agreements-hero .row-actions,
  .agreements-hero .row-actions button {
    width: 100%;
  }

  .agreement-toolbar {
    align-items: stretch;
  }

  .agreement-toolbar > input {
    width: 100%;
  }
}

.agreement-progress {
  width: 120px;
  height: 7px;
  margin-top: 7px;
  overflow: hidden;
  border-radius: 4px;
  background: #e4e7ec;
}

.agreement-progress span {
  display: block;
  height: 100%;
  background: #127c56;
}

.date-overdue strong {
  color: var(--red);
}

@media (max-width: 1500px) {
  #clientesTable {
    min-width: 1000px;
  }

  #clientesTable th:nth-child(6),
  #clientesTable td:nth-child(6),
  #clientesTable th:nth-child(7),
  #clientesTable td:nth-child(7) {
    display: none;
  }

  .compact-client-info {
    display: block;
  }
}

@media (max-width: 1180px) {
  .management-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .management-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .advanced-filters {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  #clientTablePanel > .panel-head .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .global-search {
    order: 3;
    max-width: none;
    flex-basis: 100%;
  }
}

@media (max-width: 980px) {
  nav {
    grid-template-columns: 1fr;
  }

  .nav-group {
    min-width: 0;
  }
}

@media (max-width: 768px) {
  .management-filters,
  .management-metrics { grid-template-columns: 1fr; }
  .table-pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .table-pagination > div {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
  }

  .modal-backdrop,
  .password-modal-backdrop,
  .quick-create-backdrop {
    align-items: end;
    padding: 12px;
  }

  .modal-box,
  .password-modal-box,
  .quick-create-box {
    width: 100%;
    max-height: calc(100dvh - 24px);
  }

  .confirm-action-box {
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 12px;
    padding: 20px;
  }

  .confirm-action-icon {
    width: 42px;
    height: 42px;
  }

  .confirm-action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .confirm-action-buttons button {
    width: 100%;
    min-height: 46px;
  }

  .global-search {
    min-width: 0;
    grid-template-columns: 1fr;
  }

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

  #clientTablePanel > .panel-head .filters {
    grid-template-columns: 1fr;
  }

  #clientesTable,
  #agreementsTable {
    min-width: 0;
  }

  .client-row-actions,
  .agreement-row-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .client-row-actions .row-action-menu,
  .agreement-row-actions .row-action-menu {
    width: 100%;
  }

  .row-action-menu-content {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .client-drawer {
    width: 100vw;
    border-left: 0;
  }

  .wa-chat-drawer {
    top: 0;
    left: 0;
    bottom: 0;
    transform: none;
    width: 100vw;
    border: 0;
    border-radius: 0;
  }

  .wa-chat-header {
    grid-template-columns: auto 40px minmax(0, 1fr);
    gap: 8px;
    padding: 8px 10px;
  }

  .wa-chat-refresh {
    grid-column: 1 / -1;
    width: 100%;
  }

  .wa-chat-messages {
    padding: 14px 10px;
  }

  .wa-message-bubble {
    max-width: 88%;
  }

  .wa-chat-composer {
    grid-template-columns: minmax(0, 1fr) 88px;
    gap: 8px;
    padding: 10px;
  }

  .client-drawer .client-detail-grid {
    grid-template-columns: 1fr;
  }

  .client-drawer .panel-head .row-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .client-drawer .panel-head .row-actions > * {
    width: 100%;
  }

  #clientesTable td,
  #clientesTable td:last-child {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    align-items: start;
    justify-content: normal;
    gap: 4px 10px;
    text-align: left;
  }

  #clientesTable td::before {
    grid-column: 1;
    grid-row: 1;
    max-width: none;
    text-align: left;
  }

  #clientesTable td > * {
    grid-column: 2;
    min-width: 0;
    max-width: 100%;
    text-align: left;
    overflow-wrap: anywhere;
  }

  #clientesTable .client-row-meta {
    width: 100%;
    text-align: left;
  }

  #clientesTable .client-row-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.agent-operation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.agent-operation-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border, #d9e2ea);
  border-radius: 12px;
  background: var(--surface, #fff);
}
.agent-operation-card strong,.agent-operation-card small { display:block; }
.agent-operation-card small { color:var(--muted, #65717c); margin-top:3px; }
.status-dot { width:10px; height:10px; border-radius:50%; background:#9aa4ad; box-shadow:0 0 0 4px rgba(154,164,173,.14); }
.status-dot.is-online { background:#1f9d63; box-shadow:0 0 0 4px rgba(31,157,99,.14); }
.agent-operations-panel .cash-status-banner { margin: 8px 0 14px; }
.agent-return-metrics {
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
}
.agent-return-metrics .metric strong {
  font-size: clamp(20px, 1.7vw, 27px);
  overflow-wrap: anywhere;
}

/* Responsividade global do sistema */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

main,
.view,
.panel,
.grid,
.panel-head,
.table-wrap {
  min-width: 0;
  max-width: 100%;
}

.panel-head > div,
.row-actions,
.filters,
.form-actions {
  min-width: 0;
}

.panel-head h1,
.panel-head h2,
.panel-head h3,
.panel-head p,
td,
th {
  overflow-wrap: anywhere;
}

img,
canvas,
video {
  max-width: 100%;
}

@media (max-width: 1280px) {
  .metrics-grid:not(.mini-metrics) {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }

  .panel-head.stacked {
    gap: 12px;
  }

  .panel-head.stacked > .row-actions,
  .panel-head.stacked > .filters {
    width: 100%;
  }
}

@media (max-width: 768px) {
  main {
    width: 100%;
    padding: 12px;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 14px;
  }

  .topbar > div,
  .topbar-actions,
  .row-actions,
  .form-actions {
    width: 100%;
  }

  .topbar-actions > button,
  .panel-head.stacked > .row-actions > button,
  .panel-head.stacked > .row-actions > a,
  .form-actions > button,
  .form-actions > a {
    flex: 1 1 150px;
  }

  .panel-head {
    padding: 12px;
  }

  .panel-head h2 {
    font-size: 19px;
  }

  .form-grid,
  #agreementForm {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .form-grid .span-2,
  .form-grid .span-3,
  .form-grid .span-4 {
    grid-column: 1 !important;
  }

  .filters,
  .management-filters,
  .advanced-filters {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .filters > *,
  .management-filters > *,
  .advanced-filters > * {
    width: 100%;
    min-width: 0;
  }

  .table-wrap,
  .table-wrap.compact {
    width: 100%;
    max-height: none;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }

  table {
    font-size: 13px;
  }

  th,
  td {
    padding: 10px;
  }

  #telefones .table-wrap {
    overflow: visible;
  }

  #telefones table,
  #telefones tbody {
    display: block;
    width: 100%;
  }

  #telefones thead {
    display: none;
  }

  #telefones tbody tr {
    display: grid;
    gap: 10px;
    margin: 0 0 12px;
    padding: 14px;
    border: 1px solid #d7dee8;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 3px 12px rgba(15, 23, 42, 0.07);
  }

  #telefones tbody td {
    display: grid;
    grid-template-columns: minmax(90px, 34%) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 0;
    border: 0;
    text-align: left;
  }

  #telefones tbody td::before {
    content: attr(data-label);
    color: #64748b;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
  }

  #telefones tbody td.col-hide {
    display: grid !important;
  }

  #telefones .phone-form,
  #telefones .phone-input-label,
  #telefones .contact-source,
  #telefones .phone-row-actions {
    width: 100%;
    min-width: 0;
  }

  #telefones .phone-row-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  #telefones .phone-row-actions button {
    width: 100%;
    min-height: 46px;
  }

  .modal-box,
  .password-modal-box,
  .quick-create-box {
    max-width: 100%;
    border-radius: 14px 14px 0 0;
  }

  .chart-container,
  .management-charts .chart-container {
    height: 240px;
  }
}

@media (max-width: 520px) {
  main {
    padding: 8px;
  }

  .compact-metrics,
  .management-metrics,
  #reportSummaryPanel .management-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .metric,
  .compact-metrics .metric {
    min-height: 86px;
    padding: 12px;
  }

  .metric strong,
  .compact-metrics .metric strong,
  #reportSummaryPanel .metric strong {
    font-size: 19px;
  }

  .metric span {
    margin-bottom: 8px;
    font-size: 12px;
  }

  .row-actions > button,
  .row-actions > a,
  .form-actions > button,
  .form-actions > a {
    width: 100%;
  }

  .global-search,
  .search-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .toast {
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
  }
}
