/* Painel de Gestao - reconstrucao original da UI (tema Buenos Driver)
   Paleta extraida do painel do usuario: navy #323f52, ciano #37b3dd, cinzas, alerta #F13030 */

:root {
  --navy: #323f52;
  --navy-dark: #2a3443;
  --navy-light: #3d4a5e;
  --cyan: #37b3dd;
  --cyan-dark: #2a97bd;
  --cyan-soft: #e8f6fb;
  --red: #f13030;
  --green: #2ecc71;
  --amber: #f6a609;
  --ink: #353535;
  --ink-soft: #6b7683;
  --line: #e6e6e6;
  --line-soft: #eef0f2;
  --bg: #f4f5f7;
  --card: #ffffff;
  --sidebar-w: 256px;
  --topbar-h: 60px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 30, 45, .08), 0 1px 2px rgba(20, 30, 45, .06);
  --shadow-lg: 0 8px 28px rgba(20, 30, 45, .14);
  --font: "Segoe UI", "Source Sans Pro", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cyan-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }

.main-area {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  transition: margin-left .2s ease;
}
body.sidebar-collapsed .main-area { margin-left: 72px; }

/* ---------- sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--navy);
  color: #c7cfda;
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: width .2s ease;
}
body.sidebar-collapsed .sidebar { width: 72px; }

.sidebar__brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .3px;
  background: var(--navy-dark);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar__brand .logo-mark {
  flex: none;
  width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--cyan);
  color: #fff; font-weight: 800;
}
body.sidebar-collapsed .sidebar__brand .logo-text { display: none; }

.sidebar__scroll { overflow-y: auto; overflow-x: hidden; flex: 1; padding: 8px 0 24px; }
.sidebar__scroll::-webkit-scrollbar { width: 8px; }
.sidebar__scroll::-webkit-scrollbar-thumb { background: #46556b; border-radius: 8px; }

.nav-group { list-style: none; margin: 0; padding: 0; }
.nav-group > li { position: relative; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  color: #c7cfda;
  cursor: pointer;
  font-size: 13.5px;
  border-left: 3px solid transparent;
  user-select: none;
  white-space: nowrap;
}
.nav-link:hover { background: var(--navy-light); color: #fff; text-decoration: none; }
.nav-link .material-symbols-outlined { font-size: 20px; flex: none; }
.nav-link .nav-caret { margin-left: auto; font-size: 18px; transition: transform .18s ease; opacity: .7; }
.nav-item.open > .nav-link .nav-caret { transform: rotate(90deg); }
.nav-item.active > .nav-link { color: #fff; border-left-color: var(--cyan); background: rgba(55,179,221,.12); }

body.sidebar-collapsed .nav-link .nav-text,
body.sidebar-collapsed .nav-link .nav-caret { display: none; }

.nav-sub {
  list-style: none;
  margin: 0; padding: 0;
  max-height: 0;
  overflow: hidden;
  background: var(--navy-dark);
  transition: max-height .22s ease;
}
.nav-item.open > .nav-sub { max-height: 1600px; }
.nav-sub .nav-link { padding-left: 52px; font-size: 13px; color: #aab4c2; }
.nav-sub .nav-link:hover { color: #fff; }
.nav-sub .nav-sub .nav-link { padding-left: 68px; }
body.sidebar-collapsed .nav-sub { display: none; }

/* ---------- topbar ---------- */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar__toggle {
  border: none; background: transparent; cursor: pointer;
  width: 38px; height: 38px; border-radius: 8px;
  display: grid; place-items: center; color: var(--navy);
}
.topbar__toggle:hover { background: var(--line-soft); }
.topbar__title { font-size: 16px; font-weight: 600; color: var(--navy); }
.topbar__spacer { flex: 1; }
.topbar__icon {
  position: relative;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-soft);
}
.topbar__icon:hover { background: var(--line-soft); color: var(--navy); }
.topbar__badge {
  position: absolute; top: 6px; right: 6px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 9px; display: grid; place-items: center;
}
.topbar__user { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.topbar__user:hover { background: var(--line-soft); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--cyan); color: #fff; font-weight: 700;
  display: grid; place-items: center; font-size: 13px;
}
.topbar__user-meta { line-height: 1.1; }
.topbar__user-meta .name { font-weight: 600; color: var(--navy); font-size: 13px; }
.topbar__user-meta .role { font-size: 11px; color: var(--ink-soft); }

