/* Cockpit SDR — identidade visual baseada em ochannel.com.br */
:root {
  --verde: #018B58;
  --verde-escuro: #016B44;
  --verde-claro: rgba(1, 139, 88, 0.12);
  --menta: #E8F5EF;
  --neutro: #F4F4F4;
  --texto: #1F2937;
  --texto-sec: #4B5563;
  --texto-suave: #6B7280;
  --escuro: #111827;
  --borda: #E5E7EB;
}

* { font-family: 'Figtree', system-ui, -apple-system, sans-serif; }

body {
  background: var(--neutro);
  color: var(--texto);
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 232px;
  min-height: 100vh;
  background: #fff;
  border-right: 1px solid var(--borda);
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 1030;
}
.sidebar .brand {
  padding: 20px 20px 14px;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--texto);
}
.sidebar .brand .dot { color: var(--verde); }
.sidebar .tenant-badge {
  margin: 0 16px 12px;
  padding: 6px 12px;
  background: var(--menta);
  color: var(--verde);
  border-radius: 10px;
  font-size: .78rem;
  font-weight: 600;
}
.sidebar .nav-link {
  color: var(--texto-sec);
  padding: 10px 20px;
  border-radius: 10px;
  margin: 2px 10px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .92rem;
}
.sidebar .nav-link:hover { background: var(--neutro); color: var(--texto); }
.sidebar .nav-link.active { background: var(--verde-claro); color: var(--verde); font-weight: 700; }
.sidebar .footer-user {
  margin-top: auto;
  padding: 14px 20px;
  border-top: 1px solid var(--borda);
  font-size: .82rem;
  color: var(--texto-suave);
}

.main-content { margin-left: 232px; padding: 24px 28px; }
body.embed .sidebar { display: none; }
body.embed .main-content { margin-left: 0; }
body.embed .topbar-mobile { display: none !important; }

/* ---------- Topbar mobile ---------- */
.topbar-mobile {
  display: none;
  position: sticky;
  top: 0;
  z-index: 1040;
  background: #fff;
  border-bottom: 1px solid var(--borda);
  padding: 10px 14px;
  align-items: center;
  gap: 12px;
}
.topbar-mobile .brand { font-weight: 800; font-size: 1.05rem; color: var(--texto); }
.topbar-mobile .brand .dot { color: var(--verde); }
.topbar-mobile .btn-menu {
  border: 1px solid var(--borda);
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  color: var(--texto);
  font-size: 1.2rem;
  line-height: 1;
}

/* ---------- Mobile (≤ 991px) ---------- */
@media (max-width: 991.98px) {
  .topbar-mobile { display: flex; }
  .sidebar {
    left: -260px;
    width: 250px;
    transition: left .25s ease;
    box-shadow: none;
    height: 100vh;
    overflow-y: auto;
  }
  .sidebar.aberta {
    left: 0;
    box-shadow: 0 0 40px rgba(0,0,0,.25);
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17,24,39,.45);
    z-index: 1029;
  }
  .sidebar-backdrop.aberta { display: block; }
  .main-content { margin-left: 0; padding: 14px 12px; }
  .kpi-card { padding: 12px 14px; }
  .kpi-card .valor { font-size: 1.45rem; }
  .kpi-card .rotulo { font-size: .72rem; }
  h1, .h1 { font-size: 1.35rem; }
  h2, .h2 { font-size: 1.2rem; }
  .kanban-col { min-width: 240px; max-width: 240px; }
  .kanban-board { -webkit-overflow-scrolling: touch; }
  .btn-flutuante {
    position: fixed !important;
    bottom: 16px; right: 16px;
    top: auto !important;
    padding: 10px 16px !important;
    font-size: .85rem;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
  }
  .table { font-size: .82rem; }
  .acoes-rapidas .btn { padding: 6px 10px; font-size: .8rem; }
}

