/* Nexo CRM — design system (executivo, minimalista, claro + escuro, mobile-first) */

/* ---------- tokens ---------- */
:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #FBFCFD;
  --elev: #FFFFFF;
  --ink: #0F172A;
  --ink-2: #475569;
  --muted: #94A3B8;
  --line: #E6E9EF;
  --line-2: #EFF1F5;
  --accent: #6366F1;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(99, 102, 241, 0.10);
  --good: #10B981;
  --warn: #F59E0B;
  --bad: #EF4444;
  --info: #0EA5E9;
  --good-soft: rgba(16, 185, 129, 0.12);
  --warn-soft: rgba(245, 158, 11, 0.14);
  --bad-soft: rgba(239, 68, 68, 0.12);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.18);
  --radius: 14px;
  --radius-sm: 10px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #0B0F17;
  --surface: #131A24;
  --surface-2: #0F151E;
  --elev: #182231;
  --ink: #E8EDF4;
  --ink-2: #AEB9C7;
  --muted: #6B7788;
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.06);
  --accent: #818CF8;
  --accent-ink: #0B0F17;
  --accent-soft: rgba(129, 140, 248, 0.16);
  --good-soft: rgba(16, 185, 129, 0.18);
  --warn-soft: rgba(245, 158, 11, 0.18);
  --bad-soft: rgba(239, 68, 68, 0.18);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 50px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.45;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }
::selection { background: var(--accent-soft); }

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

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.02em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--accent), #0EA5E9);
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 15px;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}
.brand-name { font-size: 16px; }
.brand-tag { font-size: 11px; color: var(--muted); font-weight: 500; margin-top: -2px; }
.spacer { flex: 1; }

.nav { display: flex; gap: 4px; align-items: center; }
.nav-item {
  border: 0; background: transparent; color: var(--ink-2);
  padding: 7px 13px; border-radius: 9px; font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; gap: 7px; transition: all .12s;
}
.nav-item:hover { background: var(--line-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item .nav-ico { font-size: 15px; line-height: 1; }
.nav-badge {
  min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 10px; font-weight: 700;
  display: inline-grid; place-items: center;
}

.content { flex: 1; padding: 22px 20px 90px; max-width: 1240px; width: 100%; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.view-title { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; margin: 0; }
.view-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; gap: 7px; transition: all .12s; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: 0 2px 10px rgba(99,102,241,.28); }
.btn-primary:hover { filter: brightness(1.05); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-2); }
.btn-danger { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.btn-danger:hover { background: var(--bad); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); display: grid; place-items: center; font-size: 15px;
}
.icon-btn:hover { color: var(--ink); border-color: var(--muted); }

/* ---------- sync pill ---------- */
.sync-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); padding: 4px 9px; border-radius: 20px; border: 1px solid var(--line); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.sync-pill.saving .sync-dot { background: var(--warn); }
.sync-pill.error .sync-dot, .sync-pill.offline .sync-dot { background: var(--bad); }

/* ---------- cards / grids ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.grid > * { min-width: 0; } /* permite que tracks 1fr encolham (evita overflow horizontal) */
.kpi-grid { grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); }
.panel-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.kpi { padding: 16px; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; margin-top: 8px; }
.kpi-sub { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.kpi-accent .kpi-value { color: var(--accent); }
.kpi .delta { font-size: 12px; font-weight: 700; }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); } .delta.flat { color: var(--muted); }

