:root,
[data-theme='dark'] {
  --bg: #0a0f1c;
  --topbar: #18233a;
  --surface: #0f1729;
  --surface-2: #131c30;
  --surface-3: #1a2440;
  --input: #0d1426;
  --border: #1d2840;
  --border-strong: #2a3756;
  --text: #e8edf5;
  --text-2: #c3cbd9;
  --muted: #8b95a7;
  --accent: #3d6fe0;
  --accent-hover: #4a7cf0;
  --accent-soft: rgba(61, 111, 224, 0.14);
  --nav-active: #2b3b5e;
  --danger: #e5484d;
  --success: #2fb36d;
  --warning: #e3a008;
  --kbd: #0b1220;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --radius: 6px;
  --radius-sm: 4px;
  color-scheme: dark;
}

[data-theme='light'] {
  --bg: #eef1f6;
  --topbar: #18233a;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --surface-3: #edf1f7;
  --input: #ffffff;
  --border: #dfe4ec;
  --border-strong: #c9d1de;
  --text: #141b2b;
  --text-2: #364156;
  --muted: #687389;
  --accent: #2f5fd0;
  --accent-hover: #2a55bb;
  --accent-soft: rgba(47, 95, 208, 0.1);
  --nav-active: #2b3b5e;
  --kbd: #0b1220;
  --shadow: 0 12px 32px rgba(20, 27, 43, 0.14);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.ico {
  width: 16px;
  height: 16px;
  flex: none;
}

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

.small {
  font-size: 12px;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

kbd {
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  background: var(--kbd);
  color: #fff;
  border-radius: 4px;
  padding: 2px 5px;
}

/* ---------- Topbar ---------- */
#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 52px;
  background: var(--topbar);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 18px;
  flex: none;
  color: #dfe6f2;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  min-width: 150px;
  color: #fff;
}

.brand-lg {
  font-size: 18px;
  margin-bottom: 28px;
}

.mainnav {
  display: flex;
  gap: 4px;
  align-items: center;
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  background: none;
  border: 0;
  color: #d5dce8;
}

.nav-item .ico {
  width: 15px;
  height: 15px;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.active {
  background: var(--nav-active);
  color: #fff;
  font-weight: 700;
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #222d45;
  border: 0;
  border-radius: var(--radius);
  padding: 8px 10px 8px 12px;
  color: #c9d2e0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-right: 10px;
}

.search-trigger span {
  margin-right: 6px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: none;
  border: 0;
  color: inherit;
  position: relative;
  flex: none;
}

.icon-btn:hover {
  background: rgba(127, 143, 170, 0.14);
}

.icon-btn.danger:hover {
  color: var(--danger);
}

.topbar .icon-btn {
  color: #cfd7e4;
}

.icon-btn .ico {
  width: 17px;
  height: 17px;
}

.bell-badge {
  position: absolute;
  top: 1px;
  right: 0;
  background: #d61f26;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  border-radius: 9px;
  min-width: 18px;
  height: 17px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--topbar);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #05070d;
  color: #fff;
  border: 0;
  font-size: 19px;
  font-weight: 700;
  margin-left: 8px;
}

/* ---------- Área de conteúdo ---------- */
.view {
  flex: 1;
  padding: 14px 14px 14px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.page {
  flex: 1;
  padding: 22px 24px;
  min-height: 0;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: 20px;
}

.page-sub {
  color: var(--muted);
  margin: 4px 0 0;
  font-size: 13px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Botões e campos ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--muted);
}

.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-danger:disabled {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

.btn-ghost {
  background: none;
  border-color: transparent;
}

.btn-sm {
  height: 28px;
  padding: 0 9px;
}

.btn-block {
  width: 100%;
  height: 38px;
}

.btn .ico {
  width: 15px;
  height: 15px;
}

.link-btn {
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 0;
}

.input {
  width: 100%;
  height: 34px;
  background: var(--input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0 10px;
  font: inherit;
}

textarea.input {
  height: auto;
  padding: 8px 10px;
  resize: vertical;
}

.input::placeholder {
  color: var(--muted);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
}

.input.invalid {
  border-color: var(--danger);
}

.input-sm {
  height: 32px;
  width: auto;
  min-width: 140px;
}

.input-color {
  padding: 2px;
  width: 60px;
}

select.input {
  padding-right: 6px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box .ico {
  position: absolute;
  left: 10px;
  color: var(--muted);
  pointer-events: none;
}

.search-box .input {
  padding-left: 32px;
  min-width: 220px;
}

.search-lg .input {
  height: 42px;
  font-size: 15px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.field.full,
.check.full {
  grid-column: 1 / -1;
}

.req {
  color: var(--danger);
  margin-left: 2px;
}

.help {
  color: var(--muted);
  font-size: 11px;
}

.field-error {
  color: var(--danger);
  font-size: 11px;
}

.form-error {
  color: var(--danger);
  margin: 0;
  font-size: 12px;
}

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

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

/* ---------- Tabelas ---------- */
.table-wrap {
  overflow: auto;
}

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

.table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-2);
  font-size: 13px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:hover {
  background: var(--surface-2);
}

.table .right {
  text-align: right;
}

.actions-col {
  width: 1%;
  white-space: nowrap;
}

.row-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
}

.row-actions .icon-btn {
  width: 30px;
  height: 30px;
}

.list-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px 0;
}

/* ---------- Badges, etiquetas, avatares ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  white-space: nowrap;
}

.badge-blue {
  background: var(--accent-soft);
  border-color: rgba(61, 111, 224, 0.4);
  color: #8eaaf0;
}

.badge-green {
  background: rgba(47, 179, 109, 0.12);
  border-color: rgba(47, 179, 109, 0.4);
  color: #4fcf8a;
}

.badge-red {
  background: rgba(229, 72, 77, 0.12);
  border-color: rgba(229, 72, 77, 0.4);
  color: #f07a7e;
}

.badge-yellow {
  background: rgba(227, 160, 8, 0.12);
  border-color: rgba(227, 160, 8, 0.4);
  color: #f0c050;
}

.badge-new {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0 6px;
  height: 14px;
  border-color: #34477a;
  color: #8ea4d6;
  background: rgba(61, 111, 224, 0.1);
}

.tag {
  --c: #3d6fe0;
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 10px;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
  margin: 1px 4px 1px 0;
  white-space: nowrap;
}

.tag-select {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-option {
  --c: #3d6fe0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 3px 9px 3px 6px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
  color: var(--c);
  cursor: pointer;
}

.tag-option input {
  margin: 0;
  accent-color: var(--c);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #111a2d;
  border: 1px solid var(--border-strong);
  color: #8eaaf0;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  object-fit: cover;
  flex: none;
  overflow: hidden;
}

[data-theme='light'] .avatar {
  background: #e8edf7;
  color: #2f5fd0;
}

.avatar-lg {
  width: 40px;
  height: 40px;
  font-size: 14px;
}

.type-badge {
  font-size: 9px;
  font-weight: 500;
  color: #8eaaf0;
  background: rgba(61, 111, 224, 0.16);
  border-radius: 8px;
  padding: 2px 6px;
}

/* ---------- Estados ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  padding: 60px 20px;
  text-align: center;
}

.empty p {
  margin: 0;
  font-size: 14px;
}

.empty-ico {
  width: 40px;
  height: 40px;
  stroke-width: 1.4;
  opacity: 0.7;
}

.loading {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 40px;
}

.loading span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: pulse 1s infinite ease-in-out;
}

.loading span:nth-child(2) {
  animation-delay: 0.15s;
}

.loading span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.25;
  }
  50% {
    opacity: 1;
  }
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}

.toast {
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 380px;
  transition: opacity 0.3s, transform 0.3s;
}

.toast-success {
  border-left-color: var(--success);
}

.toast-error {
  border-left-color: var(--danger);
}

.toast.out {
  opacity: 0;
  transform: translateY(6px);
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 14, 0.6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 7vh 16px 16px;
  z-index: 50;
  overflow: auto;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  width: 100%;
  max-width: 620px;
  box-shadow: var(--shadow);
}

.modal.sm {
  max-width: 420px;
}

.modal.lg {
  max-width: 860px;
}

.modal.modules {
  max-width: 1000px;
  border-radius: 0;
}

.modal.palette {
  max-width: 560px;
}

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

.modal-head h2 {
  font-size: 15px;
}

.modal-body {
  padding: 16px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.confirm-text {
  margin: 0;
  font-size: 14px;
}

.modules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 2.1fr;
  gap: 14px;
}

.module-col h3 {
  font-size: 12px;
  font-weight: 700;
  padding: 6px 8px;
  background: var(--surface-2);
  margin-bottom: 6px;
}

.module-sub {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.module-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 8px;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13px;
}

.module-link:hover {
  background: var(--surface-2);
}

.module-link.active {
  background: var(--surface-3);
  color: #6f97f2;
  font-weight: 650;
}

.palette-results h4 {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 14px 4px 6px;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: var(--radius);
}

.palette-item:hover,
.palette-item:focus {
  background: var(--surface-2);
}

.palette-item small {
  margin-left: auto;
  color: var(--muted);
}

.palette-empty {
  padding: 18px 4px;
}

/* ---------- Dropdown ---------- */
.dropdown {
  position: fixed;
  z-index: 60;
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.dd-body {
  max-height: 420px;
  overflow: auto;
}

.dd-empty {
  padding: 18px 14px;
  margin: 0;
}

.dd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: 0;
  padding: 10px 14px;
  text-align: left;
}

.dd-item:hover {
  background: var(--surface-2);
}

.notif {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.notif span {
  color: var(--text-2);
  font-size: 12px;
}

.notif small {
  color: var(--muted);
  font-size: 11px;
}

.notif.unread {
  background: var(--accent-soft);
}

/* ---------- Login ---------- */
.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h1 {
  font-size: 22px;
}

.login-card p {
  margin: -8px 0 6px;
}

/* ---------- Dashboard: lista ---------- */
.dash-page {
  padding: 26px 32px 40px;
  overflow: auto;
}

.dash-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.dash-top h1 {
  font-size: 22px;
}

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

.dash-search .search-box .input {
  height: 32px;
  width: 224px;
  background: transparent;
  font-size: 14px;
}

.dash-inner {
  max-width: 1150px;
  margin: 0 auto;
}

.dash-intro {
  color: var(--text-2);
  font-size: 14px;
  margin: 24px 0 32px;
}

.dash-section {
  margin-bottom: 30px;
}

.dash-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 14px;
}

.dash-section-title strong {
  font-weight: 700;
}

.dash-section-title span {
  color: var(--muted);
}

.dash-section-title .ico {
  color: var(--text-2);
}

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 48px;
}

.dash-item {
  display: flex;
  gap: 16px;
  padding: 18px 8px 20px;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius);
  align-items: flex-start;
}