/* ---------- Componentes ---------- */
.card { border: 1px solid var(--borda); border-radius: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.card-header { background: #fff; border-bottom: 1px solid var(--borda); border-radius: 14px 14px 0 0 !important; font-weight: 700; }

.btn-verde {
  background: var(--verde);
  color: #fff;
  border: none;
  border-radius: 50rem;
  padding: 8px 20px;
  font-weight: 600;
}
.btn-verde:hover { background: var(--verde-escuro); color: #fff; }
.btn-outline-verde {
  border: 1.5px solid var(--verde);
  color: var(--verde);
  border-radius: 50rem;
  padding: 7px 18px;
  font-weight: 600;
  background: transparent;
}
.btn-outline-verde:hover { background: var(--verde-claro); color: var(--verde); }

.badge-pill { border-radius: 50rem; padding: 4px 12px; font-weight: 600; font-size: .75rem; }
.badge-quente { background: #FEE2E2; color: #B91C1C; }
.badge-morno { background: #FEF3C7; color: #B45309; }
.badge-frio { background: #DBEAFE; color: #1D4ED8; }
.badge-verde { background: var(--verde-claro); color: var(--verde); }
.badge-cinza { background: var(--neutro); color: var(--texto-sec); }

.kpi-card { text-align: left; padding: 18px 20px; }
.kpi-card .valor { font-size: 1.9rem; font-weight: 800; color: var(--texto); line-height: 1.1; }
.kpi-card .rotulo { color: var(--texto-suave); font-size: .82rem; font-weight: 600; }
.kpi-card.destaque { background: var(--verde); }
.kpi-card.destaque .valor, .kpi-card.destaque .rotulo { color: #fff; }

/* ---------- Kanban ---------- */
.kanban-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  align-items: flex-start;
  padding-bottom: 12px;
}
.kanban-col {
  background: var(--neutro);
  border-radius: 14px;
  min-width: 265px;
  max-width: 265px;
  padding: 12px;
}
.kanban-col h6 {
  font-weight: 700;
  font-size: .85rem;
  display: flex;
  justify-content: space-between;
  padding: 2px 4px 8px;
}
.kanban-cards { min-height: 60px; max-height: calc(100vh - 220px); overflow-y: auto; }
.kanban-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--borda);
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: grab;
  font-size: .85rem;
}
.kanban-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.kanban-card .empresa { font-weight: 700; color: var(--texto); }
.kanban-card .meta { color: var(--texto-suave); font-size: .76rem; }
.sortable-ghost { opacity: .4; }

/* ---------- Fila de ligações ---------- */
.fila-item { cursor: pointer; border-left: 3px solid transparent; }
.fila-item.ativo { border-left-color: var(--verde); background: var(--menta); }
.timeline { border-left: 2px solid var(--borda); padding-left: 16px; }
.timeline .evento { position: relative; margin-bottom: 14px; font-size: .85rem; }
.timeline .evento::before {
  content: "";
  position: absolute;
  left: -21px; top: 5px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--verde);
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--menta) 0%, #fff 60%);
}
.login-card { max-width: 400px; width: 100%; padding: 36px; border-radius: 18px; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { --bs-table-hover-bg: var(--menta); }
.table thead th { color: var(--texto-suave); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 2px solid var(--borda); }

a { color: var(--verde); text-decoration: none; }
a:hover { color: var(--verde-escuro); }
.form-control:focus, .form-select:focus { border-color: var(--verde); box-shadow: 0 0 0 .2rem var(--verde-claro); }


/* ---------- Configuração do Funil e Checklist PIC ---------- */
.funil-config-topo .page-icon,
.funil-config-header .section-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-size: 1.05rem;
}

.funil-config-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.funil-config-tab {
  appearance: none;
  border: 1px solid var(--borda);
  background: #fff;
  border-radius: 14px;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--texto-sec);
  text-align: left;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .04);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.funil-config-tab:hover {
  border-color: rgba(1, 139, 88, .4);
  box-shadow: 0 4px 14px rgba(17, 24, 39, .07);
  transform: translateY(-1px);
}
.funil-config-tab.active {
  color: var(--texto);
  border-color: var(--verde);
  box-shadow: 0 0 0 2px var(--verde-claro), 0 4px 14px rgba(17, 24, 39, .06);
}
.funil-config-tab:focus-visible,
.drag-handle:focus-visible,
.btn-action:focus-visible {
  outline: 3px solid rgba(1, 139, 88, .24);
  outline-offset: 2px;
}
.funil-tab-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.funil-tab-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.funil-tab-text strong { font-size: .91rem; }
.funil-tab-text small {
  color: var(--texto-suave);
  font-size: .75rem;
  margin-top: 3px;
}
.funil-config-tab > .bi-chevron-right { font-size: .76rem; opacity: .55; }
.funil-config-tab.active > .bi-chevron-right { color: var(--verde); opacity: 1; }

.funil-config-card { overflow: hidden; }
.funil-config-header {
  min-height: 76px;
  padding: 15px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.funil-config-header h5 { font-size: 1rem; font-weight: 750; }
.funil-config-header .btn { white-space: nowrap; }
.funil-helpbar {
  min-height: 42px;
  padding: 9px 18px;
  background: #fafafa;
  border-bottom: 1px solid var(--borda);
  color: var(--texto-suave);
  font-size: .78rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.funil-helpbar > span { display: inline-flex; align-items: center; gap: 5px; }

.funil-stage-list { min-height: 72px; }
.funil-stage-item {
  min-height: 72px;
  padding: 11px 16px 11px 12px;
  display: grid;
  grid-template-columns: 38px 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-color: var(--borda);
  transition: background .15s ease, box-shadow .15s ease;
}
.funil-stage-item:hover { background: #fbfdfc; }
.drag-handle {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #9ca3af;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  font-size: 1.05rem;
}
.drag-handle:hover { background: var(--neutro); color: var(--texto-sec); }
.drag-handle:active { cursor: grabbing; }
.stage-color {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--stage-color, var(--verde));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--stage-color, var(--verde)) 14%, transparent);
}
.stage-main { min-width: 0; }
.stage-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: .91rem;
  font-weight: 700;
  color: var(--texto);
}
.stage-name .badge { font-size: .67rem; font-weight: 650; }
.stage-main > small { display: block; margin-top: 3px; font-size: .76rem; }
.stage-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}
.btn-action {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.save-status {
  min-height: 20px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .75rem;
  font-weight: 650;
  white-space: nowrap;
}
.save-status.is-saving { color: #92400e; }
.save-status.is-saving .bi { animation: funil-spin .9s linear infinite; }
.save-status.is-saved { color: var(--verde); }
.save-status.is-error { color: #b91c1c; }
@keyframes funil-spin { to { transform: rotate(360deg); } }
.sortable-chosen { background: var(--menta) !important; }
.sortable-ghost { opacity: .35; box-shadow: inset 0 0 0 2px var(--verde); }

.checklist-toolbar {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--borda);
}
.checklist-search { max-width: 380px; }
.checklist-filter { width: 170px; flex: 0 0 170px; }
.checklist-helpbar { border-top: 0; }
.checklist-config-list { min-height: 80px; }
.checklist-config-item {
  min-height: 94px;
  padding: 13px 16px 13px 12px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  background: #fff;
  border-bottom: 1px solid var(--borda);
  transition: background .15s ease;
}
.checklist-config-item:last-child { border-bottom: 0; }
.checklist-config-item:hover { background: #fbfdfc; }
.checklist-config-item.is-inactive { background: #fafafa; }
.checklist-config-item.is-inactive .checklist-item-main { opacity: .67; }
.checklist-item-main { min-width: 0; }
.checklist-item-title {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: var(--texto);
  font-size: .9rem;
  line-height: 1.35;
}
.checklist-item-main p { margin-top: 4px; line-height: 1.35; }
.checklist-item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.checklist-item-meta .badge { font-size: .68rem; }
.checklist-actions { align-self: center; }

.empty-state {
  min-height: 190px;
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  color: var(--texto-suave);
  border: 0;
}
.empty-state > .bi { font-size: 1.9rem; color: #9ca3af; }
.empty-state strong { color: var(--texto); }
.empty-state span { max-width: 420px; font-size: .83rem; }
.empty-state .btn { margin-top: 4px; }

.final-stage-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.final-stage-options .form-check {
  min-height: 72px;
  margin: 0;
  padding: 12px 12px 12px 37px;
  border: 1px solid var(--borda);
  border-radius: 12px;
  background: #fff;
}
.final-stage-options .form-check-input { margin-top: .25rem; }
.final-stage-options label { display: flex; flex-direction: column; gap: 3px; }
.final-stage-options label small { color: var(--texto-suave); font-size: .75rem; }
.modal-danger-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #fee2e2;
  color: #b91c1c;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 767.98px) {
  .funil-config-tabs { grid-template-columns: 1fr; gap: 8px; }
  .funil-config-tab { padding: 10px 12px; }
  .funil-config-tab > .bi-chevron-right { transform: rotate(90deg); }
  .funil-config-header { min-height: auto; padding: 13px 14px; }
  .funil-helpbar { padding: 9px 12px; flex-wrap: wrap; }
  .checklist-toolbar { align-items: stretch; flex-wrap: wrap; padding: 10px 12px; }
  .checklist-search { max-width: none; flex: 1 1 100%; }
  .checklist-filter { width: auto; flex: 1 1 170px; }
  .checklist-toolbar .save-status { margin-left: 0 !important; }
  .final-stage-options { grid-template-columns: 1fr; }
}

@media (max-width: 575.98px) {
  .funil-config-topo { align-items: flex-start; gap: 12px; }
  .funil-config-topo > .btn { width: 100%; }
  .funil-config-header { align-items: flex-start; flex-direction: column; }
  .funil-config-header > .btn { width: 100%; }
  .funil-stage-item {
    min-height: 82px;
    padding: 10px 10px 10px 7px;
    grid-template-columns: 38px 16px minmax(0, 1fr) auto;
    gap: 7px;
  }
  .stage-name { font-size: .86rem; }
  .stage-actions { flex-direction: column; gap: 5px; }
  .btn-action { width: 34px; height: 34px; }
  .checklist-config-item {
    min-height: 108px;
    padding: 11px 10px 11px 7px;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 7px;
  }
  .checklist-actions { flex-direction: column; }
  .checklist-item-title { font-size: .84rem; }
  .checklist-item-meta .text-muted { width: 100%; }
  .modal-footer { flex-wrap: nowrap; }
  .modal-footer .btn { flex: 1 1 auto; }
}

/* Contador global da fila SDR */
.sidebar .fila-pendencias-badge {
  min-width: 1.7rem;
  padding: .3rem .45rem;
  cursor: pointer;
  line-height: 1;
  flex: 0 0 auto;
}
.sidebar .fila-pendencias-badge:focus-visible {
  outline: 2px solid var(--verde);
  outline-offset: 2px;
}

/* FAROL — onboarding de 90 dias com checklists executáveis */
.farol-summary-card {
  background: linear-gradient(135deg, rgba(1,139,88,.09), rgba(255,255,255,.98));
  border-left: 4px solid #018b58 !important;
}
.farol-stage .accordion-button {
  gap: .35rem;
  padding: .9rem 1rem;
  background: #fff;
  box-shadow: none;
}
.farol-stage .accordion-button:not(.collapsed) {
  color: #173d30;
  background: rgba(1,139,88,.055);
}
.farol-stage.farol-stage-late .accordion-button {
  border-left: 3px solid #dc3545;
}
.farol-stage-number,
.farol-check-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  border: 1px solid #ced4da;
  background: #fff;
  color: #6c757d;
  font-weight: 700;
  font-size: .78rem;
}
.farol-stage-number.is-done,
.farol-check-status.is-done {
  color: #fff;
  border-color: #018b58;
  background: #018b58;
}
.farol-check-status.is-progress { color: #0d6efd; border-color: #0d6efd; background: #eaf2ff; }
.farol-check-status.is-waiting { color: #7a5900; border-color: #ffc107; background: #fff6d8; }
.farol-check-status.is-na { color: #fff; border-color: #6c757d; background: #6c757d; }
.farol-stage-progress { width: 86px; }
.farol-stage-progress .progress { height: 5px; margin-top: 3px; }
.farol-stage-context {
  padding: .75rem 1rem;
  color: #36584b;
  background: #f6faf8;
  border-bottom: 1px solid #e1ebe7;
  font-size: .82rem;
}
.farol-check-item { padding: .85rem 1rem; }
.farol-check-item.is-done { background: #f7faf8; }
.farol-check-item.is-done strong { color: #557068; }
.farol-check-item.is-late { border-left: 3px solid #dc3545; background: #fffafa; }
.farol-check-form { padding: .8rem; border-radius: .65rem; background: #f8f9fa; }
.farol-stage-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .8rem 1rem;
  border-top: 1px solid #e7ecea;
  background: #fbfcfc;
}
@media (max-width: 767.98px) {
  .farol-stage .accordion-button { padding: .75rem; }
  .farol-check-item { padding: .75rem; }
  .farol-stage-footer { align-items: stretch; }
  .farol-stage-footer > div:last-child { width: 100%; }
  .farol-stage-footer form { max-width: 100%; flex-wrap: wrap; }
  .farol-stage-footer input { min-width: 0; }
}

/* Novo projeto: rolagem interna previsível em notebooks e celulares */
#modalNovoProjeto .modal-dialog {
  height: calc(100vh - 1rem);
  height: calc(100dvh - 1rem);
  margin-top: .5rem;
  margin-bottom: .5rem;
}
#modalNovoProjeto .modal-content {
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}
#modalNovoProjeto .modal-header,
#modalNovoProjeto .modal-footer {
  flex: 0 0 auto;
}
#modalNovoProjeto .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}
#modalNovoProjeto .modal-footer {
  position: relative;
  z-index: 2;
  background: #fff;
  box-shadow: 0 -8px 18px rgba(15, 23, 42, .06);
}
@media (min-width: 576px) {
  #modalNovoProjeto .modal-dialog {
    height: calc(100vh - 2rem);
    height: calc(100dvh - 2rem);
    margin-top: 1rem;
    margin-bottom: 1rem;
  }
}
#modalNovoProjeto .modal-content > form {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
