/* ===========================================================================
   CRM Cinthia — Terapeuta 20k
   App shell com sidebar. Paleta creme / dourado / verde, refinada.
   Sem libs externas (só a fonte Inter/Sora via Google Fonts).
   ======================================================================== */

:root {
  /* marca */
  --gold:        #b08738;
  --gold-deep:   #8a6a2b;
  --gold-soft:   #cdb079;
  --green:       #1f6f5c;
  --green-deep:  #16553f;
  --green-ink:   #0f3a30;

  /* superfícies */
  --bg:          #eef0ec;
  --bg-warm:     #f3eee4;
  --surface:     #ffffff;
  --surface-2:   #f7f4ed;
  --surface-3:   #f0ebe0;

  /* texto */
  --ink:         #24221d;
  --ink-2:       #5d574c;
  --ink-3:       #938b7c;

  /* traços */
  --line:        #e7e0d0;
  --line-soft:   #f0eadd;
  --danger:      #bb392f;

  /* sombras em camadas */
  --sh-1: 0 1px 2px rgba(40,33,18,.05), 0 1px 3px rgba(40,33,18,.06);
  --sh-2: 0 4px 10px rgba(40,33,18,.07), 0 2px 4px rgba(40,33,18,.05);
  --sh-3: 0 18px 50px rgba(30,24,12,.20);
  --sh-card: 0 1px 2px rgba(40,33,18,.04), 0 6px 16px rgba(40,33,18,.06);

  --r-sm: 9px;
  --r:    13px;
  --r-lg: 18px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-head: "Sora", var(--font);

  --side-w: 248px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
body.modal-open { overflow: hidden; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--ink); }
svg { width: 100%; height: 100%; fill: currentColor; }

/* ===================== logo ===================== */
.logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 54px; height: 54px; border-radius: 16px;
  background: linear-gradient(140deg, var(--gold-soft), var(--gold) 55%, var(--gold-deep));
  color: #fff; font-family: var(--font-head); font-weight: 700; font-size: 19px;
  letter-spacing: .5px; box-shadow: inset 0 1px 1px rgba(255,255,255,.4), var(--sh-2);
}
.logo-mark.sm { width: 40px; height: 40px; border-radius: 12px; font-size: 15px; }

/* ===================== LOGIN ===================== */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 500px at 12% -5%, rgba(31,111,92,.16), transparent 55%),
    radial-gradient(900px 500px at 95% 105%, rgba(176,135,56,.18), transparent 55%),
    var(--bg-warm);
}
.login-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; box-shadow: var(--sh-3);
  padding: 40px 34px 26px; width: 100%; max-width: 384px; text-align: center;
}
.login-brand { margin-bottom: 26px; }
.login-brand h1 { margin: 16px 0 4px; font-family: var(--font-head); font-size: 23px; color: var(--green-ink); }
.login-brand p { margin: 0; color: var(--ink-3); font-size: 13px; }
#login-form { display: flex; flex-direction: column; gap: 11px; text-align: left; }
#login-form label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
#login-form input {
  padding: 13px 15px; border: 1.5px solid var(--line); border-radius: var(--r);
  background: var(--surface-2); transition: border-color .15s, box-shadow .15s;
}
#login-form input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(176,135,56,.18); }
#login-btn {
  margin-top: 8px; padding: 13px; border-radius: var(--r);
  background: linear-gradient(135deg, var(--green), var(--green-deep));
  color: #fff; font-weight: 600; font-size: 15px; transition: filter .15s, transform .05s;
}
#login-btn:hover { filter: brightness(1.07); }
#login-btn:active { transform: translateY(1px); }
.login-erro { margin: 2px 0 0; color: var(--danger); font-size: 13px; font-weight: 600; }
.login-foot { margin: 20px 0 0; font-size: 12px; color: var(--ink-3); }

/* ===================== SHELL ===================== */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }

