/* Connecta Business OS — linguagem visual Connecta: dark, hairlines, azul único */
:root {
  --bg: #070707;
  --bg-raise: #0d0d0e;
  --bg-hover: #131315;
  --line: #1e1e21;
  --text: #f0efec;
  --muted: #8b8b90;
  --brand: #16a3ff;
  --green: #2fbf71;
  --red: #e5484d;
  --amber: #f5a623;
  --font: 'Geist', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', 'Cascadia Code', monospace;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { color-scheme: dark; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: 0.02em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---- shell ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  background: var(--bg);
}
.brand { display: flex; gap: 10px; align-items: center; padding: 20px 18px; border-bottom: 1px solid var(--line); }
.brand-mark {
  width: 26px; height: 26px; flex-shrink: 0;
  border: 1px solid var(--text); position: relative;
}
.brand-mark::before {
  content: ''; position: absolute; inset: 5px;
  border: 1px solid var(--brand);
}
.brand-logo { width: 28px; height: 28px; object-fit: contain; border-radius: 4px; }
.brand-name { font-weight: 600; font-size: 14px; }
.brand-sub { font-family: var(--mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; }
.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 6px;
  color: var(--muted); font-weight: 500;
}
.nav-item:hover { color: var(--text); background: var(--bg-hover); text-decoration: none; }
.nav-item.active { color: var(--text); background: var(--bg-raise); box-shadow: inset 2px 0 0 var(--brand); }
.nav-icon { width: 18px; text-align: center; opacity: 0.8; }
.sidebar-foot { padding: 14px 18px; border-top: 1px solid var(--line); font-size: 11px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 26px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(7,7,7,0.92); backdrop-filter: blur(8px); z-index: 10;
}
.top-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.top-right { display: flex; align-items: center; gap: 16px; }
.top-link { font-size: 13px; }
.user-block { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; font-size: 13px; }
.content { padding: 26px; max-width: 1200px; width: 100%; }

/* ---- primitives ---- */
h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 2px; }

.card {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.card + .card, .card + .grid, .grid + .card, .grid + .grid, .card + h2, .grid + h2 { margin-top: 18px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

/* métrica com cantos de QR (assinatura Connecta) */
.metric { position: relative; padding: 16px 18px; }
.metric::before, .metric::after {
  content: ''; position: absolute; width: 10px; height: 10px;
  border: 1px solid var(--line); transition: border-color 0.2s;
}
.metric::before { top: 6px; left: 6px; border-right: 0; border-bottom: 0; }
.metric::after { bottom: 6px; right: 6px; border-left: 0; border-top: 0; }
.metric:hover::before, .metric:hover::after { border-color: var(--brand); }
.metric-label { font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--muted); }
.metric-value { font-size: 26px; font-weight: 650; margin-top: 4px; letter-spacing: -0.02em; }
.metric-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* chips / status */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em;
  border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px; color: var(--muted);
}
.chip-blue { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.chip-ativo, .chip-open, .chip-ok { color: var(--green); border-color: color-mix(in srgb, var(--green) 45%, transparent); }
.chip-teste, .chip-warn, .chip-connecting { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 45%, transparent); }
.chip-inativo, .chip-close, .chip-erro { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); }
.dot { width: 7px; height: 7px; border-radius: 99px; background: currentColor; display: inline-block; }

/* ---- forms ---- */
.stack { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }
textarea { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.check { flex-direction: row; align-items: center; gap: 8px; }
.check input { width: auto; }

.btn {
  font: inherit; font-weight: 550; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg-raise); color: var(--text);
  padding: 8px 14px; display: inline-flex; align-items: center; gap: 7px;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--bg-hover); border-color: #2c2c30; }
.btn-primary { background: var(--text); color: #0a0a0a; border-color: var(--text); }
.btn-primary:hover { background: #fff; }
.btn-blue { background: var(--brand); border-color: var(--brand); color: #04121d; }
.btn-danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); background: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-raise); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--muted); font-weight: 500;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--bg-hover); }

