/* ============================================================
   LUXXAI AGENT OPS — Design System
   Tema: Dark Navy (padrão Agente Checkup)
   ============================================================ */

:root {
  --bg:         #060d1a;
  --surface:    #0d1b2e;
  --surface-2:  #0a1628;
  --border:     #1a3050;
  --primary:    #0ea5e9;
  --accent:     #06b6d4;
  --muted:      #64748b;
  --ink:        #e2e8f0;
  --ink-soft:   #94a3b8;
  --green:      #10b981;
  --red:        #ef4444;
  --gold:       #f59e0b;
  --shadow:     0 4px 24px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

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

/* ============================================================
   APP SHELL — sidebar + conteúdo
   ============================================================ */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 240px;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 20;
  overflow: hidden;
}

.sidebar-brand {
  padding: 22px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.sidebar-brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 1px 10px;
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  border-left: 2px solid transparent;
}

.nav-item:hover {
  color: var(--ink);
  background: rgba(14, 165, 233, 0.08);
}

.nav-item.active {
  color: var(--primary);
  background: rgba(14, 165, 233, 0.12);
  border-left-color: var(--primary);
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.user-pill {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.user-pill-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.user-pill-role {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.logout-form {
  margin: 0;
}

/* ── Conteúdo principal ── */

.app-content {
  margin-left: 240px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  width: min(1280px, calc(100% - 48px));
  margin: 0 auto;
  padding: 32px 0 64px;
  flex: 1;
}

/* ============================================================
   NAV ICONS
   ============================================================ */

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 32px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.page-title {
  margin: 6px 0 0;
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.02em;
}

.status-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-top: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  white-space: nowrap;
}

.badge-green {
  border-color: rgba(16, 185, 129, 0.25);
  background: rgba(16, 185, 129, 0.07);
  color: #6ee7b7;
}

.badge-red {
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.07);
  color: #fca5a5;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ============================================================
   BUTTONS
   ============================================================ */

button,
.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid var(--primary);
  border-radius: 7px;
  background: var(--primary);
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  -webkit-font-smoothing: antialiased;
}

button:hover,
.button:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-ghost,
.button.secondary,
.nav-button {
  background: transparent;
  border-color: var(--border);
  color: var(--ink-soft);
}

.btn-ghost:hover,
.button.secondary:hover,
.nav-button:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(14, 165, 233, 0.08);
}

/* ============================================================
   ALERTS
   ============================================================ */

.alerts {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.alert {
  margin: 0;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  color: var(--ink-soft);
}

.alert.success {
  border-color: rgba(16, 185, 129, 0.32);
  background: rgba(16, 185, 129, 0.08);
  color: #6ee7b7;
}

.alert.error {
  border-color: rgba(239, 68, 68, 0.32);
  background: rgba(239, 68, 68, 0.08);
  color: #fca5a5;
}

/* ============================================================
   HERO
   ============================================================ */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 28px;
  align-items: stretch;
  padding: clamp(22px, 4vw, 44px) 0 20px;
}