/* ===================== SIDEBAR ===================== */
.sidebar {
  background: linear-gradient(180deg, var(--green-ink), #0c2e26 80%);
  color: #e8e3d6; display: flex; flex-direction: column;
  padding: 20px 14px; position: sticky; top: 0; height: 100vh; z-index: 40;
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 22px; }
.side-brand-txt { display: flex; flex-direction: column; line-height: 1.2; }
.side-brand-txt strong { font-family: var(--font-head); font-size: 16px; color: #fff; }
.side-brand-txt span { font-size: 11.5px; color: var(--gold-soft); letter-spacing: .3px; }

.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 11px; color: #cdc6b6;
  font-size: 14px; font-weight: 500; text-align: left; transition: background .14s, color .14s;
}
.nav-item svg { width: 19px; height: 19px; flex: none; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.is-active { background: rgba(176,135,56,.28); color: #fff; box-shadow: inset 0 0 0 1px rgba(205,176,121,.55); }
.nav-item.is-active svg { color: var(--gold-soft); opacity: 1; }
.nav-count {
  margin-left: auto; font-style: normal; font-size: 11.5px; font-weight: 800;
  background: rgba(255,255,255,.2); color: #fff; padding: 1px 8px; border-radius: 999px;
}

.side-foot { border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.side-user { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #b8b1a1; padding: 0 6px; }
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.22); }
.btn-logout {
  display: flex; align-items: center; gap: 9px; justify-content: flex-start;
  padding: 10px 12px; border-radius: 11px; color: #cdc6b6; font-size: 14px; font-weight: 500;
  transition: background .14s, color .14s;
}
.btn-logout svg { width: 18px; height: 18px; opacity: .8; }
.btn-logout:hover { background: rgba(187,57,47,.22); color: #ffd9d4; }

.side-backdrop { display: none; }

/* ===================== MAIN ===================== */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 26px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.btn-menu { display: none; width: 38px; height: 38px; padding: 8px; border-radius: 10px; color: var(--ink-2); }
.btn-menu:hover { background: var(--surface-2); }
.topbar-title { min-width: 0; }
.topbar-title h2 { margin: 0; font-family: var(--font-head); font-size: 20px; color: var(--ink); }
.topbar-title p { margin: 1px 0 0; font-size: 12.5px; color: var(--ink-3); }
.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-select {
  padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 11px; background: var(--surface);
  color: var(--ink-2); font-weight: 500; max-width: 170px;
}
.topbar-select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(176,135,56,.16); }

.search-box { position: relative; display: flex; align-items: center; }
.search-box svg { position: absolute; left: 12px; width: 17px; height: 17px; color: var(--ink-3); pointer-events: none; }
.search-box input {
  width: 248px; max-width: 260px; padding: 10px 14px 10px 36px;
  border: 1.5px solid var(--line); border-radius: 11px; background: var(--surface);
  transition: border-color .15s, box-shadow .15s, width .2s;
}
.search-box input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(176,135,56,.16); }

.btn-primary {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  background: linear-gradient(135deg, var(--green), var(--green-deep));
  color: #fff; padding: 10px 16px; border-radius: 11px; font-weight: 600; font-size: 14px;
  box-shadow: var(--sh-1); transition: filter .15s, transform .05s;
}
.btn-primary svg { width: 17px; height: 17px; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost {
  background: var(--surface); border: 1.5px solid var(--line); color: var(--ink-2);
  padding: 9px 16px; border-radius: 11px; font-weight: 600; font-size: 14px;
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--gold-soft); }
.btn-danger {
  background: var(--surface); color: var(--danger); border: 1.5px solid #e7c4bf;
  padding: 9px 16px; border-radius: 11px; font-weight: 600; font-size: 14px;
}
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.content { padding: 26px; flex: 1; }

/* ===================== DASHBOARD ===================== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--kpi-c, var(--gold));
  border-radius: var(--r-lg); padding: 18px 20px 20px; box-shadow: var(--sh-card); position: relative;
}
.kpi-ico {
  width: 38px; height: 38px; border-radius: 11px; padding: 9px; margin-bottom: 12px;
  color: #fff; background: var(--kpi-c, var(--gold)); box-shadow: var(--sh-1); position: relative; z-index: 1;
}
.kpi-label { display: block; font-size: 11.5px; color: var(--ink-2); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; position: relative; z-index: 1; }
.kpi-value { display: block; font-family: var(--font-head); font-size: 32px; font-weight: 700; line-height: 1.0; margin-top: 6px; position: relative; z-index: 1; }
.kpi-sub { display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 3px; font-weight: 500; position: relative; z-index: 1; }
.kpi-sub b { color: var(--green-deep); }

.panel-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 16px; margin-top: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px 22px; box-shadow: var(--sh-card); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; gap: 10px; }
.panel-head h3 { margin: 0; font-family: var(--font-head); font-size: 15.5px; color: var(--ink); }
.panel-hint { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .4px; }

/* funil */
.funil { display: flex; flex-direction: column; gap: 11px; }
.funil-row { display: grid; grid-template-columns: 116px 1fr 30px; align-items: center; gap: 12px; }
.funil-name { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.funil-name .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.funil-track { height: 12px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.funil-fill { height: 100%; border-radius: 999px; min-width: 4px; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.funil-num { font-size: 13.5px; font-weight: 700; color: var(--ink); text-align: right; }

/* closers */
.closers { display: flex; flex-direction: column; gap: 14px; }
.closer-row { display: flex; flex-direction: column; gap: 6px; }
.closer-top { display: flex; align-items: center; gap: 10px; }
.closer-av {
  width: 30px; height: 30px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--gold), var(--gold-deep));
}
.closer-name { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.closer-stats { margin-left: auto; font-size: 12.5px; color: var(--ink-3); }
.closer-stats b { color: var(--green-deep); }
.closer-track { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.closer-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--green), var(--green-deep)); transition: width .5s; }

/* ===================== PIPELINE (KANBAN) ===================== */
.kanban {
  display: flex; gap: 14px; overflow-x: auto; padding-bottom: 14px; padding-right: 22px;
  scroll-snap-type: x proximity; scroll-padding-left: 4px;
}
.kanban-col {
  flex: 0 0 268px; width: 268px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column;
  max-height: calc(100vh - 168px); scroll-snap-align: start;
}
.kanban-col.drop-hot { outline: 2px dashed var(--gold); outline-offset: -2px; background: #fff7e8; }
.col-head {
  display: flex; align-items: center; gap: 8px; padding: 13px 14px 11px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface-2);
  border-radius: var(--r) var(--r) 0 0; z-index: 1;
}
.col-head .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.col-head h4 { margin: 0; font-size: 13px; font-weight: 700; color: var(--ink); flex: 1; }
.col-count { font-size: 11.5px; font-weight: 700; color: var(--ink-2); background: var(--surface-3); padding: 1px 9px; border-radius: 999px; }
.col-body { padding: 10px; display: flex; flex-direction: column; gap: 9px; overflow-y: auto; flex: 1; }
.col-empty { font-size: 12.5px; color: var(--ink-3); text-align: center; padding: 16px 6px; }

.kanban-card {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--st, var(--gold));
  border-radius: 10px; padding: 12px 14px; box-shadow: var(--sh-1); cursor: grab;
  display: flex; flex-direction: column; gap: 8px; transition: box-shadow .12s, transform .12s;
}
.kanban-card:hover { box-shadow: var(--sh-2); transform: translateY(-1px); }
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: .45; }
.kc-name { font-size: 13.5px; font-weight: 600; color: var(--ink); line-height: 1.25; margin-bottom: 1px; overflow-wrap: anywhere; }
.kc-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.kc-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.kc-pill.closer { border-color: var(--gold-soft); color: var(--gold-deep); font-weight: 600; }
.kc-pill.valor { border-color: #bfe0cf; color: var(--green-deep); font-weight: 700; background: #f1faf4; }
.kc-av { width: 17px; height: 17px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--gold), var(--gold-deep)); }
.kc-det { font-size: 12px; color: var(--ink-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kc-wa { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--green-deep); text-decoration: none; font-weight: 600; }
.kc-wa svg { width: 14px; height: 14px; }
.kc-wa:hover { text-decoration: underline; }

/* ===================== LISTA (TABELA) ===================== */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-card); overflow: hidden; }
.leads-table { width: 100%; border-collapse: collapse; }
.leads-table thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--ink-3); font-weight: 700; padding: 13px 16px; border-bottom: 1px solid var(--line);
  background: var(--surface-2); white-space: nowrap; position: sticky; top: 0;
}
.leads-table thead th[data-sort] { cursor: pointer; user-select: none; }
.leads-table thead th[data-sort]:hover { color: var(--gold-deep); }
.leads-table thead th .arrow { opacity: .55; font-size: 10px; }
.leads-table tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; vertical-align: middle; }
.leads-table tbody tr { cursor: pointer; transition: background .1s; }
.leads-table tbody tr:hover { background: var(--surface-2); }
.leads-table tbody tr:last-child td { border-bottom: none; }
.td-nome { font-weight: 600; color: var(--ink); }
.td-closer { display: inline-flex; align-items: center; gap: 7px; }
.td-muted { color: var(--ink-3); }
.td-valor { font-weight: 700; color: var(--green-deep); }
.table-wa { color: var(--green-deep); text-decoration: none; font-weight: 600; }
.table-wa:hover { text-decoration: underline; }