.dash-item:hover {
  background: var(--surface-2);
}

.dash-item-ico {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-3);
  color: #8eaaf0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  margin-top: 2px;
}

.dash-item h3 {
  font-size: 14px;
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dash-item .q {
  font-size: 12px;
  font-weight: 650;
  margin: 4px 0 6px;
}

.dash-item .d {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  line-height: 1.65;
}

.dash-empty {
  color: var(--muted);
  padding: 30px 0;
}

/* ---------- Dashboard: visualização ---------- */
.dash-view-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.dash-view-head h1 {
  font-size: 20px;
}

.dash-filters {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.dash-filters .input {
  width: auto;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}

.kpi-label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.kpi-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.dash-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: 14px;
}

.dash-block {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  min-width: 0;
}

.dash-block h2 {
  font-size: 14px;
  margin-bottom: 10px;
}

.dash-block .table th,
.dash-block .table td {
  padding: 8px 8px;
  font-size: 12px;
}

.dash-block .empty {
  padding: 26px 10px;
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 30%) 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}

.bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
}

.bar-track {
  height: 10px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
}

.bar-fill {
  --w: 0%;
  display: block;
  width: var(--w);
  height: 100%;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}

.bar-row:hover .bar-fill {
  background: var(--accent-hover);
}

.bar-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.tv-mode .kpi-value {
  font-size: 40px;
}