.empty {
  border: 1px dashed var(--line); border-radius: 8px;
  padding: 40px 20px; text-align: center; color: var(--muted);
}
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }

.flash {
  margin: 16px 26px 0; padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--green) 40%, transparent);
  color: var(--green); border-radius: 6px; font-size: 13px;
}
.flash-error { border-color: color-mix(in srgb, var(--red) 40%, transparent); color: var(--red); margin: 0 0 14px; }

/* ---- login ---- */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth-card {
  width: 100%; max-width: 380px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg-raise);
  padding: 30px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font-size: 14px; color: var(--muted); }
.auth-brand strong { color: var(--text); }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .stack { margin-top: 18px; }
.auth-card .small { margin-top: 16px; }

/* ---- IA simulador ---- */
.sim { display: flex; flex-direction: column; height: 420px; }
.sim-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 12px; }
.sim-msg { max-width: 78%; padding: 9px 13px; border-radius: 10px; font-size: 13.5px; white-space: pre-wrap; }
.sim-msg.user { align-self: flex-end; background: color-mix(in srgb, var(--brand) 18%, var(--bg-raise)); border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent); }
.sim-msg.assistant { align-self: flex-start; background: var(--bg-hover); border: 1px solid var(--line); }
.sim-form { display: flex; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.sim-form input { flex: 1; }

/* qr code */
.qr-box { display: grid; place-items: center; padding: 18px; }
.qr-box img { width: 240px; height: 240px; border-radius: 8px; background: #fff; padding: 8px; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; overflow-x: auto; }
  .brand { border-bottom: 0; border-right: 1px solid var(--line); }
  .nav { flex-direction: row; padding: 8px; }
  .nav-item { white-space: nowrap; }
  .sidebar-foot { display: none; }
  .content { padding: 18px; }
  .topbar { padding: 12px 18px; }
}

/* ---- Central de atendimento ---- */
.chat-shell { display: grid; grid-template-columns: 320px 1fr; gap: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; height: calc(100vh - 210px); min-height: 480px; background: var(--bg-raise); }
.chat-list { border-right: 1px solid var(--line); overflow-y: auto; }
.chat-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 12px 14px; color: var(--text); cursor: pointer; font: inherit; }
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--bg-hover); box-shadow: inset 2px 0 0 var(--brand); }
.chat-item-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.chat-item-bottom { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; margin-top: 3px; }
.chat-item-bottom .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-badge { background: var(--brand); color: #fff; border-radius: 10px; font-size: 10px; padding: 1px 7px; font-family: var(--mono); }
.chat-main { display: flex; flex-direction: column; min-width: 0; }
.chat-empty { margin: auto; text-align: center; display: flex; flex-direction: column; gap: 6px; padding: 30px; }
.chat-pane { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.chat-msg { max-width: 72%; background: var(--bg-hover); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 13.5px; align-self: flex-start; position: relative; white-space: pre-wrap; word-break: break-word; }
.chat-msg.me { align-self: flex-end; background: color-mix(in srgb, var(--brand) 14%, var(--bg-hover)); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.chat-msg-time { display: block; font-size: 10px; color: var(--muted); margin-top: 4px; text-align: right; }
.chat-ai-tag { font-size: 9px; font-family: var(--mono); color: var(--brand); border: 1px solid color-mix(in srgb, var(--brand) 45%, transparent); border-radius: 4px; padding: 0 4px; }
.chat-suggest { border-top: 1px dashed color-mix(in srgb, var(--brand) 40%, var(--line)); padding: 10px 16px; background: color-mix(in srgb, var(--brand) 6%, var(--bg-raise)); font-size: 13px; display: flex; flex-direction: column; gap: 8px; }
.chat-suggest-label { font-size: 10px; font-family: var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--brand); }
.chat-form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; }
@media (max-width: 860px) {
  .chat-shell { grid-template-columns: 1fr; height: auto; }
  .chat-list { max-height: 240px; border-right: 0; border-bottom: 1px solid var(--line); }
  .chat-pane { height: 60vh; }
}

/* ---- CRM histórico ---- */
.hist { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.hist-item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-hover); }