/* badge de etapa (compartilhado) */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  color: var(--bd-ink, #fff); background: var(--bd-bg, var(--gold));
  white-space: nowrap; letter-spacing: .2px;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.empty-state { text-align: center; color: var(--ink-3); padding: 44px 16px; font-size: 14px; }

/* ===================== MODAL ===================== */
.modal-overlay { position: fixed; inset: 0; background: rgba(24,20,14,.55); display: flex; align-items: flex-start; justify-content: center; padding: 34px 16px; overflow-y: auto; z-index: 60; }
.modal { background: var(--surface); border-radius: 18px; box-shadow: var(--sh-3); width: 100%; max-width: 660px; display: flex; flex-direction: column; animation: pop .16s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.modal-head-title h2 { margin: 0; font-family: var(--font-head); font-size: 18px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-head-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.modal-wa { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: #fff; background: #25a35a; padding: 7px 12px; border-radius: 10px; text-decoration: none; }
.modal-wa svg { width: 16px; height: 16px; }
.modal-wa:hover { filter: brightness(1.06); }
.modal-x { font-size: 26px; line-height: 1; color: var(--ink-3); width: 34px; height: 34px; border-radius: 9px; }
.modal-x:hover { background: var(--surface-2); color: var(--danger); }
.modal-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea {
  padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface-2); transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(176,135,56,.16); }
.field input[readonly] { background: var(--surface-3); color: var(--ink-3); }
.field textarea { resize: vertical; }
.aplic-block { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); padding: 6px 14px; }
.aplic-block summary { cursor: pointer; font-weight: 600; color: var(--gold-deep); font-size: 13px; padding: 8px 0; list-style: none; }
.aplic-block summary::-webkit-details-marker { display: none; }
.aplic-block summary::before { content: "▸ "; }
.aplic-block[open] summary::before { content: "▾ "; }
.aplic-block[open] { padding-bottom: 14px; }
.aplic-block .field-row, .aplic-block .field { margin-top: 12px; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-top: 1px solid var(--line); gap: 12px; }
.modal-foot-right { display: flex; gap: 10px; }

/* ===================== TOAST ===================== */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--green-ink); color: #fff; padding: 12px 22px; border-radius: 12px; box-shadow: var(--sh-3); font-size: 14px; font-weight: 500; z-index: 100; animation: pop .16s ease; }

/* ===================== RESPONSIVO ===================== */
@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .22s ease; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--sh-3); }
  .shell.nav-open .side-backdrop { display: block; position: fixed; inset: 0; background: rgba(20,16,10,.45); z-index: 35; }
  .btn-menu { display: inline-flex; align-items: center; }
}
@media (max-width: 620px) {
  .content { padding: 16px; }
  .topbar { padding: 14px 16px; gap: 10px; }
  .topbar-title p { display: none; }
  .btn-primary span { display: none; }
  .btn-primary { padding: 10px; }
  .search-box input { width: 150px; max-width: 46vw; }
  .kpi-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .kanban { padding-right: 16px; }
  .kanban-col { flex-basis: 84vw; width: 84vw; max-height: calc(100vh - 150px); }
  .modal-foot { flex-direction: column-reverse; align-items: stretch; }
  .modal-foot-right { justify-content: space-between; }
}
