/* ============================================================
   CRM Comercial Inteligente — tema visual 2.0
   ============================================================ */
:root {
  /* identidade: vinho #780116 · creme #efede6 · âmbar #f7b538 */
  --primary: #780116; --primary-dark: #56010f; --primary-light: #f0d5d3; --primary-soft: #f7ebe7;
  --primary-grad: #96122b;
  --accent: #f7b538; --accent-dark: #d99a15; --accent-soft: #fdf0d5;
  --good: #0a7a2f; --good-bg: #e6f2e4; --bad: #c92f2f; --bad-bg: #f9e8e4;
  --warn: #a97a00; --warn-bg: #fdf0d5;
  --ink: #26190f; --sec: #5c5242; --muted: #93897a;
  --surface: #faf8f2; --page: #efede6; --border: #ded9c9; --border-strong: #c9c2ae;
  --sidebar-bg: #40020c; --sidebar-bg2: #5c0313; --sidebar-ink: #d9b8ac;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(64, 25, 5, .05), 0 4px 16px rgba(64, 25, 5, .05);
  --shadow-lg: 0 8px 24px rgba(64, 25, 5, .13);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body { font-family: var(--font); background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
#app { height: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
h3 { font-size: 12.5px; font-weight: 600; color: var(--sec); margin-bottom: 14px; text-transform: uppercase; letter-spacing: .06em; }
.ic { vertical-align: -3px; flex: none; }

/* ---------- inputs ---------- */
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 12px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
textarea { width: 100%; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--sec); font-weight: 500; }
label.f input, label.f select, label.f textarea { font-weight: 400; }

/* ---------- botões ---------- */
.btn { font: inherit; font-weight: 600; border: none; border-radius: var(--radius-sm); padding: 9px 16px; cursor: pointer; transition: all .15s; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; justify-content: center; }
.btn-primary { background: linear-gradient(180deg, var(--primary-grad), var(--primary)); color: #fff; box-shadow: 0 1px 2px rgba(16,24,40,.15), inset 0 1px 0 rgba(255,255,255,.15); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--surface); color: var(--sec); border: 1px solid var(--border-strong); }
.btn-ghost:hover { color: var(--ink); border-color: var(--muted); }
.btn-whats { background: #17a06e; color: #fff; }
.btn-whats:hover { filter: brightness(.93); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-logout { padding: 8px 10px; }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--muted); padding: 5px 6px; border-radius: 8px; display: inline-flex; align-items: center; transition: all .12s; }
.icon-btn:hover { background: var(--page); color: var(--ink); }
.icon-btn.ib-whats:hover { color: #17a06e; background: #e6f6f0; }
.icon-btn.ib-danger:hover { color: var(--bad); background: var(--bad-bg); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(1100px 600px at 15% -10%, #6b0a1e 0%, #40020c 55%, #2a0107 100%); padding: 20px; }
.login-card { background: var(--surface); border-radius: 20px; padding: 40px 34px; width: 100%; max-width: 400px; box-shadow: 0 24px 80px rgba(0,0,0,.45); display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 20px; text-align: center; letter-spacing: -.02em; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-top: -8px; }
.login-logo { width: 58px; height: 58px; border-radius: 16px; background: linear-gradient(135deg, var(--primary-grad), var(--primary-dark)); color: #fff; font-weight: 800; font-size: 22px; display: flex; align-items: center; justify-content: center; margin: 0 auto; box-shadow: 0 8px 20px rgba(120,1,22,.45); }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--sec); }
.login-demo { background: var(--primary-soft); border: 1px solid var(--primary-light); border-radius: 12px; padding: 12px 14px; font-size: 12px; color: var(--sec); display: flex; flex-direction: column; gap: 3px; }
.login-demo strong { color: var(--primary-dark); }

/* ---------- shell ---------- */
.shell { display: flex; height: 100vh; }
.sidebar { width: 236px; flex: none; background: linear-gradient(180deg, var(--sidebar-bg2), var(--sidebar-bg) 40%); color: var(--sidebar-ink); display: flex; flex-direction: column; padding: 18px 14px 14px; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand-logo { width: 36px; height: 36px; flex: none; border-radius: 10px; background: linear-gradient(135deg, #f8c05c, var(--accent-dark)); color: #40020c; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.brand-name { font-weight: 700; color: #fff; font-size: 13.5px; line-height: 1.25; letter-spacing: -.01em; }
.sidebar nav { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 11px; color: var(--sidebar-ink); padding: 9px 12px; border-radius: 10px; font-weight: 500; font-size: 13.5px; transition: all .12s; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.active { background: linear-gradient(180deg, #f8c05c, var(--accent)); color: #40020c; box-shadow: 0 4px 12px rgba(0,0,0,.25); font-weight: 600; }
.nav-icon { display: inline-flex; opacity: .9; }
.nav-badge { margin-left: auto; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 1px 7px; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.sidebar-foot .btn-ghost { background: transparent; color: var(--sidebar-ink); border-color: rgba(255,255,255,.18); }
.sidebar-foot .btn-ghost:hover { color: #fff; border-color: rgba(255,255,255,.4); }
.user-chip { display: flex; align-items: center; gap: 9px; min-width: 0; }
.avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; background: linear-gradient(135deg, #f8c05c, var(--accent-dark)); color: #40020c; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.user-nome { font-size: 12.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 108px; }
.user-perfil { font-size: 11px; color: var(--sidebar-ink); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 26px; background: var(--surface); border-bottom: 1px solid var(--border); }
.hamburger { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink); }
.gsearch { position: relative; flex: 1; max-width: 460px; }
.gsearch-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); display: inline-flex; pointer-events: none; }
.gsearch input { width: 100%; background: var(--page); border-color: transparent; padding-left: 36px; border-radius: 99px; }
.gsearch input:focus { background: var(--surface); border-color: var(--primary); }
#gsearch-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); z-index: 60; overflow: hidden; }
#gsearch-results:empty { display: none; }
.gs-item { padding: 10px 14px; cursor: pointer; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gs-item:hover { background: var(--primary-soft); }
.content { flex: 1; overflow-y: auto; padding: 24px 26px 44px; }

/* ---------- páginas ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.filters-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card-wide { grid-column: 1 / -1; }
.onboard { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; background: linear-gradient(120deg, var(--primary-soft), var(--surface) 60%); border-color: var(--primary-light); }

/* ---------- KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: flex-start; transition: transform .12s, box-shadow .12s; }
.kpi:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.kpi-icon { width: 38px; height: 38px; flex: none; border-radius: 11px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.kpi-good .kpi-icon { background: var(--good-bg); color: var(--good); }
.kpi-bad .kpi-icon { background: var(--bad-bg); color: var(--bad); }
.kpi-txt { min-width: 0; }
.kpi-label { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 23px; font-weight: 700; margin-top: 1px; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { font-size: 11.5px; color: var(--muted); }
.kpi-good .kpi-value { color: var(--good); }
.kpi-bad .kpi-value { color: var(--bad); }

/* ---------- gráficos ---------- */
.chart-empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 13px; }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 150px) 1fr auto; align-items: center; gap: 10px; }
.hbar-label { font-size: 12.5px; color: var(--sec); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { background: var(--page); border-radius: 5px; height: 16px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 0 5px 5px 0; min-width: 2px; }
.hbar-value { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar-value small { color: var(--muted); font-weight: 400; }
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut-legend { display: flex; flex-direction: column; gap: 7px; min-width: 150px; flex: 1; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3.5px; flex: none; }
.legend-name { color: var(--sec); flex: 1; }
.legend-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.legend-val small { color: var(--muted); font-weight: 400; }

/* ---------- tabelas ---------- */
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 11px 14px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); white-space: nowrap; background: #f4f1e7; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; transition: background .1s; }
tbody tr:hover { background: var(--primary-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.td-sub { font-size: 11.5px; color: var(--muted); }
.row-actions { white-space: nowrap; }
.text-bad { color: var(--bad); font-weight: 600; }

/* ---------- badges / tags / temperatura ---------- */
.badge { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 99px; padding: 2.5px 10px; white-space: nowrap; }
.badge-good { background: var(--good-bg); color: var(--good); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-muted { background: var(--page); color: var(--sec); border: 1px solid var(--border); }
.tag { display: inline-block; font-size: 10.5px; font-weight: 600; background: var(--primary-soft); color: var(--primary-dark); border-radius: 6px; padding: 1.5px 7px; margin-left: 5px; }
.temp { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--sec); white-space: nowrap; }
.temp i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.temp-frio i { background: #2a78d6; } .temp-morno i { background: var(--accent-dark); } .temp-quente i { background: var(--bad); }
.temp-quente { color: var(--bad); }
.alert-inline { font-size: 11px; color: var(--bad); font-weight: 600; margin-top: 4px; }

/* ---------- kanban ---------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 18px; align-items: flex-start; }
.kcol { flex: none; width: 272px; background: #e6e2d4; border-radius: var(--radius); max-height: calc(100vh - 190px); display: flex; flex-direction: column; border: 1px solid var(--border); }
.kcol.drop { outline: 2px dashed var(--primary); outline-offset: -2px; }
.kcol-head { padding: 11px 14px 9px; border-radius: var(--radius) var(--radius) 0 0; background: var(--surface); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; border-bottom: 1px solid var(--border); }
.kcol-title { font-weight: 700; font-size: 13px; letter-spacing: -.01em; }
.kcol-count { background: var(--page); border: 1px solid var(--border); color: var(--sec); font-size: 11px; font-weight: 700; border-radius: 99px; padding: 0 8px; }
.kcol-sum { width: 100%; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.kcol-body { padding: 10px; display: flex; flex-direction: column; gap: 9px; overflow-y: auto; min-height: 60px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 13px; cursor: grab; box-shadow: 0 1px 2px rgba(16,24,40,.06); font-size: 12.5px; transition: box-shadow .12s, transform .12s; }
.kcard:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.kcard:active { cursor: grabbing; }
.kcard-alert { border-left: 3px solid var(--bad); }
.kcard-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.kcard-prod { color: var(--sec); font-weight: 500; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kcard-line { color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.kcard-valor { justify-content: space-between; }
.kcard-valor strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.kcard-origem { font-size: 10.5px; font-weight: 600; background: var(--page); border: 1px solid var(--border); border-radius: 99px; padding: 1px 8px; color: var(--sec); }
.kcard-prox { display: inline-flex; align-items: center; gap: 3px; margin-left: auto; font-size: 11px; }
.mini-avatar { width: 18px; height: 18px; flex: none; border-radius: 50%; background: var(--primary-light); color: var(--primary-dark); font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.kcard-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 9px; padding-top: 7px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); }

/* ---------- modal / painel ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(13, 20, 33, .5); backdrop-filter: blur(2px); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--surface); border-radius: 18px; padding: 26px; width: 100%; max-width: 680px; max-height: 90vh; overflow-y: auto; box-shadow: 0 24px 70px rgba(0,0,0,.35); animation: pop .18s ease; }
@keyframes pop { from { transform: scale(.97); opacity: .6; } to { transform: none; opacity: 1; } }
.modal h3 { font-size: 17px; text-transform: none; letter-spacing: -.01em; color: var(--ink); margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.f-span { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.panel-backdrop { justify-content: flex-end; padding: 0; }
.panel { background: var(--surface); width: 580px; max-width: 100%; height: 100%; overflow-y: auto; box-shadow: -16px 0 48px rgba(0,0,0,.25); display: flex; flex-direction: column; animation: slideIn .2s ease; }
@keyframes slideIn { from { transform: translateX(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 22px 22px 12px; gap: 10px; }
.panel-title { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.panel-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.panel-close { font-size: 16px; }
.panel-tools { display: flex; gap: 8px; padding: 0 22px 14px; flex-wrap: wrap; align-items: center; }
.panel-tools select { font-size: 13px; padding: 6px 10px; max-width: 200px; }
.panel-tabs { display: flex; gap: 2px; padding: 0 22px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.ptab { background: none; border: none; font: inherit; font-weight: 600; font-size: 13px; color: var(--muted); padding: 10px 12px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; transition: color .12s; }
.ptab:hover { color: var(--ink); }
.ptab.active { color: var(--primary); border-bottom-color: var(--primary); }
.panel-body { padding: 18px 22px 32px; flex: 1; }

.dl { display: flex; flex-direction: column; }
.dl > div { display: grid; grid-template-columns: 172px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.dl > div:last-child { border-bottom: none; }
.dl dt { color: var(--muted); font-weight: 500; }
.obs-box { background: var(--page); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-top: 12px; font-size: 13px; }
.obs-box strong { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; display: block; margin-bottom: 3px; }

/* ---------- timeline ---------- */
.quick-note { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-note input[name="texto"], .quick-note input[name="produto"] { flex: 1; min-width: 160px; }
.timeline { margin-top: 16px; display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.tl-item:last-child { border-bottom: none; }
.tl-icon { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--page); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 14px; }
.tl-meta { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.tl-body { font-size: 13px; min-width: 0; }

/* ---------- tarefas ---------- */
.task-mini-list { display: flex; flex-direction: column; gap: 7px; }
.task-mini { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); font-size: 12.5px; flex-wrap: wrap; cursor: default; }
.task-mini.atrasada { border-left: 3px solid var(--bad); }
.task-mini.concluida { opacity: .55; }
.task-mini.concluida .task-mini-title { text-decoration: line-through; }
.task-mini-date { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; font-size: 11.5px; }
.task-mini-title { font-weight: 600; flex: 1; min-width: 140px; }
.task-mini-ref { color: var(--muted); }
input[type="checkbox"] { accent-color: var(--primary); width: 15px; height: 15px; }

/* ---------- necessidade ---------- */
.need-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; background: var(--surface); box-shadow: var(--shadow); }
.need-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.need-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; font-size: 12.5px; color: var(--sec); }
.need-grid b { color: var(--muted); font-weight: 600; }

/* ---------- config ---------- */
.chip-list { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); border-radius: 99px; padding: 4.5px 12px; font-size: 12.5px; font-weight: 500; background: var(--surface); }
.chip button { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 11px; padding: 0; }
.chip button:hover { color: var(--bad); }
.chip-off { color: var(--muted); border-style: dashed; background: transparent; }
.chip-add { display: inline-flex; gap: 6px; }
.chip-add input { padding: 5px 11px; font-size: 12.5px; width: 180px; }
.perm-list { padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--sec); }

/* ---------- metas ---------- */
.meta-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; flex-wrap: wrap; }
.meta-nome { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; min-width: 140px; }
.meta-track { flex: 1; min-width: 140px; height: 14px; background: var(--page); border-radius: 7px; overflow: hidden; }
.meta-fill { height: 100%; background: linear-gradient(90deg, #f8c05c, var(--accent-dark)); border-radius: 7px; min-width: 3px; transition: width .3s; }
.meta-fill.ok { background: linear-gradient(90deg, #16a34a, var(--good)); }
.meta-val { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.meta-val small { color: var(--muted); font-weight: 400; }

/* ---------- conexões (API/webhooks) ---------- */
.integ-block { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-top: 12px; background: var(--surface); }
.integ-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; font-size: 14px; }
.hook-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 7px 0; }
.hook-label { font-size: 12px; font-weight: 600; color: var(--sec); min-width: 140px; }
.hook-url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; background: var(--page); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; word-break: break-all; flex: 1; min-width: 220px; color: var(--ink); }
.hook-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--sec); font-weight: 500; cursor: pointer; }
.integ-help { margin-top: 8px; font-size: 12.5px; color: var(--sec); }
.integ-help summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.integ-help ol { padding-left: 20px; margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.hook-pre { background: var(--page); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: 11.5px; overflow-x: auto; margin-top: 8px; }

/* ---------- chat da equipe ---------- */
.chat-card { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 320px; padding: 0; overflow: hidden; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.chat-dia { text-align: center; font-size: 11px; color: var(--muted); margin: 8px 0 2px; }
.chat-msg { max-width: 72%; align-self: flex-start; }
.chat-msg.own { align-self: flex-end; text-align: right; }
.chat-meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.chat-bubble { display: inline-block; background: var(--page); border: 1px solid var(--border); border-radius: 14px 14px 14px 4px; padding: 9px 14px; font-size: 13.5px; text-align: left; word-break: break-word; }
.chat-msg.own .chat-bubble { background: var(--primary-soft); border-color: var(--primary-light); border-radius: 14px 14px 4px 14px; }
.chat-form { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface); }

/* ---------- telefonia (widget flutuante de chamada) ---------- */
.tel-widget { position: fixed; bottom: 20px; right: 20px; z-index: 400; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 16px 18px; display: flex; align-items: center; gap: 16px; min-width: 280px; animation: pop .18s ease; }
.tel-incoming { border-color: var(--accent); box-shadow: 0 8px 28px rgba(247, 181, 56, .35); }
.tel-active { border-color: var(--primary); }
.tel-pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); flex: none; animation: telpulse 1.1s infinite; }
@keyframes telpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(247,181,56,.55); } 70% { box-shadow: 0 0 0 10px rgba(247,181,56,0); } }
.tel-info { flex: 1; min-width: 0; }
.tel-info strong { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tel-numero { font-size: 16px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tel-sub { font-size: 12px; color: var(--muted); }
.tel-actions { display: flex; gap: 8px; flex: none; }
.tel-btn { border: none; border-radius: 10px; padding: 9px 14px; font-weight: 700; font-size: 13px; cursor: pointer; background: var(--page); color: var(--ink); }
.tel-btn-ok { background: var(--good); color: #fff; }
.tel-btn-bad { background: var(--bad); color: #fff; }

/* ---------- whatsapp (caixa de entrada) ---------- */
.zap-wrap { display: flex; height: calc(100vh - 170px); min-height: 380px; padding: 0; overflow: hidden; }
.zap-list { width: 300px; flex: none; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--surface); }
.zap-search { margin: 12px; width: calc(100% - 24px); }
.zap-items { flex: 1; overflow-y: auto; }
.zap-item { padding: 11px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; }
.zap-item:hover { background: var(--page); }
.zap-item.active { background: var(--primary-soft); border-left: 3px solid var(--primary); padding-left: 13px; }
.zap-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.zap-item-top strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zap-item-time { font-size: 11px; color: var(--muted); flex: none; }
.zap-item-prev { font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.zap-item-prev em { color: var(--sec); font-style: normal; }
.zap-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex: none; }
.zap-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--page); }
.zap-panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 18px; background: var(--surface); border-bottom: 1px solid var(--border); }
.zap-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13.5px; }
.zap-hora { font-size: 10px; color: var(--muted); margin-top: 3px; text-align: right; }
.zap-alert { background: var(--bad-bg); border: 1px solid #ecc9c0; color: var(--bad); border-radius: 10px; padding: 10px 16px; font-size: 13px; margin-bottom: 14px; }
.zap-alert a { color: var(--bad); text-decoration: underline; }
.zap-panel .chat-msgs { background: var(--page); }
.zap-panel .chat-form { border-top: 1px solid var(--border); }
@media (max-width: 780px) {
  .zap-wrap { flex-direction: column; height: calc(100vh - 150px); }
  .zap-list { width: 100%; max-height: 40%; border-right: none; border-bottom: 1px solid var(--border); }
}

/* ---------- propostas ---------- */
.prop-item { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.prop-item input[name="itDesc"] { flex: 1; min-width: 140px; }

/* ---------- contatos B2B ---------- */
.contato-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.contato-row:last-of-type { border-bottom: none; }

/* ---------- toast ---------- */
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #2b1d12; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: all .25s; }
.toast.show { opacity: 1; transform: none; }
.toast-bad { background: var(--bad); }

/* ---------- responsivo ---------- */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 200; transform: translateX(-100%); transition: transform .2s ease; width: 254px; }
  .sidebar.open { transform: none; box-shadow: 20px 0 50px rgba(0,0,0,.4); }
  .hamburger { display: block; }
  .content { padding: 16px 14px 44px; }
  .topbar { padding: 10px 14px; }
  .topbar .btn-primary { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .dl > div { grid-template-columns: 1fr; gap: 1px; }
  .kcol { width: 246px; }
  .panel { width: 100%; }
  .kpi-value { font-size: 19px; }
}
@media (max-width: 560px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .filters-row select, .filters-row input { flex: 1 1 45%; min-width: 0; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .donut-wrap { justify-content: center; }
}

/* mobile 2.0 */
@media (max-width: 560px) {
  .prop-item { flex-wrap: wrap; }
  .prop-item input[name="itDesc"] { flex: 1 1 100%; }
  .hook-label { min-width: 100%; }
  .integ-head { font-size: 13px; }
  .chat-card { height: calc(100dvh - 190px); }
  .chat-msg { max-width: 88%; }
  .panel-tools .btn, .panel-tools select { flex: 1 1 auto; }
  .contato-row { flex-wrap: wrap; }
  .need-grid { grid-template-columns: 1fr; }
  .quick-note button { flex: 1 1 auto; }
  .modal { padding: 18px; border-radius: 14px; }
  .panel-head { padding: 16px 14px 10px; }
  .panel-tools { padding: 0 14px 12px; }
  .panel-tabs { padding: 0 8px; }
  .panel-body { padding: 14px 14px 28px; }
}
/* área segura do iPhone (notch) no app instalado */
@supports (padding: env(safe-area-inset-top)) {
  .topbar { padding-top: calc(12px + env(safe-area-inset-top)); }
  .sidebar { padding-top: calc(18px + env(safe-area-inset-top)); }
}

/* ---- janela de detalhe do atendimento (Atendimentos) ---- */
.tk-timeline { display: flex; flex-direction: column; gap: 10px; }
.tk-evento { display: flex; gap: 10px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.tk-evento-ic { flex: 0 0 auto; width: 22px; text-align: center; }
.tk-secao { margin: 4px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-bottom: 20px; }
.tk-campo { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.tk-campo-val { display: flex; align-items: center; justify-content: space-between; gap: 6px; word-break: break-word; }
.tk-hist { display: flex; flex-direction: column; gap: 8px; }
.tk-hist-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.tk-hist-item:hover { border-color: var(--primary); }

/* ---- produtos de interesse do lead (vários, com preço e estoque) ---- */
.text-warn { color: var(--warn); font-weight: 600; }
.prod-lista { display: flex; flex-direction: column; gap: 6px; }
.prod-item { display: flex; align-items: center; gap: 8px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.prod-item-info { flex: 1; min-width: 0; }
.prod-item-info strong { display: block; word-break: break-word; }
.prod-qtd { width: 62px; flex: 0 0 auto; text-align: center; }
.prod-add { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.prod-add select { flex: 1 1 220px; }
.prod-add input { flex: 1 1 180px; }
@media (max-width: 700px) { .prod-add select, .prod-add input { flex-basis: 100%; } }

/* ---- busca de produto no formulário do lead (catálogo grande, vindo do ERP) ---- */
.prod-busca-wrap { position: relative; margin-top: 8px; }
.prod-busca-wrap input { width: 100%; }
.prod-resultados { display: flex; flex-direction: column; max-height: 260px; overflow-y: auto; margin-top: 4px; }
.prod-resultados:not(:empty) { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.prod-res { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%;
  padding: 8px 10px; background: none; border: 0; border-bottom: 1px solid var(--border);
  text-align: left; cursor: pointer; font: inherit; color: inherit; }
.prod-res:last-child { border-bottom: 0; }
.prod-res:hover { background: var(--primary-soft); }
.prod-res-nome { font-weight: 600; }
.prod-res-vazio { padding: 8px 10px; color: var(--muted); font-size: 13px; }

/* ---- painéis de setor (KDS): tela fica aberta o dia todo, precisa ler de longe ---- */
.kds-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.kds-head h2 { margin: 0; }
.kds-hora { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--primary); }
.kds-board { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; }
.kds-col { flex: 1 1 0; min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; }
.kds-col-head { display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 12px; border-top: 4px solid var(--border-strong); border-radius: 12px 12px 0 0;
  font-weight: 700; text-transform: uppercase; letter-spacing: .03em; font-size: 14px; }
.kds-badge { background: var(--page); border-radius: 999px; padding: 1px 9px; font-size: 13px; }
.kds-cards { display: flex; flex-direction: column; gap: 8px; padding: 8px; max-height: calc(100vh - 210px); overflow-y: auto; }
.kds-card { background: var(--page); border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.kds-card-top { display: flex; justify-content: space-between; align-items: center; font-size: 17px; }
.kds-tempo { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.kds-cliente { font-weight: 700; font-size: 16px; margin: 2px 0 6px; }
.kds-itens { display: flex; flex-direction: column; gap: 2px; font-size: 15px; line-height: 1.35; }
.kds-rodape { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-weight: 700; }
.kds-outro { margin-top: 2px; }
.kds-acoes { display: flex; gap: 6px; margin-top: 8px; }
.kds-avancar { flex: 1; }
.kds-vazio { text-align: center; color: var(--muted); padding: 14px 0; }
/* parado tempo demais: o cartão precisa saltar aos olhos do outro lado da sala */
.kds-card.kds-alerta { border-color: var(--bad); box-shadow: 0 0 0 2px color-mix(in srgb, var(--bad) 22%, transparent); }
.kds-card.kds-alerta .kds-tempo { color: var(--bad); }
@media (max-width: 900px) { .kds-col { min-width: 200px; } .kds-hora { font-size: 22px; } }
