/* Hub Service Desk — visual claro e minimalista (redesign 13/11/2026).
   Cor só onde carrega significado: status, alertas e gráficos. Modo escuro segue o sistema. */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f8f9fb; --border: #e6e8ec; --border-strong: #d5d9e0;
  --text: #16191f; --text-2: #3d4350; --muted: #6b7280;
  --accent: #3a5ccc; --accent-hover: #2f4fb8; --accent-soft: #eef2fc;
  --red: #c8364a; --red-soft: #fcf0f2; --orange: #c46a0a; --orange-soft: #fdf4ea;
  --green: #17845a; --green-soft: #ecf7f2; --yellow: #a07a06; --yellow-soft: #fdf8e6;
  --purple: #7048c8; --purple-soft: #f3effc;
  --gray-soft: #f0f2f5;
  --sidebar: #ffffff; --sidebar-text: #4b5262; --sidebar-active: #eef2fc;
  --s1: #3a5ccc; --s2: #1a9a9a; --s3: #c8364a;
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218; --surface: #161a22; --surface-2: #1b2029; --border: #262c37; --border-strong: #333b48;
    --text: #e8eaef; --text-2: #c4c9d3; --muted: #8b93a3;
    --accent: #7c97ec; --accent-hover: #93a9f0; --accent-soft: #1d2540;
    --red: #f07a8a; --red-soft: #351a20; --orange: #f0a35a; --orange-soft: #33241a;
    --green: #4cc493; --green-soft: #13291f; --yellow: #e6c25a; --yellow-soft: #2e2710;
    --purple: #ad93f0; --purple-soft: #261f3d;
    --gray-soft: #20252f;
    --sidebar: #12161d; --sidebar-text: #aab1bf; --sidebar-active: #1d2540;
    --s1: #7c97ec; --s2: #3cc0c0; --s3: #f07a8a;
    --shadow: none; --shadow-lg: 0 12px 32px rgba(0, 0, 0, .45);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); background: var(--bg); color: var(--text); display: flex; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
.muted { color: var(--muted); }
h1 { font-size: 21px; font-weight: 650; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 14.5px; font-weight: 600; margin: 0 0 4px; }
h3 { font-size: 12px; font-weight: 600; margin: 14px 0 8px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
code { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: var(--gray-soft); padding: 1px 5px; border-radius: 5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- sidebar */
.sidebar { width: 240px; flex: none; background: var(--sidebar); color: var(--sidebar-text); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 12px 14px; position: sticky; top: 0; height: 100vh; overflow: auto; z-index: 30; }
.brand { display: flex; gap: 10px; align-items: center; padding: 2px 8px 18px; }
.brand strong { color: var(--text); display: block; font-size: 14.5px; font-weight: 650; }
.brand span { font-size: 11.5px; color: var(--muted); }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
nav { display: flex; flex-direction: column; gap: 1px; }
.nav-group { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 6px; opacity: .85; }
.nav-group:first-child { padding-top: 0; }
nav a { color: var(--sidebar-text); padding: 7px 10px; border-radius: var(--radius-sm); display: flex; gap: 10px; align-items: center; font-size: 13.5px; font-weight: 500; }
nav a svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
nav a:hover { background: var(--gray-soft); color: var(--text); }
nav a.active { background: var(--sidebar-active); color: var(--accent); }
nav a.active svg { opacity: 1; }
.sidebar-foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 12px 8px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.user-box { display: flex; align-items: center; gap: 8px; }
.user-box .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 650; font-size: 12px; flex: none; }
.user-box b { display: block; color: var(--text); font-weight: 600; font-size: 12.5px; }
.user-box span { display: block; font-size: 11.5px; color: var(--muted); }
.user-box button:first-of-type { margin-left: auto; }
.user-box button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; }
.user-box button:hover { background: var(--gray-soft); color: var(--text); }
.user-box button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; display: block; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--green); vertical-align: 1px; }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(15, 18, 24, .35); z-index: 25; }