.panel { padding: 16px 16px 18px; }
.panel-title { font-size: 13px; font-weight: 700; margin: 0 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-title .hint { font-weight: 500; color: var(--muted); font-size: 11px; }

/* ---------- charts ---------- */
.chart-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 26px 10px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg .axis { fill: var(--muted); font-size: 11px; }
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; align-items: center; gap: 10px; }
.bar-label { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--line-2); border-radius: 6px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; transition: width .4s ease; }
.bar-val { font-size: 12px; font-weight: 700; min-width: 42px; text-align: right; }
.donut-wrap { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.donut { width: 148px; height: 148px; flex: none; }
.donut-num { fill: var(--ink); font-size: 26px; font-weight: 750; }
.donut-sub { fill: var(--muted); font-size: 11px; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; flex: 1; min-width: 140px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .lg-label { color: var(--ink-2); flex: 1; }
.legend .lg-val { color: var(--muted); font-weight: 600; }
.funnel { display: flex; flex-direction: column; gap: 12px; }
.fn-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.fn-name { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.fn-conv { font-size: 11px; font-weight: 700; color: var(--muted); }
.fn-bar-track { background: var(--line-2); border-radius: 8px; overflow: hidden; }
.fn-bar { height: 30px; border-radius: 8px; display: flex; align-items: center; padding: 0 10px; transition: width .4s ease; min-width: 42px; }
.fn-count { color: #fff; font-weight: 700; font-size: 13px; text-shadow: 0 1px 2px rgba(0,0,0,.2); }

/* ---------- segmented control ---------- */
.seg { display: inline-flex; background: var(--line-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--ink-2); padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 12px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- Kanban ---------- */
.board-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 14px; scroll-snap-type: x proximity; }
.column { flex: 0 0 288px; width: 288px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 210px); scroll-snap-align: start; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 12px 13px; border-bottom: 1px solid var(--line); position: sticky; top: 0; }
.col-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.col-name { font-weight: 700; font-size: 13px; }
.col-count { margin-left: auto; background: var(--line-2); color: var(--ink-2); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.col-sum { font-size: 11px; color: var(--muted); padding: 0 13px 8px; margin-top: -2px; }
.cards { padding: 10px; display: flex; flex-direction: column; gap: 9px; overflow-y: auto; flex: 1; min-height: 60px; }
.cards.drop-hover { background: var(--accent-soft); border-radius: 10px; }
.col-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 16px 8px; border: 1px dashed var(--line); border-radius: 10px; }

.lead-card {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--stage, var(--muted));
  border-radius: 11px; padding: 11px 12px; box-shadow: var(--shadow); cursor: grab; transition: transform .1s, box-shadow .1s;
}
.lead-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.lead-card.dragging { opacity: .5; }
.lead-card.dimmed { opacity: .62; }
.lc-top { display: flex; align-items: flex-start; gap: 8px; }
.lc-company { font-weight: 700; font-size: 13.5px; line-height: 1.25; flex: 1; }
.lc-dor { font-size: 11.5px; color: var(--ink-2); margin-top: 3px; display: flex; align-items: center; gap: 5px; }
.lc-meta { display: flex; align-items: center; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
.lc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line-2); }
.lc-na { font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; overflow: hidden; }
.lc-na .na-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.wa-btn { color: var(--good); border: 1px solid var(--line); background: var(--surface); width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.wa-btn:hover { background: var(--good); color: #fff; border-color: transparent; }

/* badges */
.icp-badge { --c: var(--muted); font-size: 11px; font-weight: 800; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); padding: 1px 7px; border-radius: 7px; line-height: 1.5; flex: none; }
.chip { font-size: 11px; font-weight: 600; color: var(--ink-2); background: var(--line-2); padding: 2px 8px; border-radius: 7px; display: inline-flex; align-items: center; gap: 4px; }
.chip.temp-quente { color: var(--bad); background: var(--bad-soft); }
.chip.temp-morno { color: var(--warn); background: var(--warn-soft); }
.chip.temp-frio { color: var(--info); background: rgba(14,165,233,.14); }
.aging { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.aging.warm { background: var(--warn); } .aging.cold { background: var(--bad); }
.na-overdue { color: var(--bad); } .na-today { color: var(--warn); } .na-future { color: var(--good); } .na-none { color: var(--muted); }

/* ---------- Hoje ---------- */
.today-cols { display: grid; grid-template-columns: 1fr; gap: 16px; }
.today-cols > * { min-width: 0; }
.today-section .panel-title .count { background: var(--line-2); color: var(--ink-2); font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 10px; }
.today-section.urgent .panel-title { color: var(--bad); }
.today-list { display: flex; flex-direction: column; gap: 8px; }
.today-item { display: flex; align-items: center; gap: 11px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.today-item .ti-main { flex: 1; min-width: 0; }
.ti-company { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 7px; }
.ti-action { font-size: 12px; color: var(--ink-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ti-when { font-size: 11px; font-weight: 700; }
.ti-actions { display: flex; gap: 6px; flex: none; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .es-emoji { font-size: 34px; }
.empty-state h3 { color: var(--ink); margin: 10px 0 4px; font-size: 16px; }

/* ---------- table ---------- */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface); }
table.data th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 11px 13px; border-bottom: 1px solid var(--line); font-weight: 700; white-space: nowrap; }
table.data td { padding: 11px 13px; border-bottom: 1px solid var(--line-2); }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--surface-2); cursor: pointer; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(15,23,42,.5); backdrop-filter: blur(3px); display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.overlay.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%; max-width: 620px; animation: pop .18s ease; }
.modal.narrow { max-width: 420px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; }
.modal-head .mh-main { flex: 1; min-width: 0; }
.modal-title { font-size: 17px; font-weight: 750; letter-spacing: -.01em; display: flex; align-items: center; gap: 9px; }
.modal-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.modal-body { padding: 6px 20px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 9px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.modal-foot .grow { flex: 1; }

/* stage stepper */
.stepper { display: flex; gap: 5px; padding: 0 20px 14px; overflow-x: auto; }
.step { flex: 1; min-width: 44px; height: 5px; border-radius: 4px; background: var(--line); }
.step.done { background: var(--accent); }
.step.current { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stage-picker { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }

/* forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field label .req { color: var(--bad); }
.field .fhint { font-size: 11px; color: var(--muted); font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); font-size: 13px; font-family: inherit; transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field textarea { resize: vertical; min-height: 62px; }
.field input.invalid, .field select.invalid { border-color: var(--bad); }
.field-section { grid-column: 1/-1; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 8px 0 -2px; display: flex; align-items: center; gap: 8px; }
.field-section::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.switch { display: inline-flex; align-items: center; gap: 9px; }
.switch input { width: auto; }

/* interactions log */
.notes { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.note-item { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 11px; font-size: 12.5px; }
.note-time { font-size: 10.5px; color: var(--muted); margin-bottom: 2px; }
.note-add { display: flex; gap: 8px; margin-top: 8px; }
.note-add input { flex: 1; }

/* login */
.login-card { max-width: 380px; margin: 8vh auto; }
.login-card .brand { justify-content: center; margin-bottom: 6px; }

/* toast */
.toast-wrap { position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg); animation: pop .18s ease; }
.toast.good { background: var(--good); color: #fff; }
.toast.bad { background: var(--bad); color: #fff; }

/* misc */
.pill-line { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.hide { display: none !important; }
@media (max-width: 520px) { .hide-sm { display: none; } }
.row { display: flex; align-items: center; gap: 10px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line-2); }
.settings-row:last-child { border-bottom: 0; }
.settings-row .sr-main { flex: 1; }
.settings-row .sr-title { font-weight: 600; }
.settings-row .sr-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.catalog-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.catalog-item .ci-ticket { color: var(--good); font-weight: 700; white-space: nowrap; }

/* mobile bottom nav */
.bottomnav { display: none; }

@media (max-width: 860px) {
  .topbar { padding: 9px 14px; }
  .brand-tag { display: none; }
  .nav.desktop-nav { display: none; }
  .content { padding: 16px 12px 96px; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px);
    border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .bottomnav .nav-item { flex: 1; flex-direction: column; gap: 2px; font-size: 10px; padding: 6px 2px; border-radius: 10px; }
  .bottomnav .nav-item .nav-ico { font-size: 19px; }
  .form-grid { grid-template-columns: 1fr; }
  .view-title { font-size: 19px; }
  .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .column { flex-basis: 82vw; width: 82vw; max-height: none; }
  .board { scroll-snap-type: x mandatory; }
}
@media (min-width: 900px) {
  .today-cols { grid-template-columns: 1fr 1fr; }
  .today-cols .full-col { grid-column: 1 / -1; }
}
