/* COMANFY® Atendimento — identidade: preto, branco e laranja #FF7400 */
:root {
  --orange: #FF7400;
  --orange-600: #e26600;
  --orange-50: #fff3e9;
  --black: #0d0d0d;
  --ink: #1a1a1a;
  --ink-2: #444;
  --muted: #777;
  --line: #e7e7e7;
  --bg: #f5f5f4;
  --white: #fff;
  --green: #1f9d55;
  --red: #d93025;
  --yellow: #c98a00;
  --blue: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --sidebar-w: 248px;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; }
a { color: var(--orange-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .6rem; line-height: 1.2; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
[hidden] { display: none !important; }

/* ---------- Estrutura ---------- */
.shell { display: flex; min-height: 100vh; background: linear-gradient(to right, var(--black) var(--sidebar-w), transparent var(--sidebar-w)); }
.sidebar { width: var(--sidebar-w); background: var(--black); color: #d6d6d6; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: block; padding: 20px 20px 14px; color: #fff; border-bottom: 1px solid #222; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 150px; display: block; }
.brand-sub { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--orange); margin-top: 6px; }
.nav { padding: 10px 8px 24px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #cfcfcf; font-size: 13.5px; position: relative; }
.nav-item svg { width: 18px; height: 18px; fill: currentColor; opacity: .85; flex-shrink: 0; }
.nav-item:hover { background: #1c1c1c; color: #fff; text-decoration: none; }
.nav-item.active { background: var(--orange); color: #fff; }
.nav-item.active svg { opacity: 1; }
.nav-badge { margin-left: auto; background: var(--orange); color: #fff; font-size: 11px; border-radius: 999px; padding: 1px 7px; font-weight: 700; }
.nav-item.active .nav-badge { background: #fff; color: var(--orange); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; background: var(--white); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 20; }
.page-title { font-size: 1.1rem; margin: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.menu-toggle { display: none; }
.content { padding: 22px; flex: 1; }
.availability select, .company-switch select { border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; background: #fff; font-size: 13px; }
.avail-online { color: var(--green); } .avail-away { color: var(--yellow); } .avail-offline { color: var(--muted); }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--black); color: var(--orange); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }
.dropdown { position: absolute; right: 0; top: 42px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 220px; padding: 6px; z-index: 30; }
.dropdown a, .dropdown button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; color: var(--ink); border-radius: 6px; font: inherit; cursor: pointer; }
.dropdown a:hover, .dropdown button:hover { background: var(--bg); text-decoration: none; }

/* ---------- Componentes ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.7rem; font-weight: 800; margin-top: 4px; }
.stat-hint { font-size: 12px; color: var(--muted); }
.stat.accent { border-top: 3px solid var(--orange); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 8px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; background: var(--black); color: #fff; text-decoration: none; line-height: 1.2; }
.btn:hover { text-decoration: none; filter: brightness(1.15); }
.btn-primary { background: var(--orange); }
.btn-outline { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-danger { background: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: 8px; cursor: pointer; display: inline-flex; }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }
.icon-btn:hover { background: var(--bg); }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafafa; }
.table tr:hover td { background: #fcfcfc; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: #eee; color: var(--ink-2); white-space: nowrap; }
.badge-orange { background: var(--orange-50); color: var(--orange-600); }
.badge-green { background: #e7f6ee; color: var(--green); }
.badge-red { background: #fde8e7; color: var(--red); }
.badge-yellow { background: #fdf3d9; color: var(--yellow); }
.badge-blue { background: #e7efff; color: var(--blue); }
.badge-black { background: var(--black); color: #fff; }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-ok { background: #e9f7ef; border-color: #bfe5cf; color: #14653a; }
.alert-warn { background: #fff6e5; border-color: #ffd9a3; color: #8a5300; }
.alert-err { background: #fdecea; border-color: #f5c2bd; color: #a3221a; }

/* Formulários */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label, .label { font-weight: 600; font-size: 13px; }
.field small, .help { color: var(--muted); font-size: 12px; }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=date], input[type=time], input[type=search], input[type=tel], select, textarea {
  width: 100%; border: 1px solid #d9d9d9; border-radius: 8px; padding: 9px 11px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,116,0,.15); }
textarea { resize: vertical; min-height: 90px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.inline-form { display: inline; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { min-width: 160px; }

/* Chave liga/desliga */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 40px; height: 22px; background: #cfcfcf; border-radius: 999px; position: relative; transition: background .15s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; width: 18px; height: 18px; top: 2px; left: 2px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--orange); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(255,116,0,.3); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs a.active { color: var(--orange-600); border-color: var(--orange); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.pagination { display: flex; gap: 4px; margin-top: 14px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }
.pagination .active span, .pagination span[aria-current] { background: var(--orange); color: #fff; border-color: var(--orange); }
.muted { color: var(--muted); }
.text-right { text-align: right; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.bar { height: 8px; background: #eee; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--orange); }

/* Login */
.auth-body { background: var(--black); display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card { background: #fff; border-radius: 14px; padding: 32px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.4); border-top: 4px solid var(--orange); }
.auth-card .brand-logo { width: 180px; margin-bottom: 6px; }
.auth-card h1 { font-size: 1.2rem; margin: 18px 0 16px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 11px; }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .shell { background: none; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.5); }
  .menu-toggle { display: inline-flex; }
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
  .content { padding: 14px; }
  .user-name { display: none; }
  .kv { grid-template-columns: 1fr; }
}

/* Telas de acesso (login, recuperação de senha) */
.auth-card .field input::placeholder { color: #9a9a9a; }
.auth-card input[type=email], .auth-card input[type=password], .auth-card .pw-wrap input { padding: 12px 13px; border-radius: 10px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 46px !important; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: transparent; border: 0; color: #6b6b6b; cursor: pointer; padding: 6px; border-radius: 6px; line-height: 0; }
.pw-toggle:hover { color: var(--ink); }
.pw-toggle:focus-visible { outline: 2px solid var(--orange); outline-offset: 1px; }
.pw-toggle .eye-closed { display: none; }
.pw-toggle.is-visible .eye-open { display: none; }
.pw-toggle.is-visible .eye-closed { display: inline; }
.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 16px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--orange); margin: 0; }
.auth-link { color: var(--orange); font-weight: 700; font-size: 13.5px; }
.auth-link:hover { text-decoration: underline; color: var(--orange-600); }
.auth-card .btn-lg { padding: 13px; font-size: 15.5px; border-radius: 10px; }
.auth-back { margin-top: 10px; }
.auth-text { font-size: 13.5px; margin: -6px 0 16px; line-height: 1.5; }
.auth-foot { margin-top: 18px; text-align: center; color: #6b6b6b; font-size: 13px; }
.auth-success { text-align: center; }
.auth-success svg { margin: 16px auto 0; display: block; }
.auth-success h1 { margin-top: 10px; }
.pw-match { min-height: 1.2em; }
.pw-match.ok { color: #14653a; }
.pw-match.bad { color: #a3221a; }
@media (max-width: 420px) {
  .auth-card { padding: 26px 22px; }
  .auth-row { flex-wrap: nowrap; gap: 6px; }
  .check, .auth-link { font-size: 12.5px; white-space: nowrap; }
}
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.legal { font-size: 14px; line-height: 1.55; max-height: 60vh; overflow: auto; }
.onboarding { border-left: 4px solid var(--orange); }
.onboarding ol { margin: 8px 0 0; padding-left: 20px; }
.onboarding li { margin: 4px 0; }
.onboarding li.done { color: var(--muted); text-decoration: line-through; }
.progress { height: 8px; background: #eee; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.progress > span { display: block; height: 100%; background: var(--orange); }

/* IA: teste no painel */
.ai-teste { margin-top: 14px; border-top: 1px solid var(--line, #e5e5e5); padding-top: 12px; }
.ai-resposta { white-space: pre-wrap; background: var(--orange-50, #fff4ea); border-radius: 10px; padding: 12px 14px; max-width: 720px; line-height: 1.45; }
.ai-numero { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-top: 1px solid var(--line, #e5e5e5); }
.ai-numero:first-of-type { border-top: 0; }
.ai-numero small { color: var(--muted, #666); padding-left: 52px; }
.ai-foto { margin: 10px 0 0; max-width: 260px; }
.ai-foto img { width: 100%; border-radius: 10px; border: 1px solid var(--line, #e5e5e5); }
.ai-foto figcaption { font-size: 13px; color: var(--muted, #666); white-space: pre-line; overflow-wrap: anywhere; }

/* Assistentes (opções em linha e lista na página do Assistente) */
.opcao { display: inline-flex; align-items: center; gap: 6px; margin: 2px 14px 2px 0; font-weight: 400; }
.assistentes { display: grid; gap: 10px; }
.assistente-item { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; padding: 12px 0; border-top: 1px solid var(--line, #e5e5e5); }
.assistente-item:first-child { border-top: 0; }
.assistente-item .info { min-width: 0; flex: 1 1 320px; }
.assistente-item .info small { display: block; color: var(--muted, #666); }

/* Avaliação do atendimento (resumo no painel) */
.avaliacao-resumo { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 4px 0 16px; }
.avaliacao-resumo > div { min-width: 0; }
.avaliacao-resumo strong { display: block; font-size: 28px; line-height: 1.1; color: var(--orange, #FF7400); }
.avaliacao-resumo small { display: block; color: var(--muted, #666); }
.avaliacao-barras { grid-column: span 2; display: grid; gap: 4px; }
.avaliacao-barras .barra { display: grid; grid-template-columns: 38px 1fr 32px; align-items: center; gap: 8px; font-size: 13px; }
.avaliacao-barras .barra i { display: block; height: 10px; border-radius: 5px; background: var(--orange, #FF7400); min-width: 2px; }
.avaliacao-barras .barra b { text-align: right; font-weight: 600; }
@media (max-width: 600px) { .avaliacao-barras { grid-column: auto; } }

/* Versão do sistema no pé do menu (vale em todas as páginas) */
.nav-versao { display: block; padding: 10px 20px 16px; font-size: 11px; color: #8a8a8a; text-decoration: none; }
.nav-versao:hover { color: #fff; }

/* Logo enviada pela empresa: fundo branco arredondado, para aparecer bem no menu escuro seja qual for a cor dela */
.brand-logo-empresa { width: auto; max-width: 170px; max-height: 64px; object-fit: contain; background: #fff; padding: 8px 10px; border-radius: 10px; }
.logo-atual { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.logo-atual img { max-width: 170px; max-height: 64px; object-fit: contain; background: #fff; border: 1px solid var(--line, #e5e5e5); border-radius: 10px; padding: 8px 10px; }