/* ---------- content ---------- */
.content { padding: 22px 24px 48px; }

.page-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 14px;
  margin-bottom: 18px;
}
.page-head h1 { font-size: 20px; font-weight: 600; color: var(--navy); margin: 0; }
.page-head .spacer { flex: 1; }

/* date range chips */
.range {
  display: inline-flex; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden;
}
.range button {
  border: none; background: #fff; cursor: pointer;
  padding: 8px 14px; font-size: 13px; color: var(--ink-soft);
  border-right: 1px solid var(--line);
}
.range button:last-child { border-right: none; }
.range button:hover { background: var(--line-soft); }
.range button.active { background: var(--cyan); color: #fff; }

/* grid + cards */
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card__head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card__head h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--navy); }
.card__head .material-symbols-outlined { color: var(--cyan); font-size: 20px; }
.card__head .spacer { flex: 1; }

.section-title {
  margin: 28px 0 14px;
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--ink-soft);
  display: flex; align-items: center; gap: 8px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* KPI tile */
.kpi { display: flex; align-items: center; gap: 14px; }
.kpi__icon {
  width: 46px; height: 46px; border-radius: 12px; flex: none;
  display: grid; place-items: center; color: #fff;
}
.kpi__icon.c { background: var(--cyan); }
.kpi__icon.g { background: var(--green); }
.kpi__icon.a { background: var(--amber); }
.kpi__icon.n { background: var(--navy); }
.kpi__value { font-size: 24px; font-weight: 700; color: var(--navy); line-height: 1; }
.kpi__label { font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; }
.kpi__delta { font-size: 12px; font-weight: 600; margin-top: 2px; }
.kpi__delta.up { color: var(--green); }
.kpi__delta.down { color: var(--red); }

.chart-wrap { position: relative; height: 240px; }
.chart-wrap.sm { height: 190px; }

/* legend list */
.legend { list-style: none; margin: 12px 0 0; padding: 0; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .legend-val { margin-left: auto; font-weight: 600; color: var(--navy); }

/* NPS bar */
.nps__score { font-size: 32px; font-weight: 800; color: var(--navy); }
.nps__bar { display: flex; height: 12px; border-radius: 7px; overflow: hidden; margin: 12px 0; }
.nps__bar span { display: block; }
.nps__row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-soft); }
.nps__row b { color: var(--navy); }