.tv-mode .table td {
  font-size: 16px;
  padding: 12px 10px;
}

/* ---------- Atendimento ---------- */
.chat-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 8px;
  min-height: 0;
  height: calc(100vh - 80px);
  grid-template-rows: minmax(0, 1fr);
}

.chat-layout > * {
  min-height: 0;
  overflow: hidden;
}

.chat-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 0 8px;
}

.chat-side-top {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 0 12px;
}

.chat-side-top .search-box {
  flex: 1;
}

.chat-side-top .search-box .input {
  min-width: 0;
  height: 32px;
  font-size: 12px;
}

.btn-square {
  width: 32px;
  height: 32px;
  padding: 0;
}

.chat-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 10px 12px 6px;
}

.chat-tab {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  background: none;
  border: 0;
  padding: 5px 8px;
  border-radius: var(--radius);
  color: var(--muted);
}

.chat-tab .ico {
  width: 15px;
  height: 15px;
}

.chat-tab.active {
  background: var(--surface-3);
  color: #8eaaf0;
}

.chat-tab-monitor {
  margin-left: auto;
}

.chat-tab-monitor.active {
  color: #8eaaf0;
}

.chat-list-title {
  font-size: 11px;
  font-weight: 700;
  padding: 10px 12px 6px;
}

.ticket-list {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

.ticket-item {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-left: 2px solid transparent;
  cursor: pointer;
  width: 100%;
  text-align: left;
  background: none;
  border-top: 0;
  border-right: 0;
  border-bottom: 1px solid var(--border);
}

.ticket-item:hover {
  background: var(--surface-2);
}

.ticket-item.active {
  background: var(--surface-3);
  border-left-color: var(--accent);
}

.ticket-body {
  flex: 1;
  min-width: 0;
}

.ticket-row {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: baseline;
}

.ticket-name {
  font-weight: 650;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticket-time {
  font-size: 11px;
  color: var(--muted);
  flex: none;
}

.ticket-last {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticket-meta {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.unread {
  background: var(--success);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  border-radius: 9px;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.chat-side-foot {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  padding: 6px 12px 0;
}

.chat-side-foot .icon-btn.off {
  color: var(--muted);
  opacity: 0.6;
}

.chat-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.chat-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: var(--text-2);
  font-size: 14px;
}

.chat-placeholder .brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  opacity: 0.85;
}

.chat-placeholder .ico-chat {
  width: 40px;
  height: 40px;
  stroke-width: 1.4;
  color: var(--muted);
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.chat-head-info {
  flex: 1;
  min-width: 0;
}

.chat-head-info strong {
  display: block;
  font-size: 14px;
}

.chat-head-info span {
  color: var(--muted);
  font-size: 12px;
}

.chat-head-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.chat-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.messages {
  flex: 1;
  overflow: auto;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg);
}

.msg {
  max-width: min(72%, 620px);
  padding: 7px 10px 5px;
  border-radius: 8px;
  background: var(--surface-3);
  align-self: flex-start;
  overflow-wrap: anywhere;
  font-size: 13px;
  position: relative;
  flex: none;
}

.msg-text {
  white-space: pre-wrap;
}

.msg.me {
  align-self: flex-end;
  background: #1d3a6e;
}

[data-theme='light'] .msg.me {
  background: #d7e4fb;
}

.msg.internal {
  align-self: center;
  background: rgba(227, 160, 8, 0.12);
  border: 1px dashed rgba(227, 160, 8, 0.5);
  max-width: 80%;
}

.msg-author {
  font-size: 11px;
  font-weight: 700;
  color: #8eaaf0;
  margin-bottom: 2px;
}

.msg-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

.msg-foot .ico {
  width: 14px;
  height: 14px;
}

.msg-foot .read {
  color: #53bdeb;
}

.msg img.msg-media,
.msg video.msg-media {
  max-width: 280px;
  max-height: 320px;
  border-radius: 6px;
  display: block;
  margin-bottom: 4px;
}

.msg audio {
  max-width: 260px;
  display: block;
}

.msg-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
  margin-bottom: 4px;
}

.msg-file-removed {
  opacity: 0.8;
}

.msg-file-removed span {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.msg-file-removed small {
  color: var(--muted);
  font-size: 11.5px;
}

.msg-quote {
  border-left: 3px solid var(--accent);
  background: rgba(0, 0, 0, 0.18);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-reply {
  position: absolute;
  top: 2px;
  right: -30px;
  opacity: 0;
  width: 26px;
  height: 26px;
}

.msg.me .msg-reply {
  right: auto;
  left: -30px;
}

.msg:hover .msg-reply {
  opacity: 1;
}

.day-sep {
  align-self: center;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  padding: 2px 10px;
  border-radius: 10px;
  margin: 10px 0;
}

.load-older {
  align-self: center;
  margin-bottom: 8px;
}

.composer {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.composer-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}

.composer textarea {
  flex: 1;
  min-height: 38px;
  max-height: 160px;
  resize: none;
  padding: 9px 10px;
}

.composer.internal-mode textarea {
  border-color: var(--warning);
}

.composer-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.attach-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 6px 8px;
}

.quick-list {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  max-height: 200px;
  overflow: auto;
}

.quick-item {
  display: block;
  width: 100%;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 7px 10px;
}

.quick-item:hover,
.quick-item.sel {
  background: var(--surface-2);
}

.quick-item strong {
  color: #8eaaf0;
  margin-right: 8px;
}

.contact-panel {
  width: 280px;
  border-left: 1px solid var(--border);
  padding: 16px;
  overflow: auto;
  flex: none;
}

.contact-panel h3 {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 16px 0 8px;
}

.kv {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 6px 8px;
  font-size: 12px;
}

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

.kv dd {
  margin: 0;
  word-break: break-word;
}

.deal-mini {
  --c: #8b95a7;
  display: block;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--c);
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-size: 12px;
}

/* ---------- Pipeline ---------- */
.pipe-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 18px 20px 14px;
  height: calc(100vh - 80px);
}

.pipe-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.pipe-select {
  min-width: 175px;
  width: auto;
  height: 30px;
  font-size: 12px;
}

.pipe-toolbar .btn {
  height: 30px;
}

.view-toggle {
  margin-left: auto;
  display: flex;
  gap: 2px;
  margin-right: 10px;
}

.view-toggle .btn {
  border-color: transparent;
  background: none;
  font-weight: 600;
}

.view-toggle .btn.active {
  background: var(--surface-3);
  color: #8eaaf0;
}

.board {
  flex: 1;
  display: flex;
  gap: 14px;
  overflow-x: auto;
  min-height: 0;
  padding-bottom: 6px;
}

.column {
  --c: #8b95a7;
  flex: 1 0 250px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--c) 7%, #141a29);
  border: 1px solid color-mix(in srgb, var(--c) 10%, var(--border));
}

