#insightsTab {
  --ins-text: #111827;
  --ins-muted: #5b6472;
  --ins-line: #e5e7eb;
  --ins-surface: #ffffff;
  --ins-bg: #f4f6f9;
  --ins-red: #d32027;
  --ins-blue: #0f6cbd;
  --ins-purple: #5b2c6f;
}

#insightsTab .ins-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 36px;
}

#insightsTab .ins-copilot {
  background: linear-gradient(120deg, #0b1f3a 0%, #1e3a5f 42%, #5b2c6f 100%);
  color: #fff;
  border-radius: 18px;
  padding: 20px 22px 18px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
}

#insightsTab .ins-copilot-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

#insightsTab .ins-copilot-kicker {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.8;
  font-weight: 700;
}

#insightsTab .ins-copilot h2 {
  margin: 4px 0 0;
  font-size: 26px;
  font-weight: 750;
}

#insightsTab .ins-copilot p {
  margin: 6px 0 0;
  max-width: 720px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
  line-height: 1.5;
}

#insightsTab .ins-cache-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#insightsTab .ins-cache {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
}

#insightsTab .ins-composer-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#insightsTab .ins-composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: end;
  background: #fff;
  border-radius: 14px;
  padding: 8px;
}

#insightsTab .ins-dir-attach-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #f8fafc;
  color: #64748b;
  padding: 0;
  cursor: pointer;
  align-self: center;
}

#insightsTab .ins-dir-attach-btn:hover {
  background: #fff;
  border-color: #cbd5e1;
  color: #111827;
}

#insightsTab .ins-composer textarea {
  border: 0;
  resize: none;
  min-height: 52px;
  font: 14px/1.45 inherit;
  color: #111827;
  padding: 10px 12px;
  outline: none;
}

#insightsTab .ins-composer > button#insCopilotSend {
  align-self: end;
  background: linear-gradient(135deg, #0f6cbd, #8764b8);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
}

#insightsTab .ins-composer-wrap .ins-user-attach-chips {
  margin: 0;
}

#insightsTab .ins-composer-wrap .ins-user-attach-error {
  margin: 0;
  color: #fecaca;
}

#insightsTab .ins-composer button:disabled {
  opacity: 0.55;
  cursor: wait;
}

#insightsTab .ins-copilot-log {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#insightsTab .ins-bubble {
  max-width: 80%;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
}

#insightsTab .ins-bubble--user {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.16);
}

#insightsTab .ins-bubble--bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.1);
}

#insightsTab .ins-bubble--warn {
  align-self: flex-start;
  background: rgba(251, 146, 60, 0.22);
  border: 1px solid rgba(251, 146, 60, 0.55);
  color: #ffedd5;
  white-space: pre-wrap;
}

#insightsTab .ins-app {
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
  gap: 16px;
}

@media (max-width: 980px) {
  #insightsTab .ins-app,
  #insightsTab .ins-composer {
    grid-template-columns: 1fr;
  }
}

#insightsTab .ins-rail,
#insightsTab .ins-main {
  background: var(--ins-surface);
  border: 1px solid var(--ins-line);
  border-radius: 16px;
}

#insightsTab .ins-rail {
  padding: 16px;
}

#insightsTab .ins-title {
  margin: 0;
  font-size: 18px;
}

#insightsTab .ins-sub {
  color: var(--ins-muted);
  font-size: 13px;
  line-height: 1.45;
}

#insightsTab .ins-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

#insightsTab .ins-card {
  text-align: left;
  border: 1px solid var(--ins-line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  cursor: pointer;
}

#insightsTab .ins-card.is-active,
#insightsTab .ins-card:hover {
  border-color: #c7d2fe;
  background: #f8fafc;
}

#insightsTab .ins-card h3 {
  margin: 0;
  font-size: 14px;
}

#insightsTab .ins-card p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ins-muted);
}

#insightsTab .ins-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

#insightsTab .ins-pill {
  font-size: 11px;
  border-radius: 999px;
  padding: 2px 8px;
  background: #f3f4f6;
}

#insightsTab .ins-pill--ok { background: #dcfce7; color: #166534; }
#insightsTab .ins-pill--tpl { background: #e0e7ff; color: #3730a3; }

#insightsTab .ins-main {
  padding: 18px 20px 24px;
}

#insightsTab .ins-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 820px) {
  #insightsTab .ins-kpis { grid-template-columns: 1fr; }
}