.hero-copy h2 {
  max-width: 880px;
  margin: 10px 0 14px;
  font-size: clamp(26px, 3.2vw, 44px);
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.hero-copy p:last-child {
  max-width: 760px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.65;
}

.compact-hero {
  grid-template-columns: 1fr;
  padding-bottom: 4px;
}

.compact-hero .hero-copy h2 {
  font-size: clamp(24px, 2.8vw, 38px);
}

/* ============================================================
   STATUS STRIP
   ============================================================ */

.status-strip {
  display: grid;
  gap: 10px;
  align-self: end;
}

.status-strip > div,
.metric,
.panel,
.config-band {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.status-strip > div {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 2px 10px;
  align-items: center;
  padding: 14px 16px;
}

.status-strip > div strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.status-strip small {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--red);
  grid-row: span 2;
  align-self: center;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

/* ============================================================
   METRICS GRID
   ============================================================ */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 20px 0 28px;
}

.metric {
  padding: 20px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 38px;
  font-weight: 700;
  line-height: 1;
  color: var(--primary);
}

/* ============================================================
   WORKSPACE & PANELS
   ============================================================ */

.workspace,
.tables {
  display: grid;
  gap: 18px;
  margin: 28px 0;
}

.workspace {
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
}

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

.panel,
.config-band {
  padding: 22px;
}

.section-title {
  margin-bottom: 18px;
}

.section-title h3 {
  margin: 5px 0 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
}

.section-note {
  margin: 8px 0 0;
  color: var(--gold);
  font-size: 13px;
  font-weight: 600;
}

/* ============================================================
   TIMELINE
   ============================================================ */

.timeline {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  min-height: 108px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

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

.timeline strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.timeline span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ============================================================
   KEY-VALUE LIST
   ============================================================ */

.kv {
  display: grid;
  gap: 0;
  margin: 0;
}

.kv div {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.kv dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.kv dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  color: var(--ink-soft);
}

/* ============================================================
   ACTIONS
   ============================================================ */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

/* ============================================================
   CONFIG BAND / FORMS
   ============================================================ */

.config-band {
  margin: 28px 0;
}

.config-band.locked .config-form {
  opacity: 0.55;
  pointer-events: none;
}

.config-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 12px;
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:hover,
select:hover {
  border-color: rgba(14, 165, 233, 0.4);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

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

select option {
  background: var(--surface);
  color: var(--ink);
}

.check {
  grid-auto-flow: column;
  grid-template-columns: 16px 1fr;
  align-items: center;
  align-content: center;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
  font-weight: 400;
  color: var(--ink-soft);
}

.check input {
  width: 16px;
  min-height: 16px;
  padding: 0;
  accent-color: var(--primary);
  background: var(--surface-2);
  border-color: var(--border);
}

.check span {
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 400;
}

.secret-box {
  grid-column: 1 / -1;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.secret-box summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.secret-box[open] {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.secret-box[open] summary {
  grid-column: 1 / -1;
}

.config-form > button {
  grid-column: 1 / span 2;
}

/* ============================================================
   CONFIG PAGE — página /configuracoes
   ============================================================ */

.config-page-form {
  padding-bottom: 80px;
}

.config-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin: 0 0 28px;
}

.config-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 22px;
}

.config-section--full {
  grid-column: 1 / -1;
}

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

.config-fields .check {
  grid-column: 1 / -1;
}

.config-save-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.35);
}

.config-save-bar .section-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.config-save-bar code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  color: var(--primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.config-section code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  color: var(--primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.btn-primary {
  white-space: nowrap;
  flex-shrink: 0;
}

.config-section .secret-box {
  grid-column: 1 / -1;
}

/* ============================================================
   TABLES
   ============================================================ */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px;
}

th,
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

tr:last-child td {
  border-bottom: 0;
}

tr:hover td {
  background: rgba(14, 165, 233, 0.04);
  color: var(--ink);
}

/* ============================================================
   LEADS — tabela e toolbar
   ============================================================ */

.leads-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.leads-toolbar .search-wrap {
  flex: 1;
  min-width: 240px;
  max-width: 520px;
}

.lead-status {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.lead-status--novo,
.lead-status--new        { background: rgba(14,165,233,0.12);  color: #38bdf8; }
.lead-status--lead       { background: rgba(139,92,246,0.12);  color: #c4b5fd; }
.lead-status--qualificado{ background: rgba(16,185,129,0.12);  color: #6ee7b7; }
.lead-status--proposta   { background: rgba(245,158,11,0.12);  color: #fcd34d; }
.lead-status--fechado    { background: rgba(16,185,129,0.18);  color: #34d399; }
.lead-status--perdido    { background: rgba(239,68,68,0.12);   color: #fca5a5; }

/* ============================================================
   CONVERSATIONS — lista e detalhe
   ============================================================ */

/* Search bar */
.convo-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 480px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

.search-input {
  padding-left: 38px !important;
}

/* Conversation cards grid */
.convo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.convo-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.convo-card:hover {
  border-color: rgba(14, 165, 233, 0.35);
  background: rgba(14, 165, 233, 0.04);
}

.convo-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(14, 165, 233, 0.15);
  border: 1px solid rgba(14, 165, 233, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
  user-select: none;
}

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

.convo-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.convo-empresa {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.convo-phone {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.02em;
}

.convo-preview {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.8;
}

.convo-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

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

.convo-count {
  background: rgba(14, 165, 233, 0.12);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Tipo badges — shared between list and detail */
.convo-tipo {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.convo-tipo--info_allgo        { background: rgba(14,165,233,0.12);  color: #38bdf8; }
.convo-tipo--interesse_comercial{ background: rgba(16,185,129,0.12); color: #6ee7b7; }
.convo-tipo--suporte           { background: rgba(245,158,11,0.12);  color: #fcd34d; }
.convo-tipo--captura_lead      { background: rgba(139,92,246,0.12);  color: #c4b5fd; }
.convo-tipo--transfer          { background: rgba(245,158,11,0.12);  color: #fcd34d; }
.convo-tipo--redirect_samir    { background: rgba(239,68,68,0.12);   color: #fca5a5; }
.convo-tipo--info_empresa,
.convo-tipo--info_servicos,
.convo-tipo--conversa_geral    { background: rgba(100,116,139,0.12); color: #94a3b8; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px 0;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface);
  transition: border-color 0.15s, color 0.15s;
}

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

.page-info {
  font-size: 13px;
  color: var(--muted);
}

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

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: 0.35;
}

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

/* ── Conversation detail ── */

.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-soft);
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
}

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

/* Lead info card */
.lead-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 20px;
  margin-bottom: 28px;
}

.lead-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Chat thread */
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 40px;
}

.chat-date-sep {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 18px 0 6px;
  position: relative;
}

.chat-date-sep::before,
.chat-date-sep::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 60px);
  height: 1px;
  background: var(--border);
}

.chat-date-sep::before { left: 0; }
.chat-date-sep::after  { right: 0; }

.chat-pair {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.bubble-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.user-row  { flex-direction: row; }
.agent-row { flex-direction: row-reverse; }

.bubble-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  user-select: none;
}

.user-av {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink-soft);
}

.agent-av {
  background: rgba(14, 165, 233, 0.18);
  border: 1px solid rgba(14, 165, 233, 0.25);
  color: var(--primary);
}

.bubble {
  max-width: min(600px, 72%);
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.bubble-user {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  border-top-left-radius: 4px;
}

.bubble-agent {
  background: rgba(14, 165, 233, 0.1);
  border: 1px solid rgba(14, 165, 233, 0.18);
  color: var(--ink);
  border-top-right-radius: 4px;
}

.bubble-ts {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.agent-ts {
  justify-content: flex-end;
}

/* ============================================================
   AUTH PAGES — login e aceitar convite
   ============================================================ */

.auth-page {
  min-height: 100vh;
}

.login-shell,
.auth-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.14), transparent 36%),
    radial-gradient(circle at bottom left, rgba(6, 182, 212, 0.10), transparent 36%),
    linear-gradient(135deg, #020c1a 0%, #060d1a 55%, #0a1628 100%);
}

/* Login: dois painéis lado a lado */

.login-wrap {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(340px, 448px);
  gap: clamp(28px, 6vw, 78px);
  align-items: center;
  max-width: 1060px;
  width: 100%;
}

.login-brand-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 460px;
}

.login-logo-image {
  display: block;
  max-height: 380px;
  max-width: min(100%, 430px);
  width: 100%;
  object-fit: contain;
  border-radius: 18px;
  box-shadow: 0 32px 70px rgba(14, 165, 233, 0.16);
}

.login-title {
  color: #ffffff;
  font-size: clamp(2.2rem, 5vw, 4rem);
  font-weight: 800;
  line-height: 0.98;
  margin: 24px 0 0;
  letter-spacing: -0.02em;
  text-align: left;
}

.login-subtitle {
  color: var(--ink-soft);
  font-size: 1rem;
  margin: 10px 0 0;
  text-align: left;
}

.login-form-panel {
  width: 100%;
}

.login-form-heading {
  margin-bottom: 18px;
}

.login-kicker {
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0;
  text-transform: uppercase;
}

.login-form-heading h2 {
  color: #ffffff;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
  margin: 6px 0 0;
}

.login-panel {
  backdrop-filter: blur(20px);
  background: rgba(13, 27, 46, 0.72);
  border: 1px solid rgba(14, 165, 233, 0.15);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  padding: 32px;
}

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

.login-field {
  color: var(--ink-soft);
  display: grid;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  gap: 8px;
  text-transform: uppercase;
}

.login-field input {
  background: rgba(6, 13, 26, 0.65);
  border: 1px solid rgba(26, 48, 80, 0.95);
  border-radius: 8px;
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 400;
  letter-spacing: 0;
  min-height: 46px;
  text-transform: none;
}

.login-field input:hover {
  border-color: rgba(14, 165, 233, 0.45);
}

.login-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
  outline: none;
}

.login-field input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px #060d1a inset;
  -webkit-text-fill-color: #ffffff;
}

.login-alerts {
  margin-bottom: 16px;
}

.login-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  color: #fca5a5;
  font-size: 0.86rem;
  margin: 0;
  padding: 10px 14px;
}

.login-error.success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.22);
  color: #6ee7b7;
}

.login-button {
  background: linear-gradient(90deg, #0ea5e9, #06b6d4);
  border: 0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.28);
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  min-height: 46px;
}

.login-button:hover {
  background: linear-gradient(90deg, #38bdf8, #22d3ee);
  box-shadow: 0 10px 28px rgba(14, 165, 233, 0.38);
}

.login-footer {
  color: #475569;
  font-size: 0.76rem;
  margin: 22px 0 0;
  text-align: center;
}

/* Auth card — aceitar convite */

.auth-shell {
  padding: 32px 24px;
}

.auth-card {
  backdrop-filter: blur(20px);
  background: rgba(13, 27, 46, 0.72);
  border: 1px solid rgba(14, 165, 233, 0.15);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  padding: 36px;
  width: 100%;
  max-width: 440px;
}

.auth-card .eyebrow {
  margin-bottom: 4px;
}

.auth-card h1 {
  color: #ffffff;
  font-size: 1.6rem;
  font-weight: 700;
  margin: 4px 0 0;
}

.auth-copy {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin: 8px 0 22px;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form label {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.auth-form input {
  background: rgba(6, 13, 26, 0.65);
  border: 1px solid rgba(26, 48, 80, 0.95);
  border-radius: 8px;
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 400;
  letter-spacing: 0;
  min-height: 44px;
  text-transform: none;
}

.auth-form input:hover {
  border-color: rgba(14, 165, 233, 0.45);
}

.auth-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
  outline: none;
}

.auth-form input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px #060d1a inset;
  -webkit-text-fill-color: #ffffff;
}

.auth-form .alerts {
  margin-bottom: 4px;
}

.auth-form button {
  background: linear-gradient(90deg, #0ea5e9, #06b6d4);
  border: 0;
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.28);
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  min-height: 46px;
}

.auth-form button:hover {
  background: linear-gradient(90deg, #38bdf8, #22d3ee);
  box-shadow: 0 10px 28px rgba(14, 165, 233, 0.38);
}

/* ============================================================
   STATUS PAGE
   ============================================================ */

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.2s;
}

.status-card--ok  { border-left: 3px solid var(--green); }
.status-card--err { border-left: 3px solid var(--red); }

.status-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.status-card-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-card-dot.online  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-card-dot.offline { background: var(--red);   box-shadow: 0 0 6px var(--red); }

.status-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.status-card-cat {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-card-detail {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 2px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1100px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .sidebar {
    width: 200px;
  }

  .app-content {
    margin-left: 200px;
  }

  .login-wrap {
    grid-template-columns: 1fr;
    max-width: 480px;
  }

  .login-brand-panel {
    align-items: center;
    min-height: auto;
    text-align: center;
  }

  .login-logo-image {
    max-height: 240px;
    max-width: 300px;
  }

  .login-title,
  .login-subtitle {
    text-align: center;
  }

  .hero,
  .workspace,
  .tables {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    gap: 14px;
  }

  .status-badges {
    padding-top: 0;
  }

  .config-form,
  .secret-box[open] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .config-sections {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 240px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .app-content {
    margin-left: 0;
  }

  main {
    width: min(100% - 24px, 1280px);
    padding-top: 20px;
  }
}

@media (max-width: 640px) {
  .login-shell,
  .auth-shell {
    padding: 20px 14px;
  }

  .login-logo-image {
    max-height: 200px;
    max-width: 240px;
  }

  .login-title {
    font-size: 2.2rem;
  }

  .login-panel,
  .auth-card {
    padding: 24px;
  }

  .metrics-grid,
  .timeline,
  .config-form,
  .secret-box[open],
  .config-fields {
    grid-template-columns: 1fr;
  }

  .config-form > button {
    grid-column: auto;
  }

  .config-save-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .config-save-bar .btn-primary {
    width: 100%;
  }
}