[data-theme='light'] .column {
  background: color-mix(in srgb, var(--c) 7%, #f3f5f9);
}

.column.drop {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.col-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px 4px;
  font-size: 12px;
}

.col-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c);
  flex: none;
}

.col-name {
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-count,
.col-prob {
  font-size: 11px;
  font-weight: 700;
}

.col-prob {
  margin-left: 12px;
}

.col-head .icon-btn {
  width: 24px;
  height: 24px;
}

.col-total {
  font-weight: 700;
  font-size: 12px;
  padding: 0 12px 10px 20px;
}

.col-cards {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}

.deal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  cursor: grab;
  text-align: left;
  width: 100%;
}

.deal-card:hover {
  border-color: var(--border-strong);
}

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

.deal-card h4 {
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 4px;
}

.deal-card .deal-value {
  font-weight: 700;
  font-size: 12px;
}

.deal-card .deal-sub {
  color: var(--muted);
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 6px;
}

.deal-card .late {
  color: var(--danger);
}

.filters-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 14px;
  background: var(--surface-2);
}

/* ---------- Clientes ---------- */
.clients-page {
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: calc(100vh - 80px);
}

.clients-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.clients-top .search-box .input {
  width: 384px;
  height: 32px;
  font-size: 14px;
  background: transparent;
}