#insightsTab .ins-kpi {
  border: 1px solid var(--ins-line);
  border-radius: 14px;
  padding: 14px 16px;
  background: #fbfcfe;
}

#insightsTab .ins-kpi span {
  display: block;
  font-size: 12px;
  color: var(--ins-muted);
  font-weight: 600;
}

#insightsTab .ins-kpi strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  letter-spacing: -0.03em;
}

#insightsTab .ins-kpi em {
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
}

#insightsTab .ins-kpi em.up { color: #166534; }
#insightsTab .ins-kpi em.down { color: #b91c1c; }

#insightsTab .ins-panel {
  margin-top: 14px;
  border: 1px solid var(--ins-line);
  border-radius: 14px;
  padding: 14px 16px;
}

#insightsTab .ins-panel h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

#insightsTab table.ins-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#insightsTab table.ins-table th,
#insightsTab table.ins-table td {
  padding: 8px 6px;
  border-bottom: 1px solid #eef2f7;
  text-align: left;
}

#insightsTab table.ins-table td.num,
#insightsTab table.ins-table th.num {
  text-align: right;
}

#insightsTab .ins-status {
  min-height: 1.2em;
  font-size: 13px;
  color: var(--ins-muted);
}

#insightsTab .ins-status.is-err { color: #b91c1c; }
#insightsTab .ins-status.is-ok { color: #166534; }

#insightsTab .ins-btn {
  border: 1px solid var(--ins-line);
  background: #fff;
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

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

#insightsTab .ins-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#insightsTab .ins-form {
  display: grid;
  gap: 12px;
}

#insightsTab .ins-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

#insightsTab label.ins-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 650;
}

#insightsTab .ins-field input,
#insightsTab .ins-field select,
#insightsTab .ins-field textarea {
  font-weight: 400;
  border: 1px solid var(--ins-line);
  border-radius: 8px;
  padding: 8px 10px;
}

#insightsTab .ins-check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
  font-weight: 400;
}

#insightsTab .ins-narrative {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.6;
}

#insightsTab details.ins-settings {
  margin-top: 16px;
  border-top: 1px solid var(--ins-line);
  padding-top: 12px;
}

#insightsTab .ins-empty {
  color: var(--ins-muted);
  padding: 24px 8px;
  text-align: center;
}

/* —— Sub-abas Diretoria / Usuários —— */
#insightsTab .ins-views {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: calc(100vh - 120px);
}

#insightsTab .ins-view-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--ins-line);
  border-radius: 12px;
  width: fit-content;
}

#insightsTab .ins-view-tab {
  border: 0;
  background: transparent;
  color: var(--ins-muted);
  font-size: 13px;
  font-weight: 650;
  padding: 8px 16px;
  border-radius: 9px;
  cursor: pointer;
}

#insightsTab .ins-view-tab:hover {
  color: var(--ins-text);
  background: #f3f4f6;
}

#insightsTab .ins-view-tab.is-active {
  background: var(--ins-red);
  color: #fff;
}

#insightsTab .ins-view-panel.hidden {
  display: none;
}

/* —— Chat Usuários (light, inspira ChatGPT) —— */
#insightsTab .ins-user-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 170px);
  background: #fff;
  border: 1px solid var(--ins-line);
  border-radius: 16px;
  overflow: hidden;
}

#insightsTab .ins-user-rail {
  background: #f8fafc;
  border-right: 1px solid var(--ins-line);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

#insightsTab .ins-user-new {
  width: 100%;
  border: 1px solid var(--ins-line);
  background: #fff;
  color: var(--ins-text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  text-align: left;
}

#insightsTab .ins-user-new:hover {
  border-color: #cbd5e1;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

#insightsTab .ins-user-recents-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ins-muted);
  padding: 6px 8px 0;
}

#insightsTab .ins-user-thread-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

#insightsTab .ins-user-thread {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 13px;
  color: var(--ins-text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#insightsTab .ins-user-thread:hover {
  background: #eef2f7;
}

#insightsTab .ins-user-thread.is-active {
  background: #e8edf5;
  font-weight: 650;
}

#insightsTab .ins-user-empty-rail {
  color: var(--ins-muted);
  font-size: 12px;
  padding: 8px;
  margin: 0;
}

#insightsTab .ins-user-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #f4f6f9;
}

