/* CRM Forca de Vendas - identidade corporativa telecom B2B.
   Toda a identidade mora nas variaveis abaixo, preparada para troca futura de marca. */
:root {
  --brand: #b3261e;            /* acento institucional */
  --brand-strong: #8f1d17;
  --nav-bg: #14181f;           /* sidebar grafite */
  --nav-ink: #c6ccd6;
  --nav-active: #ffffff;
  --surface: #f4f5f7;
  --card: #ffffff;
  --ink: #1c2430;              /* texto primario */
  --ink-2: #4b5563;            /* texto secundario */
  --ink-3: #8a93a1;            /* texto apagado */
  --line: #e3e6ea;
  --seq: #345d8a;              /* matiz unico para barras de magnitude */
  --seq-soft: #e5edf5;
  --ok: #1c7c43;  --ok-soft: #e2f2e8;
  --warn: #9a6a00; --warn-soft: #fdf3d8;
  --bad: #b3261e;  --bad-soft: #fbe9e7;
  --info-soft: #e8eef5;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08);
  font-size: 15px;
}
* { box-sizing: border-box; margin: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--surface); color: var(--ink); }
a { color: var(--seq); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, #14181f 0%, #232a35 60%, #3a2426 100%); padding: 16px; }
.login-card { background: var(--card); border-radius: 14px; padding: 36px 32px; width: 100%; max-width: 380px; box-shadow: 0 12px 40px rgba(0,0,0,.35); }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-brand { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.login-brand .logo { width: 40px; height: 40px; border-radius: 10px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 22px; }
.login-sub { color: var(--ink-3); font-size: 13px; margin-bottom: 22px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--nav-bg); color: var(--nav-ink); padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 16px; }
.sidebar .brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; font-weight: 800; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--nav-ink); font-size: 14px; border: 0; background: none; width: 100%; text-align: left; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--brand); color: var(--nav-active); font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; }
.nav-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6b7484; padding: 14px 12px 4px; }
.sidebar .foot { margin-top: auto; padding: 10px 12px; font-size: 12px; color: #6b7484; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 22px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.topbar .search { flex: 1; max-width: 480px; position: relative; }
.topbar .search input { width: 100%; padding: 9px 12px 9px 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.topbar .search .ico { position: absolute; left: 11px; top: 9px; color: var(--ink-3); }
.search-results { position: absolute; top: 42px; left: 0; right: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); max-height: 380px; overflow-y: auto; z-index: 50; }
.search-results .item { padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.search-results .item:hover { background: var(--surface); }
.userchip { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.userchip .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--seq); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.userchip .who { line-height: 1.15; }
.userchip .who b { font-size: 13.5px; display: block; }
.userchip .who span { font-size: 11.5px; color: var(--ink-3); }
.bell { position: relative; border: 1px solid var(--line); background: var(--card); border-radius: 8px; width: 38px; height: 38px; font-size: 16px; }
.bell .dot { position: absolute; top: -5px; right: -5px; background: var(--brand); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 999px; min-width: 17px; height: 17px; display: grid; place-items: center; padding: 0 3px; }
.notif-panel { position: absolute; right: 18px; top: 58px; width: 360px; max-width: calc(100vw - 24px); background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 40px rgba(0,0,0,.16); z-index: 60; max-height: 65vh; overflow-y: auto; }
.notif-panel .head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
.notif { padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; cursor: pointer; }
.notif.unread { background: var(--info-soft); }
.notif small { color: var(--ink-3); display: block; margin-top: 3px; }

.content { padding: 22px; max-width: 1280px; width: 100%; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-head h2 { font-size: 21px; }
.page-head .spacer { flex: 1; }

/* ---------- componentes ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .card-head { padding: 13px 16px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.card .card-body { padding: 16px; }
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.btn { border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--surface); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-strong); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--seq); outline-offset: -1px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
.form-grid .wide { grid-column: 1 / -1; }

.error-msg { background: var(--bad-soft); color: var(--bad); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 12px; }

/* tabela */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; padding: 10px 12px; color: var(--ink-2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 2px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
table.data th.nosort { cursor: default; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:hover { background: #f8fafc; }
table.data tbody tr.clickable { cursor: pointer; }
.pager { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.pager .spacer { flex: 1; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--info-soft); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.seq { background: var(--seq-soft); color: var(--seq); }

/* stat tiles (dashboard) */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 17px; box-shadow: var(--shadow); }
.tile .label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.tile .value { font-size: 27px; font-weight: 700; margin-top: 5px; font-variant-numeric: tabular-nums; }
.tile .value small { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.tile.alert .value { color: var(--bad); }
.tile.good .value { color: var(--ok); }
.tile.clickable { cursor: pointer; }
.tile.clickable:hover { border-color: var(--seq); }

/* barras de magnitude: um unico matiz, rotulo em tinta */
.barlist .row { display: grid; grid-template-columns: 130px 1fr 46px; align-items: center; gap: 10px; padding: 5px 0; font-size: 13px; }
.barlist .row .name { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barlist .bar { height: 14px; background: var(--seq); border-radius: 0 4px 4px 0; min-width: 2px; }
.barlist .track { background: var(--seq-soft); border-radius: 0 4px 4px 0; }
.barlist .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }

/* filtros */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.filters .field { margin-bottom: 0; min-width: 140px; flex: 0 1 170px; }
.filters .field.grow { flex: 1 1 220px; }

/* ficha da empresa */
.company-head { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.company-head h2 { font-size: 20px; }
.company-head .meta { color: var(--ink-2); font-size: 13.5px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 9px 14px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.timeline { list-style: none; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--line); margin-left: 8px; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--seq); }
.timeline li:last-child { border-left-color: transparent; }
.timeline .when { font-size: 12px; color: var(--ink-3); }
.timeline .what { font-size: 14px; margin: 2px 0; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 7px 12px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { font-weight: 500; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(10,14,20,.5); display: grid; place-items: center; z-index: 100; padding: 14px; }
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal .m-head { display: flex; justify-content: space-between; align-items: center; padding: 15px 18px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 16px; }
.modal .m-body { padding: 18px; }
.modal .m-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); }
.x-btn { border: 0; background: none; font-size: 20px; color: var(--ink-3); }

/* toast */
#toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--nav-bg); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 340px; }
.toast.err { background: var(--brand-strong); }

.empty { text-align: center; color: var(--ink-3); padding: 28px 10px; font-size: 13.5px; }
.muted { color: var(--ink-3); font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 4px 0; }
.chk input { width: 16px; height: 16px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }

/* funil kanban */
.funil-board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.funil-col { background: #eceff3; border-radius: var(--radius); min-width: 250px; flex: 1 0 250px; padding: 8px; }
.funil-col.drag-over { background: var(--seq-soft); outline: 2px dashed var(--seq); }
.funil-col-head { display: flex; flex-direction: column; gap: 1px; padding: 6px 8px 10px; font-size: 13.5px; }
.funil-col-head .muted { font-size: 12px; }
.funil-col-body { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.funil-card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px; cursor: grab; box-shadow: var(--shadow); }
.funil-card:active { cursor: grabbing; }
.funil-card:hover { border-color: var(--seq); }

/* import steps */
.steps { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.step { font-size: 12.5px; padding: 5px 11px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink-3); }
.step.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.step.done { background: var(--ok-soft); border-color: var(--ok-soft); color: var(--ok); }

/* ---------- mobile ---------- */
.mobile-nav { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .content { padding: 14px; padding-bottom: 84px; }
  .topbar { padding: 10px 12px; }
  .userchip .who { display: none; }
  .mobile-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--nav-bg); z-index: 80; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .mobile-nav button { flex: 1; border: 0; background: none; color: var(--nav-ink); font-size: 10.5px; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 2px; border-radius: 8px; }
  .mobile-nav button .ico { font-size: 19px; }
  .mobile-nav button.active { color: #fff; }
  .mobile-nav button.active .ico { color: var(--brand); }
  .kv { grid-template-columns: 110px 1fr; }
  .filters .field { flex: 1 1 46%; min-width: 0; }
  table.data th, table.data td { padding: 8px 8px; }
  .hide-m { display: none !important; }
}