/* ---------------------------------------------------------------- main */
main { flex: 1; min-width: 0; padding: 24px 32px 48px; max-width: 1480px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.topbar-title { flex: 1; min-width: 0; }
.topbar p { margin: 3px 0 0; font-size: 13px; }
.menu-btn { display: none; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: var(--radius-sm); padding: 7px; cursor: pointer; }
.menu-btn svg { width: 20px; height: 20px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.scope { display: flex; background: var(--gray-soft); border-radius: 10px; padding: 3px; }
.scope button { border: 0; background: transparent; color: var(--muted); padding: 6px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 500; }
.scope button:hover { color: var(--text); }
.scope button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .08); }
.view { display: flex; flex-direction: column; gap: 18px; }
.loading, .empty { padding: 36px; text-align: center; color: var(--muted); }
.loading::before { content: ""; display: block; width: 22px; height: 22px; margin: 0 auto 10px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-wide { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .g2, .g3, .g-wide { grid-template-columns: 1fr; } }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head p { margin: 0; font-size: 12px; }
details.panel > summary { cursor: pointer; }
.section-label { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 6px 0 -6px; }

/* ---------------------------------------------------------------- KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); position: relative; }
.kpi .label { font-size: 12.5px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.4; }
.kpi.red .label::before, .kpi.orange .label::before, .kpi.green .label::before, .kpi.blue .label::before,
.kpi.purple .label::before, .kpi.yellow .label::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none; }
.kpi.red .label::before { background: var(--red); }
.kpi.orange .label::before { background: var(--orange); }
.kpi.green .label::before { background: var(--green); }
.kpi.blue .label::before { background: var(--accent); }
.kpi.purple .label::before { background: var(--purple); }
.kpi.yellow .label::before { background: var(--yellow); }
.kpi.click { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.kpi.click:hover { border-color: var(--border-strong); box-shadow: 0 2px 8px rgba(16, 24, 40, .06); }
.tag-proxy { font-size: 10px; background: var(--gray-soft); color: var(--muted); border-radius: 4px; padding: 1px 5px; font-weight: 500; }

/* ---------------------------------------------------------------- alerts */
.alerts { display: flex; flex-direction: column; gap: 8px; max-height: 430px; overflow: auto; }
.alert { display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); cursor: default; }
.alert.red { background: var(--red-soft); border-color: transparent; }
.alert.orange { background: var(--orange-soft); border-color: transparent; }
.alert .ic { font-size: 13px; line-height: 20px; }
.alert strong { display: block; font-weight: 600; }
.alert small { color: var(--muted); }
.alert.link { cursor: pointer; }
.alert.link:hover { border-color: var(--border-strong); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow: auto; max-height: 620px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; letter-spacing: .02em; padding: 9px 10px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); white-space: nowrap; cursor: pointer; user-select: none; }
th:hover { color: var(--text); }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tr.row:hover td { background: var(--surface-2); cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.ellipsis { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { display: inline-block; font-size: 11.5px; font-weight: 500; padding: 2px 8px; border-radius: 999px; white-space: nowrap; background: var(--gray-soft); color: var(--text-2); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.blue { background: var(--accent-soft); color: var(--accent); }
.risk { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; font-weight: 600; }
.risk i { display: block; width: 46px; height: 6px; border-radius: 3px; background: var(--gray-soft); overflow: hidden; }
.risk i b { display: block; height: 100%; border-radius: 3px; }

/* ---------------------------------------------------------------- forms & filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
input, select, textarea { font: inherit; color: var(--text); }
.filters input, .filters select { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.filters input:focus, .filters select:focus, .cura-row select:focus, .ask-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.filters input { min-width: 240px; }
.seg { display: inline-flex; background: var(--gray-soft); border-radius: 9px; padding: 2px; }
.seg button { font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--muted); padding: 5px 12px; cursor: pointer; border-radius: 7px; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, .08); }

/* ---------------------------------------------------------------- bars */
.hbars { display: flex; flex-direction: column; gap: 5px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 13px; position: relative; padding: 5px 9px; border-radius: 6px; }
.hbar .fill { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); border-radius: 6px; z-index: 0; }
.hbar span, .hbar b { position: relative; z-index: 1; }
.hbar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar b { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------------------------------------------------------------- charts */
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 3 4; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------------------------------------------------------------- curadoria */
.cura-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 10px; align-items: center; padding: 7px 8px; border-radius: var(--radius-sm); }
.cura-row + .cura-row { border-top: 1px solid var(--border); }
.cura-row select { padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); width: 100%; }
.cura-row.changed { background: var(--yellow-soft); }
@media (max-width: 760px) { .cura-row { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- heatmap */
table.heat { font-size: 10.5px; border-collapse: separate; border-spacing: 2px; }
table.heat th { position: static; padding: 2px 3px; font-size: 10.5px; text-align: center; cursor: default; background: none; border: 0; }
table.heat td { padding: 0; width: 26px; height: 22px; text-align: center; border: 0; border-radius: 4px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- team */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.person { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.person-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.loadbar { height: 6px; border-radius: 3px; background: var(--gray-soft); position: relative; margin: 8px 0 12px; }
.loadbar b { position: absolute; inset: 0 auto 0 0; border-radius: 3px; }
.loadbar .median { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: .4; }
.mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-size: 11.5px; color: var(--muted); }
.mini div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 7px 8px; }
.mini b { display: block; font-size: 16px; color: var(--text); font-variant-numeric: tabular-nums; }
.note { font-size: 12.5px; background: var(--accent-soft); color: var(--text-2); border-radius: 10px; padding: 11px 14px; line-height: 1.55; }
.note.warn { background: var(--yellow-soft); }

/* ---------------------------------------------------------------- drawer */
.md h1 { font-size: 20px; margin: 4px 0 10px; } .md h2 { font-size: 15px; margin: 18px 0 6px; } .md p { margin: 6px 0; line-height: 1.55; }
.md ul, .md ol { margin: 4px 0 8px; padding-left: 22px; line-height: 1.55; } .md li { margin: 2px 0; }
.md-edit { width: 100%; min-height: 420px; font: 13px/1.5 ui-monospace, Consolas, monospace; padding: 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); resize: vertical; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 18, 24, .3); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(780px, 100vw); background: var(--bg); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  z-index: 50; transform: translateX(100%); transition: transform .22s ease; overflow: auto; padding: 24px 26px 48px; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
#drawer-body { display: flex; flex-direction: column; gap: 14px; }
.drawer-close { position: absolute; right: 14px; top: 12px; width: 32px; height: 32px; border: 0; border-radius: 8px; background: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; }
.drawer-close:hover { background: var(--gray-soft); color: var(--text); }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 7px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.desc { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 13px; max-height: 260px; overflow: auto; }
.reasons { margin: 0; padding-left: 18px; }
.chat { display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; max-height: 560px; overflow: auto; }
.msg { max-width: 82%; padding: 8px 12px; border-radius: 12px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.msg.cli { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.agt { align-self: flex-end; background: var(--accent-soft); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-end; background: var(--gray-soft); color: var(--muted); }
.msg small { display: block; font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.msg.note-int { align-self: center; max-width: 92%; background: var(--yellow-soft); border: 1px dashed var(--yellow); }
.msg a { word-break: break-all; }
.media-img { display: block; max-width: 280px; max-height: 280px; border-radius: 8px; margin-bottom: 4px; cursor: zoom-in; }
.media-img.sticker { max-width: 110px; background: transparent; }
.media-audio { display: block; width: 260px; max-width: 100%; height: 36px; }
.stt { margin-top: 4px; font-size: 12.5px; font-style: italic; opacity: .9; border-left: 2px solid var(--border-strong); padding-left: 7px; }
.media-video { display: block; max-width: 320px; max-height: 260px; border-radius: 8px; background: #000; }
.media-file { display: inline-block; padding: 6px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; }
.timeline { border-left: 2px solid var(--border); margin-left: 6px; padding-left: 14px; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.timeline div { position: relative; }
.timeline div::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--bg); }

/* ---------------------------------------------------------------- buttons & assistant */
.btn, .ask-box button { font: inherit; font-weight: 500; padding: 9px 16px; border-radius: 9px; border: 1px solid transparent; background: var(--accent); color: #fff; cursor: pointer; transition: background .15s; }
.btn:hover, .ask-box button:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--gray-soft); }
.ask-box { display: flex; gap: 8px; }
.ask-box input { flex: 1; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { font: inherit; font-size: 12.5px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.chips button:hover { border-color: var(--accent); color: var(--accent); }
.answer { border-left: 3px solid var(--accent); }
.answer .tool { font-size: 11px; font-family: ui-monospace, Consolas, monospace; color: var(--muted); }

/* ---------------------------------------------------------------- login */
.login-wrap { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); padding: 16px; z-index: 100; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow-lg); }
.login-card .brand { padding: 0 0 20px; }
.login-card label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-2); margin: 12px 0 5px; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card .btn { width: 100%; margin-top: 18px; padding: 11px; }
.login-err { color: var(--red); font-size: 12.5px; margin-top: 10px; min-height: 18px; }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; height: 100vh; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  .menu-btn { display: block; }
  main { padding: 16px 16px 40px; }
  .topbar { gap: 12px; }
  .scope { order: 3; width: 100%; }
  .scope button { flex: 1; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel { padding: 14px; }
  .filters input { min-width: 0; flex: 1; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .drawer { padding: 20px 16px 40px; }
}

/* mapa de clientes por estado */
.mapa-uf .uf:hover path { stroke: var(--text); stroke-width: 1.6; }
.mapa-uf text { pointer-events: none; }