#insightsTab .ins-user-top {
  padding: 14px 20px;
  border-bottom: 1px solid var(--ins-line);
  background: #fff;
}

#insightsTab .ins-user-top h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  color: var(--ins-text);
}

#insightsTab .ins-user-messages {
  flex: 1;
  overflow: auto;
  padding: 24px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#insightsTab .ins-user-welcome {
  margin: auto;
  max-width: 420px;
  text-align: center;
  color: var(--ins-muted);
  padding: 40px 16px;
}

#insightsTab .ins-user-welcome h3 {
  margin: 0 0 8px;
  color: var(--ins-text);
  font-size: 22px;
  font-weight: 750;
}

#insightsTab .ins-user-welcome p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

#insightsTab .ins-user-row {
  display: flex;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
}

#insightsTab .ins-user-row--user {
  justify-content: flex-end;
}

#insightsTab .ins-user-row--bot {
  justify-content: flex-start;
}

#insightsTab .ins-user-bubble {
  max-width: min(640px, 92%);
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ins-text);
  background: #fff;
  border: 1px solid var(--ins-line);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

#insightsTab .ins-user-row--user .ins-user-bubble {
  background: #fef2f2;
  border-color: #fecaca;
  color: #7f1d1d;
  border-bottom-right-radius: 6px;
}

#insightsTab .ins-user-bubble--bot {
  border-bottom-left-radius: 6px;
}

#insightsTab .ins-user-typing {
  color: var(--ins-muted);
  font-style: italic;
}

#insightsTab .ins-user-composer-wrap {
  padding: 8px 20px 18px;
  background: linear-gradient(180deg, transparent, #f4f6f9 24%);
}

#insightsTab .ins-user-disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--ins-muted);
  margin: 0 0 8px;
}

#insightsTab .ins-user-attach-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

#insightsTab .ins-user-attach-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 820px;
  margin: 0 auto 8px;
  justify-content: center;
}

#insightsTab .ins-user-attach-error {
  max-width: 820px;
  margin: 0 auto 6px;
  text-align: center;
  font-size: 12px;
  color: #b91c1c;
}

#insightsTab .ins-user-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 8px 4px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--ins-line);
  font-size: 12px;
  color: var(--ins-text);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

#insightsTab .ins-user-attach-chip--readonly {
  padding-right: 10px;
}

#insightsTab .ins-user-attach-chip-kind {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ins-muted);
}

#insightsTab .ins-user-attach-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

#insightsTab .ins-user-attach-chip-remove {
  border: 0;
  background: transparent;
  color: var(--ins-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

#insightsTab .ins-user-attach-chip-remove:hover {
  color: var(--ins-red);
}

#insightsTab .ins-user-msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

#insightsTab .ins-user-row--user .ins-user-attach-chip {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.35);
  color: #fff;
}

#insightsTab .ins-user-row--user .ins-user-attach-chip-kind {
  color: rgba(255, 255, 255, 0.75);
}

#insightsTab .ins-user-composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: end;
  max-width: 820px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--ins-line);
  border-radius: 999px;
  padding: 8px 8px 8px 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

#insightsTab .ins-user-attach-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ins-line);
  border-radius: 999px;
  background: #f8fafc;
  color: #64748b;
  padding: 0;
  cursor: pointer;
  align-self: center;
}

#insightsTab .ins-user-attach-btn:hover {
  background: #fff;
  border-color: #cbd5e1;
  color: var(--ins-text);
}

#insightsTab .ins-user-attach-icon {
  display: block;
  flex-shrink: 0;
}

#insightsTab .ins-user-composer textarea {
  border: 0;
  outline: none;
  resize: none;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  max-height: 140px;
  padding: 8px 0;
  background: transparent;
  color: var(--ins-text);
}

#insightsTab .ins-user-composer textarea::placeholder {
  color: #9ca3af;
}

#insightsTab .ins-user-send {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: var(--ins-red);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}

#insightsTab .ins-user-send:hover {
  background: #b91c22;
}

#insightsTab .ins-user-send:disabled {
  opacity: 0.45;
  cursor: default;
}

@media (max-width: 860px) {
  #insightsTab .ins-user-shell {
    grid-template-columns: 1fr;
    min-height: 70vh;
  }

  #insightsTab .ins-user-rail {
    border-right: 0;
    border-bottom: 1px solid var(--ins-line);
    max-height: 200px;
  }
}