.clients-count {
  color: var(--muted);
  font-size: 12px;
}

.clients-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.clients-table {
  flex: 1;
  overflow: auto;
}

.clients-table .table th {
  padding: 12px 14px;
  font-size: 13px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.clients-table .table td {
  padding: 8px 14px;
  font-size: 14px;
}

.clients-table .cavatar {
  width: 1%;
  padding-right: 4px;
}

.clients-table .cname {
  font-weight: 650;
}

.clients-table .cphone {
  color: var(--text-2);
  letter-spacing: 0.02em;
}

.clients-table tr {
  cursor: pointer;
}

.segment-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.segment-bar .field {
  min-width: 160px;
}

.insights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.insight {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  text-align: left;
  width: 100%;
}

.insight:hover {
  border-color: var(--accent);
}

.insight strong {
  display: block;
  font-size: 20px;
}

.insight span {
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Conexões ---------- */
.conn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.conn-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.conn-top h3 {
  font-size: 15px;
  flex: 1;
}

.conn-qr {
  background: #fff;
  border-radius: 8px;
  padding: 10px;
  align-self: center;
}

.conn-qr img {
  display: block;
  width: 240px;
  height: 240px;
}

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

.status-dot {
  --c: #8b95a7;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--c);
}

.status-dot::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
}

/* ---------- Diversos ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
}

.tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 9px 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.progress {
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
}

.progress > span {
  --w: 0%;
  display: block;
  width: var(--w);
  height: 100%;
  background: var(--accent);
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.flow-option {
  display: grid;
  grid-template-columns: 70px 1fr 1fr 170px auto;
  gap: 8px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.info-box {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-2);
}

.info-box.warn {
  border-left-color: var(--warning);
}

.section-title {
  font-size: 14px;
  margin: 22px 0 10px;
}

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

.hours-grid {
  display: grid;
  grid-template-columns: 120px 90px 120px 120px;
  gap: 8px 12px;
  align-items: center;
}

.ai-output {
  white-space: pre-wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 13px;
}

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
  .modules-grid {
    grid-template-columns: 1fr 1fr;
  }
  .module-col-wide {
    grid-column: 1 / -1;
  }
  .contact-panel {
    display: none;
  }
  .search-trigger span,
  .search-trigger kbd {
    display: none;
  }
}

@media (max-width: 860px) {
  .topbar {
    padding: 0 10px;
    gap: 8px;
    overflow-x: auto;
  }
  .brand {
    min-width: 0;
  }
  .brand span,
  .nav-item span {
    display: none;
  }
  .search-trigger {
    margin-right: 0;
  }
  .view {
    padding: 8px;
  }
  .page,
  .dash-page {
    padding: 16px;
  }
  .chat-layout {
    grid-template-columns: 1fr;
    height: calc(100vh - 68px);
  }
  .chat-layout.has-ticket .chat-side {
    display: none;
  }
  .chat-layout:not(.has-ticket) .chat-main {
    display: none;
  }
  .form-grid,
  .split,
  .filters-panel,
  .modules-grid,
  .module-sub {
    grid-template-columns: 1fr;
  }
  .dash-sections {
    grid-template-columns: 1fr;
  }
  .clients-top .search-box .input {
    width: 100%;
  }
  .clients-actions {
    margin-left: 0;
    flex-wrap: wrap;
  }
  .table thead {
    display: none;
  }
  .table tr {
    display: block;
    border-bottom: 1px solid var(--border);
    padding: 6px 0;
  }
  .table td {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    border: 0;
    padding: 4px 10px;
  }
  .table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
  }
  .table td.actions-col::before {
    content: '';
  }
  .step,
  .flow-option {
    grid-template-columns: 1fr;
  }
  .msg {
    max-width: 88%;
  }
  .pipe-page,
  .clients-page {
    height: auto;
    min-height: calc(100vh - 68px);
  }
}

/* ---------- Complementos ---------- */
.icon-btn.active {
  color: #8eaaf0;
  background: var(--surface-3);
}

.btn.active {
  border-color: var(--accent);
  color: #8eaaf0;
}

.back-mobile {
  display: none;
}

.embedded .page-head h1 {
  font-size: 16px;
}

.clickable {
  cursor: pointer;
}

.late {
  color: var(--danger);
}

.danger-text {
  color: var(--danger);
}

.sep {
  border: 0;
  border-top: 1px solid var(--border);
  width: 100%;
  margin: 4px 0;
}

.board-list {
  display: block;
  overflow: auto;
}

.picker {
  position: relative;
}

.picker-list {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow: auto;
}

.picker-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  background: none;
  border: 0;
  padding: 8px 10px;
  text-align: left;
}