/* ---------- filters panel (corridas) ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--navy);
  padding: 9px 16px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.btn:hover { background: var(--line-soft); text-decoration: none; }
.btn--primary { background: var(--cyan); border-color: var(--cyan); color: #fff; }
.btn--primary:hover { background: var(--cyan-dark); }
.btn--ghost { background: transparent; }

.filters {
  background: #fff; border: 1px solid var(--line-soft); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px;
}
.filters__grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.field input, .field select {
  border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px;
  font-size: 13px; font-family: var(--font); background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-soft); }
.filters__foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ---------- table ---------- */
.table-card { background: #fff; border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table.grid-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid-table thead th {
  background: #fafbfc; text-align: left; padding: 12px 14px;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--ink-soft); border-bottom: 1px solid var(--line);
}
table.grid-table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); color: var(--ink); }
table.grid-table tbody tr:hover { background: var(--cyan-soft); }
table.grid-table tbody tr:last-child td { border-bottom: none; }
.cell-os { font-weight: 700; color: var(--navy); }
.muted { color: var(--ink-soft); font-size: 12px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge--ok { background: #e7f8ef; color: #1e8f52; }
.badge--wait { background: #fff4e0; color: #b9780a; }
.badge--cancel { background: #fde8e8; color: #c62828; }
.badge--run { background: var(--cyan-soft); color: var(--cyan-dark); }

.icn-alert { color: var(--amber); }

.table-foot { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); background: #fafbfc; }
.table-foot .spacer { flex: 1; }
.pager { display: inline-flex; gap: 4px; }
.pager button { min-width: 32px; height: 32px; border: 1px solid var(--line); background: #fff; border-radius: 7px; cursor: pointer; color: var(--navy); font-size: 13px; }
.pager button.active { background: var(--cyan); color: #fff; border-color: var(--cyan); }
.pager button:hover:not(.active) { background: var(--line-soft); }

/* upsell banner */
.banner {
  background: linear-gradient(100deg, var(--navy), #42526a);
  color: #fff; border-radius: var(--radius); padding: 20px 24px;
  display: flex; align-items: center; gap: 18px; box-shadow: var(--shadow);
}
.banner h3 { margin: 0 0 4px; font-size: 16px; }
.banner p { margin: 0; color: #c7cfda; font-size: 13px; }
.banner .spacer { flex: 1; }

.demo-note {
  margin: 0 0 18px; padding: 10px 14px; border-radius: 8px;
  background: #fff8e1; border: 1px solid #ffe49a; color: #7a5b00; font-size: 12.5px;
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .filters__grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .sidebar { width: 72px; }
  .sidebar .nav-text, .sidebar .nav-caret, .sidebar__brand .logo-text { display: none; }
  .sidebar .nav-sub { display: none; }
  .main-area { margin-left: 72px; }
  .grid.cols-2, .grid.cols-4, .grid.cols-3 { grid-template-columns: 1fr; }
  .filters__grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}

/* material symbols fallback (if font not present, show nothing weird) */
.material-symbols-outlined {
  font-family: "Material Symbols Outlined", "Segoe UI Symbol", sans-serif;
  font-weight: normal; font-style: normal; line-height: 1;
  letter-spacing: normal; text-transform: none; white-space: nowrap;
  display: inline-block;
}

/* ---------- chat (Conversas) ---------- */
.chat { display: grid; grid-template-columns: 300px 1fr; gap: 0; background: #fff; border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; height: 560px; }
.chat-list { border-right: 1px solid var(--line); overflow-y: auto; }
.chat-item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; border-bottom: 1px solid var(--line-soft); }
.chat-item:hover { background: var(--line-soft); }
.chat-item.active { background: var(--cyan-soft); }
.chat-thread { display: flex; flex-direction: column; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 600; color: var(--navy); }
.chat-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: #f7f9fb; }
.bubble { max-width: 70%; padding: 10px 14px; border-radius: 14px; font-size: 13.5px; background: #fff; border: 1px solid var(--line); align-self: flex-start; }
.bubble.me { align-self: flex-end; background: var(--cyan); color: #fff; border-color: var(--cyan); }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-family: var(--font); font-size: 13px; }
.chat-input input:focus { outline: none; border-color: var(--cyan); }

/* ---------- mapa ---------- */
.map-canvas { position: relative; height: 480px; background:
  linear-gradient(0deg, rgba(50,63,82,.06) 1px, transparent 1px) 0 0/40px 40px,
  linear-gradient(90deg, rgba(50,63,82,.06) 1px, transparent 1px) 0 0/40px 40px,
  #eef2f6; }
.map-dot { position: absolute; width: 14px; height: 14px; border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 0 4px rgba(255,255,255,.6); }
.map-dot.on { background: var(--green); }
.map-dot.off { background: var(--amber); }
.map-legend { position: absolute; left: 14px; bottom: 14px; display: flex; gap: 16px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 12.5px; box-shadow: var(--shadow); }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend .map-dot { position: static; transform: none; box-shadow: none; width: 10px; height: 10px; }

/* ---------- planos ---------- */
.plan { position: relative; display: flex; flex-direction: column; }
.plan--current { border: 2px solid var(--cyan); }
.plan-tag { position: absolute; top: -11px; left: 18px; background: var(--cyan); color: #fff; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.plan-price { font-size: 28px; font-weight: 800; color: var(--navy); margin: 6px 0 14px; }
.plan-price span { font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.plan-feats { list-style: none; margin: 0 0 18px; padding: 0; flex: 1; }
.plan-feats li { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 13px; color: var(--ink); }
.plan-feats .material-symbols-outlined { color: var(--green); font-size: 18px; }

/* ---------- integrações / switch ---------- */
.integration { display: flex; align-items: center; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--line-soft); }
.integration:last-child { border-bottom: none; }
.integration-ic { width: 42px; height: 42px; border-radius: 10px; background: var(--cyan-soft); color: var(--cyan-dark); display: grid; place-items: center; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cdd4dc; border-radius: 24px; cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--cyan); }
.switch input:checked + span::before { transform: translateX(20px); }

/* ---------- mini lista top ---------- */
.toplist { list-style: none; margin: 0; padding: 0; }
.toplist li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.toplist li:last-child { border-bottom: none; }
.toplist .rank { width: 22px; height: 22px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; flex: none; }
.toplist .tl-val { margin-left: auto; font-weight: 700; color: var(--navy); }

@media (max-width: 820px) { .chat { grid-template-columns: 1fr; height: auto; } .chat-list { max-height: 220px; } }