.picker-item span {
  color: var(--muted);
  font-size: 12px;
}

.picker-item:hover {
  background: var(--surface-2);
}

.picker-empty {
  padding: 10px;
  color: var(--muted);
}

.turnstile:empty {
  display: none;
}

@media (max-width: 860px) {
  .back-mobile {
    display: inline-flex;
  }
}

[data-theme='light'] .type-badge {
  color: #2f5fd0;
  background: rgba(47, 95, 208, 0.1);
}

@media (max-width: 860px) {
  .top-actions a.icon-btn,
  .top-actions [data-action='theme'] {
    display: none;
  }
}

.pairing-code {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-align: center;
  margin: 8px 0 14px;
  font-variant-numeric: tabular-nums;
}

.checklist {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 14px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--input);
}

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

/* ---------- Backup mensal ---------- */
.backup-bar {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.backup-bar .field {
  min-width: 220px;
}

.backup-bar .check {
  padding-bottom: 9px;
}

.backup-disk {
  margin-left: auto;
  padding-bottom: 9px;
  font-size: 13px;
  color: var(--text-2);
}

.backup-actions {
  display: inline-flex;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.backup-help {
  margin-top: 12px;
  max-width: 820px;
}

.backup-warn {
  color: var(--danger);
  font-weight: 500;
}

@media (max-width: 860px) {
  .backup-cell {
    text-align: right;
  }

  .backup-disk {
    margin-left: 0;
    width: 100%;
  }

  .backup-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
}

.backup-clean {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.backup-clean p {
  margin: 0;
}
